Skip to contentSkip to conversation

MFD: DA9052/53 MFD core module v9

PATCH In review Ashish Jangam 2 participants 3 messages Dec 9, 2011 – Dec 12, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 MFD: DA9052/53 MFD core module v9

The DA9052/53 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.

This patch is functionally tested on Samsung SMDKV6410.

---
Changes since v9:
- Add support for regmap_irq
- Patch split into I2C, ADC and SPI
- Support unconditional registration of all the regulators
- Replace magic number with define
- Remove user define bus_type from struct da9052
- Use spi_device_id - implemented in spi incremental patch
- Remove ADC deadlock issue - implemented in ADC incremental patch Changes since v8:
- Add read/write mask flag for SPI
Changes since v7:
- Replace ADC polling with interrupt mechanism
- Move macros related to battery module IRQs to header file Changes since v6:
- Move inlined device I/O functions to header file
Changes since v5:
- Inline device I/O
- Unhandle IRQ return IRQ_NONE
- Remove register address conversion
Changes since v4:
- Modify KConfig
- Use device registration for detemining chip id
- Remove preprocessor directive with runtime bustype variable
- Replace module_init() for spi with subsys_initcall()
- Remove platform string from MODULE_ALIAS of 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               |   16 +
 drivers/mfd/Makefile              |    4 +
 drivers/mfd/da9052-core.c         |  366 +++++++++++++++++
 drivers/mfd/da9052-i2c.c          |  144 +++++++
 include/linux/mfd/da9052/da9052.h |  150 +++++++
 include/linux/mfd/da9052/pdata.h  |   40 ++
 include/linux/mfd/da9052/reg.h    |  778 +++++++++++++++++++++++++++++++++++++
 7 files changed, 1498 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/da9052-core.c
 create mode 100644 drivers/mfd/da9052-i2c.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 +16 -0
index f1391c2..baced42 100644
@@ -328,6 +328,22 @@ 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_I2C
+	bool "Support Dialog Semiconductor DA9052/53 PMIC variants with I2C"
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	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 +4 -0
index b2292eb..484f209 100644
@@ -67,6 +67,10 @@ endif
 obj-$(CONFIG_UCB1400_CORE)	+= ucb1400_core.o
 
 obj-$(CONFIG_PMIC_DA903X)	+= da903x.o
+
+obj-$(CONFIG_PMIC_DA9052)	+= da9052-core.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 +366 -0

366 lines not on this page · raw message

drivers/mfd/da9052-i2c.c new file +144 -0

144 lines not on this page · raw message

include/linux/mfd/da9052/da9052.h new file +150 -0

150 lines not on this page · raw message

include/linux/mfd/da9052/pdata.h new file +40 -0
new file mode 100644
index 0000000..62c5c3c
@@ -0,0 +1,40 @@
+/*
+ * Platform data declarations for DA9052 PMICs.
+ *
+ * Copyright(c) 2011 Dialog Semiconductor Ltd.
+ *
+ * Author: David Dajun Chen <[email protected]>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef __MFD_DA9052_PDATA_H__
+#define __MFD_DA9052_PDATA_H__
+
+#define DA9052_MAX_REGULATORS	14
+
+struct da9052;
+
+struct da9052_pdata {
+	struct led_platform_data *pled;
+	int (*init) (struct da9052 *da9052);
+	int irq_base;
+	int gpio_base;
+	int use_for_apm;
+	struct regulator_init_data *regulators[DA9052_MAX_REGULATORS];
+};
+
+#endif
include/linux/mfd/da9052/reg.h new file +778 -0

778 lines not on this page · raw message

Signature · 1 line
1.7.1
Reviewed-by on v1 1/6
#1 lore raw
Quoted 2 lines · Ashish Jangam

The DA9052/53 is a highly integrated PMIC subsystem with supply domain flexibility to support wide range of high performance application.

This looks pretty good now. There's a few issues below but with those corrected the driver looks good.

Quoted 7 lines
drivers/mfd/da9052-core.c new file +7 -0
+int da9052_add_regulator_devices(struct da9052 *da9052)
+{
+	struct platform_device *pdev;
+	int i, ret;
+
+	for (i = 0; i < DA9052_MAX_REGULATORS; i++) {
+		pdev = platform_device_alloc("da9052-regulator", i);

drivers/mfd/da9052-core.c line 122

Quoted 10 lines
drivers/mfd/da9052-core.c new file +10 -0
+		if (!pdev)
+			return -ENOMEM;
+
+		pdev->dev.parent = da9052->dev;
+		ret = platform_device_add(pdev);
+		if (ret) {
+			platform_device_put(pdev);
+			return ret;
+		}
+	}

Same comment as ever about these - just make them normal MFD children.

drivers/mfd/da9052-core.c line 326

Quoted 2 lines
drivers/mfd/da9052-core.c new file +2 -0
+	if (!pdata && !pdata->irq_base)
+		da9052->irq_base = -1;

The above should be || not && - you want to set irq_base to -1 if you don't have one provided.

include/linux/mfd/da9052/da9052.h line 142

Quoted 8 lines
include/linux/mfd/da9052/da9052.h new file +8 -0
+static inline int da9052_reg_update(struct da9052 *da9052, unsigned char reg,
+				     unsigned char bit_mask,
+				     unsigned char reg_val)
+{
+	if (reg > DA9052_MAX_REG_CNT) {
+		dev_err(da9052->dev, "invalid reg %x\n", reg);
+		return -EINVAL;
+	}

regmap will do this for you if you tell it max_register, this will also get you the ability to inspect the device registers via debugfs which can be very helpful. I'd also encourage you to enable cache support, it should make system performance better.

#2 lore raw
In reply to Ashish Jangam
Quoted 2 lines · Ashish Jangam

The DA9052/53 is a highly integrated PMIC subsystem with supply domain flexibility to support wide range of high performance application.

Oh, actually I see you didn't Samuel, you must always CC maintainers on patches otherwise they're likely to not see and apply them.

Samuel, as this uses a newly introduced regmap feature do you want me to apply these patches? I'm also happy for you to merge

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git topic/irq

into your tree (though obviously that'd prevent you rebasing).