1 Index: linux-2.6.30-rc6/drivers/mfd/pcf50633-core.c
2 ===================================================================
3 --- linux-2.6.30-rc6.orig/drivers/mfd/pcf50633-core.c 2009-05-16 06:12:57.000000000 +0200
4 +++ linux-2.6.30-rc6/drivers/mfd/pcf50633-core.c 2009-05-18 19:08:33.000000000 +0200
6 #include <linux/kernel.h>
7 #include <linux/device.h>
8 #include <linux/sysfs.h>
9 +#include <linux/device.h>
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/interrupt.h>
17 + pcf50633_reg_write(pcf, PCF50633_REG_OOCSHDWN, 0x04 ); /* defeat 8s death from lowsys on A5 */
19 /* We immediately read the usb and adapter status. We thus make sure
20 * only of USBINS/USBREM IRQ handlers are called */
21 if (pcf_int[0] & (PCF50633_INT1_USBINS | PCF50633_INT1_USBREM)) {
23 dev_dbg(pcf->dev, "pcf50633_irq\n");
26 - disable_irq(pcf->irq);
27 + disable_irq_nosync(pcf->irq);
29 schedule_work(&pcf->irq_work);
36 -static int pcf50633_suspend(struct device *dev, pm_message_t state)
37 +static int pcf50633_suspend(struct i2c_client *client, pm_message_t state)
43 - pcf = dev_get_drvdata(dev);
44 + pcf = i2c_get_clientdata(client);
46 /* Make sure our interrupt handlers are not called
52 -static int pcf50633_resume(struct device *dev)
53 +static int pcf50633_resume(struct i2c_client *client)
58 - pcf = dev_get_drvdata(dev);
59 + pcf = i2c_get_clientdata(client);
61 /* Write the saved mask registers */
62 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M,
67 + set_irq_handler(client->irq, handle_level_irq);
68 ret = request_irq(client->irq, pcf50633_irq,
69 IRQF_TRIGGER_LOW, "pcf50633", pcf);
72 static struct i2c_driver pcf50633_driver = {
75 - .suspend = pcf50633_suspend,
76 - .resume = pcf50633_resume,
78 .id_table = pcf50633_id_table,
79 .probe = pcf50633_probe,
80 .remove = __devexit_p(pcf50633_remove),
81 + .suspend = pcf50633_suspend,
82 + .resume = pcf50633_resume,
85 static int __init pcf50633_init(void)
86 Index: linux-2.6.30-rc6/drivers/power/pcf50633-charger.c
87 ===================================================================
88 --- linux-2.6.30-rc6.orig/drivers/power/pcf50633-charger.c 2009-05-16 06:12:57.000000000 +0200
89 +++ linux-2.6.30-rc6/drivers/power/pcf50633-charger.c 2009-05-18 19:08:33.000000000 +0200
92 struct power_supply usb;
93 struct power_supply adapter;
94 + struct power_supply ac;
96 struct delayed_work charging_restart_work;
100 int charging_start = 1;
102 + unsigned int mbcc5;
106 bits = PCF50633_MBCC7_USB_1000mA;
107 - else if (ma >= 500)
109 + } else if (ma >= 500) {
110 bits = PCF50633_MBCC7_USB_500mA;
111 - else if (ma >= 100)
113 + } else if (ma >= 100) {
114 bits = PCF50633_MBCC7_USB_100mA;
118 bits = PCF50633_MBCC7_USB_SUSPEND;
123 ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC7,
126 dev_info(pcf->dev, "usb curlim to %d mA\n", ma);
128 - /* Manual charging start */
130 + * We limit the charging current to be the USB current limit.
131 + * The reason is that on pcf50633, when it enters PMU Standby mode,
132 + * which it does when the device goes "off", the USB current limit
133 + * reverts to the variant default. In at least one common case, that
134 + * default is 500mA. By setting the charging current to be the same
135 + * as the USB limit we set here before PMU standby, we enforce it only
136 + * using the correct amount of current even when the USB current limit
137 + * gets reset to the wrong thing
140 + mbcc5 = (ma << 8) / mbc->pcf->pdata->chg_ref_current_ma;
143 + pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5);
145 mbcs2 = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2);
146 chgmod = (mbcs2 & PCF50633_MBCS2_MBC_MASK);
149 PCF50633_MBCC1_RESUME, PCF50633_MBCC1_RESUME);
151 mbc->usb_active = charging_start;
154 power_supply_changed(&mbc->usb);
159 static DEVICE_ATTR(usb_curlim, S_IRUGO | S_IWUSR, show_usblim, set_usblim);
162 +show_chglim(struct device *dev, struct device_attribute *attr, char *buf)
164 + struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
165 + u8 mbcc5 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC5);
168 + ma = (mbc->pcf->pdata->chg_ref_current_ma * mbcc5) >> 8;
170 + return sprintf(buf, "%u\n", ma);
173 +static ssize_t set_chglim(struct device *dev,
174 + struct device_attribute *attr, const char *buf, size_t count)
176 + struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
178 + unsigned int mbcc5;
181 + ret = strict_strtoul(buf, 10, &ma);
185 + mbcc5 = (ma << 8) / mbc->pcf->pdata->chg_ref_current_ma;
188 + pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5);
193 +static DEVICE_ATTR(chg_curlim, S_IRUGO | S_IWUSR, show_chglim, set_chglim);
195 static struct attribute *pcf50633_mbc_sysfs_entries[] = {
196 &dev_attr_chgmode.attr,
197 &dev_attr_usb_curlim.attr,
198 + &dev_attr_chg_curlim.attr,
204 power_supply_changed(&mbc->usb);
205 power_supply_changed(&mbc->adapter);
206 + power_supply_changed(&mbc->ac);
208 if (mbc->pcf->pdata->mbc_event_callback)
209 mbc->pcf->pdata->mbc_event_callback(mbc->pcf, irq);
211 enum power_supply_property psp,
212 union power_supply_propval *val)
214 - struct pcf50633_mbc *mbc = container_of(psy,
215 - struct pcf50633_mbc, adapter);
216 + struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, adapter);
220 @@ -269,10 +325,34 @@
222 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb);
224 + u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
225 + PCF50633_MBCC7_USB_MASK;
228 case POWER_SUPPLY_PROP_ONLINE:
229 - val->intval = mbc->usb_online;
230 + val->intval = mbc->usb_online &&
231 + (usblim <= PCF50633_MBCC7_USB_500mA);
240 +static int ac_get_property(struct power_supply *psy,
241 + enum power_supply_property psp,
242 + union power_supply_propval *val)
244 + struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, ac);
246 + u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
247 + PCF50633_MBCC7_USB_MASK;
250 + case POWER_SUPPLY_PROP_ONLINE:
251 + val->intval = mbc->usb_online &&
252 + (usblim == PCF50633_MBCC7_USB_1000mA);
257 mbc->usb.supplied_to = mbc->pcf->pdata->batteries;
258 mbc->usb.num_supplicants = mbc->pcf->pdata->num_batteries;
260 + mbc->ac.name = "ac";
261 + mbc->ac.type = POWER_SUPPLY_TYPE_MAINS;
262 + mbc->ac.properties = power_props;
263 + mbc->ac.num_properties = ARRAY_SIZE(power_props);
264 + mbc->ac.get_property = ac_get_property;
265 + mbc->ac.supplied_to = mbc->pcf->pdata->batteries;
266 + mbc->ac.num_supplicants = mbc->pcf->pdata->num_batteries;
268 + INIT_DELAYED_WORK(&mbc->charging_restart_work,
269 + pcf50633_mbc_charging_restart);
271 ret = power_supply_register(&pdev->dev, &mbc->adapter);
273 dev_err(mbc->pcf->dev, "failed to register adapter\n");
278 - INIT_DELAYED_WORK(&mbc->charging_restart_work,
279 - pcf50633_mbc_charging_restart);
281 + ret = power_supply_register(&pdev->dev, &mbc->ac);
283 + dev_err(mbc->pcf->dev, "failed to register ac\n");
284 + power_supply_unregister(&mbc->adapter);
285 + power_supply_unregister(&mbc->usb);
290 ret = sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group);
292 dev_err(mbc->pcf->dev, "failed to create sysfs entries\n");
293 Index: linux-2.6.30-rc6/drivers/rtc/rtc-pcf50633.c
294 ===================================================================
295 --- linux-2.6.30-rc6.orig/drivers/rtc/rtc-pcf50633.c 2009-05-16 06:12:57.000000000 +0200
296 +++ linux-2.6.30-rc6/drivers/rtc/rtc-pcf50633.c 2009-05-18 19:08:33.000000000 +0200
298 struct pcf50633_rtc {
303 struct pcf50633 *pcf;
304 struct rtc_device *rtc_dev;
306 rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]);
307 rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]);
308 rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]);
309 - rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]);
310 + rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]) - 1;
311 rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100;
315 pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour);
316 pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday);
317 pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday);
318 - pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon);
319 + pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon + 1);
320 pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100);
324 rtc = dev_get_drvdata(dev);
326 alrm->enabled = rtc->alarm_enabled;
327 + alrm->pending = rtc->alarm_pending;
329 ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSCA,
330 PCF50633_TI_EXTENT, &pcf_tm.time[0]);
332 /* Returns 0 on success */
333 ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA,
334 PCF50633_TI_EXTENT, &pcf_tm.time[0]);
335 + if (!alrm->enabled)
336 + rtc->alarm_pending = 0;
339 + if (!alarm_masked || alrm->enabled)
340 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
341 + rtc->alarm_enabled = alrm->enabled;
347 case PCF50633_IRQ_ALARM:
348 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
349 + rtc->alarm_pending = 1;
351 case PCF50633_IRQ_SECOND:
352 rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
353 Index: linux-2.6.30-rc6/include/linux/mfd/pcf50633/core.h
354 ===================================================================
355 --- linux-2.6.30-rc6.orig/include/linux/mfd/pcf50633/core.h 2009-05-16 06:12:57.000000000 +0200
356 +++ linux-2.6.30-rc6/include/linux/mfd/pcf50633/core.h 2009-05-18 19:08:33.000000000 +0200
359 int charging_restart_interval;
361 + int chg_ref_current_ma;
364 void (*probe_done)(struct pcf50633 *);
365 void (*mbc_event_callback)(struct pcf50633 *, int);
369 /* misc. registers */
370 -#define PCF50633_REG_OOCSHDWN 0x0c
371 +#define PCF50633_REG_OOCSHDWN 0x0c
372 +#define PCF50633_OOCSHDWN_GOSTDBY 0x01
375 #define PCF50633_REG_LEDOUT 0x28