[PATCH 08/10] fix-pcf50633-use-second-as-initial-kick.patch
warmcat
andy at openmoko.com
Mon Feb 11 17:35:03 CET 2008
From: Andy Green <andy at openmoko.com>
Enable the SECOND 1Hz interrupt at probetime so the work function
gets an initial kick and deals with coldplug.
Move coldplug to work function.
Signed-off-by: Andy Green <andy at openmoko.com>
---
drivers/i2c/chips/pcf50633.c | 44 +++++++++++++++++++++++++++++++-----------
1 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
index e2781d8..ef50321 100644
--- a/drivers/i2c/chips/pcf50633.c
+++ b/drivers/i2c/chips/pcf50633.c
@@ -108,6 +108,8 @@ struct pcf50633_data {
int allow_close;
int onkey_seconds;
int irq;
+
+ int coldplug_done;
#ifdef CONFIG_PM
struct {
u_int8_t int1m, int2m, int3m, int4m, int5m;
@@ -503,6 +505,35 @@ static void pcf50633_work(struct work_struct *work)
if (ret != 5)
DEBUGP("Oh crap PMU IRQ register read failed %d\n", ret);
+ if (!pcf->coldplug_done) {
+ DEBUGP("PMU Coldplug init\n");
+
+ /* we used SECOND to kick ourselves started -- turn it off */
+ pcfirq[0] &= ~PCF50633_INT1_SECOND;
+ reg_set_bit_mask(pcf, PCF50633_REG_INT1M,
+ PCF50633_INT1_SECOND,
+ PCF50633_INT1_SECOND);
+
+ /* coldplug the USB if present */
+ if ((__reg_read(pcf, PCF50633_REG_MBCS1) &
+ (PCF50633_MBCS1_USBPRES | PCF50633_MBCS1_USBOK)) ==
+ (PCF50633_MBCS1_USBPRES | PCF50633_MBCS1_USBOK)) {
+ DEBUGPC("COLD USBINS\n");
+ input_report_key(pcf->input_dev, KEY_POWER2, 1);
+ apm_queue_event(APM_POWER_STATUS_CHANGE);
+ pcf->flags |= PCF50633_F_USB_PRESENT;
+ if (pcf->pdata->cb)
+ pcf->pdata->cb(&pcf->client.dev,
+ PCF50633_FEAT_MBC, PMU_EVT_USB_INSERT);
+ }
+
+ /* figure out our initial charging stance */
+ add_request_to_adc_queue(pcf, PCF50633_ADCC1_MUX_ADCIN1,
+ PCF50633_ADCC1_AVERAGE_16);
+
+ pcf->coldplug_done = 1;
+ }
+
DEBUGP("INT1=0x%02x INT2=0x%02x INT3=0x%02x INT4=0x%02x INT5=0x%02x\n",
pcfirq[0], pcfirq[1], pcfirq[2], pcfirq[3], pcfirq[4]);
@@ -1525,7 +1556,7 @@ static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
goto exit_sysfs;
/* configure interrupt mask */
- reg_write(data, PCF50633_REG_INT1M, PCF50633_INT1_SECOND);
+ reg_write(data, PCF50633_REG_INT1M, 0x00); /* we want SECOND to kick */
reg_write(data, PCF50633_REG_INT2M, 0x00);
reg_write(data, PCF50633_REG_INT3M, 0x00);
reg_write(data, PCF50633_REG_INT4M, 0x00);
@@ -1576,17 +1607,6 @@ static int pcf50633_detect(struct i2c_adapter *adapter, int address, int kind)
}
#endif
- /* coldplug the USB if present */
- if (reg_read(data, PCF50633_REG_MBCS1) & 3) { /* usb present, power ok */
- DEBUGPC("USBINS ");
- input_report_key(data->input_dev, KEY_POWER2, 1);
- apm_queue_event(APM_POWER_STATUS_CHANGE);
- data->flags |= PCF50633_F_USB_PRESENT;
- if (data->pdata->cb)
- data->pdata->cb(&data->client.dev,
- PCF50633_FEAT_MBC, PMU_EVT_USB_INSERT);
- }
-
return 0;
exit_rtc:
if (data->pdata->used_features & PCF50633_FEAT_RTC)
More information about the openmoko-kernel
mailing list