From be0cfe737dd7a7864d02029c8044827056c5d34f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 5 Oct 2009 14:38:03 +0200 Subject: Select usb host device. --- arch/arm/mach-s3c2442/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/Kconfig b/arch/arm/mach-s3c2442/Kconfig index 103e913f225..26c14b1b835 100644 --- a/arch/arm/mach-s3c2442/Kconfig +++ b/arch/arm/mach-s3c2442/Kconfig @@ -33,6 +33,7 @@ config MACH_NEO1973_GTA02 select POWER_SUPPLY select MACH_NEO1973 select S3C2410_PWM + select S3C_DEV_USB_HOST help Say Y here if you are using the Openmoko GTA02 / Freerunner GSM Phone -- cgit v1.2.3 From f2a655587cb722c715c9208e7ad1587d69d3e8fb Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 5 Oct 2009 14:56:25 +0200 Subject: gta02: Add glamo device --- arch/arm/mach-s3c2442/Kconfig | 1 + arch/arm/mach-s3c2442/include/mach/gta02.h | 3 + arch/arm/mach-s3c2442/mach-gta02.c | 123 +++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/Kconfig b/arch/arm/mach-s3c2442/Kconfig index 26c14b1b835..550f6492f32 100644 --- a/arch/arm/mach-s3c2442/Kconfig +++ b/arch/arm/mach-s3c2442/Kconfig @@ -34,6 +34,7 @@ config MACH_NEO1973_GTA02 select MACH_NEO1973 select S3C2410_PWM select S3C_DEV_USB_HOST + select S3C24XX_GPIO_EXTRA64 help Say Y here if you are using the Openmoko GTA02 / Freerunner GSM Phone diff --git a/arch/arm/mach-s3c2442/include/mach/gta02.h b/arch/arm/mach-s3c2442/include/mach/gta02.h index 953331d8d56..43310a3c199 100644 --- a/arch/arm/mach-s3c2442/include/mach/gta02.h +++ b/arch/arm/mach-s3c2442/include/mach/gta02.h @@ -79,6 +79,9 @@ #define GTA02_PCB_ID2_0 S3C2410_GPD(3) #define GTA02_PCB_ID2_1 S3C2410_GPD(4) +#define GTA02_GPIO_GLAMO_BASE S3C_GPIO_END +#define GTA02_GPIO_GLAMO(x) (GTA02_GPIO_GLAMO_BASE + (x)) + int gta02_get_pcb_revision(void); #endif /* _GTA02_H */ diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index 0fb385bd9cd..8fa94ef405a 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -87,6 +88,9 @@ #include #include +#include +#include + static struct pcf50633 *gta02_pcf; /* @@ -149,6 +153,124 @@ static struct s3c2410_uartcfg gta02_uartcfgs[] = { }, }; +/* + * we crank down SD Card clock dynamically when GPS is powered + */ + +static int gta02_glamo_mci_use_slow(void) +{ + return gta02_pm_gps_is_on(); +} + +static void gta02_glamo_external_reset(int level) +{ + s3c2410_gpio_setpin(GTA02_GPIO_3D_RESET, level); + s3c2410_gpio_cfgpin(GTA02_GPIO_3D_RESET, S3C2410_GPIO_OUTPUT); +} + +struct spi_gpio_platform_data spigpio_platform_data = { + .sck = GTA02_GPIO_GLAMO(10), + .mosi = GTA02_GPIO_GLAMO(11), + .miso = GTA02_GPIO_GLAMO(5), + .num_chipselect = 1, +}; + +static struct platform_device spigpio_device = { + .name = "spi_gpio", + .id = 2, + .dev = { + .platform_data = &spigpio_platform_data, + }, +}; + +static void gta02_glamo_registered(struct device *dev) +{ + spigpio_device.dev.parent = dev; + platform_device_register(&spigpio_device); +} + +static struct fb_videomode gta02_glamo_modes[] = { + { + .name = "480x640", + .xres = 480, + .yres = 640, + .pixclock = 40816, + .left_margin = 8, + .right_margin = 16, + .upper_margin = 2, + .lower_margin = 16, + .hsync_len = 8, + .vsync_len = 2, + .vmode = FB_VMODE_NONINTERLACED, + }, { + .name = "240x320", + .xres = 240, + .yres = 320, + .pixclock = 40816, + .left_margin = 8, + .right_margin = 16, + .upper_margin = 2, + .lower_margin = 16, + .hsync_len = 8, + .vsync_len = 2, + .vmode = FB_VMODE_NONINTERLACED, + } +}; + + +static struct glamo_fb_platform_data gta02_glamo_fb_pdata = { + .width = 43, + .height = 58, + + .num_modes = ARRAY_SIZE(gta02_glamo_modes), + .modes = gta02_glamo_modes, +}; + +static struct glamo_mmc_platform_data gta02_glamo_mmc_pdata = { + .glamo_mmc_use_slow = gta02_glamo_mci_use_slow, +}; + +static struct glamo_gpio_platform_data gta02_glamo_gpio_pdata = { + .base = GTA02_GPIO_GLAMO_BASE, + .registered = gta02_glamo_registered, +}; + +static struct glamo_platform_data gta02_glamo_pdata = { + .fb_data = >a02_glamo_fb_pdata, + .mmc_data = >a02_glamo_mmc_pdata, + .gpio_data = >a02_glamo_gpio_pdata, + + .osci_clock_rate = 32768, + + .glamo_external_reset = gta02_glamo_external_reset, +}; + +static struct resource gta02_glamo_resources[] = { + [0] = { + .start = S3C2410_CS1, + .end = S3C2410_CS1 + 0x1000000 - 1, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = GTA02_IRQ_3D, + .end = GTA02_IRQ_3D, + .flags = IORESOURCE_IRQ, + }, + [2] = { + .start = GTA02_GPIO_3D_RESET, + .end = GTA02_GPIO_3D_RESET, + }, +}; + +static struct platform_device gta02_glamo_dev = { + .name = "glamo3362", + .num_resources = ARRAY_SIZE(gta02_glamo_resources), + .resource = gta02_glamo_resources, + .dev = { + .platform_data = >a02_glamo_pdata, + }, +}; + #ifdef CONFIG_CHARGER_PCF50633 /* * On GTA02 the 1A charger features a 48K resistor to 0V on the ID pin. @@ -577,6 +699,7 @@ static struct platform_device *gta02_devices[] __initdata = { static struct platform_device *gta02_devices_pmu_children[] = { >a02_bl_dev, + >a02_glamo_dev, }; -- cgit v1.2.3 From dde0658050829ea79e7ebeed02c18fb7547b7b63 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 5 Oct 2009 14:58:32 +0200 Subject: Add jbt6k74 device --- arch/arm/mach-s3c2442/mach-gta02.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index 8fa94ef405a..eb4e215f473 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -88,6 +88,7 @@ #include #include +#include #include #include @@ -672,6 +673,36 @@ static struct s3c2410_hcd_info gta02_usb_info = { }, }; +/* JBT6k74 display controller */ +static void gta02_jbt6k74_probe_completed(struct device *dev) +{ + struct pcf50633 *pcf = gta02_pcf; + /* Switch on backlight. Qi does not do it for us */ + pcf50633_reg_write(pcf, PCF50633_REG_LEDOUT, 0x01); + pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0x00); + pcf50633_reg_write(pcf, PCF50633_REG_LEDDIM, 0x01); + pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0x01); + + gta02_bl_dev.dev.parent = dev; + platform_device_register(>a02_bl_dev); +} + +const struct jbt6k74_platform_data jbt6k74_pdata = { + .probe_completed = gta02_jbt6k74_probe_completed, + .gpio_reset = GTA02_GPIO_GLAMO(4), +}; + +static struct spi_board_info gta02_spi_board_info[] = { + { + .modalias = "jbt6k74", + .platform_data = &jbt6k74_pdata, + .controller_data = (void*)GTA02_GPIO_GLAMO(12), + /* irq */ + .max_speed_hz = 100 * 1000, + .bus_num = 2, + .chip_select = 0 + }, +}; static void __init gta02_map_io(void) { @@ -698,7 +729,6 @@ static struct platform_device *gta02_devices[] __initdata = { /* These guys DO need to be children of PMU. */ static struct platform_device *gta02_devices_pmu_children[] = { - >a02_bl_dev, >a02_glamo_dev, }; @@ -750,6 +780,8 @@ static void __init gta02_machine_init(void) s3c_i2c0_set_platdata(NULL); i2c_register_board_info(0, gta02_i2c_devs, ARRAY_SIZE(gta02_i2c_devs)); + spi_register_board_info(gta02_spi_board_info, + ARRAY_SIZE(gta02_spi_board_info)); platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices)); pm_power_off = gta02_poweroff; -- cgit v1.2.3 From d25c63532d5940146b9c53fc76a15c3c6b194510 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 5 Oct 2009 16:53:09 +0200 Subject: gta02: Add fiq handler --- arch/arm/mach-s3c2442/Kconfig | 2 + arch/arm/mach-s3c2442/Makefile | 4 +- arch/arm/mach-s3c2442/gta02-fiq.c | 126 +++++++++++++++++++++++++ arch/arm/mach-s3c2442/include/mach/gta02-fiq.h | 9 ++ arch/arm/mach-s3c2442/mach-gta02.c | 12 +-- 5 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 arch/arm/mach-s3c2442/gta02-fiq.c create mode 100644 arch/arm/mach-s3c2442/include/mach/gta02-fiq.h (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/Kconfig b/arch/arm/mach-s3c2442/Kconfig index 550f6492f32..8e37b9f42ab 100644 --- a/arch/arm/mach-s3c2442/Kconfig +++ b/arch/arm/mach-s3c2442/Kconfig @@ -34,6 +34,8 @@ config MACH_NEO1973_GTA02 select MACH_NEO1973 select S3C2410_PWM select S3C_DEV_USB_HOST + select FIQ + select S3C_PWM select S3C24XX_GPIO_EXTRA64 help Say Y here if you are using the Openmoko GTA02 / Freerunner GSM Phone diff --git a/arch/arm/mach-s3c2442/Makefile b/arch/arm/mach-s3c2442/Makefile index 2a19113a576..87338d9e139 100644 --- a/arch/arm/mach-s3c2442/Makefile +++ b/arch/arm/mach-s3c2442/Makefile @@ -12,7 +12,7 @@ obj- := obj-$(CONFIG_CPU_S3C2442) += s3c2442.o obj-$(CONFIG_CPU_S3C2442) += clock.o -obj-$(CONFIG_MACH_NEO1973_GTA02) += mach-gta02.o - +obj-$(CONFIG_MACH_NEO1973_GTA02) += mach-gta02.o \ + gta02-fiq.o # Machine support diff --git a/arch/arm/mach-s3c2442/gta02-fiq.c b/arch/arm/mach-s3c2442/gta02-fiq.c new file mode 100644 index 00000000000..78a6501d5be --- /dev/null +++ b/arch/arm/mach-s3c2442/gta02-fiq.c @@ -0,0 +1,126 @@ +#include + +#include +#include +#include +#include +#include +#include +#include + +/* ------------------------------------------------------------------------------- + * GTA02 FIQ related + * + * Calls into vibrator and hdq and based on the return values + * determines if we the FIQ source be kept alive + */ + +#define DIVISOR_FROM_US(x) ((x) << 3) + +/* Global data related to our fiq source */ +static uint32_t gta02_fiq_ack_mask; +static const int gta02_gta02_fiq_timer_id = 2; + +struct pwm_device* gta02_fiq_timer; + +void gta02_fiq_handler(void) +{ + unsigned long intmask; + int keep_running = 0; + /* disable further timer interrupts if nobody has any work + * or adjust rate according to who still has work + * + * CAUTION: it means forground code must disable FIQ around + * its own non-atomic S3C2410_INTMSK changes... not common + * thankfully and taken care of by the fiq-basis patch + */ + + if (!keep_running) { + /* Disable irq */ + intmask = __raw_readl(S3C2410_INTMSK); + intmask |= (gta02_fiq_ack_mask); + __raw_writel(intmask, S3C2410_INTMSK); + } + + __raw_writel(gta02_fiq_ack_mask, S3C2410_SRCPND); +} + +void gta02_fiq_kick(void) +{ + unsigned long flags; + unsigned long intmask; + /* we have to take care about FIQ because this modification is + * non-atomic, FIQ could come in after the read and before the + * writeback and its changes to the register would be lost + * (platform INTMSK mod code is taken care of already) + */ + local_save_flags(flags); + local_fiq_disable(); + + /* allow FIQs to resume */ + intmask = __raw_readl(S3C2410_INTMSK); + intmask &= ~(gta02_fiq_ack_mask); + __raw_writel(intmask, S3C2410_INTMSK); + + local_irq_restore(flags); + +} + +int gta02_fiq_enable(void) +{ + int ret = 0; + + local_fiq_disable(); + + gta02_fiq_timer = pwm_request(gta02_gta02_fiq_timer_id, "fiq timer"); + + if (IS_ERR(gta02_fiq_timer)) { + ret = PTR_ERR(gta02_fiq_timer); + printk("GTA02 FIQ: Could not request fiq timer: %d\n", ret); + return ret; + } + + gta02_fiq_ack_mask = 1 << (IRQ_TIMER0 + gta02_gta02_fiq_timer_id + - S3C2410_CPUIRQ_OFFSET); + + + ret = pwm_config(gta02_fiq_timer, HDQ_SAMPLE_PERIOD_US * 1000, + HDQ_SAMPLE_PERIOD_US * 1000); + if (ret) { + printk("GTA02 FIQ: Could not configure fiq timer: %d\n", ret); + goto err; + } + + set_fiq_c_handler(gta02_fiq_handler); + + __raw_writel(gta02_fiq_ack_mask, S3C2410_INTMOD); + + pwm_enable(gta02_fiq_timer); + + local_fiq_enable(); + + return 0; + +err: + pwm_free(gta02_fiq_timer); + + return ret; +} + +void gta02_fiq_disable(void) +{ + local_fiq_disable(); + + if (!gta02_fiq_timer) + return; + + __raw_writel(0, S3C2410_INTMOD); + set_fiq_c_handler(NULL); + + pwm_disable(gta02_fiq_timer); + + pwm_free(gta02_fiq_timer); + + gta02_fiq_timer = NULL; +} +/* -------------------- /GTA02 FIQ Handler ------------------------------------- */ diff --git a/arch/arm/mach-s3c2442/include/mach/gta02-fiq.h b/arch/arm/mach-s3c2442/include/mach/gta02-fiq.h new file mode 100644 index 00000000000..90de3530595 --- /dev/null +++ b/arch/arm/mach-s3c2442/include/mach/gta02-fiq.h @@ -0,0 +1,9 @@ +#ifndef __GTA02_FIQ_H +#define __GTA02_FIQ_H + +extern void gta02_fiq_handler(void); +extern void gta02_fiq_kick(void); +extern int gta02_fiq_enable(void); +extern void gta02_fiq_disable(void); + +#endif diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index eb4e215f473..d347f3724bb 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -92,7 +92,9 @@ #include #include -static struct pcf50633 *gta02_pcf; +#include + +struct pcf50633 *gta02_pcf; /* * This gets called every 1ms when we paniced. @@ -529,12 +531,6 @@ static struct platform_device gta02_nor_flash = { .num_resources = 1, }; - -struct platform_device s3c24xx_pwm_device = { - .name = "s3c24xx_pwm", - .num_resources = 0, -}; - static struct i2c_board_info gta02_i2c_devs[] __initdata = { { I2C_BOARD_INFO("pcf50633", 0x73), @@ -721,7 +717,7 @@ static struct platform_device *gta02_devices[] __initdata = { &s3c_device_usbgadget, &s3c_device_nand, >a02_nor_flash, - &s3c24xx_pwm_device, + &s3c_device_timer, &s3c_device_iis, &s3c_device_i2c0, }; -- cgit v1.2.3 From 6b03698306920fa048cd57b998e3e7e52278f814 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 5 Oct 2009 15:18:43 +0200 Subject: gta02: Add battery driver --- arch/arm/mach-s3c2442/gta02-fiq.c | 9 ++++ arch/arm/mach-s3c2442/mach-gta02.c | 100 ++++++++++++++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/gta02-fiq.c b/arch/arm/mach-s3c2442/gta02-fiq.c index 78a6501d5be..d91c52341d5 100644 --- a/arch/arm/mach-s3c2442/gta02-fiq.c +++ b/arch/arm/mach-s3c2442/gta02-fiq.c @@ -7,6 +7,7 @@ #include #include #include +#include /* ------------------------------------------------------------------------------- * GTA02 FIQ related @@ -17,6 +18,11 @@ #define DIVISOR_FROM_US(x) ((x) << 3) +#ifdef CONFIG_HDQ_GPIO_BITBANG +#define FIQ_DIVISOR_HDQ DIVISOR_FROM_US(HDQ_SAMPLE_PERIOD_US) +extern int hdq_fiq_handler(void); +#endif + /* Global data related to our fiq source */ static uint32_t gta02_fiq_ack_mask; static const int gta02_gta02_fiq_timer_id = 2; @@ -35,6 +41,9 @@ void gta02_fiq_handler(void) * thankfully and taken care of by the fiq-basis patch */ +#ifdef CONFIG_HDQ_GPIO_BITBANG + keep_running = hdq_fiq_handler(); +#endif if (!keep_running) { /* Disable irq */ intmask = __raw_readl(S3C2410_INTMSK); diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index d347f3724bb..422ac20d5c1 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -94,6 +94,9 @@ #include +#include +#include + struct pcf50633 *gta02_pcf; /* @@ -286,6 +289,20 @@ static struct platform_device gta02_glamo_dev = { #define ADC_NOM_CHG_DETECT_1A 6 #define ADC_NOM_CHG_DETECT_USB 43 +static int gta02_get_charger_online_status(void) +{ + struct pcf50633 *pcf = gta02_pcf; + + return pcf50633_mbc_get_status(pcf) & PCF50633_MBC_USB_ONLINE; +} + +static int gta02_get_charger_active_status(void) +{ + struct pcf50633 *pcf = gta02_pcf; + + return pcf50633_mbc_get_status(pcf) & PCF50633_MBC_USB_ACTIVE; +} + static void gta02_configure_pmu_for_charger(struct pcf50633 *pcf, void *unused, int res) { @@ -362,6 +379,8 @@ static void gta02_udc_vbus_draw(unsigned int ma) #else /* !CONFIG_CHARGER_PCF50633 */ #define gta02_pmu_event_callback NULL #define gta02_udc_vbus_draw NULL +#define gta02_get_charger_online_status NULL +#define gta02_get_charger_active_status NULL #endif /* @@ -700,6 +719,84 @@ static struct spi_board_info gta02_spi_board_info[] = { }, }; +/* BQ27000 Battery */ + +struct bq27000_platform_data bq27000_pdata = { + .name = "battery", + .rsense_mohms = 20, + .hdq_read = hdq_read, + .hdq_write = hdq_write, + .hdq_initialized = hdq_initialized, + .get_charger_online_status = gta02_get_charger_online_status, + .get_charger_active_status = gta02_get_charger_active_status +}; + +struct platform_device bq27000_battery_device = { + .name = "bq27000-battery", + .dev = { + .platform_data = &bq27000_pdata, + }, +}; + +/* HDQ */ + +static void gta02_hdq_attach_child_devices(struct device *parent_device) +{ + bq27000_battery_device.dev.parent = parent_device; + platform_device_register(&bq27000_battery_device); +} + +static void gta02_hdq_gpio_direction_out(void) +{ + s3c2410_gpio_cfgpin(GTA02v5_GPIO_HDQ, S3C2410_GPIO_OUTPUT); +} + +static void gta02_hdq_gpio_direction_in(void) +{ + s3c2410_gpio_cfgpin(GTA02v5_GPIO_HDQ, S3C2410_GPIO_INPUT); +} + +static void gta02_hdq_gpio_set_value(int val) +{ + + s3c2410_gpio_setpin(GTA02v5_GPIO_HDQ, val); +} + +static int gta02_hdq_gpio_get_value(void) +{ + return s3c2410_gpio_getpin(GTA02v5_GPIO_HDQ); +} + +static struct resource gta02_hdq_resources[] = { + [0] = { + .start = GTA02v5_GPIO_HDQ, + .end = GTA02v5_GPIO_HDQ, + }, +}; + +struct hdq_platform_data gta02_hdq_platform_data = { + .attach_child_devices = gta02_hdq_attach_child_devices, + .gpio_dir_out = gta02_hdq_gpio_direction_out, + .gpio_dir_in = gta02_hdq_gpio_direction_in, + .gpio_set = gta02_hdq_gpio_set_value, + .gpio_get = gta02_hdq_gpio_get_value, + + .enable_fiq = gta02_fiq_enable, + .disable_fiq = gta02_fiq_disable, + .kick_fiq = gta02_fiq_kick, + +}; + +struct platform_device gta02_hdq_device = { + .name = "hdq", + .num_resources = 1, + .resource = gta02_hdq_resources, + .dev = { + .platform_data = >a02_hdq_platform_data, + .parent = &s3c_device_timer[2].dev, + }, +}; + static void __init gta02_map_io(void) { s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc)); @@ -717,7 +814,6 @@ static struct platform_device *gta02_devices[] __initdata = { &s3c_device_usbgadget, &s3c_device_nand, >a02_nor_flash, - &s3c_device_timer, &s3c_device_iis, &s3c_device_i2c0, }; @@ -726,6 +822,8 @@ static struct platform_device *gta02_devices[] __initdata = { static struct platform_device *gta02_devices_pmu_children[] = { >a02_glamo_dev, + &s3c_device_timer[2], + >a02_hdq_device, }; -- cgit v1.2.3 From 4a9d021ec3cfdc82aabda330b62faacec7456ad8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 5 Oct 2009 17:03:59 +0200 Subject: gta02: Add power supply consumers. --- arch/arm/mach-s3c2442/mach-gta02.c | 54 +++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index 422ac20d5c1..ffb7d74eb80 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -277,6 +277,22 @@ static struct platform_device gta02_glamo_dev = { }, }; +static struct platform_device gta02_pm_gps_dev = { + .name = "gta02-pm-gps", +}; + +static struct platform_device gta02_pm_bt_dev = { + .name = "gta02-pm-bt", +}; + +static struct platform_device gta02_pm_gsm_dev = { + .name = "gta02-pm-gsm", +}; + +static struct platform_device gta02_pm_wlan_dev = { + .name = "gta02-pm-wlan", +}; + #ifdef CONFIG_CHARGER_PCF50633 /* * On GTA02 the 1A charger features a 48K resistor to 0V on the ID pin. @@ -398,6 +414,32 @@ static char *gta02_batteries[] = { "battery", }; +static struct regulator_consumer_supply ldo4_consumers[] = { + { + .dev = >a02_pm_bt_dev.dev, + .supply = "BT_3V2", + }, +}; + +static struct regulator_consumer_supply ldo5_consumers[] = { + { + .dev = >a02_pm_gps_dev.dev, + .supply = "RF_3V", + }, +}; + +static struct regulator_consumer_supply hcldo_consumers[] = { + { + .dev = >a02_glamo_dev.dev, + .supply = "SD_3V3", + }, +}; + +static struct regulator_consumer_supply ldo6_consumers[] = { + REGULATOR_SUPPLY("VDC", "spi2.0"), + REGULATOR_SUPPLY("VDDIO", "spi2.0"), +}; + struct pcf50633_platform_data gta02_pcf_pdata = { .resumers = { [0] = PCF50633_INT1_USBINS | @@ -454,6 +496,8 @@ struct pcf50633_platform_data gta02_pcf_pdata = { .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, .always_on = 1, }, + .num_consumer_supplies = ARRAY_SIZE(hcldo_consumers), + .consumer_supplies = hcldo_consumers, }, [PCF50633_REGULATOR_LDO1] = { .constraints = { @@ -489,6 +533,8 @@ struct pcf50633_platform_data gta02_pcf_pdata = { .valid_modes_mask = REGULATOR_MODE_NORMAL, .apply_uV = 1, }, + .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers), + .consumer_supplies = ldo4_consumers, }, [PCF50633_REGULATOR_LDO5] = { .constraints = { @@ -500,6 +546,8 @@ struct pcf50633_platform_data gta02_pcf_pdata = { .enabled = 1, }, }, + .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers), + .consumer_supplies = ldo5_consumers, }, [PCF50633_REGULATOR_LDO6] = { .constraints = { @@ -507,6 +555,8 @@ struct pcf50633_platform_data gta02_pcf_pdata = { .max_uV = 3000000, .valid_modes_mask = REGULATOR_MODE_NORMAL, }, + .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers), + .consumer_supplies = ldo6_consumers, }, [PCF50633_REGULATOR_MEMLDO] = { .constraints = { @@ -613,8 +663,6 @@ static struct s3c2410_udc_mach_info gta02_udc_cfg = { }; - - static void gta02_bl_set_intensity(int intensity) { struct pcf50633 *pcf = gta02_pcf; @@ -676,8 +724,6 @@ static struct platform_device gta02_bl_dev = { }, }; - - /* USB */ static struct s3c2410_hcd_info gta02_usb_info = { .port[0] = { -- cgit v1.2.3 From 8dc7666782641befc39d9fa7e32e94b00f8c814d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 8 Oct 2009 20:38:19 +0200 Subject: gta02: Set pcf50633 chg_ref_current_ma --- arch/arm/mach-s3c2442/mach-gta02.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index ffb7d74eb80..9dac71f3675 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -454,6 +454,9 @@ struct pcf50633_platform_data gta02_pcf_pdata = { .batteries = gta02_batteries, .num_batteries = ARRAY_SIZE(gta02_batteries), + + .chg_ref_current_ma = 1000, + .reg_init_data = { [PCF50633_REGULATOR_AUTO] = { .constraints = { -- cgit v1.2.3 From 0f4f116ade2cd15660157ac21ef55448c7349766 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 11 Oct 2009 01:27:33 +0200 Subject: gta02: Add glamo mfd irq base to glamo resources ... and remove unused reset pin resource. --- arch/arm/mach-s3c2442/mach-gta02.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index 9dac71f3675..b3fbc696d89 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -263,8 +263,8 @@ static struct resource gta02_glamo_resources[] = { .flags = IORESOURCE_IRQ, }, [2] = { - .start = GTA02_GPIO_3D_RESET, - .end = GTA02_GPIO_3D_RESET, + .start = S3C2410_BOARD_IRQ_START, + .flags = IORESOURCE_IRQ, }, }; -- cgit v1.2.3 From c8490f9e736a7c0f697c83f17aee161d0241172c Mon Sep 17 00:00:00 2001 From: Nelson Castillo Date: Sat, 24 Oct 2009 03:04:47 -0500 Subject: Add touchscreen device. Signed-off-by: Nelson Castillo --- arch/arm/mach-s3c2442/mach-gta02.c | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index b3fbc696d89..b5c4b9fa0cb 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -97,6 +97,15 @@ #include #include +#include +#include +#ifdef CONFIG_TOUCHSCREEN_FILTER +#include +#include +#include +#include +#endif + struct pcf50633 *gta02_pcf; /* @@ -666,6 +675,52 @@ static struct s3c2410_udc_mach_info gta02_udc_cfg = { }; +/* Touchscreen configuration. */ + +#ifdef CONFIG_TOUCHSCREEN_FILTER +const static struct ts_filter_group_configuration gta02_ts_group = { + .length = 12, + .close_enough = 10, + .threshold = 6, /* At least half of the points in a group. */ + .attempts = 10, +}; + +const static struct ts_filter_median_configuration gta02_ts_median = { + .extent = 20, + .decimation_below = 3, + .decimation_threshold = 8 * 3, + .decimation_above = 4, +}; + +const static struct ts_filter_mean_configuration gta02_ts_mean = { + .length = 4, +}; + +const static struct ts_filter_linear_configuration gta02_ts_linear = { + .constants = {1, 0, 0, 0, 1, 0, 1}, /* Don't modify coords. */ + .coord0 = 0, + .coord1 = 1, +}; +#endif + +const static struct ts_filter_chain_configuration gta02_filter_configuration[] = +{ +#ifdef CONFIG_TOUCHSCREEN_FILTER + {&ts_filter_group_api, >a02_ts_group.config}, + {&ts_filter_median_api, >a02_ts_median.config}, + {&ts_filter_mean_api, >a02_ts_mean.config}, + {&ts_filter_linear_api, >a02_ts_linear.config}, +#endif + {NULL, NULL}, +}; + +const static struct s3c2410_ts_mach_info gta02_ts_cfg = { + .delay = 10000, + .presc = 0xff, /* slow as we can go */ + .filter_config = gta02_filter_configuration, +}; + + static void gta02_bl_set_intensity(int intensity) { struct pcf50633 *pcf = gta02_pcf; @@ -865,11 +920,13 @@ static struct platform_device *gta02_devices[] __initdata = { >a02_nor_flash, &s3c_device_iis, &s3c_device_i2c0, + &s3c_device_adc, }; /* These guys DO need to be children of PMU. */ static struct platform_device *gta02_devices_pmu_children[] = { + &s3c_device_ts, >a02_glamo_dev, &s3c_device_timer[2], >a02_hdq_device, @@ -921,6 +978,7 @@ static void __init gta02_machine_init(void) s3c24xx_udc_set_platdata(>a02_udc_cfg); s3c_i2c0_set_platdata(NULL); + set_s3c2410ts_info(>a02_ts_cfg); i2c_register_board_info(0, gta02_i2c_devs, ARRAY_SIZE(gta02_i2c_devs)); spi_register_board_info(gta02_spi_board_info, -- cgit v1.2.3 From cde58393059fceb4ef8b74a10ce6576d5f9c6410 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 2 Nov 2009 21:49:23 +0100 Subject: gta02: Replace platform backlight driver with pcf50633-backlight. --- arch/arm/mach-s3c2442/mach-gta02.c | 81 +++++--------------------------------- 1 file changed, 10 insertions(+), 71 deletions(-) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index b5c4b9fa0cb..2f78da28bcb 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -50,7 +50,6 @@ #include #include -#include #include #include @@ -58,6 +57,7 @@ #include #include #include +#include #include #include @@ -449,6 +449,12 @@ static struct regulator_consumer_supply ldo6_consumers[] = { REGULATOR_SUPPLY("VDDIO", "spi2.0"), }; +static struct pcf50633_bl_platform_data gta02_backlight_data = { + .default_brightness = 0x3f, + .default_brightness_limit = 0, + .ramp_time = 3, +}; + struct pcf50633_platform_data gta02_pcf_pdata = { .resumers = { [0] = PCF50633_INT1_USBINS | @@ -466,6 +472,8 @@ struct pcf50633_platform_data gta02_pcf_pdata = { .chg_ref_current_ma = 1000, + .backlight_data = >a02_backlight_data, + .reg_init_data = { [PCF50633_REGULATOR_AUTO] = { .constraints = { @@ -721,67 +729,6 @@ const static struct s3c2410_ts_mach_info gta02_ts_cfg = { }; -static void gta02_bl_set_intensity(int intensity) -{ - struct pcf50633 *pcf = gta02_pcf; - int old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT); - - /* We map 8-bit intensity to 6-bit intensity in hardware. */ - intensity >>= 2; - - /* - * This can happen during, eg, print of panic on blanked console, - * but we can't service i2c without interrupts active, so abort. - */ - if (in_atomic()) { - printk(KERN_ERR "gta02_bl_set_intensity called while atomic\n"); - return; - } - - old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT); - if (intensity == old_intensity) - return; - - /* We can't do this anywhere else. */ - pcf50633_reg_write(pcf, PCF50633_REG_LEDDIM, 5); - - if (!(pcf50633_reg_read(pcf, PCF50633_REG_LEDENA) & 3)) - old_intensity = 0; - - /* - * The PCF50633 cannot handle LEDOUT = 0 (datasheet p60) - * if seen, you have to re-enable the LED unit. - */ - if (!intensity || !old_intensity) - pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0); - - /* Illegal to set LEDOUT to 0. */ - if (!intensity) - pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, 2); - else - pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, - intensity); - - if (intensity) - pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 2); - -} - -static struct generic_bl_info gta02_bl_info = { - .name = "gta02-bl", - .max_intensity = 0xff, - .default_intensity = 0xff, - .set_bl_intensity = gta02_bl_set_intensity, -}; - -static struct platform_device gta02_bl_dev = { - .name = "generic-bl", - .id = 1, - .dev = { - .platform_data = >a02_bl_info, - }, -}; - /* USB */ static struct s3c2410_hcd_info gta02_usb_info = { .port[0] = { @@ -795,15 +742,7 @@ static struct s3c2410_hcd_info gta02_usb_info = { /* JBT6k74 display controller */ static void gta02_jbt6k74_probe_completed(struct device *dev) { - struct pcf50633 *pcf = gta02_pcf; - /* Switch on backlight. Qi does not do it for us */ - pcf50633_reg_write(pcf, PCF50633_REG_LEDOUT, 0x01); - pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0x00); - pcf50633_reg_write(pcf, PCF50633_REG_LEDDIM, 0x01); - pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0x01); - - gta02_bl_dev.dev.parent = dev; - platform_device_register(>a02_bl_dev); + pcf50633_bl_set_brightness_limit(gta02_pcf, 0x3f); } const struct jbt6k74_platform_data jbt6k74_pdata = { -- cgit v1.2.3 From b9943538bfbb6f99bfc08e744896d7593318b07b Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Wed, 4 Nov 2009 14:27:52 +0300 Subject: gta02: add support for platform_battery This adds support for platform_battery driver which allows to specify a set of power supply properties and callbacks to acquire them. It is needed to support dumb batteries where all the information about their status can only be obtained by platform-specific actions such as specific ADC measurements, some guessimation etc. Signed-off-by: Paul Fertser --- arch/arm/mach-s3c2442/mach-gta02.c | 113 +++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index 2f78da28bcb..888e52eb81a 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -97,6 +97,8 @@ #include #include +#include + #include #include #ifdef CONFIG_TOUCHSCREEN_FILTER @@ -781,6 +783,117 @@ struct platform_device bq27000_battery_device = { }, }; +/* Platform battery */ + +/* Capacity of a typical BL-5C dumb battery */ +#define GTA02_BAT_CHARGE_FULL 850000 + +static int gta02_bat_voltscale(int volt) +{ + /* This table is suggested by SpeedEvil based on analysis of + * experimental data */ + static const int lut[][2] = { + { 4120, 100 }, + { 3900, 60 }, + { 3740, 25 }, + { 3600, 5 }, + { 3000, 0 } }; + int i, res = 0; + + if (volt > lut[0][0]) + res = lut[0][1]; + else + for (i = 0; lut[i][1]; i++) { + if (volt <= lut[i][0] && volt >= lut[i+1][0]) { + res = lut[i][1] - (lut[i][0]-volt)* + (lut[i][1]-lut[i+1][1])/ + (lut[i][0]-lut[i+1][0]); + break; + } + } + return res; +} + +static int gta02_bat_get_voltage(void) +{ + struct pcf50633 *pcf = gta02_pcf; + u16 adc, mv = 0; + adc = pcf50633_adc_sync_read(pcf, + PCF50633_ADCC1_MUX_BATSNS_RES, + PCF50633_ADCC1_AVERAGE_16); + /* The formula from DS is for divide-by-two mode, current driver uses + divide-by-three */ + mv = (adc * 6000) / 1023; + return mv * 1000; +} + +static int gta02_bat_get_present(void) +{ + /* There is no reliable way to tell if it is present or not */ + return 1; +} + +static int gta02_bat_get_status(void) +{ +#ifdef CONFIG_CHARGER_PCF50633 + if (gta02_get_charger_active_status()) + return POWER_SUPPLY_STATUS_CHARGING; + else + return POWER_SUPPLY_STATUS_DISCHARGING; +#else + return POWER_SUPPLY_STATUS_UNKNOWN; +#endif +} + +static int gta02_bat_get_capacity(void) +{ + return gta02_bat_voltscale(gta02_bat_get_voltage()/1000); +} + +static int gta02_bat_get_charge_full(void) +{ + return GTA02_BAT_CHARGE_FULL; +} + +static int gta02_bat_get_charge_now(void) +{ + return gta02_bat_get_capacity() * gta02_bat_get_charge_full() / 100; +} + +static enum power_supply_property gta02_platform_bat_properties[] = { + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_VOLTAGE_NOW, + POWER_SUPPLY_PROP_CAPACITY, + POWER_SUPPLY_PROP_CHARGE_FULL, + POWER_SUPPLY_PROP_CHARGE_NOW, +}; + +int (*gta02_platform_bat_get_property[])(void) = { + gta02_bat_get_present, + gta02_bat_get_status, + gta02_bat_get_voltage, + gta02_bat_get_capacity, + gta02_bat_get_charge_full, + gta02_bat_get_charge_now, +}; + +static struct platform_bat_platform_data gta02_platform_bat_pdata = { + .name = "battery", + .properties = gta02_platform_bat_properties, + .num_properties = ARRAY_SIZE(gta02_platform_bat_properties), + .get_property = gta02_platform_bat_get_property, + .is_present = gta02_bat_get_present, +}; + +struct platform_device gta02_platform_bat = { + .name = "platform_battery", + .id = -1, + .dev = { + .platform_data = >a02_platform_bat_pdata, + } +}; + /* HDQ */ static void gta02_hdq_attach_child_devices(struct device *parent_device) -- cgit v1.2.3