0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/kernel.h>
0009 #include <linux/types.h>
0010 #include <linux/interrupt.h>
0011 #include <linux/list.h>
0012 #include <linux/memblock.h>
0013 #include <linux/timer.h>
0014 #include <linux/init.h>
0015 #include <linux/device.h>
0016 #include <linux/serial_core.h>
0017 #include <linux/serial_s3c.h>
0018 #include <linux/platform_device.h>
0019 #include <linux/io.h>
0020 #include <linux/gpio.h>
0021 #include <linux/gpio/machine.h>
0022 #include <linux/input.h>
0023 #include <linux/gpio_keys.h>
0024 #include <linux/pwm.h>
0025 #include <linux/pwm_backlight.h>
0026 #include <linux/i2c.h>
0027 #include <linux/leds.h>
0028 #include <linux/pda_power.h>
0029 #include <linux/s3c_adc_battery.h>
0030 #include <linux/delay.h>
0031
0032 #include <video/platform_lcd.h>
0033
0034 #include <linux/mmc/host.h>
0035 #include <linux/export.h>
0036
0037 #include <asm/irq.h>
0038 #include <asm/mach-types.h>
0039 #include <asm/mach/arch.h>
0040 #include <asm/mach/map.h>
0041 #include <asm/mach/irq.h>
0042
0043 #include <linux/platform_data/i2c-s3c2410.h>
0044 #include <linux/platform_data/mmc-s3cmci.h>
0045 #include <linux/platform_data/touchscreen-s3c2410.h>
0046 #include <linux/platform_data/usb-s3c2410_udc.h>
0047
0048 #include <sound/uda1380.h>
0049
0050 #include <linux/platform_data/fb-s3c2410.h>
0051 #include "map.h"
0052 #include "hardware-s3c24xx.h"
0053 #include "regs-clock.h"
0054 #include "regs-gpio.h"
0055 #include "gpio-samsung.h"
0056
0057 #include "cpu.h"
0058 #include "devs.h"
0059 #include "gpio-cfg.h"
0060 #include "pm.h"
0061
0062 #include "s3c24xx.h"
0063 #include "h1940.h"
0064
0065 #define H1940_LATCH ((void __force __iomem *)0xF8000000)
0066
0067 #define H1940_PA_LATCH S3C2410_CS2
0068
0069 #define H1940_LATCH_BIT(x) (1 << ((x) + 16 - S3C_GPIO_END))
0070
0071 #define S3C24XX_PLL_MDIV_SHIFT (12)
0072 #define S3C24XX_PLL_PDIV_SHIFT (4)
0073 #define S3C24XX_PLL_SDIV_SHIFT (0)
0074
0075 static struct map_desc h1940_iodesc[] __initdata = {
0076 [0] = {
0077 .virtual = (unsigned long)H1940_LATCH,
0078 .pfn = __phys_to_pfn(H1940_PA_LATCH),
0079 .length = SZ_16K,
0080 .type = MT_DEVICE
0081 },
0082 };
0083
0084 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
0085 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
0086 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
0087
0088 static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = {
0089 [0] = {
0090 .hwport = 0,
0091 .flags = 0,
0092 .ucon = 0x3c5,
0093 .ulcon = 0x03,
0094 .ufcon = 0x51,
0095 },
0096 [1] = {
0097 .hwport = 1,
0098 .flags = 0,
0099 .ucon = 0x245,
0100 .ulcon = 0x03,
0101 .ufcon = 0x00,
0102 },
0103
0104 [2] = {
0105 .hwport = 2,
0106 .flags = 0,
0107 .uart_flags = UPF_CONS_FLOW,
0108 .ucon = 0x3c5,
0109 .ulcon = 0x43,
0110 .ufcon = 0x51,
0111 }
0112 };
0113
0114
0115
0116 static unsigned int latch_state;
0117
0118 static void h1940_latch_control(unsigned int clear, unsigned int set)
0119 {
0120 unsigned long flags;
0121
0122 local_irq_save(flags);
0123
0124 latch_state &= ~clear;
0125 latch_state |= set;
0126
0127 __raw_writel(latch_state, H1940_LATCH);
0128
0129 local_irq_restore(flags);
0130 }
0131
0132 static inline int h1940_gpiolib_to_latch(int offset)
0133 {
0134 return 1 << (offset + 16);
0135 }
0136
0137 static void h1940_gpiolib_latch_set(struct gpio_chip *chip,
0138 unsigned offset, int value)
0139 {
0140 int latch_bit = h1940_gpiolib_to_latch(offset);
0141
0142 h1940_latch_control(value ? 0 : latch_bit,
0143 value ? latch_bit : 0);
0144 }
0145
0146 static int h1940_gpiolib_latch_output(struct gpio_chip *chip,
0147 unsigned offset, int value)
0148 {
0149 h1940_gpiolib_latch_set(chip, offset, value);
0150 return 0;
0151 }
0152
0153 static int h1940_gpiolib_latch_get(struct gpio_chip *chip,
0154 unsigned offset)
0155 {
0156 return (latch_state >> (offset + 16)) & 1;
0157 }
0158
0159 static struct gpio_chip h1940_latch_gpiochip = {
0160 .base = H1940_LATCH_GPIO(0),
0161 .owner = THIS_MODULE,
0162 .label = "H1940_LATCH",
0163 .ngpio = 16,
0164 .direction_output = h1940_gpiolib_latch_output,
0165 .set = h1940_gpiolib_latch_set,
0166 .get = h1940_gpiolib_latch_get,
0167 };
0168
0169 static struct s3c2410_udc_mach_info h1940_udc_cfg __initdata = {
0170 .vbus_pin = S3C2410_GPG(5),
0171 .vbus_pin_inverted = 1,
0172 .pullup_pin = H1940_LATCH_USB_DP,
0173 };
0174
0175 static struct s3c2410_ts_mach_info h1940_ts_cfg __initdata = {
0176 .delay = 10000,
0177 .presc = 49,
0178 .oversampling_shift = 2,
0179 .cfg_gpio = s3c24xx_ts_cfg_gpio,
0180 };
0181
0182
0183
0184
0185 static struct s3c2410fb_display h1940_lcd __initdata = {
0186 .lcdcon5= S3C2410_LCDCON5_FRM565 | \
0187 S3C2410_LCDCON5_INVVLINE | \
0188 S3C2410_LCDCON5_HWSWP,
0189
0190 .type = S3C2410_LCDCON1_TFT,
0191 .width = 240,
0192 .height = 320,
0193 .pixclock = 260000,
0194 .xres = 240,
0195 .yres = 320,
0196 .bpp = 16,
0197 .left_margin = 8,
0198 .right_margin = 20,
0199 .hsync_len = 4,
0200 .upper_margin = 8,
0201 .lower_margin = 7,
0202 .vsync_len = 1,
0203 };
0204
0205 static struct s3c2410fb_mach_info h1940_fb_info __initdata = {
0206 .displays = &h1940_lcd,
0207 .num_displays = 1,
0208 .default_display = 0,
0209
0210 .lpcsel = 0x02,
0211 .gpccon = 0xaa940659,
0212 .gpccon_mask = 0xffffc0f0,
0213 .gpccon_reg = S3C2410_GPCCON,
0214 .gpcup = 0x0000ffff,
0215 .gpcup_mask = 0xffffffff,
0216 .gpcup_reg = S3C2410_GPCUP,
0217 .gpdcon = 0xaa84aaa0,
0218 .gpdcon_mask = 0xffffffff,
0219 .gpdcon_reg = S3C2410_GPDCON,
0220 .gpdup = 0x0000faff,
0221 .gpdup_mask = 0xffffffff,
0222 .gpdup_reg = S3C2410_GPDUP,
0223 };
0224
0225 static int power_supply_init(struct device *dev)
0226 {
0227 return gpio_request(S3C2410_GPF(2), "cable plugged");
0228 }
0229
0230 static int h1940_is_ac_online(void)
0231 {
0232 return !gpio_get_value(S3C2410_GPF(2));
0233 }
0234
0235 static void power_supply_exit(struct device *dev)
0236 {
0237 gpio_free(S3C2410_GPF(2));
0238 }
0239
0240 static char *h1940_supplicants[] = {
0241 "main-battery",
0242 "backup-battery",
0243 };
0244
0245 static struct pda_power_pdata power_supply_info = {
0246 .init = power_supply_init,
0247 .is_ac_online = h1940_is_ac_online,
0248 .exit = power_supply_exit,
0249 .supplied_to = h1940_supplicants,
0250 .num_supplicants = ARRAY_SIZE(h1940_supplicants),
0251 };
0252
0253 static struct resource power_supply_resources[] = {
0254 [0] = DEFINE_RES_NAMED(IRQ_EINT2, 1, "ac", IORESOURCE_IRQ \
0255 | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE),
0256 };
0257
0258 static struct platform_device power_supply = {
0259 .name = "pda-power",
0260 .id = -1,
0261 .dev = {
0262 .platform_data =
0263 &power_supply_info,
0264 },
0265 .resource = power_supply_resources,
0266 .num_resources = ARRAY_SIZE(power_supply_resources),
0267 };
0268
0269 static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
0270 { .volt = 4070, .cur = 162, .level = 100},
0271 { .volt = 4040, .cur = 165, .level = 95},
0272 { .volt = 4016, .cur = 164, .level = 90},
0273 { .volt = 3996, .cur = 166, .level = 85},
0274 { .volt = 3971, .cur = 168, .level = 80},
0275 { .volt = 3951, .cur = 168, .level = 75},
0276 { .volt = 3931, .cur = 170, .level = 70},
0277 { .volt = 3903, .cur = 172, .level = 65},
0278 { .volt = 3886, .cur = 172, .level = 60},
0279 { .volt = 3858, .cur = 176, .level = 55},
0280 { .volt = 3842, .cur = 176, .level = 50},
0281 { .volt = 3818, .cur = 176, .level = 45},
0282 { .volt = 3789, .cur = 180, .level = 40},
0283 { .volt = 3769, .cur = 180, .level = 35},
0284 { .volt = 3749, .cur = 184, .level = 30},
0285 { .volt = 3732, .cur = 184, .level = 25},
0286 { .volt = 3716, .cur = 184, .level = 20},
0287 { .volt = 3708, .cur = 184, .level = 15},
0288 { .volt = 3716, .cur = 96, .level = 10},
0289 { .volt = 3700, .cur = 96, .level = 5},
0290 { .volt = 3684, .cur = 96, .level = 0},
0291 };
0292
0293 static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
0294 { .volt = 4130, .cur = 0, .level = 100},
0295 { .volt = 3982, .cur = 0, .level = 50},
0296 { .volt = 3854, .cur = 0, .level = 10},
0297 { .volt = 3841, .cur = 0, .level = 0},
0298 };
0299
0300 static struct gpiod_lookup_table h1940_bat_gpio_table = {
0301 .dev_id = "s3c-adc-battery",
0302 .table = {
0303
0304 GPIO_LOOKUP("GPIOF", 3, "charge-status", GPIO_ACTIVE_LOW),
0305 { },
0306 },
0307 };
0308
0309 static int h1940_bat_init(void)
0310 {
0311 int ret;
0312
0313 ret = gpio_request(H1940_LATCH_SM803_ENABLE, "h1940-charger-enable");
0314 if (ret)
0315 return ret;
0316 gpio_direction_output(H1940_LATCH_SM803_ENABLE, 0);
0317
0318 return 0;
0319
0320 }
0321
0322 static void h1940_bat_exit(void)
0323 {
0324 gpio_free(H1940_LATCH_SM803_ENABLE);
0325 }
0326
0327 static void h1940_enable_charger(void)
0328 {
0329 gpio_set_value(H1940_LATCH_SM803_ENABLE, 1);
0330 }
0331
0332 static void h1940_disable_charger(void)
0333 {
0334 gpio_set_value(H1940_LATCH_SM803_ENABLE, 0);
0335 }
0336
0337 static struct s3c_adc_bat_pdata h1940_bat_cfg = {
0338 .init = h1940_bat_init,
0339 .exit = h1940_bat_exit,
0340 .enable_charger = h1940_enable_charger,
0341 .disable_charger = h1940_disable_charger,
0342 .lut_noac = bat_lut_noac,
0343 .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
0344 .lut_acin = bat_lut_acin,
0345 .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
0346 .volt_channel = 0,
0347 .current_channel = 1,
0348 .volt_mult = 4056,
0349 .current_mult = 1893,
0350 .internal_impedance = 200,
0351 .backup_volt_channel = 3,
0352
0353 .backup_volt_mult = 4056,
0354 .backup_volt_min = 0,
0355 .backup_volt_max = 4149288
0356 };
0357
0358 static struct platform_device h1940_battery = {
0359 .name = "s3c-adc-battery",
0360 .id = -1,
0361 .dev = {
0362 .parent = &s3c_device_adc.dev,
0363 .platform_data = &h1940_bat_cfg,
0364 },
0365 };
0366
0367 static DEFINE_SPINLOCK(h1940_blink_spin);
0368
0369 int h1940_led_blink_set(struct gpio_desc *desc, int state,
0370 unsigned long *delay_on, unsigned long *delay_off)
0371 {
0372 int blink_gpio, check_gpio1, check_gpio2;
0373 int gpio = desc ? desc_to_gpio(desc) : -EINVAL;
0374
0375 switch (gpio) {
0376 case H1940_LATCH_LED_GREEN:
0377 blink_gpio = S3C2410_GPA(7);
0378 check_gpio1 = S3C2410_GPA(1);
0379 check_gpio2 = S3C2410_GPA(3);
0380 break;
0381 case H1940_LATCH_LED_RED:
0382 blink_gpio = S3C2410_GPA(1);
0383 check_gpio1 = S3C2410_GPA(7);
0384 check_gpio2 = S3C2410_GPA(3);
0385 break;
0386 default:
0387 blink_gpio = S3C2410_GPA(3);
0388 check_gpio1 = S3C2410_GPA(1);
0389 check_gpio2 = S3C2410_GPA(7);
0390 break;
0391 }
0392
0393 if (delay_on && delay_off && !*delay_on && !*delay_off)
0394 *delay_on = *delay_off = 500;
0395
0396 spin_lock(&h1940_blink_spin);
0397
0398 switch (state) {
0399 case GPIO_LED_NO_BLINK_LOW:
0400 case GPIO_LED_NO_BLINK_HIGH:
0401 if (!gpio_get_value(check_gpio1) &&
0402 !gpio_get_value(check_gpio2))
0403 gpio_set_value(H1940_LATCH_LED_FLASH, 0);
0404 gpio_set_value(blink_gpio, 0);
0405 if (gpio_is_valid(gpio))
0406 gpio_set_value(gpio, state);
0407 break;
0408 case GPIO_LED_BLINK:
0409 if (gpio_is_valid(gpio))
0410 gpio_set_value(gpio, 0);
0411 gpio_set_value(H1940_LATCH_LED_FLASH, 1);
0412 gpio_set_value(blink_gpio, 1);
0413 break;
0414 }
0415
0416 spin_unlock(&h1940_blink_spin);
0417
0418 return 0;
0419 }
0420 EXPORT_SYMBOL(h1940_led_blink_set);
0421
0422 static struct gpio_led h1940_leds_desc[] = {
0423 {
0424 .name = "Green",
0425 .default_trigger = "main-battery-full",
0426 .gpio = H1940_LATCH_LED_GREEN,
0427 .retain_state_suspended = 1,
0428 },
0429 {
0430 .name = "Red",
0431 .default_trigger
0432 = "main-battery-charging-blink-full-solid",
0433 .gpio = H1940_LATCH_LED_RED,
0434 .retain_state_suspended = 1,
0435 },
0436 };
0437
0438 static struct gpio_led_platform_data h1940_leds_pdata = {
0439 .num_leds = ARRAY_SIZE(h1940_leds_desc),
0440 .leds = h1940_leds_desc,
0441 .gpio_blink_set = h1940_led_blink_set,
0442 };
0443
0444 static struct platform_device h1940_device_leds = {
0445 .name = "leds-gpio",
0446 .id = -1,
0447 .dev = {
0448 .platform_data = &h1940_leds_pdata,
0449 },
0450 };
0451
0452 static struct platform_device h1940_device_bluetooth = {
0453 .name = "h1940-bt",
0454 .id = -1,
0455 };
0456
0457 static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd)
0458 {
0459 s3c24xx_mci_def_set_power(power_mode, vdd);
0460
0461 switch (power_mode) {
0462 case MMC_POWER_OFF:
0463 gpio_set_value(H1940_LATCH_SD_POWER, 0);
0464 break;
0465 case MMC_POWER_UP:
0466 case MMC_POWER_ON:
0467 gpio_set_value(H1940_LATCH_SD_POWER, 1);
0468 break;
0469 default:
0470 break;
0471 }
0472 }
0473
0474 static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = {
0475 .set_power = h1940_set_mmc_power,
0476 .ocr_avail = MMC_VDD_32_33,
0477 };
0478
0479 static struct gpiod_lookup_table h1940_mmc_gpio_table = {
0480 .dev_id = "s3c2410-sdi",
0481 .table = {
0482
0483 GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW),
0484
0485 GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW),
0486
0487 GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
0488 GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
0489 GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
0490 GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
0491 GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
0492 GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
0493 { },
0494 },
0495 };
0496
0497 static struct gpiod_lookup_table h1940_audio_gpio_table = {
0498 .dev_id = "h1940-audio",
0499 .table = {
0500 GPIO_LOOKUP("H1940_LATCH",
0501 H1940_LATCH_AUDIO_POWER - H1940_LATCH_GPIO(0),
0502 "speaker-power", GPIO_ACTIVE_HIGH),
0503 GPIO_LOOKUP("GPIOG", 4, "hp", GPIO_ACTIVE_HIGH),
0504 { },
0505 },
0506 };
0507
0508 static struct platform_device h1940_audio = {
0509 .name = "h1940-audio",
0510 .id = -1,
0511 };
0512
0513 static struct pwm_lookup h1940_pwm_lookup[] = {
0514 PWM_LOOKUP("samsung-pwm", 0, "pwm-backlight", NULL, 36296,
0515 PWM_POLARITY_NORMAL),
0516 };
0517
0518 static int h1940_backlight_init(struct device *dev)
0519 {
0520 gpio_request(S3C2410_GPB(0), "Backlight");
0521
0522 gpio_direction_output(S3C2410_GPB(0), 0);
0523 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
0524 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
0525 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
0526
0527 return 0;
0528 }
0529
0530 static int h1940_backlight_notify(struct device *dev, int brightness)
0531 {
0532 if (!brightness) {
0533 gpio_direction_output(S3C2410_GPB(0), 1);
0534 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
0535 } else {
0536 gpio_direction_output(S3C2410_GPB(0), 0);
0537 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
0538 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
0539 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
0540 }
0541 return brightness;
0542 }
0543
0544 static void h1940_backlight_exit(struct device *dev)
0545 {
0546 gpio_direction_output(S3C2410_GPB(0), 1);
0547 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
0548 }
0549
0550
0551 static struct platform_pwm_backlight_data backlight_data = {
0552 .max_brightness = 100,
0553 .dft_brightness = 50,
0554 .init = h1940_backlight_init,
0555 .notify = h1940_backlight_notify,
0556 .exit = h1940_backlight_exit,
0557 };
0558
0559 static struct platform_device h1940_backlight = {
0560 .name = "pwm-backlight",
0561 .dev = {
0562 .parent = &samsung_device_pwm.dev,
0563 .platform_data = &backlight_data,
0564 },
0565 .id = -1,
0566 };
0567
0568 static void h1940_lcd_power_set(struct plat_lcd_data *pd,
0569 unsigned int power)
0570 {
0571 int value, retries = 100;
0572
0573 if (!power) {
0574 gpio_set_value(S3C2410_GPC(0), 0);
0575
0576 do {
0577 value = gpio_get_value(S3C2410_GPC(6));
0578 } while (value && retries--);
0579
0580 gpio_set_value(H1940_LATCH_LCD_P2, 0);
0581 gpio_set_value(H1940_LATCH_LCD_P3, 0);
0582 gpio_set_value(H1940_LATCH_LCD_P4, 0);
0583
0584 gpio_direction_output(S3C2410_GPC(1), 0);
0585 gpio_direction_output(S3C2410_GPC(4), 0);
0586
0587 gpio_set_value(H1940_LATCH_LCD_P1, 0);
0588 gpio_set_value(H1940_LATCH_LCD_P0, 0);
0589
0590 gpio_set_value(S3C2410_GPC(5), 0);
0591
0592 } else {
0593 gpio_set_value(H1940_LATCH_LCD_P0, 1);
0594 gpio_set_value(H1940_LATCH_LCD_P1, 1);
0595
0596 gpio_direction_input(S3C2410_GPC(1));
0597 gpio_direction_input(S3C2410_GPC(4));
0598 mdelay(10);
0599 s3c_gpio_cfgpin(S3C2410_GPC(1), S3C_GPIO_SFN(2));
0600 s3c_gpio_cfgpin(S3C2410_GPC(4), S3C_GPIO_SFN(2));
0601
0602 gpio_set_value(S3C2410_GPC(5), 1);
0603 gpio_set_value(S3C2410_GPC(0), 1);
0604
0605 gpio_set_value(H1940_LATCH_LCD_P3, 1);
0606 gpio_set_value(H1940_LATCH_LCD_P2, 1);
0607 gpio_set_value(H1940_LATCH_LCD_P4, 1);
0608 }
0609 }
0610
0611 static struct plat_lcd_data h1940_lcd_power_data = {
0612 .set_power = h1940_lcd_power_set,
0613 };
0614
0615 static struct platform_device h1940_lcd_powerdev = {
0616 .name = "platform-lcd",
0617 .dev.parent = &s3c_device_lcd.dev,
0618 .dev.platform_data = &h1940_lcd_power_data,
0619 };
0620
0621 static struct uda1380_platform_data uda1380_info = {
0622 .gpio_power = H1940_LATCH_UDA_POWER,
0623 .gpio_reset = S3C2410_GPA(12),
0624 .dac_clk = UDA1380_DAC_CLK_SYSCLK,
0625 };
0626
0627 static struct i2c_board_info h1940_i2c_devices[] = {
0628 {
0629 I2C_BOARD_INFO("uda1380", 0x1a),
0630 .platform_data = &uda1380_info,
0631 },
0632 };
0633
0634 #define DECLARE_BUTTON(p, k, n, w) \
0635 { \
0636 .gpio = p, \
0637 .code = k, \
0638 .desc = n, \
0639 .wakeup = w, \
0640 .active_low = 1, \
0641 }
0642
0643 static struct gpio_keys_button h1940_buttons[] = {
0644 DECLARE_BUTTON(S3C2410_GPF(0), KEY_POWER, "Power", 1),
0645 DECLARE_BUTTON(S3C2410_GPF(6), KEY_ENTER, "Select", 1),
0646 DECLARE_BUTTON(S3C2410_GPF(7), KEY_RECORD, "Record", 0),
0647 DECLARE_BUTTON(S3C2410_GPG(0), KEY_F11, "Calendar", 0),
0648 DECLARE_BUTTON(S3C2410_GPG(2), KEY_F12, "Contacts", 0),
0649 DECLARE_BUTTON(S3C2410_GPG(3), KEY_MAIL, "Mail", 0),
0650 DECLARE_BUTTON(S3C2410_GPG(6), KEY_LEFT, "Left_arrow", 0),
0651 DECLARE_BUTTON(S3C2410_GPG(7), KEY_HOMEPAGE, "Home", 0),
0652 DECLARE_BUTTON(S3C2410_GPG(8), KEY_RIGHT, "Right_arrow", 0),
0653 DECLARE_BUTTON(S3C2410_GPG(9), KEY_UP, "Up_arrow", 0),
0654 DECLARE_BUTTON(S3C2410_GPG(10), KEY_DOWN, "Down_arrow", 0),
0655 };
0656
0657 static struct gpio_keys_platform_data h1940_buttons_data = {
0658 .buttons = h1940_buttons,
0659 .nbuttons = ARRAY_SIZE(h1940_buttons),
0660 };
0661
0662 static struct platform_device h1940_dev_buttons = {
0663 .name = "gpio-keys",
0664 .id = -1,
0665 .dev = {
0666 .platform_data = &h1940_buttons_data,
0667 }
0668 };
0669
0670 static struct platform_device *h1940_devices[] __initdata = {
0671 &h1940_dev_buttons,
0672 &s3c_device_ohci,
0673 &s3c_device_lcd,
0674 &s3c_device_wdt,
0675 &s3c_device_i2c0,
0676 &s3c_device_iis,
0677 &s3c_device_usbgadget,
0678 &h1940_device_leds,
0679 &h1940_device_bluetooth,
0680 &s3c_device_sdi,
0681 &s3c_device_rtc,
0682 &samsung_device_pwm,
0683 &h1940_backlight,
0684 &h1940_lcd_powerdev,
0685 &s3c_device_adc,
0686 &s3c_device_ts,
0687 &power_supply,
0688 &h1940_battery,
0689 &h1940_audio,
0690 };
0691
0692 static void __init h1940_map_io(void)
0693 {
0694 s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
0695 s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
0696 s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
0697
0698
0699
0700 #ifdef CONFIG_PM_H1940
0701 memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
0702 #endif
0703 s3c_pm_init();
0704
0705
0706 h1940_latch_control(0, 0);
0707 WARN_ON(gpiochip_add_data(&h1940_latch_gpiochip, NULL));
0708 }
0709
0710 static void __init h1940_init_time(void)
0711 {
0712 s3c2410_init_clocks(12000000);
0713 s3c24xx_timer_init();
0714 }
0715
0716
0717 static void __init h1940_reserve(void)
0718 {
0719 memblock_reserve(0x30003000, 0x1000);
0720 memblock_reserve(0x30081000, 0x1000);
0721 }
0722
0723 static void __init h1940_init(void)
0724 {
0725 u32 tmp;
0726
0727 s3c24xx_fb_set_platdata(&h1940_fb_info);
0728 gpiod_add_lookup_table(&h1940_mmc_gpio_table);
0729 gpiod_add_lookup_table(&h1940_audio_gpio_table);
0730 gpiod_add_lookup_table(&h1940_bat_gpio_table);
0731
0732 s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
0733 S3C_GPIO_PULL_NONE);
0734 s3c24xx_mci_set_platdata(&h1940_mmc_cfg);
0735 s3c24xx_udc_set_platdata(&h1940_udc_cfg);
0736 s3c24xx_ts_set_platdata(&h1940_ts_cfg);
0737 s3c_i2c0_set_platdata(NULL);
0738
0739
0740
0741
0742 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
0743 S3C2410_MISCCR_USBSUSPND0 |
0744 S3C2410_MISCCR_USBSUSPND1, 0x0);
0745
0746 tmp = (0x78 << S3C24XX_PLL_MDIV_SHIFT)
0747 | (0x02 << S3C24XX_PLL_PDIV_SHIFT)
0748 | (0x03 << S3C24XX_PLL_SDIV_SHIFT);
0749 writel(tmp, S3C2410_UPLLCON);
0750
0751 gpio_request(S3C2410_GPC(0), "LCD power");
0752 gpio_request(S3C2410_GPC(1), "LCD power");
0753 gpio_request(S3C2410_GPC(4), "LCD power");
0754 gpio_request(S3C2410_GPC(5), "LCD power");
0755 gpio_request(S3C2410_GPC(6), "LCD power");
0756 gpio_request(H1940_LATCH_LCD_P0, "LCD power");
0757 gpio_request(H1940_LATCH_LCD_P1, "LCD power");
0758 gpio_request(H1940_LATCH_LCD_P2, "LCD power");
0759 gpio_request(H1940_LATCH_LCD_P3, "LCD power");
0760 gpio_request(H1940_LATCH_LCD_P4, "LCD power");
0761 gpio_request(H1940_LATCH_MAX1698_nSHUTDOWN, "LCD power");
0762 gpio_direction_output(S3C2410_GPC(0), 0);
0763 gpio_direction_output(S3C2410_GPC(1), 0);
0764 gpio_direction_output(S3C2410_GPC(4), 0);
0765 gpio_direction_output(S3C2410_GPC(5), 0);
0766 gpio_direction_input(S3C2410_GPC(6));
0767 gpio_direction_output(H1940_LATCH_LCD_P0, 0);
0768 gpio_direction_output(H1940_LATCH_LCD_P1, 0);
0769 gpio_direction_output(H1940_LATCH_LCD_P2, 0);
0770 gpio_direction_output(H1940_LATCH_LCD_P3, 0);
0771 gpio_direction_output(H1940_LATCH_LCD_P4, 0);
0772 gpio_direction_output(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
0773
0774 gpio_request(H1940_LATCH_SD_POWER, "SD power");
0775 gpio_direction_output(H1940_LATCH_SD_POWER, 0);
0776
0777 pwm_add_table(h1940_pwm_lookup, ARRAY_SIZE(h1940_pwm_lookup));
0778 platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices));
0779
0780 gpio_request(S3C2410_GPA(1), "Red LED blink");
0781 gpio_request(S3C2410_GPA(3), "Blue LED blink");
0782 gpio_request(S3C2410_GPA(7), "Green LED blink");
0783 gpio_request(H1940_LATCH_LED_FLASH, "LED blink");
0784 gpio_direction_output(S3C2410_GPA(1), 0);
0785 gpio_direction_output(S3C2410_GPA(3), 0);
0786 gpio_direction_output(S3C2410_GPA(7), 0);
0787 gpio_direction_output(H1940_LATCH_LED_FLASH, 0);
0788
0789 i2c_register_board_info(0, h1940_i2c_devices,
0790 ARRAY_SIZE(h1940_i2c_devices));
0791 }
0792
0793 MACHINE_START(H1940, "IPAQ-H1940")
0794
0795 .atag_offset = 0x100,
0796 .nr_irqs = NR_IRQS_S3C2410,
0797 .map_io = h1940_map_io,
0798 .reserve = h1940_reserve,
0799 .init_irq = s3c2410_init_irq,
0800 .init_machine = h1940_init,
0801 .init_time = h1940_init_time,
0802 MACHINE_END