From 361fff778b7c4d2c78f28833415335148d86a1aa Mon Sep 17 00:00:00 2001 From: merge Date: Fri, 5 Dec 2008 09:59:34 +0000 Subject: MERGE-via-pending-tracking-hist-MERGE-via-stable-tracking-build-fix-path-to-toolchain-on-1228470136 pending-tracking-hist top was MERGE-via-stable-tracking-build-fix-path-to-toolchain-on-1228470136 / 21b67ab8e79998b0a534263282dab1dda0f11b00 ... parent commitmessage: From: merge MERGE-via-stable-tracking-hist-build-fix-path-to-toolchain-on stable-tracking-hist top was build-fix-path-to-toolchain-on / ca14ba894df9b28822066c578dde48d7dbe931de ... parent commitmessage: From: Andy Green build-fix-path-to-toolchain-one-at-last.patch Signed-off-by: Andy Green --- drivers/input/misc/Kconfig | 6 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/pcf50606-input.c | 123 ++++++++++++++++++++++++++++++++++++ drivers/mfd/pcf50633-adc.c | 23 +++++-- drivers/mfd/pcf50633-core.c | 39 ++++++------ drivers/mfd/pcf50633-gpio.c | 9 +-- drivers/rtc/rtc-pcf50606.c | 3 + drivers/rtc/rtc-pcf50633.c | 3 + 8 files changed, 176 insertions(+), 31 deletions(-) create mode 100644 drivers/input/misc/pcf50606-input.c (limited to 'drivers') diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index cdf0bfcebc7..ab69a5bb98d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -235,4 +235,10 @@ config INPUT_PCF50633_PMU help Say Y to include support for input events on NXP PCF50633. +config INPUT_PCF50606_PMU + tristate "PCF50606 PMU events" + depends on MFD_PCF50606 + help + Say Y to include support for input events on NXP PCF50606. + endif diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index f0ef98e23af..0884b84c29a 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -23,3 +23,4 @@ obj-$(CONFIG_INPUT_APANEL) += apanel.o obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o obj-$(CONFIG_INPUT_LIS302DL) += lis302dl.o obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o +obj-$(CONFIG_INPUT_PCF50606_PMU) += pcf50606-input.o diff --git a/drivers/input/misc/pcf50606-input.c b/drivers/input/misc/pcf50606-input.c new file mode 100644 index 00000000000..0e4564c4c82 --- /dev/null +++ b/drivers/input/misc/pcf50606-input.c @@ -0,0 +1,123 @@ +/* Philips PCF50606 Input Driver + * + * (C) 2006-2008 by Openmoko, Inc. + * Author: Balaji Rao + * 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 060, Boston, + * MA 02111-1307 USA + */ + +#include + +#include +#include + +static void +pcf50606_input_irq(struct pcf50606 *pcf, int irq, void *data) +{ + struct input_dev *input_dev = pcf->input.input_dev; + int onkey_released; + + /* We report only one event depending on if the key status */ + onkey_released = pcf50606_reg_read(pcf, PCF50606_REG_OOCS) & + PCF50606_OOCS_ONKEY; + + if (irq == PCF50606_IRQ_ONKEYF && !onkey_released) + input_report_key(input_dev, KEY_POWER, 1); + else if (irq == PCF50606_IRQ_ONKEYR && onkey_released) + input_report_key(input_dev, KEY_POWER, 0); + + input_sync(input_dev); +} + +int __init pcf50606_input_probe(struct platform_device *pdev) +{ + struct pcf50606 *pcf; + struct input_dev *input_dev; + int ret; + + pcf = platform_get_drvdata(pdev); + + input_dev = input_allocate_device(); + if (!input_dev) + return -ENODEV; + + input_dev->name = "PCF50606 PMU events"; + input_dev->id.bustype = BUS_I2C; + + input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR); + set_bit(KEY_POWER, input_dev->keybit); + set_bit(KEY_POWER2, input_dev->keybit); + + ret = input_register_device(input_dev); + if (ret) + goto out; + + pcf->input.input_dev = input_dev; + + /* Currently we care only about ONKEY and USBINS/USBREM + * + * USBINS/USBREM are told to us by mbc driver as we can't setup + * two handlers for an IRQ + */ + pcf->irq_handler[PCF50606_IRQ_ONKEYR].handler = pcf50606_input_irq; + + pcf->irq_handler[PCF50606_IRQ_ONKEYF].handler = pcf50606_input_irq; + + return 0; + +out: + input_free_device(input_dev); + return ret; +} + +static int __devexit pcf50606_input_remove(struct platform_device *pdev) +{ + struct pcf50606 *pcf; + + pcf = platform_get_drvdata(pdev); + input_unregister_device(pcf->input.input_dev); + + return 0; +} + +struct platform_driver pcf50606_input_driver = { + .driver = { + .name = "pcf50606-input", + }, + .probe = pcf50606_input_probe, + .remove = __devexit_p(pcf50606_input_remove), +}; + +static int __init pcf50606_input_init(void) +{ + return platform_driver_register(&pcf50606_input_driver); +} +module_init(pcf50606_input_init); + +static void __exit pcf50606_input_exit(void) +{ + platform_driver_unregister(&pcf50606_input_driver); +} +module_exit(pcf50606_input_exit); + +MODULE_AUTHOR("Balaji Rao "); +MODULE_DESCRIPTION("PCF50606 input driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:pcf50606-input"); diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c index ebd3792e778..e3d4eb1c03f 100644 --- a/drivers/mfd/pcf50633-adc.c +++ b/drivers/mfd/pcf50633-adc.c @@ -23,6 +23,11 @@ * MA 02111-1307 USA */ +/* + * NOTE: This driver does not yet support subtractive ADC mode, which means + * you can do only one measurement per read request. + */ + #include #include @@ -115,7 +120,7 @@ int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg) struct pcf50633_adc_request *req; int result; - /* req is freed when the result is ready, in pcf50633_work*/ + /* req is freed when the result is ready, in interrupt handler */ req = kzalloc(sizeof(*req), GFP_KERNEL); if (!req) return -ENOMEM; @@ -141,7 +146,7 @@ int pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg, { struct pcf50633_adc_request *req; - /* req is freed when the result is ready, in pcf50633_work*/ + /* req is freed when the result is ready, in interrupt handler */ req = kmalloc(sizeof(*req), GFP_KERNEL); if (!req) return -ENOMEM; @@ -159,12 +164,16 @@ EXPORT_SYMBOL_GPL(pcf50633_adc_async_read); static int adc_result(struct pcf50633 *pcf) { - u16 ret = (pcf50633_reg_read(pcf, PCF50633_REG_ADCS1) << 2) | - (pcf50633_reg_read(pcf, PCF50633_REG_ADCS3) & - PCF50633_ADCS3_ADCDAT1L_MASK); - dev_info(pcf->dev, "adc result = %d\n", ret); + u8 adcs1, adcs3; + u16 result; + + adcs1 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS1); + adcs3 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS3); + result = (adcs1 << 2) | (adcs3 & PCF50633_ADCS3_ADCDAT1L_MASK); - return ret; + dev_info(pcf->dev, "adc result = %d\n", result); + + return result; } static void pcf50633_adc_irq(struct pcf50633 *pcf, int irq, void *unused) diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index 891f7623377..6634558ea91 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c @@ -28,12 +28,8 @@ #include #include #include + #include -#include -#include -#include -#include -#include /* Read a block of upto 32 regs */ int pcf50633_read_block(struct pcf50633 *pcf , u8 reg, @@ -303,7 +299,7 @@ static void pcf50633_irq_worker(struct work_struct *work) /* 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] & PCF50633_INT1_SECOND && pcf->onkey1s_held) { + if ((pcf_int[0] & PCF50633_INT1_SECOND) && pcf->onkey1s_held) { dev_info(pcf->dev, "ONKEY1S held for %d secs\n", pcf->onkey1s_held); if (pcf->onkey1s_held++ == PCF50633_ONKEY1S_TIMEOUT) @@ -320,11 +316,11 @@ static void pcf50633_irq_worker(struct work_struct *work) PCF50633_INT1_SECOND); /* Unmask IRQ_ONKEYR */ - pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT1M, - PCF50633_INT1_SECOND); + pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT2M, + PCF50633_INT2_ONKEYR); } - if (pcf_int[1] & PCF50633_INT2_ONKEYR & pcf->onkey1s_held) { + if ((pcf_int[1] & PCF50633_INT2_ONKEYR) && pcf->onkey1s_held) { pcf->onkey1s_held = 0; /* Mask SECOND and ONKEYR interrupts */ @@ -351,19 +347,18 @@ static void pcf50633_irq_worker(struct work_struct *work) pcf->resume_reason[i] = pcf_int[i] & pcf->pdata->resumers[i]; - /* Make sure we don't pass on any input events to + /* Make sure we don't pass on any ONKEY events to * userspace now */ - pcf_int[1] = 0; + pcf_int[1] &= ~ (PCF50633_INT2_ONKEYR | PCF50633_INT2_ONKEYF); } /* Unset masked interrupts */ - for (i = 0; i < 5; i++) + 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)) pcf50633_irq_call_handler(pcf, (i * 8) + j); + } put_device(pcf->dev); @@ -434,7 +429,8 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state) cancel_work_sync(&pcf->irq_work); /* Save the masks */ - ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M, 5, + ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M, + ARRAY_SIZE(pcf->suspend_irq_masks), pcf->suspend_irq_masks); if (ret < 0) dev_err(pcf->dev, "error saving irq masks\n"); @@ -442,10 +438,10 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state) /* Set interrupt masks. So that only those sources we want to wake * us up can */ - for (i = 0; i < 5; i++) + for (i = 0; i < ARRAY_SIZE(res); i++) res[i] = ~pcf->pdata->resumers[i]; - pcf50633_write_block(pcf, PCF50633_REG_INT1M, 5, &res[0]); + pcf50633_write_block(pcf, PCF50633_REG_INT1M, ARRAY_SIZE(res), &res[0]); pcf->is_suspended = 1; @@ -459,13 +455,16 @@ static int pcf50633_resume(struct device *dev) pcf = dev_get_drvdata(dev); /* Write the saved mask registers */ - pcf50633_write_block(pcf, PCF50633_REG_INT1M, 5, + pcf50633_write_block(pcf, PCF50633_REG_INT1M, + ARRAY_SIZE(pcf->suspend_irq_masks), pcf->suspend_irq_masks); get_device(pcf->dev); - /* Clear any pending interrupts and set resume reason if any */ - /* this will leave with enable_irq() */ + /* + * Clear any pending interrupts and set resume reason if any. + * This will leave with enable_irq() + */ pcf50633_irq_worker(&pcf->irq_work); return 0; diff --git a/drivers/mfd/pcf50633-gpio.c b/drivers/mfd/pcf50633-gpio.c index a7117fa6282..55139071d22 100644 --- a/drivers/mfd/pcf50633-gpio.c +++ b/drivers/mfd/pcf50633-gpio.c @@ -42,7 +42,7 @@ int pcf50633_gpio_get(struct pcf50633 *pcf, int gpio) u8 reg, val; reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG; - val = pcf50633_reg_read(pcf, reg); + val = pcf50633_reg_read(pcf, reg) & 0x07; return val; } @@ -55,7 +55,7 @@ void pcf50633_gpio_invert_set(struct pcf50633 *pcf, int gpio, int invert) reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG; val = !!invert << 3; - pcf50633_reg_set_bit_mask(pcf, reg, val, val); + pcf50633_reg_set_bit_mask(pcf, reg, 1 << 3, val); } EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_set); @@ -87,13 +87,14 @@ static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = { void pcf50633_gpio_power_supply_set(struct pcf50633 *pcf, int gpio, int regulator, int on) { - u8 reg, val; + u8 reg, val, mask; /* the *ENA register is always one after the *OUT register */ reg = pcf50633_regulator_registers[regulator] + 1; val = (!!on << (gpio - PCF50633_GPIO1)); + mask = (1 << (gpio - PCF50633_GPIO1)); - pcf50633_reg_set_bit_mask(pcf, reg, val, val); + pcf50633_reg_set_bit_mask(pcf, reg, mask, val); } EXPORT_SYMBOL_GPL(pcf50633_gpio_power_supply_set); diff --git a/drivers/rtc/rtc-pcf50606.c b/drivers/rtc/rtc-pcf50606.c index 498ec77c82f..841ea28ca56 100644 --- a/drivers/rtc/rtc-pcf50606.c +++ b/drivers/rtc/rtc-pcf50606.c @@ -207,6 +207,9 @@ static int pcf50606_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) rtc2pcf_time(&pcf_tm, &alrm->time); + /* do like mktime does and ignore tm_wday */ + pcf_tm.time[PCF50606_TI_WKDAY] = 7; + alarm_masked = pcf50606_irq_mask_get(pcf, PCF50606_IRQ_ALARM); /* disable alarm interrupt */ diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c index 00b159920b4..e1576d24254 100644 --- a/drivers/rtc/rtc-pcf50633.c +++ b/drivers/rtc/rtc-pcf50633.c @@ -207,6 +207,9 @@ static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) rtc2pcf_time(&pcf_tm, &alrm->time); + /* do like mktime does and ignore tm_wday */ + pcf_tm.time[PCF50633_TI_WKDAY] = 7; + alarm_masked = pcf50633_irq_mask_get(pcf, PCF50633_IRQ_ALARM); /* disable alarm interrupt */ -- cgit v1.2.3