summaryrefslogtreecommitdiffstats
path: root/target/linux/xburst/patches-2.6.34/006-add-n516-board-support.patch
blob: 5f845d3324b754bfad79a1b4cfe1f963097e9bb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
From 49f148f79887cec83c4b051c104072d770a6a9af Mon Sep 17 00:00:00 2001
From: Lars-Peter Clausen <lars@metafoo.de>
Date: Sat, 24 Apr 2010 17:25:01 +0200
Subject: [PATCH] Add n516 board support

---
 arch/mips/include/asm/mach-jz4740/board-n516.h |   39 +++
 arch/mips/jz4740/Kconfig                       |    4 +
 arch/mips/jz4740/Makefile                      |    1 +
 arch/mips/jz4740/board-n516-display.c          |  393 ++++++++++++++++++++++++
 arch/mips/jz4740/board-n516.c                  |  206 +++++++++++++
 5 files changed, 643 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-jz4740/board-n516.h
 create mode 100644 arch/mips/jz4740/board-n516-display.c
 create mode 100644 arch/mips/jz4740/board-n516.c

diff --git a/arch/mips/include/asm/mach-jz4740/board-n516.h b/arch/mips/include/asm/mach-jz4740/board-n516.h
new file mode 100644
index 0000000..f3f1e0a
--- /dev/null
+++ b/arch/mips/include/asm/mach-jz4740/board-n516.h
@@ -0,0 +1,39 @@
+/*
+ *  linux/include/asm-mips/mach-jz4740/board-n516.h
+ *
+ *  JZ4730-based N516 board definition.
+ *
+ *  Copyright (C) 2009, Yauhen Kharuzhy <jekhor@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __ASM_JZ4740_N516_H__
+#define __ASM_JZ4740_N516_H__
+
+#include <asm/mach-jz4740/gpio.h>
+
+/*
+ * GPIO
+ */
+#define GPIO_SD_VCC_EN_N	JZ_GPIO_PORTD(17)
+#define GPIO_SD_CD_N		JZ_GPIO_PORTD(7)
+#define GPIO_SD_WP		JZ_GPIO_PORTD(15)
+#define GPIO_USB_DETECT		JZ_GPIO_PORTD(19)
+#define GPIO_CHARG_STAT_N	JZ_GPIO_PORTD(16)
+#define GPIO_LED_ENABLE		JZ_GPIO_PORTD(28)
+#define GPIO_LPC_INT		JZ_GPIO_PORTD(14)
+#define GPIO_HPHONE_DETECT	JZ_GPIO_PORTD(20)
+#define GPIO_SPEAKER_ENABLE	JZ_GPIO_PORTD(21)
+
+/* Display */
+#define GPIO_DISPLAY_RST_L	JZ_GPIO_PORTB(18)
+#define GPIO_DISPLAY_RDY	JZ_GPIO_PORTB(17)
+#define GPIO_DISPLAY_STBY	JZ_GPIO_PORTC(22)
+#define GPIO_DISPLAY_ERR	JZ_GPIO_PORTC(23)
+#define GPIO_DISPLAY_OFF	JZ_GPIO_PORTD(1)
+
+#endif /* __ASM_JZ4740_N516_H__ */
diff --git a/arch/mips/jz4740/Kconfig b/arch/mips/jz4740/Kconfig
index 3de3b99..b987c27 100644
--- a/arch/mips/jz4740/Kconfig
+++ b/arch/mips/jz4740/Kconfig
@@ -7,6 +7,10 @@ config JZ4740_QI_LB60
 	bool "Qi Hardware Ben NanoNote"
 	select SOC_JZ4740
 
+config JZ4740_N516
+	bool "Hanvon n516 eBook reader"
+	select SOC_JZ4740
+
 endchoice
 
 config HAVE_PWM
diff --git a/arch/mips/jz4740/Makefile b/arch/mips/jz4740/Makefile
index deca88e..9ed5e5b 100644
--- a/arch/mips/jz4740/Makefile
+++ b/arch/mips/jz4740/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_DEBUG_FS) += clock-debugfs.o
 # board specific support
 
 obj-$(CONFIG_JZ4740_QI_LB60)	+= board-qi_lb60.o
+obj-$(CONFIG_JZ4740_N516)	+= board-n516.o board-n516-display.o
 
 # PM support
 
diff --git a/arch/mips/jz4740/board-n516-display.c b/arch/mips/jz4740/board-n516-display.c
new file mode 100644
index 0000000..44d8237
--- /dev/null
+++ b/arch/mips/jz4740/board-n516-display.c
@@ -0,0 +1,393 @@
+/*
+ * board-n516-display.c -- Platform device for N516 display
+ *
+ * Copyright (C) 2009, Yauhen Kharuzhy <jekhor@gmail.com>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive for
+ * more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/fb.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/irq.h>
+#include <linux/gpio.h>
+#include <linux/jz4740_fb.h>
+
+#include <asm/mach-jz4740/platform.h>
+#include <asm/mach-jz4740/board-n516.h>
+
+#include <video/metronomefb.h>
+#include <linux/console.h>
+
+static struct fb_videomode n516_fb_modes[] = {
+	[0] = {
+		.name		= "Metronome 800x600",
+		.refresh	= 50,
+		.xres		= 400,
+		.yres		= 624,
+		.hsync_len	= 31,
+		.vsync_len	= 23,
+		.right_margin	= 31,
+		.left_margin	= 5,
+		.upper_margin	= 1,
+		.lower_margin	= 2,
+		.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+	},
+};
+
+static struct jz4740_fb_platform_data n516_fb_pdata = {
+	.num_modes	= ARRAY_SIZE(n516_fb_modes),
+	.modes		= n516_fb_modes,
+	.bpp		= 16,
+	.lcd_type	= JZ_LCD_TYPE_GENERIC_16_BIT,
+};
+
+struct n516_board_info {
+	uint8_t *metromem;
+	size_t wfm_size;
+	struct fb_info *host_fbinfo; /* the host LCD controller's fbi */
+	unsigned int fw;
+	unsigned int fh;
+};
+
+static struct platform_device *n516_device;
+static struct n516_board_info n516_board_info;
+
+static int metronome_gpios[] = {
+	GPIO_DISPLAY_STBY,
+	GPIO_DISPLAY_RST_L,
+	GPIO_DISPLAY_RDY,
+	GPIO_DISPLAY_ERR,
+/*	GPIO_DISPLAY_OFF,*/
+};
+
+static const char *metronome_gpio_names[] = {
+	"Metronome STDBY",
+	"Metronome RST",
+	"Metronome RDY",
+	"Metronome ERR",
+/*	"Metronone OFF",*/
+};
+
+static int n516_enable_hostfb(bool enable)
+{
+	int ret;
+	int blank = enable ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
+
+	acquire_console_sem();
+	ret = fb_blank(n516_board_info.host_fbinfo, blank);
+	release_console_sem();
+
+	return ret;
+}
+
+static int n516_init_metronome_gpios(struct metronomefb_par *par)
+{
+	int i;
+	int ret;
+
+	for (i = 0; i < ARRAY_SIZE(metronome_gpios); ++i) {
+		ret = gpio_request(metronome_gpios[i], metronome_gpio_names[i]);
+		if (ret)
+			goto err;
+	}
+
+	gpio_direction_output(GPIO_DISPLAY_OFF, 0);
+	gpio_direction_output(GPIO_DISPLAY_RST_L, 0);
+	gpio_direction_output(GPIO_DISPLAY_STBY, 0);
+	gpio_direction_input(GPIO_DISPLAY_RDY);
+	gpio_direction_input(GPIO_DISPLAY_ERR);
+
+	return 0;
+err:
+	for (--i; i >= 0; --i)
+		gpio_free(metronome_gpios[i]);
+
+	return ret;
+}
+
+static int n516_share_video_mem(struct fb_info *info)
+{
+	int ret;
+
+	dev_dbg(&n516_device->dev, "ENTER %s\n", __func__);
+	dev_dbg(&n516_device->dev, "%s, info->var.xres = %u, info->var.yres = %u\n", __func__, info->var.xres, info->var.yres);
+	/* rough check if this is our desired fb and not something else */
+	if ((info->var.xres != n516_fb_pdata.modes[0].xres)
+		|| (info->var.yres != n516_fb_pdata.modes[0].yres))
+		return 0;
+
+	/* we've now been notified that we have our new fb */
+	n516_board_info.metromem = info->screen_base;
+	n516_board_info.host_fbinfo = info;
+
+	n516_enable_hostfb(false);
+	/* try to refcount host drv since we are the consumer after this */
+	if (!try_module_get(info->fbops->owner))
+		return -ENODEV;
+
+	/* this _add binds metronomefb to n516. metronomefb refcounts n516 */
+	ret = platform_device_add(n516_device);
+
+	if (ret) {
+		platform_device_put(n516_device);
+		return ret;
+	}
+
+	/* request our platform independent driver */
+	request_module("metronomefb");
+
+	return 0;
+}
+
+static int n516_unshare_video_mem(struct fb_info *info)
+{
+	dev_dbg(&n516_device->dev, "ENTER %s\n", __func__);
+
+	if (info != n516_board_info.host_fbinfo)
+		return 0;
+
+	module_put(n516_board_info.host_fbinfo->fbops->owner);
+	return 0;
+}
+
+static int n516_fb_notifier_callback(struct notifier_block *self,
+				 unsigned long event, void *data)
+{
+	struct fb_event *evdata = data;
+	struct fb_info *info = evdata->info;
+
+	dev_dbg(&n516_device->dev, "ENTER %s\n", __func__);
+
+	if (event == FB_EVENT_FB_REGISTERED)
+		return n516_share_video_mem(info);
+	else if (event == FB_EVENT_FB_UNREGISTERED)
+		return n516_unshare_video_mem(info);
+
+	return 0;
+}
+
+static struct notifier_block n516_fb_notif = {
+	.notifier_call = n516_fb_notifier_callback,
+};
+
+/* this gets called as part of our init. these steps must be done now so
+ * that we can use set_pxa_fb_info */
+static void __init n516_presetup_fb(void)
+{
+	int padding_size;
+	int totalsize;
+
+	/* the frame buffer is divided as follows:
+	command | CRC | padding
+	16kb waveform data | CRC | padding
+	image data | CRC
+	*/
+
+	n516_board_info.fw = 800;
+	n516_board_info.fh = 624;
+
+	/* waveform must be 16k + 2 for checksum */
+	n516_board_info.wfm_size = roundup(16*1024 + 2, n516_board_info.fw);
+
+	padding_size = PAGE_SIZE + (4 * n516_board_info.fw);
+
+	/* total is 1 cmd , 1 wfm, padding and image */
+	totalsize = n516_board_info.fw + n516_board_info.wfm_size;
+	totalsize += padding_size + (n516_board_info.fw*n516_board_info.fh);
+
+	/* save this off because we're manipulating fw after this and
+	 * we'll need it when we're ready to setup the framebuffer */
+
+	/* the reason we do this adjustment is because we want to acquire
+	 * more framebuffer memory without imposing custom awareness on the
+	 * underlying driver */
+	n516_fb_pdata.modes[0].yres = DIV_ROUND_UP(totalsize, n516_board_info.fw);
+
+	jz4740_framebuffer_device.dev.platform_data = &n516_fb_pdata;
+	platform_device_register(&jz4740_framebuffer_device);
+}
+
+/* this gets called by metronomefb as part of its init, in our case, we
+ * have already completed initial framebuffer init in presetup_fb so we
+ * can just setup the fb access pointers */
+static int n516_setup_fb(struct metronomefb_par *par)
+{
+	/* metromem was set up by the notifier in share_video_mem so now
+	 * we can use its value to calculate the other entries */
+	par->metromem_cmd = (struct metromem_cmd *) n516_board_info.metromem;
+	par->metromem_wfm = n516_board_info.metromem + n516_board_info.fw;
+	par->metromem_img = par->metromem_wfm + n516_board_info.wfm_size;
+	par->metromem_img_csum = (u16 *) (par->metromem_img + (n516_board_info.fw * n516_board_info.fh));
+	par->metromem_dma = n516_board_info.host_fbinfo->fix.smem_start;
+
+	return 0;
+}
+
+static int n516_get_panel_type(void)
+{
+	return 5;
+}
+
+static irqreturn_t n516_handle_irq(int irq, void *dev_id)
+{
+	struct metronomefb_par *par = dev_id;
+
+	dev_dbg(&par->pdev->dev, "Metronome IRQ! RDY=%d\n", 	gpio_get_value(GPIO_DISPLAY_RDY));
+	wake_up_all(&par->waitq);
+
+	return IRQ_HANDLED;
+}
+
+static void n516_power_ctl(struct metronomefb_par *par, int cmd)
+{
+	switch (cmd) {
+	case METRONOME_POWER_OFF:
+		gpio_set_value(GPIO_DISPLAY_OFF, 1);
+		n516_enable_hostfb(false);
+		break;
+	case METRONOME_POWER_ON:
+		gpio_set_value(GPIO_DISPLAY_OFF, 0);
+		n516_enable_hostfb(true);
+		break;
+	}
+}
+
+static int n516_get_rdy(struct metronomefb_par *par)
+{
+	return gpio_get_value(GPIO_DISPLAY_RDY);
+}
+
+static int n516_get_err(struct metronomefb_par *par)
+{
+	return gpio_get_value(GPIO_DISPLAY_ERR);
+}
+
+static int n516_setup_irq(struct fb_info *info)
+{
+	int ret;
+
+	dev_dbg(&n516_device->dev, "ENTER %s\n", __func__);
+
+	ret = request_irq(gpio_to_irq(GPIO_DISPLAY_RDY), n516_handle_irq,
+				IRQF_TRIGGER_RISING,
+				"n516", info->par);
+	if (ret)
+		dev_err(&n516_device->dev, "request_irq failed: %d\n", ret);
+
+	return ret;
+}
+
+static void n516_set_rst(struct metronomefb_par *par, int state)
+{
+	dev_dbg(&n516_device->dev, "ENTER %s, RDY=%d\n", __func__, gpio_get_value(GPIO_DISPLAY_RDY));
+	if (state)
+		gpio_set_value(GPIO_DISPLAY_RST_L, 1);
+	else
+		gpio_set_value(GPIO_DISPLAY_RST_L, 0);
+}
+
+static void n516_set_stdby(struct metronomefb_par *par, int state)
+{
+	dev_dbg(&n516_device->dev, "ENTER %s, RDY=%d\n", __func__, gpio_get_value(GPIO_DISPLAY_RDY));
+	if (state)
+		gpio_set_value(GPIO_DISPLAY_STBY, 1);
+	else
+		gpio_set_value(GPIO_DISPLAY_STBY, 0);
+}
+
+static int n516_wait_event(struct metronomefb_par *par)
+{
+	unsigned long timeout = jiffies + HZ / 20;
+
+	dev_dbg(&n516_device->dev, "ENTER1 %s, RDY=%d\n",
+			__func__, gpio_get_value(GPIO_DISPLAY_RDY));
+	while (n516_get_rdy(par) && time_before(jiffies, timeout))
+		schedule();
+
+	dev_dbg(&n516_device->dev, "ENTER2 %s, RDY=%d\n",
+			__func__, gpio_get_value(GPIO_DISPLAY_RDY));
+	return wait_event_timeout(par->waitq,
+			n516_get_rdy(par), HZ * 2) ? 0 : -EIO;
+}
+
+static int n516_wait_event_intr(struct metronomefb_par *par)
+{
+	unsigned long timeout = jiffies + HZ/20;
+
+	dev_dbg(&n516_device->dev, "ENTER1 %s, RDY=%d\n",
+			__func__, gpio_get_value(GPIO_DISPLAY_RDY));
+	while (n516_get_rdy(par) && time_before(jiffies, timeout))
+		schedule();
+
+	dev_dbg(&n516_device->dev, "ENTER2 %s, RDY=%d\n",
+			__func__, gpio_get_value(GPIO_DISPLAY_RDY));
+	return wait_event_interruptible_timeout(par->waitq,
+					n516_get_rdy(par), HZ * 2) ? 0 : -EIO;
+}
+
+static void n516_cleanup(struct metronomefb_par *par)
+{
+	int i;
+
+	free_irq(gpio_to_irq(GPIO_DISPLAY_RDY), par);
+	for (i = 0; i < ARRAY_SIZE(metronome_gpios); ++i)
+		gpio_free(metronome_gpios[i]);
+}
+
+static struct metronome_board n516_board __initdata = {
+	.owner			= THIS_MODULE,
+	.power_ctl		= n516_power_ctl,
+	.setup_irq		= n516_setup_irq,
+	.setup_io		= n516_init_metronome_gpios,
+	.setup_fb		= n516_setup_fb,
+	.set_rst		= n516_set_rst,
+	.get_err		= n516_get_err,
+	.get_rdy		= n516_get_rdy,
+	.set_stdby		= n516_set_stdby,
+	.met_wait_event		= n516_wait_event,
+	.met_wait_event_intr	= n516_wait_event_intr,
+	.get_panel_type		= n516_get_panel_type,
+	.cleanup		= n516_cleanup,
+};
+
+static int __init n516_init(void)
+{
+	int ret;
+
+	/* Keep the metronome off, until its driver is loaded */
+	ret = gpio_request(GPIO_DISPLAY_OFF, "Display off");
+	if (ret)
+		return ret;
+
+	gpio_direction_output(GPIO_DISPLAY_OFF, 1);
+
+	/* before anything else, we request notification for any fb
+	 * creation events */
+	fb_register_client(&n516_fb_notif);
+
+	n516_device = platform_device_alloc("metronomefb", -1);
+	if (!n516_device)
+		return -ENOMEM;
+
+	/* the n516_board that will be seen by metronomefb is a copy */
+	platform_device_add_data(n516_device, &n516_board,
+					sizeof(n516_board));
+
+	n516_presetup_fb();
+
+	return 0;
+}
+module_init(n516_init);
+
+MODULE_DESCRIPTION("board driver for n516 display");
+MODULE_AUTHOR("Yauhen Kharuzhy");
+MODULE_LICENSE("GPL");
diff --git a/arch/mips/jz4740/board-n516.c b/arch/mips/jz4740/board-n516.c
new file mode 100644
index 0000000..efb8747
--- /dev/null
+++ b/arch/mips/jz4740/board-n516.c
@@ -0,0 +1,206 @@
+/*
+ * linux/arch/mips/jz4740/board-516.c
+ *
+ * JZ4740 n516 board setup routines.
+ *
+ * Copyright (c) 2009, Yauhen Kharuzhy <jekhor@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/console.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mmc/jz4740_mmc.h>
+#include <linux/mtd/jz4740_nand.h>
+#include <linux/leds.h>
+
+#include <linux/power_supply.h>
+#include <linux/power/gpio-charger.h>
+
+#include <linux/i2c.h>
+#include <linux/i2c-gpio.h>
+
+#include <asm/mach-jz4740/board-n516.h>
+#include <asm/mach-jz4740/platform.h>
+
+#include "clock.h"
+
+static long n516_panic_blink(long time)
+{
+	gpio_set_value(GPIO_LED_ENABLE, 1);
+	mdelay(200);
+	gpio_set_value(GPIO_LED_ENABLE, 0);
+	mdelay(200);
+
+	return 400;
+}
+
+static void __init board_gpio_setup(void)
+{
+/*	jz_gpio_enable_pullup(JZ_GPIO_PORTD(23));
+	jz_gpio_enable_pullup(JZ_GPIO_PORTD(24));*/
+}
+
+static struct i2c_gpio_platform_data n516_i2c_pdata = {
+	.sda_pin = JZ_GPIO_PORTD(23),
+	.scl_pin = JZ_GPIO_PORTD(24),
+	.udelay = 2,
+	.timeout = 3 * HZ,
+};
+
+static struct platform_device n516_i2c_device = {
+	.name = "i2c-gpio",
+	.id = -1,
+	.dev = {
+		.platform_data = &n516_i2c_pdata,
+	},
+};
+
+static const struct i2c_board_info n516_i2c_board_info[] = {
+	{
+		.type		= "LPC524",
+		.addr		= 0x54,
+	},
+	{
+		.type		= "lm75a",
+		.addr		= 0x48,
+	}
+};
+
+static struct jz4740_mmc_platform_data n516_mmc_pdata = {
+	.gpio_card_detect	= GPIO_SD_CD_N,
+	.card_detect_active_low = 1,
+	.gpio_read_only		= -1,
+	.gpio_power		= GPIO_SD_VCC_EN_N,
+	.power_active_low = 1,
+};
+
+static struct gpio_led n516_leds[] = {
+	{
+		.name = "n516:blue:power",
+		.gpio = GPIO_LED_ENABLE,
+		.default_state = LEDS_GPIO_DEFSTATE_ON,
+		.default_trigger = "nand-disk",
+	}
+};
+
+static struct gpio_led_platform_data n516_leds_pdata = {
+	.leds = n516_leds,
+	.num_leds = ARRAY_SIZE(n516_leds),
+};
+
+static struct platform_device n516_leds_device = {
+	.name = "leds-gpio",
+	.id = -1,
+	.dev = {
+		.platform_data = &n516_leds_pdata,
+	},
+};
+
+static struct mtd_partition n516_partitions[] = {
+	{ .name = "NAND BOOT partition",
+	  .offset = 0 * 0x100000,
+	  .size = 4 * 0x100000,
+	},
+	{ .name = "NAND KERNEL partition",
+	  .offset = 4 * 0x100000,
+	  .size = 4 * 0x100000,
+ 	},
+	{ .name = "NAND ROOTFS partition",
+	  .offset = 8 * 0x100000,
+	  .size = 504 * 0x100000,
+ 	},
+};
+
+static struct nand_ecclayout n516_ecclayout = {
+	.eccbytes = 36,
+	.eccpos = {
+		 6,  7,  8,  9, 10, 11, 12, 13, 14,
+		15, 16, 17, 18, 19, 20, 21, 22, 23,
+		24, 25, 26, 27, 28, 29, 30, 31, 32,
+		33, 34, 35, 36, 37, 38, 39, 40, 41,
+	},
+	.oobfree = {
+		{
+			.offset = 2,
+			.length = 4
+		},
+		{
+			.offset = 42,
+			.length = 22,
+		}
+	}
+};
+
+static struct jz_nand_platform_data n516_nand_pdata = {
+	.ecc_layout = &n516_ecclayout,
+	.partitions = n516_partitions,
+	.num_partitions = ARRAY_SIZE(n516_partitions),
+	.busy_gpio = 94,
+};
+
+static char *n516_batteries[] = {
+	"n516_battery",
+};
+
+static struct gpio_charger_platform_data n516_charger_pdata = {
+	.name = "usb",
+	.type = POWER_SUPPLY_TYPE_USB,
+	.gpio = GPIO_USB_DETECT,
+	.gpio_active_low = 1,
+	.batteries = n516_batteries,
+	.num_batteries = ARRAY_SIZE(n516_batteries),
+};
+
+static struct platform_device n516_charger_device = {
+	.name = "gpio-charger",
+	.dev = {
+		.platform_data = &n516_charger_pdata,
+	},
+};
+
+static struct platform_device *n516_devices[] __initdata = {
+	&jz4740_nand_device,
+	&n516_leds_device,
+	&jz4740_mmc_device,
+	&jz4740_i2s_device,
+	&jz4740_codec_device,
+	&jz4740_rtc_device,
+	&jz4740_usb_gdt_device,
+	&n516_i2c_device,
+	&n516_charger_device,
+};
+
+struct jz4740_clock_board_data jz4740_clock_bdata = {
+	.ext_rate = 12000000,
+	.rtc_rate = 32768,
+};
+
+extern int jz_gpiolib_init(void);
+
+static int n516_setup_platform(void)
+{
+	if (jz_gpiolib_init())
+		panic("Failed to initalize jz gpio\n");
+
+	jz4740_clock_init();
+	board_gpio_setup();
+
+	panic_blink = n516_panic_blink;
+	i2c_register_board_info(0, n516_i2c_board_info, ARRAY_SIZE(n516_i2c_board_info));
+	jz4740_mmc_device.dev.platform_data = &n516_mmc_pdata;
+	jz4740_nand_device.dev.platform_data = &n516_nand_pdata;
+
+	return platform_add_devices(n516_devices, ARRAY_SIZE(n516_devices));
+}
+arch_initcall(n516_setup_platform);
-- 
1.5.6.5