32 #define TRACE_LEVEL NIC_TRACE_LEVEL
35 #include <machine/intrinsics.h>
36 #include <machine/wdtcon.h>
37 #include "tc_inc_path.h"
38 #include TC_INCLUDE(TCPATH/Ifx_reg.h)
39 #include TC_INCLUDE(TCPATH/IfxCpu_bf.h)
40 #include "interrupts.h"
49 #if defined(__TASKING__)
122 Ifx_SCU_CCUCON5 ccucon5;
125 TRACE_INFO(
"Initializing TC3xx Ethernet MAC...\r\n");
128 nicDriverInterface = interface;
132 while(SCU_CCUCON5.B.LCK != 0)
137 unlock_safety_wdtcon();
140 ccucon5.U = SCU_CCUCON5.U;
141 ccucon5.B.GETHDIV = 2;
143 SCU_CCUCON5.U = ccucon5.U;
146 lock_safety_wdtcon();
149 while(SCU_CCUCON5.B.LCK != 0)
156 MODULE_GETH.CLC.B.DISR = 0;
166 MODULE_GETH.KRST0.B.RST = 1;
167 MODULE_GETH.KRST1.B.RST = 1;
172 while(MODULE_GETH.KRST0.B.RSTSTAT == 0)
179 MODULE_GETH.KRSTCLR.B.CLR = 1;
184 MODULE_GETH.DMA_MODE.B.SWR = 1;
186 while(MODULE_GETH.DMA_MODE.B.SWR)
191 MODULE_GETH.MAC_MDIO_ADDRESS.B.CR = 5;
194 if(interface->phyDriver != NULL)
197 error = interface->phyDriver->init(interface);
199 else if(interface->switchDriver != NULL)
202 error = interface->switchDriver->init(interface);
217 MODULE_GETH.MAC_CONFIGURATION.U = 0;
218 MODULE_GETH.MAC_CONFIGURATION.B.PS = 1;
219 MODULE_GETH.MAC_CONFIGURATION.B.DO = 1;
222 MODULE_GETH.MAC_PACKET_FILTER.U = 0;
228 MODULE_GETH.MAC_Q0_TX_FLOW_CTRL.U = 0;
229 MODULE_GETH.MAC_RX_FLOW_CTRL.U = 0;
232 MODULE_GETH.MAC_RXQ_CTRL0.B.RXQ0EN = 2;
235 MODULE_GETH.DMA_MODE.B.INTM = 0;
236 MODULE_GETH.DMA_MODE.B.PR = 0;
239 MODULE_GETH.DMA_SYSBUS_MODE.B.AAL = 1;
242 MODULE_GETH.DMA_CH[0].CONTROL.B.DSL = 0;
244 MODULE_GETH.DMA_CH[0].TX_CONTROL.B.TXPBL = 32;
247 MODULE_GETH.DMA_CH[0].RX_CONTROL.B.RXPBL = 32;
251 MODULE_GETH.MTL_TXQ0.OPERATION_MODE.B.TQS = 15;
252 MODULE_GETH.MTL_TXQ0.OPERATION_MODE.B.TXQEN = 2;
253 MODULE_GETH.MTL_TXQ0.OPERATION_MODE.B.TSF = 1;
256 MODULE_GETH.MTL_RXQ0.OPERATION_MODE.B.RQS = 31;
257 MODULE_GETH.MTL_RXQ0.OPERATION_MODE.B.RSF = 1;
263 MODULE_GETH.MMC_CONTROL.B.CNTFREEZ = 1;
266 MODULE_GETH.MAC_INTERRUPT_ENABLE.U = 0;
269 MODULE_GETH.DMA_CH[0].INTERRUPT_ENABLE.B.TIE = 1;
270 MODULE_GETH.DMA_CH[0].INTERRUPT_ENABLE.B.RIE = 1;
271 MODULE_GETH.DMA_CH[0].INTERRUPT_ENABLE.B.NIE = 1;
277 MODULE_GETH.MAC_CONFIGURATION.B.TE = 1;
278 MODULE_GETH.MAC_CONFIGURATION.B.RE = 1;
281 MODULE_GETH.DMA_CH[0].TX_CONTROL.B.ST = 1;
282 MODULE_GETH.DMA_CH[0].RX_CONTROL.B.SR = 1;
300 #if defined(USE_KIT_A2G_TC397_TFT)
302 MODULE_P11.IOCR0.B.PC0 = 22;
305 MODULE_P11.IOCR0.B.PC1 = 22;
308 MODULE_P11.IOCR0.B.PC2 = 22;
311 MODULE_P11.IOCR0.B.PC3 = 22;
314 MODULE_P11.IOCR4.B.PC4 = 23;
317 MODULE_P11.IOCR4.B.PC5 = 0;
320 MODULE_P11.IOCR4.B.PC6 = 22;
323 MODULE_P11.IOCR4.B.PC7 = 0;
324 MODULE_GETH.GPCTL.B.ALTI9 = 0;
327 MODULE_P11.IOCR8.B.PC8 = 0;
328 MODULE_GETH.GPCTL.B.ALTI8 = 0;
331 MODULE_P11.IOCR8.B.PC9 = 0;
332 MODULE_GETH.GPCTL.B.ALTI7 = 0;
335 MODULE_P11.IOCR8.B.PC10 = 0;
336 MODULE_GETH.GPCTL.B.ALTI6 = 0;
339 MODULE_P11.IOCR8.B.PC11 = 0;
340 MODULE_GETH.GPCTL.B.ALTI4 = 0;
343 MODULE_P11.IOCR12.B.PC12 = 0;
344 MODULE_GETH.GPCTL.B.ALTI1 = 0;
347 MODULE_P12.IOCR0.B.PC0 = 22;
350 MODULE_P12.IOCR0.B.PC1 = 0;
351 MODULE_GETH.GPCTL.B.ALTI0 = 2;
354 unlock_safety_wdtcon();
357 MODULE_P11.PCSR.B.SEL0 = 1;
358 MODULE_P11.PCSR.B.SEL1 = 1;
359 MODULE_P11.PCSR.B.SEL2 = 1;
360 MODULE_P11.PCSR.B.SEL3 = 1;
361 MODULE_P11.PCSR.B.SEL4 = 1;
362 MODULE_P11.PCSR.B.SEL6 = 1;
365 lock_safety_wdtcon();
371 MODULE_P11.PDR0.B.PD0 = 3;
372 MODULE_P11.PDR0.B.PL0 = 0;
373 MODULE_P11.PDR0.B.PD1 = 3;
374 MODULE_P11.PDR0.B.PL1 = 0;
375 MODULE_P11.PDR0.B.PD2 = 3;
376 MODULE_P11.PDR0.B.PL2 = 0;
377 MODULE_P11.PDR0.B.PD3 = 3;
378 MODULE_P11.PDR0.B.PL3 = 0;
379 MODULE_P11.PDR0.B.PD4 = 3;
380 MODULE_P11.PDR0.B.PL4 = 0;
381 MODULE_P11.PDR0.B.PD5 = 3;
382 MODULE_P11.PDR0.B.PL5 = 0;
383 MODULE_P11.PDR0.B.PD6 = 3;
384 MODULE_P11.PDR0.B.PL6 = 0;
385 MODULE_P11.PDR0.B.PD7 = 3;
386 MODULE_P11.PDR0.B.PL7 = 0;
387 MODULE_P11.PDR1.B.PD8 = 3;
388 MODULE_P11.PDR1.B.PL8 = 0;
389 MODULE_P11.PDR1.B.PD9 = 3;
390 MODULE_P11.PDR1.B.PL9 = 0;
391 MODULE_P11.PDR1.B.PD10 = 3;
392 MODULE_P11.PDR1.B.PL10 = 0;
393 MODULE_P11.PDR1.B.PD11 = 3;
394 MODULE_P11.PDR1.B.PL11 = 0;
395 MODULE_P11.PDR1.B.PD12 = 3;
396 MODULE_P11.PDR1.B.PL12 = 0;
398 MODULE_P12.PDR0.B.PD0 = 3;
399 MODULE_P12.PDR0.B.PL0 = 0;
400 MODULE_P12.PDR0.B.PD1 = 3;
401 MODULE_P12.PDR0.B.PL1 = 0;
407 MODULE_GETH.GPCTL.B.EPR = 1;
410 MODULE_GETH.SKEWCTL.B.TXCFG = 5;
411 MODULE_GETH.SKEWCTL.B.RXCFG = 5;
475 if(interface->phyDriver != NULL)
478 interface->phyDriver->tick(interface);
480 else if(interface->switchDriver != NULL)
483 interface->switchDriver->tick(interface);
500 InterruptEnable(SRC_ID_GETH0);
503 if(interface->phyDriver != NULL)
506 interface->phyDriver->enableIrq(interface);
508 else if(interface->switchDriver != NULL)
511 interface->switchDriver->enableIrq(interface);
528 InterruptDisable(SRC_ID_GETH0);
531 if(interface->phyDriver != NULL)
534 interface->phyDriver->disableIrq(interface);
536 else if(interface->switchDriver != NULL)
539 interface->switchDriver->disableIrq(interface);
565 status = MODULE_GETH.DMA_CH[0].STATUS.U;
588 nicDriverInterface->nicEvent =
TRUE;
667 MODULE_GETH.DMA_CH[0].TXDESC_TAIL_POINTER.U = 0;
763 MODULE_GETH.DMA_CH[0].RXDESC_TAIL_POINTER.U = 0;
781 volatile Ifx_GETH_MAC_ADDRESS_LOW *macAddressLow;
782 volatile Ifx_GETH_MAC_ADDRESS_HIGH *macAddressHigh;
788 MODULE_GETH.MAC_ADDRESS_LOW0.U = interface->macAddr.w[0] | (interface->macAddr.w[1] << 16);
789 MODULE_GETH.MAC_ADDRESS_HIGH0.U = interface->macAddr.w[2];
796 entry = &interface->macAddrFilter[i];
802 macAddressLow = &MODULE_GETH.MAC_ADDRESS_LOW1 + 2 * j;
804 macAddressHigh = &MODULE_GETH.MAC_ADDRESS_HIGH1 + 2 * j;
807 macAddressLow->U = entry->
addr.w[0] | (entry->
addr.w[1] << 16);
819 macAddressLow = &MODULE_GETH.MAC_ADDRESS_LOW1 + 2 * j;
821 macAddressHigh = &MODULE_GETH.MAC_ADDRESS_HIGH1 + 2 * j;
824 macAddressLow->U = 0;
825 macAddressHigh->U = 0;
844 Ifx_GETH_MAC_CONFIGURATION config;
847 config.U = MODULE_GETH.MAC_CONFIGURATION.U;
879 MODULE_GETH.MAC_CONFIGURATION.U = config.U;
901 MODULE_GETH.MAC_MDIO_ADDRESS.B.GOC_0 = 1;
902 MODULE_GETH.MAC_MDIO_ADDRESS.B.GOC_1 = 0;
905 MODULE_GETH.MAC_MDIO_ADDRESS.B.PA = phyAddr;
907 MODULE_GETH.MAC_MDIO_ADDRESS.B.RDA =
regAddr;
910 MODULE_GETH.MAC_MDIO_DATA.B.GD =
data;
913 MODULE_GETH.MAC_MDIO_ADDRESS.B.GB = 1;
915 while(MODULE_GETH.MAC_MDIO_ADDRESS.B.GB)
943 MODULE_GETH.MAC_MDIO_ADDRESS.B.GOC_0 = 1;
944 MODULE_GETH.MAC_MDIO_ADDRESS.B.GOC_1 = 1;
947 MODULE_GETH.MAC_MDIO_ADDRESS.B.PA = phyAddr;
949 MODULE_GETH.MAC_MDIO_ADDRESS.B.RDA =
regAddr;
952 MODULE_GETH.MAC_MDIO_ADDRESS.B.GB = 1;
954 while(MODULE_GETH.MAC_MDIO_ADDRESS.B.GB)
959 data = MODULE_GETH.MAC_MDIO_DATA.B.GD;