Root/
1 | /* mach-hmt.c - Platform code for Airgoo HMT |
2 | * |
3 | * Copyright 2009 Peter Korsgaard <jacmet@sunsite.dk> |
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 version 2 as |
7 | * published by the Free Software Foundation. |
8 | * |
9 | */ |
10 | |
11 | #include <linux/kernel.h> |
12 | #include <linux/init.h> |
13 | #include <linux/serial_core.h> |
14 | #include <linux/platform_device.h> |
15 | #include <linux/io.h> |
16 | #include <linux/i2c.h> |
17 | #include <linux/fb.h> |
18 | #include <linux/gpio.h> |
19 | #include <linux/delay.h> |
20 | #include <linux/leds.h> |
21 | #include <linux/pwm_backlight.h> |
22 | #include <linux/mtd/mtd.h> |
23 | #include <linux/mtd/partitions.h> |
24 | |
25 | #include <asm/mach/arch.h> |
26 | #include <asm/mach/map.h> |
27 | #include <asm/mach/irq.h> |
28 | |
29 | #include <mach/hardware.h> |
30 | #include <mach/regs-fb.h> |
31 | #include <mach/map.h> |
32 | |
33 | #include <asm/irq.h> |
34 | #include <asm/mach-types.h> |
35 | |
36 | #include <plat/regs-serial.h> |
37 | #include <plat/iic.h> |
38 | #include <plat/fb.h> |
39 | #include <plat/nand.h> |
40 | |
41 | #include <mach/s3c6410.h> |
42 | #include <plat/clock.h> |
43 | #include <plat/devs.h> |
44 | #include <plat/cpu.h> |
45 | |
46 | #define UCON S3C2410_UCON_DEFAULT |
47 | #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE) |
48 | #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE) |
49 | |
50 | static struct s3c2410_uartcfg hmt_uartcfgs[] __initdata = { |
51 | [0] = { |
52 | .hwport = 0, |
53 | .flags = 0, |
54 | .ucon = UCON, |
55 | .ulcon = ULCON, |
56 | .ufcon = UFCON, |
57 | }, |
58 | [1] = { |
59 | .hwport = 1, |
60 | .flags = 0, |
61 | .ucon = UCON, |
62 | .ulcon = ULCON, |
63 | .ufcon = UFCON, |
64 | }, |
65 | [2] = { |
66 | .hwport = 2, |
67 | .flags = 0, |
68 | .ucon = UCON, |
69 | .ulcon = ULCON, |
70 | .ufcon = UFCON, |
71 | }, |
72 | }; |
73 | |
74 | static int hmt_bl_init(struct device *dev) |
75 | { |
76 | int ret; |
77 | |
78 | ret = gpio_request(S3C64XX_GPB(4), "lcd backlight enable"); |
79 | if (!ret) |
80 | ret = gpio_direction_output(S3C64XX_GPB(4), 0); |
81 | |
82 | return ret; |
83 | } |
84 | |
85 | static int hmt_bl_notify(struct device *dev, int brightness) |
86 | { |
87 | /* |
88 | * translate from CIELUV/CIELAB L*->brightness, E.G. from |
89 | * perceived luminance to light output. Assumes range 0..25600 |
90 | */ |
91 | if (brightness < 0x800) { |
92 | /* Y = Yn * L / 903.3 */ |
93 | brightness = (100*256 * brightness + 231245/2) / 231245; |
94 | } else { |
95 | /* Y = Yn * ((L + 16) / 116 )^3 */ |
96 | int t = (brightness*4 + 16*1024 + 58)/116; |
97 | brightness = 25 * ((t * t * t + 0x100000/2) / 0x100000); |
98 | } |
99 | |
100 | gpio_set_value(S3C64XX_GPB(4), brightness); |
101 | |
102 | return brightness; |
103 | } |
104 | |
105 | static void hmt_bl_exit(struct device *dev) |
106 | { |
107 | gpio_free(S3C64XX_GPB(4)); |
108 | } |
109 | |
110 | static struct platform_pwm_backlight_data hmt_backlight_data = { |
111 | .pwm_id = 1, |
112 | .max_brightness = 100 * 256, |
113 | .dft_brightness = 40 * 256, |
114 | .pwm_period_ns = 1000000000 / (100 * 256 * 20), |
115 | .init = hmt_bl_init, |
116 | .notify = hmt_bl_notify, |
117 | .exit = hmt_bl_exit, |
118 | |
119 | }; |
120 | |
121 | static struct platform_device hmt_backlight_device = { |
122 | .name = "pwm-backlight", |
123 | .dev = { |
124 | .parent = &s3c_device_timer[1].dev, |
125 | .platform_data = &hmt_backlight_data, |
126 | }, |
127 | }; |
128 | |
129 | static struct s3c_fb_pd_win hmt_fb_win0 = { |
130 | .win_mode = { |
131 | .left_margin = 8, |
132 | .right_margin = 13, |
133 | .upper_margin = 7, |
134 | .lower_margin = 5, |
135 | .hsync_len = 3, |
136 | .vsync_len = 1, |
137 | .xres = 800, |
138 | .yres = 480, |
139 | }, |
140 | .max_bpp = 32, |
141 | .default_bpp = 16, |
142 | }; |
143 | |
144 | /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */ |
145 | static struct s3c_fb_platdata hmt_lcd_pdata __initdata = { |
146 | .setup_gpio = s3c64xx_fb_gpio_setup_24bpp, |
147 | .win[0] = &hmt_fb_win0, |
148 | .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB, |
149 | .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC, |
150 | }; |
151 | |
152 | static struct mtd_partition hmt_nand_part[] = { |
153 | [0] = { |
154 | .name = "uboot", |
155 | .size = SZ_512K, |
156 | .offset = 0, |
157 | }, |
158 | [1] = { |
159 | .name = "uboot-env1", |
160 | .size = SZ_256K, |
161 | .offset = SZ_512K, |
162 | }, |
163 | [2] = { |
164 | .name = "uboot-env2", |
165 | .size = SZ_256K, |
166 | .offset = SZ_512K + SZ_256K, |
167 | }, |
168 | [3] = { |
169 | .name = "kernel", |
170 | .size = SZ_2M, |
171 | .offset = SZ_1M, |
172 | }, |
173 | [4] = { |
174 | .name = "rootfs", |
175 | .size = MTDPART_SIZ_FULL, |
176 | .offset = SZ_1M + SZ_2M, |
177 | }, |
178 | }; |
179 | |
180 | static struct s3c2410_nand_set hmt_nand_sets[] = { |
181 | [0] = { |
182 | .name = "nand", |
183 | .nr_chips = 1, |
184 | .nr_partitions = ARRAY_SIZE(hmt_nand_part), |
185 | .partitions = hmt_nand_part, |
186 | }, |
187 | }; |
188 | |
189 | static struct s3c2410_platform_nand hmt_nand_info = { |
190 | .tacls = 25, |
191 | .twrph0 = 55, |
192 | .twrph1 = 40, |
193 | .nr_sets = ARRAY_SIZE(hmt_nand_sets), |
194 | .sets = hmt_nand_sets, |
195 | }; |
196 | |
197 | static struct gpio_led hmt_leds[] = { |
198 | { /* left function keys */ |
199 | .name = "left:blue", |
200 | .gpio = S3C64XX_GPO(12), |
201 | .default_trigger = "default-on", |
202 | }, |
203 | { /* right function keys - red */ |
204 | .name = "right:red", |
205 | .gpio = S3C64XX_GPO(13), |
206 | }, |
207 | { /* right function keys - green */ |
208 | .name = "right:green", |
209 | .gpio = S3C64XX_GPO(14), |
210 | }, |
211 | { /* right function keys - blue */ |
212 | .name = "right:blue", |
213 | .gpio = S3C64XX_GPO(15), |
214 | .default_trigger = "default-on", |
215 | }, |
216 | }; |
217 | |
218 | static struct gpio_led_platform_data hmt_led_data = { |
219 | .num_leds = ARRAY_SIZE(hmt_leds), |
220 | .leds = hmt_leds, |
221 | }; |
222 | |
223 | static struct platform_device hmt_leds_device = { |
224 | .name = "leds-gpio", |
225 | .id = -1, |
226 | .dev.platform_data = &hmt_led_data, |
227 | }; |
228 | |
229 | static struct map_desc hmt_iodesc[] = {}; |
230 | |
231 | static struct platform_device *hmt_devices[] __initdata = { |
232 | &s3c_device_i2c0, |
233 | &s3c_device_nand, |
234 | &s3c_device_fb, |
235 | &s3c_device_ohci, |
236 | &s3c_device_timer[1], |
237 | &hmt_backlight_device, |
238 | &hmt_leds_device, |
239 | }; |
240 | |
241 | static void __init hmt_map_io(void) |
242 | { |
243 | s3c64xx_init_io(hmt_iodesc, ARRAY_SIZE(hmt_iodesc)); |
244 | s3c24xx_init_clocks(12000000); |
245 | s3c24xx_init_uarts(hmt_uartcfgs, ARRAY_SIZE(hmt_uartcfgs)); |
246 | } |
247 | |
248 | static void __init hmt_machine_init(void) |
249 | { |
250 | s3c_i2c0_set_platdata(NULL); |
251 | s3c_fb_set_platdata(&hmt_lcd_pdata); |
252 | s3c_nand_set_platdata(&hmt_nand_info); |
253 | |
254 | gpio_request(S3C64XX_GPC(7), "usb power"); |
255 | gpio_direction_output(S3C64XX_GPC(7), 0); |
256 | gpio_request(S3C64XX_GPM(0), "usb power"); |
257 | gpio_direction_output(S3C64XX_GPM(0), 1); |
258 | gpio_request(S3C64XX_GPK(7), "usb power"); |
259 | gpio_direction_output(S3C64XX_GPK(7), 1); |
260 | gpio_request(S3C64XX_GPF(13), "usb power"); |
261 | gpio_direction_output(S3C64XX_GPF(13), 1); |
262 | |
263 | platform_add_devices(hmt_devices, ARRAY_SIZE(hmt_devices)); |
264 | } |
265 | |
266 | MACHINE_START(HMT, "Airgoo-HMT") |
267 | /* Maintainer: Peter Korsgaard <jacmet@sunsite.dk> */ |
268 | .boot_params = S3C64XX_PA_SDRAM + 0x100, |
269 | .init_irq = s3c6410_init_irq, |
270 | .map_io = hmt_map_io, |
271 | .init_machine = hmt_machine_init, |
272 | .timer = &s3c24xx_timer, |
273 | MACHINE_END |
274 |
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