//------------------------------------------------------------------- //rtl_eeprom_read_sc(): // read one word from eeprom //------------------------------------------------------------------- u16 rtl_eeprom_read_sc(void __iomem *ioaddr, u16 reg) { int addr_sz = 6; u8 x; u16 data; if (rtl_eeprom_type(ioaddr)) addr_sz = 8; else addr_sz = 6; 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_READ_OPCODE, 3, ioaddr); rtl_shift_out_bits(reg, addr_sz, ioaddr); data = rtl_shift_in_bits(ioaddr); rtl_eeprom_cleanup(ioaddr); return data; }
//------------------------------------------------------------------- //rtl_eeprom_read_sc(): // read one word from eeprom //------------------------------------------------------------------- u16 rtl_eeprom_read_sc(struct rtl8168_private *tp, u16 reg) { void __iomem *ioaddr=tp->mmio_addr; int addr_sz = 6; u8 x; u16 data; if(tp->eeprom_type == EEPROM_TYPE_NONE) { return -1; } if (tp->eeprom_type==EEPROM_TYPE_93C46) addr_sz = 6; else if (tp->eeprom_type==EEPROM_TYPE_93C56) addr_sz = 8; x = Cfg9346_EEM1 | Cfg9346_EECS; RTL_W8(Cfg9346, x); rtl_shift_out_bits(RTL_EEPROM_READ_OPCODE, 3, ioaddr); rtl_shift_out_bits(reg, addr_sz, ioaddr); data = rtl_shift_in_bits(ioaddr); rtl_eeprom_cleanup(ioaddr); RTL_W8(Cfg9346, 0); return data; }