• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * arch/arm/mach-orion5x/ls_hgl-setup.c
3  *
4  * Maintainer: Zhu Qingsen <zhuqs@cn.fujitsu.com>
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/input.h>
19 #include <linux/i2c.h>
20 #include <linux/ata_platform.h>
21 #include <linux/gpio.h>
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
24 #include <mach/orion5x.h>
25 #include "common.h"
26 #include "mpp.h"
27 
28 /*****************************************************************************
29  * Linkstation LS-HGL Info
30  ****************************************************************************/
31 
32 /*
33  * 256K NOR flash Device bus boot chip select
34  */
35 
36 #define LS_HGL_NOR_BOOT_BASE	0xf4000000
37 #define LS_HGL_NOR_BOOT_SIZE	SZ_256K
38 
39 /*****************************************************************************
40  * 256KB NOR Flash on BOOT Device
41  ****************************************************************************/
42 
43 static struct physmap_flash_data ls_hgl_nor_flash_data = {
44 	.width		= 1,
45 };
46 
47 static struct resource ls_hgl_nor_flash_resource = {
48 	.flags	= IORESOURCE_MEM,
49 	.start	= LS_HGL_NOR_BOOT_BASE,
50 	.end	= LS_HGL_NOR_BOOT_BASE + LS_HGL_NOR_BOOT_SIZE - 1,
51 };
52 
53 static struct platform_device ls_hgl_nor_flash = {
54 	.name			= "physmap-flash",
55 	.id			= 0,
56 	.dev		= {
57 		.platform_data	= &ls_hgl_nor_flash_data,
58 	},
59 	.num_resources		= 1,
60 	.resource		= &ls_hgl_nor_flash_resource,
61 };
62 
63 /*****************************************************************************
64  * Ethernet
65  ****************************************************************************/
66 
67 static struct mv643xx_eth_platform_data ls_hgl_eth_data = {
68 	.phy_addr	= 8,
69 };
70 
71 /*****************************************************************************
72  * RTC 5C372a on I2C bus
73  ****************************************************************************/
74 
75 static struct i2c_board_info __initdata ls_hgl_i2c_rtc = {
76 	I2C_BOARD_INFO("rs5c372a", 0x32),
77 };
78 
79 /*****************************************************************************
80  * LEDs attached to GPIO
81  ****************************************************************************/
82 
83 #define LS_HGL_GPIO_LED_ALARM   2
84 #define LS_HGL_GPIO_LED_INFO    3
85 #define LS_HGL_GPIO_LED_FUNC    17
86 #define LS_HGL_GPIO_LED_PWR     0
87 
88 
89 static struct gpio_led ls_hgl_led_pins[] = {
90 	{
91 		.name	   = "alarm:red",
92 		.gpio	   = LS_HGL_GPIO_LED_ALARM,
93 		.active_low     = 1,
94 	}, {
95 		.name	   = "info:amber",
96 		.gpio	   = LS_HGL_GPIO_LED_INFO,
97 		.active_low     = 1,
98 	}, {
99 		.name	   = "func:blue:top",
100 		.gpio	   = LS_HGL_GPIO_LED_FUNC,
101 		.active_low     = 1,
102 	}, {
103 		.name	   = "power:blue:bottom",
104 		.gpio	   = LS_HGL_GPIO_LED_PWR,
105 	},
106 };
107 
108 static struct gpio_led_platform_data ls_hgl_led_data = {
109 	.leds	   = ls_hgl_led_pins,
110 	.num_leds       = ARRAY_SIZE(ls_hgl_led_pins),
111 };
112 
113 static struct platform_device ls_hgl_leds = {
114 	.name   = "leds-gpio",
115 	.id     = -1,
116 	.dev    = {
117 		.platform_data  = &ls_hgl_led_data,
118 	},
119 };
120 
121 /****************************************************************************
122  * GPIO Attached Keys
123  ****************************************************************************/
124 #define LS_HGL_GPIO_KEY_FUNC       15
125 #define LS_HGL_GPIO_KEY_POWER      8
126 #define LS_HGL_GPIO_KEY_AUTOPOWER  10
127 
128 #define LS_HGL_SW_POWER     0x00
129 #define LS_HGL_SW_AUTOPOWER 0x01
130 
131 static struct gpio_keys_button ls_hgl_buttons[] = {
132 	{
133 		.code	   = KEY_OPTION,
134 		.gpio	   = LS_HGL_GPIO_KEY_FUNC,
135 		.desc	   = "Function Button",
136 		.active_low     = 1,
137 	}, {
138 		.type		= EV_SW,
139 		.code	   = LS_HGL_SW_POWER,
140 		.gpio	   = LS_HGL_GPIO_KEY_POWER,
141 		.desc	   = "Power-on Switch",
142 		.active_low     = 1,
143 	}, {
144 		.type		= EV_SW,
145 		.code	   = LS_HGL_SW_AUTOPOWER,
146 		.gpio	   = LS_HGL_GPIO_KEY_AUTOPOWER,
147 		.desc	   = "Power-auto Switch",
148 		.active_low     = 1,
149 	},
150 };
151 
152 static struct gpio_keys_platform_data ls_hgl_button_data = {
153 	.buttons	= ls_hgl_buttons,
154 	.nbuttons       = ARRAY_SIZE(ls_hgl_buttons),
155 };
156 
157 static struct platform_device ls_hgl_button_device = {
158 	.name	   = "gpio-keys",
159 	.id	     = -1,
160 	.num_resources  = 0,
161 	.dev	    = {
162 		.platform_data  = &ls_hgl_button_data,
163 	},
164 };
165 
166 
167 /*****************************************************************************
168  * SATA
169  ****************************************************************************/
170 static struct mv_sata_platform_data ls_hgl_sata_data = {
171 	.n_ports	= 2,
172 };
173 
174 
175 /*****************************************************************************
176  * Linkstation LS-HGL specific power off method: reboot
177  ****************************************************************************/
178 /*
179  * On the Linkstation LS-HGL, the shutdown process is following:
180  * - Userland monitors key events until the power switch goes to off position
181  * - The board reboots
182  * - U-boot starts and goes into an idle mode waiting for the user
183  *   to move the switch to ON position
184  */
185 
ls_hgl_power_off(void)186 static void ls_hgl_power_off(void)
187 {
188 	orion5x_restart(REBOOT_HARD, NULL);
189 }
190 
191 
192 /*****************************************************************************
193  * General Setup
194  ****************************************************************************/
195 
196 #define LS_HGL_GPIO_USB_POWER	9
197 #define LS_HGL_GPIO_AUTO_POWER	10
198 #define LS_HGL_GPIO_POWER	    8
199 
200 #define LS_HGL_GPIO_HDD_POWER	1
201 
202 static unsigned int ls_hgl_mpp_modes[] __initdata = {
203 	MPP0_GPIO, /* LED_PWR */
204 	MPP1_GPIO, /* HDD_PWR */
205 	MPP2_GPIO, /* LED_ALARM */
206 	MPP3_GPIO, /* LED_INFO */
207 	MPP4_UNUSED,
208 	MPP5_UNUSED,
209 	MPP6_GPIO, /* FAN_LCK */
210 	MPP7_GPIO, /* INIT */
211 	MPP8_GPIO, /* POWER */
212 	MPP9_GPIO, /* USB_PWR */
213 	MPP10_GPIO, /* AUTO_POWER */
214 	MPP11_UNUSED, /* LED_ETH (dummy) */
215 	MPP12_UNUSED,
216 	MPP13_UNUSED,
217 	MPP14_UNUSED,
218 	MPP15_GPIO, /* FUNC */
219 	MPP16_UNUSED,
220 	MPP17_GPIO, /* LED_FUNC */
221 	MPP18_UNUSED,
222 	MPP19_UNUSED,
223 	0,
224 };
225 
ls_hgl_init(void)226 static void __init ls_hgl_init(void)
227 {
228 	/*
229 	 * Setup basic Orion functions. Need to be called early.
230 	 */
231 	orion5x_init();
232 
233 	orion5x_mpp_conf(ls_hgl_mpp_modes);
234 
235 	/*
236 	 * Configure peripherals.
237 	 */
238 	orion5x_ehci0_init();
239 	orion5x_ehci1_init();
240 	orion5x_eth_init(&ls_hgl_eth_data);
241 	orion5x_i2c_init();
242 	orion5x_sata_init(&ls_hgl_sata_data);
243 	orion5x_uart0_init();
244 	orion5x_xor_init();
245 
246 	mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
247 				    ORION_MBUS_DEVBUS_BOOT_ATTR,
248 				    LS_HGL_NOR_BOOT_BASE,
249 				    LS_HGL_NOR_BOOT_SIZE);
250 	platform_device_register(&ls_hgl_nor_flash);
251 
252 	platform_device_register(&ls_hgl_button_device);
253 
254 	platform_device_register(&ls_hgl_leds);
255 
256 	i2c_register_board_info(0, &ls_hgl_i2c_rtc, 1);
257 
258 	/* enable USB power */
259 	gpio_set_value(LS_HGL_GPIO_USB_POWER, 1);
260 
261 	/* register power-off method */
262 	pm_power_off = ls_hgl_power_off;
263 
264 	pr_info("%s: finished\n", __func__);
265 }
266 
267 MACHINE_START(LINKSTATION_LS_HGL, "Buffalo Linkstation LS-HGL")
268 	/* Maintainer: Zhu Qingsen <zhuqs@cn.fujistu.com> */
269 	.atag_offset	= 0x100,
270 	.init_machine	= ls_hgl_init,
271 	.map_io		= orion5x_map_io,
272 	.init_early	= orion5x_init_early,
273 	.init_irq	= orion5x_init_irq,
274 	.init_time	= orion5x_timer_init,
275 	.fixup		= tag_fixup_mem32,
276 	.restart	= orion5x_restart,
277 MACHINE_END
278