r1597 - trunk/src/target/kernel/patches
laforge at sita.openmoko.org
laforge at sita.openmoko.org
Sun Apr 1 13:09:09 CEST 2007
Author: laforge
Date: 2007-04-01 13:09:09 +0200 (Sun, 01 Apr 2007)
New Revision: 1597
Modified:
trunk/src/target/kernel/patches/gta01-core.patch
trunk/src/target/kernel/patches/gta01-pcf50606.patch
Log:
* add a callback to the pcf50606 platform data
* call that callback whenever accessory detection is hit
* implement this callback in gta01 to enable/disable fast charge in >= GTA01Bv4
* some further code cleanup of pcf50606
Modified: trunk/src/target/kernel/patches/gta01-core.patch
===================================================================
--- trunk/src/target/kernel/patches/gta01-core.patch 2007-04-01 10:58:55 UTC (rev 1596)
+++ trunk/src/target/kernel/patches/gta01-core.patch 2007-04-01 11:09:09 UTC (rev 1597)
@@ -4,7 +4,7 @@
Index: linux-2.6.20.4/arch/arm/mach-s3c2410/Kconfig
===================================================================
--- linux-2.6.20.4.orig/arch/arm/mach-s3c2410/Kconfig 2007-04-01 10:27:56.000000000 +0200
-+++ linux-2.6.20.4/arch/arm/mach-s3c2410/Kconfig 2007-04-01 10:48:06.000000000 +0200
++++ linux-2.6.20.4/arch/arm/mach-s3c2410/Kconfig 2007-04-01 12:33:02.000000000 +0200
@@ -86,6 +86,14 @@
help
Say Y here if you are using the Armzone QT2410
@@ -23,7 +23,7 @@
Index: linux-2.6.20.4/arch/arm/mach-s3c2410/Makefile
===================================================================
--- linux-2.6.20.4.orig/arch/arm/mach-s3c2410/Makefile 2007-04-01 10:27:56.000000000 +0200
-+++ linux-2.6.20.4/arch/arm/mach-s3c2410/Makefile 2007-04-01 10:48:05.000000000 +0200
++++ linux-2.6.20.4/arch/arm/mach-s3c2410/Makefile 2007-04-01 12:33:01.000000000 +0200
@@ -89,5 +89,6 @@
obj-$(CONFIG_MACH_NEXCODER_2440) += mach-nexcoder.o
obj-$(CONFIG_MACH_VSTMS) += mach-vstms.o
@@ -34,8 +34,8 @@
Index: linux-2.6.20.4/arch/arm/mach-s3c2410/mach-gta01.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.20.4/arch/arm/mach-s3c2410/mach-gta01.c 2007-04-01 10:48:17.000000000 +0200
-@@ -0,0 +1,681 @@
++++ linux-2.6.20.4/arch/arm/mach-s3c2410/mach-gta01.c 2007-04-01 12:36:42.000000000 +0200
+@@ -0,0 +1,706 @@
+/*
+ * linux/arch/arm/mach-s3c2410/mach-gta01.c
+ *
@@ -141,6 +141,29 @@
+
+/* PMU driver info */
+
++static int pmu_callback(struct device *dev, unsigned int feature,
++ enum pmu_event event)
++{
++ switch (feature) {
++ case PCF50606_FEAT_ACD:
++ switch (event) {
++ case PMU_EVT_INSERT:
++ pcf50606_charge_fast(pcf50606_global, 1);
++ break;
++ case PMU_EVT_REMOVE:
++ pcf50606_charge_fast(pcf50606_global, 0);
++ break;
++ default:
++ break;
++ }
++ break;
++ default:
++ break;
++ }
++
++ return 0;
++}
++
+static struct pcf50606_platform_data gta01_pcf_pdata = {
+ .used_features = PCF50606_FEAT_EXTON |
+ PCF50606_FEAT_MBC |
@@ -151,6 +174,7 @@
+ PCF50606_FEAT_BATVOLT |
+ PCF50606_FEAT_BATTEMP,
+ .onkey_seconds_required = 5,
++ .cb = &pmu_callback,
+ .r_fix_batt = 10000,
+ .r_fix_batt_par = 10000,
+ .r_sense_milli = 220,
@@ -230,6 +254,7 @@
+{
+ switch (system_rev) {
+ case GTA01Bv4_SYSTEM_REV:
++ gta01_pcf_pdata.used_features |= PCF50606_FEAT_ACD;
+ break;
+ case GTA01Bv3_SYSTEM_REV:
+ case GTA01Bv2_SYSTEM_REV:
Modified: trunk/src/target/kernel/patches/gta01-pcf50606.patch
===================================================================
--- trunk/src/target/kernel/patches/gta01-pcf50606.patch 2007-04-01 10:58:55 UTC (rev 1596)
+++ trunk/src/target/kernel/patches/gta01-pcf50606.patch 2007-04-01 11:09:09 UTC (rev 1597)
@@ -3,8 +3,8 @@
Index: linux-2.6.20.4/drivers/i2c/chips/pcf50606.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.20.4/drivers/i2c/chips/pcf50606.c 2007-04-01 10:53:01.000000000 +0200
-@@ -0,0 +1,1863 @@
++++ linux-2.6.20.4/drivers/i2c/chips/pcf50606.c 2007-04-01 13:05:25.000000000 +0200
+@@ -0,0 +1,1896 @@
+/* Philips PCF50606 Power Management Unit (PMU) driver
+ *
+ * (C) 2006 by OpenMoko, Inc.
@@ -57,6 +57,7 @@
+#include <linux/pcf50606.h>
+
+#include <asm/apm.h>
++#include <asm/mach-types.h>
+#include <asm/arch/gta01.h>
+
+#include "pcf50606.h"
@@ -122,6 +123,8 @@
+#endif
+};
+
++static struct i2c_driver pcf50606_driver;
++
+struct pcf50606_data *pcf50606_global;
+EXPORT_SYMBOL(pcf50606_global);
+
@@ -630,6 +633,9 @@
+ input_report_key(pcf->input_dev, KEY_BATTERY, 1);
+ apm_queue_event(APM_POWER_STATUS_CHANGE);
+ pcf->flags |= PCF50606_F_CHG_PRESENT;
++ if (pcf->pdata->cb)
++ pcf->pdata->cb(&pcf->client.dev,
++ PCF50606_FEAT_MBC, PMU_EVT_INSERT);
+ /* FIXME: signal this to userspace */
+ //kobject_uevent( ,KOBJ_ADD);
+ }
@@ -639,6 +645,9 @@
+ input_report_key(pcf->input_dev, KEY_BATTERY, 0);
+ apm_queue_event(APM_POWER_STATUS_CHANGE);
+ pcf->flags &= ~(PCF50606_F_CHG_MASK|PCF50606_F_CHG_PRESENT);
++ if (pcf->pdata->cb)
++ pcf->pdata->cb(&pcf->client.dev,
++ PCF50606_FEAT_MBC, PMU_EVT_INSERT);
+ /* FIXME: signal this to userspace */
+ //kobject_uevent( ,KOBJ_REMOVE);
+ }
@@ -685,7 +694,21 @@
+ /* ADC result ready */
+ DEBUGPC("ADCRDY ");
+ }
-+ /* FIXME: ACDINS, ACDREM, TSCPRES */
++ if (int3 & PCF50606_INT3_ACDINS) {
++ /* Accessory insertion detected */
++ DEBUGP("ACDINS ");
++ if (pcf->pdata->cb)
++ pcf->pdata->cb(&pcf->client.dev,
++ PCF50606_FEAT_ACD, PMU_EVT_INSERT);
++ }
++ if (int3 & PCF50606_INT3_ACDREM) {
++ /* Accessory removal detected */
++ DEBUGP("ACDREM ");
++ if (pcf->pdata->cb)
++ pcf->pdata->cb(&pcf->client.dev,
++ PCF50606_FEAT_ACD, PMU_EVT_REMOVE);
++ }
++ /* FIXME: TSCPRES */
+ if (int3 & PCF50606_INT3_LOWBAT) {
+ /* Really low battery voltage, we have 8 seconds left */
+ DEBUGPC("LOWBAT ");
@@ -1228,6 +1251,14 @@
+ return 0;
+}
+
++static struct rtc_class_ops pcf50606_rtc_ops = {
++ .ioctl = pcf50606_rtc_ioctl,
++ .read_time = pcf50606_rtc_read_time,
++ .set_time = pcf50606_rtc_set_time,
++ .read_alarm = pcf50606_rtc_read_alarm,
++ .set_alarm = pcf50606_rtc_set_alarm,
++};
++
+/***********************************************************************
+ * Watchdog
+ ***********************************************************************/
@@ -1342,16 +1373,6 @@
+ .fops = &pcf50606_wdt_fops,
+};
+
-+static struct i2c_driver pcf50606_driver;
-+
-+static struct rtc_class_ops pcf50606_rtc_ops = {
-+ .ioctl = pcf50606_rtc_ioctl,
-+ .read_time = pcf50606_rtc_read_time,
-+ .set_time = pcf50606_rtc_set_time,
-+ .read_alarm = pcf50606_rtc_read_alarm,
-+ .set_alarm = pcf50606_rtc_set_alarm,
-+};
-+
+/***********************************************************************
+ * PWM
+ ***********************************************************************/
@@ -1464,7 +1485,7 @@
+};
+
+/***********************************************************************
-+ * Input device
++ * Driver initialization
+ ***********************************************************************/
+
+#ifdef CONFIG_MACH_GTA01
@@ -1533,8 +1554,7 @@
+
+ DEBUGP("entering\n");
+ if (!pcf50606_pdev) {
-+ printk(KERN_ERR
-+ "pcf50606: this driver needs a platform_device!\n");
++ printk(KERN_ERR "pcf50606: driver needs a platform_device!\n");
+ return -EIO;
+ }
+
@@ -1546,8 +1566,8 @@
+
+ /* At the moment, we only support one PCF50606 in a system */
+ if (pcf50606_global) {
-+ printk(KERN_ERR
-+ "pcf50606: currently only one chip supported\n");
++ dev_err(&pcf50606_pdev->dev,
++ "currently only one chip supported\n");
+ return -EBUSY;
+ }
+
@@ -1572,7 +1592,8 @@
+
+ /* register with i2c core */
+ if ((err = i2c_attach_client(new_client))) {
-+ DEBUGP("error during i2c_attach_client()\n");
++ dev_err(&new_client->dev,
++ "error during i2c_attach_client()\n");
+ goto exit_free;
+ }
+
@@ -1604,8 +1625,8 @@
+ set_irq_type(irq, IRQT_FALLING);
+
+ if (enable_irq_wake(irq) < 0)
-+ printk(KERN_ERR "PCF50606: IRQ %u cannot be enabled as wake-up"
-+ "source in this hardware revision!", irq);
++ dev_err(&new_client->dev, "IRQ %u cannot be enabled as wake-up"
++ "source in this hardware revision!", irq);
+
+ if (data->pdata->used_features & PCF50606_FEAT_RTC) {
+ data->rtc = rtc_device_register("pcf50606", &new_client->dev,
@@ -1619,7 +1640,7 @@
+ if (data->pdata->used_features & PCF50606_FEAT_WDT) {
+ err = misc_register(&pcf50606_wdt_miscdev);
+ if (err) {
-+ printk(KERN_ERR "cannot register miscdev on \n"
++ dev_err(&new_client->dev, "cannot register miscdev on "
+ "minor=%d (%d)\n", WATCHDOG_MINOR, err);
+ goto exit_rtc;
+ }
@@ -1660,15 +1681,27 @@
+ apm_get_power_status = pcf50606_get_power_status;
+
+#ifdef CONFIG_MACH_GTA01
-+ gta01_pm_bt_dev.dev.parent = &new_client->dev;
-+ gta01_pm_gps_dev.dev.parent = &new_client->dev;
-+ if (system_rev == GTA01Bv2_SYSTEM_REV ||
-+ system_rev == GTA01Bv3_SYSTEM_REV)
-+ platform_device_register(>a01_pm_bt_dev);
-+
-+ platform_device_register(>a01_pm_gps_dev);
++ if (machine_is_gta01()) {
++ gta01_pm_gps_dev.dev.parent = &new_client->dev;
++ switch (system_rev) {
++ case GTA01Bv2_SYSTEM_REV:
++ case GTA01Bv3_SYSTEM_REV:
++ case GTA01Bv4_SYSTEM_REV:
++ gta01_pm_bt_dev.dev.parent = &new_client->dev;
++ platform_device_register(>a01_pm_bt_dev);
++ break;
++ }
++ platform_device_register(>a01_pm_gps_dev);
++ }
+#endif
+
++ if (data->pdata->used_features & PCF50606_FEAT_ACD)
++ reg_set_bit_mask(data, PCF50606_REG_ACDC1,
++ PCF50606_ACDC1_ACDAPE, PCF50606_ACDC1_ACDAPE);
++ else
++ reg_clear_bits(data, PCF50606_REG_ACDC1,
++ PCF50606_ACDC1_ACDAPE);
++
+ return 0;
+exit_pwm:
+ if (data->pdata->used_features & PCF50606_FEAT_PWM_BL)
@@ -1730,7 +1763,7 @@
+#ifdef CONFIG_PM
+#define INT1M_RESUMERS (PCF50606_INT1_ALARM|PCF50606_INT1_ONKEYF|PCF50606_INT1_EXTONR)
+#define INT2M_RESUMERS (PCF50606_INT2_CHGWD10S|PCF50606_INT2_CHGPROT|PCF50606_INT2_CHGERR)
-+#define INT3M_RESUMERS (PCF50606_INT3_LOWBAT|PCF50606_INT3_HIGHTMP)
++#define INT3M_RESUMERS (PCF50606_INT3_LOWBAT|PCF50606_INT3_HIGHTMP|PCF50606_INT3_ACDINS)
+static int pcf50606_suspend(struct device *dev, pm_message_t state)
+{
+ struct i2c_client *client = to_i2c_client(dev);
@@ -1871,8 +1904,8 @@
Index: linux-2.6.20.4/drivers/i2c/chips/pcf50606.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.20.4/drivers/i2c/chips/pcf50606.h 2007-03-30 22:07:41.000000000 +0200
-@@ -0,0 +1,288 @@
++++ linux-2.6.20.4/drivers/i2c/chips/pcf50606.h 2007-04-01 12:46:15.000000000 +0200
+@@ -0,0 +1,302 @@
+#ifndef _PCF50606_H
+#define _PCF50606_H
+
@@ -2117,6 +2150,20 @@
+ PCF50606_MBCC1_DETMOD_WDRST = 0x40,
+};
+
++enum pcf50606_reg_acdc1 {
++ PCF50606_ACDC1_ACDDET = 0x01,
++ PCF50606_ACDC1_THRSHLD_1V0 = 0x00,
++ PCF50606_ACDC1_THRSHLD_1V2 = 0x02,
++ PCF50606_ACDC1_THRSHLD_1V4 = 0x04,
++ PCF50606_ACDC1_THRSHLD_1V6 = 0x06,
++ PCF50606_ACDC1_THRSHLD_1V8 = 0x08,
++ PCF50606_ACDC1_THRSHLD_2V0 = 0x0a,
++ PCF50606_ACDC1_THRSHLD_2V2 = 0x0c,
++ PCF50606_ACDC1_THRSHLD_2V4 = 0x0e,
++ PCF50606_ACDC1_DISDB = 0x10,
++ PCF50606_ACDC1_ACDAPE = 0x80,
++};
++
+enum pcf50606_reg_bvmc {
+ PCF50606_BVMC_LOWBAT = 0x01,
+ PCF50606_BVMC_THRSHLD_NULL = 0x00,
@@ -2210,8 +2257,8 @@
Index: linux-2.6.20.4/include/linux/pcf50606.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.20.4/include/linux/pcf50606.h 2007-03-31 22:22:35.000000000 +0200
-@@ -0,0 +1,90 @@
++++ linux-2.6.20.4/include/linux/pcf50606.h 2007-04-01 13:01:16.000000000 +0200
+@@ -0,0 +1,101 @@
+#ifndef _LINUX_PCF50606_H
+#define _LINUX_PCF50606_H
+
@@ -2269,6 +2316,16 @@
+ } voltage;
+};
+
++enum pmu_event {
++ PMU_EVT_NONE,
++ PMU_EVT_INSERT,
++ PMU_EVT_REMOVE,
++ __NUM_PMU_EVTS
++};
++
++typedef int pmu_cb(struct device *dev, unsigned int feature,
++ enum pmu_event event);
++
+#define PCF50606_FEAT_EXTON 0x00000001 /* not yet supported */
+#define PCF50606_FEAT_MBC 0x00000002
+#define PCF50606_FEAT_BBC 0x00000004 /* not yet supported */
@@ -2299,6 +2356,7 @@
+ struct {
+ u_int8_t mbcc3; /* charger voltage / current */
+ } charger;
++ pmu_cb *cb;
+};
+
+#endif
More information about the commitlog
mailing list