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