Date:2010-04-24 17:24:26 (13 years 7 months ago)
Author:Lars C.
Commit:f34b540402df4f8b4c22df788633fd1aa1fd46bf
Message:Add qi_lb60 board support

Files: arch/mips/include/asm/mach-jz4740/board-qi_lb60.h (1 diff)
arch/mips/jz4740/Kconfig (2 diffs)
arch/mips/jz4740/Makefile (1 diff)
arch/mips/jz4740/board-qi_lb60.c (1 diff)

Change Details

arch/mips/include/asm/mach-jz4740/board-qi_lb60.h
1/*
2 * Copyright (c) 2009 Qi Hardware Inc.,
3 * Author: Xiangfu Liu <xiangfu@qi-hardware.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __ASM_JZ4740_QI_LB60_H__
20#define __ASM_JZ4740_QI_LB60_H__
21
22#include <linux/gpio.h>
23
24/*
25 * GPIO
26 */
27#define GPIO_DC_DETE_N JZ_GPIO_PORTC(26)
28#define GPIO_CHARG_STAT_N JZ_GPIO_PORTC(27)
29#define GPIO_LED_EN JZ_GPIO_PORTC(28)
30#define GPIO_LCD_CS JZ_GPIO_PORTC(21)
31#define GPIO_DISP_OFF_N JZ_GPIO_PORTD(21)
32#define GPIO_PWM JZ_GPIO_PORTD(27)
33#define GPIO_WAKEUP_N JZ_GPIO_PORTD(29)
34
35#define GPIO_AMP_EN JZ_GPIO_PORTD(4)
36
37#define GPIO_SD_CD_N JZ_GPIO_PORTD(0)
38#define GPIO_SD_VCC_EN_N JZ_GPIO_PORTD(2)
39
40#define GPIO_USB_DETE JZ_GPIO_PORTD(28)
41#define GPIO_BUZZ_PWM JZ_GPIO_PORTD(27)
42#define GPIO_UDC_HOTPLUG GPIO_USB_DETE
43
44#define GPIO_AUDIO_POP JZ_GPIO_PORTB(29)
45#define GPIO_COB_TEST JZ_GPIO_PORTB(30)
46
47#define GPIO_KEYOUT_BASE JZ_GPIO_PORTC(10)
48#define GPIO_KEYIN_BASE JZ_GPIO_PORTD(18)
49#define GPIO_KEYIN_8 JZ_GPIO_PORTD(26)
50
51#endif /* __ASM_JZ4740_QI_LB60_H__ */
arch/mips/jz4740/Kconfig
33    depends on MACH_JZ
44    default JZ4740_QI_LB60
55
6config JZ4740_QI_LB60
7    bool "Qi Hardware Ben NanoNote"
8    select SOC_JZ4740
9
610endchoice
711
812config SOC_JZ4740
...... 
1317    select SYS_HAS_EARLY_PRINTK
1418    select SYS_SUPPORTS_LITTLE_ENDIAN
1519    select IRQ_CPU
20    select DMA_NONCOHERENT
1621
1722config JZSOC
1823    bool
arch/mips/jz4740/Makefile
1111
1212# board specific support
1313
14obj-$(CONFIG_JZ4740_QI_LB60) += board-qi_lb60.o
15
1416# PM support
1517
1618obj-$(CONFIG_PM) += pm.o
arch/mips/jz4740/board-qi_lb60.c
1/*
2 * linux/arch/mips/jz4740/board-qi_lb60.c
3 *
4 * QI_LB60 setup routines.
5 *
6 * Copyright (c) 2009 Qi Hardware inc.,
7 * Author: Xiangfu Liu <xiangfu@qi-hardware.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 or later
11 * as published by the Free Software Foundation.
12 */
13
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/gpio.h>
17
18#include <asm/mach-jz4740/board-qi_lb60.h>
19#include <asm/mach-jz4740/platform.h>
20
21#include <linux/input.h>
22#include <linux/gpio_keys.h>
23#include <linux/mtd/jz4740_nand.h>
24#include <linux/jz4740_fb.h>
25#include <linux/input/matrix_keypad.h>
26#include <linux/mtd/jz4740_nand.h>
27#include <linux/spi/spi.h>
28#include <linux/spi/spi_gpio.h>
29#include <linux/power_supply.h>
30#include <linux/power/jz4740-battery.h>
31#include <linux/power/gpio-charger.h>
32#include <linux/mmc/jz4740_mmc.h>
33
34#include <linux/regulator/fixed.h>
35#include <linux/regulator/machine.h>
36
37#include "clock.h"
38
39static bool is_avt2;
40
41/* NAND */
42static struct nand_ecclayout qi_lb60_ecclayout_1gb = {
43    .eccbytes = 36,
44    .eccpos = {
45        6, 7, 8, 9, 10, 11, 12, 13,
46        14, 15, 16, 17, 18, 19, 20, 21,
47        22, 23, 24, 25, 26, 27, 28, 29,
48        30, 31, 32, 33, 34, 35, 36, 37,
49        38, 39, 40, 41},
50    .oobfree = {
51        {.offset = 2,
52         .length = 4},
53        {.offset = 42,
54         .length = 22}}
55};
56
57static struct mtd_partition qi_lb60_partitions_1gb[] = {
58    { .name = "NAND BOOT partition",
59      .offset = 0 * 0x100000,
60      .size = 4 * 0x100000,
61     },
62    { .name = "NAND KERNEL partition",
63      .offset = 4 * 0x100000,
64      .size = 4 * 0x100000,
65     },
66    { .name = "NAND ROOTFS partition",
67      .offset = 8 * 0x100000,
68      .size = (504 + 512) * 0x100000,
69     },
70};
71
72static struct nand_ecclayout qi_lb60_ecclayout_2gb = {
73    .eccbytes = 72,
74    .eccpos = {
75        12, 13, 14, 15, 16, 17, 18, 19,
76        20, 21, 22, 23, 24, 25, 26, 27,
77        28, 29, 30, 31, 32, 33, 34, 35,
78        36, 37, 38, 39, 40, 41, 42, 43,
79        44, 45, 46, 47, 48, 49, 50, 51,
80        52, 53, 54, 55, 56, 57, 58, 59,
81        60, 61, 62, 63, 64, 65, 66, 67,
82        68, 69, 70, 71, 72, 73, 74, 75,
83        76, 77, 78, 79, 80, 81, 82, 83},
84    .oobfree = {
85         { .offset = 2, .length = 10},
86        { .offset = 84, .length = 44},
87    },
88};
89
90static struct mtd_partition qi_lb60_partitions_2gb[] = {
91    { .name = "NAND BOOT partition",
92      .offset = 0 * 0x100000,
93      .size = 4 * 0x100000,
94     },
95    { .name = "NAND KERNEL partition",
96      .offset = 4 * 0x100000,
97      .size = 4 * 0x100000,
98     },
99    { .name = "NAND ROOTFS partition",
100      .offset = 8 * 0x100000,
101      .size = (504 + 512 + 1024) * 0x100000,
102     },
103};
104
105static void qi_lb60_nand_ident(struct platform_device *pdev,
106        struct nand_chip *chip, struct mtd_partition **partitions,
107        int *num_partitions)
108{
109    if (chip->page_shift == 12) {
110        chip->ecc.layout = &qi_lb60_ecclayout_2gb;
111        *partitions = qi_lb60_partitions_2gb;
112        *num_partitions = ARRAY_SIZE(qi_lb60_partitions_2gb);
113    } else {
114        chip->ecc.layout = &qi_lb60_ecclayout_1gb;
115        *partitions = qi_lb60_partitions_1gb;
116        *num_partitions = ARRAY_SIZE(qi_lb60_partitions_1gb);
117    }
118}
119
120static struct jz_nand_platform_data qi_lb60_nand_pdata = {
121    .ident_callback = qi_lb60_nand_ident,
122    .busy_gpio = 94,
123};
124
125/* Keyboard*/
126
127/* #define KEEP_UART_ALIVE
128 * don't define this. the keyboard and keyboard both work
129 */
130
131#define KEY_QI_QI KEY_F13
132#define KEY_QI_UPRED KEY_RIGHTALT
133#define KEY_QI_VOLUP KEY_VOLUMEUP
134#define KEY_QI_VOLDOWN KEY_VOLUMEDOWN
135#define KEY_QI_FN KEY_LEFTCTRL
136
137static const uint32_t qi_lb60_keymap[] = {
138    KEY(0, 0, KEY_F1), /* S2 */
139    KEY(0, 1, KEY_F2), /* S3 */
140    KEY(0, 2, KEY_F3), /* S4 */
141    KEY(0, 3, KEY_F4), /* S5 */
142    KEY(0, 4, KEY_F5), /* S6 */
143    KEY(0, 5, KEY_F6), /* S7 */
144    KEY(0, 6, KEY_F7), /* S8 */
145
146    KEY(1, 0, KEY_Q), /* S10 */
147    KEY(1, 1, KEY_W), /* S11 */
148    KEY(1, 2, KEY_E), /* S12 */
149    KEY(1, 3, KEY_R), /* S13 */
150    KEY(1, 4, KEY_T), /* S14 */
151    KEY(1, 5, KEY_Y), /* S15 */
152    KEY(1, 6, KEY_U), /* S16 */
153    KEY(1, 7, KEY_I), /* S17 */
154    KEY(2, 0, KEY_A), /* S18 */
155    KEY(2, 1, KEY_S), /* S19 */
156    KEY(2, 2, KEY_D), /* S20 */
157    KEY(2, 3, KEY_F), /* S21 */
158    KEY(2, 4, KEY_G), /* S22 */
159    KEY(2, 5, KEY_H), /* S23 */
160    KEY(2, 6, KEY_J), /* S24 */
161    KEY(2, 7, KEY_K), /* S25 */
162    KEY(3, 0, KEY_ESC), /* S26 */
163    KEY(3, 1, KEY_Z), /* S27 */
164    KEY(3, 2, KEY_X), /* S28 */
165    KEY(3, 3, KEY_C), /* S29 */
166    KEY(3, 4, KEY_V), /* S30 */
167    KEY(3, 5, KEY_B), /* S31 */
168    KEY(3, 6, KEY_N), /* S32 */
169    KEY(3, 7, KEY_M), /* S33 */
170    KEY(4, 0, KEY_TAB), /* S34 */
171    KEY(4, 1, KEY_CAPSLOCK), /* S35 */
172    KEY(4, 2, KEY_BACKSLASH), /* S36 */
173    KEY(4, 3, KEY_APOSTROPHE), /* S37 */
174    KEY(4, 4, KEY_COMMA), /* S38 */
175    KEY(4, 5, KEY_DOT), /* S39 */
176    KEY(4, 6, KEY_SLASH), /* S40 */
177    KEY(4, 7, KEY_UP), /* S41 */
178    KEY(5, 0, KEY_O), /* S42 */
179    KEY(5, 1, KEY_L), /* S43 */
180    KEY(5, 2, KEY_EQUAL), /* S44 */
181    KEY(5, 3, KEY_QI_UPRED), /* S45 */
182    KEY(5, 4, KEY_SPACE), /* S46 */
183    KEY(5, 5, KEY_QI_QI), /* S47 */
184    KEY(5, 6, KEY_RIGHTCTRL), /* S48 */
185    KEY(5, 7, KEY_LEFT), /* S49 */
186    KEY(6, 0, KEY_F8), /* S50 */
187    KEY(6, 1, KEY_P), /* S51 */
188    KEY(6, 2, KEY_BACKSPACE),/* S52 */
189    KEY(6, 3, KEY_ENTER), /* S53 */
190    KEY(6, 4, KEY_QI_VOLUP), /* S54 */
191    KEY(6, 5, KEY_QI_VOLDOWN), /* S55 */
192    KEY(6, 6, KEY_DOWN), /* S56 */
193    KEY(6, 7, KEY_RIGHT), /* S57 */
194
195#ifndef KEEP_UART_ALIVE
196    KEY(7, 0, KEY_LEFTSHIFT), /* S58 */
197    KEY(7, 1, KEY_LEFTALT), /* S59 */
198    KEY(7, 2, KEY_QI_FN), /* S60 */
199#endif
200};
201
202static const struct matrix_keymap_data qi_lb60_keymap_data = {
203    .keymap = qi_lb60_keymap,
204    .keymap_size = ARRAY_SIZE(qi_lb60_keymap),
205};
206
207static const unsigned int qi_lb60_keypad_cols[] = {
208    74, 75, 76, 77, 78, 79, 80, 81,
209};
210
211static const unsigned int qi_lb60_keypad_rows[] = {
212    114, 115, 116, 117, 118, 119, 120,
213#ifndef KEEP_UART_ALIVE
214    122,
215#endif
216};
217
218static struct matrix_keypad_platform_data qi_lb60_pdata = {
219    .keymap_data = &qi_lb60_keymap_data,
220    .col_gpios = qi_lb60_keypad_cols,
221    .row_gpios = qi_lb60_keypad_rows,
222    .num_col_gpios = ARRAY_SIZE(qi_lb60_keypad_cols),
223    .num_row_gpios = ARRAY_SIZE(qi_lb60_keypad_rows),
224    .col_scan_delay_us = 10,
225    .debounce_ms = 10,
226    .wakeup = 1,
227    .active_low = 1,
228};
229
230static struct platform_device qi_lb60_keypad = {
231    .name = "matrix-keypad",
232    .id = -1,
233    .dev = {
234        .platform_data = &qi_lb60_pdata,
235    },
236};
237
238/* Display */
239static struct fb_videomode qi_lb60_video_modes[] = {
240    {
241        .name = "320x240",
242        .xres = 320,
243        .yres = 240,
244        .refresh = 30,
245        .left_margin = 140,
246        .right_margin = 273,
247        .upper_margin = 20,
248        .lower_margin = 2,
249        .hsync_len = 1,
250        .vsync_len = 1,
251        .sync = 0,
252        .vmode = FB_VMODE_NONINTERLACED,
253    },
254};
255
256static struct jz4740_fb_platform_data qi_lb60_fb_pdata = {
257    .width = 60,
258    .height = 45,
259    .num_modes = ARRAY_SIZE(qi_lb60_video_modes),
260    .modes = qi_lb60_video_modes,
261    .bpp = 24,
262    .lcd_type = JZ_LCD_TYPE_8BIT_SERIAL,
263    .pixclk_falling_edge = 1,
264};
265
266
267struct spi_gpio_platform_data spigpio_platform_data = {
268    .sck = JZ_GPIO_PORTC(23),
269    .mosi = JZ_GPIO_PORTC(22),
270    .miso = JZ_GPIO_PORTC(22),
271    .num_chipselect = 1,
272};
273
274static struct platform_device spigpio_device = {
275    .name = "spi_gpio",
276    .id = 1,
277    .dev = {
278        .platform_data = &spigpio_platform_data,
279    },
280};
281
282static struct spi_board_info qi_lb60_spi_board_info[] = {
283    {
284        .modalias = "gpm940b0",
285        .controller_data = (void *)JZ_GPIO_PORTC(21),
286        .chip_select = 0,
287        .bus_num = 1,
288        .max_speed_hz = 30 * 1000,
289    },
290};
291
292/* Battery */
293static struct jz_battery_platform_data qi_lb60_battery_pdata = {
294    .gpio_charge = GPIO_CHARG_STAT_N,
295    .gpio_charge_active_low = 1,
296    .info = {
297        .name = "battery",
298        .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
299        .voltage_max_design = 4200000,
300        .voltage_min_design = 3600000,
301    },
302};
303
304static char *qi_lb60_batteries[] = {
305    "battery",
306};
307
308static struct gpio_charger_platform_data qi_lb60_charger_pdata = {
309    .name = "USB",
310    .type = POWER_SUPPLY_TYPE_USB,
311    .gpio = GPIO_USB_DETE,
312    .gpio_active_low = 1,
313    .batteries = qi_lb60_batteries,
314    .num_batteries = ARRAY_SIZE(qi_lb60_batteries),
315};
316
317static struct platform_device qi_lb60_charger_device = {
318    .name = "gpio-charger",
319    .dev = {
320        .platform_data = &qi_lb60_charger_pdata,
321    },
322};
323
324/* GPIO Key: power */
325static struct gpio_keys_button qi_lb60_gpio_keys_buttons[] = {
326    [0] = {
327        .code = KEY_POWER,
328        .gpio = GPIO_WAKEUP_N,
329        .active_low = 1,
330        .desc = "Power",
331        .wakeup = 1,
332    },
333};
334
335static struct gpio_keys_platform_data qi_lb60_gpio_keys_data = {
336    .nbuttons = ARRAY_SIZE(qi_lb60_gpio_keys_buttons),
337    .buttons = qi_lb60_gpio_keys_buttons,
338};
339
340static struct platform_device qi_lb60_gpio_keys = {
341    .name = "gpio-keys",
342    .id = -1,
343    .dev = {
344        .platform_data = &qi_lb60_gpio_keys_data,
345    }
346};
347
348static struct jz4740_mmc_platform_data qi_lb60_mmc_pdata = {
349    .gpio_card_detect = JZ_GPIO_PORTD(0),
350    .gpio_read_only = -1,
351    .gpio_power = JZ_GPIO_PORTD(2),
352    .power_active_low = 1,
353};
354
355static struct regulator_consumer_supply avt2_usb_regulator_consumer =
356    REGULATOR_SUPPLY("vbus", "jz4740-ohci");
357
358static struct regulator_init_data avt2_usb_regulator_init_data = {
359    .num_consumer_supplies = 1,
360    .consumer_supplies = &avt2_usb_regulator_consumer,
361    .constraints = {
362        .name = "USB power",
363        .min_uV = 5000000,
364        .max_uV = 5000000,
365        .valid_modes_mask = REGULATOR_MODE_NORMAL,
366        .valid_ops_mask = REGULATOR_CHANGE_STATUS,
367    },
368};
369
370static struct fixed_voltage_config avt2_usb_regulator_data = {
371    .supply_name = "USB power",
372    .microvolts = 5000000,
373    .gpio = JZ_GPIO_PORTB(17),
374    .init_data = &avt2_usb_regulator_init_data,
375};
376
377static struct platform_device avt2_usb_regulator_device = {
378    .name = "reg-fixed-voltage",
379    .id = -1,
380    .dev = {
381        .platform_data = &avt2_usb_regulator_data,
382    }
383};
384
385static struct platform_device *jz_platform_devices[] __initdata = {
386    &jz4740_usb_gdt_device,
387    &jz4740_mmc_device,
388    &jz4740_nand_device,
389    &qi_lb60_keypad,
390    &spigpio_device,
391    &jz4740_framebuffer_device,
392    &jz4740_i2s_device,
393    &jz4740_codec_device,
394    &jz4740_rtc_device,
395    &jz4740_adc_device,
396    &jz4740_battery_device,
397    &qi_lb60_gpio_keys,
398    &qi_lb60_charger_device,
399};
400
401static void __init board_gpio_setup(void)
402{
403    /* We only need to enable/disable pullup here for pins used in generic
404     * drivers. Everything else is done by the drivers themselfs. */
405    jz_gpio_disable_pullup(GPIO_SD_VCC_EN_N);
406    jz_gpio_disable_pullup(GPIO_SD_CD_N);
407}
408
409static int __init qi_lb60_init_platform_devices(void)
410{
411    jz4740_framebuffer_device.dev.platform_data = &qi_lb60_fb_pdata;
412    jz4740_nand_device.dev.platform_data = &qi_lb60_nand_pdata;
413    jz4740_battery_device.dev.platform_data = &qi_lb60_battery_pdata;
414    jz4740_mmc_device.dev.platform_data = &qi_lb60_mmc_pdata;
415
416    spi_register_board_info(qi_lb60_spi_board_info,
417                ARRAY_SIZE(qi_lb60_spi_board_info));
418
419    if (is_avt2) {
420        platform_device_register(&avt2_usb_regulator_device);
421        platform_device_register(&jz4740_usb_ohci_device);
422    }
423
424    return platform_add_devices(jz_platform_devices,
425                    ARRAY_SIZE(jz_platform_devices));
426
427}
428
429struct jz4740_clock_board_data jz4740_clock_bdata = {
430    .ext_rate = 12000000,
431    .rtc_rate = 32768,
432};
433
434extern int jz_gpiolib_init(void);
435
436static __init int board_avt2(char *str)
437{
438    qi_lb60_mmc_pdata.card_detect_active_low = 1;
439    qi_lb60_mmc_pdata.power_active_low = 1;
440    is_avt2 = true;
441
442    return 1;
443}
444
445__setup("avt2", board_avt2);
446
447static int __init qi_lb60_board_setup(void)
448{
449    printk(KERN_INFO "Qi Hardware JZ4740 QI_LB60 setup\n");
450    if (jz_gpiolib_init())
451        panic("Failed to initalize jz gpio\n");
452
453    jz4740_clock_init();
454    board_gpio_setup();
455
456    if (qi_lb60_init_platform_devices())
457        panic("Failed to initalize platform devices\n");
458
459    return 0;
460}
461
462arch_initcall(qi_lb60_board_setup);

Archive Download the corresponding diff file



interactive