14 #include <linux/kernel.h>
15 #include <linux/types.h>
17 #include <linux/list.h>
21 #include <linux/device.h>
22 #include <linux/serial_core.h>
26 #include <linux/input.h>
29 #include <linux/i2c.h>
38 #include <linux/export.h>
44 #include <mach/hardware.h>
49 #include <mach/regs-lcd.h>
50 #include <mach/regs-clock.h>
52 #include <mach/regs-gpio.h>
63 #include <plat/clock.h>
75 #define H1940_LATCH ((void __force __iomem *)0xF8000000)
77 #define H1940_PA_LATCH S3C2410_CS2
79 #define H1940_LATCH_BIT(x) (1 << ((x) + 16 - S3C_GPIO_END))
90 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
91 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
92 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
122 static unsigned int latch_state;
124 static void h1940_latch_control(
unsigned int clear,
unsigned int set)
130 latch_state &= ~clear;
138 static inline int h1940_gpiolib_to_latch(
int offset)
140 return 1 << (offset + 16);
143 static void h1940_gpiolib_latch_set(
struct gpio_chip *
chip,
146 int latch_bit = h1940_gpiolib_to_latch(offset);
148 h1940_latch_control(value ? 0 : latch_bit,
149 value ? latch_bit : 0);
152 static int h1940_gpiolib_latch_output(
struct gpio_chip *
chip,
155 h1940_gpiolib_latch_set(chip, offset, value);
159 static int h1940_gpiolib_latch_get(
struct gpio_chip *
chip,
162 return (latch_state >> (offset + 16)) & 1;
165 static struct gpio_chip h1940_latch_gpiochip = {
168 .label =
"H1940_LATCH",
170 .direction_output = h1940_gpiolib_latch_output,
171 .set = h1940_gpiolib_latch_set,
172 .get = h1940_gpiolib_latch_get,
177 .vbus_pin_inverted = 1,
184 .oversampling_shift = 2,
193 S3C2410_LCDCON5_INVVLINE | \
194 S3C2410_LCDCON5_HWSWP,
212 .displays = &h1940_lcd,
214 .default_display = 0,
217 .gpccon = 0xaa940659,
218 .gpccon_mask = 0xffffc0f0,
220 .gpcup_mask = 0xffffffff,
221 .gpdcon = 0xaa84aaa0,
222 .gpdcon_mask = 0xffffffff,
224 .gpdup_mask = 0xffffffff,
227 static int power_supply_init(
struct device *
dev)
232 static int h1940_is_ac_online(
void)
237 static void power_supply_exit(
struct device *dev)
242 static char *h1940_supplicants[] = {
248 .init = power_supply_init,
249 .is_ac_online = h1940_is_ac_online,
250 .exit = power_supply_exit,
251 .supplied_to = h1940_supplicants,
252 .num_supplicants =
ARRAY_SIZE(h1940_supplicants),
255 static struct resource power_supply_resources[] = {
267 .resource = power_supply_resources,
268 .num_resources =
ARRAY_SIZE(power_supply_resources),
272 { .volt = 4070, .cur = 162, .level = 100},
273 { .volt = 4040, .cur = 165, .level = 95},
274 { .volt = 4016, .cur = 164, .level = 90},
275 { .volt = 3996, .cur = 166, .level = 85},
276 { .volt = 3971, .cur = 168, .level = 80},
277 { .volt = 3951, .cur = 168, .level = 75},
278 { .volt = 3931, .cur = 170, .level = 70},
279 { .volt = 3903, .cur = 172, .level = 65},
280 { .volt = 3886, .cur = 172, .level = 60},
281 { .volt = 3858, .cur = 176, .level = 55},
282 { .volt = 3842, .cur = 176, .level = 50},
283 { .volt = 3818, .cur = 176, .level = 45},
284 { .volt = 3789, .cur = 180, .level = 40},
285 { .volt = 3769, .cur = 180, .level = 35},
286 { .volt = 3749, .cur = 184, .level = 30},
287 { .volt = 3732, .cur = 184, .level = 25},
288 { .volt = 3716, .cur = 184, .level = 20},
289 { .volt = 3708, .cur = 184, .level = 15},
290 { .volt = 3716, .cur = 96, .level = 10},
291 { .volt = 3700, .cur = 96, .level = 5},
292 { .volt = 3684, .cur = 96, .level = 0},
296 { .volt = 4130, .cur = 0, .level = 100},
297 { .volt = 3982, .cur = 0, .level = 50},
298 { .volt = 3854, .cur = 0, .level = 10},
299 { .volt = 3841, .cur = 0, .level = 0},
302 static int h1940_bat_init(
void)
315 static void h1940_bat_exit(
void)
320 static void h1940_enable_charger(
void)
325 static void h1940_disable_charger(
void)
331 .init = h1940_bat_init,
332 .exit = h1940_bat_exit,
333 .enable_charger = h1940_enable_charger,
334 .disable_charger = h1940_disable_charger,
337 .lut_noac = bat_lut_noac,
339 .lut_acin = bat_lut_acin,
342 .current_channel = 1,
344 .current_mult = 1893,
345 .internal_impedance = 200,
346 .backup_volt_channel = 3,
348 .backup_volt_mult = 4056,
349 .backup_volt_min = 0,
350 .backup_volt_max = 4149288
354 .name =
"s3c-adc-battery",
358 .platform_data = &h1940_bat_cfg,
365 unsigned long *delay_on,
unsigned long *delay_off)
367 int blink_gpio, check_gpio1, check_gpio2;
387 if (delay_on && delay_off && !*delay_on && !*delay_off)
388 *delay_on = *delay_off = 500;
390 spin_lock(&h1940_blink_spin);
399 if (gpio_is_valid(gpio))
403 if (gpio_is_valid(gpio))
410 spin_unlock(&h1940_blink_spin);
416 static struct gpio_led h1940_leds_desc[] = {
419 .default_trigger =
"main-battery-full",
421 .retain_state_suspended = 1,
426 =
"main-battery-charging-blink-full-solid",
428 .retain_state_suspended = 1,
434 .leds = h1940_leds_desc,
442 .platform_data = &h1940_leds_pdata,
451 static void h1940_set_mmc_power(
unsigned char power_mode,
unsigned short vdd)
453 switch (power_mode) {
469 .set_power = h1940_set_mmc_power,
473 static int h1940_backlight_init(
struct device *dev)
499 static void h1940_backlight_exit(
struct device *dev)
508 .max_brightness = 100,
509 .dft_brightness = 50,
511 .pwm_period_ns = 36296,
512 .init = h1940_backlight_init,
513 .notify = h1940_backlight_notify,
514 .exit = h1940_backlight_exit,
518 .name =
"pwm-backlight",
521 .platform_data = &backlight_data,
536 }
while (value && retries--);
570 .set_power = h1940_lcd_power_set,
574 .name =
"platform-lcd",
576 .dev.platform_data = &h1940_lcd_power_data,
588 .platform_data = &uda1380_info,
592 #define DECLARE_BUTTON(p, k, n, w) \
616 .buttons = h1940_buttons,
624 .platform_data = &h1940_buttons_data,
638 &h1940_device_bluetooth,
650 static void __init h1940_map_io(
void)
658 #ifdef CONFIG_PM_H1940
664 h1940_latch_control(0, 0);
669 static void __init h1940_reserve(
void)
675 static void __init h1940_init_irq(
void)
680 static void __init h1940_init(
void)
745 .atag_offset = 0x100,
746 .map_io = h1940_map_io,
747 .reserve = h1940_reserve,
748 .init_irq = h1940_init_irq,
749 .init_machine = h1940_init,