]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - arch/arm/mach-orion5x/ls-chl-setup.c
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[mirror_ubuntu-zesty-kernel.git] / arch / arm / mach-orion5x / ls-chl-setup.c
1 /*
2 * arch/arm/mach-orion5x/ls-chl-setup.c
3 *
4 * Maintainer: Ash Hughes <ashley.hughes@blueyonder.co.uk>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/mtd/physmap.h>
15 #include <linux/mv643xx_eth.h>
16 #include <linux/leds.h>
17 #include <linux/gpio_keys.h>
18 #include <linux/gpio-fan.h>
19 #include <linux/input.h>
20 #include <linux/i2c.h>
21 #include <linux/ata_platform.h>
22 #include <linux/gpio.h>
23 #include <asm/mach-types.h>
24 #include <asm/mach/arch.h>
25 #include "common.h"
26 #include "mpp.h"
27 #include "orion5x.h"
28
29 /*****************************************************************************
30 * Linkstation LS-CHL Info
31 ****************************************************************************/
32
33 /*
34 * 256K NOR flash Device bus boot chip select
35 */
36
37 #define LSCHL_NOR_BOOT_BASE 0xf4000000
38 #define LSCHL_NOR_BOOT_SIZE SZ_256K
39
40 /*****************************************************************************
41 * 256KB NOR Flash on BOOT Device
42 ****************************************************************************/
43
44 static struct physmap_flash_data lschl_nor_flash_data = {
45 .width = 1,
46 };
47
48 static struct resource lschl_nor_flash_resource = {
49 .flags = IORESOURCE_MEM,
50 .start = LSCHL_NOR_BOOT_BASE,
51 .end = LSCHL_NOR_BOOT_BASE + LSCHL_NOR_BOOT_SIZE - 1,
52 };
53
54 static struct platform_device lschl_nor_flash = {
55 .name = "physmap-flash",
56 .id = 0,
57 .dev = {
58 .platform_data = &lschl_nor_flash_data,
59 },
60 .num_resources = 1,
61 .resource = &lschl_nor_flash_resource,
62 };
63
64 /*****************************************************************************
65 * Ethernet
66 ****************************************************************************/
67
68 static struct mv643xx_eth_platform_data lschl_eth_data = {
69 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
70 };
71
72 /*****************************************************************************
73 * RTC 5C372a on I2C bus
74 ****************************************************************************/
75
76 static struct i2c_board_info __initdata lschl_i2c_rtc = {
77 I2C_BOARD_INFO("rs5c372a", 0x32),
78 };
79
80 /*****************************************************************************
81 * LEDs attached to GPIO
82 ****************************************************************************/
83
84 #define LSCHL_GPIO_LED_ALARM 2
85 #define LSCHL_GPIO_LED_INFO 3
86 #define LSCHL_GPIO_LED_FUNC 17
87 #define LSCHL_GPIO_LED_PWR 0
88
89 static struct gpio_led lschl_led_pins[] = {
90 {
91 .name = "alarm:red",
92 .gpio = LSCHL_GPIO_LED_ALARM,
93 .active_low = 1,
94 }, {
95 .name = "info:amber",
96 .gpio = LSCHL_GPIO_LED_INFO,
97 .active_low = 1,
98 }, {
99 .name = "func:blue:top",
100 .gpio = LSCHL_GPIO_LED_FUNC,
101 .active_low = 1,
102 }, {
103 .name = "power:blue:bottom",
104 .gpio = LSCHL_GPIO_LED_PWR,
105 },
106 };
107
108 static struct gpio_led_platform_data lschl_led_data = {
109 .leds = lschl_led_pins,
110 .num_leds = ARRAY_SIZE(lschl_led_pins),
111 };
112
113 static struct platform_device lschl_leds = {
114 .name = "leds-gpio",
115 .id = -1,
116 .dev = {
117 .platform_data = &lschl_led_data,
118 },
119 };
120
121 /*****************************************************************************
122 * SATA
123 ****************************************************************************/
124 static struct mv_sata_platform_data lschl_sata_data = {
125 .n_ports = 2,
126 };
127
128 /*****************************************************************************
129 * LS-CHL specific power off method: reboot
130 ****************************************************************************/
131 /*
132 * On the LS-CHL, the shutdown process is following:
133 * - Userland monitors key events until the power switch goes to off position
134 * - The board reboots
135 * - U-boot starts and goes into an idle mode waiting for the user
136 * to move the switch to ON position
137 *
138 */
139
140 static void lschl_power_off(void)
141 {
142 orion5x_restart(REBOOT_HARD, NULL);
143 }
144
145 /*****************************************************************************
146 * General Setup
147 ****************************************************************************/
148 #define LSCHL_GPIO_USB_POWER 9
149 #define LSCHL_GPIO_AUTO_POWER 17
150 #define LSCHL_GPIO_POWER 18
151
152 /****************************************************************************
153 * GPIO Attached Keys
154 ****************************************************************************/
155 #define LSCHL_GPIO_KEY_FUNC 15
156 #define LSCHL_GPIO_KEY_POWER 8
157 #define LSCHL_GPIO_KEY_AUTOPOWER 10
158 #define LSCHL_SW_POWER 0x00
159 #define LSCHL_SW_AUTOPOWER 0x01
160 #define LSCHL_SW_FUNC 0x02
161
162 static struct gpio_keys_button lschl_buttons[] = {
163 {
164 .type = EV_SW,
165 .code = LSCHL_SW_POWER,
166 .gpio = LSCHL_GPIO_KEY_POWER,
167 .desc = "Power-on Switch",
168 .active_low = 1,
169 }, {
170 .type = EV_SW,
171 .code = LSCHL_SW_AUTOPOWER,
172 .gpio = LSCHL_GPIO_KEY_AUTOPOWER,
173 .desc = "Power-auto Switch",
174 .active_low = 1,
175 }, {
176 .type = EV_SW,
177 .code = LSCHL_SW_FUNC,
178 .gpio = LSCHL_GPIO_KEY_FUNC,
179 .desc = "Function Switch",
180 .active_low = 1,
181 },
182 };
183
184 static struct gpio_keys_platform_data lschl_button_data = {
185 .buttons = lschl_buttons,
186 .nbuttons = ARRAY_SIZE(lschl_buttons),
187 };
188
189 static struct platform_device lschl_button_device = {
190 .name = "gpio-keys",
191 .id = -1,
192 .num_resources = 0,
193 .dev = {
194 .platform_data = &lschl_button_data,
195 },
196 };
197
198 #define LSCHL_GPIO_HDD_POWER 1
199
200 /****************************************************************************
201 * GPIO Fan
202 ****************************************************************************/
203
204 #define LSCHL_GPIO_FAN_LOW 16
205 #define LSCHL_GPIO_FAN_HIGH 14
206 #define LSCHL_GPIO_FAN_LOCK 6
207
208 static struct gpio_fan_alarm lschl_alarm = {
209 .gpio = LSCHL_GPIO_FAN_LOCK,
210 };
211
212 static struct gpio_fan_speed lschl_speeds[] = {
213 {
214 .rpm = 0,
215 .ctrl_val = 3,
216 }, {
217 .rpm = 1500,
218 .ctrl_val = 2,
219 }, {
220 .rpm = 3250,
221 .ctrl_val = 1,
222 }, {
223 .rpm = 5000,
224 .ctrl_val = 0,
225 },
226 };
227
228 static int lschl_gpio_list[] = {
229 LSCHL_GPIO_FAN_HIGH, LSCHL_GPIO_FAN_LOW,
230 };
231
232 static struct gpio_fan_platform_data lschl_fan_data = {
233 .num_ctrl = ARRAY_SIZE(lschl_gpio_list),
234 .ctrl = lschl_gpio_list,
235 .alarm = &lschl_alarm,
236 .num_speed = ARRAY_SIZE(lschl_speeds),
237 .speed = lschl_speeds,
238 };
239
240 static struct platform_device lschl_fan_device = {
241 .name = "gpio-fan",
242 .id = -1,
243 .num_resources = 0,
244 .dev = {
245 .platform_data = &lschl_fan_data,
246 },
247 };
248
249 /****************************************************************************
250 * GPIO Data
251 ****************************************************************************/
252
253 static unsigned int lschl_mpp_modes[] __initdata = {
254 MPP0_GPIO, /* LED POWER */
255 MPP1_GPIO, /* HDD POWER */
256 MPP2_GPIO, /* LED ALARM */
257 MPP3_GPIO, /* LED INFO */
258 MPP4_UNUSED,
259 MPP5_UNUSED,
260 MPP6_GPIO, /* FAN LOCK */
261 MPP7_GPIO, /* SW INIT */
262 MPP8_GPIO, /* SW POWER */
263 MPP9_GPIO, /* USB POWER */
264 MPP10_GPIO, /* SW AUTO POWER */
265 MPP11_UNUSED,
266 MPP12_UNUSED,
267 MPP13_UNUSED,
268 MPP14_GPIO, /* FAN HIGH */
269 MPP15_GPIO, /* SW FUNC */
270 MPP16_GPIO, /* FAN LOW */
271 MPP17_GPIO, /* LED FUNC */
272 MPP18_UNUSED,
273 MPP19_UNUSED,
274 0,
275 };
276
277 static void __init lschl_init(void)
278 {
279 /*
280 * Setup basic Orion functions. Needs to be called early.
281 */
282 orion5x_init();
283
284 orion5x_mpp_conf(lschl_mpp_modes);
285
286 /*
287 * Configure peripherals.
288 */
289 orion5x_ehci0_init();
290 orion5x_ehci1_init();
291 orion5x_eth_init(&lschl_eth_data);
292 orion5x_i2c_init();
293 orion5x_sata_init(&lschl_sata_data);
294 orion5x_uart0_init();
295 orion5x_xor_init();
296
297 mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
298 ORION_MBUS_DEVBUS_BOOT_ATTR,
299 LSCHL_NOR_BOOT_BASE,
300 LSCHL_NOR_BOOT_SIZE);
301 platform_device_register(&lschl_nor_flash);
302
303 platform_device_register(&lschl_leds);
304
305 platform_device_register(&lschl_button_device);
306
307 platform_device_register(&lschl_fan_device);
308
309 i2c_register_board_info(0, &lschl_i2c_rtc, 1);
310
311 /* usb power on */
312 gpio_set_value(LSCHL_GPIO_USB_POWER, 1);
313
314 /* register power-off method */
315 pm_power_off = lschl_power_off;
316
317 pr_info("%s: finished\n", __func__);
318 }
319
320 MACHINE_START(LINKSTATION_LSCHL, "Buffalo Linkstation LiveV3 (LS-CHL)")
321 /* Maintainer: Ash Hughes <ashley.hughes@blueyonder.co.uk> */
322 .atag_offset = 0x100,
323 .nr_irqs = ORION5X_NR_IRQS,
324 .init_machine = lschl_init,
325 .map_io = orion5x_map_io,
326 .init_early = orion5x_init_early,
327 .init_irq = orion5x_init_irq,
328 .init_time = orion5x_timer_init,
329 .fixup = tag_fixup_mem32,
330 .restart = orion5x_restart,
331 MACHINE_END