1 From 876a111075de6fcffbaa0814ee4118ac739df1a9 Mon Sep 17 00:00:00 2001
2 From: Lars-Peter Clausen <lars@metafoo.de>
3 Date: Sat, 24 Apr 2010 17:24:26 +0200
4 Subject: [PATCH] Add qi_lb60 board support
7 arch/mips/include/asm/mach-jz4740/board-qi_lb60.h | 51 +++
8 arch/mips/jz4740/Kconfig | 4 +
9 arch/mips/jz4740/Makefile | 2 +
10 arch/mips/jz4740/board-qi_lb60.c | 486 +++++++++++++++++++++
11 4 files changed, 543 insertions(+), 0 deletions(-)
12 create mode 100644 arch/mips/include/asm/mach-jz4740/board-qi_lb60.h
13 create mode 100644 arch/mips/jz4740/board-qi_lb60.c
15 diff --git a/arch/mips/include/asm/mach-jz4740/board-qi_lb60.h b/arch/mips/include/asm/mach-jz4740/board-qi_lb60.h
17 index 0000000..cfbf073
19 +++ b/arch/mips/include/asm/mach-jz4740/board-qi_lb60.h
22 + * Copyright (c) 2009 Qi Hardware Inc.,
23 + * Author: Xiangfu Liu <xiangfu@qi-hardware.com>
25 + * This program is free software: you can redistribute it and/or modify
26 + * it under the terms of the GNU General Public License as published by
27 + * the Free Software Foundation, either version 3 of the License, or
28 + * (at your option) any later version.
30 + * This program is distributed in the hope that it will be useful,
31 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 + * GNU General Public License for more details.
35 + * You should have received a copy of the GNU General Public License
36 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
39 +#ifndef __ASM_JZ4740_QI_LB60_H__
40 +#define __ASM_JZ4740_QI_LB60_H__
42 +#include <linux/gpio.h>
47 +#define GPIO_DC_DETE_N JZ_GPIO_PORTC(26)
48 +#define GPIO_CHARG_STAT_N JZ_GPIO_PORTC(27)
49 +#define GPIO_LED_EN JZ_GPIO_PORTC(28)
50 +#define GPIO_LCD_CS JZ_GPIO_PORTC(21)
51 +#define GPIO_DISP_OFF_N JZ_GPIO_PORTD(21)
52 +#define GPIO_PWM JZ_GPIO_PORTD(27)
53 +#define GPIO_WAKEUP_N JZ_GPIO_PORTD(29)
55 +#define GPIO_AMP_EN JZ_GPIO_PORTD(4)
57 +#define GPIO_SD_CD_N JZ_GPIO_PORTD(0)
58 +#define GPIO_SD_VCC_EN_N JZ_GPIO_PORTD(2)
60 +#define GPIO_USB_DETE JZ_GPIO_PORTD(28)
61 +#define GPIO_BUZZ_PWM JZ_GPIO_PORTD(27)
62 +#define GPIO_UDC_HOTPLUG GPIO_USB_DETE
64 +#define GPIO_AUDIO_POP JZ_GPIO_PORTB(29)
65 +#define GPIO_COB_TEST JZ_GPIO_PORTB(30)
67 +#define GPIO_KEYOUT_BASE JZ_GPIO_PORTC(10)
68 +#define GPIO_KEYIN_BASE JZ_GPIO_PORTD(18)
69 +#define GPIO_KEYIN_8 JZ_GPIO_PORTD(26)
71 +#endif /* __ASM_JZ4740_QI_LB60_H__ */
72 diff --git a/arch/mips/jz4740/Kconfig b/arch/mips/jz4740/Kconfig
73 index 5f6da09..3de3b99 100644
74 --- a/arch/mips/jz4740/Kconfig
75 +++ b/arch/mips/jz4740/Kconfig
76 @@ -3,6 +3,10 @@ choice
78 default JZ4740_QI_LB60
80 +config JZ4740_QI_LB60
81 + bool "Qi Hardware Ben NanoNote"
87 diff --git a/arch/mips/jz4740/Makefile b/arch/mips/jz4740/Makefile
88 index e389ddd..deca88e 100644
89 --- a/arch/mips/jz4740/Makefile
90 +++ b/arch/mips/jz4740/Makefile
91 @@ -11,6 +11,8 @@ obj-$(CONFIG_DEBUG_FS) += clock-debugfs.o
93 # board specific support
95 +obj-$(CONFIG_JZ4740_QI_LB60) += board-qi_lb60.o
99 obj-$(CONFIG_PM) += pm.o
100 diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c
102 index 0000000..b3cc308
104 +++ b/arch/mips/jz4740/board-qi_lb60.c
107 + * linux/arch/mips/jz4740/board-qi_lb60.c
109 + * QI_LB60 setup routines.
111 + * Copyright (c) 2009 Qi Hardware inc.,
112 + * Author: Xiangfu Liu <xiangfu@qi-hardware.com>
114 + * This program is free software; you can redistribute it and/or modify
115 + * it under the terms of the GNU General Public License version 2 or later
116 + * as published by the Free Software Foundation.
119 +#include <linux/kernel.h>
120 +#include <linux/init.h>
121 +#include <linux/gpio.h>
123 +#include <asm/mach-jz4740/board-qi_lb60.h>
124 +#include <asm/mach-jz4740/platform.h>
126 +#include <linux/input.h>
127 +#include <linux/gpio_keys.h>
128 +#include <linux/mtd/jz4740_nand.h>
129 +#include <linux/jz4740_fb.h>
130 +#include <linux/input/matrix_keypad.h>
131 +#include <linux/mtd/jz4740_nand.h>
132 +#include <linux/spi/spi.h>
133 +#include <linux/spi/spi_gpio.h>
134 +#include <linux/power_supply.h>
135 +#include <linux/power/jz4740-battery.h>
136 +#include <linux/power/gpio-charger.h>
137 +#include <linux/mmc/jz4740_mmc.h>
139 +#include <linux/regulator/fixed.h>
140 +#include <linux/regulator/machine.h>
142 +#include <linux/leds_pwm.h>
146 +static bool is_avt2;
149 +static struct nand_ecclayout qi_lb60_ecclayout_1gb = {
152 + 6, 7, 8, 9, 10, 11, 12, 13,
153 + 14, 15, 16, 17, 18, 19, 20, 21,
154 + 22, 23, 24, 25, 26, 27, 28, 29,
155 + 30, 31, 32, 33, 34, 35, 36, 37,
164 +static struct mtd_partition qi_lb60_partitions_1gb[] = {
165 + { .name = "NAND BOOT partition",
166 + .offset = 0 * 0x100000,
167 + .size = 4 * 0x100000,
169 + { .name = "NAND KERNEL partition",
170 + .offset = 4 * 0x100000,
171 + .size = 4 * 0x100000,
173 + { .name = "NAND ROOTFS partition",
174 + .offset = 8 * 0x100000,
175 + .size = (504 + 512) * 0x100000,
179 +static struct nand_ecclayout qi_lb60_ecclayout_2gb = {
182 + 12, 13, 14, 15, 16, 17, 18, 19,
183 + 20, 21, 22, 23, 24, 25, 26, 27,
184 + 28, 29, 30, 31, 32, 33, 34, 35,
185 + 36, 37, 38, 39, 40, 41, 42, 43,
186 + 44, 45, 46, 47, 48, 49, 50, 51,
187 + 52, 53, 54, 55, 56, 57, 58, 59,
188 + 60, 61, 62, 63, 64, 65, 66, 67,
189 + 68, 69, 70, 71, 72, 73, 74, 75,
190 + 76, 77, 78, 79, 80, 81, 82, 83},
192 + { .offset = 2, .length = 10},
193 + { .offset = 84, .length = 44},
197 +static struct mtd_partition qi_lb60_partitions_2gb[] = {
198 + { .name = "NAND BOOT partition",
199 + .offset = 0 * 0x100000,
200 + .size = 4 * 0x100000,
202 + { .name = "NAND KERNEL partition",
203 + .offset = 4 * 0x100000,
204 + .size = 4 * 0x100000,
206 + { .name = "NAND ROOTFS partition",
207 + .offset = 8 * 0x100000,
208 + .size = (504 + 512 + 1024) * 0x100000,
212 +static void qi_lb60_nand_ident(struct platform_device *pdev,
213 + struct nand_chip *chip, struct mtd_partition **partitions,
214 + int *num_partitions)
216 + if (chip->page_shift == 12) {
217 + chip->ecc.layout = &qi_lb60_ecclayout_2gb;
218 + *partitions = qi_lb60_partitions_2gb;
219 + *num_partitions = ARRAY_SIZE(qi_lb60_partitions_2gb);
221 + chip->ecc.layout = &qi_lb60_ecclayout_1gb;
222 + *partitions = qi_lb60_partitions_1gb;
223 + *num_partitions = ARRAY_SIZE(qi_lb60_partitions_1gb);
227 +static struct jz_nand_platform_data qi_lb60_nand_pdata = {
228 + .ident_callback = qi_lb60_nand_ident,
234 +/* #define KEEP_UART_ALIVE
235 + * don't define this. the keyboard and keyboard both work
238 +#define KEY_QI_QI KEY_F13
239 +#define KEY_QI_UPRED KEY_RIGHTALT
240 +#define KEY_QI_VOLUP KEY_VOLUMEUP
241 +#define KEY_QI_VOLDOWN KEY_VOLUMEDOWN
242 +#define KEY_QI_FN KEY_LEFTCTRL
244 +static const uint32_t qi_lb60_keymap[] = {
245 + KEY(0, 0, KEY_F1), /* S2 */
246 + KEY(0, 1, KEY_F2), /* S3 */
247 + KEY(0, 2, KEY_F3), /* S4 */
248 + KEY(0, 3, KEY_F4), /* S5 */
249 + KEY(0, 4, KEY_F5), /* S6 */
250 + KEY(0, 5, KEY_F6), /* S7 */
251 + KEY(0, 6, KEY_F7), /* S8 */
253 + KEY(1, 0, KEY_Q), /* S10 */
254 + KEY(1, 1, KEY_W), /* S11 */
255 + KEY(1, 2, KEY_E), /* S12 */
256 + KEY(1, 3, KEY_R), /* S13 */
257 + KEY(1, 4, KEY_T), /* S14 */
258 + KEY(1, 5, KEY_Y), /* S15 */
259 + KEY(1, 6, KEY_U), /* S16 */
260 + KEY(1, 7, KEY_I), /* S17 */
261 + KEY(2, 0, KEY_A), /* S18 */
262 + KEY(2, 1, KEY_S), /* S19 */
263 + KEY(2, 2, KEY_D), /* S20 */
264 + KEY(2, 3, KEY_F), /* S21 */
265 + KEY(2, 4, KEY_G), /* S22 */
266 + KEY(2, 5, KEY_H), /* S23 */
267 + KEY(2, 6, KEY_J), /* S24 */
268 + KEY(2, 7, KEY_K), /* S25 */
269 + KEY(3, 0, KEY_ESC), /* S26 */
270 + KEY(3, 1, KEY_Z), /* S27 */
271 + KEY(3, 2, KEY_X), /* S28 */
272 + KEY(3, 3, KEY_C), /* S29 */
273 + KEY(3, 4, KEY_V), /* S30 */
274 + KEY(3, 5, KEY_B), /* S31 */
275 + KEY(3, 6, KEY_N), /* S32 */
276 + KEY(3, 7, KEY_M), /* S33 */
277 + KEY(4, 0, KEY_TAB), /* S34 */
278 + KEY(4, 1, KEY_CAPSLOCK), /* S35 */
279 + KEY(4, 2, KEY_BACKSLASH), /* S36 */
280 + KEY(4, 3, KEY_APOSTROPHE), /* S37 */
281 + KEY(4, 4, KEY_COMMA), /* S38 */
282 + KEY(4, 5, KEY_DOT), /* S39 */
283 + KEY(4, 6, KEY_SLASH), /* S40 */
284 + KEY(4, 7, KEY_UP), /* S41 */
285 + KEY(5, 0, KEY_O), /* S42 */
286 + KEY(5, 1, KEY_L), /* S43 */
287 + KEY(5, 2, KEY_EQUAL), /* S44 */
288 + KEY(5, 3, KEY_QI_UPRED), /* S45 */
289 + KEY(5, 4, KEY_SPACE), /* S46 */
290 + KEY(5, 5, KEY_QI_QI), /* S47 */
291 + KEY(5, 6, KEY_RIGHTCTRL), /* S48 */
292 + KEY(5, 7, KEY_LEFT), /* S49 */
293 + KEY(6, 0, KEY_F8), /* S50 */
294 + KEY(6, 1, KEY_P), /* S51 */
295 + KEY(6, 2, KEY_BACKSPACE),/* S52 */
296 + KEY(6, 3, KEY_ENTER), /* S53 */
297 + KEY(6, 4, KEY_QI_VOLUP), /* S54 */
298 + KEY(6, 5, KEY_QI_VOLDOWN), /* S55 */
299 + KEY(6, 6, KEY_DOWN), /* S56 */
300 + KEY(6, 7, KEY_RIGHT), /* S57 */
302 +#ifndef KEEP_UART_ALIVE
303 + KEY(7, 0, KEY_LEFTSHIFT), /* S58 */
304 + KEY(7, 1, KEY_LEFTALT), /* S59 */
305 + KEY(7, 2, KEY_QI_FN), /* S60 */
309 +static const struct matrix_keymap_data qi_lb60_keymap_data = {
310 + .keymap = qi_lb60_keymap,
311 + .keymap_size = ARRAY_SIZE(qi_lb60_keymap),
314 +static const unsigned int qi_lb60_keypad_cols[] = {
315 + 74, 75, 76, 77, 78, 79, 80, 81,
318 +static const unsigned int qi_lb60_keypad_rows[] = {
319 + 114, 115, 116, 117, 118, 119, 120,
320 +#ifndef KEEP_UART_ALIVE
325 +static struct matrix_keypad_platform_data qi_lb60_pdata = {
326 + .keymap_data = &qi_lb60_keymap_data,
327 + .col_gpios = qi_lb60_keypad_cols,
328 + .row_gpios = qi_lb60_keypad_rows,
329 + .num_col_gpios = ARRAY_SIZE(qi_lb60_keypad_cols),
330 + .num_row_gpios = ARRAY_SIZE(qi_lb60_keypad_rows),
331 + .col_scan_delay_us = 10,
337 +static struct platform_device qi_lb60_keypad = {
338 + .name = "matrix-keypad",
341 + .platform_data = &qi_lb60_pdata,
346 +static struct fb_videomode qi_lb60_video_modes[] = {
352 + .left_margin = 140,
353 + .right_margin = 273,
354 + .upper_margin = 20,
359 + .vmode = FB_VMODE_NONINTERLACED,
363 +static struct jz4740_fb_platform_data qi_lb60_fb_pdata = {
366 + .num_modes = ARRAY_SIZE(qi_lb60_video_modes),
367 + .modes = qi_lb60_video_modes,
369 + .lcd_type = JZ_LCD_TYPE_8BIT_SERIAL,
370 + .pixclk_falling_edge = 1,
374 +struct spi_gpio_platform_data spigpio_platform_data = {
375 + .sck = JZ_GPIO_PORTC(23),
376 + .mosi = JZ_GPIO_PORTC(22),
378 + .num_chipselect = 1,
381 +static struct platform_device spigpio_device = {
382 + .name = "spi_gpio",
385 + .platform_data = &spigpio_platform_data,
389 +static struct spi_board_info qi_lb60_spi_board_info[] = {
391 + .modalias = "gpm940b0",
392 + .controller_data = (void *)JZ_GPIO_PORTC(21),
395 + .max_speed_hz = 30 * 1000,
401 +static struct jz_battery_platform_data qi_lb60_battery_pdata = {
402 + .gpio_charge = GPIO_CHARG_STAT_N,
403 + .gpio_charge_active_low = 1,
406 + .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
407 + .voltage_max_design = 4200000,
408 + .voltage_min_design = 3600000,
412 +static char *qi_lb60_batteries[] = {
416 +static struct gpio_charger_platform_data qi_lb60_charger_pdata = {
418 + .type = POWER_SUPPLY_TYPE_USB,
419 + .gpio = GPIO_USB_DETE,
420 + .gpio_active_low = 1,
421 + .batteries = qi_lb60_batteries,
422 + .num_batteries = ARRAY_SIZE(qi_lb60_batteries),
425 +static struct platform_device qi_lb60_charger_device = {
426 + .name = "gpio-charger",
428 + .platform_data = &qi_lb60_charger_pdata,
432 +/* GPIO Key: power */
433 +static struct gpio_keys_button qi_lb60_gpio_keys_buttons[] = {
436 + .gpio = GPIO_WAKEUP_N,
443 +static struct gpio_keys_platform_data qi_lb60_gpio_keys_data = {
444 + .nbuttons = ARRAY_SIZE(qi_lb60_gpio_keys_buttons),
445 + .buttons = qi_lb60_gpio_keys_buttons,
448 +static struct platform_device qi_lb60_gpio_keys = {
449 + .name = "gpio-keys",
452 + .platform_data = &qi_lb60_gpio_keys_data,
456 +static struct jz4740_mmc_platform_data qi_lb60_mmc_pdata = {
457 + .gpio_card_detect = JZ_GPIO_PORTD(0),
458 + .gpio_read_only = -1,
459 + .gpio_power = JZ_GPIO_PORTD(2),
460 + .power_active_low = 1,
463 +static struct regulator_consumer_supply avt2_usb_regulator_consumer =
464 + REGULATOR_SUPPLY("vbus", "jz4740-ohci");
466 +static struct regulator_init_data avt2_usb_regulator_init_data = {
467 + .num_consumer_supplies = 1,
468 + .consumer_supplies = &avt2_usb_regulator_consumer,
470 + .name = "USB power",
473 + .valid_modes_mask = REGULATOR_MODE_NORMAL,
474 + .valid_ops_mask = REGULATOR_CHANGE_STATUS,
478 +static struct fixed_voltage_config avt2_usb_regulator_data = {
479 + .supply_name = "USB power",
480 + .microvolts = 5000000,
481 + .gpio = JZ_GPIO_PORTB(17),
482 + .init_data = &avt2_usb_regulator_init_data,
485 +static struct platform_device avt2_usb_regulator_device = {
486 + .name = "reg-fixed-voltage",
489 + .platform_data = &avt2_usb_regulator_data,
493 +static struct led_pwm qi_lb60_pizo_led = {
494 + .name = "nanonote::pizo",
496 + .max_brightness = 255,
497 + .pwm_period_ns = 1000000,
500 +static struct led_pwm_platform_data qi_lb60_pizo_data = {
502 + .leds = &qi_lb60_pizo_led,
505 +static struct platform_device qi_lb60_pizo_device = {
506 + .name = "leds_pwm",
509 + .platform_data = &qi_lb60_pizo_data,
513 +static struct platform_device *jz_platform_devices[] __initdata = {
514 + &jz4740_usb_gdt_device,
515 + &jz4740_mmc_device,
516 + &jz4740_nand_device,
519 + &jz4740_framebuffer_device,
520 + &jz4740_i2s_device,
521 + &jz4740_codec_device,
522 + &jz4740_rtc_device,
523 + &jz4740_adc_device,
524 + &jz4740_battery_device,
525 + &qi_lb60_gpio_keys,
526 + &qi_lb60_charger_device,
527 + &qi_lb60_pizo_device,
530 +static void __init board_gpio_setup(void)
532 + /* We only need to enable/disable pullup here for pins used in generic
533 + * drivers. Everything else is done by the drivers themselfs. */
534 + jz_gpio_disable_pullup(GPIO_SD_VCC_EN_N);
535 + jz_gpio_disable_pullup(GPIO_SD_CD_N);
538 +static int __init qi_lb60_init_platform_devices(void)
540 + jz4740_framebuffer_device.dev.platform_data = &qi_lb60_fb_pdata;
541 + jz4740_nand_device.dev.platform_data = &qi_lb60_nand_pdata;
542 + jz4740_battery_device.dev.platform_data = &qi_lb60_battery_pdata;
543 + jz4740_mmc_device.dev.platform_data = &qi_lb60_mmc_pdata;
545 + spi_register_board_info(qi_lb60_spi_board_info,
546 + ARRAY_SIZE(qi_lb60_spi_board_info));
549 + platform_device_register(&avt2_usb_regulator_device);
550 + platform_device_register(&jz4740_usb_ohci_device);
553 + return platform_add_devices(jz_platform_devices,
554 + ARRAY_SIZE(jz_platform_devices));
558 +struct jz4740_clock_board_data jz4740_clock_bdata = {
559 + .ext_rate = 12000000,
563 +extern int jz_gpiolib_init(void);
565 +static __init int board_avt2(char *str)
567 + qi_lb60_mmc_pdata.card_detect_active_low = 1;
568 + qi_lb60_mmc_pdata.power_active_low = 1;
574 +__setup("avt2", board_avt2);
576 +static int __init qi_lb60_board_setup(void)
578 + printk(KERN_INFO "Qi Hardware JZ4740 QI_LB60 setup\n");
579 + if (jz_gpiolib_init())
580 + panic("Failed to initalize jz gpio\n");
582 + jz4740_clock_init();
583 + board_gpio_setup();
585 + if (qi_lb60_init_platform_devices())
586 + panic("Failed to initalize platform devices\n");
591 +arch_initcall(qi_lb60_board_setup);