2 * arch/arm/mach-orion5x/ls-chl-setup.c
4 * Maintainer: Ash Hughes <ashley.hughes@blueyonder.co.uk>
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.
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 <mach/orion5x.h>
29 /*****************************************************************************
30 * Linkstation LS-CHL Info
31 ****************************************************************************/
34 * 256K NOR flash Device bus boot chip select
37 #define LSCHL_NOR_BOOT_BASE 0xf4000000
38 #define LSCHL_NOR_BOOT_SIZE SZ_256K
40 /*****************************************************************************
41 * 256KB NOR Flash on BOOT Device
42 ****************************************************************************/
44 static struct physmap_flash_data lschl_nor_flash_data
= {
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,
54 static struct platform_device lschl_nor_flash
= {
55 .name
= "physmap-flash",
58 .platform_data
= &lschl_nor_flash_data
,
61 .resource
= &lschl_nor_flash_resource
,
64 /*****************************************************************************
66 ****************************************************************************/
68 static struct mv643xx_eth_platform_data lschl_eth_data
= {
69 .phy_addr
= MV643XX_ETH_PHY_ADDR(8),
72 /*****************************************************************************
73 * RTC 5C372a on I2C bus
74 ****************************************************************************/
76 static struct i2c_board_info __initdata lschl_i2c_rtc
= {
77 I2C_BOARD_INFO("rs5c372a", 0x32),
80 /*****************************************************************************
81 * LEDs attached to GPIO
82 ****************************************************************************/
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
89 static struct gpio_led lschl_led_pins
[] = {
92 .gpio
= LSCHL_GPIO_LED_ALARM
,
96 .gpio
= LSCHL_GPIO_LED_INFO
,
99 .name
= "func:blue:top",
100 .gpio
= LSCHL_GPIO_LED_FUNC
,
103 .name
= "power:blue:bottom",
104 .gpio
= LSCHL_GPIO_LED_PWR
,
108 static struct gpio_led_platform_data lschl_led_data
= {
109 .leds
= lschl_led_pins
,
110 .num_leds
= ARRAY_SIZE(lschl_led_pins
),
113 static struct platform_device lschl_leds
= {
117 .platform_data
= &lschl_led_data
,
121 /*****************************************************************************
123 ****************************************************************************/
124 static struct mv_sata_platform_data lschl_sata_data
= {
128 /*****************************************************************************
129 * LS-CHL specific power off method: reboot
130 ****************************************************************************/
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
140 static void lschl_power_off(void)
142 orion5x_restart(REBOOT_HARD
, NULL
);
145 /*****************************************************************************
147 ****************************************************************************/
148 #define LSCHL_GPIO_USB_POWER 9
149 #define LSCHL_GPIO_AUTO_POWER 17
150 #define LSCHL_GPIO_POWER 18
152 /****************************************************************************
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
162 static struct gpio_keys_button lschl_buttons
[] = {
165 .code
= LSCHL_SW_POWER
,
166 .gpio
= LSCHL_GPIO_KEY_POWER
,
167 .desc
= "Power-on Switch",
171 .code
= LSCHL_SW_AUTOPOWER
,
172 .gpio
= LSCHL_GPIO_KEY_AUTOPOWER
,
173 .desc
= "Power-auto Switch",
177 .code
= LSCHL_SW_FUNC
,
178 .gpio
= LSCHL_GPIO_KEY_FUNC
,
179 .desc
= "Function Switch",
184 static struct gpio_keys_platform_data lschl_button_data
= {
185 .buttons
= lschl_buttons
,
186 .nbuttons
= ARRAY_SIZE(lschl_buttons
),
189 static struct platform_device lschl_button_device
= {
194 .platform_data
= &lschl_button_data
,
198 #define LSCHL_GPIO_HDD_POWER 1
200 /****************************************************************************
202 ****************************************************************************/
204 #define LSCHL_GPIO_FAN_LOW 16
205 #define LSCHL_GPIO_FAN_HIGH 14
206 #define LSCHL_GPIO_FAN_LOCK 6
208 static struct gpio_fan_alarm lschl_alarm
= {
209 .gpio
= LSCHL_GPIO_FAN_LOCK
,
212 static struct gpio_fan_speed lschl_speeds
[] = {
228 static int lschl_gpio_list
[] = {
229 LSCHL_GPIO_FAN_HIGH
, LSCHL_GPIO_FAN_LOW
,
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
,
240 static struct platform_device lschl_fan_device
= {
245 .platform_data
= &lschl_fan_data
,
249 /****************************************************************************
251 ****************************************************************************/
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 */
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 */
268 MPP14_GPIO
, /* FAN HIGH */
269 MPP15_GPIO
, /* SW FUNC */
270 MPP16_GPIO
, /* FAN LOW */
271 MPP17_GPIO
, /* LED FUNC */
277 static void __init
lschl_init(void)
280 * Setup basic Orion functions. Needs to be called early.
284 orion5x_mpp_conf(lschl_mpp_modes
);
287 * Configure peripherals.
289 orion5x_ehci0_init();
290 orion5x_ehci1_init();
291 orion5x_eth_init(&lschl_eth_data
);
293 orion5x_sata_init(&lschl_sata_data
);
294 orion5x_uart0_init();
297 mvebu_mbus_add_window("devbus-boot", LSCHL_NOR_BOOT_BASE
,
298 LSCHL_NOR_BOOT_SIZE
);
299 platform_device_register(&lschl_nor_flash
);
301 platform_device_register(&lschl_leds
);
303 platform_device_register(&lschl_button_device
);
305 platform_device_register(&lschl_fan_device
);
307 i2c_register_board_info(0, &lschl_i2c_rtc
, 1);
310 gpio_set_value(LSCHL_GPIO_USB_POWER
, 1);
312 /* register power-off method */
313 pm_power_off
= lschl_power_off
;
315 pr_info("%s: finished\n", __func__
);
318 MACHINE_START(LINKSTATION_LSCHL
, "Buffalo Linkstation LiveV3 (LS-CHL)")
319 /* Maintainer: Ash Hughes <ashley.hughes@blueyonder.co.uk> */
320 .atag_offset
= 0x100,
321 .init_machine
= lschl_init
,
322 .map_io
= orion5x_map_io
,
323 .init_early
= orion5x_init_early
,
324 .init_irq
= orion5x_init_irq
,
325 .init_time
= orion5x_timer_init
,
326 .fixup
= tag_fixup_mem32
,
327 .restart
= orion5x_restart
,