2 * arch/arm/mach-orion5x/d2net-setup.c
4 * LaCie d2Network and Big Disk Network NAS setup
6 * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/pci.h>
17 #include <linux/irq.h>
18 #include <linux/mtd/physmap.h>
19 #include <linux/mv643xx_eth.h>
20 #include <linux/leds.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/input.h>
23 #include <linux/i2c.h>
24 #include <linux/ata_platform.h>
25 #include <linux/gpio.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/pci.h>
29 #include <mach/orion5x.h>
33 /*****************************************************************************
34 * LaCie d2 Network Info
35 ****************************************************************************/
38 * 512KB NOR flash Device bus boot chip select
41 #define D2NET_NOR_BOOT_BASE 0xfff80000
42 #define D2NET_NOR_BOOT_SIZE SZ_512K
44 /*****************************************************************************
45 * 512KB NOR Flash on Boot Device
46 ****************************************************************************/
49 * TODO: Check write support on flash MX29LV400CBTC-70G
52 static struct mtd_partition d2net_partitions
[] = {
55 .size
= MTDPART_SIZ_FULL
,
57 .mask_flags
= MTD_WRITEABLE
,
61 static struct physmap_flash_data d2net_nor_flash_data
= {
63 .parts
= d2net_partitions
,
64 .nr_parts
= ARRAY_SIZE(d2net_partitions
),
67 static struct resource d2net_nor_flash_resource
= {
68 .flags
= IORESOURCE_MEM
,
69 .start
= D2NET_NOR_BOOT_BASE
,
70 .end
= D2NET_NOR_BOOT_BASE
71 + D2NET_NOR_BOOT_SIZE
- 1,
74 static struct platform_device d2net_nor_flash
= {
75 .name
= "physmap-flash",
78 .platform_data
= &d2net_nor_flash_data
,
81 .resource
= &d2net_nor_flash_resource
,
84 /*****************************************************************************
86 ****************************************************************************/
88 static struct mv643xx_eth_platform_data d2net_eth_data
= {
89 .phy_addr
= MV643XX_ETH_PHY_ADDR(8),
92 /*****************************************************************************
94 ****************************************************************************/
97 * i2c addr | chip | description
98 * 0x32 | Ricoh 5C372b | RTC
99 * 0x3e | GMT G762 | PWM fan controller
100 * 0x50 | HT24LC08 | eeprom (1kB)
102 * TODO: Add G762 support to the g760a driver.
104 static struct i2c_board_info __initdata d2net_i2c_devices
[] = {
106 I2C_BOARD_INFO("rs5c372b", 0x32),
108 I2C_BOARD_INFO("24c08", 0x50),
112 /*****************************************************************************
114 ****************************************************************************/
116 static struct mv_sata_platform_data d2net_sata_data
= {
120 #define D2NET_GPIO_SATA0_POWER 3
121 #define D2NET_GPIO_SATA1_POWER 12
123 static void __init
d2net_sata_power_init(void)
127 err
= gpio_request(D2NET_GPIO_SATA0_POWER
, "SATA0 power");
129 err
= gpio_direction_output(D2NET_GPIO_SATA0_POWER
, 1);
131 gpio_free(D2NET_GPIO_SATA0_POWER
);
134 pr_err("d2net: failed to configure SATA0 power GPIO\n");
136 err
= gpio_request(D2NET_GPIO_SATA1_POWER
, "SATA1 power");
138 err
= gpio_direction_output(D2NET_GPIO_SATA1_POWER
, 1);
140 gpio_free(D2NET_GPIO_SATA1_POWER
);
143 pr_err("d2net: failed to configure SATA1 power GPIO\n");
146 /*****************************************************************************
148 ****************************************************************************/
151 * The blue front LED is wired to the CPLD and can blink in relation with the
152 * SATA activity. This feature is disabled to make this LED compatible with
153 * the leds-gpio driver: MPP14 and MPP15 are configured to act like output
154 * GPIO's and have to stay in an active state. This is needed to set the blue
155 * LED in a "fix on" state regardless of the SATA activity.
157 * The following array detail the different LED registers and the combination
158 * of their possible values:
160 * led_off | blink_ctrl | SATA active | LED state
164 * 0 | 1 | 0 | blink (rate 300ms)
167 * Notes: The blue and the red front LED's can't be on at the same time.
168 * Red LED have priority.
171 #define D2NET_GPIO_RED_LED 6
172 #define D2NET_GPIO_BLUE_LED_BLINK_CTRL 16
173 #define D2NET_GPIO_BLUE_LED_OFF 23
174 #define D2NET_GPIO_SATA0_ACT 14
175 #define D2NET_GPIO_SATA1_ACT 15
177 static struct gpio_led d2net_leds
[] = {
179 .name
= "d2net:blue:power",
180 .gpio
= D2NET_GPIO_BLUE_LED_OFF
,
184 .name
= "d2net:red:fail",
185 .gpio
= D2NET_GPIO_RED_LED
,
189 static struct gpio_led_platform_data d2net_led_data
= {
190 .num_leds
= ARRAY_SIZE(d2net_leds
),
194 static struct platform_device d2net_gpio_leds
= {
198 .platform_data
= &d2net_led_data
,
202 static void __init
d2net_gpio_leds_init(void)
204 /* Configure GPIO over MPP max number. */
205 orion_gpio_set_valid(D2NET_GPIO_BLUE_LED_OFF
, 1);
207 if (gpio_request(D2NET_GPIO_SATA0_ACT
, "LED SATA0 activity") != 0)
209 if (gpio_direction_output(D2NET_GPIO_SATA0_ACT
, 1) != 0)
211 if (gpio_request(D2NET_GPIO_SATA1_ACT
, "LED SATA1 activity") != 0)
213 if (gpio_direction_output(D2NET_GPIO_SATA1_ACT
, 1) != 0)
215 platform_device_register(&d2net_gpio_leds
);
219 gpio_free(D2NET_GPIO_SATA1_ACT
);
221 gpio_free(D2NET_GPIO_SATA0_ACT
);
225 /****************************************************************************
227 ****************************************************************************/
229 #define D2NET_GPIO_PUSH_BUTTON 18
230 #define D2NET_GPIO_POWER_SWITCH_ON 8
231 #define D2NET_GPIO_POWER_SWITCH_OFF 9
233 #define D2NET_SWITCH_POWER_ON 0x1
234 #define D2NET_SWITCH_POWER_OFF 0x2
236 static struct gpio_keys_button d2net_buttons
[] = {
239 .code
= D2NET_SWITCH_POWER_OFF
,
240 .gpio
= D2NET_GPIO_POWER_SWITCH_OFF
,
241 .desc
= "Power rocker switch (auto|off)",
246 .code
= D2NET_SWITCH_POWER_ON
,
247 .gpio
= D2NET_GPIO_POWER_SWITCH_ON
,
248 .desc
= "Power rocker switch (on|auto)",
254 .gpio
= D2NET_GPIO_PUSH_BUTTON
,
255 .desc
= "Front Push Button",
260 static struct gpio_keys_platform_data d2net_button_data
= {
261 .buttons
= d2net_buttons
,
262 .nbuttons
= ARRAY_SIZE(d2net_buttons
),
265 static struct platform_device d2net_gpio_buttons
= {
269 .platform_data
= &d2net_button_data
,
273 /*****************************************************************************
275 ****************************************************************************/
277 static struct orion5x_mpp_mode d2net_mpp_modes
[] __initdata
= {
278 { 0, MPP_GPIO
}, /* Board ID (bit 0) */
279 { 1, MPP_GPIO
}, /* Board ID (bit 1) */
280 { 2, MPP_GPIO
}, /* Board ID (bit 2) */
281 { 3, MPP_GPIO
}, /* SATA 0 power */
283 { 5, MPP_GPIO
}, /* Fan fail detection */
284 { 6, MPP_GPIO
}, /* Red front LED */
286 { 8, MPP_GPIO
}, /* Rear power switch (on|auto) */
287 { 9, MPP_GPIO
}, /* Rear power switch (auto|off) */
290 { 12, MPP_GPIO
}, /* SATA 1 power */
292 { 14, MPP_GPIO
}, /* SATA 0 active */
293 { 15, MPP_GPIO
}, /* SATA 1 active */
294 { 16, MPP_GPIO
}, /* Blue front LED blink control */
296 { 18, MPP_GPIO
}, /* Front button (0 = Released, 1 = Pushed ) */
299 /* 22: USB port 1 fuse (0 = Fail, 1 = Ok) */
300 /* 23: Blue front LED off */
301 /* 24: Inhibit board power off (0 = Disabled, 1 = Enabled) */
304 static void __init
d2net_init(void)
307 * Setup basic Orion functions. Need to be called early.
311 orion5x_mpp_conf(d2net_mpp_modes
);
314 * Configure peripherals.
316 orion5x_ehci0_init();
317 orion5x_eth_init(&d2net_eth_data
);
319 orion5x_uart0_init();
321 d2net_sata_power_init();
322 orion5x_sata_init(&d2net_sata_data
);
324 orion5x_setup_dev_boot_win(D2NET_NOR_BOOT_BASE
,
325 D2NET_NOR_BOOT_SIZE
);
326 platform_device_register(&d2net_nor_flash
);
328 platform_device_register(&d2net_gpio_buttons
);
330 d2net_gpio_leds_init();
332 pr_notice("d2net: Flash write are not yet supported.\n");
334 i2c_register_board_info(0, d2net_i2c_devices
,
335 ARRAY_SIZE(d2net_i2c_devices
));
338 /* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */
340 #ifdef CONFIG_MACH_D2NET
341 MACHINE_START(D2NET
, "LaCie d2 Network")
342 .phys_io
= ORION5X_REGS_PHYS_BASE
,
343 .io_pg_offst
= ((ORION5X_REGS_VIRT_BASE
) >> 18) & 0xFFFC,
344 .boot_params
= 0x00000100,
345 .init_machine
= d2net_init
,
346 .map_io
= orion5x_map_io
,
347 .init_irq
= orion5x_init_irq
,
348 .timer
= &orion5x_timer
,
349 .fixup
= tag_fixup_mem32
,
353 #ifdef CONFIG_MACH_BIGDISK
354 MACHINE_START(BIGDISK
, "LaCie Big Disk Network")
355 .phys_io
= ORION5X_REGS_PHYS_BASE
,
356 .io_pg_offst
= ((ORION5X_REGS_VIRT_BASE
) >> 18) & 0xFFFC,
357 .boot_params
= 0x00000100,
358 .init_machine
= d2net_init
,
359 .map_io
= orion5x_map_io
,
360 .init_irq
= orion5x_init_irq
,
361 .timer
= &orion5x_timer
,
362 .fixup
= tag_fixup_mem32
,