Pārlūkot izejas kodu

added eeprom from rtl8139 but not working

tags/v0.9.3
Udayan Kumar 18 gadus atpakaļ
vecāks
revīzija
4a73631106
1 mainītis faili ar 54 papildinājumiem un 56 dzēšanām
  1. 54
    56
      src/drivers/net/natsemi.c

+ 54
- 56
src/drivers/net/natsemi.c Parādīt failu

@@ -149,64 +149,62 @@ enum desc_status_bits {
149 149
 
150 150
 
151 151
 
152
-/*  EEPROM access */
153
-#define EE_M1		0x80	/* Mode select bit 1 */
154
-#define EE_M0		0x40	/* Mode select bit 0 */
152
+/*  EEPROM access , values are devices specific*/
153
+//#define EE_M1		0x80	/* Mode select bit 1 */
154
+//#define EE_M0		0x40	/* Mode select bit 0 */
155 155
 #define EE_CS		0x08	/* EEPROM chip select */
156 156
 #define EE_SK		0x04	/* EEPROM shift clock */
157
-#define EE_DI		0x02	/* Data in */
158
-#define EE_DO		0x01	/* Data out */
157
+#define EE_DI		0x01	/* Data in */
158
+#define EE_DO		0x02	/* Data out */
159 159
 
160 160
 /* Offsets within EEPROM (these are word offsets) */
161 161
 #define EE_MAC 7
162
-
162
+#define EE_REG  EECtrl
163 163
 static uint32_t SavedClkRun;	
164 164
 
165 165
 
166
-/* TODO
167
-static const uint8_t rtl_ee_bits[] = {
166
+static const uint8_t nat_ee_bits[] = {
168 167
 	[SPI_BIT_SCLK]	= EE_SK,
169 168
 	[SPI_BIT_MOSI]	= EE_DI,
170 169
 	[SPI_BIT_MISO]	= EE_DO,
171
-	[SPI_BIT_SS(0)]	= ( EE_CS | EE_M1 ),
170
+	[SPI_BIT_SS(0)]	= EE_CS,
172 171
 };
173 172
 
174
-static int rtl_spi_read_bit ( struct bit_basher *basher,
173
+static int nat_spi_read_bit ( struct bit_basher *basher,
175 174
 			      unsigned int bit_id ) {
176
-	struct rtl8139_nic *rtl = container_of ( basher, struct rtl8139_nic,
175
+	struct natsemi_nic *nat = container_of ( basher, struct natsemi_nic,
177 176
 						 spibit.basher );
178
-	uint8_t mask = rtl_ee_bits[bit_id];
177
+	uint8_t mask = nat_ee_bits[bit_id];
179 178
 	uint8_t eereg;
180 179
 
181
-	eereg = inb ( rtl->ioaddr + Cfg9346 );
180
+	eereg = inb ( nat->ioaddr + EE_REG);
182 181
 	return ( eereg & mask );
183 182
 }
184 183
 
185
-static void rtl_spi_write_bit ( struct bit_basher *basher,
184
+static void nat_spi_write_bit ( struct bit_basher *basher,
186 185
 				unsigned int bit_id, unsigned long data ) {
187
-	struct rtl8139_nic *rtl = container_of ( basher, struct rtl8139_nic,
186
+	struct natsemi_nic *nat = container_of ( basher, struct natsemi_nic,
188 187
 						 spibit.basher );
189
-	uint8_t mask = rtl_ee_bits[bit_id];
188
+	uint8_t mask = nat_ee_bits[bit_id];
190 189
 	uint8_t eereg;
191 190
 
192
-	eereg = inb ( rtl->ioaddr + Cfg9346 );
191
+	eereg = inb ( nat->ioaddr + EE_REG );
193 192
 	eereg &= ~mask;
194 193
 	eereg |= ( data & mask );
195
-	outb ( eereg, rtl->ioaddr + Cfg9346 );
194
+	outb ( eereg, nat->ioaddr + EE_REG);
196 195
 }
197 196
 
198
-static struct bit_basher_operations rtl_basher_ops = {
199
-	.read = rtl_spi_read_bit,
200
-	.write = rtl_spi_write_bit,
197
+static struct bit_basher_operations nat_basher_ops = {
198
+	.read = nat_spi_read_bit,
199
+	.write = nat_spi_write_bit,
201 200
 };
202
-*/
203 201
 /** Portion of EEPROM available for non-volatile stored options
204 202
  *
205 203
  * We use offset 0x40 (i.e. address 0x20), length 0x40.  This block is
206 204
  * marked as VPD in the rtl8139 datasheets, so we use it only if we
207 205
  * detect that the card is not supporting VPD.
208 206
  */
209
-static struct nvo_fragment rtl_nvo_fragments[] = {
207
+static struct nvo_fragment nat_nvo_fragments[] = {
210 208
 	{ 0x20, 0x40 },
211 209
 	{ 0, 0 }
212 210
 };
@@ -216,37 +214,29 @@ static struct nvo_fragment rtl_nvo_fragments[] = {
216 214
  *
217 215
  * @v NAT		NATSEMI NIC
218 216
  */
219
-/* TODO
220
- void rtl_init_eeprom ( struct natsemi_nic *rtl ) {
217
+ void nat_init_eeprom ( struct natsemi_nic *nat ) {
221 218
 	int ee9356;
222 219
 	int vpd;
223 220
 
224 221
 	// Initialise three-wire bus 
225
-	rtl->spibit.basher.op = &rtl_basher_ops;
226
-	rtl->spibit.bus.mode = SPI_MODE_THREEWIRE;
227
-	init_spi_bit_basher ( &rtl->spibit );
228
-
229
-	//Detect EEPROM type and initialise three-wire device 
230
-	ee9356 = ( inw ( rtl->ioaddr + RxConfig ) & Eeprom9356 );
231
-	if ( ee9356 ) {
232
-		DBG ( "EEPROM is an AT93C56\n" );
233
-		init_at93c56 ( &rtl->eeprom, 16 );
234
-	} else {
235
-		DBG ( "EEPROM is an AT93C46\n" );
236
-		init_at93c46 ( &rtl->eeprom, 16 );
237
-	}
238
-	rtl->eeprom.bus = &rtl->spibit.bus;
222
+	nat->spibit.basher.op = &nat_basher_ops;
223
+	nat->spibit.bus.mode = SPI_MODE_THREEWIRE;
224
+	init_spi_bit_basher ( &nat->spibit );
225
+
226
+	DBG ( "EEPROM is an AT93C46\n" );
227
+	init_at93c46 ( &nat->eeprom, 16 );
228
+	nat->eeprom.bus = &nat->spibit.bus;
239 229
 
240 230
 	// Initialise space for non-volatile options, if available 
241
-	vpd = ( inw ( rtl->ioaddr + Config1 ) & VPDEnable );
242
-	if ( vpd ) {
243
-		DBG ( "EEPROM in use for VPD; cannot use for options\n" );
244
-	} else {
245
-		rtl->nvo.nvs = &rtl->eeprom.nvs;
246
-		rtl->nvo.fragments = rtl_nvo_fragments;
247
-	}
231
+	//vpd = ( inw ( rtl->ioaddr + Config1 ) & VPDEnable );
232
+	//if ( vpd ) {
233
+	//	DBG ( "EEPROM in use for VPD; cannot use for options\n" );
234
+	//} else {
235
+//		nat->nvo.nvs = &nat->eeprom.nvs;
236
+//		nat->nvo.fragments = nat_nvo_fragments;
237
+//	}
248 238
 }
249
-*/
239
+
250 240
 /**
251 241
  * Reset NIC
252 242
  *
@@ -303,10 +293,14 @@ static int nat_open ( struct net_device *netdev ) {
303 293
 
304 294
 
305 295
 	/* Program the MAC address TODO enable this comment */
306
-	/*
307
-	 for ( i = 0 ; i < ETH_ALEN ; i++ )
308
-		outb ( netdev->ll_addr[i], rtl->ioaddr + MAC0 + i );
309
-        */
296
+	
297
+	 for ( i = 0 ; i < ETH_ALEN ; i+=2 )
298
+	 {
299
+		outl(i,nat->ioaddr+RxFilterAddr);
300
+		outw ( netdev->ll_addr[i] + (netdev->ll_addr[i+1]<<8), nat->ioaddr +RxFilterData);
301
+		DBG("MAC address %d octet :%X %X\n",i,netdev->ll_addr[i],netdev->ll_addr[i+1]);
302
+	}
303
+       
310 304
 
311 305
 
312 306
 	/*Set up the Tx Ring */
@@ -542,12 +536,16 @@ static int nat_probe ( struct pci_device *pci,
542 536
 
543 537
 	/* Reset the NIC, set up EEPROM access and read MAC address */
544 538
 	nat_reset ( nat );
545
-	/* commenitng two line below. Have to be included in final natsemi.c TODO*/
546
-	/*
547
-	nat_init_eeprom ( rtl );
539
+	nat_init_eeprom ( nat );
548 540
 	nvs_read ( &nat->eeprom.nvs, EE_MAC, netdev->ll_addr, ETH_ALEN );
549
-	
550
-	*/
541
+	uint8_t  eetest[12];	
542
+	int i;
543
+	nvs_read ( &nat->eeprom.nvs, 6, eetest,8 );
544
+	for (i=0;i<8;i++)
545
+	{
546
+		printf("%d word : %X\n",i,eetest[i]);
547
+	}
548
+		
551 549
 	
552 550
 
553 551
 	/* mdio routine of etherboot-5.4.0 natsemi driver has been removed and 

Notiek ielāde…
Atcelt
Saglabāt