On Wed, Jan 28, 2009 at 07:57:55PM +0000, Andy Green wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Somebody in the thread at some point said:
>
> |> Balaji, what do you think?  It basically means allowing setting of MBCC5
> |> with a sys name like force_charging_limit_dangerous.
> |
> | Yea, AFAICS including this attribute is going to be harmless. Andy,
> | should I add it right away ?
>
> That'd be great, thanks.

Hi Andy,

Here it is.

Also in gta02-moredrivers-defconfig, NFSD is enabled and also
PHYSMAP_COMPAT which causes a backtrace during bootup. I think it was
disabled previously. There's a patch that fixes this is on
balaji-tracking along with the one below.

    pcf50633_charging_current_control.patch
    
    Introduces battery charging current control.
    
    Signed-off-by: Balaji Rao <[email protected]>

diff --git a/arch/arm/mach-s3c2440/mach-gta02.c 
b/arch/arm/mach-s3c2440/mach-gta02.c
index 31759d8..d780128 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -640,6 +640,7 @@ struct pcf50633_platform_data gta02_pcf_pdata = {
        .batteries = gta02_batteries,
        .num_batteries = ARRAY_SIZE(gta02_batteries),
        .charging_restart_interval = (900 * HZ),
+       .chg_ref_current_ma = 1000,
 
        .reg_init_data = {
                [PCF50633_REGULATOR_AUTO] = {
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
index 1efd798..874caf6 100644
--- a/drivers/power/pcf50633-charger.c
+++ b/drivers/power/pcf50633-charger.c
@@ -156,9 +156,42 @@ static ssize_t set_usblim(struct device *dev,
 
 static DEVICE_ATTR(usb_curlim, S_IRUGO | S_IWUSR, show_usblim, set_usblim);
 
+static ssize_t
+show_chglim(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
+       u8 mbcc5 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC5);
+       unsigned int ma;
+
+       ma = (mbc->pcf->pdata->chg_ref_current_ma *  mbcc5) >> 8;
+
+       return sprintf(buf, "%u\n", ma);
+}
+
+static ssize_t set_chglim(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
+{
+       struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
+       unsigned long ma;
+       u8 mbcc5;
+       int ret;
+
+       ret = strict_strtoul(buf, 10, &ma);
+       if (ret)
+               return -EINVAL;
+
+       mbcc5 = (ma << 8) / mbc->pcf->pdata->chg_ref_current_ma;
+       pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5);
+
+       return count;
+}
+
+static DEVICE_ATTR(chg_curlim, S_IRUGO | S_IWUSR, show_chglim, set_chglim);
+
 static struct attribute *pcf50633_mbc_sysfs_entries[] = {
        &dev_attr_chgmode.attr,
        &dev_attr_usb_curlim.attr,
+       &dev_attr_chg_curlim.attr,
        NULL,
 };
 
diff --git a/include/linux/mfd/pcf50633/core.h 
b/include/linux/mfd/pcf50633/core.h
index b7a891b..af67b4e 100644
--- a/include/linux/mfd/pcf50633/core.h
+++ b/include/linux/mfd/pcf50633/core.h
@@ -31,6 +31,8 @@ struct pcf50633_platform_data {
 
        int charging_restart_interval;
 
+       int chg_ref_current_ma;
+
        /* Callbacks */
        void (*probe_done)(struct pcf50633 *);
        void (*mbc_event_callback)(struct pcf50633 *, int);

Reply via email to