[kernel] kmod-usb-core is buildin on etrax target
[openwrt.git] / target / linux / xburst / patches-2.6.34 / 007-add-n526-board-support.patch
1 From 3999cbda30a298ee3385a0748f670e40db0b094a Mon Sep 17 00:00:00 2001
2 From: Lars-Peter Clausen <lars@metafoo.de>
3 Date: Sat, 24 Apr 2010 17:25:23 +0200
4 Subject: [PATCH] Add n526 board support
5
6 ---
7 arch/mips/jz4740/Kconfig | 4 +
8 arch/mips/jz4740/Makefile | 1 +
9 arch/mips/jz4740/board-n526.c | 333 +++++++++++++++++++++++++++++++++++++++++
10 3 files changed, 338 insertions(+), 0 deletions(-)
11 create mode 100644 arch/mips/jz4740/board-n526.c
12
13 diff --git a/arch/mips/jz4740/Kconfig b/arch/mips/jz4740/Kconfig
14 index b987c27..e667913 100644
15 --- a/arch/mips/jz4740/Kconfig
16 +++ b/arch/mips/jz4740/Kconfig
17 @@ -11,6 +11,10 @@ config JZ4740_N516
18 bool "Hanvon n516 eBook reader"
19 select SOC_JZ4740
20
21 +config JZ4740_N526
22 + bool "Hanvon n526 eBook reader"
23 + select SOC_JZ4740
24 +
25 endchoice
26
27 config HAVE_PWM
28 diff --git a/arch/mips/jz4740/Makefile b/arch/mips/jz4740/Makefile
29 index 9ed5e5b..80ccf77 100644
30 --- a/arch/mips/jz4740/Makefile
31 +++ b/arch/mips/jz4740/Makefile
32 @@ -13,6 +13,7 @@ obj-$(CONFIG_DEBUG_FS) += clock-debugfs.o
33
34 obj-$(CONFIG_JZ4740_QI_LB60) += board-qi_lb60.o
35 obj-$(CONFIG_JZ4740_N516) += board-n516.o board-n516-display.o
36 +obj-$(CONFIG_JZ4740_N526) += board-n526.o
37
38 # PM support
39
40 diff --git a/arch/mips/jz4740/board-n526.c b/arch/mips/jz4740/board-n526.c
41 new file mode 100644
42 index 0000000..e3e6710
43 --- /dev/null
44 +++ b/arch/mips/jz4740/board-n526.c
45 @@ -0,0 +1,333 @@
46 +/*
47 + * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de>
48 + * N526 eBook reader support
49 + *
50 + * This program is free software; you can redistribute it and/or modify it
51 + * under the terms of the GNU General Public License as published by the
52 + * Free Software Foundation; either version 2 of the License, or (at your
53 + * option) any later version.
54 + *
55 + * You should have received a copy of the GNU General Public License along
56 + * with this program; if not, write to the Free Software Foundation, Inc.,
57 + * 675 Mass Ave, Cambridge, MA 02139, USA.
58 + *
59 + */
60 +
61 +#include <linux/kernel.h>
62 +#include <linux/init.h>
63 +#include <linux/gpio.h>
64 +
65 +#include <asm/mach-jz4740/platform.h>
66 +
67 +#include <linux/mtd/jz4740_nand.h>
68 +#include <linux/jz4740_fb.h>
69 +#include <linux/power_supply.h>
70 +#include <linux/mmc/jz4740_mmc.h>
71 +
72 +#include <video/broadsheetfb.h>
73 +#include <linux/delay.h>
74 +#include <linux/interrupt.h>
75 +
76 +#include <linux/input.h>
77 +#include <linux/gpio_keys.h>
78 +
79 +#include <linux/i2c.h>
80 +#include <linux/i2c-gpio.h>
81 +
82 +#include "clock.h"
83 +
84 +/* NAND */
85 +static struct nand_ecclayout n526_ecclayout = {
86 + .eccbytes = 36,
87 + .eccpos = {
88 + 6, 7, 8, 9, 10, 11, 12, 13,
89 + 14, 15, 16, 17, 18, 19, 20, 21,
90 + 22, 23, 24, 25, 26, 27, 28, 29,
91 + 30, 31, 32, 33, 34, 35, 36, 37,
92 + 38, 39, 40, 41},
93 + .oobfree = {
94 + {.offset = 2,
95 + .length = 4},
96 + {.offset = 42,
97 + .length = 22}}
98 +};
99 +
100 +static struct mtd_partition n526_partitions[] = {
101 + { .name = "NAND BOOT partition",
102 + .offset = 0 * 0x100000,
103 + .size = 4 * 0x100000,
104 + },
105 + { .name = "NAND KERNEL partition",
106 + .offset = 4 * 0x100000,
107 + .size = 4 * 0x100000,
108 + },
109 + { .name = "NAND ROOTFS partition",
110 + .offset = 16 * 0x100000,
111 + .size = 498 * 0x100000,
112 + },
113 +};
114 +
115 +static struct jz_nand_platform_data n526_nand_pdata = {
116 + .ecc_layout = &n526_ecclayout,
117 + .partitions = n526_partitions,
118 + .num_partitions = ARRAY_SIZE(n526_partitions),
119 + .busy_gpio = 94,
120 +};
121 +
122 +static struct jz4740_mmc_platform_data n526_mmc_pdata = {
123 + .gpio_card_detect = JZ_GPIO_PORTD(7),
124 + .card_detect_active_low = 1,
125 + .gpio_read_only = -1,
126 + .gpio_power = JZ_GPIO_PORTD(17),
127 + .power_active_low = 1,
128 +};
129 +
130 +static struct gpio_led n526_leds[] = {
131 + {
132 + .name = "n526:blue:power",
133 + .gpio = JZ_GPIO_PORTD(28),
134 + .default_state = LEDS_GPIO_DEFSTATE_ON,
135 + }
136 +};
137 +
138 +static struct gpio_led_platform_data n526_leds_pdata = {
139 + .leds = n526_leds,
140 + .num_leds = ARRAY_SIZE(n526_leds),
141 +};
142 +
143 +static struct platform_device n526_leds_device = {
144 + .name = "leds-gpio",
145 + .id = -1,
146 + .dev = {
147 + .platform_data = &n526_leds_pdata,
148 + },
149 +};
150 +
151 +static void __init board_gpio_setup(void)
152 +{
153 + /* We only need to enable/disable pullup here for pins used in generic
154 + * drivers. Everything else is done by the drivers themselfs. */
155 + jz_gpio_disable_pullup(JZ_GPIO_PORTD(17));
156 + jz_gpio_enable_pullup(JZ_GPIO_PORTD(7));
157 + jz_gpio_disable_pullup(JZ_GPIO_PORTC(19));
158 + jz_gpio_disable_pullup(JZ_GPIO_PORTC(20));
159 + jz_gpio_disable_pullup(JZ_GPIO_PORTC(21));
160 + jz_gpio_disable_pullup(JZ_GPIO_PORTC(23));
161 +}
162 +
163 +
164 +static const int n526_eink_ctrl_gpios[] = {
165 + 0,
166 + JZ_GPIO_PORTC(23),
167 + JZ_GPIO_PORTC(19),
168 + JZ_GPIO_PORTC(20),
169 +};
170 +
171 +static void n526_eink_set_ctl(struct broadsheetfb_par * par, unsigned char ctrl, u8
172 +value)
173 +{
174 + gpio_set_value(n526_eink_ctrl_gpios[ctrl], value);
175 +}
176 +
177 +
178 +static int n526_eink_wait(struct broadsheetfb_par *par)
179 +{
180 + wait_event(par->waitq, gpio_get_value(JZ_GPIO_PORTB(17)));
181 +
182 + return 0;
183 +}
184 +
185 +static u16 n526_eink_get_hdb(struct broadsheetfb_par *par)
186 +{
187 + u16 value = 0;
188 + jz_gpio_port_direction_input(JZ_GPIO_PORTC(0), 0xffff);
189 + gpio_set_value(JZ_GPIO_PORTC(21), 0);
190 + mdelay(100);
191 +
192 + value = jz_gpio_port_get_value(JZ_GPIO_PORTC(0), 0xffff);
193 +
194 + gpio_set_value(JZ_GPIO_PORTC(21), 1);
195 + jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff);
196 + return value;
197 +}
198 +
199 +static void n526_eink_set_hdb(struct broadsheetfb_par *par, u16 value)
200 +{
201 + jz_gpio_port_set_value(JZ_GPIO_PORTC(0), value, 0xffff);
202 +}
203 +
204 +static int n526_eink_init(struct broadsheetfb_par *par)
205 +{
206 + int i;
207 +
208 + gpio_request(JZ_GPIO_PORTD(1), "display reset");
209 + gpio_direction_output(JZ_GPIO_PORTD(1), 1);
210 + mdelay(10);
211 + gpio_set_value(JZ_GPIO_PORTD(1), 0);
212 +
213 + gpio_request(JZ_GPIO_PORTB(18), "eink enable");
214 + gpio_direction_output(JZ_GPIO_PORTB(18), 0);
215 +
216 + gpio_request(JZ_GPIO_PORTB(29), "foobar");
217 + gpio_direction_output(JZ_GPIO_PORTB(29), 1);
218 +
219 + for(i = 1; i < ARRAY_SIZE(n526_eink_ctrl_gpios); ++i) {
220 + gpio_request(n526_eink_ctrl_gpios[i], "eink display ctrl");
221 + gpio_direction_output(n526_eink_ctrl_gpios[i], 0);
222 + }
223 +
224 + gpio_request(JZ_GPIO_PORTC(22), "foobar");
225 + gpio_direction_input(JZ_GPIO_PORTC(22));
226 + gpio_request(JZ_GPIO_PORTC(21), "eink nRD");
227 + gpio_direction_output(JZ_GPIO_PORTC(21), 1);
228 +
229 + for(i = 0; i < 16; ++i) {
230 + gpio_request(JZ_GPIO_PORTC(i), "eink display data");
231 + }
232 + jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff);
233 +
234 + gpio_set_value(JZ_GPIO_PORTB(18), 1);
235 +
236 + return 0;
237 +}
238 +
239 +static irqreturn_t n526_eink_busy_irq(int irq, void *devid)
240 +{
241 + struct broadsheetfb_par *par = devid;
242 + wake_up(&par->waitq);
243 +
244 + return IRQ_HANDLED;
245 +}
246 +
247 +static int n526_eink_setup_irq(struct fb_info *info)
248 +{
249 + int ret;
250 + struct broadsheetfb_par *par = info->par;
251 +
252 + gpio_request(JZ_GPIO_PORTB(17), "eink busy");
253 + gpio_direction_input(JZ_GPIO_PORTB(17));
254 +
255 + ret = request_irq(gpio_to_irq(JZ_GPIO_PORTB(17)), n526_eink_busy_irq,
256 + IRQF_DISABLED | IRQF_TRIGGER_RISING,
257 + "eink busyline", par);
258 + if (ret)
259 + printk("n526 display: Failed to request busyline irq: %d\n", ret);
260 + return 0;
261 +}
262 +
263 +static void n526_eink_cleanup(struct broadsheetfb_par *par)
264 +{
265 +}
266 +
267 +static struct broadsheet_board broadsheet_pdata = {
268 + .owner = THIS_MODULE,
269 + .init = n526_eink_init,
270 + .wait_for_rdy = n526_eink_wait,
271 + .set_ctl = n526_eink_set_ctl,
272 + .set_hdb = n526_eink_set_hdb,
273 + .get_hdb = n526_eink_get_hdb,
274 + .cleanup = n526_eink_cleanup,
275 + .setup_irq = n526_eink_setup_irq,
276 +};
277 +
278 +static struct platform_device n526_broadsheet_device = {
279 + .name = "broadsheetfb",
280 + .id = -1,
281 + .dev = {
282 + .platform_data = &broadsheet_pdata,
283 + },
284 +};
285 +
286 +static struct gpio_keys_button qi_lb60_gpio_keys_buttons[] = {
287 + [0] = {
288 + .code = KEY_ENTER,
289 + .gpio = 0,
290 + .active_low = 1,
291 + .desc = "Power",
292 + },
293 +};
294 +
295 +static struct gpio_keys_platform_data qi_lb60_gpio_keys_data = {
296 + .nbuttons = ARRAY_SIZE(qi_lb60_gpio_keys_buttons),
297 + .buttons = qi_lb60_gpio_keys_buttons,
298 +};
299 +
300 +static struct platform_device qi_lb60_gpio_keys = {
301 + .name = "gpio-keys",
302 + .id = -1,
303 + .dev = {
304 + .platform_data = &qi_lb60_gpio_keys_data,
305 + }
306 +};
307 +
308 +static struct i2c_gpio_platform_data n526_i2c_pdata = {
309 + .sda_pin = JZ_GPIO_PORTD(23),
310 + .scl_pin = JZ_GPIO_PORTD(24),
311 + .udelay = 2,
312 + .timeout = 3 * HZ,
313 +};
314 +
315 +static struct platform_device n526_i2c_device = {
316 + .name = "i2c-gpio",
317 + .id = -1,
318 + .dev = {
319 + .platform_data = &n526_i2c_pdata,
320 + },
321 +};
322 +
323 +static struct i2c_board_info n526_i2c_board_info = {
324 + .type = "n526-lpc",
325 + .addr = 0x54,
326 +};
327 +
328 +static struct platform_device *jz_platform_devices[] __initdata = {
329 + &jz4740_usb_ohci_device,
330 + &jz4740_usb_gdt_device,
331 + &jz4740_mmc_device,
332 + &jz4740_nand_device,
333 + &jz4740_i2s_device,
334 + &jz4740_codec_device,
335 + &jz4740_rtc_device,
336 + &n526_leds_device,
337 + &n526_broadsheet_device,
338 + &qi_lb60_gpio_keys,
339 + &n526_i2c_device,
340 +};
341 +
342 +
343 +static int __init n526_init_platform_devices(void)
344 +{
345 +
346 + jz4740_nand_device.dev.platform_data = &n526_nand_pdata;
347 + jz4740_mmc_device.dev.platform_data = &n526_mmc_pdata;
348 +
349 + n526_i2c_board_info.irq = gpio_to_irq(JZ_GPIO_PORTD(14)),
350 + i2c_register_board_info(0, &n526_i2c_board_info, 1);
351 +
352 + return platform_add_devices(jz_platform_devices,
353 + ARRAY_SIZE(jz_platform_devices));
354 +
355 +}
356 +
357 +struct jz4740_clock_board_data jz4740_clock_bdata = {
358 + .ext_rate = 12000000,
359 + .rtc_rate = 32768,
360 +};
361 +
362 +extern int jz_gpiolib_init(void);
363 +
364 +static int __init n526_board_setup(void)
365 +{
366 + if (jz_gpiolib_init())
367 + panic("Failed to initalize jz gpio\n");
368 +
369 + jz4740_clock_init();
370 + board_gpio_setup();
371 +
372 + if (n526_init_platform_devices())
373 + panic("Failed to initalize platform devices\n");
374 +
375 + return 0;
376 +}
377 +
378 +arch_initcall(n526_board_setup);
379 --
380 1.5.6.5
381
This page took 0.060995 seconds and 5 git commands to generate.