Exemplo n.º 1
0
//-------------------------------------------------------------------
//rtl_eeprom_write_sc():
//  write one word to a specific address in the eeprom
//-------------------------------------------------------------------
void rtl_eeprom_write_sc(struct rtl8168_private *tp, u16 reg, u16 data)
{
    void __iomem *ioaddr=tp->mmio_addr;
    u8 x;
    int addr_sz = 6;
    int w_dummy_addr = 4;

    if(tp->eeprom_type == EEPROM_TYPE_NONE) {
        return ;
    }

    if (tp->eeprom_type==EEPROM_TYPE_93C46) {
        addr_sz = 6;
        w_dummy_addr = 4;
    } else if (tp->eeprom_type==EEPROM_TYPE_93C56) {
        addr_sz = 8;
        w_dummy_addr = 6;
    }

    x = Cfg9346_EEM1 | Cfg9346_EECS;
    RTL_W8(Cfg9346, x);

    rtl_shift_out_bits(RTL_EEPROM_EWEN_OPCODE, 5, ioaddr);
    rtl_shift_out_bits(reg, w_dummy_addr, ioaddr);
    rtl_stand_by(ioaddr);

    rtl_shift_out_bits(RTL_EEPROM_ERASE_OPCODE, 3, ioaddr);
    rtl_shift_out_bits(reg, addr_sz, ioaddr);
    if (rtl_eeprom_cmd_done(ioaddr) < 0) {
        return;
    }
    rtl_stand_by(ioaddr);

    rtl_shift_out_bits(RTL_EEPROM_WRITE_OPCODE, 3, ioaddr);
    rtl_shift_out_bits(reg, addr_sz, ioaddr);
    rtl_shift_out_bits(data, 16, ioaddr);
    if (rtl_eeprom_cmd_done(ioaddr) < 0) {
        return;
    }
    rtl_stand_by(ioaddr);

    rtl_shift_out_bits(RTL_EEPROM_EWDS_OPCODE, 5, ioaddr);
    rtl_shift_out_bits(reg, w_dummy_addr, ioaddr);

    rtl_eeprom_cleanup(ioaddr);
    RTL_W8(Cfg9346, 0);
}
Exemplo n.º 2
0
//-------------------------------------------------------------------
//rtl_eeprom_write_sc():
//	write one word to a specific address in the eeprom
//-------------------------------------------------------------------
void rtl_eeprom_write_sc(void __iomem *ioaddr, u16 reg, u16 data)
{
	u8 x;
	int addr_sz = 6;
	int w_dummy_addr = 4;

	if (rtl_eeprom_type(ioaddr)) {
		addr_sz = 8;
		w_dummy_addr = 6;
	} else {
		addr_sz = 6;
		w_dummy_addr = 4;
	}

	x = RTL_R8(Cfg9346);
	x &= ~(Cfg9346_EEDI | Cfg9346_EEDO | Cfg9346_EESK);
	x |= Cfg9346_EEM1 | Cfg9346_EECS;
	RTL_W8(Cfg9346, x);

	rtl_shift_out_bits(RTL_EEPROM_EWEN_OPCODE, 5, ioaddr);
	rtl_shift_out_bits(reg, w_dummy_addr, ioaddr);
	rtl_stand_by(ioaddr);

	rtl_shift_out_bits(RTL_EEPROM_ERASE_OPCODE, 3, ioaddr);
	rtl_shift_out_bits(reg, addr_sz, ioaddr);
	if (rtl_eeprom_cmd_done(ioaddr) < 0) {
		return;
	}
	rtl_stand_by(ioaddr);

	rtl_shift_out_bits(RTL_EEPROM_WRITE_OPCODE, 3, ioaddr);
	rtl_shift_out_bits(reg, addr_sz, ioaddr);
	rtl_shift_out_bits(data, 16, ioaddr);
	if (rtl_eeprom_cmd_done(ioaddr) < 0) {
		return;
	}
	rtl_stand_by(ioaddr);

	rtl_shift_out_bits(RTL_EEPROM_EWDS_OPCODE, 5, ioaddr);
	rtl_shift_out_bits(reg, w_dummy_addr, ioaddr);

	rtl_eeprom_cleanup(ioaddr);
}
Exemplo n.º 3
0
int rtl_eeprom_cmd_done(void __iomem *ioaddr)
{
	u8 x;
	int i;

	rtl_stand_by(ioaddr);

	for (i = 0; i < 50000; i++) {
		x = RTL_R8(Cfg9346);

		if (x & Cfg9346_EEDO) {
			udelay(RTL_CLOCK_RATE * 2 * 3);
			return 0;	
		}
		udelay(1);
	}

	return -1;
}