~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-orion5x/ls-chl-setup.c

Version: ~ [ linux-5.1-rc1 ] ~ [ linux-5.0.3 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.30 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.107 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.164 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.176 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.136 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.63 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp