Date: | 2010-04-24 17:25:23 (13 years 11 months ago) |
---|---|
Author: | Lars C. |
Commit: | f40825a9742f2fe8096a79a3f506b91b9c4ef095 |
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 | ||
---|---|---|
10 | 10 | bool "Hanvon n516 eBook reader" |
11 | 11 | select SOC_JZ4740 |
12 | 12 | |
13 | config JZ4740_N526 | |
14 | bool "Hanvon n526 eBook reader" | |
15 | select SOC_JZ4740 | |
16 | ||
13 | 17 | endchoice |
14 | 18 | |
15 | 19 | config HAVE_PWM |
arch/mips/jz4740/Makefile | ||
---|---|---|
13 | 13 | |
14 | 14 | obj-$(CONFIG_JZ4740_QI_LB60) += board-qi_lb60.o |
15 | 15 | obj-$(CONFIG_JZ4740_N516) += board-n516.o board-n516-display.o |
16 | obj-$(CONFIG_JZ4740_N526) += board-n526.o | |
16 | 17 | |
17 | 18 | # PM support |
18 | 19 |
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 | #include <video/broadsheetfb.h> | |
21 | #include <linux/delay.h> | |
22 | #include <linux/interrupt.h> | |
23 | ||
24 | #include <linux/input.h> | |
25 | #include <linux/gpio_keys.h> | |
26 | ||
27 | #include <linux/i2c.h> | |
28 | ||
29 | #include "clock.h" | |
30 | ||
31 | #include <asm/mach-jz4740/jz4740_mmc.h> | |
32 | #include <asm/mach-jz4740/jz4740_nand.h> | |
33 | #include <asm/mach-jz4740/jz4740_fb.h> | |
34 | ||
35 | #include <asm/mach-jz4740/platform.h> | |
36 | ||
37 | /* NAND */ | |
38 | static struct nand_ecclayout n526_ecclayout = { | |
39 | /* .eccbytes = 36, | |
40 | .eccpos = { | |
41 | 6, 7, 8, 9, 10, 11, 12, 13, | |
42 | 14, 15, 16, 17, 18, 19, 20, 21, | |
43 | 22, 23, 24, 25, 26, 27, 28, 29, | |
44 | 30, 31, 32, 33, 34, 35, 36, 37, | |
45 | 38, 39, 40, 41},*/ | |
46 | .oobfree = { | |
47 | { | |
48 | .offset = 2, | |
49 | .length = 4, | |
50 | }, | |
51 | { | |
52 | .offset = 42, | |
53 | .length = 22, | |
54 | }, | |
55 | } | |
56 | }; | |
57 | ||
58 | static struct mtd_partition n526_partitions[] = { | |
59 | { .name = "NAND BOOT partition", | |
60 | .offset = 0 * 0x100000, | |
61 | .size = 4 * 0x100000, | |
62 | }, | |
63 | { .name = "NAND KERNEL partition", | |
64 | .offset = 4 * 0x100000, | |
65 | .size = 4 * 0x100000, | |
66 | }, | |
67 | { .name = "NAND ROOTFS partition", | |
68 | .offset = 16 * 0x100000, | |
69 | .size = 498 * 0x100000, | |
70 | }, | |
71 | }; | |
72 | ||
73 | static struct jz_nand_platform_data n526_nand_pdata = { | |
74 | .ecc_layout = &n526_ecclayout, | |
75 | .partitions = n526_partitions, | |
76 | .num_partitions = ARRAY_SIZE(n526_partitions), | |
77 | .busy_gpio = JZ_GPIO_PORTC(30), | |
78 | }; | |
79 | ||
80 | static struct jz4740_mmc_platform_data n526_mmc_pdata = { | |
81 | .gpio_card_detect = JZ_GPIO_PORTD(7), | |
82 | .card_detect_active_low = 1, | |
83 | .gpio_read_only = -1, | |
84 | .gpio_power = JZ_GPIO_PORTD(17), | |
85 | .power_active_low = 1, | |
86 | }; | |
87 | ||
88 | static struct gpio_led n526_leds[] = { | |
89 | { | |
90 | .name = "n526:blue:power", | |
91 | .gpio = JZ_GPIO_PORTD(28), | |
92 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
93 | } | |
94 | }; | |
95 | ||
96 | static struct gpio_led_platform_data n526_leds_pdata = { | |
97 | .leds = n526_leds, | |
98 | .num_leds = ARRAY_SIZE(n526_leds), | |
99 | }; | |
100 | ||
101 | static struct platform_device n526_leds_device = { | |
102 | .name = "leds-gpio", | |
103 | .id = -1, | |
104 | .dev = { | |
105 | .platform_data = &n526_leds_pdata, | |
106 | }, | |
107 | }; | |
108 | ||
109 | static void __init board_gpio_setup(void) | |
110 | { | |
111 | /* We only need to enable/disable pullup here for pins used in generic | |
112 | * drivers. Everything else is done by the drivers themselfs. */ | |
113 | jz_gpio_disable_pullup(JZ_GPIO_PORTD(17)); | |
114 | jz_gpio_enable_pullup(JZ_GPIO_PORTD(7)); | |
115 | jz_gpio_disable_pullup(JZ_GPIO_PORTC(19)); | |
116 | jz_gpio_disable_pullup(JZ_GPIO_PORTC(20)); | |
117 | jz_gpio_disable_pullup(JZ_GPIO_PORTC(21)); | |
118 | jz_gpio_disable_pullup(JZ_GPIO_PORTC(23)); | |
119 | } | |
120 | ||
121 | ||
122 | static const int n526_eink_ctrl_gpios[] = { | |
123 | 0, | |
124 | JZ_GPIO_PORTC(23), | |
125 | JZ_GPIO_PORTC(19), | |
126 | JZ_GPIO_PORTC(20), | |
127 | }; | |
128 | ||
129 | static void n526_eink_set_ctl(struct broadsheetfb_par * par, unsigned char ctrl, u8 | |
130 | value) | |
131 | { | |
132 | gpio_set_value(n526_eink_ctrl_gpios[ctrl], value); | |
133 | } | |
134 | ||
135 | ||
136 | static int n526_eink_wait(struct broadsheetfb_par *par) | |
137 | { | |
138 | wait_event(par->waitq, gpio_get_value(JZ_GPIO_PORTB(17))); | |
139 | ||
140 | return 0; | |
141 | } | |
142 | ||
143 | static u16 n526_eink_get_hdb(struct broadsheetfb_par *par) | |
144 | { | |
145 | u16 value = 0; | |
146 | jz_gpio_port_direction_input(JZ_GPIO_PORTC(0), 0xffff); | |
147 | gpio_set_value(JZ_GPIO_PORTC(21), 0); | |
148 | mdelay(100); | |
149 | ||
150 | value = jz_gpio_port_get_value(JZ_GPIO_PORTC(0), 0xffff); | |
151 | ||
152 | gpio_set_value(JZ_GPIO_PORTC(21), 1); | |
153 | jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff); | |
154 | return value; | |
155 | } | |
156 | ||
157 | static void n526_eink_set_hdb(struct broadsheetfb_par *par, u16 value) | |
158 | { | |
159 | jz_gpio_port_set_value(JZ_GPIO_PORTC(0), value, 0xffff); | |
160 | } | |
161 | ||
162 | static int n526_eink_init(struct broadsheetfb_par *par) | |
163 | { | |
164 | int i; | |
165 | ||
166 | gpio_request(JZ_GPIO_PORTD(1), "display reset"); | |
167 | gpio_direction_output(JZ_GPIO_PORTD(1), 1); | |
168 | mdelay(10); | |
169 | gpio_set_value(JZ_GPIO_PORTD(1), 0); | |
170 | ||
171 | gpio_request(JZ_GPIO_PORTB(18), "eink enable"); | |
172 | gpio_direction_output(JZ_GPIO_PORTB(18), 0); | |
173 | ||
174 | gpio_request(JZ_GPIO_PORTB(29), "foobar"); | |
175 | gpio_direction_output(JZ_GPIO_PORTB(29), 1); | |
176 | ||
177 | for(i = 1; i < ARRAY_SIZE(n526_eink_ctrl_gpios); ++i) { | |
178 | gpio_request(n526_eink_ctrl_gpios[i], "eink display ctrl"); | |
179 | gpio_direction_output(n526_eink_ctrl_gpios[i], 0); | |
180 | } | |
181 | ||
182 | gpio_request(JZ_GPIO_PORTC(22), "foobar"); | |
183 | gpio_direction_input(JZ_GPIO_PORTC(22)); | |
184 | gpio_request(JZ_GPIO_PORTC(21), "eink nRD"); | |
185 | gpio_direction_output(JZ_GPIO_PORTC(21), 1); | |
186 | ||
187 | for(i = 0; i < 16; ++i) { | |
188 | gpio_request(JZ_GPIO_PORTC(i), "eink display data"); | |
189 | } | |
190 | jz_gpio_port_direction_output(JZ_GPIO_PORTC(0), 0xffff); | |
191 | ||
192 | gpio_set_value(JZ_GPIO_PORTB(18), 1); | |
193 | ||
194 | return 0; | |
195 | } | |
196 | ||
197 | static irqreturn_t n526_eink_busy_irq(int irq, void *devid) | |
198 | { | |
199 | struct broadsheetfb_par *par = devid; | |
200 | wake_up(&par->waitq); | |
201 | ||
202 | return IRQ_HANDLED; | |
203 | } | |
204 | ||
205 | static int n526_eink_setup_irq(struct fb_info *info) | |
206 | { | |
207 | int ret; | |
208 | struct broadsheetfb_par *par = info->par; | |
209 | ||
210 | gpio_request(JZ_GPIO_PORTB(17), "eink busy"); | |
211 | gpio_direction_input(JZ_GPIO_PORTB(17)); | |
212 | ||
213 | ret = request_irq(gpio_to_irq(JZ_GPIO_PORTB(17)), n526_eink_busy_irq, | |
214 | IRQF_DISABLED | IRQF_TRIGGER_RISING, | |
215 | "eink busyline", par); | |
216 | if (ret) | |
217 | printk("n526 display: Failed to request busyline irq: %d\n", ret); | |
218 | return 0; | |
219 | } | |
220 | ||
221 | static void n526_eink_cleanup(struct broadsheetfb_par *par) | |
222 | { | |
223 | } | |
224 | ||
225 | static struct broadsheet_board broadsheet_pdata = { | |
226 | .owner = THIS_MODULE, | |
227 | .init = n526_eink_init, | |
228 | .wait_for_rdy = n526_eink_wait, | |
229 | .set_ctl = n526_eink_set_ctl, | |
230 | .set_hdb = n526_eink_set_hdb, | |
231 | .get_hdb = n526_eink_get_hdb, | |
232 | .cleanup = n526_eink_cleanup, | |
233 | .setup_irq = n526_eink_setup_irq, | |
234 | }; | |
235 | ||
236 | static struct platform_device n526_broadsheet_device = { | |
237 | .name = "broadsheetfb", | |
238 | .id = -1, | |
239 | .dev = { | |
240 | .platform_data = &broadsheet_pdata, | |
241 | }, | |
242 | }; | |
243 | ||
244 | /* Buttons */ | |
245 | static struct gpio_keys_button n526_gpio_keys_buttons[] = { | |
246 | [0] = { | |
247 | .code = KEY_ENTER, | |
248 | .gpio = 0, | |
249 | .active_low = 1, | |
250 | .desc = "Power", | |
251 | }, | |
252 | }; | |
253 | ||
254 | static struct gpio_keys_platform_data qi_lb60_gpio_keys_data = { | |
255 | .nbuttons = ARRAY_SIZE(qi_lb60_gpio_keys_buttons), | |
256 | .buttons = qi_lb60_gpio_keys_buttons, | |
257 | }; | |
258 | ||
259 | static struct platform_device n526_gpio_keys_device = { | |
260 | .name = "gpio-keys", | |
261 | .id = -1, | |
262 | .dev = { | |
263 | .platform_data = &n526_gpio_keys_data, | |
264 | } | |
265 | }; | |
266 | ||
267 | static struct i2c_board_info n526_i2c_board_info = { | |
268 | .type = "n526-lpc", | |
269 | .addr = 0x54, | |
270 | }; | |
271 | ||
272 | static struct platform_device *n526_platform_devices[] __initdata = { | |
273 | &jz4740_usb_ohci_device, | |
274 | &jz4740_udc_device, | |
275 | &jz4740_mmc_device, | |
276 | &jz4740_nand_device, | |
277 | &jz4740_i2s_device, | |
278 | &jz4740_codec_device, | |
279 | &jz4740_pcm_device, | |
280 | &jz4740_rtc_device, | |
281 | &jz4740_i2c_device, | |
282 | &n526_leds_device, | |
283 | &n526_broadsheet_device, | |
284 | &n526_gpio_keys_device, | |
285 | }; | |
286 | ||
287 | static int __init n526_init_platform_devices(void) | |
288 | { | |
289 | jz4740_nand_device.dev.platform_data = &n526_nand_pdata; | |
290 | jz4740_mmc_device.dev.platform_data = &n526_mmc_pdata; | |
291 | ||
292 | jz4740_serial_device_register(); | |
293 | ||
294 | n526_i2c_board_info.irq = gpio_to_irq(JZ_GPIO_PORTD(14)), | |
295 | i2c_register_board_info(0, &n526_i2c_board_info, 1); | |
296 | ||
297 | return platform_add_devices(n526_platform_devices, | |
298 | ARRAY_SIZE(n526_platform_devices)); | |
299 | ||
300 | } | |
301 | ||
302 | struct jz4740_clock_board_data jz4740_clock_bdata = { | |
303 | .ext_rate = 12000000, | |
304 | .rtc_rate = 32768, | |
305 | }; | |
306 | ||
307 | static int __init n526_board_setup(void) | |
308 | { | |
309 | board_gpio_setup(); | |
310 | ||
311 | if (n526_init_platform_devices()) | |
312 | panic("Failed to initalize platform devices\n"); | |
313 | ||
314 | return 0; | |
315 | } | |
316 | arch_initcall(n526_board_setup); |
Branches:
ben-wpan
ben-wpan-stefan
5396a9238205f20f811ea57898980d3ca82df0b6
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9