Пример #1
0
static int sr_share_write_word(struct usbnet *dev, int phy, u8 reg,
			       __le16 value)
{
	int ret;

	mutex_lock(&dev->phy_mutex);

	ret = sr_write(dev, SR_EPDR, 2, &value);
	if (ret < 0)
		goto out_unlock;

	sr_write_reg(dev, SR_EPAR, phy ? (reg | EPAR_PHY_ADR) : reg);
	sr_write_reg(dev, SR_EPCR, phy ? (EPCR_WEP | EPCR_EPOS | EPCR_ERPRW) :
		    (EPCR_WEP | EPCR_ERPRW));

	ret = wait_phy_eeprom_ready(dev, phy);
	if (ret < 0)
		goto out_unlock;

	sr_write_reg(dev, SR_EPCR, 0x0);

out_unlock:
	mutex_unlock(&dev->phy_mutex);
	return ret;
}
Пример #2
0
void write_1602a(bool register_select, uint8_t value)
{
    if (register_select)
        PORTD |= _BV(1);        // data register
    else
        PORTD &= ~_BV(1);       // instruction register

    sr_write(value);

    // cycle E
    PORTD |= _BV(0);
    asm volatile("nop\n nop\n nop\n nop"); /* 4 cycles = ~250ns at 16MHz, tDSW is 195ns */
    PORTD &= ~_BV(0);

    _delay_us(37);
}
Пример #3
0
/* write one word to phy or eeprom */
static int sr_share_write_word(struct usbnet *dev, int phy, u8 reg, __le16 value)
{
	int ret, i;

	mutex_lock(&dev->phy_mutex);

	ret = sr_write(dev, EPDR, 2, &value);
	if (ret < 0)
		goto out;

	sr_write_reg(dev, EPAR, phy ? (reg | 0x40) : reg);
	sr_write_reg(dev, EPCR, phy ? 0x1a : 0x12);

	for (i = 0; i < SR_SHARE_TIMEOUT; i++) {
		u8 tmp;

		udelay(1);
		ret = sr_read_reg(dev, EPCR, &tmp);
		if (ret < 0)
			goto out;

		/* ready */
		if ((tmp & 1) == 0)
			break;
	}

	if (i >= SR_SHARE_TIMEOUT) {
		netdev_err(dev->net, "%s write timed out!", phy ? "phy" : "eeprom");
		ret = -EIO;
		goto out;
	}

	sr_write_reg(dev, EPCR, 0x0);

out:
	mutex_unlock(&dev->phy_mutex);
	return ret;
}
Пример #4
0
 void rx_ctrl_clear_cmds(const size_t port) { sr_write(regs::RX_CTRL_CLEAR_CMDS, 0, port); }
Пример #5
0
void NECDSP::write(unsigned addr, uint8 data) {
  if(!debugger_access()) cpu.synchronize_coprocessor();
  if((addr & srmask) == srtest) return sr_write(data);
  if((addr & drmask) == drtest) return dr_write(data);
  if((addr & dpmask) == dptest) return dp_write(addr, data);
}