Root/
Source at commit 7587a4c created 12 years 7 months ago. By Xiangfu Liu, ben nanonote: forward patches to linux-3.0 | |
---|---|
1 | From 633a1f02f183675e3448c45a5ddd5e942ecbc37c Mon Sep 17 00:00:00 2001 |
2 | From: Lars-Peter Clausen <lars@metafoo.de> |
3 | Date: Sat, 24 Apr 2010 17:25:01 +0200 |
4 | Subject: [PATCH 02/29] Add n516 board support |
5 | |
6 | --- |
7 | arch/mips/include/asm/mach-jz4740/board-n516.h | 39 +++ |
8 | arch/mips/jz4740/Kconfig | 4 + |
9 | arch/mips/jz4740/Makefile | 1 + |
10 | arch/mips/jz4740/board-n516-display.c | 394 ++++++++++++++++++++++++ |
11 | arch/mips/jz4740/board-n516.c | 182 +++++++++++ |
12 | 5 files changed, 620 insertions(+), 0 deletions(-) |
13 | create mode 100644 arch/mips/include/asm/mach-jz4740/board-n516.h |
14 | create mode 100644 arch/mips/jz4740/board-n516-display.c |
15 | create mode 100644 arch/mips/jz4740/board-n516.c |
16 | |
17 | diff --git a/arch/mips/include/asm/mach-jz4740/board-n516.h b/arch/mips/include/asm/mach-jz4740/board-n516.h |
18 | new file mode 100644 |
19 | index 0000000..090707e |
20 | --- /dev/null |
21 | +++ b/arch/mips/include/asm/mach-jz4740/board-n516.h |
22 | @@ -0,0 +1,39 @@ |
23 | +/* |
24 | + * linux/include/asm-mips/mach-jz4740/board-n516.h |
25 | + * |
26 | + * JZ4730-based N516 board definition. |
27 | + * |
28 | + * Copyright (C) 2009, Yauhen Kharuzhy <jekhor@gmail.com> |
29 | + * |
30 | + * This program is free software; you can redistribute it and/or modify |
31 | + * it under the terms of the GNU General Public License as published by |
32 | + * the Free Software Foundation; either version 2 of the License, or |
33 | + * (at your option) any later version. |
34 | + */ |
35 | + |
36 | +#ifndef __ASM_JZ4740_N516_H__ |
37 | +#define __ASM_JZ4740_N516_H__ |
38 | + |
39 | +#include <asm/mach-jz4740/gpio.h> |
40 | + |
41 | +/* |
42 | + * GPIO |
43 | + */ |
44 | +#define GPIO_SD_VCC_EN_N JZ_GPIO_PORTD(17) |
45 | +#define GPIO_SD_CD_N JZ_GPIO_PORTD(7) |
46 | +#define GPIO_SD_WP JZ_GPIO_PORTD(15) |
47 | +#define GPIO_USB_DETECT JZ_GPIO_PORTD(19) |
48 | +#define GPIO_CHARG_STAT_N JZ_GPIO_PORTD(16) |
49 | +#define GPIO_LED_ENABLE JZ_GPIO_PORTD(28) |
50 | +#define GPIO_LPC_INT JZ_GPIO_PORTD(14) |
51 | +#define GPIO_HPHONE_DETECT JZ_GPIO_PORTD(20) |
52 | +#define GPIO_SPEAKER_ENABLE JZ_GPIO_PORTD(21) |
53 | + |
54 | +/* Display */ |
55 | +#define GPIO_DISPLAY_RST_L JZ_GPIO_PORTB(18) |
56 | +#define GPIO_DISPLAY_RDY JZ_GPIO_PORTB(17) |
57 | +#define GPIO_DISPLAY_STBY JZ_GPIO_PORTC(22) |
58 | +#define GPIO_DISPLAY_ERR JZ_GPIO_PORTC(23) |
59 | +#define GPIO_DISPLAY_OFF_N JZ_GPIO_PORTD(1) |
60 | + |
61 | +#endif /* __ASM_JZ4740_N516_H__ */ |
62 | diff --git a/arch/mips/jz4740/Kconfig b/arch/mips/jz4740/Kconfig |
63 | index 3e7141f..85bfbf3 100644 |
64 | --- a/arch/mips/jz4740/Kconfig |
65 | +++ b/arch/mips/jz4740/Kconfig |
66 | @@ -6,6 +6,10 @@ choice |
67 | config JZ4740_QI_LB60 |
68 | bool "Qi Hardware Ben NanoNote" |
69 | |
70 | +config JZ4740_N516 |
71 | + bool "Hanvon n516 eBook reader" |
72 | + select SOC_JZ4740 |
73 | + |
74 | endchoice |
75 | |
76 | config HAVE_PWM |
77 | diff --git a/arch/mips/jz4740/Makefile b/arch/mips/jz4740/Makefile |
78 | index a9dff33..727270a 100644 |
79 | --- a/arch/mips/jz4740/Makefile |
80 | +++ b/arch/mips/jz4740/Makefile |
81 | @@ -12,6 +12,7 @@ obj-$(CONFIG_DEBUG_FS) += clock-debugfs.o |
82 | # board specific support |
83 | |
84 | obj-$(CONFIG_JZ4740_QI_LB60) += board-qi_lb60.o |
85 | +obj-$(CONFIG_JZ4740_N516) += board-n516.o board-n516-display.o |
86 | |
87 | # PM support |
88 | |
89 | diff --git a/arch/mips/jz4740/board-n516-display.c b/arch/mips/jz4740/board-n516-display.c |
90 | new file mode 100644 |
91 | index 0000000..0e77a82 |
92 | --- /dev/null |
93 | +++ b/arch/mips/jz4740/board-n516-display.c |
94 | @@ -0,0 +1,394 @@ |
95 | +/* |
96 | + * board-n516-display.c -- Platform device for N516 display |
97 | + * |
98 | + * Copyright (C) 2009, Yauhen Kharuzhy <jekhor@gmail.com> |
99 | + * |
100 | + * This file is subject to the terms and conditions of the GNU General Public |
101 | + * License. See the file COPYING in the main directory of this archive for |
102 | + * more details. |
103 | + */ |
104 | + |
105 | +#include <linux/module.h> |
106 | +#include <linux/kernel.h> |
107 | +#include <linux/errno.h> |
108 | +#include <linux/string.h> |
109 | +#include <linux/delay.h> |
110 | +#include <linux/interrupt.h> |
111 | +#include <linux/fb.h> |
112 | +#include <linux/init.h> |
113 | +#include <linux/platform_device.h> |
114 | +#include <linux/irq.h> |
115 | +#include <linux/gpio.h> |
116 | + |
117 | +#include <asm/mach-jz4740/jz4740_fb.h> |
118 | + |
119 | +#include <asm/mach-jz4740/platform.h> |
120 | +#include <asm/mach-jz4740/board-n516.h> |
121 | + |
122 | +#include <video/metronomefb.h> |
123 | +#include <linux/console.h> |
124 | + |
125 | +static struct fb_videomode n516_fb_modes[] = { |
126 | + [0] = { |
127 | + .name = "Metronome 800x600", |
128 | + .refresh = 50, |
129 | + .xres = 400, |
130 | + .yres = 624, |
131 | + .hsync_len = 31, |
132 | + .vsync_len = 23, |
133 | + .right_margin = 31, |
134 | + .left_margin = 5, |
135 | + .upper_margin = 1, |
136 | + .lower_margin = 2, |
137 | + .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
138 | + }, |
139 | +}; |
140 | + |
141 | +static struct jz4740_fb_platform_data n516_fb_pdata = { |
142 | + .num_modes = ARRAY_SIZE(n516_fb_modes), |
143 | + .modes = n516_fb_modes, |
144 | + .bpp = 16, |
145 | + .lcd_type = JZ_LCD_TYPE_GENERIC_16_BIT, |
146 | +}; |
147 | + |
148 | +struct n516_board_info { |
149 | + uint8_t *metromem; |
150 | + size_t wfm_size; |
151 | + struct fb_info *host_fbinfo; /* the host LCD controller's fbi */ |
152 | + unsigned int fw; |
153 | + unsigned int fh; |
154 | +}; |
155 | + |
156 | +static struct platform_device *n516_device; |
157 | +static struct n516_board_info n516_board_info; |
158 | + |
159 | +static int metronome_gpios[] = { |
160 | + GPIO_DISPLAY_STBY, |
161 | + GPIO_DISPLAY_RST_L, |
162 | + GPIO_DISPLAY_RDY, |
163 | + GPIO_DISPLAY_ERR, |
164 | +/* GPIO_DISPLAY_OFF_N,*/ |
165 | +}; |
166 | + |
167 | +static const char *metronome_gpio_names[] = { |
168 | + "Metronome STDBY", |
169 | + "Metronome RST", |
170 | + "Metronome RDY", |
171 | + "Metronome ERR", |
172 | +/* "Metronone OFF",*/ |
173 | +}; |
174 | + |
175 | +static int n516_enable_hostfb(bool enable) |
176 | +{ |
177 | + int ret; |
178 | + int blank = enable ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; |
179 | + |
180 | + acquire_console_sem(); |
181 | + ret = fb_blank(n516_board_info.host_fbinfo, blank); |
182 | + release_console_sem(); |
183 | + |
184 | + return ret; |
185 | +} |
186 | + |
187 | +static int n516_init_metronome_gpios(struct metronomefb_par *par) |
188 | +{ |
189 | + int i; |
190 | + int ret; |
191 | + |
192 | + for (i = 0; i < ARRAY_SIZE(metronome_gpios); ++i) { |
193 | + ret = gpio_request(metronome_gpios[i], metronome_gpio_names[i]); |
194 | + if (ret) |
195 | + goto err; |
196 | + } |
197 | + |
198 | + gpio_direction_output(GPIO_DISPLAY_OFF_N, 0); |
199 | + gpio_direction_output(GPIO_DISPLAY_RST_L, 0); |
200 | + gpio_direction_output(GPIO_DISPLAY_STBY, 0); |
201 | + gpio_direction_input(GPIO_DISPLAY_RDY); |
202 | + gpio_direction_input(GPIO_DISPLAY_ERR); |
203 | + |
204 | + return 0; |
205 | +err: |
206 | + for (--i; i >= 0; --i) |
207 | + gpio_free(metronome_gpios[i]); |
208 | + |
209 | + return ret; |
210 | +} |
211 | + |
212 | +static int n516_share_video_mem(struct fb_info *info) |
213 | +{ |
214 | + int ret; |
215 | + |
216 | + dev_dbg(&n516_device->dev, "ENTER %s\n", __func__); |
217 | + dev_dbg(&n516_device->dev, "%s, info->var.xres = %u, info->var.yres = %u\n", __func__, info->var.xres, info->var.yres); |
218 | + /* rough check if this is our desired fb and not something else */ |
219 | + if ((info->var.xres != n516_fb_pdata.modes[0].xres) |
220 | + || (info->var.yres != n516_fb_pdata.modes[0].yres)) |
221 | + return 0; |
222 | + |
223 | + /* we've now been notified that we have our new fb */ |
224 | + n516_board_info.metromem = info->screen_base; |
225 | + n516_board_info.host_fbinfo = info; |
226 | + |
227 | + n516_enable_hostfb(false); |
228 | + /* try to refcount host drv since we are the consumer after this */ |
229 | + if (!try_module_get(info->fbops->owner)) |
230 | + return -ENODEV; |
231 | + |
232 | + /* this _add binds metronomefb to n516. metronomefb refcounts n516 */ |
233 | + ret = platform_device_add(n516_device); |
234 | + |
235 | + if (ret) { |
236 | + platform_device_put(n516_device); |
237 | + return ret; |
238 | + } |
239 | + |
240 | + /* request our platform independent driver */ |
241 | + request_module("metronomefb"); |
242 | + |
243 | + return 0; |
244 | +} |
245 | + |
246 | +static int n516_unshare_video_mem(struct fb_info *info) |
247 | +{ |
248 | + dev_dbg(&n516_device->dev, "ENTER %s\n", __func__); |
249 | + |
250 | + if (info != n516_board_info.host_fbinfo) |
251 | + return 0; |
252 | + |
253 | + module_put(n516_board_info.host_fbinfo->fbops->owner); |
254 | + return 0; |
255 | +} |
256 | + |
257 | +static int n516_fb_notifier_callback(struct notifier_block *self, |
258 | + unsigned long event, void *data) |
259 | +{ |
260 | + struct fb_event *evdata = data; |
261 | + struct fb_info *info = evdata->info; |
262 | + |
263 | + dev_dbg(&n516_device->dev, "ENTER %s\n", __func__); |
264 | + |
265 | + if (event == FB_EVENT_FB_REGISTERED) |
266 | + return n516_share_video_mem(info); |
267 | + else if (event == FB_EVENT_FB_UNREGISTERED) |
268 | + return n516_unshare_video_mem(info); |
269 | + |
270 | + return 0; |
271 | +} |
272 | + |
273 | +static struct notifier_block n516_fb_notif = { |
274 | + .notifier_call = n516_fb_notifier_callback, |
275 | +}; |
276 | + |
277 | +/* this gets called as part of our init. these steps must be done now so |
278 | + * that we can use set_pxa_fb_info */ |
279 | +static void __init n516_presetup_fb(void) |
280 | +{ |
281 | + int padding_size; |
282 | + int totalsize; |
283 | + |
284 | + /* the frame buffer is divided as follows: |
285 | + command | CRC | padding |
286 | + 16kb waveform data | CRC | padding |
287 | + image data | CRC |
288 | + */ |
289 | + |
290 | + n516_board_info.fw = 800; |
291 | + n516_board_info.fh = 624; |
292 | + |
293 | + /* waveform must be 16k + 2 for checksum */ |
294 | + n516_board_info.wfm_size = roundup(16*1024 + 2, n516_board_info.fw); |
295 | + |
296 | + padding_size = PAGE_SIZE + (4 * n516_board_info.fw); |
297 | + |
298 | + /* total is 1 cmd , 1 wfm, padding and image */ |
299 | + totalsize = n516_board_info.fw + n516_board_info.wfm_size; |
300 | + totalsize += padding_size + (n516_board_info.fw*n516_board_info.fh); |
301 | + |
302 | + /* save this off because we're manipulating fw after this and |
303 | + * we'll need it when we're ready to setup the framebuffer */ |
304 | + |
305 | + /* the reason we do this adjustment is because we want to acquire |
306 | + * more framebuffer memory without imposing custom awareness on the |
307 | + * underlying driver */ |
308 | + n516_fb_pdata.modes[0].yres = DIV_ROUND_UP(totalsize, n516_board_info.fw); |
309 | + |
310 | + jz4740_framebuffer_device.dev.platform_data = &n516_fb_pdata; |
311 | + platform_device_register(&jz4740_framebuffer_device); |
312 | +} |
313 | + |
314 | +/* this gets called by metronomefb as part of its init, in our case, we |
315 | + * have already completed initial framebuffer init in presetup_fb so we |
316 | + * can just setup the fb access pointers */ |
317 | +static int n516_setup_fb(struct metronomefb_par *par) |
318 | +{ |
319 | + /* metromem was set up by the notifier in share_video_mem so now |
320 | + * we can use its value to calculate the other entries */ |
321 | + par->metromem_cmd = (struct metromem_cmd *) n516_board_info.metromem; |
322 | + par->metromem_wfm = n516_board_info.metromem + n516_board_info.fw; |
323 | + par->metromem_img = par->metromem_wfm + n516_board_info.wfm_size; |
324 | + par->metromem_img_csum = (u16 *) (par->metromem_img + (n516_board_info.fw * n516_board_info.fh)); |
325 | + par->metromem_dma = n516_board_info.host_fbinfo->fix.smem_start; |
326 | + |
327 | + return 0; |
328 | +} |
329 | + |
330 | +static int n516_get_panel_type(void) |
331 | +{ |
332 | + return 5; |
333 | +} |
334 | + |
335 | +static irqreturn_t n516_handle_irq(int irq, void *dev_id) |
336 | +{ |
337 | + struct metronomefb_par *par = dev_id; |
338 | + |
339 | + dev_dbg(&par->pdev->dev, "Metronome IRQ! RDY=%d\n", gpio_get_value(GPIO_DISPLAY_RDY)); |
340 | + wake_up_all(&par->waitq); |
341 | + |
342 | + return IRQ_HANDLED; |
343 | +} |
344 | + |
345 | +static void n516_power_ctl(struct metronomefb_par *par, int cmd) |
346 | +{ |
347 | + switch (cmd) { |
348 | + case METRONOME_POWER_OFF: |
349 | + gpio_set_value(GPIO_DISPLAY_OFF_N, 1); |
350 | + n516_enable_hostfb(false); |
351 | + break; |
352 | + case METRONOME_POWER_ON: |
353 | + gpio_set_value(GPIO_DISPLAY_OFF_N, 0); |
354 | + n516_enable_hostfb(true); |
355 | + break; |
356 | + } |
357 | +} |
358 | + |
359 | +static int n516_get_rdy(struct metronomefb_par *par) |
360 | +{ |
361 | + return gpio_get_value(GPIO_DISPLAY_RDY); |
362 | +} |
363 | + |
364 | +static int n516_get_err(struct metronomefb_par *par) |
365 | +{ |
366 | + return gpio_get_value(GPIO_DISPLAY_ERR); |
367 | +} |
368 | + |
369 | +static int n516_setup_irq(struct fb_info *info) |
370 | +{ |
371 | + int ret; |
372 | + |
373 | + dev_dbg(&n516_device->dev, "ENTER %s\n", __func__); |
374 | + |
375 | + ret = request_irq(gpio_to_irq(GPIO_DISPLAY_RDY), n516_handle_irq, |
376 | + IRQF_TRIGGER_RISING, |
377 | + "n516", info->par); |
378 | + if (ret) |
379 | + dev_err(&n516_device->dev, "request_irq failed: %d\n", ret); |
380 | + |
381 | + return ret; |
382 | +} |
383 | + |
384 | +static void n516_set_rst(struct metronomefb_par *par, int state) |
385 | +{ |
386 | + dev_dbg(&n516_device->dev, "ENTER %s, RDY=%d\n", __func__, gpio_get_value(GPIO_DISPLAY_RDY)); |
387 | + if (state) |
388 | + gpio_set_value(GPIO_DISPLAY_RST_L, 1); |
389 | + else |
390 | + gpio_set_value(GPIO_DISPLAY_RST_L, 0); |
391 | +} |
392 | + |
393 | +static void n516_set_stdby(struct metronomefb_par *par, int state) |
394 | +{ |
395 | + dev_dbg(&n516_device->dev, "ENTER %s, RDY=%d\n", __func__, gpio_get_value(GPIO_DISPLAY_RDY)); |
396 | + if (state) |
397 | + gpio_set_value(GPIO_DISPLAY_STBY, 1); |
398 | + else |
399 | + gpio_set_value(GPIO_DISPLAY_STBY, 0); |
400 | +} |
401 | + |
402 | +static int n516_wait_event(struct metronomefb_par *par) |
403 | +{ |
404 | + unsigned long timeout = jiffies + HZ / 20; |
405 | + |
406 | + dev_dbg(&n516_device->dev, "ENTER1 %s, RDY=%d\n", |
407 | + __func__, gpio_get_value(GPIO_DISPLAY_RDY)); |
408 | + while (n516_get_rdy(par) && time_before(jiffies, timeout)) |
409 | + schedule(); |
410 | + |
411 | + dev_dbg(&n516_device->dev, "ENTER2 %s, RDY=%d\n", |
412 | + __func__, gpio_get_value(GPIO_DISPLAY_RDY)); |
413 | + return wait_event_timeout(par->waitq, |
414 | + n516_get_rdy(par), HZ * 2) ? 0 : -EIO; |
415 | +} |
416 | + |
417 | +static int n516_wait_event_intr(struct metronomefb_par *par) |
418 | +{ |
419 | + unsigned long timeout = jiffies + HZ/20; |
420 | + |
421 | + dev_dbg(&n516_device->dev, "ENTER1 %s, RDY=%d\n", |
422 | + __func__, gpio_get_value(GPIO_DISPLAY_RDY)); |
423 | + while (n516_get_rdy(par) && time_before(jiffies, timeout)) |
424 | + schedule(); |
425 | + |
426 | + dev_dbg(&n516_device->dev, "ENTER2 %s, RDY=%d\n", |
427 | + __func__, gpio_get_value(GPIO_DISPLAY_RDY)); |
428 | + return wait_event_interruptible_timeout(par->waitq, |
429 | + n516_get_rdy(par), HZ * 2) ? 0 : -EIO; |
430 | +} |
431 | + |
432 | +static void n516_cleanup(struct metronomefb_par *par) |
433 | +{ |
434 | + int i; |
435 | + |
436 | + free_irq(gpio_to_irq(GPIO_DISPLAY_RDY), par); |
437 | + for (i = 0; i < ARRAY_SIZE(metronome_gpios); ++i) |
438 | + gpio_free(metronome_gpios[i]); |
439 | +} |
440 | + |
441 | +static struct metronome_board n516_board __initdata = { |
442 | + .owner = THIS_MODULE, |
443 | + .power_ctl = n516_power_ctl, |
444 | + .setup_irq = n516_setup_irq, |
445 | + .setup_io = n516_init_metronome_gpios, |
446 | + .setup_fb = n516_setup_fb, |
447 | + .set_rst = n516_set_rst, |
448 | + .get_err = n516_get_err, |
449 | + .get_rdy = n516_get_rdy, |
450 | + .set_stdby = n516_set_stdby, |
451 | + .met_wait_event = n516_wait_event, |
452 | + .met_wait_event_intr = n516_wait_event_intr, |
453 | + .get_panel_type = n516_get_panel_type, |
454 | + .cleanup = n516_cleanup, |
455 | +}; |
456 | + |
457 | +static int __init n516_init(void) |
458 | +{ |
459 | + int ret; |
460 | + |
461 | + /* Keep the metronome off, until its driver is loaded */ |
462 | + ret = gpio_request(GPIO_DISPLAY_OFF_N, "Display off"); |
463 | + if (ret) |
464 | + return ret; |
465 | + |
466 | + gpio_direction_output(GPIO_DISPLAY_OFF_N, 1); |
467 | + |
468 | + /* before anything else, we request notification for any fb |
469 | + * creation events */ |
470 | + fb_register_client(&n516_fb_notif); |
471 | + |
472 | + n516_device = platform_device_alloc("metronomefb", -1); |
473 | + if (!n516_device) |
474 | + return -ENOMEM; |
475 | + |
476 | + /* the n516_board that will be seen by metronomefb is a copy */ |
477 | + platform_device_add_data(n516_device, &n516_board, |
478 | + sizeof(n516_board)); |
479 | + |
480 | + n516_presetup_fb(); |
481 | + |
482 | + return 0; |
483 | +} |
484 | +module_init(n516_init); |
485 | + |
486 | +MODULE_DESCRIPTION("board driver for n516 display"); |
487 | +MODULE_AUTHOR("Yauhen Kharuzhy"); |
488 | +MODULE_LICENSE("GPL"); |
489 | diff --git a/arch/mips/jz4740/board-n516.c b/arch/mips/jz4740/board-n516.c |
490 | new file mode 100644 |
491 | index 0000000..678885c |
492 | --- /dev/null |
493 | +++ b/arch/mips/jz4740/board-n516.c |
494 | @@ -0,0 +1,182 @@ |
495 | +/* |
496 | + * linux/arch/mips/jz4740/board-516.c |
497 | + * |
498 | + * JZ4740 n516 board setup routines. |
499 | + * |
500 | + * Copyright (c) 2009, Yauhen Kharuzhy <jekhor@gmail.com> |
501 | + * |
502 | + * This program is free software; you can redistribute it and/or modify |
503 | + * it under the terms of the GNU General Public License as published by |
504 | + * the Free Software Foundation; either version 2 of the License, or |
505 | + * (at your option) any later version. |
506 | + */ |
507 | + |
508 | +#include <linux/init.h> |
509 | +#include <linux/sched.h> |
510 | +#include <linux/ioport.h> |
511 | +#include <linux/mm.h> |
512 | +#include <linux/console.h> |
513 | +#include <linux/delay.h> |
514 | +#include <linux/i2c.h> |
515 | +#include <linux/platform_device.h> |
516 | +#include <linux/mtd/mtd.h> |
517 | +#include <linux/leds.h> |
518 | + |
519 | +#include <linux/power_supply.h> |
520 | +#include <linux/power/gpio-charger.h> |
521 | + |
522 | +#include <linux/i2c.h> |
523 | + |
524 | +#include <asm/mach-jz4740/jz4740_mmc.h> |
525 | +#include <asm/mach-jz4740/jz4740_nand.h> |
526 | + |
527 | +#include <asm/mach-jz4740/board-n516.h> |
528 | +#include <asm/mach-jz4740/platform.h> |
529 | + |
530 | +#include "clock.h" |
531 | + |
532 | +static long n516_panic_blink(int state) |
533 | +{ |
534 | + gpio_set_value(GPIO_LED_ENABLE, state ? 1 : 0); |
535 | + return 0; |
536 | +} |
537 | + |
538 | +static void __init board_gpio_setup(void) |
539 | +{ |
540 | +/* jz_gpio_enable_pullup(JZ_GPIO_PORTD(23)); |
541 | + jz_gpio_enable_pullup(JZ_GPIO_PORTD(24));*/ |
542 | +} |
543 | + |
544 | +static const struct i2c_board_info n516_i2c_board_info[] = { |
545 | + { |
546 | + .type = "LPC524", |
547 | + .addr = 0x54, |
548 | + }, |
549 | + { |
550 | + .type = "lm75a", |
551 | + .addr = 0x48, |
552 | + } |
553 | +}; |
554 | + |
555 | +static struct jz4740_mmc_platform_data n516_mmc_pdata = { |
556 | + .gpio_card_detect = GPIO_SD_CD_N, |
557 | + .card_detect_active_low = 1, |
558 | + .gpio_read_only = -1, |
559 | + .gpio_power = GPIO_SD_VCC_EN_N, |
560 | + .power_active_low = 1, |
561 | +}; |
562 | + |
563 | +static struct gpio_led n516_leds[] = { |
564 | + { |
565 | + .name = "n516:blue:power", |
566 | + .gpio = GPIO_LED_ENABLE, |
567 | + .default_state = LEDS_GPIO_DEFSTATE_ON, |
568 | + .default_trigger = "nand-disk", |
569 | + } |
570 | +}; |
571 | + |
572 | +static struct gpio_led_platform_data n516_leds_pdata = { |
573 | + .leds = n516_leds, |
574 | + .num_leds = ARRAY_SIZE(n516_leds), |
575 | +}; |
576 | + |
577 | +static struct platform_device n516_leds_device = { |
578 | + .name = "leds-gpio", |
579 | + .id = -1, |
580 | + .dev = { |
581 | + .platform_data = &n516_leds_pdata, |
582 | + }, |
583 | +}; |
584 | + |
585 | +static struct mtd_partition n516_partitions[] = { |
586 | + { .name = "NAND BOOT partition", |
587 | + .offset = 0 * 0x100000, |
588 | + .size = 4 * 0x100000, |
589 | + }, |
590 | + { .name = "NAND KERNEL partition", |
591 | + .offset = 4 * 0x100000, |
592 | + .size = 4 * 0x100000, |
593 | + }, |
594 | + { .name = "NAND ROOTFS partition", |
595 | + .offset = 8 * 0x100000, |
596 | + .size = 504 * 0x100000, |
597 | + }, |
598 | +}; |
599 | + |
600 | +static struct nand_ecclayout n516_ecclayout = { |
601 | + .eccbytes = 36, |
602 | + .eccpos = { |
603 | + 6, 7, 8, 9, 10, 11, 12, 13, 14, |
604 | + 15, 16, 17, 18, 19, 20, 21, 22, 23, |
605 | + 24, 25, 26, 27, 28, 29, 30, 31, 32, |
606 | + 33, 34, 35, 36, 37, 38, 39, 40, 41, |
607 | + }, |
608 | + .oobfree = { |
609 | + { |
610 | + .offset = 2, |
611 | + .length = 4 |
612 | + }, |
613 | + { |
614 | + .offset = 42, |
615 | + .length = 22, |
616 | + } |
617 | + } |
618 | +}; |
619 | + |
620 | +static struct jz_nand_platform_data n516_nand_pdata = { |
621 | + .ecc_layout = &n516_ecclayout, |
622 | + .partitions = n516_partitions, |
623 | + .num_partitions = ARRAY_SIZE(n516_partitions), |
624 | + .busy_gpio = 94, |
625 | +}; |
626 | + |
627 | +static char *n516_batteries[] = { |
628 | + "n516_battery", |
629 | +}; |
630 | + |
631 | +static struct gpio_charger_platform_data n516_charger_pdata = { |
632 | + .name = "usb", |
633 | + .type = POWER_SUPPLY_TYPE_USB, |
634 | + .gpio = GPIO_USB_DETECT, |
635 | + .gpio_active_low = 1, |
636 | + .batteries = n516_batteries, |
637 | + .num_batteries = ARRAY_SIZE(n516_batteries), |
638 | +}; |
639 | + |
640 | +static struct platform_device n516_charger_device = { |
641 | + .name = "gpio-charger", |
642 | + .dev = { |
643 | + .platform_data = &n516_charger_pdata, |
644 | + }, |
645 | +}; |
646 | + |
647 | +static struct platform_device *n516_devices[] __initdata = { |
648 | + &jz4740_nand_device, |
649 | + &n516_leds_device, |
650 | + &jz4740_mmc_device, |
651 | + &jz4740_i2s_device, |
652 | + &jz4740_codec_device, |
653 | + &jz4740_rtc_device, |
654 | + &jz4740_udc_device, |
655 | + &jz4740_i2c_device, |
656 | + &n516_charger_device, |
657 | +}; |
658 | + |
659 | +struct jz4740_clock_board_data jz4740_clock_bdata = { |
660 | + .ext_rate = 12000000, |
661 | + .rtc_rate = 32768, |
662 | +}; |
663 | + |
664 | +static int n516_setup_platform(void) |
665 | +{ |
666 | + jz4740_serial_device_register(); |
667 | + board_gpio_setup(); |
668 | + |
669 | + panic_blink = n516_panic_blink; |
670 | + i2c_register_board_info(0, n516_i2c_board_info, ARRAY_SIZE(n516_i2c_board_info)); |
671 | + jz4740_mmc_device.dev.platform_data = &n516_mmc_pdata; |
672 | + jz4740_nand_device.dev.platform_data = &n516_nand_pdata; |
673 | + |
674 | + return platform_add_devices(n516_devices, ARRAY_SIZE(n516_devices)); |
675 | +} |
676 | +arch_initcall(n516_setup_platform); |
677 | -- |
678 | 1.7.4.1 |
679 | |
680 |