Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d2net_v2-setup.c
Go to the documentation of this file.
1 /*
2  * arch/arm/mach-kirkwood/d2net_v2-setup.c
3  *
4  * LaCie d2 Network Space v2 Board Setup
5  *
6  * Copyright (C) 2010 Simon Guinot <[email protected]>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */
22 
23 #include <linux/kernel.h>
24 #include <linux/init.h>
25 #include <linux/platform_device.h>
26 #include <linux/ata_platform.h>
27 #include <linux/mv643xx_eth.h>
28 #include <linux/input.h>
29 #include <linux/gpio.h>
30 #include <linux/gpio_keys.h>
31 #include <linux/leds.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <mach/kirkwood.h>
36 #include "common.h"
37 #include "mpp.h"
38 #include "lacie_v2-common.h"
39 
40 /*****************************************************************************
41  * Ethernet
42  ****************************************************************************/
43 
44 static struct mv643xx_eth_platform_data d2net_v2_ge00_data = {
45  .phy_addr = MV643XX_ETH_PHY_ADDR(8),
46 };
47 
48 /*****************************************************************************
49  * SATA
50  ****************************************************************************/
51 
52 static struct mv_sata_platform_data d2net_v2_sata_data = {
53  .n_ports = 2,
54 };
55 
56 /*****************************************************************************
57  * GPIO keys
58  ****************************************************************************/
59 
60 #define D2NET_V2_GPIO_PUSH_BUTTON 34
61 #define D2NET_V2_GPIO_POWER_SWITCH_ON 13
62 #define D2NET_V2_GPIO_POWER_SWITCH_OFF 15
63 
64 #define D2NET_V2_SWITCH_POWER_ON 0x1
65 #define D2NET_V2_SWITCH_POWER_OFF 0x2
66 
67 static struct gpio_keys_button d2net_v2_buttons[] = {
68  [0] = {
69  .type = EV_SW,
72  .desc = "Back power switch (on|auto)",
73  .active_low = 0,
74  },
75  [1] = {
76  .type = EV_SW,
79  .desc = "Back power switch (auto|off)",
80  .active_low = 0,
81  },
82  [2] = {
83  .code = KEY_POWER,
85  .desc = "Front Push Button",
86  .active_low = 1,
87  },
88 };
89 
90 static struct gpio_keys_platform_data d2net_v2_button_data = {
91  .buttons = d2net_v2_buttons,
92  .nbuttons = ARRAY_SIZE(d2net_v2_buttons),
93 };
94 
95 static struct platform_device d2net_v2_gpio_buttons = {
96  .name = "gpio-keys",
97  .id = -1,
98  .dev = {
99  .platform_data = &d2net_v2_button_data,
100  },
101 };
102 
103 /*****************************************************************************
104  * GPIO LEDs
105  ****************************************************************************/
106 
107 #define D2NET_V2_GPIO_RED_LED 12
108 
109 static struct gpio_led d2net_v2_gpio_led_pins[] = {
110  {
111  .name = "d2net_v2:red:fail",
112  .gpio = D2NET_V2_GPIO_RED_LED,
113  },
114 };
115 
116 static struct gpio_led_platform_data d2net_v2_gpio_leds_data = {
117  .num_leds = ARRAY_SIZE(d2net_v2_gpio_led_pins),
118  .leds = d2net_v2_gpio_led_pins,
119 };
120 
121 static struct platform_device d2net_v2_gpio_leds = {
122  .name = "leds-gpio",
123  .id = -1,
124  .dev = {
125  .platform_data = &d2net_v2_gpio_leds_data,
126  },
127 };
128 
129 /*****************************************************************************
130  * Dual-GPIO CPLD LEDs
131  ****************************************************************************/
132 
133 #define D2NET_V2_GPIO_BLUE_LED_SLOW 29
134 #define D2NET_V2_GPIO_BLUE_LED_CMD 30
135 
136 static struct ns2_led d2net_v2_led_pins[] = {
137  {
138  .name = "d2net_v2:blue:sata",
141  },
142 };
143 
144 static struct ns2_led_platform_data d2net_v2_leds_data = {
145  .num_leds = ARRAY_SIZE(d2net_v2_led_pins),
146  .leds = d2net_v2_led_pins,
147 };
148 
149 static struct platform_device d2net_v2_leds = {
150  .name = "leds-ns2",
151  .id = -1,
152  .dev = {
153  .platform_data = &d2net_v2_leds_data,
154  },
155 };
156 
157 /*****************************************************************************
158  * General Setup
159  ****************************************************************************/
160 
161 static unsigned int d2net_v2_mpp_config[] __initdata = {
162  MPP0_SPI_SCn,
164  MPP2_SPI_SCK,
167  MPP7_GPO, /* Request power-off */
168  MPP8_TW0_SDA,
169  MPP9_TW0_SCK,
172  MPP12_GPO, /* Red led */
173  MPP13_GPIO, /* Rear power switch (on|auto) */
174  MPP14_GPIO, /* USB fuse */
175  MPP15_GPIO, /* Rear power switch (auto|off) */
176  MPP16_GPIO, /* SATA 0 power */
178  MPP24_GPIO, /* USB mode select */
179  MPP26_GPIO, /* USB device vbus */
180  MPP28_GPIO, /* USB enable host vbus */
181  MPP29_GPIO, /* Blue led (slow register) */
182  MPP30_GPIO, /* Blue led (command register) */
183  MPP34_GPIO, /* Power button (1 = Released, 0 = Pushed) */
184  MPP35_GPIO, /* Inhibit power-off */
185  0
186 };
187 
188 #define D2NET_V2_GPIO_POWER_OFF 7
189 
190 static void d2net_v2_power_off(void)
191 {
193 }
194 
195 static void __init d2net_v2_init(void)
196 {
197  /*
198  * Basic setup. Needs to be called early.
199  */
200  kirkwood_init();
201  kirkwood_mpp_conf(d2net_v2_mpp_config);
202 
204 
206  kirkwood_ge00_init(&d2net_v2_ge00_data);
207  kirkwood_sata_init(&d2net_v2_sata_data);
211 
212  platform_device_register(&d2net_v2_leds);
213  platform_device_register(&d2net_v2_gpio_leds);
214  platform_device_register(&d2net_v2_gpio_buttons);
215 
216  if (gpio_request(D2NET_V2_GPIO_POWER_OFF, "power-off") == 0 &&
218  pm_power_off = d2net_v2_power_off;
219  else
220  pr_err("d2net_v2: failed to configure power-off GPIO\n");
221 }
222 
223 MACHINE_START(D2NET_V2, "LaCie d2 Network v2")
224  .atag_offset = 0x100,
225  .init_machine = d2net_v2_init,
226  .map_io = kirkwood_map_io,
227  .init_early = kirkwood_init_early,
228  .init_irq = kirkwood_init_irq,
229  .timer = &kirkwood_timer,
230  .restart = kirkwood_restart,