Date:2010-04-24 17:25:23 (9 years 27 days ago)
Author:Lars C.
Commit:2888489430965e340f5bbdb9816278ecc6f5ccac
Message:Add n526 board support

Files: arch/mips/jz4740/Kconfig (1 diff)
arch/mips/jz4740/Makefile (1 diff)
arch/mips/jz4740/board-n526.c (1 diff)

Change Details

arch/mips/jz4740/Kconfig
1010    bool "Hanvon n516 eBook reader"
1111    select SOC_JZ4740
1212
13config JZ4740_N526
14    bool "Hanvon n526 eBook reader"
15    select SOC_JZ4740
16
1317endchoice
1418
1519config HAVE_PWM
arch/mips/jz4740/Makefile
1313
1414obj-$(CONFIG_JZ4740_QI_LB60) += board-qi_lb60.o
1515obj-$(CONFIG_JZ4740_N516) += board-n516.o board-n516-display.o
16obj-$(CONFIG_JZ4740_N526) += board-n526.o
1617
1718# PM support
1819
arch/mips/jz4740/board-n526.c
1/*
2 * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de>
3 * N526 eBook reader support
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * You should have received a copy of the GNU General Public License along
11 * with this program; if not, write to the Free Software Foundation, Inc.,
12 * 675 Mass Ave, Cambridge, MA 02139, USA.
13 *
14 */
15
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/gpio.h>
19
20
21#include <linux/power_supply.h>
22
23#include <video/broadsheetfb.h>
24#include <linux/delay.h>
25#include <linux/interrupt.h>
26
27#include <linux/input.h>
28#include <linux/gpio_keys.h>
29
30#include <linux/i2c.h>
31#include <linux/i2c-gpio.h>
32
33#include "clock.h"
34
35#include <asm/mach-jz4740/jz4740_mmc.h>
36#include <asm/mach-jz4740/jz4740_nand.h>
37#include <asm/mach-jz4740/jz4740_fb.h>
38
39#include <asm/mach-jz4740/platform.h>
40
41/* NAND */
42static struct nand_ecclayout n526_ecclayout = {
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 n526_partitions[] = {
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 = 16 * 0x100000,
68      .size = 498 * 0x100000,
69     },
70};
71
72static struct jz_nand_platform_data n526_nand_pdata = {
73    .ecc_layout = &n526_ecclayout,
74    .partitions = n526_partitions,
75    .num_partitions = ARRAY_SIZE(n526_partitions),
76    .busy_gpio = 94,
77};
78
79static struct jz4740_mmc_platform_data n526_mmc_pdata = {
80    .gpio_card_detect = JZ_GPIO_PORTD(7),
81    .card_detect_active_low = 1,
82    .gpio_read_only = -1,
83    .gpio_power = JZ_GPIO_PORTD(17),
84    .power_active_low = 1,
85};
86
87static struct gpio_led n526_leds[] = {
88    {
89        .name = "n526:blue:power",
90        .gpio = JZ_GPIO_PORTD(28),
91        .default_state = LEDS_GPIO_DEFSTATE_ON,
92    }
93};
94
95static struct gpio_led_platform_data n526_leds_pdata = {
96    .leds = n526_leds,
97    .num_leds = ARRAY_SIZE(n526_leds),
98};
99
100static struct platform_device n526_leds_device = {
101    .name = "leds-gpio",
102    .id = -1,
103    .dev = {
104        .platform_data = &n526_leds_pdata,
105    },
106};
107
108static void __init board_gpio_setup(void)
109{
110    /* We only need to enable/disable pullup here for pins used in generic
111     * drivers. Everything else is done by the drivers themselfs. */
112    jz_gpio_disable_pullup(JZ_GPIO_PORTD(17));
113    jz_gpio_enable_pullup(JZ_GPIO_PORTD(7));
114    jz_gpio_disable_pullup(JZ_GPIO_PORTC(19));
115    jz_gpio_disable_pullup(JZ_GPIO_PORTC(20));
116    jz_gpio_disable_pullup(JZ_GPIO_PORTC(21));
117    jz_gpio_disable_pullup(JZ_GPIO_PORTC(23));
118}
119
120
121static const int n526_eink_ctrl_gpios[] = {
122    0,
123    JZ_GPIO_PORTC(23),
124    JZ_GPIO_PORTC(19),
125    JZ_GPIO_PORTC(20),
126};
127
128static void n526_eink_set_ctl(struct broadsheetfb_par * par, unsigned char ctrl, u8
129value)
130{
131    gpio_set_value(n526_eink_ctrl_gpios[ctrl], value);
132}
133
134
135static int n526_eink_wait(struct broadsheetfb_par *par)
136{
137    wait_event(par->waitq, gpio_get_value(JZ_GPIO_PORTB(17)));
138
139    return 0;
140}
141
142static u16 n526_eink_get_hdb(struct broadsheetfb_par *par)
143{
144    u16 value = 0;
145    jz_gpio_port_direction_input(JZ_GPIO_PORTC(0), 0xffff);
146    gpio_set_value(JZ_GPIO_PORTC(21), 0);
147    mdelay(100);
148
149    value = jz_gpio_port_get_value(JZ_GPIO_PORTC(0), 0xffff);
150
151    gpio_set_value(JZ_GPIO_PORTC(21), 1);
152    jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff);
153    return value;
154}
155
156static void n526_eink_set_hdb(struct broadsheetfb_par *par, u16 value)
157{
158    jz_gpio_port_set_value(JZ_GPIO_PORTC(0), value, 0xffff);
159}
160
161static int n526_eink_init(struct broadsheetfb_par *par)
162{
163    int i;
164
165    gpio_request(JZ_GPIO_PORTD(1), "display reset");
166    gpio_direction_output(JZ_GPIO_PORTD(1), 1);
167    mdelay(10);
168    gpio_set_value(JZ_GPIO_PORTD(1), 0);
169
170    gpio_request(JZ_GPIO_PORTB(18), "eink enable");
171    gpio_direction_output(JZ_GPIO_PORTB(18), 0);
172
173    gpio_request(JZ_GPIO_PORTB(29), "foobar");
174    gpio_direction_output(JZ_GPIO_PORTB(29), 1);
175
176    for(i = 1; i < ARRAY_SIZE(n526_eink_ctrl_gpios); ++i) {
177        gpio_request(n526_eink_ctrl_gpios[i], "eink display ctrl");
178        gpio_direction_output(n526_eink_ctrl_gpios[i], 0);
179    }
180
181    gpio_request(JZ_GPIO_PORTC(22), "foobar");
182    gpio_direction_input(JZ_GPIO_PORTC(22));
183    gpio_request(JZ_GPIO_PORTC(21), "eink nRD");
184    gpio_direction_output(JZ_GPIO_PORTC(21), 1);
185
186    for(i = 0; i < 16; ++i) {
187        gpio_request(JZ_GPIO_PORTC(i), "eink display data");
188    }
189    jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff);
190
191    gpio_set_value(JZ_GPIO_PORTB(18), 1);
192
193    return 0;
194}
195
196static irqreturn_t n526_eink_busy_irq(int irq, void *devid)
197{
198    struct broadsheetfb_par *par = devid;
199    wake_up(&par->waitq);
200
201    return IRQ_HANDLED;
202}
203
204static int n526_eink_setup_irq(struct fb_info *info)
205{
206    int ret;
207    struct broadsheetfb_par *par = info->par;
208
209    gpio_request(JZ_GPIO_PORTB(17), "eink busy");
210    gpio_direction_input(JZ_GPIO_PORTB(17));
211
212    ret = request_irq(gpio_to_irq(JZ_GPIO_PORTB(17)), n526_eink_busy_irq,
213                IRQF_DISABLED | IRQF_TRIGGER_RISING,
214                "eink busyline", par);
215    if (ret)
216        printk("n526 display: Failed to request busyline irq: %d\n", ret);
217    return 0;
218}
219
220static void n526_eink_cleanup(struct broadsheetfb_par *par)
221{
222}
223
224static struct broadsheet_board broadsheet_pdata = {
225    .owner = THIS_MODULE,
226    .init = n526_eink_init,
227    .wait_for_rdy = n526_eink_wait,
228    .set_ctl = n526_eink_set_ctl,
229    .set_hdb = n526_eink_set_hdb,
230    .get_hdb = n526_eink_get_hdb,
231    .cleanup = n526_eink_cleanup,
232    .setup_irq = n526_eink_setup_irq,
233};
234
235static struct platform_device n526_broadsheet_device = {
236    .name = "broadsheetfb",
237    .id = -1,
238    .dev = {
239        .platform_data = &broadsheet_pdata,
240    },
241};
242
243static struct gpio_keys_button qi_lb60_gpio_keys_buttons[] = {
244    [0] = {
245        .code = KEY_ENTER,
246        .gpio = 0,
247        .active_low = 1,
248        .desc = "Power",
249    },
250};
251
252static struct gpio_keys_platform_data qi_lb60_gpio_keys_data = {
253    .nbuttons = ARRAY_SIZE(qi_lb60_gpio_keys_buttons),
254    .buttons = qi_lb60_gpio_keys_buttons,
255};
256
257static struct platform_device qi_lb60_gpio_keys = {
258    .name = "gpio-keys",
259    .id = -1,
260    .dev = {
261        .platform_data = &qi_lb60_gpio_keys_data,
262    }
263};
264
265static struct i2c_gpio_platform_data n526_i2c_pdata = {
266    .sda_pin = JZ_GPIO_PORTD(23),
267    .scl_pin = JZ_GPIO_PORTD(24),
268    .udelay = 2,
269    .timeout = 3 * HZ,
270};
271
272static struct platform_device n526_i2c_device = {
273    .name = "i2c-gpio",
274    .id = -1,
275    .dev = {
276        .platform_data = &n526_i2c_pdata,
277    },
278};
279
280static struct i2c_board_info n526_i2c_board_info = {
281    .type = "n526-lpc",
282    .addr = 0x54,
283};
284
285static struct platform_device *jz_platform_devices[] __initdata = {
286    &jz4740_usb_ohci_device,
287    &jz4740_udc_device,
288    &jz4740_mmc_device,
289    &jz4740_nand_device,
290    &jz4740_i2s_device,
291    &jz4740_codec_device,
292    &jz4740_rtc_device,
293    &n526_leds_device,
294    &n526_broadsheet_device,
295    &qi_lb60_gpio_keys,
296    &n526_i2c_device,
297};
298
299static int __init n526_init_platform_devices(void)
300{
301
302    jz4740_nand_device.dev.platform_data = &n526_nand_pdata;
303    jz4740_mmc_device.dev.platform_data = &n526_mmc_pdata;
304
305    n526_i2c_board_info.irq = gpio_to_irq(JZ_GPIO_PORTD(14)),
306    i2c_register_board_info(0, &n526_i2c_board_info, 1);
307
308    return platform_add_devices(jz_platform_devices,
309                    ARRAY_SIZE(jz_platform_devices));
310
311}
312
313struct jz4740_clock_board_data jz4740_clock_bdata = {
314    .ext_rate = 12000000,
315    .rtc_rate = 32768,
316};
317
318static int __init n526_board_setup(void)
319{
320    board_gpio_setup();
321
322    if (n526_init_platform_devices())
323        panic("Failed to initalize platform devices\n");
324
325    return 0;
326}
327arch_initcall(n526_board_setup);

Archive Download the corresponding diff file



interactive