Root/
Source at commit a0cdc62b12557c0fd0f10582e28d029038e76a87 created 13 years 15 days ago. By Peter Zotov, XZ0032: Fix backlight PWM frequency. | |
---|---|
1 | /* |
2 | * Copyright (C) 2011 Peter Zotov <whitequark@whitequark.org> |
3 | * XZ0032 JZ4725B board 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 | #include <linux/gpio_keys.h> |
20 | #include <linux/power_supply.h> |
21 | #include <linux/power/gpio-charger.h> |
22 | #include <linux/power/jz4740-battery.h> |
23 | #include <linux/pwm_backlight.h> |
24 | #include <linux/input.h> |
25 | |
26 | #include <jz4750/platform.h> |
27 | |
28 | #include "../clock.h" |
29 | |
30 | #include <jz4750_nand.h> |
31 | #include <jz4740_fb.h> |
32 | #include <jz4740_mmc.h> |
33 | #include <jz47xx_adc_keys.h> |
34 | |
35 | static long xz0032_panic_blink(int state) { |
36 | gpio_set_value(JZ_GPIO_PORTC(15), state ? 1 : 0); |
37 | return 0; |
38 | } |
39 | |
40 | /* NAND */ |
41 | static struct nand_ecclayout xz0032_ecclayout = { |
42 | .eccbytes = 52, |
43 | .eccpos = { |
44 | 3, 4, 5, 6, 7, 8, 9, 10, |
45 | 11, 12, 13, 14, 15, 16, 17, 18, |
46 | 19, 20, 21, 22, 23, 24, 25, 26, |
47 | 27, 28, 29, 30, 31, 32, 33, 34, |
48 | 35, 36, 37, 38, 39, 40, 41, 42, |
49 | 43, 44, 45, 46, 47, 48, 49, 50, |
50 | 51, 52, 53, 54, 55, |
51 | }, |
52 | .oobfree = { |
53 | { .offset = 0, .length = 3 }, |
54 | { .offset = 56, .length = 8 }, |
55 | }, |
56 | }; |
57 | |
58 | static struct mtd_partition xz0032_partitions[] = { |
59 | { |
60 | .name = "u-boot", |
61 | .offset = 0, |
62 | .size = 1 * 0x100000, |
63 | }, |
64 | { |
65 | .name = "kernel", |
66 | .offset = 1 * 0x100000, |
67 | .size = 15 * 0x100000, |
68 | }, |
69 | { |
70 | .name = "rootfs", |
71 | .offset = 16 * 0x100000, |
72 | .size = (1024 - 16) * 0x100000, |
73 | }, |
74 | }; |
75 | |
76 | static struct jz_nand_platform_data xz0032_nand_pdata = { |
77 | .bch_8bit = 1, |
78 | .ecc_layout = &xz0032_ecclayout, |
79 | .partitions = xz0032_partitions, |
80 | .num_partitions = ARRAY_SIZE(xz0032_partitions), |
81 | .busy_gpio = 91, |
82 | }; |
83 | |
84 | /* MMC controller */ |
85 | |
86 | static struct jz_gpio_bulk_request xz0032_mmc1_pins[] = { |
87 | JZ_GPIO_BULK_PIN(MSC1_CMD), |
88 | JZ_GPIO_BULK_PIN(MSC1_CLK), |
89 | JZ_GPIO_BULK_PIN(MSC1_DATA0), |
90 | }; |
91 | |
92 | static struct jz4740_mmc_platform_data xz0032_mmc1_pdata = { |
93 | .gpio_card_detect = JZ_GPIO_PORTC(20), |
94 | .gpio_read_only = -1, |
95 | .gpio_power = -1, |
96 | |
97 | .card_detect_active_low = 1, |
98 | |
99 | .data_1bit = 1, |
100 | |
101 | .mmc_pins = xz0032_mmc1_pins, |
102 | .mmc_pin_count = ARRAY_SIZE(xz0032_mmc1_pins), |
103 | |
104 | .clock_id = "mmc1", |
105 | }; |
106 | |
107 | /* LCD */ |
108 | |
109 | static struct fb_videomode xz0032_video_modes[] = { |
110 | { |
111 | .name = "480x272", |
112 | .xres = 480, |
113 | .yres = 272, |
114 | .refresh = 60, |
115 | .left_margin = 2, |
116 | .right_margin = 2, |
117 | .upper_margin = 2, |
118 | .lower_margin = 2, |
119 | .hsync_len = 41, |
120 | .vsync_len = 10, |
121 | .sync = 0, |
122 | .vmode = FB_VMODE_NONINTERLACED, |
123 | }, |
124 | }; |
125 | |
126 | static struct jz4740_fb_platform_data xz0032_fb_pdata = { |
127 | .width = 90, |
128 | .height = 52, |
129 | .num_modes = ARRAY_SIZE(xz0032_video_modes), |
130 | .modes = xz0032_video_modes, |
131 | .bpp = 16, |
132 | .lcd_type = JZ_LCD_TYPE_GENERIC_16_BIT, |
133 | .pixclk_falling_edge = 1, |
134 | }; |
135 | |
136 | /* Battery */ |
137 | static struct jz_battery_platform_data xz0032_battery_pdata = { |
138 | .gpio_charge = -1, |
139 | .info = { |
140 | .name = "battery", |
141 | .technology = POWER_SUPPLY_TECHNOLOGY_LIPO, |
142 | .voltage_max_design = 4100000, |
143 | .voltage_min_design = 2700000, |
144 | }, |
145 | }; |
146 | |
147 | /* Charger */ |
148 | static char *xz0032_batteries[] = { |
149 | "battery", |
150 | }; |
151 | |
152 | static struct gpio_charger_platform_data xz0032_charger_pdata = { |
153 | .name = "usb", |
154 | .type = POWER_SUPPLY_TYPE_USB, |
155 | .gpio = JZ_GPIO_PORTD(16), |
156 | .gpio_active_low = 0, |
157 | .batteries = xz0032_batteries, |
158 | .num_batteries = ARRAY_SIZE(xz0032_batteries), |
159 | }; |
160 | |
161 | static struct platform_device xz0032_charger_device = { |
162 | .name = "gpio-charger", |
163 | .dev = { |
164 | .platform_data = &xz0032_charger_pdata, |
165 | }, |
166 | }; |
167 | |
168 | /* PWM controlled backlight */ |
169 | static struct platform_pwm_backlight_data xz0032_backlight_data = { |
170 | .pwm_id = 5, |
171 | .max_brightness = 100, |
172 | .dft_brightness = 100, |
173 | .pwm_period_ns = 10000000, |
174 | }; |
175 | |
176 | static struct platform_device xz0032_pwm_backlight_device = { |
177 | .name = "pwm-backlight", |
178 | .dev = { |
179 | .platform_data = &xz0032_backlight_data, |
180 | } |
181 | }; |
182 | |
183 | /* Buttons */ |
184 | static struct gpio_keys_button xz0032_gpio_keys_buttons[] = { |
185 | #ifdef CONFIG_JZ4750L_XZ0032_UART0_RX_PIN_AS_KEY |
186 | { |
187 | .code = KEY_A, |
188 | .gpio = JZ_GPIO_PORTC(31), |
189 | .active_low = 1, |
190 | .desc = "K1", |
191 | }, |
192 | #endif |
193 | { |
194 | .code = KEY_B, |
195 | .gpio = JZ_GPIO_PORTD(23), |
196 | .active_low = 1, |
197 | .desc = "K2", |
198 | }, |
199 | #ifdef CONFIG_JZ4750L_XZ0032_I2C_PINS_AS_KEYS |
200 | { |
201 | .code = KEY_VOLUMEUP, |
202 | .gpio = JZ_GPIO_PORTC(10), |
203 | .active_low = 1, |
204 | .desc = "VOL+", |
205 | }, |
206 | { |
207 | .code = KEY_VOLUMEDOWN, |
208 | .gpio = JZ_GPIO_PORTC(11), |
209 | .active_low = 1, |
210 | .desc = "VOL-", |
211 | }, |
212 | #endif |
213 | { |
214 | .code = KEY_POWER, |
215 | .gpio = JZ_GPIO_PORTB(31), |
216 | .active_low = 1, |
217 | .desc = "POWER", |
218 | }, |
219 | }; |
220 | |
221 | static struct gpio_keys_platform_data xz0032_gpio_keys_data = { |
222 | .nbuttons = ARRAY_SIZE(xz0032_gpio_keys_buttons), |
223 | .buttons = xz0032_gpio_keys_buttons, |
224 | .rep = 1, |
225 | }; |
226 | |
227 | static struct platform_device xz0032_gpio_keys_device = { |
228 | .name = "gpio-keys", |
229 | .id = -1, |
230 | .dev = { |
231 | .platform_data = &xz0032_gpio_keys_data, |
232 | } |
233 | }; |
234 | |
235 | /* ADC buttons */ |
236 | static struct jz_adc_button xz0032_adc_keys[] = { |
237 | { |
238 | .code = KEY_C, |
239 | .value_min = 550, |
240 | .value_max = 750, |
241 | .desc = "K3", |
242 | }, |
243 | { |
244 | .code = KEY_D, |
245 | .value_min = 950, |
246 | .value_max = 1150, |
247 | .desc = "K4", |
248 | }, |
249 | { |
250 | .code = KEY_E, |
251 | .value_min = 1450, |
252 | .value_max = 1650, |
253 | .desc = "K5", |
254 | }, |
255 | { |
256 | .code = KEY_F, |
257 | .value_min = 1950, |
258 | .value_max = 2150, |
259 | .desc = "K6", |
260 | }, |
261 | }; |
262 | |
263 | static struct jz_adc_keys_platform_data xz0032_adc_keys_pdata = { |
264 | .buttons = xz0032_adc_keys, |
265 | .nbuttons = ARRAY_SIZE(xz0032_adc_keys), |
266 | .rep = 1, |
267 | .poll_interval = 50, |
268 | }; |
269 | |
270 | static struct platform_device *jz_platform_devices[] __initdata = { |
271 | &jz4750_rtc_device, |
272 | &jz4750_udc_device, |
273 | &jz4750_nand_device, |
274 | &jz4750_framebuffer_device, |
275 | #ifndef CONFIG_JZ4750L_XZ0032_I2C_GPIO_AS_KEYS |
276 | &jz4750_i2c_device, |
277 | #endif |
278 | &jz4750_adc_device, |
279 | &jz4750_mmc1_device, |
280 | &xz0032_charger_device, |
281 | &xz0032_pwm_backlight_device, |
282 | &xz0032_gpio_keys_device, |
283 | }; |
284 | |
285 | static int __init xz0032_init_platform_devices(void) |
286 | { |
287 | jz4750_nand_device.dev.platform_data = &xz0032_nand_pdata; |
288 | jz4750_framebuffer_device.dev.platform_data = &xz0032_fb_pdata; |
289 | jz4750_adc_device.dev.platform_data = &xz0032_battery_pdata; |
290 | jz4750_mmc1_device.dev.platform_data = &xz0032_mmc1_pdata; |
291 | |
292 | #ifdef CONFIG_KEYBOARD_JZ47XX_ADC |
293 | jz47xx_adc_keys_set_config(&xz0032_adc_keys_pdata); |
294 | #endif |
295 | |
296 | panic_blink = xz0032_panic_blink; |
297 | |
298 | jz4750_serial_device_register(); |
299 | |
300 | return platform_add_devices(jz_platform_devices, |
301 | ARRAY_SIZE(jz_platform_devices)); |
302 | |
303 | } |
304 | |
305 | struct jz47xx_clock_board_data jz47xx_clock_bdata = { |
306 | .ext_rate = 12000000, |
307 | .rtc_rate = 32768, |
308 | }; |
309 | |
310 | static int __init xz0032_board_setup(void) |
311 | { |
312 | printk(KERN_INFO "XZ0032 (JZ4725B) setup\n"); |
313 | |
314 | if (xz0032_init_platform_devices()) |
315 | panic("Failed to initalize platform devices\n"); |
316 | |
317 | return 0; |
318 | } |
319 | arch_initcall(xz0032_board_setup); |
320 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
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