ar71xx: add an id argument to ar71xx_add_device_mdio
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-all0258n.c
1 /*
2 * Allnet ALL0258N support
3 *
4 * Copyright (C) 2011 Daniel Golle <dgolle@allnet.de>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/platform_device.h>
14 #include <asm/mach-ar71xx/ar71xx.h>
15
16 #include "machtype.h"
17 #include "devices.h"
18 #include "dev-m25p80.h"
19 #include "dev-ap91-pci.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22
23 /* found via /sys/gpio/... try and error */
24 #define ALL0258N_GPIO_BTN_RESET 1
25 #define ALL0258N_GPIO_LED_RSSIHIGH 13
26 #define ALL0258N_GPIO_LED_RSSIMEDIUM 15
27 #define ALL0258N_GPIO_LED_RSSILOW 14
28
29 /* defaults taken from others machs */
30 #define ALL0258N_KEYS_POLL_INTERVAL 20 /* msecs */
31 #define ALL0258N_KEYS_DEBOUNCE_INTERVAL (3 * ALL0258N_KEYS_POLL_INTERVAL)
32
33 /* showed up in the original firmware's bootlog */
34 #define ALL0258N_LAN_PHYMASK BIT(4)
35 #define ALL0258N_SEC_PHYMASK BIT(3)
36
37 /*
38 * from U-Boot bootargs of original firmware:
39 * mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),320k(custom),1024k(kernel),4928k(rootfs),1536k(failsafe),64k(ART)
40 * we use a more OpenWrt-friendly layout now:
41 * mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),896k(kernel),5376k(rootfs),1536k(failsafe),64k(ART)
42 */
43 #ifdef CONFIG_MTD_PARTITIONS
44 static struct mtd_partition all0258n_partitions[] = {
45 {
46 .name = "u-boot",
47 .offset = 0,
48 .size = 0x040000,
49 .mask_flags = MTD_WRITEABLE,
50 }, {
51 .name = "u-boot-env",
52 .offset = 0x040000,
53 .size = 0x010000,
54 }, {
55 .name = "kernel",
56 .offset = 0x050000,
57 .size = 0x0E0000,
58 }, {
59 .name = "rootfs",
60 .offset = 0x130000,
61 .size = 0x540000,
62 }, {
63 .name = "failsafe",
64 .offset = 0x670000,
65 .size = 0x180000,
66 }, {
67 .name = "firmware",
68 .offset = 0x050000,
69 .size = 0x620000,
70 }, {
71 .name = "art",
72 .offset = 0x7F0000,
73 .size = 0x010000,
74 .mask_flags = MTD_WRITEABLE,
75 }
76 };
77 #endif /* CONFIG_MTD_PARTITIONS */
78
79 static struct flash_platform_data all0258n_flash_data = {
80 #ifdef CONFIG_MTD_PARTITIONS
81 .parts = all0258n_partitions,
82 .nr_parts = ARRAY_SIZE(all0258n_partitions),
83 #endif
84 };
85
86 static struct gpio_led all0258n_leds_gpio[] __initdata = {
87 {
88 .name = "all0258n:green:rssihigh",
89 .gpio = ALL0258N_GPIO_LED_RSSIHIGH,
90 .active_low = 1,
91 }, {
92 .name = "all0258n:yellow:rssimedium",
93 .gpio = ALL0258N_GPIO_LED_RSSIMEDIUM,
94 .active_low = 1,
95 }, {
96 .name = "all0258n:red:rssilow",
97 .gpio = ALL0258N_GPIO_LED_RSSILOW,
98 .active_low = 1,
99 }
100 };
101
102 static struct gpio_keys_button all0258n_gpio_keys[] __initdata = {
103 {
104 .desc = "reset",
105 .type = EV_KEY,
106 .code = KEY_RESTART,
107 .debounce_interval = ALL0258N_KEYS_DEBOUNCE_INTERVAL,
108 .gpio = ALL0258N_GPIO_BTN_RESET,
109 .active_low = 1,
110 }
111 };
112
113 static void __init all0258n_setup(void)
114 {
115 u8 *mac = (u8 *) KSEG1ADDR(0x1f7f0000);
116 u8 *ee = (u8 *) KSEG1ADDR(0x1f7f1000);
117
118 ar71xx_add_device_m25p80(&all0258n_flash_data);
119
120 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(all0258n_leds_gpio),
121 all0258n_leds_gpio);
122
123 ar71xx_register_gpio_keys_polled(-1, ALL0258N_KEYS_POLL_INTERVAL,
124 ARRAY_SIZE(all0258n_gpio_keys),
125 all0258n_gpio_keys);
126
127 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
128 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 0);
129
130 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
131 ar71xx_eth0_data.phy_mask = ALL0258N_LAN_PHYMASK;
132
133 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
134 ar71xx_eth1_data.phy_mask = ALL0258N_SEC_PHYMASK;
135 ar71xx_eth1_data.has_ar7240_switch = 1;
136
137 ar71xx_add_device_mdio(0, 0x0);
138
139 ar71xx_add_device_eth(0);
140 ar71xx_add_device_eth(1);
141
142 ap91_pci_init(ee, mac);
143 }
144
145 MIPS_MACHINE(AR71XX_MACH_ALL0258N, "ALL0258N", "Allnet ALL0258N",
146 all0258n_setup);