Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r4052 - branches/src/target/kernel/2.6.24.x/patches
      ([EMAIL PROTECTED])
   2. r4053 - branches/src/target/kernel/2.6.24.x/patches
      ([EMAIL PROTECTED])
   3. r4054 - branches/src/target/kernel/2.6.24.x/patches
      ([EMAIL PROTECTED])
   4. r4055 - in branches/src/target/kernel/2.6.24.x: config
      patches ([EMAIL PROTECTED])
   5. r4056 - branches/src/target/kernel/2.6.24.x/patches
      ([EMAIL PROTECTED])
--- Begin Message ---
Author: werner
Date: 2008-02-12 23:58:05 +0100 (Tue, 12 Feb 2008)
New Revision: 4052

Modified:
   branches/src/target/kernel/2.6.24.x/patches/fiq-hdq.patch
Log:
[PATCH Try#2] introduce-fiq-hdq.patch

From: Andy Green <[EMAIL PROTECTED]>

fiq-hdq.patch:
- drivers/power/gta02_hdq.c: cleanup after review
- include/linux/gta02_hdq.h: added previously missing file



Modified: branches/src/target/kernel/2.6.24.x/patches/fiq-hdq.patch
===================================================================
--- branches/src/target/kernel/2.6.24.x/patches/fiq-hdq.patch   2008-02-11 
10:50:32 UTC (rev 4051)
+++ branches/src/target/kernel/2.6.24.x/patches/fiq-hdq.patch   2008-02-12 
22:58:05 UTC (rev 4052)
@@ -376,7 +376,7 @@
 +      int n;
 +      int v;
 +      u8 u8a[128]; /* whole address space for HDQ */
-+      char *buf1 = buf;
++      char *end = buf;
 +
 +      /* the dump does not take care about 16 bit regs, because at this
 +       * bus level we don't know about the chip details
@@ -385,16 +385,16 @@
 +              v = gta02hdq_read(n);
 +              if (v < 0)
 +                      goto bail;
-+              u8a[n] = (u8)v;
++              u8a[n] = v;
 +      }
 +
 +      for (n = 0; n < sizeof(u8a); n += 16) {
-+              hex_dump_to_buffer(u8a + n, sizeof(u8a), 16, 1, buf1, 4096, 0);
-+              buf1 += strlen(buf1);
-+              *buf1++ = '\n';
-+              *buf1 = '\0';
++              hex_dump_to_buffer(u8a + n, sizeof(u8a), 16, 1, end, 4096, 0);
++              end += strlen(end);
++              *end++ = '\n';
++              *end = '\0';
 +      }
-+      return (buf1 - buf);
++      return (end - buf);
 +
 +bail:
 +      return sprintf(buf, "ERROR %d\n", v);
@@ -408,19 +408,19 @@
 +                             struct device_attribute *attr,
 +                             const char *buf, size_t count)
 +{
-+      const char *buf1 = buf + count;
++      const char *end = buf + count;
 +      int address = atoi(buf);
 +
-+      while ((buf < buf1) && (*buf != ' '))
++      while ((buf != end) && (*buf != ' '))
 +              buf++;
-+      if (buf >= buf1)
++      if (buf >= end)
 +              return 0;
-+      while ((buf < buf1) && (*buf == ' '))
++      while ((buf < end) && (*buf == ' '))
 +              buf++;
-+      if (buf >= buf1)
++      if (buf >= end)
 +              return 0;
 +
-+      gta02hdq_write(address, (u8)atoi(buf));
++      gta02hdq_write(address, atoi(buf));
 +
 +      return count;
 +}
@@ -514,7 +514,7 @@
 +module_exit(gta02hdq_exit);
 +
 +MODULE_AUTHOR("Andy Green <[EMAIL PROTECTED]>");
-+MODULE_DESCRIPTION("FIC Neo1973 GTA02 HDQ driver");
++MODULE_DESCRIPTION("Neo Freerunner HDQ driver");
 +MODULE_LICENSE("GPL");
 Index: linux-2.6.24/include/asm-arm/arch-s3c2410/fiq_ipc_gta02.h
 ===================================================================
@@ -568,3 +568,16 @@
  
  #define GTA02_GPIO_nG1_INT    S3C2410_GPF0
  #define GTA02_GPIO_IO1                S3C2410_GPF1
+Index: linux-2.6.24/include/linux/gta02_hdq.h
+===================================================================
+--- /dev/null
++++ linux-2.6.24/include/linux/gta02_hdq.h
+@@ -0,0 +1,8 @@
++#ifndef __GTA02HDQ_H__
++#define __GTA02HDQ_H__
++
++int gta02hdq_read(int address);
++int gta02hdq_write(int address, u8 data);
++int gta02hdq_initialized(void);
++
++#endif




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2008-02-13 00:03:11 +0100 (Wed, 13 Feb 2008)
New Revision: 4053

Modified:
   branches/src/target/kernel/2.6.24.x/patches/fiq-hdq.patch
Log:
fiq-hdq.patch:
- drivers/power/gta02_hdq.c: changed platform name from "Neo Freerunner" to 
  "GTA02"



Modified: branches/src/target/kernel/2.6.24.x/patches/fiq-hdq.patch
===================================================================
--- branches/src/target/kernel/2.6.24.x/patches/fiq-hdq.patch   2008-02-12 
22:58:05 UTC (rev 4052)
+++ branches/src/target/kernel/2.6.24.x/patches/fiq-hdq.patch   2008-02-12 
23:03:11 UTC (rev 4053)
@@ -514,7 +514,7 @@
 +module_exit(gta02hdq_exit);
 +
 +MODULE_AUTHOR("Andy Green <[EMAIL PROTECTED]>");
-+MODULE_DESCRIPTION("Neo Freerunner HDQ driver");
++MODULE_DESCRIPTION("GTA02 HDQ driver");
 +MODULE_LICENSE("GPL");
 Index: linux-2.6.24/include/asm-arm/arch-s3c2410/fiq_ipc_gta02.h
 ===================================================================




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2008-02-13 00:40:22 +0100 (Wed, 13 Feb 2008)
New Revision: 4054

Added:
   branches/src/target/kernel/2.6.24.x/patches/bq27000-battery-driver.patch
Modified:
   branches/src/target/kernel/2.6.24.x/patches/series
Log:
introduce-bq27000-battery-driver.patch

From: Andy Green <[EMAIL PROTECTED]>

This is a driver for the bq27000 found in the Highcell A5
battery, and the platform device stuff for it for GTA02.  It
is a Power Supply Class battery device. 
      
The driver doesn't contain an HDQ engine but accepts pointers
from the platform data to the HDQ action routines; our
platform data plugs it into the FIQ HDQ engine stuff.
    
The Power Supply class exposes the battery down /sys so you
can find out battery status by doing the equivalent of this
bash command
    
for i in capacity charge_full current_now present status technology temp 
time_to_empty_now time_to_full_now type voltage_now ; do echo -n "$i    " ; cat 
/sys/devices/platform/bq27000-battery.0/power_supply/bat/$i ; done

Here is the kind of result you get from a battery discharging

capacity    0
charge_full    1215585
current_now    183375
present    1
status    Discharging
technology    Li-ion
temp    276
time_to_empty_now    0
time_to_full_now    3932100
type    Battery
voltage_now    2761000

Note that temp is in 1/10 degrees C, other values are in uV,
uA, uW.  The time_to_* reported are bogus, but that is what
the battery actually reports.

We can make more mappings to entries in power_supply class
but this is enough to get started with.

Signed-off-by: Andy Green <[EMAIL PROTECTED]>

---

 arch/arm/mach-s3c2440/mach-gta02.c |   21 ++
 defconfig-2.6.24                   |    1
 drivers/power/Kconfig              |    5
 drivers/power/Makefile             |    1
 drivers/power/bq27000_battery.c    |  375 ++++++++++++++++++++++++++++++++++++
 include/linux/bq27000_battery.h    |   12 +
 6 files changed, 415 insertions(+), 0 deletions(-)
 create mode 100644 drivers/power/bq27000_battery.c
 create mode 100644 include/linux/bq27000_battery.h



Added: branches/src/target/kernel/2.6.24.x/patches/bq27000-battery-driver.patch
===================================================================
--- branches/src/target/kernel/2.6.24.x/patches/bq27000-battery-driver.patch    
2008-02-12 23:03:11 UTC (rev 4053)
+++ branches/src/target/kernel/2.6.24.x/patches/bq27000-battery-driver.patch    
2008-02-12 23:40:22 UTC (rev 4054)
@@ -0,0 +1,470 @@
+Index: linux-2.6.24/arch/arm/mach-s3c2440/mach-gta02.c
+===================================================================
+--- linux-2.6.24.orig/arch/arm/mach-s3c2440/mach-gta02.c
++++ linux-2.6.24/arch/arm/mach-s3c2440/mach-gta02.c
+@@ -81,6 +81,8 @@
+ 
+ #include <asm/arch/fiq_ipc_gta02.h>
+ #include "fiq_c_isr.h"
++#include <linux/gta02_hdq.h>
++#include <linux/bq27000_battery.h>
+ 
+ /* define FIQ IPC struct */
+ /*
+@@ -578,6 +580,24 @@
+ };
+ #endif
+ 
++/* BQ27000 Battery */
++
++struct bq27000_platform_data bq27000_pdata = {
++      .name = "bat",
++      .rsense_mohms = 20,
++      .hdq_read = gta02hdq_read,
++      .hdq_write = gta02hdq_write,
++      .hdq_initialized = gta02hdq_initialized,
++};
++
++struct platform_device bq27000_battery_device = {
++      .name           = "bq27000-battery",
++      .dev = {
++              .platform_data = &bq27000_pdata,
++      },
++};
++
++
+ /* NOR Flash */
+ 
+ #define GTA02_FLASH_BASE      0x18000000 /* GCS3 */
+@@ -1245,6 +1265,7 @@
+       switch (system_rev) {
+       case GTA02v5_SYSTEM_REV:
+               platform_device_register(&gta02_hdq_device);
++              platform_device_register(&bq27000_battery_device);
+               break;
+       default:
+               break;
+Index: linux-2.6.24/drivers/power/Kconfig
+===================================================================
+--- linux-2.6.24.orig/drivers/power/Kconfig
++++ linux-2.6.24/drivers/power/Kconfig
+@@ -49,6 +49,11 @@
+       help
+         Say Y to enable support for the battery on the OLPC laptop.
+ 
++config BATTERY_BQ27000_HDQ
++      tristate "BQ27000 HDQ battery monitor driver"
++      help
++        Say Y to enable support for the battery on the Neo Freerunner
++
+ endif # POWER_SUPPLY
+ 
+ config GTA02_HDQ
+Index: linux-2.6.24/drivers/power/Makefile
+===================================================================
+--- linux-2.6.24.orig/drivers/power/Makefile
++++ linux-2.6.24/drivers/power/Makefile
+@@ -20,5 +20,6 @@
+ obj-$(CONFIG_BATTERY_DS2760)  += ds2760_battery.o
+ obj-$(CONFIG_BATTERY_PMU)     += pmu_battery.o
+ obj-$(CONFIG_BATTERY_OLPC)    += olpc_battery.o
++obj-$(CONFIG_BATTERY_BQ27000_HDQ)     += bq27000_battery.o
+ 
+ obj-$(CONFIG_GTA02_HDQ)               += gta02_hdq.o
+Index: linux-2.6.24/drivers/power/bq27000_battery.c
+===================================================================
+--- /dev/null
++++ linux-2.6.24/drivers/power/bq27000_battery.c
+@@ -0,0 +1,375 @@
++/*
++ * Driver for batteries with bq27000 chips inside via HDQ
++ *
++ * Copyright 2008 Openmoko, Inc
++ * Andy Green <[EMAIL PROTECTED]>
++ *
++ * based on ds2760 driver, original copyright notice for that --->
++ *
++ * Copyright © 2007 Anton Vorontsov
++ *           2004-2007 Matt Reimer
++ *           2004 Szabolcs Gyurko
++ *
++ * Use consistent with the GNU GPL is permitted,
++ * provided that this copyright notice is
++ * preserved in its entirety in all copies and derived works.
++ *
++ * Author:  Anton Vorontsov <[EMAIL PROTECTED]>
++ *        February 2007
++ *
++ *        Matt Reimer <[EMAIL PROTECTED]>
++ *        April 2004, 2005, 2007
++ *
++ *        Szabolcs Gyurko <[EMAIL PROTECTED]>
++ *        September 2004
++ */
++
++#include <linux/module.h>
++#include <linux/param.h>
++#include <linux/jiffies.h>
++#include <linux/delay.h>
++#include <linux/pm.h>
++#include <linux/platform_device.h>
++#include <linux/power_supply.h>
++#include <linux/bq27000_battery.h>
++
++enum bq27000_regs {
++      /* RAM regs */
++              /* read-write after this */
++      BQ27000_CTRL = 0, /* Device Control Register */
++      BQ27000_MODE, /* Device Mode Register */
++      BQ27000_AR_L, /* At-Rate H L */
++      BQ27000_AR_H,
++              /* read-only after this */
++      BQ27000_ARTTE_L, /* At-Rate Time To Empty H L */
++      BQ27000_ARTTE_H,
++      BQ27000_TEMP_L, /* Reported Temperature H L */
++      BQ27000_TEMP_H,
++      BQ27000_VOLT_L, /* Reported Voltage H L */
++      BQ27000_VOLT_H,
++      BQ27000_FLAGS, /* Status Flags */
++      BQ27000_RSOC, /* Relative State of Charge */
++      BQ27000_NAC_L, /* Nominal Available Capacity H L */
++      BQ27000_NAC_H,
++      BQ27000_CACD_L, /* Discharge Compensated H L */
++      BQ27000_CACD_H,
++      BQ27000_CACT_L, /* Temperature Compensated H L */
++      BQ27000_CACT_H,
++      BQ27000_LMD_L, /* Last measured discharge H L */
++      BQ27000_LMD_H,
++      BQ27000_AI_L, /* Average Current H L */
++      BQ27000_AI_H,
++      BQ27000_TTE_L, /* Time to Empty H L */
++      BQ27000_TTE_H,
++      BQ27000_TTF_L, /* Time to Full H L */
++      BQ27000_TTF_H,
++      BQ27000_SI_L, /* Standby Current H L */
++      BQ27000_SI_H,
++      BQ27000_STTE_L, /* Standby Time To Empty H L */
++      BQ27000_STTE_H,
++      BQ27000_MLI_L, /* Max Load Current H L */
++      BQ27000_MLI_H,
++      BQ27000_MLTTE_L, /* Max Load Time To Empty H L */
++      BQ27000_MLTTE_H,
++      BQ27000_SAE_L, /* Available Energy H L */
++      BQ27000_SAE_H,
++      BQ27000_AP_L, /* Available Power H L */
++      BQ27000_AP_H,
++      BQ27000_TTECP_L, /* Time to Empty at Constant Power H L */
++      BQ27000_TTECP_H,
++      BQ27000_CYCL_L, /* Cycle count since learning cycle H L */
++      BQ27000_CYCL_H,
++      BQ27000_CYCT_L, /* Cycle Count Total H L */
++      BQ27000_CYCT_H,
++      BQ27000_CSOC, /* Compensated State Of Charge */
++      /* EEPROM regs */
++              /* read-write after this */
++      BQ27000_EE_EE_EN = 0x6e, /* EEPROM Program Enable */
++      BQ27000_EE_ILMD = 0x76, /* Initial Last Measured Discharge High Byte */
++      BQ27000_EE_SEDVF, /* Scaled EDVF Threshold */
++      BQ27000_EE_SEDV1, /* Scaled EDV1 Threshold */
++      BQ27000_EE_ISLC, /* Initial Standby Load Current */
++      BQ27000_EE_DMFSD, /* Digital Magnitude Filter and Self Discharge */
++      BQ27000_EE_TAPER, /* Aging Estimate Enable, Charge Termination Taper */
++      BQ27000_EE_PKCFG, /* Pack Configuration Values */
++      BQ27000_EE_IMLC, /* Initial Max Load Current or ID #3 */
++      BQ27000_EE_DCOMP, /* Discharge rate compensation constants or ID #2 */
++      BQ27000_EE_TCOMP, /* Temperature Compensation constants or ID #1 */
++};
++
++enum bq27000_status_flags {
++      BQ27000_STATUS_CHGS = 0x80, /* 1 = being charged */
++      BQ27000_STATUS_NOACT = 0x40, /* 1 = no activity */
++      BQ27000_STATUS_IMIN = 0x20, /* 1 = Lion taper current mode */
++      BQ27000_STATUS_CI = 0x10, /* 1 = capacity likely  innacurate */
++      BQ27000_STATUS_CALIP = 0x08, /* 1 = calibration in progress */
++      BQ27000_STATUS_VDQ = 0x04, /* 1 = capacity should be accurate */
++      BQ27000_STATUS_EDV1 = 0x02, /* 1 = end of discharge.. <6% left */
++      BQ27000_STATUS_EDVF = 0x01, /* 1 = no, it's really empty now */
++};
++
++#define NANOVOLTS_UNIT 3750
++
++struct bq27000_device_info {
++      struct device *dev;
++      struct power_supply bat;
++
++      int rsense_mohms;               /* from platform */
++
++      int (*hdq_initialized)(void); /* from platform */
++      int (*hdq_read)(int); /* from platform */
++      int (*hdq_write)(int, u8); /* from platform */
++};
++
++/*
++ * reading 16 bit values over HDQ has a special hazard where the
++ * hdq device firmware can update the 16-bit register during the time we
++ * read the two halves.  TI document SLUS556D recommends the algorithm here
++ * to avoid trouble
++ */
++
++static int hdq_read16(struct bq27000_device_info *di, int address)
++{
++      int acc;
++      int high;
++      int retries = 3;
++
++      while (retries--) {
++
++              high = (di->hdq_read)(address + 1); /* high part */
++
++              if (high < 0)
++                      return high;
++              acc = (di->hdq_read)(address);
++              if (acc < 0)
++                      return acc;
++
++              /* confirm high didn't change between reading it and low */
++              if (high == (di->hdq_read)(address + 1))
++                      return (high << 8) | acc;
++      }
++
++      return -ETIME;
++}
++
++#define to_bq27000_device_info(x) container_of((x), \
++                                             struct bq27000_device_info, \
++                                             bat);
++
++static void bq27000_battery_external_power_changed(struct power_supply *psy)
++{
++      struct bq27000_device_info *di = to_bq27000_device_info(psy);
++
++      dev_dbg(di->dev, "%s\n", __FUNCTION__);
++}
++
++static int bq27000_battery_get_property(struct power_supply *psy,
++                                     enum power_supply_property psp,
++                                     union power_supply_propval *val)
++{
++      int v, n;
++      struct bq27000_device_info *di = to_bq27000_device_info(psy);
++
++      if (!(di->hdq_initialized)())
++              return -EINVAL;
++
++      switch (psp) {
++      case POWER_SUPPLY_PROP_STATUS:
++              val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
++              v = hdq_read16(di, BQ27000_AI_L);
++              if (v < 0)
++                      return v;
++              if (v < 2) { /* no real activity on the battery */
++                      if (!hdq_read16(di, BQ27000_TTF_L))
++                              val->intval = POWER_SUPPLY_STATUS_FULL;
++                      else
++                              val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
++                      break;
++              }
++              /* power is actually going in or out... */
++              v = (di->hdq_read)(BQ27000_FLAGS);
++              if (v < 0)
++                      return v;
++              if (v & BQ27000_STATUS_CHGS)
++                      val->intval = POWER_SUPPLY_STATUS_CHARGING;
++              else
++                      val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
++              break;
++      case POWER_SUPPLY_PROP_VOLTAGE_NOW:
++              v = hdq_read16(di, BQ27000_VOLT_L);
++              if (v < 0)
++                      return v;
++              val->intval = v * 1000; /* mV -> uV */
++              break;
++      case POWER_SUPPLY_PROP_CURRENT_NOW:
++              v = (di->hdq_read)(BQ27000_FLAGS);
++              if (v < 0)
++                      return v;
++              if (v & BQ27000_STATUS_CHGS)
++                      n = -NANOVOLTS_UNIT;
++              else
++                      n = NANOVOLTS_UNIT;
++              v = hdq_read16(di, BQ27000_AI_L);
++              if (v < 0)
++                      return v;
++              val->intval = (v * n) / di->rsense_mohms;
++              break;
++      case POWER_SUPPLY_PROP_CHARGE_FULL:
++              v = hdq_read16(di, BQ27000_LMD_L);
++              if (v < 0)
++                      return v;
++              val->intval = (v * 3570) / di->rsense_mohms;
++              break;
++      case POWER_SUPPLY_PROP_TEMP:
++              v = hdq_read16(di, BQ27000_TEMP_L);
++              if (v < 0)
++                      return v;
++              /* K (in 0.25K units) is 273.15 up from C (in 0.1C)*/
++              /* 10926 = 27315 * 4 / 10 */
++              val->intval = (((long)v * 10l) - 10926) / 4;
++              break;
++      case POWER_SUPPLY_PROP_TECHNOLOGY:
++              val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
++              break;
++      case POWER_SUPPLY_PROP_CAPACITY:
++              val->intval = (di->hdq_read)(BQ27000_RSOC);
++              if (val->intval < 0)
++                      return val->intval;
++              break;
++      case POWER_SUPPLY_PROP_PRESENT:
++              v = (di->hdq_read)(BQ27000_RSOC);
++              val->intval = !(v < 0);
++              break;
++      case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
++              v = hdq_read16(di, BQ27000_TTE_L);
++              if (v < 0)
++                      return v;
++              val->intval = 60 * v;
++              break;
++      case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
++              v = hdq_read16(di, BQ27000_TTF_L);
++              if (v < 0)
++                      return v;
++              val->intval = 60 * v;
++              break;
++      default:
++              return -EINVAL;
++      }
++
++      return 0;
++}
++
++static enum power_supply_property bq27000_battery_props[] = {
++      POWER_SUPPLY_PROP_STATUS,
++      POWER_SUPPLY_PROP_VOLTAGE_NOW,
++      POWER_SUPPLY_PROP_CURRENT_NOW,
++      POWER_SUPPLY_PROP_CHARGE_FULL,
++      POWER_SUPPLY_PROP_TEMP,
++      POWER_SUPPLY_PROP_TECHNOLOGY,
++      POWER_SUPPLY_PROP_PRESENT,
++      POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
++      POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
++      POWER_SUPPLY_PROP_MODEL_NAME,
++      POWER_SUPPLY_PROP_CAPACITY
++};
++
++static int bq27000_battery_probe(struct platform_device *pdev)
++{
++      int retval = 0;
++      struct bq27000_device_info *di;
++      struct bq27000_platform_data *pdata;
++
++      dev_info(&pdev->dev, "BQ27000 Battery Driver (C) 2008 Openmoko, Inc\n");
++
++      di = kzalloc(sizeof(*di), GFP_KERNEL);
++      if (!di) {
++              retval = -ENOMEM;
++              goto di_alloc_failed;
++      }
++
++      platform_set_drvdata(pdev, di);
++
++      pdata = pdev->dev.platform_data;
++      di->dev         = &pdev->dev;
++      /* di->w1_dev        = pdev->dev.parent; */
++      di->bat.name       = pdata->name;
++      di->bat.type       = POWER_SUPPLY_TYPE_BATTERY;
++      di->bat.properties     = bq27000_battery_props;
++      di->bat.num_properties = ARRAY_SIZE(bq27000_battery_props);
++      di->bat.get_property   = bq27000_battery_get_property;
++      di->bat.external_power_changed =
++                                bq27000_battery_external_power_changed;
++      di->hdq_read = pdata->hdq_read;
++      di->hdq_write = pdata->hdq_write;
++      di->rsense_mohms = pdata->rsense_mohms;
++      di->hdq_initialized = pdata->hdq_initialized;
++
++      retval = power_supply_register(&pdev->dev, &di->bat);
++      if (retval) {
++              dev_err(di->dev, "failed to register battery\n");
++              goto batt_failed;
++      }
++
++      return 0;
++
++batt_failed:
++      kfree(di);
++di_alloc_failed:
++      return retval;
++}
++
++static int bq27000_battery_remove(struct platform_device *pdev)
++{
++      struct bq27000_device_info *di = platform_get_drvdata(pdev);
++
++      power_supply_unregister(&di->bat);
++
++      return 0;
++}
++
++#ifdef CONFIG_PM
++
++static int bq27000_battery_suspend(struct platform_device *pdev,
++                                pm_message_t state)
++{
++      return 0;
++}
++
++static int bq27000_battery_resume(struct platform_device *pdev)
++{
++      return 0;
++}
++
++#else
++
++#define bq27000_battery_suspend NULL
++#define bq27000_battery_resume NULL
++
++#endif /* CONFIG_PM */
++
++static struct platform_driver bq27000_battery_driver = {
++      .driver = {
++              .name = "bq27000-battery",
++      },
++      .probe    = bq27000_battery_probe,
++      .remove   = bq27000_battery_remove,
++      .suspend  = bq27000_battery_suspend,
++      .resume   = bq27000_battery_resume,
++};
++
++static int __init bq27000_battery_init(void)
++{
++      return platform_driver_register(&bq27000_battery_driver);
++}
++
++static void __exit bq27000_battery_exit(void)
++{
++      platform_driver_unregister(&bq27000_battery_driver);
++}
++
++module_init(bq27000_battery_init);
++module_exit(bq27000_battery_exit);
++
++MODULE_LICENSE("GPL");
++MODULE_AUTHOR("Andy Green <[EMAIL PROTECTED]>");
++MODULE_DESCRIPTION("bq27000 battery driver");
+Index: linux-2.6.24/include/linux/bq27000_battery.h
+===================================================================
+--- /dev/null
++++ linux-2.6.24/include/linux/bq27000_battery.h
+@@ -0,0 +1,12 @@
++#ifndef __BQ27000_BATTERY_H__
++#define __BQ27000_BATTERY_H__
++
++struct bq27000_platform_data {
++      const char      *name;
++      int             rsense_mohms;
++      int (*hdq_read)(int);
++      int (*hdq_write)(int, u8);
++      int (*hdq_initialized)(void);
++};
++
++#endif

Modified: branches/src/target/kernel/2.6.24.x/patches/series
===================================================================
--- branches/src/target/kernel/2.6.24.x/patches/series  2008-02-12 23:03:11 UTC 
(rev 4053)
+++ branches/src/target/kernel/2.6.24.x/patches/series  2008-02-12 23:40:22 UTC 
(rev 4054)
@@ -77,7 +77,7 @@
 introduce-fiq-use-timer3-as-source.patch
 introduce-fiq-migrate-vibrator-gta02-only.patch
 fiq-hdq.patch
-#bq27000-battery-driver.patch
+bq27000-battery-driver.patch
 
 # OE patches
 fix-EVIOCGRAB-semantics.patch




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2008-02-13 00:51:35 +0100 (Wed, 13 Feb 2008)
New Revision: 4055

Modified:
   branches/src/target/kernel/2.6.24.x/config/defconfig-2.6.24
   branches/src/target/kernel/2.6.24.x/patches/bq27000-battery-driver.patch
Log:
Some build fixes after introduce-bq27000-battery-driver.patch

patches/bq27000-battery-driver.patch:
- arch/arm/mach-s3c2440/Kconfig: MACH_NEO1973_GTA02 also selects POWER_SUPPLY
  and BATTERY_BQ27000_HDQ
- drivers/power/Kconfig: GTA02_HDQ section ended up outside the "if ... endif"

config/defconfig-2.6.24:
- added CONFIG_POWER_SUPPLY=y and CONFIG_BATTERY_BQ27000_HDQ=y



Modified: branches/src/target/kernel/2.6.24.x/config/defconfig-2.6.24
===================================================================
--- branches/src/target/kernel/2.6.24.x/config/defconfig-2.6.24 2008-02-12 
23:40:22 UTC (rev 4054)
+++ branches/src/target/kernel/2.6.24.x/config/defconfig-2.6.24 2008-02-12 
23:51:35 UTC (rev 4055)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.24
-# Sun Feb 10 20:32:17 2008
+# Tue Feb 12 20:45:39 2008
 #
 CONFIG_ARM=y
 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -1015,7 +1015,12 @@
 # CONFIG_SPI_SPIDEV is not set
 # CONFIG_SPI_TLE62X0 is not set
 # CONFIG_W1 is not set
-# CONFIG_POWER_SUPPLY is not set
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+# CONFIG_PDA_POWER is not set
+# CONFIG_APM_POWER is not set
+# CONFIG_BATTERY_DS2760 is not set
+CONFIG_BATTERY_BQ27000_HDQ=y
 CONFIG_GTA02_HDQ=y
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y

Modified: 
branches/src/target/kernel/2.6.24.x/patches/bq27000-battery-driver.patch
===================================================================
--- branches/src/target/kernel/2.6.24.x/patches/bq27000-battery-driver.patch    
2008-02-12 23:40:22 UTC (rev 4054)
+++ branches/src/target/kernel/2.6.24.x/patches/bq27000-battery-driver.patch    
2008-02-12 23:51:35 UTC (rev 4055)
@@ -48,18 +48,24 @@
 ===================================================================
 --- linux-2.6.24.orig/drivers/power/Kconfig
 +++ linux-2.6.24/drivers/power/Kconfig
-@@ -49,6 +49,11 @@
+@@ -49,7 +49,10 @@
        help
          Say Y to enable support for the battery on the OLPC laptop.
  
+-endif # POWER_SUPPLY
 +config BATTERY_BQ27000_HDQ
 +      tristate "BQ27000 HDQ battery monitor driver"
 +      help
 +        Say Y to enable support for the battery on the Neo Freerunner
-+
- endif # POWER_SUPPLY
  
  config GTA02_HDQ
+       tristate "Neo Freerunner HDQ"
+@@ -58,3 +61,5 @@
+         Say Y to enable support for communicating with an HDQ battery
+         on the Neo Freerunner.  You probably want to select
+         at least BATTERY_BQ27000_HDQ as well
++
++endif # POWER_SUPPLY
 Index: linux-2.6.24/drivers/power/Makefile
 ===================================================================
 --- linux-2.6.24.orig/drivers/power/Makefile
@@ -468,3 +474,16 @@
 +};
 +
 +#endif
+Index: linux-2.6.24/arch/arm/mach-s3c2440/Kconfig
+===================================================================
+--- linux-2.6.24.orig/arch/arm/mach-s3c2440/Kconfig
++++ linux-2.6.24/arch/arm/mach-s3c2440/Kconfig
+@@ -85,6 +85,8 @@
+       bool "FIC Neo1973 GSM Phone (GTA02 Hardware)"
+       select CPU_S3C2442
+       select SENSORS_PCF50633
++      select POWER_SUPPLY
++      select GTA02_HDQ
+       help
+          Say Y here if you are using the FIC Neo1973 GSM Phone
+ 




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2008-02-13 02:18:47 +0100 (Wed, 13 Feb 2008)
New Revision: 4056

Modified:
   branches/src/target/kernel/2.6.24.x/patches/gta01-pcf50606.patch
   branches/src/target/kernel/2.6.24.x/patches/pcf50633.patch
Log:
fix-pcf50606-set-irq-type.patch
fix-pcf50633-set-irq-type.patch

    From: Andy Green <[EMAIL PROTECTED]>

    Remove set_irq_type and use IRQF_FALLING with interrupt enabled all the
    time.
    Use a mutex to stop any reentrancy


Signed-off-by: Andy Green <[EMAIL PROTECTED]>

---

 drivers/i2c/chips/pcf50606.c |   29 ++++++++---------------------
 1 files changed, 8 insertions(+), 21 deletions(-)
 drivers/i2c/chips/pcf50633.c |   31 +++++++++----------------------
 1 files changed, 9 insertions(+), 22 deletions(-)



Modified: branches/src/target/kernel/2.6.24.x/patches/gta01-pcf50606.patch
===================================================================
--- branches/src/target/kernel/2.6.24.x/patches/gta01-pcf50606.patch    
2008-02-12 23:51:35 UTC (rev 4055)
+++ branches/src/target/kernel/2.6.24.x/patches/gta01-pcf50606.patch    
2008-02-13 01:18:47 UTC (rev 4056)
@@ -8,7 +8,7 @@
 ===================================================================
 --- /dev/null
 +++ linux-2.6.24/drivers/i2c/chips/pcf50606.c
-@@ -0,0 +1,1946 @@
+@@ -0,0 +1,1933 @@
 +/* Philips/NXP PCF50606 Power Management Unit (PMU) driver
 + *
 + * (C) 2006-2007 by OpenMoko, Inc.
@@ -106,6 +106,7 @@
 +      struct mutex lock;
 +      unsigned int flags;
 +      unsigned int working;
++      struct mutex working_lock;
 +      struct work_struct work;
 +      struct rtc_device *rtc;
 +      struct input_dev *input_dev;
@@ -567,6 +568,7 @@
 +                      container_of(work, struct pcf50606_data, work);
 +      u_int8_t int1, int2, int3;
 +
++      mutex_lock(&pcf->working_lock);
 +      pcf->working = 1;
 +
 +      int1 = __reg_read(pcf, PCF50606_REG_INT1);
@@ -745,33 +747,19 @@
 +      pcf->working = 0;
 +      input_sync(pcf->input_dev);
 +      put_device(&pcf->client.dev);
-+
-+      enable_irq(pcf->irq);
++      mutex_unlock(&pcf->working_lock);
 +}
 +
-+static void pcf50606_schedule_work(struct pcf50606_data *pcf)
-+{
-+      int status;
-+
-+      get_device(&pcf->client.dev);
-+      status = schedule_work(&pcf->work);
-+      if (!status && !pcf->working)
-+              dev_dbg(&pcf->client.dev, "work item may be lost\n");
-+}
-+
-+
 +static irqreturn_t pcf50606_irq(int irq, void *_pcf)
 +{
 +      struct pcf50606_data *pcf = _pcf;
 +
 +      dev_dbg(&pcf->client.dev, "entering(irq=%u, pcf=%p): scheduling work\n",
 +              irq, _pcf);
-+      pcf50606_schedule_work(pcf);
++      get_device(&pcf->client.dev);
++      if (!schedule_work(&pcf->work) && !pcf->working)
++              dev_dbg(&pcf->client.dev, "work item may be lost\n");
 +
-+      /* Disable any further interrupts until we have processed
-+       * the current one */
-+      disable_irq(irq);
-+
 +      return IRQ_HANDLED;
 +}
 +
@@ -1601,6 +1589,7 @@
 +              return -ENOMEM;
 +
 +      mutex_init(&data->lock);
++      mutex_init(&data->working_lock);
 +      INIT_WORK(&data->work, pcf50606_work);
 +      data->irq = irq;
 +      data->working = 0;
@@ -1662,13 +1651,11 @@
 +      reg_write(data, PCF50606_REG_INT2M, 0x00);
 +      reg_write(data, PCF50606_REG_INT3M, PCF50606_INT3_TSCPRES);
 +
-+      err = request_irq(irq, pcf50606_irq, IRQF_DISABLED,
++      err = request_irq(irq, pcf50606_irq, IRQF_TRIGGER_FALLING,
 +                        "pcf50606", data);
 +      if (err < 0)
 +              goto exit_input;
 +
-+      set_irq_type(irq, IRQT_FALLING);
-+
 +      if (enable_irq_wake(irq) < 0)
 +              dev_err(&new_client->dev, "IRQ %u cannot be enabled as wake-up"
 +                      "source in this hardware revision!", irq);

Modified: branches/src/target/kernel/2.6.24.x/patches/pcf50633.patch
===================================================================
--- branches/src/target/kernel/2.6.24.x/patches/pcf50633.patch  2008-02-12 
23:51:35 UTC (rev 4055)
+++ branches/src/target/kernel/2.6.24.x/patches/pcf50633.patch  2008-02-13 
01:18:47 UTC (rev 4056)
@@ -34,7 +34,7 @@
 ===================================================================
 --- /dev/null
 +++ linux-2.6.24/drivers/i2c/chips/pcf50633.c
-@@ -0,0 +1,1802 @@
+@@ -0,0 +1,1789 @@
 +/* Philips PCF50633 Power Management Unit (PMU) driver
 + *
 + * (C) 2006-2007 by OpenMoko, Inc.
@@ -138,6 +138,7 @@
 +      struct mutex lock;
 +      unsigned int flags;
 +      unsigned int working;
++      struct mutex working_lock;
 +      struct work_struct work;
 +      struct rtc_device *rtc;
 +      struct input_dev *input_dev;
@@ -527,6 +528,7 @@
 +                      container_of(work, struct pcf50633_data, work);
 +      u_int8_t int1, int2, int3, int4, int5;
 +
++      mutex_lock(&pcf->working_lock);
 +      pcf->working = 1;
 +
 +      /* FIXME: read in one i2c transaction */
@@ -702,32 +704,18 @@
 +      pcf->working = 0;
 +      input_sync(pcf->input_dev);
 +      put_device(&pcf->client.dev);
-+
-+      enable_irq(pcf->irq);
++      mutex_unlock(&pcf->working_lock);
 +}
 +
-+static void pcf50633_schedule_work(struct pcf50633_data *pcf)
-+{
-+      int status;
-+
-+      get_device(&pcf->client.dev);
-+      status = schedule_work(&pcf->work);
-+      if (!status && !pcf->working)
-+              dev_dbg(&pcf->client.dev, "work item may be lost\n");
-+}
-+
-+
 +static irqreturn_t pcf50633_irq(int irq, void *_pcf)
 +{
 +      struct pcf50633_data *pcf = _pcf;
 +
-+      DEBUGP("entering(irq=%u, pcf=%p): scheduling work\n",
-+              irq, _pcf);
-+      pcf50633_schedule_work(pcf);
++      DEBUGP("entering(irq=%u, pcf=%p): scheduling work\n", irq, _pcf);
 +
-+      /* Disable any further interrupts until we have processed
-+       * the current one */
-+      disable_irq(irq);
++      get_device(&pcf->client.dev);
++      if (!schedule_work(&pcf->work) && !pcf->working)
++              dev_dbg(&pcf->client.dev, "work item may be lost\n");
 +
 +      return IRQ_HANDLED;
 +}
@@ -1472,6 +1460,7 @@
 +              return -ENOMEM;
 +
 +      mutex_init(&data->lock);
++      mutex_init(&data->working_lock);
 +      INIT_WORK(&data->work, pcf50633_work);
 +      data->irq = irq;
 +      data->working = 0;
@@ -1535,13 +1524,11 @@
 +      reg_write(data, PCF50633_REG_INT4M, 0x00);
 +      reg_write(data, PCF50633_REG_INT5M, 0x00);
 +
-+      err = request_irq(irq, pcf50633_irq, IRQF_DISABLED,
++      err = request_irq(irq, pcf50633_irq, IRQF_TRIGGER_FALLING,
 +                        "pcf50633", data);
 +      if (err < 0)
 +              goto exit_input;
 +
-+      set_irq_type(irq, IRQT_FALLING);
-+
 +      if (enable_irq_wake(irq) < 0)
 +              dev_err(&new_client->dev, "IRQ %u cannot be enabled as wake-up"
 +                      "source in this hardware revision!", irq);




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to