aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authormerging other branches <null@invalid>2008-11-26 16:07:01 +0000
committerAndy Green <agreen@pads.home.warmcat.com>2008-11-26 16:07:01 +0000
commit6d2c293d6578048e7b71e0c44897144f15f350ae (patch)
treecba36be2a06ee7bfa0aab1a3c7d36bd67ea37402 /drivers
parent524f4a1dfe71a8b353a244140164e09828abb68c (diff)
MERGE-via-balaji-tracking-hist-MERGE-via-stable-tracking-hist-MERGE-via-mokopatches-tracking-via-master-s3c-hsmmc-clean
balaji-tracking-hist top was efb2d57c0e0ed62324d79d6c5793fe797c157266
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ar6000/ar6000/wireless_ext.c14
-rw-r--r--drivers/input/misc/pcf50633-input.c2
-rw-r--r--drivers/input/touchscreen/s3c2410_ts.c38
-rw-r--r--drivers/mfd/Kconfig23
-rw-r--r--drivers/mfd/Makefile5
-rw-r--r--drivers/mfd/pcf50606-adc.c239
-rw-r--r--drivers/mfd/pcf50606-core.c580
-rw-r--r--drivers/mfd/pcf50606-gpo.c128
-rw-r--r--drivers/mfd/pcf50633-adc.c6
-rw-r--r--drivers/mfd/pcf50633-core.c22
-rw-r--r--drivers/mfd/pcf50633-gpio.c6
-rw-r--r--drivers/mmc/host/sdhci-s3c.c2
-rw-r--r--drivers/power/pcf50633-charger.c7
-rw-r--r--drivers/regulator/Makefile2
-rw-r--r--drivers/regulator/pcf50633-regulator.c24
-rw-r--r--drivers/rtc/Kconfig6
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-pcf50606.c297
-rw-r--r--drivers/rtc/rtc-pcf50633.c24
-rw-r--r--drivers/watchdog/Kconfig8
-rw-r--r--drivers/watchdog/Makefile1
-rw-r--r--drivers/watchdog/pcf50606_wdt.c213
22 files changed, 1583 insertions, 65 deletions
diff --git a/drivers/ar6000/ar6000/wireless_ext.c b/drivers/ar6000/ar6000/wireless_ext.c
index ab4d21b1f8c..0aa4bdc1a5c 100644
--- a/drivers/ar6000/ar6000/wireless_ext.c
+++ b/drivers/ar6000/ar6000/wireless_ext.c
@@ -317,7 +317,19 @@ ar6000_ioctl_siwessid(struct net_device *dev,
ar->arNetworkType = arNetworkType;
}
- if ((ar->arSsidLen) || (!data->flags))
+ /*
+ * The original logic here prevented a disconnect if issuing an "essid off"
+ * if no ESSID was set, presumably to prevent sending multiple disconnects
+ * to the WMI.
+ *
+ * Unfortunately, this also meant that no disconnect was sent when we were
+ * already connected, but the profile has been changed since (which also
+ * clears the ESSID as a reminder that the WMI needs updating.)
+ *
+ * The "1 ||" makes sure we always disconnect or reconnect. The WMI doesn't
+ * seem to mind being sent multiple disconnects.
+ */
+ if (1 || (ar->arSsidLen) || (!data->flags))
{
if ((!data->flags) ||
(A_MEMCMP(ar->arSsid, ssid, ar->arSsidLen) != 0) ||
diff --git a/drivers/input/misc/pcf50633-input.c b/drivers/input/misc/pcf50633-input.c
index 6fafd2729cb..a3cc4d680e9 100644
--- a/drivers/input/misc/pcf50633-input.c
+++ b/drivers/input/misc/pcf50633-input.c
@@ -5,7 +5,7 @@
* All rights reserved.
*
* Broken down from monstrous PCF50633 driver mainly by
- * Harald Welte and Andy Green
+ * Harald Welte, Andy Green and Werner Almesberger
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
index 8e580a833e5..253dc5b7eac 100644
--- a/drivers/input/touchscreen/s3c2410_ts.c
+++ b/drivers/input/touchscreen/s3c2410_ts.c
@@ -89,6 +89,11 @@ MODULE_LICENSE("GPL");
* Definitions & global arrays.
*/
+#define TOUCH_STANDBY_FLAG 0
+#define TOUCH_PRESSED_FLAG 1
+#define TOUCH_RELEASE_FLAG 2
+
+#define TOUCH_RELEASE_TIMEOUT (HZ >> 4)
static char *s3c2410ts_name = "s3c2410 TouchScreen";
@@ -143,23 +148,31 @@ static void ts_input_report(int event)
}
#endif
}
+
+static void touch_timer_fire(unsigned long data);
+static struct timer_list touch_timer =
+ TIMER_INITIALIZER(touch_timer_fire, 0, 0);
+
static void touch_timer_fire(unsigned long data)
{
if (ts.tsf[0])
(ts.tsf[0]->api->scale)(ts.tsf[0], &ts.coords[0]);
- if (ts.need_to_send_first_touch) {
- ts.need_to_send_first_touch = 0;
- ts_input_report(IE_DOWN);
- if (!ts.is_down) { /* Do we need this? I think so. */
+ if (ts.is_down && ts.need_to_send_first_touch == TOUCH_RELEASE_FLAG)
+ ts.need_to_send_first_touch = TOUCH_PRESSED_FLAG;
+
+ if ( ts.is_down ) {
+ if ( ts.need_to_send_first_touch == TOUCH_STANDBY_FLAG )
+ ts_input_report(IE_DOWN);
+ else
ts_input_report(IE_UPDATE);
- ts_input_report(IE_UP);
- }
- } else if (ts.is_down) {
- ts_input_report(IE_UPDATE);
- } else {
+ ts.need_to_send_first_touch = TOUCH_PRESSED_FLAG;
+ } else if (ts.need_to_send_first_touch == TOUCH_RELEASE_FLAG)
ts_input_report(IE_UP);
- }
+ else {
+ ts.need_to_send_first_touch = TOUCH_RELEASE_FLAG;
+ mod_timer(&touch_timer, jiffies + TOUCH_RELEASE_TIMEOUT);
+ }
if (ts.is_down) {
writel(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST,
@@ -173,9 +186,6 @@ static void touch_timer_fire(unsigned long data)
}
}
-static struct timer_list touch_timer =
- TIMER_INITIALIZER(touch_timer_fire, 0, 0);
-
static irqreturn_t stylus_updown(int irq, void *dev_id)
{
unsigned long data0;
@@ -188,7 +198,6 @@ static irqreturn_t stylus_updown(int irq, void *dev_id)
(!(data1 & S3C2410_ADCDAT0_UPDOWN));
if (ts.is_down) {
- ts.need_to_send_first_touch = 1;
writel(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST,
base_addr+S3C2410_ADCTSC);
writel(readl(base_addr+S3C2410_ADCCON) |
@@ -316,6 +325,7 @@ static int __init s3c2410ts_probe(struct platform_device *pdev)
ts.dev->id.vendor = 0xDEAD;
ts.dev->id.product = 0xBEEF;
ts.dev->id.version = S3C2410TSVERSION;
+ ts.need_to_send_first_touch = TOUCH_STANDBY_FLAG;
/* create the filter chain set up for the 2 coordinates we produce */
ret = ts_filter_create_chain(
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 6509719237d..1ab10dba8c8 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -177,6 +177,29 @@ config PCF50633_GPIO
Say yes here if you want to include support GPIO for pins on
the PCF50633 chip.
+config MFD_PCF50606
+ tristate "Support for NXP PCF50606"
+ depends on I2C
+ help
+ Say yes here if you have NXP PCF50606 chip on your board.
+ This core driver provides register access and IRQ handling
+ facilities, and registers devices for the various functions
+ so that function-specific drivers can bind to them.
+
+config PCF50606_ADC
+ tristate "Support for NXP PCF50606 ADC"
+ depends on MFD_PCF50606
+ help
+ Say yes here if you want to include support for ADC in the
+ NXP PCF50606 chip.
+
+config PCF50606_GPO
+ tristate "Support for NXP PCF50606 GPO"
+ depends on MFD_PCF50606
+ help
+ Say yes here if you want to include support GPO for pins on
+ the PCF50606 chip.
+
source "drivers/mfd/glamo/Kconfig"
endmenu
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index c515325b4b2..f6a769c8eff 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -37,3 +37,8 @@ obj-$(CONFIG_PMIC_DA903X) += da903x.o
obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o
obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o
+
+obj-$(CONFIG_MFD_PCF50606) += pcf50606-core.o
+obj-$(CONFIG_PCF50606_ADC) += pcf50606-adc.o
+obj-$(CONFIG_PCF50606_GPO) += pcf50606-gpo.o
+
diff --git a/drivers/mfd/pcf50606-adc.c b/drivers/mfd/pcf50606-adc.c
new file mode 100644
index 00000000000..68e099ad61c
--- /dev/null
+++ b/drivers/mfd/pcf50606-adc.c
@@ -0,0 +1,239 @@
+/* Philips PCF50606 ADC Driver
+ *
+ * (C) 2006-2008 by Openmoko, Inc.
+ * Author: Balaji Rao <balajirrao@openmoko.org>
+ * All rights reserved.
+ *
+ * Broken down from monstrous PCF50606 driver mainly by
+ * Harald Welte, Andy Green and Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <linux/mfd/pcf50606/core.h>
+#include <linux/mfd/pcf50606/adc.h>
+
+struct pcf50606_adc_request {
+ int mux;
+ int avg;
+ int result;
+ void (*callback)(struct pcf50606 *, void *, int);
+ void *callback_param;
+
+ /* Used in case of sync requests */
+ struct completion completion;
+
+};
+
+static void adc_read_setup(struct pcf50606 *pcf,
+ int channel, int avg)
+{
+ channel &= PCF50606_ADCC2_ADCMUX_MASK;
+
+ /* start ADC conversion of selected channel */
+ pcf50606_reg_write(pcf, PCF50606_REG_ADCC2, channel |
+ PCF50606_ADCC2_ADCSTART | PCF50606_ADCC2_RES_10BIT);
+
+}
+
+static void trigger_next_adc_job_if_any(struct pcf50606 *pcf)
+{
+ int head, tail;
+
+ mutex_lock(&pcf->adc.queue_mutex);
+
+ head = pcf->adc.queue_head;
+ tail = pcf->adc.queue_tail;
+
+ if (!pcf->adc.queue[head])
+ goto out;
+
+ adc_read_setup(pcf, pcf->adc.queue[head]->mux,
+ pcf->adc.queue[head]->avg);
+out:
+ mutex_unlock(&pcf->adc.queue_mutex);
+}
+
+static int
+adc_enqueue_request(struct pcf50606 *pcf, struct pcf50606_adc_request *req)
+{
+ int head, tail;
+
+ mutex_lock(&pcf->adc.queue_mutex);
+ head = pcf->adc.queue_head;
+ tail = pcf->adc.queue_tail;
+
+ if (pcf->adc.queue[tail]) {
+ mutex_unlock(&pcf->adc.queue_mutex);
+ return -EBUSY;
+ }
+
+ pcf->adc.queue[tail] = req;
+
+ pcf->adc.queue_tail =
+ (tail + 1) & (PCF50606_MAX_ADC_FIFO_DEPTH - 1);
+
+ mutex_unlock(&pcf->adc.queue_mutex);
+
+ trigger_next_adc_job_if_any(pcf);
+
+ return 0;
+}
+
+static void
+pcf50606_adc_sync_read_callback(struct pcf50606 *pcf, void *param, int result)
+{
+ struct pcf50606_adc_request *req;
+
+ /*We know here that the passed param is an adc_request object */
+ req = (struct pcf50606_adc_request *)param;
+
+ req->result = result;
+ complete(&req->completion);
+}
+
+int pcf50606_adc_sync_read(struct pcf50606 *pcf, int mux, int avg)
+{
+
+ struct pcf50606_adc_request *req;
+ int result;
+
+ /* req is freed when the result is ready, in pcf50606_work*/
+ req = kzalloc(sizeof(*req), GFP_KERNEL);
+ if (!req)
+ return -ENOMEM;
+
+ req->mux = mux;
+ req->avg = avg;
+ req->callback = pcf50606_adc_sync_read_callback;
+ req->callback_param = req;
+ init_completion(&req->completion);
+
+ adc_enqueue_request(pcf, req);
+
+ wait_for_completion(&req->completion);
+ result = req->result;
+
+ return result;
+}
+EXPORT_SYMBOL_GPL(pcf50606_adc_sync_read);
+
+int pcf50606_adc_async_read(struct pcf50606 *pcf, int mux, int avg,
+ void (*callback)(struct pcf50606 *, void *, int),
+ void *callback_param)
+{
+ struct pcf50606_adc_request *req;
+
+ /* req is freed when the result is ready, in pcf50606_work*/
+ req = kmalloc(sizeof(*req), GFP_KERNEL);
+ if (!req)
+ return -ENOMEM;
+
+ req->mux = mux;
+ req->avg = avg;
+ req->callback = callback;
+ req->callback_param = callback_param;
+
+ adc_enqueue_request(pcf, req);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(pcf50606_adc_async_read);
+
+static int adc_result(struct pcf50606 *pcf)
+{
+ u16 ret = (pcf50606_reg_read(pcf, PCF50606_REG_ADCS1) << 2) |
+ (pcf50606_reg_read(pcf, PCF50606_REG_ADCS2) & 0x03);
+
+ dev_info(pcf->dev, "adc result = %d\n", ret);
+
+ return ret;
+}
+
+static void pcf50606_adc_irq(struct pcf50606 *pcf, int irq, void *unused)
+{
+ struct pcf50606_adc_request *req;
+ int head;
+
+ mutex_lock(&pcf->adc.queue_mutex);
+ head = pcf->adc.queue_head;
+
+ req = pcf->adc.queue[head];
+ if (!req) {
+ dev_err(pcf->dev, "ADC queue empty\n");
+ mutex_unlock(&pcf->adc.queue_mutex);
+ return;
+ }
+ pcf->adc.queue[head] = NULL;
+ pcf->adc.queue_head = (head + 1) &
+ (PCF50606_MAX_ADC_FIFO_DEPTH - 1);
+
+ mutex_unlock(&pcf->adc.queue_mutex);
+ req->callback(pcf, req->callback_param, adc_result(pcf));
+
+ kfree(req);
+
+ trigger_next_adc_job_if_any(pcf);
+}
+
+int __init pcf50606_adc_probe(struct platform_device *pdev)
+{
+ struct pcf50606 *pcf;
+
+ pcf = platform_get_drvdata(pdev);
+
+ /* Set up IRQ handlers */
+ pcf->irq_handler[PCF50606_IRQ_ADCRDY].handler = pcf50606_adc_irq;
+
+ mutex_init(&pcf->adc.queue_mutex);
+ return 0;
+}
+
+static int __devexit pcf50606_adc_remove(struct platform_device *pdev)
+{
+ struct pcf50606 *pcf;
+
+ pcf = platform_get_drvdata(pdev);
+ pcf->irq_handler[PCF50606_IRQ_ADCRDY].handler = NULL;
+
+ return 0;
+}
+
+struct platform_driver pcf50606_adc_driver = {
+ .driver = {
+ .name = "pcf50606-adc",
+ },
+ .probe = pcf50606_adc_probe,
+ .remove = __devexit_p(pcf50606_adc_remove),
+};
+
+static int __init pcf50606_adc_init(void)
+{
+ return platform_driver_register(&pcf50606_adc_driver);
+}
+module_init(pcf50606_adc_init);
+
+static void __exit pcf50606_adc_exit(void)
+{
+ platform_driver_unregister(&pcf50606_adc_driver);
+}
+module_exit(pcf50606_adc_exit);
+
+MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
+MODULE_DESCRIPTION("PCF50606 adc driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pcf50606-adc");
+
diff --git a/drivers/mfd/pcf50606-core.c b/drivers/mfd/pcf50606-core.c
new file mode 100644
index 00000000000..47a8aa11954
--- /dev/null
+++ b/drivers/mfd/pcf50606-core.c
@@ -0,0 +1,580 @@
+/* Philips PCF50606 Power Management Unit (PMU) driver
+ *
+ * (C) 2006-2008 by Openmoko, Inc.
+ * Author: Harald Welte <laforge@openmoko.org>
+ * Matt Hsu <matt@openmoko.org>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+#include <linux/i2c.h>
+#include <linux/irq.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/reboot.h>
+#include <linux/interrupt.h>
+#include <linux/workqueue.h>
+#include <linux/platform_device.h>
+
+#include <linux/mfd/pcf50606/core.h>
+
+/* Read a block of upto 32 regs */
+int pcf50606_read_block(struct pcf50606 *pcf , u8 reg,
+ int nr_regs, u8 *data)
+{
+ int ret;
+
+ mutex_lock(&pcf->lock);
+ ret = i2c_smbus_read_i2c_block_data(pcf->i2c_client, reg,
+ nr_regs, data);
+ mutex_unlock(&pcf->lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(pcf50606_read_block);
+
+/* Write a block of upto 32 regs */
+int pcf50606_write_block(struct pcf50606 *pcf , u8 reg,
+ int nr_regs, u8 *data)
+{
+ int ret;
+
+ mutex_lock(&pcf->lock);
+ ret = i2c_smbus_write_i2c_block_data(pcf->i2c_client, reg,
+ nr_regs, data);
+ mutex_unlock(&pcf->lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(pcf50606_write_block);
+
+u8 pcf50606_reg_read(struct pcf50606 *pcf, u8 reg)
+{
+ int ret;
+
+ mutex_lock(&pcf->lock);
+ ret = i2c_smbus_read_byte_data(pcf->i2c_client, reg);
+ mutex_unlock(&pcf->lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(pcf50606_reg_read);
+
+int pcf50606_reg_write(struct pcf50606 *pcf, u8 reg, u8 val)
+{
+ int ret;
+ mutex_lock(&pcf->lock);
+ ret = i2c_smbus_write_byte_data(pcf->i2c_client, reg, val);
+ mutex_unlock(&pcf->lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(pcf50606_reg_write);
+
+int pcf50606_reg_set_bit_mask(struct pcf50606 *pcf, u8 reg, u8 mask, u8 val)
+{
+ int ret;
+ u8 tmp;
+
+ val &= mask;
+
+ mutex_lock(&pcf->lock);
+
+ tmp = i2c_smbus_read_byte_data(pcf->i2c_client, reg);
+ tmp &= ~mask;
+ tmp |= val;
+ ret = i2c_smbus_write_byte_data(pcf->i2c_client, reg, tmp);
+
+ mutex_unlock(&pcf->lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(pcf50606_reg_set_bit_mask);
+
+int pcf50606_reg_clear_bits(struct pcf50606 *pcf, u8 reg, u8 val)
+{
+ int ret;
+ u8 tmp;
+
+ mutex_lock(&pcf->lock);
+
+ tmp = i2c_smbus_read_byte_data(pcf->i2c_client, reg);
+ tmp &= ~val;
+ ret = i2c_smbus_write_byte_data(pcf->i2c_client, reg, tmp);
+
+ mutex_unlock(&pcf->lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(pcf50606_reg_clear_bits);
+
+static ssize_t show_resume_reason(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct pcf50606 *pcf = dev_get_drvdata(dev);
+ int n;
+
+ n = sprintf(buf, "%02x%02x%02x%02x%02x\n",
+ pcf->resume_reason[0],
+ pcf->resume_reason[1],
+ pcf->resume_reason[2],
+ pcf->resume_reason[3],
+ pcf->resume_reason[4]);
+
+ return n;
+}
+static DEVICE_ATTR(resume_reason, 0400, show_resume_reason, NULL);
+
+static struct attribute *pcf_sysfs_entries[] = {
+ &dev_attr_resume_reason.attr,
+ NULL,
+};
+
+static struct attribute_group pcf_attr_group = {
+ .name = NULL, /* put in device directory */
+ .attrs = pcf_sysfs_entries,
+};
+
+
+static int pcf50606_irq_mask_set(struct pcf50606 *pcf, int irq, int mask)
+{
+ u8 reg, bits, tmp;
+ int ret = 0, idx;
+
+ idx = irq / 8;
+ reg = PCF50606_REG_INT1M + idx;
+ bits = 1 << (irq % 8);
+
+ mutex_lock(&pcf->lock);
+
+ if (mask) {
+ tmp = i2c_smbus_read_byte_data(pcf->i2c_client, reg);
+ tmp |= bits;
+ ret = i2c_smbus_write_byte_data(pcf->i2c_client, reg, tmp);
+
+ pcf->mask_regs[idx] &= ~bits;
+ pcf->mask_regs[idx] |= bits;
+ } else {
+ tmp = i2c_smbus_read_byte_data(pcf->i2c_client, reg);
+ tmp &= ~bits;
+ ret = i2c_smbus_write_byte_data(pcf->i2c_client, reg, tmp);
+
+ pcf->mask_regs[idx] &= ~bits;
+ }
+
+ mutex_unlock(&pcf->lock);
+
+ return 0;
+}
+
+int pcf50606_irq_mask(struct pcf50606 *pcf, int irq)
+{
+ dev_info(pcf->dev, "Masking IRQ %d\n", irq);
+
+ return pcf50606_irq_mask_set(pcf, irq, 1);
+}
+EXPORT_SYMBOL_GPL(pcf50606_irq_mask);
+
+int pcf50606_irq_unmask(struct pcf50606 *pcf, int irq)
+{
+ dev_info(pcf->dev, "Unmasking IRQ %d\n", irq);
+
+ return pcf50606_irq_mask_set(pcf, irq, 0);
+}
+EXPORT_SYMBOL_GPL(pcf50606_irq_unmask);
+
+int pcf50606_irq_mask_get(struct pcf50606 *pcf, int irq)
+{
+ u8 reg, bits;
+
+ reg = (irq / 8);
+ bits = (1 << (irq % 8));
+
+ return pcf->mask_regs[reg] & bits;
+}
+EXPORT_SYMBOL_GPL(pcf50606_irq_mask_get);
+
+static void pcf50606_irq_call_handler(struct pcf50606 *pcf,
+ int irq)
+{
+ if (pcf->irq_handler[irq].handler)
+ pcf->irq_handler[irq].handler(pcf, irq,
+ pcf->irq_handler[irq].data);
+}
+
+#define PCF50606_ONKEY1S_TIMEOUT 8
+
+static void pcf50606_irq_worker(struct work_struct *work)
+{
+ struct pcf50606 *pcf;
+ int ret, i, j;
+ u8 pcf_int[3], chgstat;
+
+ pcf = container_of(work, struct pcf50606, irq_work);
+
+ /* Read the 3 INT regs in one transaction */
+ ret = pcf50606_read_block(pcf, PCF50606_REG_INT1,
+ sizeof(pcf_int), pcf_int);
+ if (ret != sizeof(pcf_int)) {
+ dev_info(pcf->dev, "Error reading INT registers\n");
+
+ /* We don't have an option but to retry. Because if
+ * we don't, there won't be another interrupt edge.
+ */
+ goto reschedule;
+ }
+
+ /* We immediately read the usb and adapter status. We thus make sure
+ * only of CHGINS/CHGRM handlers are called */
+ if (pcf_int[1] & (PCF50606_INT2_CHGINS | PCF50606_INT2_CHGRM)) {
+ chgstat = pcf50606_reg_read(pcf, PCF50606_REG_MBCS1);
+ if (chgstat & (0x1 << 4))
+ pcf_int[1] &= ~(1 << PCF50606_INT2_CHGRM);
+ else
+ pcf_int[1] &= ~(1 << PCF50606_INT2_CHGINS);
+ }
+
+ dev_info(pcf->dev, "INT1=0x%02x INT2=0x%02x INT3=0x%02x",
+ pcf_int[0], pcf_int[1], pcf_int[2]);
+
+ /* Some revisions of the chip don't have a 8s standby mode on
+ * ONKEY1S press. We try to manually do it in such cases. */
+
+ if (pcf_int[0] & PCF50606_INT1_SECOND && pcf->onkey1s_held) {
+ dev_info(pcf->dev, "ONKEY1S held for %d secs\n",
+ pcf->onkey1s_held);
+ if (pcf->onkey1s_held++ == PCF50606_ONKEY1S_TIMEOUT)
+ if (pcf->pdata->force_shutdown)
+ pcf->pdata->force_shutdown(pcf);
+ }
+
+ if (pcf_int[0] & PCF50606_INT1_ONKEY1S) {
+ dev_info(pcf->dev, "ONKEY1S held\n");
+ pcf->onkey1s_held = 1 ;
+
+ /* Unmask IRQ_SECOND */
+ pcf50606_reg_clear_bits(pcf, PCF50606_REG_INT1M,
+ PCF50606_INT1_SECOND);
+
+ /* Unmask IRQ_ONKEYF */
+ pcf50606_reg_clear_bits(pcf, PCF50606_REG_INT1M,
+ PCF50606_INT1_ONKEYF);
+ }
+
+ if ((pcf_int[0] & PCF50606_INT1_ONKEYR) && pcf->onkey1s_held) {
+ pcf->onkey1s_held = 0;
+
+ /* Mask SECOND and ONKEYF interrupts */
+ if (pcf->mask_regs[0] & PCF50606_INT1_SECOND)
+ pcf50606_reg_set_bit_mask(pcf,
+ PCF50606_REG_INT1M,
+ PCF50606_INT1_SECOND,
+ PCF50606_INT1_SECOND);
+
+ if (pcf->mask_regs[0] & PCF50606_INT1_ONKEYF)
+ pcf50606_reg_set_bit_mask(pcf,
+ PCF50606_REG_INT1M,
+ PCF50606_INT1_ONKEYF,
+ PCF50606_INT1_ONKEYF);
+ }
+
+ /* Have we just resumed ? */
+ if (pcf->is_suspended) {
+
+ pcf->is_suspended = 0;
+
+ /* Set the resume reason filtering out non resumers */
+ for (i = 0; i < ARRAY_SIZE(pcf_int); i++)
+ pcf->resume_reason[i] = pcf_int[i] &
+ pcf->pdata->resumers[i];
+
+ /* Make sure we don't pass on any input events to
+ * userspace now */
+ pcf_int[0] &= ~(PCF50606_INT1_SECOND | PCF50606_INT1_ALARM);
+ }
+
+ /* Unset masked interrupts */
+ for (i = 0; i < ARRAY_SIZE(pcf_int); i++)
+ pcf_int[i] &= ~pcf->mask_regs[i];
+
+ for (i = 0; i < ARRAY_SIZE(pcf_int); i++)
+ for (j = 0; j < 8 ; j++)
+ if (pcf_int[i] & (1 << j))
+ pcf50606_irq_call_handler(pcf, (i * 8) + j);
+
+ put_device(pcf->dev);
+
+ return;
+reschedule:
+ schedule_work(&pcf->irq_work);
+
+ /* Don't put_device here. Will be used when we are rescheduled */
+
+ return;
+}
+
+static irqreturn_t pcf50606_irq(int irq, void *data)
+{
+ struct pcf50606 *pcf = data;
+
+ get_device(pcf->dev);
+ schedule_work(&pcf->irq_work);
+
+ return IRQ_HANDLED;
+}
+
+static void
+pcf50606_client_dev_register(struct pcf50606 *pcf, const char *name,
+ struct platform_device **pdev)
+{
+ int ret;
+
+ *pdev = platform_device_alloc(name, -1);
+
+ if (!pdev) {
+ dev_err(pcf->dev, "Falied to allocate %s\n", name);
+ return;
+ }
+
+ (*pdev)->dev.parent = pcf->dev;
+ platform_set_drvdata(*pdev, pcf);
+
+ ret = platform_device_add(*pdev);
+ if (ret != 0) {
+ dev_err(pcf->dev, "Failed to register %s: %d\n", name, ret);
+ platform_device_put(*pdev);
+ *pdev = NULL;
+ }
+}
+
+#ifdef CONFIG_PM
+static int pcf50606_suspend(struct device *dev, pm_message_t state)
+{
+ struct pcf50606 *pcf;
+ int ret, i;
+ u8 res[3];
+
+ pcf = dev_get_drvdata(dev);
+
+ /* Make sure our interrupt handlers are not called
+ * henceforth */
+ disable_irq(pcf->irq);
+
+ /* Make sure that an IRQ worker has quit */
+ cancel_work_sync(&pcf->irq_work);
+
+ /* Save the masks */
+ ret = pcf50606_read_block(pcf, PCF50606_REG_INT1M,
+ ARRAY_SIZE(pcf->suspend_irq_masks),
+ pcf->suspend_irq_masks);
+ if (ret < 0)
+ dev_err(pcf->dev, "error saving irq masks\n");
+
+ /* Set interrupt masks. So that only those sources we want to wake
+ * us up can
+ */
+ for (i = 0; i < ARRAY_SIZE(res); i++)
+ res[i] = ~pcf->pdata->resumers[i];
+
+ pcf50606_write_block(pcf, PCF50606_REG_INT1M,
+ ARRAY_SIZE(res), &res[0]);
+
+ pcf->is_suspended = 1;
+
+ return 0;
+}
+
+static int pcf50606_resume(struct device *dev)
+{
+ struct pcf50606 *pcf;
+
+ pcf = dev_get_drvdata(dev);
+
+ /* Write the saved mask registers */
+ pcf50606_write_block(pcf, PCF50606_REG_INT1M,
+ ARRAY_SIZE(pcf->suspend_irq_masks),
+ pcf->suspend_irq_masks);
+
+ /* Clear any pending interrupts and set resume reason if any */
+ pcf50606_irq_worker(&pcf->irq_work);
+
+ enable_irq(pcf->irq);
+
+ return 0;
+}
+#else
+#define pcf50606_suspend NULL
+#define pcf50606_resume NULL
+#endif
+
+static int pcf50606_probe(struct i2c_client *client,
+ const struct i2c_device_id *ids)
+{
+ struct pcf50606 *pcf;
+ struct pcf50606_platform_data *pdata;
+ int i, ret = 0;
+ int version, variant;
+ u8 mbcs1;
+
+ pdata = client->dev.platform_data;
+
+ pcf = kzalloc(sizeof(*pcf), GFP_KERNEL);
+ if (!pcf)
+ return -ENOMEM;
+
+ pcf->pdata = pdata;
+ pdata->pcf = pcf;
+
+ mutex_init(&pcf->lock);
+
+ i2c_set_clientdata(client, pcf);
+ pcf->dev = &client->dev;
+ pcf->i2c_client = client;
+
+ INIT_WORK(&pcf->irq_work, pcf50606_irq_worker);
+
+ version = pcf50606_reg_read(pcf, 0);
+ if (version < 0) {
+ dev_err(pcf->dev, "Unable to probe pcf50606\n");
+ kfree(pcf);
+ return -ENODEV;
+ }
+
+ variant = pcf50606_reg_read(pcf, 1);
+ if (version < 0) {
+ dev_err(pcf->dev, "Unable to probe pcf50606\n");
+ kfree(pcf);
+ return -ENODEV;
+ }
+
+ dev_info(pcf->dev, "Probed device version %d variant %d\n",
+ version, variant);
+
+ /* Enable all inteerupts except RTC SECOND */
+ pcf->mask_regs[0] = 0x80;
+ pcf50606_reg_write(pcf, PCF50606_REG_INT1M, 0x80);
+
+ pcf50606_reg_write(pcf, PCF50606_REG_INT2M, 0x00);
+ pcf50606_reg_write(pcf, PCF50606_REG_INT3M, 0x00);
+
+ pcf50606_client_dev_register(pcf, "pcf50606-input",
+ &pcf->input.pdev);
+ pcf50606_client_dev_register(pcf, "pcf50606-rtc",
+ &pcf->rtc.pdev);
+ pcf50606_client_dev_register(pcf, "pcf50606-mbc",
+ &pcf->mbc.pdev);
+ pcf50606_client_dev_register(pcf, "pcf50606-adc",
+ &pcf->adc.pdev);
+ pcf50606_client_dev_register(pcf, "pcf50606-wdt",
+ &pcf->wdt.pdev);
+ for (i = 0; i < PCF50606_NUM_REGULATORS; i++) {
+ struct platform_device *pdev;
+
+ pdev = platform_device_alloc("pcf50606-regltr", i);
+ if (!pdev) {
+ dev_err(pcf->dev, "Cannot create regulator\n");
+ continue;
+ }
+
+ pdev->dev.parent = pcf->dev;
+ pdev->dev.platform_data = &pdata->reg_init_data[i];
+ pdev->dev.driver_data = pcf;
+ pcf->pmic.pdev[i] = pdev;
+
+ platform_device_add(pdev);
+ }
+
+ pcf->irq = client->irq;
+
+ if (client->irq) {
+ ret = request_irq(client->irq, pcf50606_irq,
+ IRQF_TRIGGER_FALLING, "pcf50606", pcf);
+
+ if (ret) {
+ dev_err(pcf->dev, "Failed to request IRQ %d\n", ret);
+ goto err;
+ }
+ } else {
+ dev_err(pcf->dev, "No IRQ configured\n");
+ goto err;
+ }
+
+ if (enable_irq_wake(client->irq) < 0)
+ dev_err(pcf->dev, "IRQ %u cannot be enabled as wake-up source"
+ "in this hardware revision", client->irq);
+
+ /* Cold Intialization */
+ mbcs1 = pcf50606_reg_read(pcf, PCF50606_REG_MBCS1);
+
+ if (mbcs1 & (0x01 << 4)) /* Charger present ? */
+ pcf50606_irq_call_handler(pcf, PCF50606_IRQ_CHGINS);
+
+ ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group);
+ if (ret)
+ dev_err(pcf->dev, "error creating sysfs entries\n");
+
+ if (pdata->probe_done)
+ pdata->probe_done(pcf);
+
+ return 0;
+
+err:
+ kfree(pcf);
+ return ret;
+}
+
+static int pcf50606_remove(struct i2c_client *client)
+{
+ struct pcf50606 *pcf = i2c_get_clientdata(client);
+
+ free_irq(pcf->irq, pcf);
+ kfree(pcf);
+
+ return 0;
+}
+
+static struct i2c_device_id pcf50606_id_table[] = {
+ {"pcf50606", 0x73},
+};
+
+static struct i2c_driver pcf50606_driver = {
+ .driver = {
+ .name = "pcf50606",
+ .suspend = pcf50606_suspend,
+ .resume = pcf50606_resume,
+ },
+ .id_table = pcf50606_id_table,
+ .probe = pcf50606_probe,
+ .remove = pcf50606_remove,
+};
+
+static int __init pcf50606_init(void)
+{
+ return i2c_add_driver(&pcf50606_driver);
+}
+
+static void pcf50606_exit(void)
+{
+ i2c_del_driver(&pcf50606_driver);
+}
+
+MODULE_DESCRIPTION("I2C chip driver for NXP PCF50606 PMU");
+MODULE_AUTHOR("Harald Welte <laforge@openmoko.org>");
+MODULE_LICENSE("GPL");
+
+module_init(pcf50606_init);
+module_exit(pcf50606_exit);
diff --git a/drivers/mfd/pcf50606-gpo.c b/drivers/mfd/pcf50606-gpo.c
new file mode 100644
index 00000000000..28b6d77ad80
--- /dev/null
+++ b/drivers/mfd/pcf50606-gpo.c
@@ -0,0 +1,128 @@
+/* Philips PCF50606 GPO Driver
+ *
+ * (C) 2006-2008 by Openmoko, Inc.
+ * Author: Balaji Rao <balajirrao@openmoko.org>
+ * All rights reserved.
+ *
+ * Broken down from monstrous PCF50606 driver mainly by
+ * Harald Welte, Andy Green and Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <linux/mfd/pcf50606/core.h>
+#include <linux/mfd/pcf50606/gpo.h>
+#include <linux/mfd/pcf50606/pmic.h>
+
+void pcf50606_gpo_set_active(struct pcf50606 *pcf, int gpo, int val)
+{
+ u8 reg, value, mask;
+
+ reg = gpo;
+ value = val;
+ mask = 0x07;
+
+ if (gpo == PCF50606_GPO2) {
+ value = val << 4;
+ mask = 0x07 << 4;
+ }
+ pcf50606_reg_set_bit_mask(pcf, reg, mask, value);
+}
+EXPORT_SYMBOL_GPL(pcf50606_gpo_set_active);
+
+int pcf50606_gpo_get_active(struct pcf50606 *pcf, int gpo)
+{
+ u8 reg, value, shift = 0;
+
+ reg = gpo;
+ if (gpo == PCF50606_GPO2)
+ shift = 4;
+
+ value = pcf50606_reg_read(pcf, reg);
+
+ return (value >> shift) & 0x07;
+}
+EXPORT_SYMBOL_GPL(pcf50606_gpo_get_active);
+
+void pcf50606_gpo_set_standby(struct pcf50606 *pcf, int gpo, int val)
+{
+ u8 reg;
+
+ if (gpo == PCF50606_GPO1 || gpo == PCF50606_GPO2) {
+ dev_err(pcf->dev, "Can't set standby settings for GPO[12]n");
+ return;
+ }
+
+ reg = gpo;
+
+ pcf50606_reg_set_bit_mask(pcf, gpo, 0x07 << 3, val);
+}
+EXPORT_SYMBOL_GPL(pcf50606_gpo_set_standby);
+
+int pcf50606_gpo_get_standby(struct pcf50606 *pcf, int gpo)
+{
+ u8 reg, value;
+
+ if (gpo == PCF50606_GPO1 || gpo == PCF50606_GPO2) {
+ dev_err(pcf->dev, "Can't get standby settings for GPO[12]n");
+ return -EINVAL;
+ }
+
+ reg = gpo;
+ value = pcf50606_reg_read(pcf, reg);
+
+ return (value >> 3) & 0x07;
+}
+EXPORT_SYMBOL_GPL(pcf50606_gpo_get_standby);
+
+void pcf50606_gpo_invert_set(struct pcf50606 *pcf, int gpo, int invert)
+{
+ u8 reg, value, mask;
+
+ reg = gpo;
+ value = !!invert << 6;
+ mask = 0x01 << 6;
+
+ if (gpo == PCF50606_GPO1) {
+ mask = 0x01 << 4;
+ value = !!invert << 4;
+ }
+ else if (gpo == PCF50606_GPO2) {
+ mask = 0x01 << 7;
+ value = !!invert << 7;
+ }
+
+ pcf50606_reg_set_bit_mask(pcf, reg, mask, value);
+}
+EXPORT_SYMBOL_GPL(pcf50606_gpo_invert_set);
+
+int pcf50606_gpo_invert_get(struct pcf50606 *pcf, int gpo)
+{
+ u8 reg, value, shift;
+
+ reg = gpo;
+ shift = 6;
+
+ if (gpo == PCF50606_GPO1)
+ shift = 4;
+ else if (gpo == PCF50606_GPO2)
+ shift = 7;
+
+ value = pcf50606_reg_read(pcf, reg);
+
+ return (value >> shift) & 0x01;
+}
+EXPORT_SYMBOL_GPL(pcf50606_gpo_invert_get);
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c
index 39bdbae67da..ebd3792e778 100644
--- a/drivers/mfd/pcf50633-adc.c
+++ b/drivers/mfd/pcf50633-adc.c
@@ -5,7 +5,7 @@
* All rights reserved.
*
* Broken down from monstrous PCF50633 driver mainly by
- * Harald Welte and Andy Green
+ * Harald Welte, Andy Green and Werner Almesberger
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -133,7 +133,7 @@ int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg)
return result;
}
-EXPORT_SYMBOL(pcf50633_adc_sync_read);
+EXPORT_SYMBOL_GPL(pcf50633_adc_sync_read);
int pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg,
void (*callback)(struct pcf50633 *, void *, int),
@@ -155,7 +155,7 @@ int pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg,
return 0;
}
-EXPORT_SYMBOL(pcf50633_adc_async_read);
+EXPORT_SYMBOL_GPL(pcf50633_adc_async_read);
static int adc_result(struct pcf50633 *pcf)
{
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index 6d66b526bc2..dd6a7949182 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -48,7 +48,7 @@ int pcf50633_read_block(struct pcf50633 *pcf , u8 reg,
return ret;
}
-EXPORT_SYMBOL(pcf50633_read_block);
+EXPORT_SYMBOL_GPL(pcf50633_read_block);
/* Write a block of upto 32 regs */
int pcf50633_write_block(struct pcf50633 *pcf , u8 reg,
@@ -63,7 +63,7 @@ int pcf50633_write_block(struct pcf50633 *pcf , u8 reg,
return ret;
}
-EXPORT_SYMBOL(pcf50633_write_block);
+EXPORT_SYMBOL_GPL(pcf50633_write_block);
u8 pcf50633_reg_read(struct pcf50633 *pcf, u8 reg)
{
@@ -75,7 +75,7 @@ u8 pcf50633_reg_read(struct pcf50633 *pcf, u8 reg)
return ret;
}
-EXPORT_SYMBOL(pcf50633_reg_read);
+EXPORT_SYMBOL_GPL(pcf50633_reg_read);
int pcf50633_reg_write(struct pcf50633 *pcf, u8 reg, u8 val)
{
@@ -86,7 +86,7 @@ int pcf50633_reg_write(struct pcf50633 *pcf, u8 reg, u8 val)
return ret;
}
-EXPORT_SYMBOL(pcf50633_reg_write);
+EXPORT_SYMBOL_GPL(pcf50633_reg_write);
int pcf50633_reg_set_bit_mask(struct pcf50633 *pcf, u8 reg, u8 mask, u8 val)
{
@@ -106,7 +106,7 @@ int pcf50633_reg_set_bit_mask(struct pcf50633 *pcf, u8 reg, u8 mask, u8 val)
return ret;
}
-EXPORT_SYMBOL(pcf50633_reg_set_bit_mask);
+EXPORT_SYMBOL_GPL(pcf50633_reg_set_bit_mask);
int pcf50633_reg_clear_bits(struct pcf50633 *pcf, u8 reg, u8 val)
{
@@ -123,7 +123,7 @@ int pcf50633_reg_clear_bits(struct pcf50633 *pcf, u8 reg, u8 val)
return ret;
}
-EXPORT_SYMBOL(pcf50633_reg_clear_bits);
+EXPORT_SYMBOL_GPL(pcf50633_reg_clear_bits);
/* sysfs attributes */
static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr,
@@ -226,7 +226,7 @@ int pcf50633_irq_mask(struct pcf50633 *pcf, int irq)
return pcf50633_irq_mask_set(pcf, irq, 1);
}
-EXPORT_SYMBOL(pcf50633_irq_mask);
+EXPORT_SYMBOL_GPL(pcf50633_irq_mask);
int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq)
{
@@ -234,7 +234,7 @@ int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq)
return pcf50633_irq_mask_set(pcf, irq, 0);
}
-EXPORT_SYMBOL(pcf50633_irq_unmask);
+EXPORT_SYMBOL_GPL(pcf50633_irq_unmask);
int pcf50633_irq_mask_get(struct pcf50633 *pcf, int irq)
{
@@ -245,7 +245,7 @@ int pcf50633_irq_mask_get(struct pcf50633 *pcf, int irq)
return pcf->mask_regs[reg] & bits;
}
-EXPORT_SYMBOL(pcf50633_irq_mask_get);
+EXPORT_SYMBOL_GPL(pcf50633_irq_mask_get);
static void pcf50633_irq_call_handler(struct pcf50633 *pcf,
int irq)
@@ -485,7 +485,7 @@ static int pcf50633_probe(struct i2c_client *client,
pcf->pdata = pdata;
pdata->pcf = pcf;
-
+
mutex_init(&pcf->lock);
i2c_set_clientdata(client, pcf);
@@ -502,7 +502,7 @@ static int pcf50633_probe(struct i2c_client *client,
}
variant = pcf50633_reg_read(pcf, 1);
- if (version < 0) {
+ if (variant < 0) {
dev_err(pcf->dev, "Unable to probe pcf50633\n");
kfree(pcf);
return -ENODEV;
diff --git a/drivers/mfd/pcf50633-gpio.c b/drivers/mfd/pcf50633-gpio.c
index a5b978c4e3c..a7117fa6282 100644
--- a/drivers/mfd/pcf50633-gpio.c
+++ b/drivers/mfd/pcf50633-gpio.c
@@ -5,7 +5,7 @@
* All rights reserved.
*
* Broken down from monstrous PCF50633 driver mainly by
- * Harald Welte and Andy Green
+ * Harald Welte, Andy Green and Werner Almesberger
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -30,7 +30,7 @@
void pcf50633_gpio_set(struct pcf50633 *pcf, int gpio, int val)
{
u8 reg;
-
+
reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
pcf50633_reg_set_bit_mask(pcf, reg, 0x07, val);
@@ -91,7 +91,7 @@ void pcf50633_gpio_power_supply_set(struct pcf50633 *pcf,
/* the *ENA register is always one after the *OUT register */
reg = pcf50633_regulator_registers[regulator] + 1;
-
+
val = (!!on << (gpio - PCF50633_GPIO1));
pcf50633_reg_set_bit_mask(pcf, reg, val, val);
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index a1ddb136d9e..b8f2044e451 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -371,5 +371,5 @@ module_exit(sdhci_s3c_exit);
MODULE_DESCRIPTION("Samsung SDHCI (HSMMC) glue");
MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
-MODULE_LICENSE("GPLv2");
+MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:s3c-sdhci");
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
index 24d6a8aa7e5..03d64111501 100644
--- a/drivers/power/pcf50633-charger.c
+++ b/drivers/power/pcf50633-charger.c
@@ -5,7 +5,7 @@
* All rights reserved.
*
* Broken down from monstrous PCF50633 driver mainly by
- * Harald Welte and Andy Green
+ * Harald Welte, Andy Green and Werner Almesberger
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -49,7 +49,7 @@ void pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma)
power_supply_changed(&pcf->mbc.usb);
}
-EXPORT_SYMBOL(pcf50633_mbc_usb_curlim_set);
+EXPORT_SYMBOL_GPL(pcf50633_mbc_usb_curlim_set);
static const char *chgmode_names[] = {
[PCF50633_MBCS2_MBC_PLAY] = "play-only",
@@ -130,7 +130,7 @@ static void pcf50633_mbc_irq_handler(struct pcf50633 *pcf, int irq, void *data)
struct pcf50633_mbc *mbc;
mbc = &pcf->mbc;
-
+
/* USB */
if (irq == PCF50633_IRQ_USBINS)
mbc->usb_online = 1;
@@ -298,4 +298,3 @@ MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
MODULE_DESCRIPTION("PCF50633 mbc driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:pcf50633-mbc");
-
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 82e77c11a47..61b30c6ddec 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -11,6 +11,6 @@ obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
-obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
+obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
index 8dee6e03870..f8e1fafb03f 100644
--- a/drivers/regulator/pcf50633-regulator.c
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -253,29 +253,29 @@ struct regulator_ops pcf50633_regulator_ops = {
.set_suspend_disable = pcf50633_regulator_disable,
};
-struct regulator_desc regulators[] = {
- [PCF50633_REGULATOR_AUTO] =
+static struct regulator_desc regulators[] = {
+ [PCF50633_REGULATOR_AUTO] =
PCF50633_REGULATOR("auto", PCF50633_REGULATOR_AUTO),
[PCF50633_REGULATOR_DOWN1] =
- PCF50633_REGULATOR("down1", PCF50633_REGULATOR_DOWN1),
+ PCF50633_REGULATOR("down1", PCF50633_REGULATOR_DOWN1),
[PCF50633_REGULATOR_DOWN2] =
PCF50633_REGULATOR("down2", PCF50633_REGULATOR_DOWN2),
[PCF50633_REGULATOR_LDO1] =
- PCF50633_REGULATOR("ldo1", PCF50633_REGULATOR_LDO1),
+ PCF50633_REGULATOR("ldo1", PCF50633_REGULATOR_LDO1),
[PCF50633_REGULATOR_LDO2] =
- PCF50633_REGULATOR("ldo2", PCF50633_REGULATOR_LDO2),
+ PCF50633_REGULATOR("ldo2", PCF50633_REGULATOR_LDO2),
[PCF50633_REGULATOR_LDO3] =
- PCF50633_REGULATOR("ldo3", PCF50633_REGULATOR_LDO3),
+ PCF50633_REGULATOR("ldo3", PCF50633_REGULATOR_LDO3),
[PCF50633_REGULATOR_LDO4] =
- PCF50633_REGULATOR("ldo4", PCF50633_REGULATOR_LDO4),
+ PCF50633_REGULATOR("ldo4", PCF50633_REGULATOR_LDO4),
[PCF50633_REGULATOR_LDO5] =
- PCF50633_REGULATOR("ldo5", PCF50633_REGULATOR_LDO5),
+ PCF50633_REGULATOR("ldo5", PCF50633_REGULATOR_LDO5),
[PCF50633_REGULATOR_LDO6] =
- PCF50633_REGULATOR("ldo6", PCF50633_REGULATOR_LDO6),
+ PCF50633_REGULATOR("ldo6", PCF50633_REGULATOR_LDO6),
[PCF50633_REGULATOR_HCLDO] =
- PCF50633_REGULATOR("hcldo", PCF50633_REGULATOR_HCLDO),
+ PCF50633_REGULATOR("hcldo", PCF50633_REGULATOR_HCLDO),
[PCF50633_REGULATOR_MEMLDO] =
- PCF50633_REGULATOR("memldo", PCF50633_REGULATOR_MEMLDO),
+ PCF50633_REGULATOR("memldo", PCF50633_REGULATOR_MEMLDO),
};
int __init pcf50633_regulator_probe(struct platform_device *pdev)
@@ -283,7 +283,7 @@ int __init pcf50633_regulator_probe(struct platform_device *pdev)
struct regulator_dev *rdev;
struct pcf50633 *pcf;
- pcf = pdev->dev.driver_data;
+ pcf = pdev->dev.driver_data;
rdev = regulator_register(&regulators[pdev->id], &pdev->dev, pcf);
if (IS_ERR(rdev))
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index c7108a4d613..cc3c077df37 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -225,6 +225,12 @@ config RTC_DRV_PCF50633
If you say yes here you get support for the Philips PCF50633
PMU's RTC.
+config RTC_DRV_PCF50606
+ tristate "Philips PCF50606"
+ help
+ If you say yes here you get support for the Philips PCF50606
+ PMU's RTC.
+
config RTC_DRV_M41T80
tristate "ST M41T65/M41T80/81/82/83/84/85/87"
help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index ab3a003991e..50f337b338f 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o
+obj-$(CONFIG_RTC_DRV_PCF50606) += rtc-pcf50606.o
obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030.o
obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o
obj-$(CONFIG_RTC_DRV_PARISC) += rtc-parisc.o
diff --git a/drivers/rtc/rtc-pcf50606.c b/drivers/rtc/rtc-pcf50606.c
new file mode 100644
index 00000000000..498ec77c82f
--- /dev/null
+++ b/drivers/rtc/rtc-pcf50606.c
@@ -0,0 +1,297 @@
+/* Philips PCF50606 RTC Driver
+ *
+ * (C) 2006-2008 by Openmoko, Inc.
+ * Author: Balaji Rao <balajirrao@openmoko.org>
+ * All rights reserved.
+ *
+ * Broken down from monstrous PCF50606 driver mainly by
+ * Harald Welte, Andy Green and Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 060, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <linux/rtc.h>
+#include <linux/platform_device.h>
+#include <linux/bcd.h>
+
+#include <linux/mfd/pcf50606/core.h>
+#include <linux/mfd/pcf50606/rtc.h>
+
+enum pcf50606_time_indexes {
+ PCF50606_TI_SEC = 0,
+ PCF50606_TI_MIN,
+ PCF50606_TI_HOUR,
+ PCF50606_TI_WKDAY,
+ PCF50606_TI_DAY,
+ PCF50606_TI_MONTH,
+ PCF50606_TI_YEAR,
+ PCF50606_TI_EXTENT /* always last */
+};
+
+
+struct pcf50606_time {
+ u_int8_t time[PCF50606_TI_EXTENT];
+};
+
+static void pcf2rtc_time(struct rtc_time *rtc, struct pcf50606_time *pcf)
+{
+ rtc->tm_sec = bcd2bin(pcf->time[PCF50606_TI_SEC]);
+ rtc->tm_min = bcd2bin(pcf->time[PCF50606_TI_MIN]);
+ rtc->tm_hour = bcd2bin(pcf->time[PCF50606_TI_HOUR]);
+ rtc->tm_wday = bcd2bin(pcf->time[PCF50606_TI_WKDAY]);
+ rtc->tm_mday = bcd2bin(pcf->time[PCF50606_TI_DAY]);
+ rtc->tm_mon = bcd2bin(pcf->time[PCF50606_TI_MONTH]);
+ rtc->tm_year = bcd2bin(pcf->time[PCF50606_TI_YEAR]) + 100;
+}
+
+static void rtc2pcf_time(struct pcf50606_time *pcf, struct rtc_time *rtc)
+{
+ pcf->time[PCF50606_TI_SEC] = bin2bcd(rtc->tm_sec);
+ pcf->time[PCF50606_TI_MIN] = bin2bcd(rtc->tm_min);
+ pcf->time[PCF50606_TI_HOUR] = bin2bcd(rtc->tm_hour);
+ pcf->time[PCF50606_TI_WKDAY] = bin2bcd(rtc->tm_wday);
+ pcf->time[PCF50606_TI_DAY] = bin2bcd(rtc->tm_mday);
+ pcf->time[PCF50606_TI_MONTH] = bin2bcd(rtc->tm_mon);
+ pcf->time[PCF50606_TI_YEAR] = bin2bcd(rtc->tm_year - 100);
+}
+
+static int pcf50606_rtc_ioctl(struct device *dev, unsigned int cmd,
+ unsigned long arg)
+{
+ struct pcf50606 *pcf;
+
+ pcf = dev_get_drvdata(dev);
+
+ switch (cmd) {
+ case RTC_AIE_OFF:
+ /* disable the alarm interrupt */
+ pcf->rtc.alarm_enabled = 0;
+ pcf50606_irq_mask(pcf, PCF50606_IRQ_ALARM);
+ return 0;
+ case RTC_AIE_ON:
+ /* enable the alarm interrupt */
+ pcf->rtc.alarm_enabled = 1;
+ pcf50606_irq_unmask(pcf, PCF50606_IRQ_ALARM);
+ return 0;
+ case RTC_PIE_OFF:
+ /* disable periodic interrupt (hz tick) */
+ pcf->rtc.second_enabled = 0;
+ pcf50606_irq_mask(pcf, PCF50606_IRQ_SECOND);
+ return 0;
+ case RTC_PIE_ON:
+ /* ensable periodic interrupt (hz tick) */
+ pcf->rtc.second_enabled = 1;
+ pcf50606_irq_unmask(pcf, PCF50606_IRQ_SECOND);
+ return 0;
+ }
+ return -ENOIOCTLCMD;
+}
+
+static int pcf50606_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct pcf50606 *pcf;
+ struct pcf50606_time pcf_tm;
+ int ret;
+
+ pcf = dev_get_drvdata(dev);
+
+ ret = pcf50606_read_block(pcf, PCF50606_REG_RTCSC,
+ PCF50606_TI_EXTENT,
+ &pcf_tm.time[0]);
+ if (ret != PCF50606_TI_EXTENT)
+ dev_err(dev, "Failed to read time\n");
+
+ dev_dbg(dev, "PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
+ pcf_tm.time[PCF50606_TI_DAY],
+ pcf_tm.time[PCF50606_TI_MONTH],
+ pcf_tm.time[PCF50606_TI_YEAR],
+ pcf_tm.time[PCF50606_TI_HOUR],
+ pcf_tm.time[PCF50606_TI_MIN],
+ pcf_tm.time[PCF50606_TI_SEC]);
+
+ pcf2rtc_time(tm, &pcf_tm);
+
+ dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
+ tm->tm_mday, tm->tm_mon, tm->tm_year,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+ return 0;
+}
+
+static int pcf50606_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct pcf50606 *pcf;
+ struct pcf50606_time pcf_tm;
+ int ret;
+ int second_masked, alarm_masked;
+
+ pcf = dev_get_drvdata(dev);
+
+ dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
+ tm->tm_mday, tm->tm_mon, tm->tm_year,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+ rtc2pcf_time(&pcf_tm, tm);
+ dev_dbg(dev, "PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
+ pcf_tm.time[PCF50606_TI_DAY],
+ pcf_tm.time[PCF50606_TI_MONTH],
+ pcf_tm.time[PCF50606_TI_YEAR],
+ pcf_tm.time[PCF50606_TI_HOUR],
+ pcf_tm.time[PCF50606_TI_MIN],
+ pcf_tm.time[PCF50606_TI_SEC]);
+
+
+ second_masked = pcf50606_irq_mask_get(pcf, PCF50606_IRQ_SECOND);
+ alarm_masked = pcf50606_irq_mask_get(pcf, PCF50606_IRQ_ALARM);
+
+ if (!second_masked)
+ pcf50606_irq_mask(pcf, PCF50606_IRQ_SECOND);
+ if (!alarm_masked)
+ pcf50606_irq_mask(pcf, PCF50606_IRQ_ALARM);
+
+ ret = pcf50606_write_block(pcf, PCF50606_REG_RTCSC,
+ PCF50606_TI_EXTENT,
+ &pcf_tm.time[0]);
+ if (ret)
+ dev_err(dev, "Failed to set time %d\n", ret);
+
+ if (!second_masked)
+ pcf50606_irq_unmask(pcf, PCF50606_IRQ_SECOND);
+ if (!alarm_masked)
+ pcf50606_irq_unmask(pcf, PCF50606_IRQ_ALARM);
+
+
+ return 0;
+}
+
+static int pcf50606_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct pcf50606 *pcf;
+ struct pcf50606_time pcf_tm;
+ int ret;
+
+ pcf = dev_get_drvdata(dev);
+
+ alrm->enabled = pcf->rtc.alarm_enabled;
+
+ ret = pcf50606_read_block(pcf, PCF50606_REG_RTCSCA,
+ PCF50606_TI_EXTENT, &pcf_tm.time[0]);
+
+ if (ret != PCF50606_TI_EXTENT)
+ dev_err(dev, "Failed to read Alarm time :-(\n");
+
+ pcf2rtc_time(&alrm->time, &pcf_tm);
+
+ return 0;
+}
+
+static int pcf50606_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct pcf50606 *pcf;
+ struct pcf50606_time pcf_tm;
+ int ret, alarm_masked;
+
+ pcf = dev_get_drvdata(dev);
+
+ rtc2pcf_time(&pcf_tm, &alrm->time);
+
+ alarm_masked = pcf50606_irq_mask_get(pcf, PCF50606_IRQ_ALARM);
+
+ /* disable alarm interrupt */
+ if (!alarm_masked)
+ pcf50606_irq_mask(pcf, PCF50606_IRQ_ALARM);
+
+ ret = pcf50606_write_block(pcf, PCF50606_REG_RTCSCA,
+ PCF50606_TI_EXTENT, &pcf_tm.time[0]);
+ if (ret)
+ dev_err(dev, "Failed to write alarm time %d\n", ret);
+
+ if (!alarm_masked)
+ pcf50606_irq_unmask(pcf, PCF50606_IRQ_ALARM);
+
+ 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,
+};
+
+static void pcf50606_rtc_irq(struct pcf50606 *pcf, int irq, void *unused)
+{
+ switch (irq) {
+ case PCF50606_IRQ_ALARM:
+ rtc_update_irq(pcf->rtc.rtc_dev, 1, RTC_AF | RTC_IRQF);
+ break;
+ case PCF50606_IRQ_SECOND:
+ rtc_update_irq(pcf->rtc.rtc_dev, 1, RTC_PF | RTC_IRQF);
+ break;
+ }
+}
+
+static int pcf50606_rtc_probe(struct platform_device *pdev)
+{
+ struct rtc_device *rtc;
+ struct pcf50606 *pcf;
+
+ rtc = rtc_device_register("pcf50606", &pdev->dev,
+ &pcf50606_rtc_ops, THIS_MODULE);
+ if (IS_ERR(rtc))
+ return -ENODEV;
+
+ pcf = platform_get_drvdata(pdev);
+
+ /* Set up IRQ handlers */
+ pcf->irq_handler[PCF50606_IRQ_ALARM].handler = pcf50606_rtc_irq;
+ pcf->irq_handler[PCF50606_IRQ_SECOND].handler = pcf50606_rtc_irq;
+
+ pcf->rtc.rtc_dev = rtc;
+
+ return 0;
+}
+
+static int pcf50606_rtc_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+
+
+static struct platform_driver pcf50606_rtc_driver = {
+ .driver = {
+ .name = "pcf50606-rtc",
+ },
+ .probe = pcf50606_rtc_probe,
+ .remove = __devexit_p(pcf50606_rtc_remove),
+};
+
+static int __init pcf50606_rtc_init(void)
+{
+ return platform_driver_register(&pcf50606_rtc_driver);
+}
+module_init(pcf50606_rtc_init);
+
+static void __exit pcf50606_rtc_exit(void)
+{
+ platform_driver_unregister(&pcf50606_rtc_driver);
+}
+module_exit(pcf50606_rtc_exit);
+
+
+MODULE_DESCRIPTION("RTC driver for NXP PCF50606 power management unit");
+MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
+MODULE_LICENSE("GPL");
+
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c
index bd99be1837a..00b159920b4 100644
--- a/drivers/rtc/rtc-pcf50633.c
+++ b/drivers/rtc/rtc-pcf50633.c
@@ -5,7 +5,7 @@
* All rights reserved.
*
* Broken down from monstrous PCF50633 driver mainly by
- * Harald Welte and Andy Green
+ * Harald Welte, Andy Green and Werner Almesberger
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -207,9 +207,6 @@ static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
rtc2pcf_time(&pcf_tm, &alrm->time);
- printk("wkday is %x\n", alrm->time.tm_wday);
- printk("wkday is %x\n", pcf_tm.time[PCF50633_TI_WKDAY]);
-
alarm_masked = pcf50633_irq_mask_get(pcf, PCF50633_IRQ_ALARM);
/* disable alarm interrupt */
@@ -236,13 +233,13 @@ static struct rtc_class_ops pcf50633_rtc_ops = {
static void pcf50633_rtc_irq(struct pcf50633 *pcf, int irq, void *unused)
{
- switch(irq) {
- case PCF50633_IRQ_ALARM:
- rtc_update_irq(pcf->rtc.rtc_dev, 1, RTC_AF | RTC_IRQF);
- break;
- case PCF50633_IRQ_SECOND:
- rtc_update_irq(pcf->rtc.rtc_dev, 1, RTC_PF | RTC_IRQF);
- break;
+ switch (irq) {
+ case PCF50633_IRQ_ALARM:
+ rtc_update_irq(pcf->rtc.rtc_dev, 1, RTC_AF | RTC_IRQF);
+ break;
+ case PCF50633_IRQ_SECOND:
+ rtc_update_irq(pcf->rtc.rtc_dev, 1, RTC_PF | RTC_IRQF);
+ break;
}
}
@@ -250,12 +247,12 @@ static int pcf50633_rtc_probe(struct platform_device *pdev)
{
struct rtc_device *rtc;
struct pcf50633 *pcf;
-
+
rtc = rtc_device_register("pcf50633", &pdev->dev,
&pcf50633_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc))
return -ENODEV;
-
+
pcf = platform_get_drvdata(pdev);
/* Set up IRQ handlers */
@@ -263,6 +260,7 @@ static int pcf50633_rtc_probe(struct platform_device *pdev)
pcf->irq_handler[PCF50633_IRQ_SECOND].handler = pcf50633_rtc_irq;
pcf->rtc.rtc_dev = rtc;
+
return 0;
}
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 4fd3fa5546b..7ec506f5014 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -233,6 +233,12 @@ config ORION5X_WATCHDOG
To compile this driver as a module, choose M here: the
module will be called orion5x_wdt.
+config PCF50606_WATCHDOG
+ tristate "NXP PCF50606 Watchdog"
+ depends on MFD_PCF50606
+ help
+ Say Y here to include support for NXP PCF50606 watchdog timer.
+
# ARM26 Architecture
# AVR32 Architecture
@@ -784,7 +790,7 @@ config WATCHDOG_RTAS
tristate "RTAS watchdog"
depends on PPC_RTAS
help
- This driver adds watchdog support for the RTAS watchdog.
+ his driver adds watchdog support for the RTAS watchdog.
To compile this driver as a module, choose M here. The module
will be called wdrtas.
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index e352bbb7630..496ec41bdbc 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o
obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o
obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o
obj-$(CONFIG_ORION5X_WATCHDOG) += orion5x_wdt.o
+obj-$(CONFIG_PCF50606_WATCHDOG) += pcf50606_wdt.o
# ARM26 Architecture
diff --git a/drivers/watchdog/pcf50606_wdt.c b/drivers/watchdog/pcf50606_wdt.c
new file mode 100644
index 00000000000..ba8a472abf6
--- /dev/null
+++ b/drivers/watchdog/pcf50606_wdt.c
@@ -0,0 +1,213 @@
+/* Philips PCF50606 Watchdog Timer Driver
+ *
+ * (C) 2006-2008 by Openmoko, Inc.
+ * Author: Balaji Rao <balajirrao@openmoko.org>
+ * All rights reserved.
+ *
+ * Broken down from monstrous PCF50606 driver mainly by
+ * Harald Welte, Matt Hsu, Andy Green and Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+
+#include <linux/mfd/pcf50606/core.h>
+#include <linux/mfd/pcf50606/wdt.h>
+
+static struct pcf50606 *pcf;
+static unsigned long wdt_status;
+#define WDT_IN_USE 0
+#define WDT_OK_TO_CLOSE 1
+#define WDT_REGION_INITED 2
+#define WDT_DEVICE_INITED 3
+
+static int allow_close;
+#define CLOSE_STATE_NOT 0x0000
+#define CLOSE_STATE_ALLOW 0x2342
+
+static void pcf50606_wdt_start(void)
+{
+ pcf50606_reg_set_bit_mask(pcf, PCF50606_REG_OOCC1, PCF50606_OOCC1_WDTRST,
+ PCF50606_OOCC1_WDTRST);
+}
+
+static void pcf50606_wdt_stop(void)
+{
+ pcf50606_reg_clear_bits(pcf, PCF50606_REG_OOCS, PCF50606_OOCS_WDTEXP);
+}
+
+static void pcf50606_wdt_keepalive(void)
+{
+ pcf50606_wdt_start();
+}
+
+static int pcf50606_wdt_open(struct inode *inode, struct file *file)
+{
+ if (test_and_set_bit(WDT_IN_USE, &wdt_status))
+ return -EBUSY;
+
+ pcf50606_wdt_start();
+
+ return nonseekable_open(inode, file);
+}
+
+static int pcf50606_wdt_release(struct inode *inode, struct file *file)
+{
+ if (allow_close == CLOSE_STATE_ALLOW)
+ pcf50606_wdt_stop();
+ else {
+ printk(KERN_CRIT "Unexpected close, not stopping watchdog!\n");
+ pcf50606_wdt_keepalive();
+ }
+
+ allow_close = CLOSE_STATE_NOT;
+ clear_bit(WDT_IN_USE, &wdt_status);
+
+ return 0;
+}
+
+static ssize_t pcf50606_wdt_write(struct file *file, const char __user *data,
+ size_t len, loff_t *ppos)
+{
+ if (len) {
+ size_t i;
+
+ for (i = 0; i != len; i++) {
+ char c;
+ if (get_user(c, data + i))
+ return -EFAULT;
+ if (c == 'V')
+ allow_close = CLOSE_STATE_ALLOW;
+ }
+ pcf50606_wdt_keepalive();
+ }
+
+ return len;
+}
+
+static struct watchdog_info pcf50606_wdt_ident = {
+ .options = WDIOF_MAGICCLOSE,
+ .firmware_version = 0,
+ .identity = "PCF50606 Watchdog",
+};
+
+static int pcf50606_wdt_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ void __user *argp = (void __user *)arg;
+ int __user *p = argp;
+
+ switch (cmd) {
+ case WDIOC_GETSUPPORT:
+ return copy_to_user(argp, &pcf50606_wdt_ident,
+ sizeof(pcf50606_wdt_ident)) ? -EFAULT : 0;
+ break;
+ case WDIOC_GETSTATUS:
+ case WDIOC_GETBOOTSTATUS:
+ return put_user(0, p);
+ case WDIOC_KEEPALIVE:
+ pcf50606_wdt_keepalive();
+ return 0;
+ case WDIOC_GETTIMEOUT:
+ return put_user(8, p);
+ default:
+ return -ENOIOCTLCMD;
+ }
+}
+
+static struct file_operations pcf50606_wdt_fops = {
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .write = &pcf50606_wdt_write,
+ .ioctl = &pcf50606_wdt_ioctl,
+ .open = &pcf50606_wdt_open,
+ .release = &pcf50606_wdt_release,
+};
+
+static struct miscdevice pcf50606_wdt_miscdev = {
+ .minor = WATCHDOG_MINOR,
+ .name = "watchdog",
+ .fops = &pcf50606_wdt_fops,
+};
+
+static void pcf50606_wdt_irq(struct pcf50606 *pcf, int irq, void *unused)
+{
+ pcf50606_reg_set_bit_mask(pcf, PCF50606_REG_OOCC1,
+ PCF50606_OOCC1_WDTRST,
+ PCF50606_OOCC1_WDTRST);
+}
+
+int __init pcf50606_wdt_probe(struct platform_device *pdev)
+{
+ struct pcf50606 *pcf;
+ int err;
+
+ pcf = platform_get_drvdata(pdev);
+
+ err = misc_register(&pcf50606_wdt_miscdev);
+ if (err) {
+ dev_err(&pdev->dev, "cannot register miscdev on "
+ "minor=%d (%d)\n", WATCHDOG_MINOR, err);
+ return err;
+ }
+ set_bit(WDT_DEVICE_INITED, &wdt_status);
+
+ /* Set up IRQ handlers */
+ pcf->irq_handler[PCF50606_IRQ_CHGWD10S].handler = pcf50606_wdt_irq;
+
+ return 0;
+}
+
+static int __devexit pcf50606_wdt_remove(struct platform_device *pdev)
+{
+ struct pcf50606 *pcf;
+
+ pcf = platform_get_drvdata(pdev);
+
+ misc_deregister(&pcf50606_wdt_miscdev);
+
+ pcf->irq_handler[PCF50606_IRQ_CHGWD10S].handler = NULL;
+
+ return 0;
+}
+
+struct platform_driver pcf50606_wdt_driver = {
+ .driver = {
+ .name = "pcf50606-wdt",
+ },
+ .probe = pcf50606_wdt_probe,
+ .remove = __devexit_p(pcf50606_wdt_remove),
+};
+
+static int __init pcf50606_wdt_init(void)
+{
+ return platform_driver_register(&pcf50606_wdt_driver);
+}
+module_init(pcf50606_wdt_init);
+
+static void __exit pcf50606_wdt_exit(void)
+{
+ platform_driver_unregister(&pcf50606_wdt_driver);
+}
+module_exit(pcf50606_wdt_exit);
+
+MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
+MODULE_DESCRIPTION("PCF50606 wdt driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pcf50606-wdt");
+