diff options
-rw-r--r-- | arch/arm/mach-orion5x/dns323-setup.c | 111 |
1 files changed, 95 insertions, 16 deletions
diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c index 3e66098340a5..4053bd354766 100644 --- a/arch/arm/mach-orion5x/dns323-setup.c +++ b/arch/arm/mach-orion5x/dns323-setup.c | |||
@@ -75,14 +75,6 @@ static int __init dns323_pci_init(void) | |||
75 | subsys_initcall(dns323_pci_init); | 75 | subsys_initcall(dns323_pci_init); |
76 | 76 | ||
77 | /**************************************************************************** | 77 | /**************************************************************************** |
78 | * Ethernet | ||
79 | */ | ||
80 | |||
81 | static struct mv643xx_eth_platform_data dns323_eth_data = { | ||
82 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), | ||
83 | }; | ||
84 | |||
85 | /**************************************************************************** | ||
86 | * 8MiB NOR flash (Spansion S29GL064M90TFIR4) | 78 | * 8MiB NOR flash (Spansion S29GL064M90TFIR4) |
87 | * | 79 | * |
88 | * Layout as used by D-Link: | 80 | * Layout as used by D-Link: |
@@ -143,6 +135,90 @@ static struct platform_device dns323_nor_flash = { | |||
143 | }; | 135 | }; |
144 | 136 | ||
145 | /**************************************************************************** | 137 | /**************************************************************************** |
138 | * Ethernet | ||
139 | */ | ||
140 | |||
141 | static struct mv643xx_eth_platform_data dns323_eth_data = { | ||
142 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), | ||
143 | }; | ||
144 | |||
145 | /* dns323_parse_hex_*() taken from tsx09-common.c; should a common copy of these | ||
146 | * functions be kept somewhere? | ||
147 | */ | ||
148 | static int __init dns323_parse_hex_nibble(char n) | ||
149 | { | ||
150 | if (n >= '0' && n <= '9') | ||
151 | return n - '0'; | ||
152 | |||
153 | if (n >= 'A' && n <= 'F') | ||
154 | return n - 'A' + 10; | ||
155 | |||
156 | if (n >= 'a' && n <= 'f') | ||
157 | return n - 'a' + 10; | ||
158 | |||
159 | return -1; | ||
160 | } | ||
161 | |||
162 | static int __init dns323_parse_hex_byte(const char *b) | ||
163 | { | ||
164 | int hi; | ||
165 | int lo; | ||
166 | |||
167 | hi = dns323_parse_hex_nibble(b[0]); | ||
168 | lo = dns323_parse_hex_nibble(b[1]); | ||
169 | |||
170 | if (hi < 0 || lo < 0) | ||
171 | return -1; | ||
172 | |||
173 | return (hi << 4) | lo; | ||
174 | } | ||
175 | |||
176 | static int __init dns323_read_mac_addr(void) | ||
177 | { | ||
178 | u_int8_t addr[6]; | ||
179 | int i; | ||
180 | char *mac_page; | ||
181 | |||
182 | /* MAC address is stored as a regular ol' string in /dev/mtdblock4 | ||
183 | * (0x007d0000-0x00800000) starting at offset 196480 (0x2ff80). | ||
184 | */ | ||
185 | mac_page = ioremap(DNS323_NOR_BOOT_BASE + 0x7d0000 + 196480, 1024); | ||
186 | if (!mac_page) | ||
187 | return -ENOMEM; | ||
188 | |||
189 | /* Sanity check the string we're looking at */ | ||
190 | for (i = 0; i < 5; i++) { | ||
191 | if (*(mac_page + (i * 3) + 2) != ':') { | ||
192 | goto error_fail; | ||
193 | } | ||
194 | } | ||
195 | |||
196 | for (i = 0; i < 6; i++) { | ||
197 | int byte; | ||
198 | |||
199 | byte = dns323_parse_hex_byte(mac_page + (i * 3)); | ||
200 | if (byte < 0) { | ||
201 | goto error_fail; | ||
202 | } | ||
203 | |||
204 | addr[i] = byte; | ||
205 | } | ||
206 | |||
207 | iounmap(mac_page); | ||
208 | printk("DNS323: Found ethernet MAC address: "); | ||
209 | for (i = 0; i < 6; i++) | ||
210 | printk("%.2x%s", addr[i], (i < 5) ? ":" : ".\n"); | ||
211 | |||
212 | memcpy(dns323_eth_data.mac_addr, addr, 6); | ||
213 | |||
214 | return 0; | ||
215 | |||
216 | error_fail: | ||
217 | iounmap(mac_page); | ||
218 | return -EINVAL; | ||
219 | } | ||
220 | |||
221 | /**************************************************************************** | ||
146 | * GPIO LEDs (simple - doesn't use hardware blinking support) | 222 | * GPIO LEDs (simple - doesn't use hardware blinking support) |
147 | */ | 223 | */ |
148 | 224 | ||
@@ -267,14 +343,6 @@ static void __init dns323_init(void) | |||
267 | orion5x_mpp_conf(dns323_mpp_modes); | 343 | orion5x_mpp_conf(dns323_mpp_modes); |
268 | writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */ | 344 | writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */ |
269 | 345 | ||
270 | /* | ||
271 | * Configure peripherals. | ||
272 | */ | ||
273 | orion5x_ehci0_init(); | ||
274 | orion5x_eth_init(&dns323_eth_data); | ||
275 | orion5x_i2c_init(); | ||
276 | orion5x_uart0_init(); | ||
277 | |||
278 | /* setup flash mapping | 346 | /* setup flash mapping |
279 | * CS3 holds a 8 MB Spansion S29GL064M90TFIR4 | 347 | * CS3 holds a 8 MB Spansion S29GL064M90TFIR4 |
280 | */ | 348 | */ |
@@ -288,6 +356,17 @@ static void __init dns323_init(void) | |||
288 | i2c_register_board_info(0, dns323_i2c_devices, | 356 | i2c_register_board_info(0, dns323_i2c_devices, |
289 | ARRAY_SIZE(dns323_i2c_devices)); | 357 | ARRAY_SIZE(dns323_i2c_devices)); |
290 | 358 | ||
359 | /* | ||
360 | * Configure peripherals. | ||
361 | */ | ||
362 | if (dns323_read_mac_addr() < 0) | ||
363 | printk("DNS323: Failed to read MAC address\n"); | ||
364 | |||
365 | orion5x_ehci0_init(); | ||
366 | orion5x_eth_init(&dns323_eth_data); | ||
367 | orion5x_i2c_init(); | ||
368 | orion5x_uart0_init(); | ||
369 | |||
291 | /* register dns323 specific power-off method */ | 370 | /* register dns323 specific power-off method */ |
292 | if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 || | 371 | if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 || |
293 | gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0) | 372 | gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0) |