ARM: Kirkwood: Use hw_pci.ops instead of hw_pci.scan
[cascardo/linux.git] / arch / arm / mach-kirkwood / board-lsxl.c
1 /*
2  * Copyright 2012 (C), Michael Walle <michael@walle.cc>
3  *
4  * arch/arm/mach-kirkwood/board-lsxl.c
5  *
6  * Buffalo Linkstation LS-XHL and LS-CHLv2 init for drivers not
7  * converted to flattened device tree yet.
8  *
9  * This file is licensed under the terms of the GNU General Public
10  * License version 2.  This program is licensed "as is" without any
11  * warranty of any kind, whether express or implied.
12  */
13
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/platform_device.h>
17 #include <linux/mv643xx_eth.h>
18 #include <linux/gpio.h>
19 #include <linux/gpio-fan.h>
20 #include "common.h"
21 #include "mpp.h"
22
23 static struct mv643xx_eth_platform_data lsxl_ge00_data = {
24         .phy_addr       = MV643XX_ETH_PHY_ADDR(0),
25 };
26
27 static struct mv643xx_eth_platform_data lsxl_ge01_data = {
28         .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
29 };
30
31 static unsigned int lsxl_mpp_config[] __initdata = {
32         MPP10_GPO,      /* HDD Power Enable */
33         MPP11_GPIO,     /* USB Vbus Enable */
34         MPP18_GPO,      /* FAN High Enable# */
35         MPP19_GPO,      /* FAN Low Enable# */
36         MPP36_GPIO,     /* Function Blue LED */
37         MPP37_GPIO,     /* Alarm LED */
38         MPP38_GPIO,     /* Info LED */
39         MPP39_GPIO,     /* Power LED */
40         MPP40_GPIO,     /* Fan Lock */
41         MPP41_GPIO,     /* Function Button */
42         MPP42_GPIO,     /* Power Switch */
43         MPP43_GPIO,     /* Power Auto Switch */
44         MPP48_GPIO,     /* Function Red LED */
45         0
46 };
47
48 #define LSXL_GPIO_FAN_HIGH      18
49 #define LSXL_GPIO_FAN_LOW       19
50 #define LSXL_GPIO_FAN_LOCK      40
51
52 static struct gpio_fan_alarm lsxl_alarm = {
53         .gpio = LSXL_GPIO_FAN_LOCK,
54 };
55
56 static struct gpio_fan_speed lsxl_speeds[] = {
57         {
58                 .rpm = 0,
59                 .ctrl_val = 3,
60         }, {
61                 .rpm = 1500,
62                 .ctrl_val = 1,
63         }, {
64                 .rpm = 3250,
65                 .ctrl_val = 2,
66         }, {
67                 .rpm = 5000,
68                 .ctrl_val = 0,
69         }
70 };
71
72 static int lsxl_gpio_list[] = {
73         LSXL_GPIO_FAN_HIGH, LSXL_GPIO_FAN_LOW,
74 };
75
76 static struct gpio_fan_platform_data lsxl_fan_data = {
77         .num_ctrl = ARRAY_SIZE(lsxl_gpio_list),
78         .ctrl = lsxl_gpio_list,
79         .alarm = &lsxl_alarm,
80         .num_speed = ARRAY_SIZE(lsxl_speeds),
81         .speed = lsxl_speeds,
82 };
83
84 static struct platform_device lsxl_fan_device = {
85         .name = "gpio-fan",
86         .id = -1,
87         .num_resources = 0,
88         .dev = {
89                 .platform_data = &lsxl_fan_data,
90         },
91 };
92
93 /*
94  * On the LS-XHL/LS-CHLv2, the shutdown process is following:
95  * - Userland monitors key events until the power switch goes to off position
96  * - The board reboots
97  * - U-boot starts and goes into an idle mode waiting for the user
98  *   to move the switch to ON position
99  *
100  */
101 static void lsxl_power_off(void)
102 {
103         kirkwood_restart('h', NULL);
104 }
105
106 #define LSXL_GPIO_HDD_POWER 10
107 #define LSXL_GPIO_USB_POWER 11
108
109 void __init lsxl_init(void)
110 {
111         /*
112          * Basic setup. Needs to be called early.
113          */
114         kirkwood_mpp_conf(lsxl_mpp_config);
115
116         /* usb and sata power on */
117         gpio_set_value(LSXL_GPIO_USB_POWER, 1);
118         gpio_set_value(LSXL_GPIO_HDD_POWER, 1);
119
120         kirkwood_ehci_init();
121         kirkwood_ge00_init(&lsxl_ge00_data);
122         kirkwood_ge01_init(&lsxl_ge01_data);
123         platform_device_register(&lsxl_fan_device);
124
125         /* register power-off method */
126         pm_power_off = lsxl_power_off;
127 }