Merge tag 'v3.8-rc6' into next/cleanup
[linux-2.6-microblaze.git] / arch / arm / mach-kirkwood / board-nsa310.c
1 /*
2  * arch/arm/mach-kirkwood/nsa-310-setup.c
3  *
4  * ZyXEL NSA-310 Setup
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/gpio.h>
14 #include <mach/kirkwood.h>
15 #include <linux/of.h>
16 #include "common.h"
17 #include "mpp.h"
18
19 #define NSA310_GPIO_USB_POWER_OFF       21
20 #define NSA310_GPIO_POWER_OFF           48
21
22 static unsigned int nsa310_mpp_config[] __initdata = {
23         MPP12_GPIO, /* led esata green */
24         MPP13_GPIO, /* led esata red */
25         MPP15_GPIO, /* led usb green */
26         MPP16_GPIO, /* led usb red */
27         MPP21_GPIO, /* control usb power off */
28         MPP28_GPIO, /* led sys green */
29         MPP29_GPIO, /* led sys red */
30         MPP36_GPIO, /* key reset */
31         MPP37_GPIO, /* key copy */
32         MPP39_GPIO, /* led copy green */
33         MPP40_GPIO, /* led copy red */
34         MPP41_GPIO, /* led hdd green */
35         MPP42_GPIO, /* led hdd red */
36         MPP44_GPIO, /* ?? */
37         MPP46_GPIO, /* key power */
38         MPP48_GPIO, /* control power off */
39         0
40 };
41
42 static struct i2c_board_info __initdata nsa310_i2c_info[] = {
43         { I2C_BOARD_INFO("adt7476", 0x2e) },
44 };
45
46 static void nsa310_power_off(void)
47 {
48         gpio_set_value(NSA310_GPIO_POWER_OFF, 1);
49 }
50
51 static int __init nsa310_gpio_request(unsigned int gpio, unsigned long flags,
52                                        const char *label)
53 {
54         int err;
55
56         err = gpio_request_one(gpio, flags, label);
57         if (err)
58                 pr_err("NSA-310: can't setup GPIO%u (%s), err=%d\n",
59                         gpio, label, err);
60
61         return err;
62 }
63
64 static void __init nsa310_gpio_init(void)
65 {
66         int err;
67
68         err = nsa310_gpio_request(NSA310_GPIO_POWER_OFF, GPIOF_OUT_INIT_LOW,
69                                   "Power Off");
70         if (!err)
71                 pm_power_off = nsa310_power_off;
72
73         nsa310_gpio_request(NSA310_GPIO_USB_POWER_OFF, GPIOF_OUT_INIT_LOW,
74                             "USB Power Off");
75 }
76
77 void __init nsa310_init(void)
78 {
79         kirkwood_mpp_conf(nsa310_mpp_config);
80
81         nsa310_gpio_init();
82
83         i2c_register_board_info(0, ARRAY_AND_SIZE(nsa310_i2c_info));
84 }
85
86 static int __init nsa310_pci_init(void)
87 {
88         if (of_machine_is_compatible("zyxel,nsa310"))
89                 kirkwood_pcie_init(KW_PCIE0);
90
91         return 0;
92 }
93
94 subsys_initcall(nsa310_pci_init);