From 28c1eda203c40eb2abe452c83c2f62ddcee0a3f5 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 | 11 +++++ arch/arm/mach-s3c2442/mach-gta02.c | 98 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) (limited to 'arch') diff --git a/arch/arm/mach-s3c2442/gta02-fiq.c b/arch/arm/mach-s3c2442/gta02-fiq.c index 436e7448e23..d2c825c17ad 100644 --- a/arch/arm/mach-s3c2442/gta02-fiq.c +++ b/arch/arm/mach-s3c2442/gta02-fiq.c @@ -5,6 +5,7 @@ #include #include #include +#include /* ------------------------------------------------------------------------------- * GTA02 FIQ related @@ -15,6 +16,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 struct s3c2410_pwm gta02_fiq_pwm_timer; @@ -33,6 +39,11 @@ void gta02_fiq_handler(void) * thankfully and taken care of by the fiq-basis patch */ +#ifdef CONFIG_HDQ_GPIO_BITBANG + if (hdq_fiq_handler()) + divisor = FIQ_DIVISOR_HDQ; +#endif + if (divisor == 0xffff) /* mask the fiq irq source */ __raw_writel(__raw_readl(S3C2410_INTMSK) | gta02_fiq_ack_mask, S3C2410_INTMSK); diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index 00c18b17af3..2df92e8e071 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -103,6 +103,9 @@ #include +#include +#include + struct pcf50633 *gta02_pcf; /* @@ -295,6 +298,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) { @@ -371,6 +388,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 /* @@ -791,6 +810,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 = &s3c24xx_pwm_device.dev, + }, +}; + static void __init gta02_map_io(void) { s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc)); @@ -823,6 +920,7 @@ static struct platform_device *gta02_devices[] __initdata = { static struct platform_device *gta02_devices_pmu_children[] = { >a02_glamo_dev, + >a02_hdq_device, }; -- cgit v1.2.3