MFD: DA9052 MFD core module
Subsystems (2)
PATCH v3 1/11 MFD: DA9052 MFD core module
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 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 | 67 ++++ drivers/mfd/Makefile | 7 + drivers/mfd/da9052-core.c | 404 +++++++++++++++++++ drivers/mfd/da9052-i2c.c | 137 +++++++ drivers/mfd/da9052-irq.c | 170 ++++++++ drivers/mfd/da9052-spi.c | 107 +++++ include/linux/mfd/da9052/da9052.h | 84 ++++ include/linux/mfd/da9052/pdata.h | 42 ++ include/linux/mfd/da9052/reg.h | 783 +++++++++++++++++++++++++++++++++++++ 9 files changed, 1801 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 +67 -0
@@ -343,6 +343,73 @@ 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 PMIC 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 PMIC 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 MFD_DA9053_SPI + bool "Support Dialog Semiconductor DA9053 PMIC with SPI" + select MFD_DA9052_SPI + depends on SPI_MASTER=y + help + Support for the Dialog Semiconductor DA9053 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_DA9053_I2C + bool "Support Dialog Semiconductor DA9053 PMIC with I2C" + select REGMAP_I2C + select MFD_DA9052_I2C + depends on I2C=y + help + Support for the Dialog Semiconductor DA9053 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. + +choice + prompt "Chip Type" + depends on MFD_DA9053_SPI || MFD_DA9053_I2C +config PMIC_DA9053AA + bool "Support Dialog Semiconductor DA9053 AA PMIC" + help + Support for Dialog semiconductor DA9053 AA PMIC. + 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_DA9053Bx + bool "Support Dialog Semiconductor DA9053 BA/BB PMIC" + help + Support for Dialog semiconductor DA9053 BA/BB PMIC. + This driver provides common support for accessing the device, + additional drivers must be enabled in order to use the + functionality of the device. + +endchoice + 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 +404 -0
404 lines not on this page · raw message
drivers/mfd/da9052-i2c.c new file +137 -0
137 lines not on this page · raw message
drivers/mfd/da9052-irq.c new file +170 -0
170 lines not on this page · raw message
drivers/mfd/da9052-spi.c new file +107 -0
107 lines not on this page · raw message
include/linux/mfd/da9052/da9052.h new file +84 -0
84 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 +783 -0
783 lines not on this page · raw message
On Fri, Aug 05, 2011 at 07:23:44PM +0530, ashishj3 wrote:
Patch v3 seems a little low, we've had *slightly* more versions than that...
drivers/mfd/Kconfig config PMIC_DA903X · line 403
Quoted 11 lines
drivers/mfd/Kconfig +11
-0+choice + prompt "Chip Type" + depends on MFD_DA9053_SPI || MFD_DA9053_I2C +config PMIC_DA9053AA + bool "Support Dialog Semiconductor DA9053 AA PMIC" + help + Support for Dialog semiconductor DA9053 AA PMIC. + 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_DA9053Bx
Could do with blank lines between blocks. Though looking at the code here I don't understand why these are compile options at all, or if they need to be compile options for some reason why they're not independantly selectable?
drivers/mfd/da9052-core.c line 192
Quoted 12 lines
drivers/mfd/da9052-core.c new file +12
-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 ; + } + +#ifdef CONFIG_MFD_DA9052_SPI + reg = (reg <<1 ) |1 ; +#endif
There's several problems here:
- You shouldn't be indenting preprocessor directives.
- You shouldn't be adding extra indentation before.
- This will break I2C devices if SPI support is built into the driver.
Please, when writing code try to understand the abstractions you're using. For example here think about the purpose of being able to build I2C and SPI separately and simultaneously and the goal of the regmap API.
Looks like we need to add per device mangling for the SPI register read/write flag.
drivers/mfd/da9052-core.c line 357
Quoted 11 lines
drivers/mfd/da9052-core.c new file +11
-0+static struct mfd_cell __initdata da9052_subdev_info[] = { + {"da9052-onkey" , .resources = &da9052_onkey_resource, + .num_resources =1 }, + {"da9052-rtc" , .resources = &da9052_rtc_resource, + .num_resources =1 }, + {"da9052-gpio" }, + {"da9052-hwmon" }, + {"da9052-leds" }, + {"da9052-WLED1" }, + {"da9052-WLED2" }, + {"da9052-WLED3" },
Upper case in device names is *very* non-idiomatic.
drivers/mfd/da9052-core.c line 363
Quoted 6 lines
drivers/mfd/da9052-core.c new file +6
-0+ {"da9052-tsi", .resources = da9052_tsi_resources, + .num_resources = ARRAY_SIZE(da9052_tsi_resources)}, + {"da9052-bat", .resources = da9052_power_resources, + .num_resources = ARRAY_SIZE(da9052_power_resources)}, + {"da9052-watchdog"}, +};
The formatting here is really odd for Linux, both in terms of the lack of spaces and the brace placement.
drivers/mfd/da9052-irq.c line 106
Quoted 5 lines
drivers/mfd/da9052-irq.c new file +5
-0+da9052_group_write (da9052,DA9052_EVENT_A_REG ,4 , v); + +#ifndef CONFIG_PMIC_DA9053Bx +DA9052_FIXME (); +#endif
This should be runtime detected based on the device name, either from the device registration or by reading back chip identification.
Formatting issues too.
drivers/mfd/da9052-spi.c line 96
Quoted 3 lines
drivers/mfd/da9052-spi.c new file +3
-0+return 0 ; +} +module_init (da9052_spi_init);
I rather suspect that you'll find that in order to use this in an actual system this needs to be subsys_initcall().
Quoted 1 line
+MODULE_ALIAS("platform:da9052_spi");
This isn't a platform driver.
Quoted 11 lines
-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Saturday, August 06, 2011 7:09 PM
To: Ashish Jangam
Cc: [email protected]; [email protected]; Dajun; linaro- [email protected]
Subject: Re: [PATCH v3 01/11] MFD: DA9052 MFD core moduleOn Fri, Aug 05, 2011 at 07:23:44PM +0530, ashishj3 wrote:
Quoted 16 lines
drivers/mfd/Kconfig config PMIC_DA903X · line 403
Quoted 11 lines
drivers/mfd/Kconfig +11
-0+choice + prompt "Chip Type" + depends on MFD_DA9053_SPI || MFD_DA9053_I2C +config PMIC_DA9053AA + bool "Support Dialog Semiconductor DA9053 AA PMIC" + help + Support for Dialog semiconductor DA9053 AA PMIC. + 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_DA9053BxCould do with blank lines between blocks. Though looking at the code here I don't understand why these are compile options at all, or if they need to be compile options for some reason why they're not independantly selectable?
DA9052 PMIC chip id may get OTP therefore chip id cannot be used as a distinguishing factor. Hence these compile time options were introduced. DA9053 is a higher version of DA9052 therefore not independently selectable. This means that there can be either DA9052 or DA9053 on system. I need to correct this Kconfig to take care of this.
Quoted 20 lines
drivers/mfd/da9052-core.c line 192
Quoted 13 lines
drivers/mfd/da9052-core.c new file +12
-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 ; + } + +#ifdef CONFIG_MFD_DA9052_SPI + reg = (reg <<1 ) |1 ; +#endif There's several problems here:
- You shouldn't be indenting preprocessor directives.
- You shouldn't be adding extra indentation before.
- This will break I2C devices if SPI support is built into the driver.
Quoted 7 lines
Please, when writing code try to understand the abstractions you're using. For example here think about the purpose of being able to build I2C and SPI separately and simultaneously and the goal of the regmap API.
Looks like we need to add per device mangling for the SPI register read/write flag.
For now we will handle this as below:-
During SPI and I2C registration we will add bus type(SPI/I2C) info in the struct da9052. And before initiating any device I/O this struct member will be read and reg address will be manipulated if needed.
Quoted 9 lines
drivers/mfd/da9052-irq.c line 106
Quoted 6 lines
drivers/mfd/da9052-irq.c new file +5
-0+da9052_group_write (da9052,DA9052_EVENT_A_REG ,4 , v); + +#ifndef CONFIG_PMIC_DA9053Bx +DA9052_FIXME (); +#endif This should be runtime detected based on the device name, either from the device registration or by reading back chip identification.
As said above getting chip info will not work in DA9053/53 case. Also DA9052 code works for DA9053 except for few minor changes in MFD and regulator module. In this case registering different device will also require a preprocessor directive Or separate DA9053 file therefore this option was not opt.
Quoted 1 line
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 10 lines · Ashish Jangam
Quoted 4 lines
Could do with blank lines between blocks. Though looking at the code here I don't understand why these are compile options at all, or if they need to be compile options for some reason why they're not independantly selectable?
DA9052 PMIC chip id may get OTP therefore chip id cannot be used as a distinguishing factor. Hence these compile time options were introduced. DA9053 is a higher version of DA9052 therefore not independently selectable. This means that there can be either DA9052 or DA9053 on system. I need to correct this
Kconfigto take care of this.
No, this is not acceptable in the kernel. One kernel can support many different boards so you need to be able to compile support for all chips in simultaneously. If you can't identify based on the hardware you need to rely on the device being registered correctly by the user.
Quoted 7 lines
Quoted 2 lines
This should be runtime detected based on the device name, either from the device registration or by reading back chip identification.
As said above getting chip info will not work in DA9053/53 case. Also DA9052 code works for DA9053 except for few minor changes in MFD and regulator module. In this case registering different device will also require a preprocessor directive Or separate DA9053 file therefore this option was not opt.
No, this is not acceptable. One kernel build should be able to support many different boards. Like I said in my quote above you need to either use the device registration or chip registers - if chip registers are not suitable I guess that means you need to use the device registration. There are a large number of examples of this in the kernel.
I know the Linaro guys have offered to help you out with this stuff, can you please work with them? You are obviously experiencing a lot of difficulties with understanding the requirements and standards for getting your code into the standard kernel, they really know what they're doing.