disable sstrip when using musl
[openwrt/openwrt.git] / target / linux / ubicom32 / files / arch / ubicom32 / mach-ip5k / board-ip5170dpf.c
1 /*
2 * arch/ubicom32/mach-ip5k/board-ip5170dpf.c
3 * Platform initialization for ip5160dpf board.
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 *
7 * This file is part of the Ubicom32 Linux Kernel Port.
8 *
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
22 *
23 * Ubicom32 implementation derived from (with many thanks):
24 * arch/m68knommu
25 * arch/blackfin
26 * arch/parisc
27 */
28 #include <linux/device.h>
29 #include <linux/platform_device.h>
30 #include <linux/gpio.h>
31 #include <linux/leds.h>
32
33 #include <linux/i2c.h>
34 #include <linux/i2c-gpio.h>
35
36 #include <linux/input.h>
37 #include <asm/board.h>
38 #include <asm/machdep.h>
39 #include <asm/ubicom32hid.h>
40 #include <asm/vdc_tio.h>
41
42 /*
43 * LEDs
44 *
45 * WLAN PD9 (Note this is shared with MISO, but we don't use it)
46 * WPS PD8
47 *
48 * TODO: check triggers, are they generic?
49 */
50 static struct gpio_led ip5170dpf_gpio_leds[] = {
51 {
52 .name = "d31:green:WLAN1",
53 .default_trigger = "WLAN1",
54 .gpio = GPIO_RD_9,
55 .active_low = 1,
56 },
57 {
58 .name = "d30:green:WPS",
59 .default_trigger = "WPS",
60 .gpio = GPIO_RD_8,
61 .active_low = 1,
62 },
63 };
64
65 static struct gpio_led_platform_data ip5170dpf_gpio_led_platform_data = {
66 .num_leds = 2,
67 .leds = ip5170dpf_gpio_leds,
68 };
69
70 static struct platform_device ip5170dpf_gpio_leds_device = {
71 .name = "leds-gpio",
72 .id = -1,
73 .dev = {
74 .platform_data = &ip5170dpf_gpio_led_platform_data,
75 },
76 };
77
78 /*
79 * Backlight on the board PD0, hardware PWM
80 */
81 static const struct ubicom32hid_button ip5170dpf_ubicom32hid_buttons[] = {
82 {
83 .type = EV_KEY,
84 .code = KEY_UP,
85 .bit = 0,
86 },
87 {
88 .type = EV_KEY,
89 .code = KEY_LEFT,
90 .bit = 1,
91 },
92 {
93 .type = EV_KEY,
94 .code = KEY_RIGHT,
95 .bit = 2,
96 },
97 {
98 .type = EV_KEY,
99 .code = KEY_DOWN,
100 .bit = 3,
101 },
102 {
103 .type = EV_KEY,
104 .code = KEY_ENTER,
105 .bit = 4,
106 },
107 {
108 .type = EV_KEY,
109 .code = KEY_MENU,
110 .bit = 5,
111 },
112 {
113 .type = EV_KEY,
114 .code = KEY_ESC,
115 .bit = 7,
116 },
117 };
118
119 static const struct ubicom32hid_ir ip5170dpf_ubicom32hid_ircodes[] = {
120 {
121 .type = EV_KEY,
122 .code = KEY_UP,
123 .ir_code = 0xF807916E
124 },
125 {
126 .type = EV_KEY,
127 .code = KEY_DOWN,
128 .ir_code = 0xF20D916E
129 },
130 {
131 .type = EV_KEY,
132 .code = KEY_LEFT,
133 .ir_code = 0xF609916E
134 },
135 {
136 .type = EV_KEY,
137 .code = KEY_RIGHT,
138 .ir_code = 0xF40B916E
139 },
140 {
141 .type = EV_KEY,
142 .code = KEY_ENTER,
143 .ir_code = 0xF50A916E
144 },
145 { /* rotate */
146 .type = EV_KEY,
147 .code = KEY_FN_F1,
148 .ir_code = 0xF906916E
149 },
150 {
151 .type = EV_KEY,
152 .code = KEY_MENU,
153 .ir_code = 0xF708916E
154 },
155 { /* font size */
156 .type = EV_KEY,
157 .code = KEY_FN_F2,
158 .ir_code = 0xF30C916E
159 },
160 {
161 .type = EV_KEY,
162 .code = KEY_ESC,
163 .ir_code = 0xF10E916E
164 },
165 {
166 .type = EV_KEY,
167 .code = KEY_VOLUMEUP,
168 .ir_code = 0xF00F916E
169 },
170 {
171 .type = EV_KEY,
172 .code = KEY_VOLUMEDOWN,
173 .ir_code = 0xED12916E
174 },
175 {
176 .type = EV_KEY,
177 .code = KEY_MUTE,
178 .ir_code = 0xEA15916E
179 },
180 {
181 .type = EV_KEY,
182 .code = KEY_INFO,
183 .ir_code = 0xEF10916E
184 },
185 { /* Like */
186 .type = EV_KEY,
187 .code = KEY_FN_F3,
188 .ir_code = 0xEE11916E
189 },
190 { /* Dislike */
191 .type = EV_KEY,
192 .code = KEY_FN_F4,
193 .ir_code = 0xEB14916E
194 },
195 {
196 .type = EV_KEY,
197 .code = KEY_POWER,
198 .ir_code = 0xFD02916E
199 },
200 };
201
202 static struct ubicom32hid_platform_data ip5170dpf_ubicom32hid_platform_data = {
203 .gpio_reset = GPIO_RA_4,
204 .gpio_reset_polarity = 0,
205 .type = UBICOM32HID_BL_TYPE_BINARY,
206 .invert = 0,
207 .default_intensity = 1,
208 .buttons = ip5170dpf_ubicom32hid_buttons,
209 .nbuttons = ARRAY_SIZE(ip5170dpf_ubicom32hid_buttons),
210 .ircodes = ip5170dpf_ubicom32hid_ircodes,
211 .nircodes = ARRAY_SIZE(ip5170dpf_ubicom32hid_ircodes),
212 };
213
214 /*
215 * Devices on the I2C bus
216 */
217 static struct i2c_board_info __initdata ip5170dpf_i2c_board_info[] = {
218 /*
219 * U24, ubicom32hid
220 */
221 {
222 .type = "ubicom32hid",
223 .addr = 0x08,
224 .platform_data = &ip5170dpf_ubicom32hid_platform_data,
225 },
226
227 /*
228 * U14, CS4350 DAC, address 0x4B
229 */
230 };
231
232 /*
233 * I2C bus on the board, SDA PF13, SCL PF14
234 */
235 static struct i2c_gpio_platform_data ip5170dpf_i2c_data = {
236 .sda_pin = GPIO_RF_13,
237 .scl_pin = GPIO_RF_14,
238 .sda_is_open_drain = 0,
239 .scl_is_open_drain = 0,
240 .scl_is_output_only = 1,
241 .udelay = 5,
242 };
243
244 static struct platform_device ip5170dpf_i2c_device = {
245 .name = "i2c-gpio",
246 .id = 0,
247 .dev = {
248 .platform_data = &ip5170dpf_i2c_data,
249 },
250 };
251
252 /*
253 * List of all devices in our system
254 */
255 static struct platform_device *ip5170dpf_devices[] __initdata = {
256 &ip5170dpf_i2c_device,
257 &ip5170dpf_gpio_leds_device,
258 };
259
260 /*
261 * ip5170dpf_init
262 * Called to add the devices which we have on this board
263 */
264 static int __init ip5170dpf_init(void)
265 {
266 ubi_gpio_init();
267
268 vdc_tio_init();
269
270 printk(KERN_INFO "%s: registering device resources\n", __FUNCTION__);
271 platform_add_devices(ip5170dpf_devices, ARRAY_SIZE(ip5170dpf_devices));
272
273 printk(KERN_INFO "%s: registering i2c resources\n", __FUNCTION__);
274 i2c_register_board_info(0, ip5170dpf_i2c_board_info, ARRAY_SIZE(ip5170dpf_i2c_board_info));
275
276 return 0;
277 }
278
279 arch_initcall(ip5170dpf_init);