Skip to contentSkip to conversation

PCF50633 support

PATCH Applied Balaji Rao 9 participants 26 messages Dec 18, 2008 – Dec 25, 2008

Subsystems (4)

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore

Balaji Rao

author
#0 lore raw

v2 cover PCF50633 support

Changes from V1:
- Subdevice specific header files now included in its respective patch.
- Introduces pcf50633_register_irq and pcf50633_free_irq for irq management
- Many changes in how subdevices are created and information is passed to them. Thanks to Alessandro Zummo for suggestions.

The following series implements support for NXP PCF50633. It's basically an I2C device with 9 regulators, an ADC, a PMIC, a Battery Charger and a RTC.

This chip is used in Openmoko Neo Freerunner mobile phone.

Driver for a similar chip PCF50606, used in Openmoko Neo 1973 device will follow soon.

The specs are open and are available at
http://people.openmoko.org/tony_tu/GTA02/datasheet/PMU/PCF50633DS_02.pdf

Samuel, are you ok with merging this via linux-mfd tree ?

---
Balaji Rao (7):
mfd: PCF50633 core driver
mfd: PCF50633 adc driver
mfd: PCF50633 gpio support
rtc: PCF50633 rtc driver
power_supply: PCF50633 battery charger driver
input: PCF50633 input driver
regulator: PCF50633 pmic driver

 drivers/input/misc/Kconfig             |    7 
 drivers/input/misc/Makefile            |    1 
 drivers/input/misc/pcf50633-input.c    |  132 ++++++
 drivers/mfd/Kconfig                    |   23 +
 drivers/mfd/Makefile                   |    6 
 drivers/mfd/pcf50633-adc.c             |  277 +++++++++++++
 drivers/mfd/pcf50633-core.c            |  707 ++++++++++++++++++++++++++++++++
 drivers/mfd/pcf50633-gpio.c            |  118 +++++
 drivers/power/Kconfig                  |    6 
 drivers/power/Makefile                 |    2 
 drivers/power/pcf50633-charger.c       |  358 ++++++++++++++++
 drivers/regulator/Kconfig              |    7 
 drivers/regulator/Makefile             |    1 
 drivers/regulator/pcf50633-regulator.c |  330 +++++++++++++++
 drivers/rtc/Kconfig                    |    6 
 drivers/rtc/Makefile                   |    1 
 drivers/rtc/rtc-pcf50633.c             |  336 +++++++++++++++
 include/linux/mfd/pcf50633/adc.h       |   72 +++
 include/linux/mfd/pcf50633/core.h      |  218 ++++++++++
 include/linux/mfd/pcf50633/gpio.h      |   52 ++
 include/linux/mfd/pcf50633/mbc.h       |  134 ++++++
 include/linux/mfd/pcf50633/pmic.h      |   68 +++
 22 files changed, 2861 insertions(+), 1 deletions(-)
 create mode 100644 drivers/input/misc/pcf50633-input.c
 create mode 100644 drivers/mfd/pcf50633-adc.c
 create mode 100644 drivers/mfd/pcf50633-core.c
 create mode 100644 drivers/mfd/pcf50633-gpio.c
 create mode 100644 drivers/power/pcf50633-charger.c
 create mode 100644 drivers/regulator/pcf50633-regulator.c
 create mode 100644 drivers/rtc/rtc-pcf50633.c
 create mode 100644 include/linux/mfd/pcf50633/adc.h
 create mode 100644 include/linux/mfd/pcf50633/core.h
 create mode 100644 include/linux/mfd/pcf50633/gpio.h
 create mode 100644 include/linux/mfd/pcf50633/mbc.h
 create mode 100644 include/linux/mfd/pcf50633/pmic.h
Signature · 2 lines
Thanks,
Balaji Rao
author
#1 lore raw

PATCH v2 1/7 mfd: PCF50633 core driver

This patch implements the core of the PCF50633 driver. This core driver has generic register read/write functions and does interrupt management for its sub devices.

Cc Andy Green <[email protected]>
Cc Samuel Ortiz <[email protected]>
---
 drivers/mfd/Kconfig               |    9 
 drivers/mfd/Makefile              |    4 
 drivers/mfd/pcf50633-core.c       |  707 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/pcf50633/core.h |  218 +++++++++++
 4 files changed, 937 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mfd/pcf50633-core.c
 create mode 100644 include/linux/mfd/pcf50633/core.h
drivers/mfd/Kconfig +9 -0
index 8cd3dd9..fb1f0f7 100644
@@ -153,6 +153,15 @@ config MFD_WM8350_I2C
 	  I2C as the control interface.  Additional options must be
 	  selected to enable support for the functionality of the chip.
 
+config MFD_PCF50633
+	tristate "Support for NXP PCF50633"
+	depends on I2C
+	help
+	  Say yes here if you have NXP PCF50633 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.
+
 endmenu
 
 menu "Multimedia Capabilities Port drivers"
drivers/mfd/Makefile +3 -1
index 9a5ad8a..6a4add8 100644
@@ -31,4 +31,6 @@ obj-$(CONFIG_MCP_UCB1200)	+= ucb1x00-assabet.o
 endif
 obj-$(CONFIG_UCB1400_CORE)	+= ucb1400_core.o
 
-obj-$(CONFIG_PMIC_DA903X)	+= da903x.o
\ No newline at end of file
+obj-$(CONFIG_PMIC_DA903X)	+= da903x.o
+
+obj-$(CONFIG_MFD_PCF50633)	+= pcf50633-core.o
drivers/mfd/pcf50633-core.c new file +707 -0

707 lines not on this page · raw message

include/linux/mfd/pcf50633/core.h new file +218 -0

218 lines not on this page · raw message

author
#2 lore raw

PATCH v2 2/7 mfd: PCF50633 adc driver

In reply to Balaji Rao

This patch adds basic support for the PCF50633 ADC. The subtractive mode is not supported yet.

Since we don't have adc subsystem, it currently lives in drivers/mfd.

Cc Andy Green <[email protected]>
Cc Samuel Ortiz <[email protected]>
---
 drivers/mfd/Kconfig              |    7 +
 drivers/mfd/Makefile             |    1 
 drivers/mfd/pcf50633-adc.c       |  277 ++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/pcf50633/adc.h |   72 ++++++++++
 4 files changed, 357 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/pcf50633-adc.c
 create mode 100644 include/linux/mfd/pcf50633/adc.h
drivers/mfd/Kconfig +7 -0
index fb1f0f7..02e3d73 100644
@@ -162,6 +162,13 @@ config MFD_PCF50633
 	  facilities, and registers devices for the various functions
 	  so that function-specific drivers can bind to them.
 
+config PCF50633_ADC
+	tristate "Support for NXP PCF50633 ADC"
+	depends on MFD_PCF50633
+	help
+	 Say yes here if you want to include support for ADC in the
+	 NXP PCF50633 chip.
+
 endmenu
 
 menu "Multimedia Capabilities Port drivers"
drivers/mfd/Makefile +1 -0
index 6a4add8..7a12b09 100644
@@ -34,3 +34,4 @@ obj-$(CONFIG_UCB1400_CORE)	+= ucb1400_core.o
 obj-$(CONFIG_PMIC_DA903X)	+= da903x.o
 
 obj-$(CONFIG_MFD_PCF50633)	+= pcf50633-core.o
+obj-$(CONFIG_PCF50633_ADC)	+= pcf50633-adc.o
drivers/mfd/pcf50633-adc.c new file +277 -0

277 lines not on this page · raw message

include/linux/mfd/pcf50633/adc.h new file +72 -0

72 lines not on this page · raw message

Acked-by on v2 2/7
#3 lore raw

Re: [PATCH V2 2/7] mfd: PCF50633 adc driver

Hi Balaji,

Nice driver. I particularly like the queueing structure. In the IIO design I hadn't come across any devices that operate in this request then wait for interrupt fashion. May need to rethink a few bits of that.

Couple of minor suggestions below.

Quoted 7 lines

This patch adds basic support for the PCF50633 ADC. The subtractive mode is not supported yet.

Since we don't have adc subsystem, it currently lives in drivers/mfd.

...

drivers/mfd/pcf50633-adc.c line 10

Quoted 13 lines
drivers/mfd/pcf50633-adc.c new file +10 -0
@@ -0,0 +1,277 @@
+/* NXP PCF50633 ADC Driver
+ *
+ * (C) 2006-2008 by Openmoko, Inc.
+ * Author: Balaji Rao <[email protected]>
+ * All rights reserved.
+ *
+ * Broken down from monstrous PCF50633 driver mainly by
+ * Harald Welte, Andy Green and Werner Almesberger
+ *
+ *  This program is free software; you can redistribute  it and/or

modify it

drivers/mfd/pcf50633-adc.c line 11

Quoted 1 line
drivers/mfd/pcf50633-adc.c new file +1 -0
+ *  under  the terms of  the GNU General  Public License as published

by the

drivers/mfd/pcf50633-adc.c line 12

Quoted 1 line
drivers/mfd/pcf50633-adc.c new file +1 -0
+ *  Free Software Foundation;  either version 2 of the  License, or

(at your

drivers/mfd/pcf50633-adc.c

Quoted 3 lines
drivers/mfd/pcf50633-adc.c new file +3 -0
+ *  option) any later version.
+ *
+ *  NOTE: This driver does not yet support subtractive ADC mode, which

means

drivers/mfd/pcf50633-adc.c line 17

Quoted 2 lines
drivers/mfd/pcf50633-adc.c new file +2 -0
+ *  you can do only one measurement per read request.
+ */

...

This is confusingly named. To my mind it is writing the setup to the device not reading it.

drivers/mfd/pcf50633-adc.c line 60

Quoted 3 lines
drivers/mfd/pcf50633-adc.c new file +3 -0
+static void adc_read_setup(struct pcf50633 *pcf, int channel, int avg)
+{
+    channel &= PCF50633_ADCC1_ADCMUX_MASK;

This needs a bit more explanation. Particularly as the data sheet describes that accsw as 'for rationmetric measurement'. Also, seeing as I assume this is the only driver that can touch these registers and you don't change them else where, why can't they be in initial setup code rather than here? (probably a good reason, but be nice to have it document here!)

Quoted 6 lines
drivers/mfd/pcf50633-adc.c new file +6 -0
+    /* kill ratiometric, but enable ACCSW biasing */
+    pcf50633_reg_write(pcf, PCF50633_REG_ADCC2, 0x00);
+    pcf50633_reg_write(pcf, PCF50633_REG_ADCC3, 0x01);
+
+    /* start ADC conversion on selected channel */
+    pcf50633_reg_write(pcf, PCF50633_REG_ADCC1, channel | avg |

...

Quoted 7 lines
drivers/mfd/pcf50633-adc.c new file +7 -0
+
+static void pcf50633_adc_irq(int irq, void *data)
+{
+    struct pcf50633_adc *adc = data;
+    struct pcf50633 *pcf = adc->pcf;
+    struct pcf50633_adc_request *req;
+    int head;

drivers/mfd/pcf50633-adc.c line 198

Quoted 10 lines
drivers/mfd/pcf50633-adc.c new file +10 -0
+    mutex_lock(&adc->queue_mutex);
+    head = adc->queue_head;
+
+    req = adc->queue[head];
+    if (WARN_ON(!req)) {
+        dev_err(pcf->dev, "pcf50633-adc irq: ADC queue empty!\n");
+        mutex_unlock(&adc->queue_mutex);
+        return;
+    }
+    adc->queue[head] = NULL;

Weird formatting?

drivers/mfd/pcf50633-adc.c line 209

Quoted 10 lines
drivers/mfd/pcf50633-adc.c new file +10 -0
+    adc->queue_head = (head + 1) &
+                      (PCF50633_MAX_ADC_FIFO_DEPTH - 1);
+
+    mutex_unlock(&adc->queue_mutex);
+    req->callback(pcf, req->callback_param, adc_result(pcf));
+    kfree(req);
+
+    trigger_next_adc_job_if_any(pcf);
+}
+

Rest looks good to me.

Acked-by Jonathan Cameron
#4 lore raw

Re: [PATCH V2 2/7] mfd: PCF50633 adc driver

Quoted 4 lines · Jonathan Cameron

Nice driver. I particularly like the queueing structure. In the IIO design I hadn't come across any devices that operate in this request then wait for interrupt fashion. May need to rethink a few bits of that.

There's auxiliary ADCs like that in several Wolfson parts too - at least WM97xx and WM8350 have them. They're typically used for applications like battery and supply monitoring.

#5 lore raw

Re: [PATCH V2 2/7] mfd: PCF50633 adc driver

Quoted 9 lines · Mark Brown
Quoted 5 lines · Jonathan Cameron

Nice driver. I particularly like the queueing structure. In the IIO design I hadn't come across any devices that operate in this request then wait for interrupt fashion. May need to rethink a few bits of that.

Quoted 4 lines

There's auxiliary ADCs like that in several Wolfson parts too - at least WM97xx and WM8350 have them. They're typically used for applications like battery and supply monitoring.

True. The da903x chips have one as well.

#6 lore raw

Re: [PATCH V2 2/7] mfd: PCF50633 adc driver

In reply to Jonathan Cameron

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Somebody in the thread at some point said:

Hi Johnathan -

| This needs a bit more explanation. Particularly as the data | sheet describes that accsw as 'for rationmetric measurement'.

What's going on here is that ACCSW can be driven from the PMU to bias a resistor divider to scale what's being measured... we use it to detect resistor to 0V on ID pin of USB on our charger.

You can power accsw / that divider "by hand" which is what we're doing here, or you can have the ratiometric state machine change the mux / bias automatically between the two measurements it takes, which we're not doing.

| Also, seeing as I assume this is the only driver that can touch
| these registers and you don't change them else where, why can't
| they be in initial setup code rather than here? (probably a good
| reason, but be nice to have it document here!)

ADCC2 setting concerned with ratiometric disable could indeed be moved to init, it was done like this before I did the queuing stuff and we took ADC measurement in two different places in the code. But in fact for the best we should only enable accsw until the measurement completes and save a tiny bit of power.

|> +    /* kill ratiometric, but enable ACCSW biasing */
|> +    pcf50633_reg_write(pcf, PCF50633_REG_ADCC2, 0x00);
|> +    pcf50633_reg_write(pcf, PCF50633_REG_ADCC3, 0x01);
|> +
|> +    /* start ADC conversion on selected channel */
|> +    pcf50633_reg_write(pcf, PCF50633_REG_ADCC1, channel | avg |
| ...
|> +
|> +static void pcf50633_adc_irq(int irq, void *data)
|> +{
|> +    struct pcf50633_adc *adc = data;
|> +    struct pcf50633 *pcf = adc->pcf;
|> +    struct pcf50633_adc_request *req;
|> +    int head;
|> +    mutex_lock(&adc->queue_mutex);
|> +    head = adc->queue_head;
|> +
|> +    req = adc->queue[head];
|> +    if (WARN_ON(!req)) {
|> +        dev_err(pcf->dev, "pcf50633-adc irq: ADC queue empty!\n");
|> +        mutex_unlock(&adc->queue_mutex);
|> +        return;
|> +    }
|> +    adc->queue[head] = NULL;
|
| Weird formatting?
|
|> +    adc->queue_head = (head + 1) &
|> +                      (PCF50633_MAX_ADC_FIFO_DEPTH - 1);
|> +
|> +    mutex_unlock(&adc->queue_mutex);

This would save the power

~ pcf50633_reg_write(pcf, PCF50633_REG_ADCC3, 0x0);

|> +    req->callback(pcf, req->callback_param, adc_result(pcf));
|> +    kfree(req);
|> +
|> +    trigger_next_adc_job_if_any(pcf);
|> +}
|> +
| Rest looks good to me.
|
| Acked-by: Jonathan Cameron
|

- -Andy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAklLkHIACgkQOjLpvpq7dMoAtACeNxmM0m69xgbvT4YIPik2aHNP hSIAoIUUbXcibwPYqgasik4ALFEc0img
=//X+
-----END PGP SIGNATURE-----

#7 lore raw

Re: [PATCH V2 2/7] mfd: PCF50633 adc driver

Quoted 7 lines · Andy Green

Somebody in the thread at some point said:

Hi Johnathan -

| This needs a bit more explanation. Particularly as the data | sheet describes that accsw as 'for rationmetric measurement'.

Quoted 8 lines

What's going on here is that ACCSW can be driven from the PMU to bias a resistor divider to scale what's being measured... we use it to detect resistor to 0V on ID pin of USB on our charger.

You can power accsw / that divider "by hand" which is what we're doing here, or you can have the ratiometric state machine change the mux / bias automatically between the two measurements it takes, which we're not doing.

That makes sense. Thanks for the explanation.

Quoted 11 lines
| Also, seeing as I assume this is the only driver that can touch
| these registers and you don't change them else where, why can't
| they be in initial setup code rather than here? (probably a good
| reason, but be nice to have it document here!)

ADCC2 setting concerned with ratiometric disable could indeed be moved to init, it was done like this before I did the queuing stuff and we took ADC measurement in two different places in the code. But in fact for the best we should only enable accsw until the measurement completes and save a tiny bit of power.

Either way sounds fine to me as I'd be surprised if it is a significant power
drain and anyway it would come at the cost of a couple more register writes which, if the bus is slow, would be more of an issue.

Quoted 49 lines
|> +    /* kill ratiometric, but enable ACCSW biasing */
|> +    pcf50633_reg_write(pcf, PCF50633_REG_ADCC2, 0x00);
|> +    pcf50633_reg_write(pcf, PCF50633_REG_ADCC3, 0x01);
|> +
|> +    /* start ADC conversion on selected channel */
|> +    pcf50633_reg_write(pcf, PCF50633_REG_ADCC1, channel | avg |
| ...
|> +
|> +static void pcf50633_adc_irq(int irq, void *data)
|> +{
|> +    struct pcf50633_adc *adc = data;
|> +    struct pcf50633 *pcf = adc->pcf;
|> +    struct pcf50633_adc_request *req;
|> +    int head;
|> +    mutex_lock(&adc->queue_mutex);
|> +    head = adc->queue_head;
|> +
|> +    req = adc->queue[head];
|> +    if (WARN_ON(!req)) {
|> +        dev_err(pcf->dev, "pcf50633-adc irq: ADC queue empty!\n");
|> +        mutex_unlock(&adc->queue_mutex);
|> +        return;
|> +    }
|> +    adc->queue[head] = NULL;
|
| Weird formatting?
|
|> +    adc->queue_head = (head + 1) &
|> +                      (PCF50633_MAX_ADC_FIFO_DEPTH - 1);
|> +
|> +    mutex_unlock(&adc->queue_mutex);

This would save the power

~ pcf50633_reg_write(pcf, PCF50633_REG_ADCC3, 0x0);

|> +    req->callback(pcf, req->callback_param, adc_result(pcf));
|> +    kfree(req);
|> +
|> +    trigger_next_adc_job_if_any(pcf);
|> +}
|> +
| Rest looks good to me.
|
| Acked-by: Jonathan Cameron
|

-Andy

author
#8 lore raw

Re: [PATCH V2 2/7] mfd: PCF50633 adc driver

In reply to Jonathan Cameron

On Fri, Dec 19, 2008 at 11:18:52AM +0000, Jonathan Cameron wrote:
Hi Jonathan,

Quoted 7 lines

This is confusingly named. To my mind it is writing the setup to the device not reading it.

drivers/mfd/pcf50633-adc.c line 60

Quoted 3 lines
drivers/mfd/pcf50633-adc.c new file +3 -0
+static void adc_read_setup(struct pcf50633 *pcf, int channel, int avg)
+{
+    channel &= PCF50633_ADCC1_ADCMUX_MASK;

Yes, right. Will change.

Quoted 6 lines

This needs a bit more explanation. Particularly as the data sheet describes that accsw as 'for rationmetric measurement'. Also, seeing as I assume this is the only driver that can touch these registers and you don't change them else where, why can't they be in initial setup code rather than here? (probably a good reason, but be nice to have it document here!)

Yes, the for killing ratiometric measurement can be in _probe. But we need to enable accsw everytime because it's turned off automatically once a conversion is complete - to save power.

Quoted 18 lines
Quoted 6 lines
drivers/mfd/pcf50633-adc.c new file +6 -0
+    /* kill ratiometric, but enable ACCSW biasing */
+    pcf50633_reg_write(pcf, PCF50633_REG_ADCC2, 0x00);
+    pcf50633_reg_write(pcf, PCF50633_REG_ADCC3, 0x01);
+
+    /* start ADC conversion on selected channel */
+    pcf50633_reg_write(pcf, PCF50633_REG_ADCC1, channel | avg |

...

Quoted 11 lines
drivers/mfd/pcf50633-adc.c new file +11 -0
+
+static void pcf50633_adc_irq(int irq, void *data)
+{
+    struct pcf50633_adc *adc = data;
+    struct pcf50633 *pcf = adc->pcf;
+    struct pcf50633_adc_request *req;
+    int head;
+    mutex_lock(&adc->queue_mutex);
+    head = adc->queue_head;
+
+    req = adc->queue[head];
Quoted 9 lines

drivers/mfd/pcf50633-adc.c line 198

Quoted 6 lines
drivers/mfd/pcf50633-adc.c new file +6 -0
+    if (WARN_ON(!req)) {
+        dev_err(pcf->dev, "pcf50633-adc irq: ADC queue empty!\n");
+        mutex_unlock(&adc->queue_mutex);
+        return;
+    }
+    adc->queue[head] = NULL;

Weird formatting?

Oops! Will fix.

Thank you for the review.

Balaji Rao

author
#9 lore raw

PATCH v2 3/7 mfd: PCF50633 gpio support

In reply to Balaji Rao

What the PCF05633 calls as a 'GPIO' is much more than the GPIO in the linux sense and there are only 4 of them - which means, the gpiolib is not used here.

Cc Andy Green <[email protected]>
Cc Samuel Ortiz <[email protected]>
---
 drivers/mfd/Kconfig               |    7 ++
 drivers/mfd/Makefile              |    1 
 drivers/mfd/pcf50633-gpio.c       |  118 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/pcf50633/gpio.h |   52 ++++++++++++++++
 4 files changed, 178 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/pcf50633-gpio.c
 create mode 100644 include/linux/mfd/pcf50633/gpio.h
drivers/mfd/Kconfig +7 -0
index 02e3d73..cdb178b 100644
@@ -169,6 +169,13 @@ config PCF50633_ADC
 	 Say yes here if you want to include support for ADC in the
 	 NXP PCF50633 chip.
 
+config PCF50633_GPIO
+	tristate "Support for NXP PCF50633 GPIO"
+	depends on MFD_PCF50633
+	help
+	 Say yes here if you want to include support GPIO for pins on
+	 the PCF50633 chip.
+
 endmenu
 
 menu "Multimedia Capabilities Port drivers"
drivers/mfd/Makefile +1 -0
index 7a12b09..5bc7c9f 100644
@@ -35,3 +35,4 @@ 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
drivers/mfd/pcf50633-gpio.c new file +118 -0

118 lines not on this page · raw message

include/linux/mfd/pcf50633/gpio.h new file +52 -0

52 lines not on this page · raw message

author
#10 lore raw

PATCH v2 4/7 rtc: PCF50633 rtc driver

In reply to Balaji Rao

Changes from V1:
- Removed include/linux/mfd/pcf50633/rtc.h and moved defenitions into the source file.
- Remove PIE and introduce UIE support. UIE being the one actually supported in the chip.

Alessandro, I'll change to the new API for AIE once it appears upstream.

Cc Andy Green <[email protected]>
Cc Alessandro Zummo <[email protected]>
Cc Paul Gortmaker <[email protected]>
---
 drivers/rtc/Kconfig        |    6 +
 drivers/rtc/Makefile       |    1 
 drivers/rtc/rtc-pcf50633.c |  336 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 343 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/rtc-pcf50633.c
drivers/rtc/Kconfig +6 -0
index 123092d..68e68d2 100644
@@ -497,6 +497,12 @@ config RTC_DRV_WM8350
 	  This driver can also be built as a module. If so, the module
 	  will be called "rtc-wm8350".
 
+config RTC_DRV_PCF50633
+	depends on MFD_PCF50633
+	tristate "NXP PCF50633 RTC"
+	help
+	  If you say yes here you get support for the NXP PCF50633 RTC.
+
 comment "on-CPU RTC drivers"
 
 config RTC_DRV_OMAP
drivers/rtc/Makefile +1 -0
index 6e79c91..a717fec 100644
@@ -70,3 +70,4 @@ obj-$(CONFIG_RTC_DRV_V3020)	+= rtc-v3020.o
 obj-$(CONFIG_RTC_DRV_VR41XX)	+= rtc-vr41xx.o
 obj-$(CONFIG_RTC_DRV_WM8350)	+= rtc-wm8350.o
 obj-$(CONFIG_RTC_DRV_X1205)	+= rtc-x1205.o
+obj-$(CONFIG_RTC_DRV_PCF50633)	+= rtc-pcf50633.o
drivers/rtc/rtc-pcf50633.c new file +336 -0

336 lines not on this page · raw message

#11 lore raw

Re: [PATCH V2 4/7] rtc: PCF50633 rtc driver

Quoted 7 lines · On Thu, 18 Dec 2008 11:27:26 +0530 Balaji Rao <[email protected]> wrote:

Changes from V1:
- Removed include/linux/mfd/pcf50633/rtc.h and moved defenitions into the source file.
- Remove PIE and introduce UIE support. UIE being the one actually supported in the chip.

Alessandro, I'll change to the new API for AIE once it appears upstream.

Ok, I guess the driver will not go in tomorrow, so you can wait. I'd add it now, while you're at it :)

some comments below:

Quoted 17 lines
Cc Andy Green <[email protected]>
Cc Alessandro Zummo <[email protected]>
Cc Paul Gortmaker <[email protected]>
---
 drivers/rtc/Kconfig        |    6 +
 drivers/rtc/Makefile       |    1 
 drivers/rtc/rtc-pcf50633.c |  336 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 343 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/rtc-pcf50633.c
drivers/rtc/Kconfig +0 -0
index 123092d..68e68d2 100644

drivers/rtc/Kconfig config RTC_DRV_WM8350 · line 504

Quoted 8 lines
drivers/rtc/Kconfig +5 -0
@@ -497,6 +497,12 @@ config RTC_DRV_WM8350
 	  This driver can also be built as a module. If so, the module
 	  will be called "rtc-wm8350".
 
+config RTC_DRV_PCF50633
+	depends on MFD_PCF50633
+	tristate "NXP PCF50633 RTC"
+	help
+	  If you say yes here you get support for the NXP PCF50633 RTC.

a more detailed description please stating which platforms commonly have this rtc

Quoted 290 lines
drivers/rtc/Kconfig +0 -0
 comment "on-CPU RTC drivers"
 
 config RTC_DRV_OMAP
drivers/rtc/Makefile +1 -0
index 6e79c91..a717fec 100644
@@ -70,3 +70,4 @@ obj-$(CONFIG_RTC_DRV_V3020)	+= rtc-v3020.o
 obj-$(CONFIG_RTC_DRV_VR41XX)	+= rtc-vr41xx.o
 obj-$(CONFIG_RTC_DRV_WM8350)	+= rtc-wm8350.o
 obj-$(CONFIG_RTC_DRV_X1205)	+= rtc-x1205.o
+obj-$(CONFIG_RTC_DRV_PCF50633)	+= rtc-pcf50633.o
drivers/rtc/rtc-pcf50633.c new file +272 -0
new file mode 100644
index 0000000..2f33509
@@ -0,0 +1,336 @@
+/* NXP PCF50633 RTC Driver
+ *
+ * (C) 2006-2008 by Openmoko, Inc.
+ * Author: Balaji Rao <[email protected]>
+ * All rights reserved.
+ *
+ * Broken down from monstrous PCF50633 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+#include <linux/bcd.h>
+#include <linux/err.h>
+
+#include <linux/mfd/pcf50633/core.h>
+
+#define PCF50633_REG_RTCSC	0x59 /* Second */
+#define PCF50633_REG_RTCMN	0x5a /* Minute */
+#define PCF50633_REG_RTCHR	0x5b /* Hour */
+#define PCF50633_REG_RTCWD	0x5c /* Weekday */
+#define PCF50633_REG_RTCDT	0x5d /* Day */
+#define PCF50633_REG_RTCMT	0x5e /* Month */
+#define PCF50633_REG_RTCYR	0x5f /* Year */
+#define PCF50633_REG_RTCSCA	0x60 /* Alarm Second */
+#define PCF50633_REG_RTCMNA	0x61 /* Alarm Minute */
+#define PCF50633_REG_RTCHRA	0x62 /* Alarm Hour */
+#define PCF50633_REG_RTCWDA	0x63 /* Alarm Weekday */
+#define PCF50633_REG_RTCDTA	0x64 /* Alarm Day */
+#define PCF50633_REG_RTCMTA	0x65 /* Alarm Month */
+#define PCF50633_REG_RTCYRA	0x66 /* Alarm Year */
+
+enum pcf50633_time_indexes {
+	PCF50633_TI_SEC,
+	PCF50633_TI_MIN,
+	PCF50633_TI_HOUR,
+	PCF50633_TI_WKDAY,
+	PCF50633_TI_DAY,
+	PCF50633_TI_MONTH,
+	PCF50633_TI_YEAR,
+	PCF50633_TI_EXTENT /* always last */
+};
+
+struct pcf50633_time {
+	u_int8_t time[PCF50633_TI_EXTENT];
+};
+
+struct pcf50633_rtc {
+	int alarm_enabled;
+	int second_enabled;
+
+	struct pcf50633 *pcf;
+	struct rtc_device *rtc_dev;
+};
+
+static void pcf2rtc_time(struct rtc_time *rtc, struct pcf50633_time *pcf)
+{
+	rtc->tm_sec = bcd2bin(pcf->time[PCF50633_TI_SEC]);
+	rtc->tm_min = bcd2bin(pcf->time[PCF50633_TI_MIN]);
+	rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]);
+	rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]);
+	rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]);
+	rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]);
+	rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100;
+}
+
+static void rtc2pcf_time(struct pcf50633_time *pcf, struct rtc_time *rtc)
+{
+	pcf->time[PCF50633_TI_SEC] = bin2bcd(rtc->tm_sec);
+	pcf->time[PCF50633_TI_MIN] = bin2bcd(rtc->tm_min);
+	pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour);
+	pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday);
+	pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday);
+	pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon);
+	pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100);
+}
+
+static int
+pcf50633_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+	struct pcf50633_rtc *rtc = dev_get_drvdata(dev);
+
+	switch (cmd) {
+	case RTC_AIE_OFF:
+		rtc->alarm_enabled = 0;
+		pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
+		return 0;
+	case RTC_AIE_ON:
+		rtc->alarm_enabled = 1;
+		pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
+		return 0;
+	case RTC_UIE_OFF:
+		rtc->second_enabled = 0;
+		pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND);
+		return 0;
+	case RTC_UIE_ON:
+		rtc->second_enabled = 1;
+		pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND);
+		return 0;
+	}
+
+	return -ENOIOCTLCMD;
+}
+
+static int pcf50633_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+	struct pcf50633_rtc *rtc;
+	struct pcf50633_time pcf_tm;
+	int ret;
+
+	rtc = dev_get_drvdata(dev);
+
+	ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSC,
+					    PCF50633_TI_EXTENT,
+					    &pcf_tm.time[0]);
+	if (ret != PCF50633_TI_EXTENT) {
+		dev_err(dev, "Failed to read time\n");
+		return -EIO;
+	}
+
+	dev_dbg(dev, "PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
+		pcf_tm.time[PCF50633_TI_DAY],
+		pcf_tm.time[PCF50633_TI_MONTH],
+		pcf_tm.time[PCF50633_TI_YEAR],
+		pcf_tm.time[PCF50633_TI_HOUR],
+		pcf_tm.time[PCF50633_TI_MIN],
+		pcf_tm.time[PCF50633_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 rtc_valid_tm(tm);
+}
+
+static int pcf50633_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+	struct pcf50633_rtc *rtc;
+	struct pcf50633_time pcf_tm;
+	int second_masked, alarm_masked, ret = 0;
+
+	rtc = 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[PCF50633_TI_DAY],
+		pcf_tm.time[PCF50633_TI_MONTH],
+		pcf_tm.time[PCF50633_TI_YEAR],
+		pcf_tm.time[PCF50633_TI_HOUR],
+		pcf_tm.time[PCF50633_TI_MIN],
+		pcf_tm.time[PCF50633_TI_SEC]);
+
+
+	second_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_SECOND);
+	alarm_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_ALARM);
+
+	if (!second_masked)
+		pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND);
+	if (!alarm_masked)
+		pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
+
+	/* Returns 0 on success */
+	ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSC,
+					     PCF50633_TI_EXTENT,
+					     &pcf_tm.time[0]);
+
+	if (!second_masked)
+		pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND);
+	if (!alarm_masked)
+		pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
+
+	return ret;
+}
+
+static int pcf50633_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+	struct pcf50633_rtc *rtc;
+	struct pcf50633_time pcf_tm;
+	int ret = 0;
+
+	rtc = dev_get_drvdata(dev);
+
+	alrm->enabled = rtc->alarm_enabled;
+
+	ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSCA,
+				PCF50633_TI_EXTENT, &pcf_tm.time[0]);
+	if (ret != PCF50633_TI_EXTENT) {
+		dev_err(dev, "Failed to read time\n");
+		return -EIO;
+	}
+
+	pcf2rtc_time(&alrm->time, &pcf_tm);
+
+	return rtc_valid_tm(&alrm->time);
+}
+
+static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+	struct pcf50633_rtc *rtc;
+	struct pcf50633_time pcf_tm;
+	int alarm_masked, ret = 0;
+
+	rtc = dev_get_drvdata(dev);
+
+	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(rtc->pcf, PCF50633_IRQ_ALARM);
+
+	/* disable alarm interrupt */
+	if (!alarm_masked)
+		pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
+
+	/* Returns 0 on success */
+	ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA,
+				PCF50633_TI_EXTENT, &pcf_tm.time[0]);
+
+	if (!alarm_masked)
+		pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
+
+	return ret;
+}
+
+static struct rtc_class_ops pcf50633_rtc_ops = {
+	.ioctl		= pcf50633_rtc_ioctl,
+	.read_time	= pcf50633_rtc_read_time,
+	.set_time	= pcf50633_rtc_set_time,
+	.read_alarm	= pcf50633_rtc_read_alarm,
+	.set_alarm	= pcf50633_rtc_set_alarm,
+};
+
+static void pcf50633_rtc_irq(int irq, void *data)
+{
+	struct pcf50633_rtc *rtc = data;
+
+	switch (irq) {
+	case PCF50633_IRQ_ALARM:
+		rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
+		break;
+	case PCF50633_IRQ_SECOND:
+		rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
+		break;
+	}
+}
+
+static int __devinit pcf50633_rtc_probe(struct platform_device *pdev)
+{
+	struct pcf50633_subdev_pdata *pdata;
+	struct pcf50633_rtc *rtc;
+	struct rtc_device *rtc_dev;
+
+	rtc_dev = rtc_device_register("pcf50633-rtc", &pdev->dev,
+				&pcf50633_rtc_ops, THIS_MODULE);

drivers/rtc/rtc-pcf50633.c line 282

Quoted 10 lines
drivers/rtc/rtc-pcf50633.c new file +10 -0
+
+	if (IS_ERR(rtc_dev))
+		return PTR_ERR(rtc_dev);
+
+	rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
+	if (!rtc) {
+		dev_err(&pdev->dev, "allocation of pcf50633_rtc failed\n");
+		rtc_device_unregister(rtc_dev);
+		return -ENOMEM;
+	}

once registered, the rtc could be immediately in use. you should first allocate and setup your data structures and only then register the device:

	rtc = kzalloc(....
	if (rtc == NULL)
		return -ENOMEM;

	..setup rtc structs here...

	rtc->dev = rtc_register(...

	..irqs...
Quoted 12 lines
drivers/rtc/rtc-pcf50633.c new file +12 -0
+	pdata = pdev->dev.platform_data;
+	rtc->pcf = pdata->pcf;
+	rtc->rtc_dev = rtc_dev;
+	platform_set_drvdata(pdev, rtc);
+
+	pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_ALARM,
+					pcf50633_rtc_irq, rtc);
+	pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_SECOND,
+					pcf50633_rtc_irq, rtc);
+
+	return 0;
+}

drivers/rtc/rtc-pcf50633.c line 305

Quoted 10 lines
drivers/rtc/rtc-pcf50633.c new file +10 -0
+
+static int __devexit pcf50633_rtc_remove(struct platform_device *pdev)
+{
+	struct pcf50633_rtc *rtc;
+
+	rtc = platform_get_drvdata(pdev);
+	rtc_device_unregister(rtc->rtc_dev);
+
+	pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_ALARM);
+	pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_SECOND);

please remove rtc before unregistering

Quoted 31 lines
drivers/rtc/rtc-pcf50633.c new file +30 -0
+	kfree(rtc);
+
+	return 0;
+}
+
+
+static struct platform_driver pcf50633_rtc_driver = {
+	.driver = {
+		.name = "pcf50633-rtc",
+	},
+	.probe = pcf50633_rtc_probe,
+	.remove = __devexit_p(pcf50633_rtc_remove),
+};
+
+static int __init pcf50633_rtc_init(void)
+{
+	return platform_driver_register(&pcf50633_rtc_driver);
+}
+module_init(pcf50633_rtc_init);
+
+static void __exit pcf50633_rtc_exit(void)
+{
+	platform_driver_unregister(&pcf50633_rtc_driver);
+}
+module_exit(pcf50633_rtc_exit);
+
+MODULE_DESCRIPTION("PCF50633 RTC driver");
+MODULE_AUTHOR("Balaji Rao <[email protected]>");
+MODULE_LICENSE("GPL");
+
Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
author
#12 lore raw

Re: [PATCH V2 4/7] rtc: PCF50633 rtc driver

Quoted 9 lines · Alessandro Zummo
Quoted 6 lines · On Thu, 18 Dec 2008 11:27:26 +0530 Balaji Rao <[email protected]> wrote:

Changes from V1:
- Removed include/linux/mfd/pcf50633/rtc.h and moved defenitions into the source file.
- Remove PIE and introduce UIE support. UIE being the one actually supported in the chip.

Quoted 5 lines
Quoted 1 line

Alessandro, I'll change to the new API for AIE once it appears upstream.

Ok, I guess the driver will not go in tomorrow, so you can wait. I'd add it now, while you're at it :)

OK! :) So that I can change when it's in -next ?

Quoted 9 lines

drivers/rtc/Kconfig config RTC_DRV_WM8350 · line 504

Quoted 5 lines
drivers/rtc/Kconfig +5 -0
+config RTC_DRV_PCF50633
+	depends on MFD_PCF50633
+	tristate "NXP PCF50633 RTC"
+	help
+	  If you say yes here you get support for the NXP PCF50633 RTC.

a more detailed description please stating which platforms commonly have this rtc

OK.

Quoted 13 lines
Quoted 13 lines
drivers/rtc/rtc-pcf50633.c new file +13 -0
+static int __devinit pcf50633_rtc_probe(struct platform_device *pdev)
+{
+	struct pcf50633_subdev_pdata *pdata;
+	struct pcf50633_rtc *rtc;
+	struct rtc_device *rtc_dev;
+
+	rtc_dev = rtc_device_register("pcf50633-rtc", &pdev->dev,
+				&pcf50633_rtc_ops, THIS_MODULE);
+
+	if (IS_ERR(rtc_dev))
+		return PTR_ERR(rtc_dev);
+
+	rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
Quoted 9 lines

drivers/rtc/rtc-pcf50633.c line 282

Quoted 5 lines
drivers/rtc/rtc-pcf50633.c new file +5 -0
+	if (!rtc) {
+		dev_err(&pdev->dev, "allocation of pcf50633_rtc failed\n");
+		rtc_device_unregister(rtc_dev);
+		return -ENOMEM;
+	}

once registered, the rtc could be immediately in use. you should first allocate and setup your data structures and only then register the device:

Oh, yea right. Will fix.

Quoted 12 lines

drivers/rtc/rtc-pcf50633.c line 305

Quoted 9 lines
drivers/rtc/rtc-pcf50633.c new file +9 -0
+static int __devexit pcf50633_rtc_remove(struct platform_device *pdev)
+{
+	struct pcf50633_rtc *rtc;
+
+	rtc = platform_get_drvdata(pdev);
+	rtc_device_unregister(rtc->rtc_dev);
+
+	pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_ALARM);
+	pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_SECOND);

please remove rtc before unregistering

Sorry, didn't get you meant.

Thank you for the review.

-Balaji

#13 lore raw

Re: [PATCH V2 4/7] rtc: PCF50633 rtc driver

Quoted 9 lines · On Thu, 18 Dec 2008 20:41:43 +0530 Balaji Rao <[email protected]> wrote:
Quoted 5 lines
drivers/rtc/rtc-pcf50633.c new file +1 -0
+	pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_ALARM);

drivers/rtc/rtc-pcf50633.c line 305

Quoted 1 line
drivers/rtc/rtc-pcf50633.c new file +1 -0
+	pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_SECOND);  

please remove rtc before unregistering

Sorry, didn't get you meant.

Thank you for the review.

my fault. s/rtc/irq/

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
author
#14 lore raw

PATCH v2 5/7 power_supply: PCF50633 battery charger driver

In reply to Balaji Rao
Cc Andy Green <[email protected]>
Cc Anton Vorontsov <[email protected]>
Cc David Woodhouse <[email protected]>
---
 drivers/power/Kconfig            |    6 +
 drivers/power/Makefile           |    2 
 drivers/power/pcf50633-charger.c |  358 ++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/pcf50633/mbc.h |  134 ++++++++++++++
 4 files changed, 500 insertions(+), 0 deletions(-)
 create mode 100644 drivers/power/pcf50633-charger.c
 create mode 100644 include/linux/mfd/pcf50633/mbc.h
drivers/power/Kconfig +6 -0
index 52f8676..04f6316 100644
@@ -75,4 +75,10 @@ config BATTERY_BQ27x00
 	help
 	  Say Y here to enable support for batteries with BQ27200(I2C) chip.
 
+config CHARGER_PCF50633
+	tristate "NXP PCF50633 MBC"
+	depends on MFD_PCF50633
+	help
+	 Say Y to include support for NXP PCF50633 Main Battery Charger.
+
 endif # POWER_SUPPLY
drivers/power/Makefile +2 -0
index e6f6865..62bcb76 100644
@@ -24,3 +24,5 @@ obj-$(CONFIG_BATTERY_OLPC)	+= olpc_battery.o
 obj-$(CONFIG_BATTERY_TOSA)	+= tosa_battery.o
 obj-$(CONFIG_BATTERY_WM97XX)	+= wm97xx_battery.o
 obj-$(CONFIG_BATTERY_BQ27x00)	+= bq27x00_battery.o
+
+obj-$(CONFIG_CHARGER_PCF50633)	+= pcf50633-charger.o
drivers/power/pcf50633-charger.c new file +358 -0

358 lines not on this page · raw message

include/linux/mfd/pcf50633/mbc.h new file +134 -0

134 lines not on this page · raw message

author
#15 lore raw

Re: [PATCH V2 5/7] power_supply: PCF50633 battery charger driver

Quoted 4 lines · Balaji Rao
(quoted diff) +4 -0
+int pcf50633_mbc_get_status(struct pcf50633 *pcf)
+{
+	struct pcf50633_mbc *mbc  = platform_get_drvdata(pcf->mbc_pdev);
+	int status = 0;

Review

Quoted 10 lines
(quoted diff) +10 -0
+
+	if (mbc->usb_online)
+		status |= PCF50633_MBC_USB_ONLINE;
+	if (mbc->usb_online)
+		status |= PCF50633_MBC_USB_ACTIVE;
+	if (mbc->usb_online)
+		status |= PCF50633_MBC_ADAPTER_ONLINE;
+	if (mbc->usb_online)
+		status |= PCF50633_MBC_ADAPTER_ACTIVE;
+

Oops! copy-paste error.. Fixed. Resending..

Cc Andy Green <[email protected]>
Cc Anton Vorontsov <[email protected]>
Cc David Woodhouse <[email protected]>
---
 drivers/power/Kconfig            |    6 +
 drivers/power/Makefile           |    2 
 drivers/power/pcf50633-charger.c |  358 ++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/pcf50633/mbc.h |  134 ++++++++++++++
 4 files changed, 500 insertions(+), 0 deletions(-)
 create mode 100644 drivers/power/pcf50633-charger.c
 create mode 100644 include/linux/mfd/pcf50633/mbc.h
drivers/power/Kconfig +6 -0
index 52f8676..04f6316 100644
@@ -75,4 +75,10 @@ config BATTERY_BQ27x00
 	help
 	  Say Y here to enable support for batteries with BQ27200(I2C) chip.
 
+config CHARGER_PCF50633
+	tristate "NXP PCF50633 MBC"
+	depends on MFD_PCF50633
+	help
+	 Say Y to include support for NXP PCF50633 Main Battery Charger.
+
 endif # POWER_SUPPLY
drivers/power/Makefile +2 -0
index e6f6865..62bcb76 100644
@@ -24,3 +24,5 @@ obj-$(CONFIG_BATTERY_OLPC)	+= olpc_battery.o
 obj-$(CONFIG_BATTERY_TOSA)	+= tosa_battery.o
 obj-$(CONFIG_BATTERY_WM97XX)	+= wm97xx_battery.o
 obj-$(CONFIG_BATTERY_BQ27x00)	+= bq27x00_battery.o
+
+obj-$(CONFIG_CHARGER_PCF50633)	+= pcf50633-charger.o
drivers/power/pcf50633-charger.c new file +358 -0

358 lines not on this page · raw message

include/linux/mfd/pcf50633/mbc.h new file +134 -0

134 lines not on this page · raw message

Acked-by on v2 5/7
#16 lore raw

Re: [PATCH V2 5/7] power_supply: PCF50633 battery charger driver

In reply to Balaji Rao
Quoted 5 lines · Balaji Rao
Cc Andy Green <[email protected]>
Cc Anton Vorontsov <[email protected]>
Cc David Woodhouse <[email protected]>

---

(As the patch depends on MFD parts, I assume Samuel will merge it into linux-mfd.)

Quoted 7 lines
 drivers/power/Kconfig            |    6 +
 drivers/power/Makefile           |    2 
 drivers/power/pcf50633-charger.c |  358 ++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/pcf50633/mbc.h |  134 ++++++++++++++
 4 files changed, 500 insertions(+), 0 deletions(-)
 create mode 100644 drivers/power/pcf50633-charger.c
 create mode 100644 include/linux/mfd/pcf50633/mbc.h

[...]

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
author
#17 lore raw

Re: [PATCH V2 5/7] power_supply: PCF50633 battery charger driver

Quoted 7 lines · Anton Vorontsov
Quoted 5 lines · Balaji Rao
Cc Andy Green <[email protected]>
Cc Anton Vorontsov <[email protected]>
Cc David Woodhouse <[email protected]>

---

Quoted 5 lines

(As the patch depends on MFD parts, I assume Samuel will merge it into linux-mfd.)

Yes. thanks a lot!

- Balaji

author
#18 lore raw

PATCH v2 6/7 input: PCF50633 input driver

In reply to Balaji Rao
Cc Andy Green <[email protected]>
Cc Dmitry Torokhov <[email protected]>
---
 drivers/input/misc/Kconfig          |    7 ++
 drivers/input/misc/Makefile         |    1 
 drivers/input/misc/pcf50633-input.c |  132 +++++++++++++++++++++++++++++++++++
 3 files changed, 140 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/pcf50633-input.c
drivers/input/misc/Kconfig +7 -0
index 199055d..67e5553 100644
@@ -220,4 +220,11 @@ config HP_SDC_RTC
 	  Say Y here if you want to support the built-in real time clock
 	  of the HP SDC controller.
 
+config INPUT_PCF50633_PMU
+	tristate "PCF50633 PMU events"
+	depends on MFD_PCF50633
+	help
+	 Say Y to include support for delivering  PMU events via  input
+	 layer on NXP PCF50633.
+
 endif
drivers/input/misc/Makefile +1 -0
index d7db2ae..bb62e6e 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
 obj-$(CONFIG_INPUT_APANEL)		+= apanel.o
 obj-$(CONFIG_INPUT_SGI_BTNS)		+= sgi_btns.o
+obj-$(CONFIG_INPUT_PCF50633_PMU)	+= pcf50633-input.o
drivers/input/misc/pcf50633-input.c new file +132 -0

132 lines not on this page · raw message

author
#19 lore raw

PATCH v2 7/7 regulator: PCF50633 pmic driver

In reply to Balaji Rao

Changes from V1:
- Removed support for suspend_enable & suspend_disable functions.

Cc Andy Green <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
---
 drivers/regulator/Kconfig              |    7 +
 drivers/regulator/Makefile             |    1 
 drivers/regulator/pcf50633-regulator.c |  330 ++++++++++++++++++++++++++++++++
 include/linux/mfd/pcf50633/pmic.h      |   68 +++++++
 4 files changed, 406 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/pcf50633-regulator.c
 create mode 100644 include/linux/mfd/pcf50633/pmic.h
drivers/regulator/Kconfig +7 -0
index 39360e2..e7e0cf1 100644
@@ -73,4 +73,11 @@ config REGULATOR_DA903X
 	  Say y here to support the BUCKs and LDOs regulators found on
 	  Dialog Semiconductor DA9030/DA9034 PMIC.
 
+config REGULATOR_PCF50633
+	tristate "PCF50633 regulator driver"
+        depends on MFD_PCF50633
+	help
+	 Say Y here to support the voltage regulators and convertors
+	 on PCF50633
+
 endif
drivers/regulator/Makefile +1 -0
index 254d40c..61b30c6 100644
@@ -11,5 +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
 
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
drivers/regulator/pcf50633-regulator.c new file +330 -0

330 lines not on this page · raw message

include/linux/mfd/pcf50633/pmic.h new file +68 -0

68 lines not on this page · raw message

Acked-by on v2 7/7
#20 lore raw

Re: [PATCH V2 7/7] regulator: PCF50633 pmic driver

Quoted 6 lines · Balaji Rao

Changes from V1:
- Removed support for suspend_enable & suspend_disable functions.

Cc Andy Green <[email protected]>
Cc Liam Girdwood <[email protected]>

That should be slimlogic with two ls - fixed in the CCs and not cutting any text for his benefit.

Quoted 1 line
Cc Mark Brown <[email protected]>
Quoted 447 lines
---
 drivers/regulator/Kconfig              |    7 +
 drivers/regulator/Makefile             |    1 
 drivers/regulator/pcf50633-regulator.c |  330 ++++++++++++++++++++++++++++++++
 include/linux/mfd/pcf50633/pmic.h      |   68 +++++++
 4 files changed, 406 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/pcf50633-regulator.c
 create mode 100644 include/linux/mfd/pcf50633/pmic.h
drivers/regulator/Kconfig +7 -0
index 39360e2..e7e0cf1 100644
@@ -73,4 +73,11 @@ config REGULATOR_DA903X
 	  Say y here to support the BUCKs and LDOs regulators found on
 	  Dialog Semiconductor DA9030/DA9034 PMIC.
 
+config REGULATOR_PCF50633
+	tristate "PCF50633 regulator driver"
+        depends on MFD_PCF50633
+	help
+	 Say Y here to support the voltage regulators and convertors
+	 on PCF50633
+
 endif
drivers/regulator/Makefile +1 -0
index 254d40c..61b30c6 100644
@@ -11,5 +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
 
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
drivers/regulator/pcf50633-regulator.c new file +330 -0
new file mode 100644
index 0000000..7a5d732
@@ -0,0 +1,330 @@
+/* NXP PCF50633 PMIC Driver
+ *
+ * (C) 2006-2008 by Openmoko, Inc.
+ * Author: Balaji Rao <[email protected]>
+ * All rights reserved.
+ *
+ * Broken down from monstrous PCF50633 driver mainly by
+ * Harald Welte and 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+
+#include <linux/mfd/pcf50633/core.h>
+#include <linux/mfd/pcf50633/pmic.h>
+
+#define PCF50633_REGULATOR(_name, _id) 		\
+	{					\
+		.name = _name, 			\
+		.id = _id,			\
+		.ops = &pcf50633_regulator_ops,	\
+		.type = REGULATOR_VOLTAGE, 	\
+		.owner = THIS_MODULE, 		\
+	}
+
+static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = {
+	[PCF50633_REGULATOR_AUTO]	= PCF50633_REG_AUTOOUT,
+	[PCF50633_REGULATOR_DOWN1]	= PCF50633_REG_DOWN1OUT,
+	[PCF50633_REGULATOR_DOWN2]	= PCF50633_REG_DOWN2OUT,
+	[PCF50633_REGULATOR_MEMLDO]	= PCF50633_REG_MEMLDOOUT,
+	[PCF50633_REGULATOR_LDO1]	= PCF50633_REG_LDO1OUT,
+	[PCF50633_REGULATOR_LDO2]	= PCF50633_REG_LDO2OUT,
+	[PCF50633_REGULATOR_LDO3]	= PCF50633_REG_LDO3OUT,
+	[PCF50633_REGULATOR_LDO4]	= PCF50633_REG_LDO4OUT,
+	[PCF50633_REGULATOR_LDO5]	= PCF50633_REG_LDO5OUT,
+	[PCF50633_REGULATOR_LDO6]	= PCF50633_REG_LDO6OUT,
+	[PCF50633_REGULATOR_HCLDO]	= PCF50633_REG_HCLDOOUT,
+};
+
+/* Bits from voltage value */
+static u8 auto_voltage_bits(unsigned int millivolts)
+{
+	if (millivolts < 1800)
+		return 0;
+	if (millivolts > 3800)
+		return 0xff;
+
+	millivolts -= 625;
+
+	return millivolts / 25;
+}
+
+static u8 down_voltage_bits(unsigned int millivolts)
+{
+	if (millivolts < 625)
+		return 0;
+	else if (millivolts > 3000)
+		return 0xff;
+
+	millivolts -= 625;
+
+	return millivolts / 25;
+}
+
+static u8 ldo_voltage_bits(unsigned int millivolts)
+{
+	if (millivolts < 900)
+		return 0;
+	else if (millivolts > 3600)
+		return 0x1f;
+
+	millivolts -= 900;
+	return millivolts / 100;
+}
+
+/* Obtain voltage value from bits */
+static unsigned int auto_voltage_value(u8 bits)
+{
+	if (bits < 0x2f)
+		return 0;
+
+	return 625 + (bits * 25);
+}
+
+
+static unsigned int down_voltage_value(u8 bits)
+{
+	return 625 + (bits * 25);
+}
+
+
+static unsigned int ldo_voltage_value(u8 bits)
+{
+	bits &= 0x1f;
+
+	return 900 + (bits * 100);
+}
+
+static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev,
+						int min_uV, int max_uV)
+{
+	struct pcf50633 *pcf;
+	int regulator_id, millivolts;
+	u8 volt_bits, regnr;
+
+	pcf = rdev_get_drvdata(rdev);
+
+	regulator_id = rdev_get_id(rdev);
+	if (regulator_id >= PCF50633_NUM_REGULATORS)
+		return -EINVAL;
+
+	millivolts = min_uV / 1000;
+
+	regnr = pcf50633_regulator_registers[regulator_id];
+
+	switch (regulator_id) {
+	case PCF50633_REGULATOR_AUTO:
+		volt_bits = auto_voltage_bits(millivolts);
+		break;
+	case PCF50633_REGULATOR_DOWN1:
+		volt_bits = down_voltage_bits(millivolts);
+		break;
+	case PCF50633_REGULATOR_DOWN2:
+		volt_bits = down_voltage_bits(millivolts);
+		break;
+	case PCF50633_REGULATOR_LDO1:
+	case PCF50633_REGULATOR_LDO2:
+	case PCF50633_REGULATOR_LDO3:
+	case PCF50633_REGULATOR_LDO4:
+	case PCF50633_REGULATOR_LDO5:
+	case PCF50633_REGULATOR_LDO6:
+	case PCF50633_REGULATOR_HCLDO:
+		volt_bits = ldo_voltage_bits(millivolts);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return pcf50633_reg_write(pcf, regnr, volt_bits);
+}
+
+static int pcf50633_regulator_get_voltage(struct regulator_dev *rdev)
+{
+	struct pcf50633 *pcf;
+	int regulator_id, millivolts, volt_bits;
+	u8 regnr;
+
+	pcf = rdev_get_drvdata(rdev);;
+
+	regulator_id = rdev_get_id(rdev);
+	if (regulator_id >= PCF50633_NUM_REGULATORS)
+		return -EINVAL;
+
+	regnr = pcf50633_regulator_registers[regulator_id];
+
+	volt_bits = pcf50633_reg_read(pcf, regnr);
+	if (volt_bits < 0)
+		return -1;
+
+	switch (regulator_id) {
+	case PCF50633_REGULATOR_AUTO:
+		millivolts = auto_voltage_value(volt_bits);
+		break;
+	case PCF50633_REGULATOR_DOWN1:
+		millivolts = down_voltage_value(volt_bits);
+		break;
+	case PCF50633_REGULATOR_DOWN2:
+		millivolts = down_voltage_value(volt_bits);
+		break;
+	case PCF50633_REGULATOR_LDO1:
+	case PCF50633_REGULATOR_LDO2:
+	case PCF50633_REGULATOR_LDO3:
+	case PCF50633_REGULATOR_LDO4:
+	case PCF50633_REGULATOR_LDO5:
+	case PCF50633_REGULATOR_LDO6:
+	case PCF50633_REGULATOR_HCLDO:
+		millivolts = ldo_voltage_value(volt_bits);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return millivolts * 1000;
+}
+
+static int pcf50633_regulator_enable(struct regulator_dev *rdev)
+{
+	struct pcf50633 *pcf = rdev_get_drvdata(rdev);
+	int regulator_id;
+	u8 regnr;
+
+	regulator_id = rdev_get_id(rdev);
+	if (regulator_id >= PCF50633_NUM_REGULATORS)
+		return -EINVAL;
+
+	/* The *ENA register is always one after the *OUT register */
+	regnr = pcf50633_regulator_registers[regulator_id] + 1;
+
+	return pcf50633_reg_set_bit_mask(pcf, regnr, PCF50633_REGULATOR_ON,
+						       PCF50633_REGULATOR_ON);
+
+}
+
+static int pcf50633_regulator_disable(struct regulator_dev *rdev)
+{
+	struct pcf50633 *pcf = rdev_get_drvdata(rdev);
+	int regulator_id;
+	u8 regnr;
+
+	regulator_id = rdev_get_id(rdev);
+	if (regulator_id >= PCF50633_NUM_REGULATORS)
+		return -EINVAL;
+
+	/* the *ENA register is always one after the *OUT register */
+	regnr = pcf50633_regulator_registers[regulator_id] + 1;
+
+	return pcf50633_reg_set_bit_mask(pcf, regnr,
+					PCF50633_REGULATOR_ON, 0);
+}
+
+static int pcf50633_regulator_is_enabled(struct regulator_dev *rdev)
+{
+	struct pcf50633 *pcf = rdev_get_drvdata(rdev);
+	int regulator_id = rdev_get_id(rdev);
+	u8 regnr;
+
+	regulator_id = rdev_get_id(rdev);
+	if (regulator_id >= PCF50633_NUM_REGULATORS)
+		return -EINVAL;
+
+	/* the *ENA register is always one after the *OUT register */
+	regnr = pcf50633_regulator_registers[regulator_id] + 1;
+
+	return pcf50633_reg_read(pcf, regnr) & PCF50633_REGULATOR_ON;
+}
+
+static struct regulator_ops pcf50633_regulator_ops = {
+	.set_voltage = pcf50633_regulator_set_voltage,
+	.get_voltage = pcf50633_regulator_get_voltage,
+	.enable = pcf50633_regulator_enable,
+	.disable = pcf50633_regulator_disable,
+	.is_enabled = pcf50633_regulator_is_enabled,
+};
+
+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_DOWN2] =
+		PCF50633_REGULATOR("down2", PCF50633_REGULATOR_DOWN2),
+	[PCF50633_REGULATOR_LDO1] =
+		PCF50633_REGULATOR("ldo1", PCF50633_REGULATOR_LDO1),
+	[PCF50633_REGULATOR_LDO2] =
+		PCF50633_REGULATOR("ldo2", PCF50633_REGULATOR_LDO2),
+	[PCF50633_REGULATOR_LDO3] =
+		PCF50633_REGULATOR("ldo3", PCF50633_REGULATOR_LDO3),
+	[PCF50633_REGULATOR_LDO4] =
+		PCF50633_REGULATOR("ldo4", PCF50633_REGULATOR_LDO4),
+	[PCF50633_REGULATOR_LDO5] =
+		PCF50633_REGULATOR("ldo5", PCF50633_REGULATOR_LDO5),
+	[PCF50633_REGULATOR_LDO6] =
+		PCF50633_REGULATOR("ldo6", PCF50633_REGULATOR_LDO6),
+	[PCF50633_REGULATOR_HCLDO] =
+		PCF50633_REGULATOR("hcldo", PCF50633_REGULATOR_HCLDO),
+	[PCF50633_REGULATOR_MEMLDO] =
+		PCF50633_REGULATOR("memldo", PCF50633_REGULATOR_MEMLDO),
+};
+
+static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
+{
+	struct regulator_dev *rdev;
+	struct pcf50633 *pcf;
+
+	/* Already set by core driver */
+	pcf = platform_get_drvdata(pdev);
+
+	rdev = regulator_register(&regulators[pdev->id], &pdev->dev, pcf);
+	if (IS_ERR(rdev))
+		return PTR_ERR(rdev);
+
+	if (pcf->pdata->regulator_registered)
+		pcf->pdata->regulator_registered(pcf, pdev->id);
+
+	return 0;
+}
+
+static int __devexit pcf50633_regulator_remove(struct platform_device *pdev)
+{
+	struct regulator_dev *rdev = platform_get_drvdata(pdev);
+
+	regulator_unregister(rdev);
+
+	return 0;
+}
+
+static struct platform_driver pcf50633_regulator_driver = {
+	.driver = {
+		.name = "pcf50633-regltr",
+	},
+	.probe = pcf50633_regulator_probe,
+	.remove = __devexit_p(pcf50633_regulator_remove),
+};
+
+static int __init pcf50633_regulator_init(void)
+{
+	return platform_driver_register(&pcf50633_regulator_driver);
+}
+module_init(pcf50633_regulator_init);
+
+static void __exit pcf50633_regulator_exit(void)
+{
+	platform_driver_unregister(&pcf50633_regulator_driver);
+}
+module_exit(pcf50633_regulator_exit);
+
+MODULE_AUTHOR("Balaji Rao <[email protected]>");
+MODULE_DESCRIPTION("PCF50633 regulator driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pcf50633-regulator");
include/linux/mfd/pcf50633/pmic.h new file +68 -0
new file mode 100644
index 0000000..8c567a1
@@ -0,0 +1,68 @@
+#ifndef __LINUX_MFD_PCF50633_PMIC_H
+#define __LINUX_MFD_PCF50633_PMIC_H
+
+#include <linux/mfd/pcf50633/core.h>
+#include <linux/platform_device.h>
+
+#define PCF50633_REG_AUTOOUT	0x1a
+#define PCF50633_REG_AUTOENA	0x1b
+#define PCF50633_REG_AUTOCTL	0x1c
+#define PCF50633_REG_AUTOMXC	0x1d
+#define PCF50633_REG_DOWN1OUT	0x1e
+#define PCF50633_REG_DOWN1ENA	0x1f
+#define PCF50633_REG_DOWN1CTL	0x20
+#define PCF50633_REG_DOWN1MXC	0x21
+#define PCF50633_REG_DOWN2OUT	0x22
+#define PCF50633_REG_DOWN2ENA	0x23
+#define PCF50633_REG_DOWN2CTL	0x24
+#define PCF50633_REG_DOWN2MXC	0x25
+#define PCF50633_REG_MEMLDOOUT	0x26
+#define PCF50633_REG_MEMLDOENA	0x27
+#define PCF50633_REG_LDO1OUT	0x2d
+#define PCF50633_REG_LDO1ENA	0x2e
+#define PCF50633_REG_LDO2OUT	0x2f
+#define PCF50633_REG_LDO2ENA	0x30
+#define PCF50633_REG_LDO3OUT	0x31
+#define PCF50633_REG_LDO3ENA	0x32
+#define PCF50633_REG_LDO4OUT	0x33
+#define PCF50633_REG_LDO4ENA	0x34
+#define PCF50633_REG_LDO5OUT	0x35
+#define PCF50633_REG_LDO5ENA	0x36
+#define PCF50633_REG_LDO6OUT	0x37
+#define PCF50633_REG_LDO6ENA	0x38
+#define PCF50633_REG_HCLDOOUT	0x39
+#define PCF50633_REG_HCLDOENA	0x3a
+#define PCF50633_REG_HCLDOOVL	0x40
+
+enum pcf50633_regulator_enable {
+	PCF50633_REGULATOR_ON		= 0x01,
+	PCF50633_REGULATOR_ON_GPIO1	= 0x02,
+	PCF50633_REGULATOR_ON_GPIO2	= 0x04,
+	PCF50633_REGULATOR_ON_GPIO3	= 0x08,
+};
+#define PCF50633_REGULATOR_ON_MASK	0x0f
+
+enum pcf50633_regulator_phase {
+	PCF50633_REGULATOR_ACTPH1	= 0x00,
+	PCF50633_REGULATOR_ACTPH2	= 0x10,
+	PCF50633_REGULATOR_ACTPH3	= 0x20,
+	PCF50633_REGULATOR_ACTPH4	= 0x30,
+};
+#define PCF50633_REGULATOR_ACTPH_MASK	0x30
+
+enum pcf50633_regulator_id {
+	PCF50633_REGULATOR_AUTO,
+	PCF50633_REGULATOR_DOWN1,
+	PCF50633_REGULATOR_DOWN2,
+	PCF50633_REGULATOR_LDO1,
+	PCF50633_REGULATOR_LDO2,
+	PCF50633_REGULATOR_LDO3,
+	PCF50633_REGULATOR_LDO4,
+	PCF50633_REGULATOR_LDO5,
+	PCF50633_REGULATOR_LDO6,
+	PCF50633_REGULATOR_HCLDO,
+	PCF50633_REGULATOR_MEMLDO,
+};
+
+#endif
+
author
#21 lore raw

Re: [PATCH V2 7/7] regulator: PCF50633 pmic driver

Quoted 11 lines · Mark Brown
Quoted 6 lines · Balaji Rao

Changes from V1:
- Removed support for suspend_enable & suspend_disable functions.

Cc Andy Green <[email protected]>
Cc Liam Girdwood <[email protected]>

That should be slimlogic with two ls - fixed in the CCs and not cutting any text for his benefit.

Ah! Sorry about that, I've read it wrongly right from the first time :( Will fix.

Thank you.

- Balaji

author
#23 lore raw

Re: [PATCH V2 7/7] regulator: PCF50633 pmic driver

Quoted 6 lines · Liam Girdwood
Quoted 5 lines · Balaji Rao
Quoted 4 lines · Mark Brown
Quoted 3 lines · Balaji Rao

Changes from V1:
- Removed support for suspend_enable & suspend_disable functions.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Cc Andy Green <[email protected]>
Cc Liam Girdwood <[email protected]>

Applied.

Thanks

Liam, the pcf50633-regulator.c has depends on include/linux/mfd/pcf50633/core.patch which is not here, but in [PATCH 1/7] of the series. So, pcf50633-regulator.c it wouldn't build.

I was expecting it to make it to -next via linux-mfd - I've asked Samuel Ortiz about this in [0/7].

So, I was hoping you to ack this so that Samuel can take it into linux-mfd.

I apologize for the confusion.

- Balaji

#24 lore raw

Re: [PATCH V2 7/7] regulator: PCF50633 pmic driver

Quoted 21 lines · Balaji Rao
Quoted 6 lines · Liam Girdwood
Quoted 5 lines · Balaji Rao
Quoted 4 lines · Mark Brown
Quoted 3 lines · Balaji Rao

Changes from V1:
- Removed support for suspend_enable & suspend_disable functions.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Cc Andy Green <[email protected]>
Cc Liam Girdwood <[email protected]>

Applied.

Thanks

Liam, the pcf50633-regulator.c has depends on include/linux/mfd/pcf50633/core.patch which is not here, but in [PATCH 1/7] of the series. So, pcf50633-regulator.c it wouldn't build.

Quoted 7 lines

I was expecting it to make it to -next via linux-mfd - I've asked Samuel Ortiz about this in [0/7].

So, I was hoping you to ack this so that Samuel can take it into linux-mfd.

I apologize for the confusion.

Ok. Np.

Thanks

Liam

#25 lore raw
In reply to Balaji Rao

Hi Balaji,

Quoted 13 lines · Balaji Rao

Changes from V1:
- Subdevice specific header files now included in its respective patch.
- Introduces pcf50633_register_irq and pcf50633_free_irq for irq management
- Many changes in how subdevices are created and information is passed to them. Thanks to Alessandro Zummo for suggestions.

The following series implements support for NXP PCF50633. It's basically an I2C device with 9 regulators, an ADC, a PMIC, a Battery Charger and a RTC.

This chip is used in Openmoko Neo Freerunner mobile phone.

Quoted 7 lines

Driver for a similar chip PCF50606, used in Openmoko Neo 1973 device will follow soon.

The specs are open and are available at
http://people.openmoko.org/tony_tu/GTA02/datasheet/PMU/PCF50633DS_02.pdf

Samuel, are you ok with merging this via linux-mfd tree ?

Yes, I'm fine with it. Two things though:
- Could you please resend the non-mfd parts (patch 4,5,6 and 7) to me ?
- I see from the lkml archives that patches 5 and 6 didnt get Acked yet. I'll queue them, but I'd really like to get Anton and Dmitry approval before sending them upstream.

Cheers,
Samuel.

Quoted 52 lines

---
Balaji Rao (7):
mfd: PCF50633 core driver
mfd: PCF50633 adc driver
mfd: PCF50633 gpio support
rtc: PCF50633 rtc driver
power_supply: PCF50633 battery charger driver
input: PCF50633 input driver
regulator: PCF50633 pmic driver

 drivers/input/misc/Kconfig             |    7 
 drivers/input/misc/Makefile            |    1 
 drivers/input/misc/pcf50633-input.c    |  132 ++++++
 drivers/mfd/Kconfig                    |   23 +
 drivers/mfd/Makefile                   |    6 
 drivers/mfd/pcf50633-adc.c             |  277 +++++++++++++
 drivers/mfd/pcf50633-core.c            |  707 ++++++++++++++++++++++++++++++++
 drivers/mfd/pcf50633-gpio.c            |  118 +++++
 drivers/power/Kconfig                  |    6 
 drivers/power/Makefile                 |    2 
 drivers/power/pcf50633-charger.c       |  358 ++++++++++++++++
 drivers/regulator/Kconfig              |    7 
 drivers/regulator/Makefile             |    1 
 drivers/regulator/pcf50633-regulator.c |  330 +++++++++++++++
 drivers/rtc/Kconfig                    |    6 
 drivers/rtc/Makefile                   |    1 
 drivers/rtc/rtc-pcf50633.c             |  336 +++++++++++++++
 include/linux/mfd/pcf50633/adc.h       |   72 +++
 include/linux/mfd/pcf50633/core.h      |  218 ++++++++++
 include/linux/mfd/pcf50633/gpio.h      |   52 ++
 include/linux/mfd/pcf50633/mbc.h       |  134 ++++++
 include/linux/mfd/pcf50633/pmic.h      |   68 +++
 22 files changed, 2861 insertions(+), 1 deletions(-)
 create mode 100644 drivers/input/misc/pcf50633-input.c
 create mode 100644 drivers/mfd/pcf50633-adc.c
 create mode 100644 drivers/mfd/pcf50633-core.c
 create mode 100644 drivers/mfd/pcf50633-gpio.c
 create mode 100644 drivers/power/pcf50633-charger.c
 create mode 100644 drivers/regulator/pcf50633-regulator.c
 create mode 100644 drivers/rtc/rtc-pcf50633.c
 create mode 100644 include/linux/mfd/pcf50633/adc.h
 create mode 100644 include/linux/mfd/pcf50633/core.h
 create mode 100644 include/linux/mfd/pcf50633/gpio.h
 create mode 100644 include/linux/mfd/pcf50633/mbc.h
 create mode 100644 include/linux/mfd/pcf50633/pmic.h
Signature · 2 lines
Thanks,
Balaji Rao
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/