aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-s3c2440
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2009-10-05 15:18:43 +0200
committerLars-Peter Clausen <lars@metafoo.de>2010-05-18 00:53:34 +0200
commit6fbc374d90032ad76f6fd3556514e18bed573088 (patch)
tree45c69772b8b53f19031eb9599c4d75d1d3bc9d06 /arch/arm/mach-s3c2440
parent487349e69fa5737e9370c889acc350890a25c10b (diff)
gta02: Add battery driver
Diffstat (limited to 'arch/arm/mach-s3c2440')
-rw-r--r--arch/arm/mach-s3c2440/gta02-fiq.c9
-rw-r--r--arch/arm/mach-s3c2440/mach-gta02.c91
2 files changed, 100 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c2440/gta02-fiq.c b/arch/arm/mach-s3c2440/gta02-fiq.c
index 78a6501d5be..d91c52341d5 100644
--- a/arch/arm/mach-s3c2440/gta02-fiq.c
+++ b/arch/arm/mach-s3c2440/gta02-fiq.c
@@ -7,6 +7,7 @@
#include <linux/io.h>
#include <linux/pwm.h>
#include <linux/err.h>
+#include <linux/hdq.h>
/* -------------------------------------------------------------------------------
* 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-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index be8782b80e5..3f1da153bd2 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -103,6 +103,9 @@
#include <mach/gta02-fiq.h>
+#include <linux/hdq.h>
+#include <linux/bq27000_battery.h>
+
#include <linux/jbt6k74.h>
#include <linux/glamofb.h>
#include <linux/mfd/glamo.h>
@@ -369,6 +372,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)
{
@@ -437,6 +454,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
/*
@@ -869,6 +888,67 @@ static struct platform_device gta02_pwm_leds_device = {
}
};
+/* 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_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);
+}
+
+struct hdq_platform_data gta02_hdq_platform_data = {
+ .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",
+ .id = -1,
+ .dev = {
+ .platform_data = &gta02_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));
@@ -906,6 +986,7 @@ static struct platform_device *gta02_devices[] __initdata = {
/* These guys DO need to be children of PMU. */
static struct platform_device *gta02_devices_pmu_children[] = {
+ &gta02_hdq_device,
};
/*
@@ -952,6 +1033,11 @@ static struct platform_device* gta02_gsm_supply_children[] = {
&gta02_pm_gsm_dev,
};
+static struct platform_device* gta02_hdq_children[] = {
+ &bq27000_battery_device,
+};
+
+
static struct gta02_device_children gta02_device_children[] = {
{
.dev_name = "pcf50633-gpio",
@@ -967,6 +1053,11 @@ static struct gta02_device_children gta02_device_children[] = {
.dev_name = "spi2.0",
.probed_callback = gta02_jbt6k74_probe_completed,
},
+ {
+ .dev_name = "hdq",
+ .num_children = 1,
+ .children = gta02_hdq_children,
+ },
};
static int gta02_add_child_devices(struct device *parent,