Merge branch 'soc' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/renesas...
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-kirkwood / board-iconnect.c
1 /*
2  * arch/arm/mach-kirkwood/board-iconnect.c
3  *
4  * Iomega i-connect Board 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/platform_device.h>
14 #include <linux/of.h>
15 #include <linux/of_address.h>
16 #include <linux/of_fdt.h>
17 #include <linux/of_irq.h>
18 #include <linux/of_platform.h>
19 #include <linux/mtd/partitions.h>
20 #include <linux/mv643xx_eth.h>
21 #include <linux/gpio.h>
22 #include <linux/leds.h>
23 #include <linux/spi/flash.h>
24 #include <linux/spi/spi.h>
25 #include <linux/spi/orion_spi.h>
26 #include <linux/i2c.h>
27 #include <linux/input.h>
28 #include <linux/gpio_keys.h>
29 #include <asm/mach/arch.h>
30 #include <mach/kirkwood.h>
31 #include "common.h"
32 #include "mpp.h"
33
34 static struct mv643xx_eth_platform_data iconnect_ge00_data = {
35         .phy_addr       = MV643XX_ETH_PHY_ADDR(11),
36 };
37
38 static struct gpio_led iconnect_led_pins[] = {
39         {
40                 .name           = "led_level",
41                 .gpio           = 41,
42                 .default_trigger = "default-on",
43         }, {
44                 .name           = "power:blue",
45                 .gpio           = 42,
46                 .default_trigger = "timer",
47         }, {
48                 .name           = "power:red",
49                 .gpio           = 43,
50         }, {
51                 .name           = "usb1:blue",
52                 .gpio           = 44,
53         }, {
54                 .name           = "usb2:blue",
55                 .gpio           = 45,
56         }, {
57                 .name           = "usb3:blue",
58                 .gpio           = 46,
59         }, {
60                 .name           = "usb4:blue",
61                 .gpio           = 47,
62         }, {
63                 .name           = "otb:blue",
64                 .gpio           = 48,
65         },
66 };
67
68 static struct gpio_led_platform_data iconnect_led_data = {
69         .leds           = iconnect_led_pins,
70         .num_leds       = ARRAY_SIZE(iconnect_led_pins),
71         .gpio_blink_set = orion_gpio_led_blink_set,
72 };
73
74 static struct platform_device iconnect_leds = {
75         .name   = "leds-gpio",
76         .id     = -1,
77         .dev    = {
78                 .platform_data  = &iconnect_led_data,
79         }
80 };
81
82 static unsigned int iconnect_mpp_config[] __initdata = {
83         MPP12_GPIO,
84         MPP35_GPIO,
85         MPP41_GPIO,
86         MPP42_GPIO,
87         MPP43_GPIO,
88         MPP44_GPIO,
89         MPP45_GPIO,
90         MPP46_GPIO,
91         MPP47_GPIO,
92         MPP48_GPIO,
93         0
94 };
95
96 static struct i2c_board_info __initdata iconnect_board_info[] = {
97         {
98                 I2C_BOARD_INFO("lm63", 0x4c),
99         },
100 };
101
102 static struct mtd_partition iconnect_nand_parts[] = {
103         {
104                 .name = "flash",
105                 .offset = 0,
106                 .size = MTDPART_SIZ_FULL,
107         },
108 };
109
110 /* yikes... theses are the original input buttons */
111 /* but I'm not convinced by the sw event choices  */
112 static struct gpio_keys_button iconnect_buttons[] = {
113         {
114                 .type           = EV_SW,
115                 .code           = SW_LID,
116                 .gpio           = 12,
117                 .desc           = "Reset Button",
118                 .active_low     = 1,
119                 .debounce_interval = 100,
120         }, {
121                 .type           = EV_SW,
122                 .code           = SW_TABLET_MODE,
123                 .gpio           = 35,
124                 .desc           = "OTB Button",
125                 .active_low     = 1,
126                 .debounce_interval = 100,
127         },
128 };
129
130 static struct gpio_keys_platform_data iconnect_button_data = {
131         .buttons        = iconnect_buttons,
132         .nbuttons       = ARRAY_SIZE(iconnect_buttons),
133 };
134
135 static struct platform_device iconnect_button_device = {
136         .name           = "gpio-keys",
137         .id             = -1,
138         .num_resources  = 0,
139         .dev        = {
140                 .platform_data  = &iconnect_button_data,
141         },
142 };
143
144 void __init iconnect_init(void)
145 {
146         kirkwood_mpp_conf(iconnect_mpp_config);
147         kirkwood_nand_init(ARRAY_AND_SIZE(iconnect_nand_parts), 25);
148         kirkwood_i2c_init();
149         i2c_register_board_info(0, iconnect_board_info,
150                 ARRAY_SIZE(iconnect_board_info));
151
152         kirkwood_ehci_init();
153         kirkwood_ge00_init(&iconnect_ge00_data);
154
155         platform_device_register(&iconnect_button_device);
156         platform_device_register(&iconnect_leds);
157 }
158
159 static int __init iconnect_pci_init(void)
160 {
161         if (of_machine_is_compatible("iom,iconnect"))
162                 kirkwood_pcie_init(KW_PCIE0);
163         return 0;
164 }
165 subsys_initcall(iconnect_pci_init);