1 /* mach-hmt.c - Platform code for Airgoo HMT
3 * Copyright 2009 Peter Korsgaard <jacmet@sunsite.dk>
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.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/serial_core.h>
14 #include <linux/platform_device.h>
16 #include <linux/i2c.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>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/irq.h>
29 #include <mach/hardware.h>
30 #include <mach/regs-fb.h>
34 #include <asm/mach-types.h>
36 #include <plat/regs-serial.h>
39 #include <plat/nand.h>
41 #include <plat/s3c6410.h>
42 #include <plat/clock.h>
43 #include <plat/devs.h>
46 #define UCON S3C2410_UCON_DEFAULT
47 #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE)
48 #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
50 static struct s3c2410_uartcfg hmt_uartcfgs
[] __initdata
= {
74 static int hmt_bl_init(struct device
*dev
)
78 ret
= gpio_request(S3C64XX_GPB(4), "lcd backlight enable");
80 ret
= gpio_direction_output(S3C64XX_GPB(4), 0);
85 static int hmt_bl_notify(int brightness
)
88 * translate from CIELUV/CIELAB L*->brightness, E.G. from
89 * perceived luminance to light output. Assumes range 0..25600
91 if (brightness
< 0x800) {
92 /* Y = Yn * L / 903.3 */
93 brightness
= (100*256 * brightness
+ 231245/2) / 231245;
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);
100 gpio_set_value(S3C64XX_GPB(4), brightness
);
105 static void hmt_bl_exit(struct device
*dev
)
107 gpio_free(S3C64XX_GPB(4));
110 static struct platform_pwm_backlight_data hmt_backlight_data
= {
112 .max_brightness
= 100 * 256,
113 .dft_brightness
= 40 * 256,
114 .pwm_period_ns
= 1000000000 / (100 * 256 * 20),
116 .notify
= hmt_bl_notify
,
121 static struct platform_device hmt_backlight_device
= {
122 .name
= "pwm-backlight",
124 .parent
= &s3c_device_timer
[1].dev
,
125 .platform_data
= &hmt_backlight_data
,
129 static struct s3c_fb_pd_win hmt_fb_win0
= {
145 /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
146 static struct s3c_fb_platdata hmt_lcd_pdata __initdata
= {
147 .setup_gpio
= s3c64xx_fb_gpio_setup_24bpp
,
148 .win
[0] = &hmt_fb_win0
,
149 .vidcon0
= VIDCON0_VIDOUT_RGB
| VIDCON0_PNRMODE_RGB
,
150 .vidcon1
= VIDCON1_INV_HSYNC
| VIDCON1_INV_VSYNC
,
153 static struct mtd_partition hmt_nand_part
[] = {
160 .name
= "uboot-env1",
165 .name
= "uboot-env2",
167 .offset
= SZ_512K
+ SZ_256K
,
176 .size
= MTDPART_SIZ_FULL
,
177 .offset
= SZ_1M
+ SZ_2M
,
181 static struct s3c2410_nand_set hmt_nand_sets
[] = {
185 .nr_partitions
= ARRAY_SIZE(hmt_nand_part
),
186 .partitions
= hmt_nand_part
,
190 static struct s3c2410_platform_nand hmt_nand_info
= {
194 .nr_sets
= ARRAY_SIZE(hmt_nand_sets
),
195 .sets
= hmt_nand_sets
,
198 static struct gpio_led hmt_leds
[] = {
199 { /* left function keys */
201 .gpio
= S3C64XX_GPO(12),
202 .default_trigger
= "default-on",
204 { /* right function keys - red */
206 .gpio
= S3C64XX_GPO(13),
208 { /* right function keys - green */
209 .name
= "right:green",
210 .gpio
= S3C64XX_GPO(14),
212 { /* right function keys - blue */
213 .name
= "right:blue",
214 .gpio
= S3C64XX_GPO(15),
215 .default_trigger
= "default-on",
219 static struct gpio_led_platform_data hmt_led_data
= {
220 .num_leds
= ARRAY_SIZE(hmt_leds
),
224 static struct platform_device hmt_leds_device
= {
227 .dev
.platform_data
= &hmt_led_data
,
230 static struct map_desc hmt_iodesc
[] = {};
232 static struct platform_device
*hmt_devices
[] __initdata
= {
237 &s3c_device_timer
[1],
238 &hmt_backlight_device
,
242 static void __init
hmt_map_io(void)
244 s3c64xx_init_io(hmt_iodesc
, ARRAY_SIZE(hmt_iodesc
));
245 s3c24xx_init_clocks(12000000);
246 s3c24xx_init_uarts(hmt_uartcfgs
, ARRAY_SIZE(hmt_uartcfgs
));
249 static void __init
hmt_machine_init(void)
251 s3c_i2c0_set_platdata(NULL
);
252 s3c_fb_set_platdata(&hmt_lcd_pdata
);
253 s3c_device_nand
.dev
.platform_data
= &hmt_nand_info
;
255 gpio_request(S3C64XX_GPC(7), "usb power");
256 gpio_direction_output(S3C64XX_GPC(7), 0);
257 gpio_request(S3C64XX_GPM(0), "usb power");
258 gpio_direction_output(S3C64XX_GPM(0), 1);
259 gpio_request(S3C64XX_GPK(7), "usb power");
260 gpio_direction_output(S3C64XX_GPK(7), 1);
261 gpio_request(S3C64XX_GPF(13), "usb power");
262 gpio_direction_output(S3C64XX_GPF(13), 1);
264 platform_add_devices(hmt_devices
, ARRAY_SIZE(hmt_devices
));
267 MACHINE_START(HMT
, "Airgoo-HMT")
268 /* Maintainer: Peter Korsgaard <jacmet@sunsite.dk> */
269 .phys_io
= S3C_PA_UART
& 0xfff00000,
270 .io_pg_offst
= (((u32
)S3C_VA_UART
) >> 18) & 0xfffc,
271 .boot_params
= S3C64XX_PA_SDRAM
+ 0x100,
272 .init_irq
= s3c6410_init_irq
,
273 .map_io
= hmt_map_io
,
274 .init_machine
= hmt_machine_init
,
275 .timer
= &s3c24xx_timer
,