mfd: palma: add RTC and GPIO support
Subsystems (4)
cover mfd: palma: add RTC and GPIO support
This series add the RTC and gpio driver for the TI Palma series PMIC. The changes are splitted so that easy to apply in different sub systems.
Laxman Dewangan (4):
mfd: palmas: add rtc irq number as irq resource for palmas-rtc
mfd: palmas: add apis to access the Palmas' registers
gpio: palmas: Add support for Palams GPIO
rtc: palmas: add RTC driver Palmas series PMIC
drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-palmas.c | 184 ++++++++++++++++++++++++ drivers/mfd/palmas.c | 14 ++- drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-palmas.c | 339 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/palmas.h | 52 +++++++ 8 files changed, 606 insertions(+), 2 deletions(-) create mode 100644 drivers/gpio/gpio-palmas.c create mode 100644 drivers/rtc/rtc-palmas.c
PATCH 1/4 mfd: palmas: add rtc irq number as irq resource for palmas-rtc
Palma RTC is capable of generating alarm interrupt. Pass the alarm interrupt as IRQ_RESOURCE for palmas-rtc sub device driver so that rtc driver can get irq as platform_get_irq().
Also pass the irq domain in mfd_add_devices() to properly offset the irqs for sub devices. This is needed when adding device through DT.
--- drivers/mfd/palmas.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
drivers/mfd/palmas.c +12 -2
@@ -39,6 +39,14 @@ enum palmas_ids { PALMAS_USB_ID, }; +static struct resource palmas_rtc_resources[] = { + { + .start =PALMAS_RTC_ALARM_IRQ , + .end =PALMAS_RTC_ALARM_IRQ , + .flags =IORESOURCE_IRQ , + }, +}; +static const struct mfd_cell palmas_children[] = { { .name ="palmas-pmic" ,
@@ -59,6 +67,8 @@ static const struct mfd_cell palmas_children[] = { { .name = "palmas-rtc", .id = PALMAS_RTC_ID, + .resources = &palmas_rtc_resources[0], + .num_resources = ARRAY_SIZE(palmas_rtc_resources), }, { .name = "palmas-pwrbutton",
@@ -456,8 +466,8 @@ static int palmas_i2c_probe(struct i2c_client *i2c, ret =mfd_add_devices (palmas->dev,-1 , children,ARRAY_SIZE (palmas_children), -NULL ,regmap_irq_chip_get_base (palmas->irq_data), -NULL ); +NULL ,0 , +regmap_irq_get_domain (palmas->irq_data));kfree (children);if (ret <0 )
Signature · 1 line
1.7.1.1
PATCH 2/4 mfd: palmas: add apis to access the Palmas' registers
In reply to Laxman DewanganPalmas register set is divided into different blocks (base and offset) and hence different i2c addresses. The i2c address offsets are derived from base address of block of registers.
Add inline APIs to access the Palma's registers which takes the base of register block and register offset. The i2c address offset is derived from the base address of register blocks.
--- include/linux/mfd/palmas.h | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-)
include/linux/mfd/palmas.h +52 -0
@@ -2789,4 +2789,56 @@ enum usb_irq_events {#define PALMAS_GPADC_TRIM15 0xE#define PALMAS_GPADC_TRIM16 0xF +static inline int palmas_read (struct palmas *palmas,unsigned int base, +unsigned int reg,unsigned int *val) +{ +unsigned int addr =PALMAS_BASE_TO_REG (base, reg); +int slave_id =PALMAS_BASE_TO_SLAVE (base); + +return regmap_read (palmas->regmap[slave_id], addr, val); +} + +static inline int palmas_write (struct palmas *palmas,unsigned int base, +unsigned int reg,unsigned int value) +{ +unsigned int addr =PALMAS_BASE_TO_REG (base, reg); +int slave_id =PALMAS_BASE_TO_SLAVE (base); + +return regmap_write (palmas->regmap[slave_id], addr, value); +} + +static inline int palmas_bulk_write (struct palmas *palmas,unsigned int base, +unsigned int reg,const void *val,size_t val_count) +{ +unsigned int addr =PALMAS_BASE_TO_REG (base, reg); +int slave_id =PALMAS_BASE_TO_SLAVE (base); + +return regmap_bulk_write (palmas->regmap[slave_id], addr, + val, val_count); +} + +static inline int palmas_bulk_read (struct palmas *palmas,unsigned int base, +unsigned int reg,void *val,size_t val_count) +{ +unsigned int addr =PALMAS_BASE_TO_REG (base, reg); +int slave_id =PALMAS_BASE_TO_SLAVE (base); + +return regmap_bulk_read (palmas->regmap[slave_id], addr, + val, val_count); +} + +static inline int palmas_update_bits (struct palmas *palmas,unsigned int base, +unsigned int reg,unsigned int mask,unsigned int val) +{ +unsigned int addr =PALMAS_BASE_TO_REG (base, reg); +int slave_id =PALMAS_BASE_TO_SLAVE (base); + +return regmap_update_bits (palmas->regmap[slave_id], addr, mask, val); +} + +static inline int palmas_irq_get_virq (struct palmas *palmas,int irq) +{ +return regmap_irq_get_virq (palmas->irq_data, irq); +} +#endif /* __LINUX_MFD_PALMAS_H */
Signature · 1 line
1.7.1.1
PATCH 3/4 gpio: palmas: Add support for Palams GPIO
In reply to Laxman DewanganAdd gpio driver for TI Palmas series PMIC. This has 8 gpio which can work as input/output.
--- drivers/gpio/Kconfig | 7 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-palmas.c | 184 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 192 insertions(+), 0 deletions(-) create mode 100644 drivers/gpio/gpio-palmas.c
drivers/gpio/Kconfig +7 -0
@@ -663,6 +663,13 @@ config GPIO_AB8500 help Select this to enable the AB8500 IC GPIO driver +config GPIO_PALMAS + bool "TI PALMAS series PMICs GPIO" + depends on MFD_PALMAS + help + Select this option to enable GPIO driver for the TI PALMAS + series chip family. + config GPIO_TPS6586X bool "TPS6586X GPIO" depends on MFD_TPS6586X
drivers/gpio/Makefile +1 -0
@@ -69,6 +69,7 @@ obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o obj-$(CONFIG_ARCH_DAVINCI_TNETV107X) += gpio-tnetv107x.o +obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o
drivers/gpio/gpio-palmas.c new file +184 -0
184 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Re: [PATCH 3/4] gpio: palmas: Add support for Palams GPIO
Quoted 4 lines · Laxman Dewangan
Add gpio driver for TI Palmas series PMIC. This has 8 gpio which can work as input/output.
Signed-off-by Laxman Dewangan <[email protected]>
This driver seems unnecessary. Can't you just usedrivers/gpio/gpio-generic.c ?
drivers/gpio/gpio-palmas.c line 109
Quoted 7 lines
drivers/gpio/gpio-palmas.c new file +7
-0+static int palmas_gpio_to_irq (struct gpio_chip *gc,unsigned offset) +{ +struct palmas_gpio *pg =to_palmas_gpio (gc); +struct palmas *palmas = pg->palmas; + +return palmas_irq_get_virq (palmas,PALMAS_GPIO_0_IRQ + offset); +}
Why are you implementing this for a driver which does not even expose the ability to trigger IRQs? If it's supposed to support IRQs it should register a struct irq_chip.
Yours,
Linus Walleij
Re: [PATCH 3/4] gpio: palmas: Add support for Palams GPIO
Quoted 8 lines · Linus Walleij
Quoted 4 lines · Laxman Dewangan
Add gpio driver for TI Palmas series PMIC. This has 8 gpio which can work as input/output.
Signed-off-by Laxman Dewangan <[email protected]>This driver seems unnecessary. Can't you just use
drivers/gpio/gpio-generic.c?
The gpio-generic driver is for the MMIO based interface. This is for the PMIC-Palma which is in i2c interface and so need to have register access through the i2c call exposed by palma mfd driver.
Quoted 11 lines
drivers/gpio/gpio-palmas.c line 109
Quoted 8 lines
drivers/gpio/gpio-palmas.c new file +7
-0+static int palmas_gpio_to_irq (struct gpio_chip *gc,unsigned offset) +{ +struct palmas_gpio *pg =to_palmas_gpio (gc); +struct palmas *palmas = pg->palmas; + +return palmas_irq_get_virq (palmas,PALMAS_GPIO_0_IRQ + offset); +}Why are you implementing this for a driver which does not even expose the ability to trigger IRQs? If it's supposed to support IRQs it should register a struct
irq_chip.
The interrupts are registered in mfd core via the regmap-irq_chip. This api converts the gpio number to corresponding irq.
Re: [PATCH 3/4] gpio: palmas: Add support for Palams GPIO
In reply to Linus WalleijQuoted 9 lines · Linus Walleij
Quoted 4 lines · Laxman Dewangan
Add gpio driver for TI Palmas series PMIC. This has 8 gpio which can work as input/output.
Signed-off-by Laxman Dewangan <[email protected]>This driver seems unnecessary. Can't you just use
drivers/gpio/gpio-generic.c?
This only works for memory mapped devices but this is an I2C controlled MFD. Someone should really do a regmap gpio-chip (or convert the gpio-generic driver to regmap, regmap does support MMIO now but it does add a little overhead).
Quoted 11 lines
drivers/gpio/gpio-palmas.c line 109
Quoted 7 lines
drivers/gpio/gpio-palmas.c new file +7
-0+static int palmas_gpio_to_irq (struct gpio_chip *gc,unsigned offset) +{ +struct palmas_gpio *pg =to_palmas_gpio (gc); +struct palmas *palmas = pg->palmas; + +return palmas_irq_get_virq (palmas,PALMAS_GPIO_0_IRQ + offset); +}Why are you implementing this for a driver which does not even expose the ability to trigger IRQs? If it's supposed to support IRQs it should register a struct
irq_chip.
The irq_chip is in the MFD core for the device.
Re: [PATCH 3/4] gpio: palmas: Add support for Palams GPIO
In reply to Laxman DewanganQuoted 4 lines · Laxman Dewangan
Add gpio driver for TI Palmas series PMIC. This has 8 gpio which can work as input/output.
Signed-off-by Laxman Dewangan <[email protected]>
OK you & Mark have convinced me that this driver is OK as it stands.
Do you want me to apply it to my GPIO tree or does it have dependencies so you'll take it through MFD or something?
Yours,
Linus Walleij
Re: [PATCH 3/4] gpio: palmas: Add support for Palams GPIO
Quoted 2 lines · Linus Walleij
Do you want me to apply it to my GPIO tree or does it have dependencies so you'll take it through MFD or something?
The MFD has been merged for a couple of releases now.
Re: [PATCH 3/4] gpio: palmas: Add support for Palams GPIO
Quoted 5 lines · Mark Brown
Quoted 2 lines · Linus Walleij
Do you want me to apply it to my GPIO tree or does it have dependencies so you'll take it through MFD or something?
The MFD has been merged for a couple of releases now.
Yes, Although this driver used the new API introduced in patch 1/4 but I think it is fine to apply this in GPIO subsystem here as it is independent driver.
Re: [rtc-linux] Re: [PATCH 3/4] gpio: palmas: Add support for Palams GPIO
Quoted 4 lines · Laxman Dewangan
Quoted 3 lines · Mark Brown
On Thu, Jan 17, 2013 at 11:34:42AM +0100, Linus Walleij wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Do you want me to apply it to my GPIO tree or does it have dependencies so you'll take it through MFD or something?
The MFD has been merged for a couple of releases now.
Yes, Although this driver used the new API introduced in patch 1/4 but I think it is fine to apply this in GPIO subsystem here as it is independent driver.
OK that's what fooled me.
Patch applied!
Yours,
Linus Walleij
PATCH 4/4 rtc: palmas: add RTC driver Palmas series PMIC
In reply to Laxman DewanganTI Palmas series PMIC support the RTC and alarm functionality. Add RTC driver with alarm support for this device.
--- drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-palmas.c | 339 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 350 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-palmas.c
drivers/rtc/Kconfig +10 -0
@@ -279,6 +279,16 @@ config RTC_DRV_X1205 This driver can also be built as a module. If so, the module will be called rtc-x1205. +config RTC_DRV_PALMAS + tristate "TI Palmas RTC driver" + depends on MFD_PALMAS + help + If you say yes here you get support for the RTC of TI PALMA series PMIC + chips. + + This driver can also be built as a module. If so, the module + will be called rtc-palma. + config RTC_DRV_PCF8523 tristate "NXP PCF8523" help
drivers/rtc/Makefile +1 -0
@@ -77,6 +77,7 @@ obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o obj-$(CONFIG_RTC_DRV_NUC900) += rtc-nuc900.o obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o +obj-$(CONFIG_RTC_DRV_PALMAS) += rtc-palmas.o obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
drivers/rtc/rtc-palmas.c new file +339 -0
339 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Quoted 9 lines · Laxman Dewangan
This series add the RTC and gpio driver for the TI Palma series PMIC. The changes are splitted so that easy to apply in different sub systems.
Laxman Dewangan (4):
mfd: palmas: add rtc irq number as irq resource for palmas-rtc
mfd: palmas: add apis to access the Palmas' registers
gpio: palmas: Add support for Palams GPIO
rtc: palmas: add RTC driver Palmas series PMIC
Samuel,
I think you need to take all these patches to your tree as Linus has dropped the gpio patch due to build error. Possible same will apply for RTC change also.
Thanks,
Laxman
Hi Laxman,
Quoted 8 lines · Laxman Dewangan
This series add the RTC and gpio driver for the TI Palma series PMIC. The changes are splitted so that easy to apply in different sub systems.
Laxman Dewangan (4):
mfd: palmas: add rtc irq number as irq resource for palmas-rtc
mfd: palmas: add apis to access the Palmas' registers
gpio: palmas: Add support for Palams GPIO
rtc: palmas: add RTC driver Palmas series PMIC
All 4 patches applied to my for-next branch, thanks.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Quoted 6 lines · Samuel Ortiz
Hi Laxman,
Quoted 3 lines · Laxman Dewangan
This series add the RTC and gpio driver for the TI Palma series PMIC. The changes are splitted so that easy to apply in different sub systems.
Quoted 6 lines
Quoted 5 lines
Laxman Dewangan (4):
mfd: palmas: add rtc irq number as irq resource for palmas-rtc
mfd: palmas: add apis to access the Palmas' registers
gpio: palmas: Add support for Palams GPIO
rtc: palmas: add RTC driver Palmas series PMICAll 4 patches applied to my for-next branch, thanks.
Hi Samuel,
Thanks for taking care. But it seems 2/4 of this series is missed which is very important for 3/4 and 4/4 to be compile.
Can you please apply the 2/4 before 3/4 and 4/4?
Thanks,
Laxman
Hi Laxman,
Quoted 12 lines · Laxman Dewangan
Quoted 11 lines · Samuel Ortiz
Hi Laxman,
Quoted 8 lines · Laxman Dewangan
This series add the RTC and gpio driver for the TI Palma series PMIC. The changes are splitted so that easy to apply in different sub systems.
Laxman Dewangan (4):
mfd: palmas: add rtc irq number as irq resource for palmas-rtc
mfd: palmas: add apis to access the Palmas' registers
gpio: palmas: Add support for Palams GPIO
rtc: palmas: add RTC driver Palmas series PMIC
Quoted 7 lines
Quoted 1 line
All 4 patches applied to my for-next branch, thanks.
Hi Samuel,
Thanks for taking care. But it seems 2/4 of this series is missed which is very important for 3/4 and 4/4 to be compile.
Can you please apply the 2/4 before 3/4 and 4/4?
Patch #2 is applied, see:
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Quoted 18 lines · Samuel Ortiz
Hi Laxman,
Quoted 15 lines · Laxman Dewangan
Quoted 6 lines · Samuel Ortiz
Hi Laxman,
Quoted 3 lines · Laxman Dewangan
This series add the RTC and gpio driver for the TI Palma series PMIC. The changes are splitted so that easy to apply in different sub systems.
Quoted 6 lines
Quoted 5 lines
Laxman Dewangan (4):
mfd: palmas: add rtc irq number as irq resource for palmas-rtc
mfd: palmas: add apis to access the Palmas' registers
gpio: palmas: Add support for Palams GPIO
rtc: palmas: add RTC driver Palmas series PMICAll 4 patches applied to my for-next branch, thanks.
Hi Samuel,
Quoted 8 lines
Quoted 4 lines
Thanks for taking care. But it seems 2/4 of this series is missed which is very important for 3/4 and 4/4 to be compile.
Can you please apply the 2/4 before 3/4 and 4/4?
Patch #2 is applied, see:
Yes, it is there, Thank you very much. All patches are applied properly.
Thanks,
Laxman