1 From 7c51f9f9bab723d2cf7ea458ea459cc392a753f7 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
7 arch/mips/jz4740/Kconfig | 4 +
8 arch/mips/jz4740/Makefile | 1 +
9 arch/mips/jz4740/board-n526.c | 327 +++++++++++++++++++++++++++++++++++++++++
10 3 files changed, 332 insertions(+), 0 deletions(-)
11 create mode 100644 arch/mips/jz4740/board-n526.c
13 --- a/arch/mips/jz4740/Kconfig
14 +++ b/arch/mips/jz4740/Kconfig
15 @@ -10,6 +10,10 @@ config JZ4740_N516
16 bool "Hanvon n516 eBook reader"
20 + bool "Hanvon n526 eBook reader"
26 --- a/arch/mips/jz4740/Makefile
27 +++ b/arch/mips/jz4740/Makefile
28 @@ -13,6 +13,7 @@ obj-$(CONFIG_DEBUG_FS) += clock-debugfs.
30 obj-$(CONFIG_JZ4740_QI_LB60) += board-qi_lb60.o
31 obj-$(CONFIG_JZ4740_N516) += board-n516.o board-n516-display.o
32 +obj-$(CONFIG_JZ4740_N526) += board-n526.o
37 +++ b/arch/mips/jz4740/board-n526.c
40 + * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de>
41 + * N526 eBook reader support
43 + * This program is free software; you can redistribute it and/or modify it
44 + * under the terms of the GNU General Public License as published by the
45 + * Free Software Foundation; either version 2 of the License, or (at your
46 + * option) any later version.
48 + * You should have received a copy of the GNU General Public License along
49 + * with this program; if not, write to the Free Software Foundation, Inc.,
50 + * 675 Mass Ave, Cambridge, MA 02139, USA.
54 +#include <linux/kernel.h>
55 +#include <linux/init.h>
56 +#include <linux/gpio.h>
59 +#include <linux/power_supply.h>
61 +#include <video/broadsheetfb.h>
62 +#include <linux/delay.h>
63 +#include <linux/interrupt.h>
65 +#include <linux/input.h>
66 +#include <linux/gpio_keys.h>
68 +#include <linux/i2c.h>
69 +#include <linux/i2c-gpio.h>
73 +#include <asm/mach-jz4740/jz4740_mmc.h>
74 +#include <asm/mach-jz4740/jz4740_nand.h>
75 +#include <asm/mach-jz4740/jz4740_fb.h>
77 +#include <asm/mach-jz4740/platform.h>
80 +static struct nand_ecclayout n526_ecclayout = {
83 + 6, 7, 8, 9, 10, 11, 12, 13,
84 + 14, 15, 16, 17, 18, 19, 20, 21,
85 + 22, 23, 24, 25, 26, 27, 28, 29,
86 + 30, 31, 32, 33, 34, 35, 36, 37,
95 +static struct mtd_partition n526_partitions[] = {
96 + { .name = "NAND BOOT partition",
97 + .offset = 0 * 0x100000,
98 + .size = 4 * 0x100000,
100 + { .name = "NAND KERNEL partition",
101 + .offset = 4 * 0x100000,
102 + .size = 4 * 0x100000,
104 + { .name = "NAND ROOTFS partition",
105 + .offset = 16 * 0x100000,
106 + .size = 498 * 0x100000,
110 +static struct jz_nand_platform_data n526_nand_pdata = {
111 + .ecc_layout = &n526_ecclayout,
112 + .partitions = n526_partitions,
113 + .num_partitions = ARRAY_SIZE(n526_partitions),
117 +static struct jz4740_mmc_platform_data n526_mmc_pdata = {
118 + .gpio_card_detect = JZ_GPIO_PORTD(7),
119 + .card_detect_active_low = 1,
120 + .gpio_read_only = -1,
121 + .gpio_power = JZ_GPIO_PORTD(17),
122 + .power_active_low = 1,
125 +static struct gpio_led n526_leds[] = {
127 + .name = "n526:blue:power",
128 + .gpio = JZ_GPIO_PORTD(28),
129 + .default_state = LEDS_GPIO_DEFSTATE_ON,
133 +static struct gpio_led_platform_data n526_leds_pdata = {
135 + .num_leds = ARRAY_SIZE(n526_leds),
138 +static struct platform_device n526_leds_device = {
139 + .name = "leds-gpio",
142 + .platform_data = &n526_leds_pdata,
146 +static void __init board_gpio_setup(void)
148 + /* We only need to enable/disable pullup here for pins used in generic
149 + * drivers. Everything else is done by the drivers themselfs. */
150 + jz_gpio_disable_pullup(JZ_GPIO_PORTD(17));
151 + jz_gpio_enable_pullup(JZ_GPIO_PORTD(7));
152 + jz_gpio_disable_pullup(JZ_GPIO_PORTC(19));
153 + jz_gpio_disable_pullup(JZ_GPIO_PORTC(20));
154 + jz_gpio_disable_pullup(JZ_GPIO_PORTC(21));
155 + jz_gpio_disable_pullup(JZ_GPIO_PORTC(23));
159 +static const int n526_eink_ctrl_gpios[] = {
166 +static void n526_eink_set_ctl(struct broadsheetfb_par * par, unsigned char ctrl, u8
169 + gpio_set_value(n526_eink_ctrl_gpios[ctrl], value);
173 +static int n526_eink_wait(struct broadsheetfb_par *par)
175 + wait_event(par->waitq, gpio_get_value(JZ_GPIO_PORTB(17)));
180 +static u16 n526_eink_get_hdb(struct broadsheetfb_par *par)
183 + jz_gpio_port_direction_input(JZ_GPIO_PORTC(0), 0xffff);
184 + gpio_set_value(JZ_GPIO_PORTC(21), 0);
187 + value = jz_gpio_port_get_value(JZ_GPIO_PORTC(0), 0xffff);
189 + gpio_set_value(JZ_GPIO_PORTC(21), 1);
190 + jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff);
194 +static void n526_eink_set_hdb(struct broadsheetfb_par *par, u16 value)
196 + jz_gpio_port_set_value(JZ_GPIO_PORTC(0), value, 0xffff);
199 +static int n526_eink_init(struct broadsheetfb_par *par)
203 + gpio_request(JZ_GPIO_PORTD(1), "display reset");
204 + gpio_direction_output(JZ_GPIO_PORTD(1), 1);
206 + gpio_set_value(JZ_GPIO_PORTD(1), 0);
208 + gpio_request(JZ_GPIO_PORTB(18), "eink enable");
209 + gpio_direction_output(JZ_GPIO_PORTB(18), 0);
211 + gpio_request(JZ_GPIO_PORTB(29), "foobar");
212 + gpio_direction_output(JZ_GPIO_PORTB(29), 1);
214 + for(i = 1; i < ARRAY_SIZE(n526_eink_ctrl_gpios); ++i) {
215 + gpio_request(n526_eink_ctrl_gpios[i], "eink display ctrl");
216 + gpio_direction_output(n526_eink_ctrl_gpios[i], 0);
219 + gpio_request(JZ_GPIO_PORTC(22), "foobar");
220 + gpio_direction_input(JZ_GPIO_PORTC(22));
221 + gpio_request(JZ_GPIO_PORTC(21), "eink nRD");
222 + gpio_direction_output(JZ_GPIO_PORTC(21), 1);
224 + for(i = 0; i < 16; ++i) {
225 + gpio_request(JZ_GPIO_PORTC(i), "eink display data");
227 + jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff);
229 + gpio_set_value(JZ_GPIO_PORTB(18), 1);
234 +static irqreturn_t n526_eink_busy_irq(int irq, void *devid)
236 + struct broadsheetfb_par *par = devid;
237 + wake_up(&par->waitq);
239 + return IRQ_HANDLED;
242 +static int n526_eink_setup_irq(struct fb_info *info)
245 + struct broadsheetfb_par *par = info->par;
247 + gpio_request(JZ_GPIO_PORTB(17), "eink busy");
248 + gpio_direction_input(JZ_GPIO_PORTB(17));
250 + ret = request_irq(gpio_to_irq(JZ_GPIO_PORTB(17)), n526_eink_busy_irq,
251 + IRQF_DISABLED | IRQF_TRIGGER_RISING,
252 + "eink busyline", par);
254 + printk("n526 display: Failed to request busyline irq: %d\n", ret);
258 +static void n526_eink_cleanup(struct broadsheetfb_par *par)
262 +static struct broadsheet_board broadsheet_pdata = {
263 + .owner = THIS_MODULE,
264 + .init = n526_eink_init,
265 + .wait_for_rdy = n526_eink_wait,
266 + .set_ctl = n526_eink_set_ctl,
267 + .set_hdb = n526_eink_set_hdb,
268 + .get_hdb = n526_eink_get_hdb,
269 + .cleanup = n526_eink_cleanup,
270 + .setup_irq = n526_eink_setup_irq,
273 +static struct platform_device n526_broadsheet_device = {
274 + .name = "broadsheetfb",
277 + .platform_data = &broadsheet_pdata,
281 +static struct gpio_keys_button qi_lb60_gpio_keys_buttons[] = {
290 +static struct gpio_keys_platform_data qi_lb60_gpio_keys_data = {
291 + .nbuttons = ARRAY_SIZE(qi_lb60_gpio_keys_buttons),
292 + .buttons = qi_lb60_gpio_keys_buttons,
295 +static struct platform_device qi_lb60_gpio_keys = {
296 + .name = "gpio-keys",
299 + .platform_data = &qi_lb60_gpio_keys_data,
303 +static struct i2c_gpio_platform_data n526_i2c_pdata = {
304 + .sda_pin = JZ_GPIO_PORTD(23),
305 + .scl_pin = JZ_GPIO_PORTD(24),
310 +static struct platform_device n526_i2c_device = {
311 + .name = "i2c-gpio",
314 + .platform_data = &n526_i2c_pdata,
318 +static struct i2c_board_info n526_i2c_board_info = {
319 + .type = "n526-lpc",
323 +static struct platform_device *jz_platform_devices[] __initdata = {
324 + &jz4740_usb_ohci_device,
325 + &jz4740_udc_device,
326 + &jz4740_mmc_device,
327 + &jz4740_nand_device,
328 + &jz4740_i2s_device,
329 + &jz4740_codec_device,
330 + &jz4740_rtc_device,
332 + &n526_broadsheet_device,
333 + &qi_lb60_gpio_keys,
337 +static int __init n526_init_platform_devices(void)
340 + jz4740_nand_device.dev.platform_data = &n526_nand_pdata;
341 + jz4740_mmc_device.dev.platform_data = &n526_mmc_pdata;
343 + n526_i2c_board_info.irq = gpio_to_irq(JZ_GPIO_PORTD(14)),
344 + i2c_register_board_info(0, &n526_i2c_board_info, 1);
346 + return platform_add_devices(jz_platform_devices,
347 + ARRAY_SIZE(jz_platform_devices));
351 +struct jz4740_clock_board_data jz4740_clock_bdata = {
352 + .ext_rate = 12000000,
356 +static int __init n526_board_setup(void)
358 + board_gpio_setup();
360 + if (n526_init_platform_devices())
361 + panic("Failed to initalize platform devices\n");
365 +arch_initcall(n526_board_setup);