1 | /* LEON3 BSP SMC91111 registration and low-level initialization |
---|
2 | * |
---|
3 | * The license and distribution terms for this file may be |
---|
4 | * found in the file LICENSE in this distribution or at |
---|
5 | * http://www.rtems.com/license/LICENSE. |
---|
6 | */ |
---|
7 | |
---|
8 | #include <bsp.h> |
---|
9 | #include <libchip/smc91111exp.h> |
---|
10 | #include <rtems/bspIo.h> |
---|
11 | #include <ambapp.h> |
---|
12 | |
---|
13 | #define SMC91111_BASE_ADDR (void*)0x20000300 |
---|
14 | #define SMC91111_BASE_IRQ 4 |
---|
15 | #define SMC91111_BASE_PIO 4 |
---|
16 | |
---|
17 | scmv91111_configuration_t leon_scmv91111_configuration = { |
---|
18 | SMC91111_BASE_ADDR, /* base address */ |
---|
19 | SMC91111_BASE_IRQ, /* IRQ number (on LEON vector is irq) */ |
---|
20 | SMC91111_BASE_PIO, /* PIO */ |
---|
21 | 100, /* 100b */ |
---|
22 | 1, /* fulldx */ |
---|
23 | 1 /* autoneg */ |
---|
24 | }; |
---|
25 | |
---|
26 | int _rtems_smc91111_driver_attach (struct rtems_bsdnet_ifconfig *config, |
---|
27 | scmv91111_configuration_t * scm_config); |
---|
28 | |
---|
29 | /* |
---|
30 | * Attach an SMC91111 driver to the system |
---|
31 | */ |
---|
32 | int |
---|
33 | rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config, |
---|
34 | int attach) |
---|
35 | { |
---|
36 | unsigned long addr_mctrl = 0; |
---|
37 | LEON3_IOPORT_Regs_Map *io; |
---|
38 | struct ambapp_apb_info apbpio; |
---|
39 | struct ambapp_apb_info apbmctrl; |
---|
40 | |
---|
41 | if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_GPIO, &apbpio) |
---|
42 | != 1) { |
---|
43 | printk("SMC9111_leon3: didn't find PIO\n"); |
---|
44 | return 0; |
---|
45 | } |
---|
46 | |
---|
47 | /* In order to access the SMC controller the memory controller must have |
---|
48 | * I/O bus enabled. Find first memory controller. |
---|
49 | */ |
---|
50 | if (ambapp_find_apbslv(&ambapp_plb, VENDOR_ESA, ESA_MCTRL, &apbmctrl) != 1) { |
---|
51 | if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTMCTRL, |
---|
52 | &apbmctrl) != 1) { |
---|
53 | if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL, |
---|
54 | &apbmctrl) != 1) { |
---|
55 | if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL8, |
---|
56 | &apbmctrl) != 1) { |
---|
57 | printk("SMC9111_leon3: didn't find any memory controller\n"); |
---|
58 | return 0; |
---|
59 | } |
---|
60 | } |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | /* Get controller address */ |
---|
65 | addr_mctrl = (unsigned long) apbmctrl.start; |
---|
66 | io = (LEON3_IOPORT_Regs_Map *) apbpio.start; |
---|
67 | |
---|
68 | printk( |
---|
69 | "Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n", |
---|
70 | (unsigned int)io, |
---|
71 | (unsigned int)addr_mctrl); |
---|
72 | |
---|
73 | /* Setup PIO IRQ */ |
---|
74 | io->irqmask |= (1 << leon_scmv91111_configuration.pio); |
---|
75 | io->irqpol |= (1 << leon_scmv91111_configuration.pio); |
---|
76 | io->irqedge |= (1 << leon_scmv91111_configuration.pio); |
---|
77 | io->iodir &= ~(1 << leon_scmv91111_configuration.pio); |
---|
78 | |
---|
79 | /* Setup memory controller I/O waitstates */ |
---|
80 | *((volatile unsigned int *) addr_mctrl) |= 0x10f80000; /* enable I/O area access */ |
---|
81 | |
---|
82 | return _rtems_smc91111_driver_attach(config, &leon_scmv91111_configuration); |
---|
83 | }; |
---|