aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-orion5x/dns323-setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-orion5x/dns323-setup.c')
-rw-r--r--arch/arm/mach-orion5x/dns323-setup.c174
1 files changed, 155 insertions, 19 deletions
diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c
index 3e66098340a5..0722d6510df1 100644
--- a/arch/arm/mach-orion5x/dns323-setup.c
+++ b/arch/arm/mach-orion5x/dns323-setup.c
@@ -21,6 +21,7 @@
21#include <linux/gpio_keys.h> 21#include <linux/gpio_keys.h>
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/ata_platform.h>
24#include <asm/mach-types.h> 25#include <asm/mach-types.h>
25#include <asm/gpio.h> 26#include <asm/gpio.h>
26#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
@@ -64,9 +65,21 @@ static struct hw_pci dns323_pci __initdata = {
64 .map_irq = dns323_pci_map_irq, 65 .map_irq = dns323_pci_map_irq,
65}; 66};
66 67
68static int __init dns323_dev_id(void)
69{
70 u32 dev, rev;
71
72 orion5x_pcie_id(&dev, &rev);
73
74 return dev;
75}
76
67static int __init dns323_pci_init(void) 77static int __init dns323_pci_init(void)
68{ 78{
69 if (machine_is_dns323()) 79 /* The 5182 doesn't really use it's PCI bus, and initialising PCI
80 * gets in the way of initialising the SATA controller.
81 */
82 if (machine_is_dns323() && dns323_dev_id() != MV88F5182_DEV_ID)
70 pci_common_init(&dns323_pci); 83 pci_common_init(&dns323_pci);
71 84
72 return 0; 85 return 0;
@@ -75,14 +88,6 @@ static int __init dns323_pci_init(void)
75subsys_initcall(dns323_pci_init); 88subsys_initcall(dns323_pci_init);
76 89
77/**************************************************************************** 90/****************************************************************************
78 * Ethernet
79 */
80
81static 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) 91 * 8MiB NOR flash (Spansion S29GL064M90TFIR4)
87 * 92 *
88 * Layout as used by D-Link: 93 * Layout as used by D-Link:
@@ -143,6 +148,90 @@ static struct platform_device dns323_nor_flash = {
143}; 148};
144 149
145/**************************************************************************** 150/****************************************************************************
151 * Ethernet
152 */
153
154static struct mv643xx_eth_platform_data dns323_eth_data = {
155 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
156};
157
158/* dns323_parse_hex_*() taken from tsx09-common.c; should a common copy of these
159 * functions be kept somewhere?
160 */
161static int __init dns323_parse_hex_nibble(char n)
162{
163 if (n >= '0' && n <= '9')
164 return n - '0';
165
166 if (n >= 'A' && n <= 'F')
167 return n - 'A' + 10;
168
169 if (n >= 'a' && n <= 'f')
170 return n - 'a' + 10;
171
172 return -1;
173}
174
175static int __init dns323_parse_hex_byte(const char *b)
176{
177 int hi;
178 int lo;
179
180 hi = dns323_parse_hex_nibble(b[0]);
181 lo = dns323_parse_hex_nibble(b[1]);
182
183 if (hi < 0 || lo < 0)
184 return -1;
185
186 return (hi << 4) | lo;
187}
188
189static int __init dns323_read_mac_addr(void)
190{
191 u_int8_t addr[6];
192 int i;
193 char *mac_page;
194
195 /* MAC address is stored as a regular ol' string in /dev/mtdblock4
196 * (0x007d0000-0x00800000) starting at offset 196480 (0x2ff80).
197 */
198 mac_page = ioremap(DNS323_NOR_BOOT_BASE + 0x7d0000 + 196480, 1024);
199 if (!mac_page)
200 return -ENOMEM;
201
202 /* Sanity check the string we're looking at */
203 for (i = 0; i < 5; i++) {
204 if (*(mac_page + (i * 3) + 2) != ':') {
205 goto error_fail;
206 }
207 }
208
209 for (i = 0; i < 6; i++) {
210 int byte;
211
212 byte = dns323_parse_hex_byte(mac_page + (i * 3));
213 if (byte < 0) {
214 goto error_fail;
215 }
216
217 addr[i] = byte;
218 }
219
220 iounmap(mac_page);
221 printk("DNS323: Found ethernet MAC address: ");
222 for (i = 0; i < 6; i++)
223 printk("%.2x%s", addr[i], (i < 5) ? ":" : ".\n");
224
225 memcpy(dns323_eth_data.mac_addr, addr, 6);
226
227 return 0;
228
229error_fail:
230 iounmap(mac_page);
231 return -EINVAL;
232}
233
234/****************************************************************************
146 * GPIO LEDs (simple - doesn't use hardware blinking support) 235 * GPIO LEDs (simple - doesn't use hardware blinking support)
147 */ 236 */
148 237
@@ -207,10 +296,17 @@ static struct platform_device dns323_button_device = {
207 }, 296 },
208}; 297};
209 298
299/*****************************************************************************
300 * SATA
301 */
302static struct mv_sata_platform_data dns323_sata_data = {
303 .n_ports = 2,
304};
305
210/**************************************************************************** 306/****************************************************************************
211 * General Setup 307 * General Setup
212 */ 308 */
213static struct orion5x_mpp_mode dns323_mpp_modes[] __initdata = { 309static struct orion5x_mpp_mode dns323_mv88f5181_mpp_modes[] __initdata = {
214 { 0, MPP_PCIE_RST_OUTn }, 310 { 0, MPP_PCIE_RST_OUTn },
215 { 1, MPP_GPIO }, /* right amber LED (sata ch0) */ 311 { 1, MPP_GPIO }, /* right amber LED (sata ch0) */
216 { 2, MPP_GPIO }, /* left amber LED (sata ch1) */ 312 { 2, MPP_GPIO }, /* left amber LED (sata ch1) */
@@ -234,6 +330,30 @@ static struct orion5x_mpp_mode dns323_mpp_modes[] __initdata = {
234 { -1 }, 330 { -1 },
235}; 331};
236 332
333static struct orion5x_mpp_mode dns323_mv88f5182_mpp_modes[] __initdata = {
334 { 0, MPP_UNUSED },
335 { 1, MPP_GPIO }, /* right amber LED (sata ch0) */
336 { 2, MPP_GPIO }, /* left amber LED (sata ch1) */
337 { 3, MPP_UNUSED },
338 { 4, MPP_GPIO }, /* power button LED */
339 { 5, MPP_GPIO }, /* power button LED */
340 { 6, MPP_GPIO }, /* GMT G751-2f overtemp */
341 { 7, MPP_GPIO }, /* M41T80 nIRQ/OUT/SQW */
342 { 8, MPP_GPIO }, /* triggers power off */
343 { 9, MPP_GPIO }, /* power button switch */
344 { 10, MPP_GPIO }, /* reset button switch */
345 { 11, MPP_UNUSED },
346 { 12, MPP_SATA_LED },
347 { 13, MPP_SATA_LED },
348 { 14, MPP_SATA_LED },
349 { 15, MPP_SATA_LED },
350 { 16, MPP_UNUSED },
351 { 17, MPP_UNUSED },
352 { 18, MPP_UNUSED },
353 { 19, MPP_UNUSED },
354 { -1 },
355};
356
237/* 357/*
238 * On the DNS-323 the following devices are attached via I2C: 358 * On the DNS-323 the following devices are attached via I2C:
239 * 359 *
@@ -264,16 +384,15 @@ static void __init dns323_init(void)
264 /* Setup basic Orion functions. Need to be called early. */ 384 /* Setup basic Orion functions. Need to be called early. */
265 orion5x_init(); 385 orion5x_init();
266 386
267 orion5x_mpp_conf(dns323_mpp_modes); 387 /* Just to be tricky, the 5182 has a completely different
268 writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */ 388 * set of MPP modes to the 5181.
269
270 /*
271 * Configure peripherals.
272 */ 389 */
273 orion5x_ehci0_init(); 390 if (dns323_dev_id() == MV88F5182_DEV_ID)
274 orion5x_eth_init(&dns323_eth_data); 391 orion5x_mpp_conf(dns323_mv88f5182_mpp_modes);
275 orion5x_i2c_init(); 392 else {
276 orion5x_uart0_init(); 393 orion5x_mpp_conf(dns323_mv88f5181_mpp_modes);
394 writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */
395 }
277 396
278 /* setup flash mapping 397 /* setup flash mapping
279 * CS3 holds a 8 MB Spansion S29GL064M90TFIR4 398 * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
@@ -288,6 +407,23 @@ static void __init dns323_init(void)
288 i2c_register_board_info(0, dns323_i2c_devices, 407 i2c_register_board_info(0, dns323_i2c_devices,
289 ARRAY_SIZE(dns323_i2c_devices)); 408 ARRAY_SIZE(dns323_i2c_devices));
290 409
410 /*
411 * Configure peripherals.
412 */
413 if (dns323_read_mac_addr() < 0)
414 printk("DNS323: Failed to read MAC address\n");
415
416 orion5x_ehci0_init();
417 orion5x_eth_init(&dns323_eth_data);
418 orion5x_i2c_init();
419 orion5x_uart0_init();
420
421 /* The 5182 has it's SATA controller on-chip, and needs it's own little
422 * init routine.
423 */
424 if (dns323_dev_id() == MV88F5182_DEV_ID)
425 orion5x_sata_init(&dns323_sata_data);
426
291 /* register dns323 specific power-off method */ 427 /* register dns323 specific power-off method */
292 if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 || 428 if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
293 gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0) 429 gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)