MFD: DA9052/53 MFD core module v4
Subsystems (2)
PATCH 1/11 MFD: DA9052/53 MFD core module v4
The DA9052 is a highly integrated PMIC subsystem with supply domain flexibility to support wide range of high performance application.
It provides voltage regulators, GPIO controller, Touch Screen, RTC, Battery control and other functionality.
---
Changes since v4:
- Modify KConfig to support DA9052/53
- Use device registration for detemining chip id
- Lower case in device names
- Replace preprocessor directive with runtime bustype variable
- Use of subsys_initcall in spi module
- Remove MODULE_ALIAS from spi module.
Changes since v3:
- Code refactored to use REGMAP API.
- Add Battery resources.
- da9052_set_bits() and da9052_clear_bits() replaced by da9052_reg_update().
- Add support for DA9053 PMIC
Changes since v2:
- Drop da9052_irqs[] table.
- Move struct da9052_subdev_info[].
- Remove initialization of static member.
- Care for NULL pdata init().
- Check removal of subdevices on errors.
- Remove open source spi code.
- Remove '_spi' from the driver name.
- Move tbat_lookup table from header file.
- Remove irq.h
- Remove num_gpio variable from pdata
--- drivers/mfd/Kconfig | 26 ++ drivers/mfd/Makefile | 7 + drivers/mfd/da9052-core.c | 408 +++++++++++++++++++ drivers/mfd/da9052-i2c.c | 143 +++++++ drivers/mfd/da9052-irq.c | 171 ++++++++ drivers/mfd/da9052-spi.c | 166 ++++++++ include/linux/mfd/da9052/da9052.h | 93 +++++ include/linux/mfd/da9052/pdata.h | 42 ++ include/linux/mfd/da9052/reg.h | 777 +++++++++++++++++++++++++++++++++++++ 9 files changed, 1833 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/da9052-core.c create mode 100644 drivers/mfd/da9052-i2c.c create mode 100644 drivers/mfd/da9052-irq.c create mode 100644 drivers/mfd/da9052-spi.c create mode 100644 include/linux/mfd/da9052/da9052.h create mode 100644 include/linux/mfd/da9052/pdata.h create mode 100644 include/linux/mfd/da9052/reg.h
drivers/mfd/Kconfig +26 -0
@@ -343,6 +343,32 @@ config PMIC_DA903X individual components like LCD backlight, voltage regulators, LEDs and battery-charger under the corresponding menus. +config PMIC_DA9052 + bool + select MFD_CORE + +config MFD_DA9052_SPI + bool "Support Dialog Semiconductor DA9052/53 PMIC variants with SPI" + select REGMAP_SPI + select PMIC_DA9052 + depends on SPI_MASTER=y + help + Support for the Dialog Semiconductor DA9052 PMIC + when controlled using SPI. This driver provides common support + for accessing the device, additional drivers must be enabled in + order to use the functionality of the device. + +config MFD_DA9052_I2C + bool "Support Dialog Semiconductor DA9052/53 PMIC variants with I2C" + select REGMAP_I2C + select PMIC_DA9052 + depends on I2C=y + help + Support for the Dialog Semiconductor DA9052 PMIC + when controlled using I2C. This driver provides common support + for accessing the device, additional drivers must be enabled in + order to use the functionality of the device. + config PMIC_ADP5520 bool "Analog Devices ADP5520/01 MFD PMIC Core Support" depends on I2C=y
drivers/mfd/Makefile +7 -0
@@ -67,6 +67,13 @@ endif obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o obj-$(CONFIG_PMIC_DA903X) += da903x.o + +da9052-objs := da9052-core.o da9052-irq.o +obj-$(CONFIG_PMIC_DA9052) += da9052.o + +obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o +obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o + max8925-objs := max8925-core.o max8925-i2c.o obj-$(CONFIG_MFD_MAX8925) += max8925.o obj-$(CONFIG_MFD_MAX8997) += max8997.o max8997-irq.o
drivers/mfd/da9052-core.c new file +408 -0
408 lines not on this page · raw message
drivers/mfd/da9052-i2c.c new file +143 -0
143 lines not on this page · raw message
drivers/mfd/da9052-irq.c new file +171 -0
171 lines not on this page · raw message
drivers/mfd/da9052-spi.c new file +166 -0
166 lines not on this page · raw message
include/linux/mfd/da9052/da9052.h new file +93 -0
93 lines not on this page · raw message
include/linux/mfd/da9052/pdata.h new file +42 -0
42 lines not on this page · raw message
include/linux/mfd/da9052/reg.h new file +777 -0
777 lines not on this page · raw message
drivers/mfd/da9052-core.c line 193
Quoted 11 lines · On Thu, Aug 18, 2011 at 07:23:22PM +0530, ashishj3 wrote:
drivers/mfd/da9052-core.c new file +11
-0+int da9052_reg_read (struct da9052 *da9052,unsigned char reg) +{ +int val, ret; + +if (reg >DA9052_MAX_REG_CNT ) { +dev_err (da9052->dev,"invalid reg %x\n" , reg); +return -EINVAL ; + } + +if (da9052->bustype ==BUS_SPI ) + reg = (reg <<1 ) |1 ;
The same comment I made last time applies now: this isn't something that should be being handled at the driver level.
For all your I/O functions there's not really any work going on in the function except the translation from struct da9052 to the regmap it points to. May as well just turn the functions into inlines.
Quoted 5 lines
drivers/mfd/da9052-irq.c new file +5
-0+if (events ==0 ) + goto err; + +for (i =0 ; i <32 ; i++) { +if (events & (1 << i))
drivers/mfd/da9052-irq.c line 109
Quoted 10 lines
drivers/mfd/da9052-irq.c new file +10
-0+handle_nested_irq (da9052->irq_base + i); + } + +da9052_group_write (da9052,DA9052_EVENT_A_REG ,4 , v); + +if (da9052->chip_id ==DA9052 || da9052->chip_id ==DA9053_AA ) +DA9052_FIXME (); + +err: +return IRQ_HANDLED ;
If you hit an error you didn't handle an IRQ and so ought to be returning IRQ_NONE.