*** SUBJECT HERE ***
Subsystems (5)
cover *** SUBJECT HERE ***
From: Abhijeet Dharmapurikar <[email protected]>
This patch series adds support for pmic 8921 chip and its subdevices. The pmic 8921 chip is used as a power management ic for 8960 based boards. It communicates over the ssbi bus, ssbi bus can be found here
https://patchwork.kernel.org/patch/601771/
The patch set contains support for interrupt, gpio and mpp (multi purpose pin) subdevices.
Note that gpio and mpp subdevices need the interrupt subdevice to be operational, this is becuase the reading the the value of gpio/mpp lines happens by doing a transaction over registers managed by the interrupt subdev. The code invokes a call on interrupt subdevice, rather than writing to those registers directly, avoiding race conditions.
Abhijeet Dharmapurikar (5):
mfd: pm8921: Add PMIC 8921 core driver
mfd: pm8xxx: Add irq support
gpio: pm8xxx-gpio: Add pm8xxx gpio driver
MAINTAINERS: Add pmic8921, pmic8xxx subdevices maintainers
msm: board-8960: Add support for pm8921
David Collins (1):
mfd: pm8xxx-mpp: Add pm8xxx MPP driver
MAINTAINERS | 6 + arch/arm/mach-msm/board-msm8960.c | 47 ++- arch/arm/mach-msm/include/mach/irqs-8960.h | 9 +- drivers/gpio/Kconfig | 10 + drivers/gpio/Makefile | 1 + drivers/gpio/pm8xxx-gpio.c | 452 +++++++++++++++++++++ drivers/mfd/Kconfig | 41 ++ drivers/mfd/Makefile | 3 + drivers/mfd/pm8921-core.c | 288 +++++++++++++ drivers/mfd/pm8xxx-irq.c | 599 ++++++++++++++++++++++++++++ drivers/mfd/pm8xxx-mpp.c | 319 +++++++++++++++ include/linux/mfd/pm8921.h | 48 +++ include/linux/mfd/pm8xxx/core.h | 75 ++++ include/linux/mfd/pm8xxx/gpio.h | 132 ++++++ include/linux/mfd/pm8xxx/irq.h | 62 +++ include/linux/mfd/pm8xxx/mpp.h | 233 +++++++++++ 16 files changed, 2310 insertions(+), 15 deletions(-) create mode 100644 drivers/gpio/pm8xxx-gpio.c create mode 100644 drivers/mfd/pm8921-core.c create mode 100644 drivers/mfd/pm8xxx-irq.c create mode 100644 drivers/mfd/pm8xxx-mpp.c create mode 100644 include/linux/mfd/pm8921.h create mode 100644 include/linux/mfd/pm8xxx/core.h create mode 100644 include/linux/mfd/pm8xxx/gpio.h create mode 100644 include/linux/mfd/pm8xxx/irq.h create mode 100644 include/linux/mfd/pm8xxx/mpp.h
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
PATCH 1/6 mfd: pm8921: Add PMIC 8921 core driver
From: Abhijeet Dharmapurikar <[email protected]>
Add support for the Qualcomm PM8921 PMIC chip. The core driver will communicate with the PMIC chip via the MSM SSBI bus.
--- drivers/mfd/Kconfig | 23 +++++ drivers/mfd/Makefile | 1 + drivers/mfd/pm8921-core.c | 172 +++++++++++++++++++++++++++++++++++++++ include/linux/mfd/pm8921.h | 26 ++++++ include/linux/mfd/pm8xxx/core.h | 66 +++++++++++++++ 5 files changed, 288 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/pm8921-core.c create mode 100644 include/linux/mfd/pm8921.h create mode 100644 include/linux/mfd/pm8xxx/core.h
drivers/mfd/Kconfig +23 -0
@@ -624,6 +624,29 @@ config MFD_WL1273_CORE driver connects the radio-wl1273 V4L2 module and the wl1273 audio codec. +config MFD_PM8XXX + tristate "Support for Qualcomm PM8xxx subdevices" + help + This option enables the usage of various Qualcomm PMIC 8xxx subdevice + drivers. This is required in order to use generic PM8xxx subdevice + drivers. Selecting with option will result in PM8xxx subdevice + drivers being compiled by default. + +config MFD_PM8921_CORE + tristate "Qualcomm PM8921 PMIC chip" + depends on MSM_SSBI + select MFD_CORE + select MFD_PM8XXX + help + If you say yes to this option, support will be included for the + built-in PM8921 PMIC chip + + This is required if your board has a PM8921 and uses its features, + such as: MPPs, GPIOs, regulators, interrupts, and PWM. + + Say M here if you want to include support for PM8921 chip as a module. + This will build a module called "pm8921-core.ko". + endif # MFD_SUPPORT menu "Multimedia Capabilities Port drivers"
drivers/mfd/Makefile +1 -0
@@ -83,3 +83,4 @@ obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o obj-$(CONFIG_MFD_VX855) += vx855.o obj-$(CONFIG_MFD_WL1273_CORE) += wl1273-core.o obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o +obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o
drivers/mfd/pm8921-core.c new file +172 -0
172 lines not on this page · raw message
include/linux/mfd/pm8921.h new file +26 -0
@@ -0,0 +1,26 @@ +/* Copyright (c) 2011, Code Aurora Forum. 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 version 2 and +* only version 2 as published by the Free Software Foundation. +* +* 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. +*/ +/* +* Qualcomm PMIC 8921 driver header file +* +*/ + +#ifndef __MFD_PM8921_H +#define __MFD_PM8921_H + +#include <linux/device.h> + +struct pm8921_platform_data { +int irq_base; +}; + +#endif
include/linux/mfd/pm8xxx/core.h new file +66 -0
66 lines not on this page · raw message
Signature · 4 lines
1.7.1 Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
Re: [Qualcomm PM8921 MFD 1/6] mfd: pm8921: Add PMIC 8921 core driver
drivers/mfd/Kconfig config MFD_WL1273_CORE · line 633
Quoted 7 lines · adharmap at codeaurora.org
drivers/mfd/Kconfig +7
-0+config MFD_PM8XXX + tristate "Support for Qualcomm PM8xxx subdevices" + help + This option enables the usage of various Qualcomm PMIC 8xxx subdevice + drivers. This is required in order to use generic PM8xxx subdevice + drivers. Selecting with option will result in PM8xxx subdevice + drivers being compiled by default.
As this is selected by the driver it shouldn't have any help text - there's no point in users seeing the option since it's useless by itself. If we get enough to make an option useful either a menu or dependencies from the individual MFDs would be a better option.
drivers/mfd/pm8921-core.c line 76
Quoted 6 lines
drivers/mfd/pm8921-core.c new file +6
-0+static int __devinit pm8921_add_subdevices (const struct pm8921_platform_data + *pdata, +struct pm8921 *pmic) +{ +return 0 ; +}
This looks suspicious.
drivers/mfd/pm8921-core.c line 161
Quoted 5 lines
drivers/mfd/pm8921-core.c new file +5
-0+static int __init pm8921_init (void ) +{ +return platform_driver_register (&pm8921_driver); +} +postcore_initcall (pm8921_init);
Typically subsys_initcall() has been used.
Re: [Qualcomm PM8921 MFD 1/6] mfd: pm8921: Add PMIC 8921 core driver
Quoted 14 lines · Mark Brown
drivers/mfd/Kconfig config MFD_WL1273_CORE · line 633
Quoted 7 lines · adharmap at codeaurora.org
drivers/mfd/Kconfig +7
-0+config MFD_PM8XXX + tristate "Support for Qualcomm PM8xxx subdevices" + help + This option enables the usage of various Qualcomm PMIC 8xxx subdevice + drivers. This is required in order to use generic PM8xxx subdevice + drivers. Selecting with option will result in PM8xxx subdevice + drivers being compiled by default.As this is selected by the driver it shouldn't have any help text - there's no point in users seeing the option since it's useless by itself. If we get enough to make an option useful either a menu or dependencies from the individual MFDs would be a better option.
Agree will fix this.
Quoted 9 lines
drivers/mfd/pm8921-core.c line 76
Quoted 7 lines
drivers/mfd/pm8921-core.c new file +6
-0+static int __devinit pm8921_add_subdevices (const struct pm8921_platform_data + *pdata, +struct pm8921 *pmic) +{ +return 0 ; +}This looks suspicious.
True, the next patch fills in this function. Will remove it from here.
Quoted 8 lines
drivers/mfd/pm8921-core.c line 161
Quoted 6 lines
drivers/mfd/pm8921-core.c new file +5
-0+static int __init pm8921_init (void ) +{ +return platform_driver_register (&pm8921_driver); +} +postcore_initcall (pm8921_init);Typically
subsys_initcall()has been used.
Yes will change this and others to subsys_initcall()
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 2/6 mfd: pm8xxx: Add irq support
In reply to [email protected]From: Abhijeet Dharmapurikar <[email protected]>
Add support for the irq controller in Qualcomm 8xxx pmic. The 8xxx interrupt controller provides control for gpio and mpp configured as interrupts in addition to other subdevice interrupts. The interrupt controller also provides a way to read the real time status of an interrupt. This real time status is the only way one can get the input values of gpio and mpp lines.
--- drivers/mfd/Kconfig | 10 + drivers/mfd/Makefile | 1 + drivers/mfd/pm8921-core.c | 70 ++++- drivers/mfd/pm8xxx-irq.c | 599 +++++++++++++++++++++++++++++++++++++++ include/linux/mfd/pm8921.h | 6 +- include/linux/mfd/pm8xxx/core.h | 9 + include/linux/mfd/pm8xxx/irq.h | 62 ++++ 7 files changed, 748 insertions(+), 9 deletions(-) create mode 100644 drivers/mfd/pm8xxx-irq.c create mode 100644 include/linux/mfd/pm8xxx/irq.h
drivers/mfd/Kconfig +10 -0
@@ -647,6 +647,16 @@ config MFD_PM8921_CORE Say M here if you want to include support for PM8921 chip as a module. This will build a module called "pm8921-core.ko". +config MFD_PM8XXX_IRQ + bool "Support for Qualcomm PM8xxx IRQ features" + depends on MFD_PM8XXX + default y if MFD_PM8XXX + help + This is the IRQ driver for Qualcomm PM 8xxx PMIC chips. + + This is required to use certain other PM 8xxx features, such as GPIO + and MPP. + endif # MFD_SUPPORT menu "Multimedia Capabilities Port drivers"
drivers/mfd/Makefile +1 -0
@@ -84,3 +84,4 @@ obj-$(CONFIG_MFD_VX855) += vx855.o obj-$(CONFIG_MFD_WL1273_CORE) += wl1273-core.o obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o +obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o
drivers/mfd/pm8921-core.c +62 -8
127 lines not on this page · raw message
drivers/mfd/pm8xxx-irq.c new file +599 -0
599 lines not on this page · raw message
include/linux/mfd/pm8921.h +5 -1
@@ -18,9 +18,13 @@#define __MFD_PM8921_H#include <linux/device.h> +#include <linux/mfd/pm8xxx/irq.h> + +#define NR_PM8921_IRQS 256struct pm8921_platform_data { -int irq_base; +int irq_base; +struct pm8xxx_irq_platform_data *irq_pdata; };#endif
include/linux/mfd/pm8xxx/core.h +9 -0
@@ -26,6 +26,7 @@ struct pm8xxx_drvdata { int n);int (*pmic_write_buf) (const struct device *dev,u16 addr,u8 *buf,int n); +int (*pmic_read_irq_stat) (const struct device *dev,int irq);void *pm_chip_data; };
@@ -63,4 +64,12 @@ static inline int pm8xxx_write_buf(const struct device *dev, u16 addr, u8 *buf, return dd->pmic_write_buf(dev, addr, buf, n); } +static inline int pm8xxx_read_irq_stat (const struct device *dev,int irq) +{ +struct pm8xxx_drvdata *dd =dev_get_drvdata (dev); + +BUG_ON (!dd); +return dd->pmic_read_irq_stat (dev, irq); +} +#endif
include/linux/mfd/pm8xxx/irq.h new file +62 -0
62 lines not on this page · raw message
Signature · 4 lines
1.7.1 Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
Re: [Qualcomm PM8921 MFD 2/6] mfd: pm8xxx: Add irq support
Quoted 3 lines · adharmap at codeaurora.org
Change-Id Ibb23878cd382af9a750d62ab49482f5dc72e3714Signed-off-by Abhijeet Dharmapurikar <[email protected]>
Remove the change IDs from upstream submissions. The kernel doesn't use gerritt.
drivers/mfd/pm8921-core.c line 29
Quoted 4 lines
struct pm8921 {
drivers/mfd/pm8921-core.c +2
-1-struct device *dev; +struct device *dev; +struct device *irq_dev;
Is it really useful to register a struct device purely for the interrupt controller? I'd have expected this to be core functionality of the device. The fact that you need to store the device at all is a bit odd too as you're using the MFD API.
drivers/mfd/pm8921-core.c static int pm8921_write_buf(const struct device *dev, u16 addr, u8 *buf, · line 80
Quoted 11 lines
static struct
pm8xxx_drvdatapm8921_drvdata= {drivers/mfd/pm8921-core.c +6
-4- .pmic_readb = pm8921_readb, - .pmic_writeb = pm8921_writeb, - .pmic_read_buf = pm8921_read_buf, - .pmic_write_buf = pm8921_write_buf, + .pmic_readb = pm8921_readb, + .pmic_writeb = pm8921_writeb, + .pmic_read_buf = pm8921_read_buf, + .pmic_write_buf = pm8921_write_buf, + .pmic_read_irq_stat = pm8921_read_irq_stat, +};
It'd seem better to indent things as per the final driver in the first patch - this reindentation creates a lot of noise in the diff.
drivers/mfd/pm8921-core.c static int __devinit pm8921_probe(struct platform_device *pdev) · line 144
Quoted 6 lines
drivers/mfd/pm8921-core.c +2
-1goto err_read_rev; } -pr_info ("PMIC revision: %02X\n" , val); +pr_info ("PMIC revision 1: %02X\n" , val); + rev = val;
Again, do this in the first patch.
Quoted 9 lines
drivers/mfd/pm8xxx-irq.c new file +9
-0+static int +pm8xxx_read_block (const struct pm_irq_chip *chip,u8 bp,u8 *ip) +{ +int rc; + + rc =pm8xxx_writeb (chip->dev->parent, +SSBI_REG_ADDR_IRQ_BLK_SEL , bp); +if (rc) { +pr_err ("Failed Selecting Block %d rc=%d\n" , bp, rc);
drivers/mfd/pm8xxx-irq.c line 110
Quoted 10 lines
drivers/mfd/pm8xxx-irq.c new file +10
-0+ goto bail_out; + } + + rc =pm8xxx_readb (chip->dev->parent, +SSBI_REG_ADDR_IRQ_IT_STATUS , ip); +if (rc) +pr_err ("Failed Reading Status rc=%d\n" , rc); +bail_out: +return rc; +}
The namespacing here is odd, this looks like it should be a generic API not a block specific one.
Quoted 13 lines
drivers/mfd/pm8xxx-irq.c new file +13
-0+/* Check IRQ bits */ +for (k =0 ; k <8 ; k++) { +if (bits & (1 << k)) { + pmirq = block *8 + k; + irq = pmirq + chip->irq_base; +/* Check spurious interrupts */ +if (((1 << k) & chip->irqs_allowed[block])) { +/* Found one */ + chip->irqs_to_handle[*handled] = irq; + (*handled)++; + }else {/* Clear and mask wrong one */ + config =PM_IRQF_W_C_M | + (k <<PM_IRQF_BITS_SHIFT );
drivers/mfd/pm8xxx-irq.c line 172
Quoted 10 lines
drivers/mfd/pm8xxx-irq.c new file +10
-0+ +pm8xxx_config_irq (chip, + block, config); + +if (pm8xxx_can_print ()) +pr_err ("Spurious IRQ: %d " +"[block, bit]=" +"[%d, %d]\n" , + irq, block, k); + }
The generic IRQ code should be able to take care of spurious interrupts for you? It's a bit surprising that there's all this logic - I'd expect an IRQ chip to just defer logic about which interrupts are valid and so on to the generic IRQ code.
include/linux/mfd/pm8921.h line 23
Quoted 4 lines
#include <
linux/device.h>include/linux/mfd/pm8921.h +3
-0+#include <linux/mfd/pm8xxx/irq.h> + +#define NR_PM8921_IRQS 256
Traditionally this'd be namespaced like this:
+#define PM8921_NR_IRQS 256
Re: [Qualcomm PM8921 MFD 2/6] mfd: pm8xxx: Add irq support
Quoted 7 lines · Mark Brown
Quoted 2 lines · adharmap at codeaurora.org
Change-Id Ibb23878cd382af9a750d62ab49482f5dc72e3714Signed-off-by Abhijeet Dharmapurikar <[email protected]>Remove the change IDs from upstream submissions. The kernel doesn't use gerritt.
Quoted 9 lines
drivers/mfd/pm8921-core.c line 29
Quoted 4 lines
struct pm8921 {
drivers/mfd/pm8921-core.c +2
-1-struct device *dev; +struct device *dev; +struct device *irq_dev;Is it really useful to register a struct device purely for the interrupt controller? I'd have expected this to be core functionality of the device. The fact that you need to store the device at all is a bit odd too as you're using the MFD API.
This design is slightly different from other MFD drivers.
I separated the interrupt from the core because the interrupt implementation for different Qualcomm pmics remains the same. On 8660 FFA boards for example, we have two pmic chips that have the same interrupt subdevice implementation (the number of interrupts managed by each is different). I didn't want to duplicate the exact code in the core driver - hence a separate interrupt driver.
To answer why we need to keep a reference to irq_dev. This is so because the gpio code needs to make calls on the irq driver to read the input values. The gpio code calls pm8xxx_read_irq_stat() on the core and expects it to read the value. The core then calls an api in the irq driver (pm8xxx_get_irq_stat)passing it irq_dev to get the required values.
I could have made the gpio code call the irq code directly, but then that would mean the irq driver has to go over all its devices and find which device handles this irq number and then read it. That is too much code execution as compared to remember the irq_dev for each core and let the gpio code call read apis on it.
Quoted 16 lines
drivers/mfd/pm8921-core.c static int pm8921_write_buf(const struct device *dev, u16 addr, u8 *buf, · line 80
Quoted 12 lines
static struct
pm8xxx_drvdatapm8921_drvdata= {drivers/mfd/pm8921-core.c +6
-4- .pmic_readb = pm8921_readb, - .pmic_writeb = pm8921_writeb, - .pmic_read_buf = pm8921_read_buf, - .pmic_write_buf = pm8921_write_buf, + .pmic_readb = pm8921_readb, + .pmic_writeb = pm8921_writeb, + .pmic_read_buf = pm8921_read_buf, + .pmic_write_buf = pm8921_write_buf, + .pmic_read_irq_stat = pm8921_read_irq_stat, +};It'd seem better to indent things as per the final driver in the first patch - this reindentation creates a lot of noise in the diff.
Quoted 5 lines
drivers/mfd/pm8921-core.c static int __devinit pm8921_probe(struct platform_device *pdev) · line 144
Quoted 5 lines
drivers/mfd/pm8921-core.c +2
-1goto err_read_rev; } -pr_info ("PMIC revision: %02X\n" , val); +pr_info ("PMIC revision 1: %02X\n" , val); + rev = val;
Yes will fix them
Quoted 18 lines
Quoted 1 line
Again, do this in the first patch.
Quoted 14 lines
drivers/mfd/pm8xxx-irq.c new file +14
-0+static int +pm8xxx_read_block (const struct pm_irq_chip *chip,u8 bp,u8 *ip) +{ +int rc; + + rc =pm8xxx_writeb (chip->dev->parent, +SSBI_REG_ADDR_IRQ_BLK_SEL , bp); +if (rc) { +pr_err ("Failed Selecting Block %d rc=%d\n" , bp, rc); + goto bail_out; + } + + rc =pm8xxx_readb (chip->dev->parent, +SSBI_REG_ADDR_IRQ_IT_STATUS , ip);
Quoted 8 lines
drivers/mfd/pm8xxx-irq.c line 110
Quoted 5 lines
drivers/mfd/pm8xxx-irq.c new file +5
-0+if (rc) +pr_err ("Failed Reading Status rc=%d\n" , rc); +bail_out: +return rc; +}The namespacing here is odd, this looks like it should be a generic API not a block specific one.
It indicates that the code intends to read a block of interrupt statuses. The irq h/w is implemented as follows, there are 256 interrupts. One block manages 8 interrupts, so there are 32 blocks. One master manages 8 blocks so there are 4 masters. And finally there is one root that manages all the 4 masters.
When an interrupt triggers, the corresponding bit in the block, master and root is set. The handler reads the root and figures out which master is set. It then reads the master and figures out which block in that master is set. It then reads the block to figure out which interrupt in that block is set. This hardware design makes the handler find the interrupt super quick as opposed to checking 256 bits when an interrupt fires.
With that in mind, the driver has following functions pm8xxxx_read_rootpm8xxxx_read_masterpm8xxxx_read_block
Do you still think I should change the name?
Quoted 21 lines
Quoted 21 lines
drivers/mfd/pm8xxx-irq.c new file +20
-0+/* Check IRQ bits */ +for (k =0 ; k <8 ; k++) { +if (bits & (1 << k)) { + pmirq = block *8 + k; + irq = pmirq + chip->irq_base; +/* Check spurious interrupts */ +if (((1 << k) & chip->irqs_allowed[block])) { +/* Found one */ + chip->irqs_to_handle[*handled] = irq; + (*handled)++; + }else {/* Clear and mask wrong one */ + config =PM_IRQF_W_C_M | + (k <<PM_IRQF_BITS_SHIFT ); + +pm8xxx_config_irq (chip, + block, config); + +if (pm8xxx_can_print ()) +pr_err ("Spurious IRQ: %d " + "[block, bit]="
Quoted 8 lines
drivers/mfd/pm8xxx-irq.c line 172
Quoted 3 lines
drivers/mfd/pm8xxx-irq.c new file +3
-0+"[%d, %d]\n" , + irq, block, k); + }The generic IRQ code should be able to take care of spurious interrupts for you? It's a bit surprising that there's all this logic - I'd expect an IRQ chip to just defer logic about which interrupts are valid and so on to the generic IRQ code.
That is correct, the genirq does handle spurious interrupts gracefully. Will fix this in the next patch series.
Quoted 6 lines
include/linux/mfd/pm8921.h line 23
Quoted 2 lines
include/linux/mfd/pm8921.h +2
-0+ +#define NR_PM8921_IRQS 256Traditionally this'd be namespaced like this:
+#define
PM8921_NR_IRQS256
ok good to know will change that.
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [Qualcomm PM8921 MFD 2/6] mfd: pm8xxx: Add irq support
Quoted 7 lines · Abhijeet Dharmapurikar
Quoted 4 lines · Mark Brown
Is it really useful to register a struct device purely for the interrupt controller? I'd have expected this to be core functionality of the device. The fact that you need to store the device at all is a bit odd too as you're using the MFD API.
Quoted 7 lines
This design is slightly different from other MFD drivers. I separated the interrupt from the core because the interrupt implementation for different Qualcomm pmics remains the same. On 8660 FFA boards for example, we have two pmic chips that have the same interrupt subdevice implementation (the number of interrupts managed by each is different). I didn't want to duplicate the exact code in the core driver - hence a separate interrupt driver.
Could you deal with this with a library instead?
Quoted 6 lines
With that in mind, the driver has following functions
pm8xxxx_read_rootpm8xxxx_read_masterpm8xxxx_read_blockDo you still think I should change the name?
I'd suggest adding an _irq in there.
Re: [Qualcomm PM8921 MFD 2/6] mfd: pm8xxx: Add irq support
Quoted 16 lines · Mark Brown
Quoted 7 lines · Abhijeet Dharmapurikar
Quoted 4 lines · Mark Brown
Is it really useful to register a struct device purely for the interrupt controller? I'd have expected this to be core functionality of the device. The fact that you need to store the device at all is a bit odd too as you're using the MFD API.
Quoted 7 lines
This design is slightly different from other MFD drivers. I separated the interrupt from the core because the interrupt implementation for different Qualcomm pmics remains the same. On 8660 FFA boards for example, we have two pmic chips that have the same interrupt subdevice implementation (the number of interrupts managed by each is different). I didn't want to duplicate the exact code in the core driver - hence a separate interrupt driver.
Quoted 1 line
Could you deal with this with a library instead?
Can you please clarify what a library means here?
Quoted 5 lines
Quoted 3 lines
pm8xxxx_read_blockDo you still think I should change the name?
I'd suggest adding an
_irqin there.
Ok will do.
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [Qualcomm PM8921 MFD 2/6] mfd: pm8xxx: Add irq support
Quoted 5 lines · Abhijeet Dharmapurikar
Quoted 1 line · Mark Brown
Could you deal with this with a library instead?
Can you please clarify what a library means here?
You can share the code without creating a struct device, just have the driver for each chip call into the common code.
PATCH 3/6 gpio: pm8xxx-gpio: Add pm8xxx gpio driver
In reply to [email protected]From: Abhijeet Dharmapurikar <[email protected]>
Add support for GPIO on Qualcomm PM8xxx PMIC chips.
--- drivers/gpio/Kconfig | 10 + drivers/gpio/Makefile | 1 + drivers/gpio/pm8xxx-gpio.c | 452 +++++++++++++++++++++++++++++++++++++++ drivers/mfd/pm8921-core.c | 35 +++- include/linux/mfd/pm8921.h | 20 ++- include/linux/mfd/pm8xxx/gpio.h | 132 ++++++++++++ 6 files changed, 645 insertions(+), 5 deletions(-) create mode 100644 drivers/gpio/pm8xxx-gpio.c create mode 100644 include/linux/mfd/pm8xxx/gpio.h
drivers/gpio/Kconfig +10 -0
@@ -411,4 +411,14 @@ config GPIO_JANZ_TTL This driver provides support for driving the pins in output mode only. Input mode is not supported. +comment "SSBI GPIO expanders:" + +config GPIO_PM8XXX + tristate "Qualcomm PM8xxx GPIO support" + depends on MFD_PM8XXX + default y if MFD_PM8XXX + help + This option enables support for on-chip GPIO found on Qualcomm PM8xxx + PMICs. + endif
drivers/gpio/Makefile +1 -0
@@ -42,3 +42,4 @@ obj-$(CONFIG_GPIO_JANZ_TTL) += janz-ttl.o obj-$(CONFIG_GPIO_SX150X) += sx150x.o obj-$(CONFIG_GPIO_VX855) += vx855_gpio.o obj-$(CONFIG_GPIO_ML_IOH) += ml_ioh_gpio.o +obj-$(CONFIG_GPIO_PM8XXX) += pm8xxx-gpio.o
drivers/gpio/pm8xxx-gpio.c new file +452 -0
452 lines not on this page · raw message
drivers/mfd/pm8921-core.c +33 -2
@@ -20,6 +20,7 @@#include <linux/mfd/pm8921.h> #include <linux/mfd/pm8xxx/core.h> #include <linux/mfd/pm8xxx/irq.h> +#include <linux/mfd/pm8xxx/gpio.h> #define REG_HWREV 0x002/* PMIC4 revision */ #define REG_HWREV_2 0x0E8/* PMIC4 revision 2 */
@@ -84,6 +85,22 @@ static struct __devinitdata mfd_cell irq_cell = { .id = -1, }; +static const struct resource gpio_cell_resources[]__devinitconst = { + [0 ] = { + .start =PM8921_IRQ_BLOCK_BIT (PM8921_GPIO_BLOCK_START ,0 ), + .end =PM8921_IRQ_BLOCK_BIT (PM8921_GPIO_BLOCK_START ,0 ) + +NR_PM8921_IRQS -1 , + .flags =IORESOURCE_IRQ , + }, +}; + +static struct mfd_cell gpio_cell__devinitdata = { + .name =PM8XXX_GPIO_DEV_NAME , + .id =-1 , + .resources = gpio_cell_resources, + .num_resources =ARRAY_SIZE (gpio_cell_resources), +}; + static int __devinit pm8921_add_subdevices(const struct pm8921_platform_data *pdata, struct pm8921 *pmic,
@@ -102,11 +119,25 @@ static int __devinit pm8921_add_subdevices(const struct pm8921_platform_data NULL, 0);if (ret <0 ) {pr_err ("Failed to add irq_subdevice ret=%d\n" , ret); -return ret; + goto bail; } } -return 0 ; +if (pdata->gpio_pdata) { + pdata->gpio_pdata->gpio_cdata.ngpios =NR_PM8921_GPIOS ; + pdata->gpio_pdata->gpio_cdata.rev = rev; + gpio_cell.platform_data = pdata->gpio_pdata; + gpio_cell.data_size =sizeof (struct pm8xxx_gpio_platform_data ); + ret =mfd_add_devices (pmic->dev,0 , &gpio_cell,1 , +NULL , irq_base); +if (ret) { +pr_err ("Failed to add gpio subdevice ret=%d\n" , ret); + goto bail; + } + } + +bail: +return ret; }static int __devinit match_irq_dev (struct device *dev,void *data)
include/linux/mfd/pm8921.h +17 -3
@@ -19,12 +19,26 @@#include <linux/device.h> #include <linux/mfd/pm8xxx/irq.h> +#include <linux/mfd/pm8xxx/gpio.h> -#define NR_PM8921_IRQS 256 +#define NR_PM8921_IRQS 256 + +#define NR_PM8921_GPIOS 44 + +#define PM8921_GPIO_BLOCK_START 24 +#define PM8921_MPP_BLOCK_START 16 +#define PM8921_IRQ_BLOCK_BIT (block, bit) ((block) * 8 + (bit)) + +/* MPPs and GPIOs [1,N) */ +#define PM8921_MPP_IRQ (base, mpp) ((base) + \ + PM8921_IRQ_BLOCK_BIT(PM8921_MPP_BLOCK_START, (mpp)-1)) +#define PM8921_GPIO_IRQ (base, gpio) ((base) + \ + PM8921_IRQ_BLOCK_BIT(PM8921_GPIO_BLOCK_START, (gpio)-1))struct pm8921_platform_data { -int irq_base; -struct pm8xxx_irq_platform_data *irq_pdata; +int irq_base; +struct pm8xxx_irq_platform_data *irq_pdata; +struct pm8xxx_gpio_platform_data *gpio_pdata; };#endif
include/linux/mfd/pm8xxx/gpio.h new file +132 -0
132 lines not on this page · raw message
Signature · 4 lines
1.7.1 Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
Re: [Qualcomm PM8921 MFD 3/6] gpio: pm8xxx-gpio: Add pm8xxx gpio driver
Quoted 5 lines · adharmap at codeaurora.org
From: Abhijeet Dharmapurikar <[email protected]>
Add support for GPIO on Qualcomm PM8xxx PMIC chips.
Change-Id: I5c00baeedc6c40ed40065d15c83577051e6ac9c6
What is this line for?
Re: [Qualcomm PM8921 MFD 3/6] gpio: pm8xxx-gpio: Add pm8xxx gpio driver
Quoted 8 lines · Greg KH
Quoted 5 lines · adharmap at codeaurora.org
From: Abhijeet Dharmapurikar<[email protected]>
Add support for GPIO on Qualcomm PM8xxx PMIC chips.
Change-Id: I5c00baeedc6c40ed40065d15c83577051e6ac9c6
What is this line for?
That commit text artifact is for our internal review tool (gerrit). I cleaned it up in the later revision of the patch series. The latest can be found here
https://lkml.org/lkml/2011/4/5/427
Thanks for looking,
Abhijeet
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 4/6 mfd: pm8xxx-mpp: Add pm8xxx MPP driver
In reply to [email protected]From: David Collins <[email protected]>
Add support for multi-purpose pins (MPPs) on Qualcomm PM8xxx PMIC chips.
PM8xxx MPPs can be configured as digital or analog inputs or outputs, current sinks, or buffers.
--- drivers/mfd/Kconfig | 8 + drivers/mfd/Makefile | 1 + drivers/mfd/pm8921-core.c | 31 ++++ drivers/mfd/pm8xxx-mpp.c | 319 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/pm8921.h | 4 + include/linux/mfd/pm8xxx/mpp.h | 233 +++++++++++++++++++++++++++++ 6 files changed, 596 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/pm8xxx-mpp.c create mode 100644 include/linux/mfd/pm8xxx/mpp.h
drivers/mfd/Kconfig +8 -0
@@ -657,6 +657,14 @@ config MFD_PM8XXX_IRQ This is required to use certain other PM 8xxx features, such as GPIO and MPP. +config MFD_PM8XXX_MPP + tristate "Support for Qualcomm PM8xxx MPP features" + depends on MFD_PM8XXX + default y if MFD_PM8XXX + help + This is the multi-purpose pin (MPP) driver for Qualcomm PM 8xxx PMIC + chips. + endif # MFD_SUPPORT menu "Multimedia Capabilities Port drivers"
drivers/mfd/Makefile +1 -0
@@ -85,3 +85,4 @@ obj-$(CONFIG_MFD_WL1273_CORE) += wl1273-core.o obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o +obj-$(CONFIG_MFD_PM8XXX_MPP) += pm8xxx-mpp.o
drivers/mfd/pm8921-core.c +31 -0
@@ -25,6 +25,8 @@#define REG_HWREV 0x002/* PMIC4 revision */ #define REG_HWREV_2 0x0E8/* PMIC4 revision 2 */ +#define REG_MPP_BASE 0x050 +struct pm8921 {struct device *dev;struct device *irq_dev;
@@ -101,6 +103,22 @@ static struct mfd_cell gpio_cell __devinitdata = { .num_resources = ARRAY_SIZE(gpio_cell_resources), }; +static const struct resource mpp_cell_resources[]__devinitconst = { + { + .start =PM8921_IRQ_BLOCK_BIT (PM8921_MPP_BLOCK_START ,0 ), + .end =PM8921_IRQ_BLOCK_BIT (PM8921_MPP_BLOCK_START ,0 ) + +NR_PM8921_MPPS -1 , + .flags =IORESOURCE_IRQ , + }, +}; + +static struct mfd_cell mpp_cell__devinitdata = { + .name =PM8XXX_MPP_DEV_NAME , + .id =-1 , + .resources = mpp_cell_resources, + .num_resources =ARRAY_SIZE (mpp_cell_resources), +}; + static int __devinit pm8921_add_subdevices(const struct pm8921_platform_data *pdata, struct pm8921 *pmic,
@@ -136,6 +154,19 @@ static int __devinit pm8921_add_subdevices(const struct pm8921_platform_data } } +if (pdata->mpp_pdata) { + pdata->mpp_pdata->core_data.nmpps =NR_PM8921_MPPS ; + pdata->mpp_pdata->core_data.base_addr =REG_MPP_BASE ; + mpp_cell.platform_data = pdata->mpp_pdata; + mpp_cell.data_size =sizeof (struct pm8xxx_mpp_platform_data ); + ret =mfd_add_devices (pmic->dev,0 , &mpp_cell,1 ,NULL , + irq_base); +if (ret) { +pr_err ("Failed to add mpp subdevice ret=%d\n" , ret); + goto bail; + } + } + bail:return ret; }
drivers/mfd/pm8xxx-mpp.c new file +319 -0
319 lines not on this page · raw message
include/linux/mfd/pm8921.h +4 -0
@@ -20,11 +20,14 @@#include <linux/device.h> #include <linux/mfd/pm8xxx/irq.h> #include <linux/mfd/pm8xxx/gpio.h> +#include <linux/mfd/pm8xxx/mpp.h> #define NR_PM8921_IRQS 256#define NR_PM8921_GPIOS 44 +#define NR_PM8921_MPPS 12 +#define PM8921_GPIO_BLOCK_START 24#define PM8921_MPP_BLOCK_START 16#define PM8921_IRQ_BLOCK_BIT (block, bit) ((block) * 8 + (bit))
@@ -39,6 +42,7 @@ struct pm8921_platform_data {int irq_base;struct pm8xxx_irq_platform_data *irq_pdata;struct pm8xxx_gpio_platform_data *gpio_pdata; + struct pm8xxx_mpp_platform_data *mpp_pdata; };#endif
include/linux/mfd/pm8xxx/mpp.h new file +233 -0
233 lines not on this page · raw message
Signature · 4 lines
1.7.1 Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
Re: [Qualcomm PM8921 MFD 4/6] mfd: pm8xxx-mpp: Add pm8xxx MPP driver
Quoted 9 lines · adharmap at codeaurora.org
From: David Collins <[email protected]>
Add support for multi-purpose pins (MPPs) on Qualcomm PM8xxx PMIC chips.
PM8xxx MPPs can be configured as digital or analog inputs or outputs, current sinks, or buffers.
Change-Id: Iab39b2f7c2ba3f35ef6ac74d37ee7add8c70681f
What is this line for? It makes no sense for a patch that is being submitted to the kernel tree, please remove it.
Quoted 1 line
Signed-off-by David Collins <[email protected]>
Why have you sent this patch from a different email address than this one?
greg k-h
PATCH 5/6 MAINTAINERS: Add pmic8921, pmic8xxx subdevices maintainers
In reply to [email protected]From: Abhijeet Dharmapurikar <[email protected]>
--- MAINTAINERS | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
MAINTAINERS +6 -0
@@ -905,6 +905,12 @@ F: drivers/mmc/host/msm_sdcc.h F: drivers/tty/serial/msm_serial.h F: drivers/tty/serial/msm_serial.c F: drivers/platform/msm/ +F: drivers/mfd/pm8921-core.c +F: drivers/mfd/pm8xxx-mpp.c +F: include/linux/mfd/pm8921.h +F: include/linux/mfd/pm8xxx/ +F: drivers/gpio/pm8xxx-gpio.c +F: drivers/mfd/pm8xxx-irq.c T: git git://codeaurora.org/quic/kernel/davidb/linux-msm.git S: Maintained
Signature · 4 lines
1.7.1 Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum
Re: [Qualcomm PM8921 MFD 5/6] MAINTAINERS: Add pmic8921, pmic8xxx subdevices maintainers
MAINTAINERS
Quoted 1 line · adharmap at codeaurora.org
MAINTAINERS +0
-0
The patch subject is not quite correct.
You're adding patterns, not maintainers.
MAINTAINERS F: drivers/mmc/host/msm_sdcc.h · line 913
Quoted 13 lines
index 696cb18..97107fd 100644
MAINTAINERS +6
-0@@ -905,6 +905,12 @@ F: drivers/mmc/host/msm_sdcc.h F: drivers/tty/serial/msm_serial.h F: drivers/tty/serial/msm_serial.c F: drivers/platform/msm/ +F: drivers/mfd/pm8921-core.c +F: drivers/mfd/pm8xxx-mpp.c +F: include/linux/mfd/pm8921.h +F: include/linux/mfd/pm8xxx/ +F: drivers/gpio/pm8xxx-gpio.c +F: drivers/mfd/pm8xxx-irq.c
My preference is to keep these in alphabetic order.
Another option is a wildcard pattern match like:
F: drivers/*/pm8???-*
instead of:
F: drivers/gpio/pm8xxx-gpio.c
F: drivers/mfd/pm8921-core.c
F: drivers/mfd/pm8xxx-irq.c
F: drivers/mfd/pm8xxx-mpp.c
Re: [Qualcomm PM8921 MFD 5/6] MAINTAINERS: Add pmic8921, pmic8xxx subdevices maintainers
Quoted 5 lines · Joe Perches
MAINTAINERS
Quoted 1 line · adharmap at codeaurora.org
MAINTAINERS +0
-0The patch subject is not quite correct.
You're adding patterns, not maintainers.
Ok will fix it in the next patch series.
Quoted 10 lines
Another option is a wildcard pattern match like:
F: drivers/*/pm8???-*
instead of:
F:
drivers/gpio/pm8xxx-gpio.c
F:drivers/mfd/pm8921-core.c
F:drivers/mfd/pm8xxx-irq.c
F:drivers/mfd/pm8xxx-mpp.c
Will do, thanks for this wildcard pattern
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 6/6 msm: board-8960: Add support for pm8921
In reply to [email protected]From: Abhijeet Dharmapurikar <[email protected]>
Add device structure declarations to the msm8960 board file for PMIC 8921 chip and its subdevices.
--- arch/arm/mach-msm/board-msm8960.c | 47 ++++++++++++++++++++++------ arch/arm/mach-msm/include/mach/irqs-8960.h | 9 ++--- 2 files changed, 41 insertions(+), 15 deletions(-)
arch/arm/mach-msm/board-msm8960.c +37 -10
@@ -8,19 +8,15 @@* 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., 51 Franklin Street, Fifth Floor, Boston, MA -* 02110-1301, USA. -* */ +#include <linux/kernel.h> #include <linux/platform_device.h> #include <linux/io.h> #include <linux/irq.h> #include <linux/clkdev.h> #include <linux/msm_ssbi.h> +#include <linux/mfd/pm8921.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -28,9 +24,18 @@#include <mach/board.h> #include <mach/msm_iomap.h> +#include <mach/irqs.h> #include "devices.h" +/* Macros assume PMIC GPIOs and MPPs start at 1 */ +#define PM8921_GPIO_BASE NR_GPIO_IRQS +#define PM8921_GPIO_PM_TO_SYS (pm_gpio) (pm_gpio - 1 + PM8921_GPIO_BASE) +#define PM8921_MPP_BASE (PM8921_GPIO_BASE + NR_PM8921_GPIOS) +#define PM8921_MPP_PM_TO_SYS (pm_gpio) (pm_gpio - 1 + PM8921_MPP_BASE) +#define PM8921_IRQ_BASE (NR_MSM_IRQS + NR_GPIO_IRQS) +#define PM8921_MPP_IRQ_BASE (PM8921_IRQ_BASE + NR_GPIO_IRQS) +static void __init msm8960_map_io (void ) {msm_map_msm8960_io ();
@@ -65,12 +70,34 @@ static struct platform_device *sim_devices[] __initdata = {static struct platform_device *rumi3_devices[]__initdata = { &msm8960_device_uart_gsbi5, + &msm8960_device_ssbi_pm8921, +}; + +static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata__devinitdata = { + .irq_base =PM8921_IRQ_BASE , + .devirq =MSM_GPIO_TO_INT (104 ), + .irq_trigger_flag =IRQF_TRIGGER_LOW , +}; + +static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata__devinitdata = { + .gpio_base =PM8921_GPIO_PM_TO_SYS (1 ), +}; + +static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata__devinitdata = { + .mpp_base =PM8921_MPP_PM_TO_SYS (1 ), +}; + +static struct pm8921_platform_data pm8921_platform_data__devinitdata = { + .irq_pdata = &pm8xxx_irq_pdata, + .gpio_pdata = &pm8xxx_gpio_pdata, + .mpp_pdata = &pm8xxx_mpp_pdata, }; -static struct msm_ssbi_platform_data msm8960_ssbi_pm8921_pdata = { - .controller_type =MSM_SBI_CTRL_PMIC_ARBITER , - .slave = { - .name ="pm8921-core" , +static struct msm_ssbi_platform_data msm8960_ssbi_pm8921_pdata__initdata = { + .controller_type =MSM_SBI_CTRL_PMIC_ARBITER , + .slave = { + .name ="pm8921-core" , + .platform_data = &pm8921_platform_data, }, };
arch/arm/mach-msm/include/mach/irqs-8960.h +4 -5
@@ -267,11 +267,10 @@#define PM8921_SEC_IRQ_104 (GIC_SPI_START + 225)#define PM8018_SEC_IRQ_107 (GIC_SPI_START + 226) -/* For now, use the maximum number of interrupts until a pending GIC issue -* is sorted out */ -#define NR_MSM_IRQS 1020 -#define NR_BOARD_IRQS 0 -#define NR_GPIO_IRQS 0 +#define NR_MSM_IRQS 256 +#define NR_GPIO_IRQS 151 +#define NR_PM8921_IRQS 256 +#define NR_BOARD_IRQS (NR_PM8921_IRQS)#endif
Signature · 4 lines
1.7.1 Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum