aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/xburst/patches-2.6.37/008-add-id800wt-board-support.patch
Commit message (Expand)AuthorAgeFilesLines
* Add 2.6.37 supportLars-Peter Clausen2011-01-061-0/+196
'>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
From 5739f1348052000ed12a7745f7bafd352fff832a Mon Sep 17 00:00:00 2001
From: Lars-Peter Clausen <lars@metafoo.de>
Date: Sat, 24 Apr 2010 17:25:23 +0200
Subject: [PATCH 07/23] Add n526 board support

---
 arch/mips/jz4740/Kconfig      |    4 +
 arch/mips/jz4740/Makefile     |    1 +
 arch/mips/jz4740/board-n526.c |  318 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 323 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/jz4740/board-n526.c

--- a/arch/mips/jz4740/Kconfig
+++ b/arch/mips/jz4740/Kconfig
@@ -10,6 +10,10 @@ config JZ4740_N516
 	bool "Hanvon n516 eBook reader"
 	select SOC_JZ4740
 
+config JZ4740_N526
+	bool "Hanvon n526 eBook reader"
+	select SOC_JZ4740
+
 endchoice
 
 config HAVE_PWM
--- a/arch/mips/jz4740/Makefile
+++ b/arch/mips/jz4740/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_DEBUG_FS) += clock-debugfs.
 
 obj-$(CONFIG_JZ4740_QI_LB60)	+= board-qi_lb60.o
 obj-$(CONFIG_JZ4740_N516)	+= board-n516.o board-n516-display.o
+obj-$(CONFIG_JZ4740_N526)	+= board-n526.o
 
 # PM support
 
--- /dev/null
+++ b/arch/mips/jz4740/board-n526.c
@@ -0,0 +1,320 @@
+/*
+ *  Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de>
+ *  	N526 eBook reader support
+ *
+ *  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.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/gpio.h>
+
+#include <linux/mutex.h>
+#include <linux/wait.h>
+#include <video/broadsheetfb.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+
+#include <linux/input.h>
+#include <linux/gpio_keys.h>
+
+#include <linux/leds.h>
+
+#include <linux/i2c.h>
+
+#include "clock.h"
+
+#include <asm/mach-jz4740/jz4740_mmc.h>
+#include <asm/mach-jz4740/jz4740_nand.h>
+#include <asm/mach-jz4740/jz4740_fb.h>
+
+#include <asm/mach-jz4740/platform.h>
+
+/* NAND */
+static struct nand_ecclayout n526_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 mtd_partition n526_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 = 16 * 0x100000,
+	  .size = 498 * 0x100000,
+ 	},
+};
+
+static struct jz_nand_platform_data n526_nand_pdata = {
+	.ecc_layout = &n526_ecclayout,
+	.partitions = n526_partitions,
+	.num_partitions = ARRAY_SIZE(n526_partitions),
+	.busy_gpio = JZ_GPIO_PORTC(30),
+};
+
+static struct jz4740_mmc_platform_data n526_mmc_pdata = {
+	.gpio_card_detect	= JZ_GPIO_PORTD(7),
+	.card_detect_active_low = 1,
+	.gpio_read_only		= -1,
+	.gpio_power		= JZ_GPIO_PORTD(17),
+	.power_active_low	= 1,
+};
+
+static struct gpio_led n526_leds[] = {
+	{
+		.name = "n526:blue:power",
+		.gpio = JZ_GPIO_PORTD(28),
+		.default_state = LEDS_GPIO_DEFSTATE_ON,
+	}
+};
+
+static struct gpio_led_platform_data n526_leds_pdata = {
+	.leds = n526_leds,
+	.num_leds = ARRAY_SIZE(n526_leds),
+};
+
+static struct platform_device n526_leds_device = {
+	.name = "leds-gpio",
+	.id = -1,
+	.dev = {
+		.platform_data = &n526_leds_pdata,
+	},
+};
+
+static void __init board_gpio_setup(void)
+{
+	/* We only need to enable/disable pullup here for pins used in generic
+	 * drivers. Everything else is done by the drivers themselfs. */
+	jz_gpio_disable_pullup(JZ_GPIO_PORTD(17));
+	jz_gpio_enable_pullup(JZ_GPIO_PORTD(7));
+	jz_gpio_disable_pullup(JZ_GPIO_PORTC(19));
+	jz_gpio_disable_pullup(JZ_GPIO_PORTC(20));
+	jz_gpio_disable_pullup(JZ_GPIO_PORTC(21));
+	jz_gpio_disable_pullup(JZ_GPIO_PORTC(23));
+}
+
+
+static const int n526_eink_ctrl_gpios[] = {
+	0,
+	JZ_GPIO_PORTC(23),
+	JZ_GPIO_PORTC(19),
+	JZ_GPIO_PORTC(20),
+};
+
+static void n526_eink_set_ctl(struct broadsheetfb_par * par, unsigned char ctrl, u8
+value)
+{
+	gpio_set_value(n526_eink_ctrl_gpios[ctrl], value);
+}
+
+
+static int n526_eink_wait(struct broadsheetfb_par *par)
+{
+	wait_event(par->waitq, gpio_get_value(JZ_GPIO_PORTB(17)));
+
+	return 0;
+}
+
+static u16 n526_eink_get_hdb(struct broadsheetfb_par *par)
+{
+	u16 value = 0;
+	jz_gpio_port_direction_input(JZ_GPIO_PORTC(0), 0xffff);
+	gpio_set_value(JZ_GPIO_PORTC(21), 0);
+	mdelay(100);
+
+	value = jz_gpio_port_get_value(JZ_GPIO_PORTC(0), 0xffff);
+
+	gpio_set_value(JZ_GPIO_PORTC(21), 1);
+	jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff);
+	return value;
+}
+
+static void n526_eink_set_hdb(struct broadsheetfb_par *par, u16 value)
+{
+	jz_gpio_port_set_value(JZ_GPIO_PORTC(0), value, 0xffff);
+}
+
+static int n526_eink_init(struct broadsheetfb_par *par)
+{
+	int i;
+
+	gpio_request(JZ_GPIO_PORTD(1), "display reset");
+	gpio_direction_output(JZ_GPIO_PORTD(1), 1);
+	mdelay(10);
+	gpio_set_value(JZ_GPIO_PORTD(1), 0);
+
+	gpio_request(JZ_GPIO_PORTB(18), "eink enable");
+	gpio_direction_output(JZ_GPIO_PORTB(18), 0);
+
+	gpio_request(JZ_GPIO_PORTB(29), "foobar");
+	gpio_direction_output(JZ_GPIO_PORTB(29), 1);
+
+	for(i = 1; i < ARRAY_SIZE(n526_eink_ctrl_gpios); ++i) {
+		gpio_request(n526_eink_ctrl_gpios[i], "eink display ctrl");
+		gpio_direction_output(n526_eink_ctrl_gpios[i], 0);
+	}
+
+	gpio_request(JZ_GPIO_PORTC(22), "foobar");
+	gpio_direction_input(JZ_GPIO_PORTC(22));
+	gpio_request(JZ_GPIO_PORTC(21), "eink nRD");
+	gpio_direction_output(JZ_GPIO_PORTC(21), 1);
+
+	for(i = 0; i < 16; ++i) {
+		gpio_request(JZ_GPIO_PORTC(i), "eink display data");
+	}
+	jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff);
+
+	gpio_set_value(JZ_GPIO_PORTB(18), 1);
+
+	return 0;
+}
+
+static irqreturn_t n526_eink_busy_irq(int irq, void *devid)
+{
+	struct broadsheetfb_par *par = devid;
+	wake_up(&par->waitq);
+
+	return IRQ_HANDLED;
+}
+
+static int n526_eink_setup_irq(struct fb_info *info)
+{
+	int ret;
+	struct broadsheetfb_par *par = info->par;
+
+	gpio_request(JZ_GPIO_PORTB(17), "eink busy");
+	gpio_direction_input(JZ_GPIO_PORTB(17));
+
+	ret = request_irq(gpio_to_irq(JZ_GPIO_PORTB(17)), n526_eink_busy_irq,
+				IRQF_DISABLED | IRQF_TRIGGER_RISING,
+				"eink busyline", par);
+	if (ret)
+		printk("n526 display: Failed to request busyline irq: %d\n", ret);
+	return 0;
+}
+
+static void n526_eink_cleanup(struct broadsheetfb_par *par)
+{
+}
+
+static struct broadsheet_board broadsheet_pdata = {
+	.owner = THIS_MODULE,
+	.init = n526_eink_init,
+	.wait_for_rdy = n526_eink_wait,
+	.set_ctl = n526_eink_set_ctl,
+	.set_hdb = n526_eink_set_hdb,
+	.get_hdb = n526_eink_get_hdb,
+	.cleanup = n526_eink_cleanup,
+	.setup_irq = n526_eink_setup_irq,
+};
+
+static struct platform_device n526_broadsheet_device = {
+	.name = "broadsheetfb",
+	.id = -1,
+	.dev = {
+		.platform_data = &broadsheet_pdata,
+	},
+};
+
+/* Buttons */
+static struct gpio_keys_button n526_gpio_keys_buttons[] = {
+	[0] = {
+		.code		= KEY_ENTER,
+		.gpio		= 0,
+		.active_low	= 1,
+		.desc		= "Power",
+	},
+};
+
+static struct gpio_keys_platform_data n526_gpio_keys_data = {
+	.nbuttons = ARRAY_SIZE(n526_gpio_keys_buttons),
+	.buttons = n526_gpio_keys_buttons,
+};
+
+static struct platform_device n526_gpio_keys_device = {
+	.name =	"gpio-keys",
+	.id =	-1,
+	.dev = {
+		.platform_data = &n526_gpio_keys_data,
+	}
+};
+
+static struct i2c_board_info n526_i2c_board_info = {
+	.type = "n526-lpc",
+	.addr = 0x54,
+};
+
+static struct platform_device *n526_platform_devices[] __initdata = {
+	&jz4740_usb_ohci_device,
+	&jz4740_udc_device,
+	&jz4740_mmc_device,
+	&jz4740_nand_device,
+	&jz4740_i2s_device,
+	&jz4740_codec_device,
+	&jz4740_pcm_device,
+	&jz4740_rtc_device,
+	&jz4740_i2c_device,
+	&n526_leds_device,
+	&n526_broadsheet_device,
+	&n526_gpio_keys_device,
+};
+
+static int __init n526_init_platform_devices(void)
+{
+	jz4740_nand_device.dev.platform_data = &n526_nand_pdata;
+	jz4740_mmc_device.dev.platform_data = &n526_mmc_pdata;
+
+	jz4740_serial_device_register();
+
+	n526_i2c_board_info.irq = gpio_to_irq(JZ_GPIO_PORTD(14)),
+	i2c_register_board_info(0, &n526_i2c_board_info, 1);
+
+	return platform_add_devices(n526_platform_devices,
+					ARRAY_SIZE(n526_platform_devices));
+
+}
+
+struct jz4740_clock_board_data jz4740_clock_bdata = {
+	.ext_rate = 12000000,
+	.rtc_rate = 32768,
+};
+
+static int __init n526_board_setup(void)
+{
+	board_gpio_setup();
+
+	if (n526_init_platform_devices())
+		panic("Failed to initalize platform devices\n");
+
+	return 0;
+}
+arch_initcall(n526_board_setup);