DA9058 MFD core driver
Subsystems (2)
PATCH v3 1/8 DA9058 MFD core driver
This is the CORE component driver for the Dialog DA9058 PMIC MFD.
This driver, via MFD CELLs, causes all the other component drivers to be loaded (if a module), and initialized via their probe methods. All the other component drivers depend on this CORE component driver.
This CORE component driver supplies all of the MFD cell platform data used by the other DA9058 component drivers for initialization. This CORE component driver recieves the actual platform data from the machine driver, but that config data has the nature of overides from sensible default values. Thus it is not essential to provide any real platform data at all from the machine driver.
--- drivers/mfd/Kconfig | 18 + drivers/mfd/Makefile | 3 + drivers/mfd/da9058-core.c | 83 +++ drivers/mfd/da9058-i2c.c | 97 ++++ drivers/mfd/da9058-info.c | 935 ++++++++++++++++++++++++++++++++++ drivers/mfd/da9058-irq.c | 56 ++ include/linux/mfd/da9058/bat.h | 33 ++ include/linux/mfd/da9058/codec.h | 22 + include/linux/mfd/da9058/conf.h | 22 + include/linux/mfd/da9058/core.h | 66 +++ include/linux/mfd/da9058/gpio.h | 19 + include/linux/mfd/da9058/hwmon.h | 36 ++ include/linux/mfd/da9058/i2c.h | 22 + include/linux/mfd/da9058/irq.h | 50 ++ include/linux/mfd/da9058/onkey.h | 17 + include/linux/mfd/da9058/pdata.h | 32 ++ include/linux/mfd/da9058/registers.h | 480 +++++++++++++++++ include/linux/mfd/da9058/regulator.h | 33 ++ include/linux/mfd/da9058/rtc.h | 17 + 19 files changed, 2041 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/da9058-core.c create mode 100644 drivers/mfd/da9058-i2c.c create mode 100644 drivers/mfd/da9058-info.c create mode 100644 drivers/mfd/da9058-irq.c create mode 100644 include/linux/mfd/da9058/bat.h create mode 100644 include/linux/mfd/da9058/codec.h create mode 100644 include/linux/mfd/da9058/conf.h create mode 100644 include/linux/mfd/da9058/core.h create mode 100644 include/linux/mfd/da9058/gpio.h create mode 100644 include/linux/mfd/da9058/hwmon.h create mode 100644 include/linux/mfd/da9058/i2c.h create mode 100644 include/linux/mfd/da9058/irq.h create mode 100644 include/linux/mfd/da9058/onkey.h create mode 100644 include/linux/mfd/da9058/pdata.h create mode 100644 include/linux/mfd/da9058/registers.h create mode 100644 include/linux/mfd/da9058/regulator.h create mode 100644 include/linux/mfd/da9058/rtc.h
drivers/mfd/Kconfig +18 -0
@@ -3,6 +3,7 @@ # if HAS_IOMEM + menu "Multifunction device drivers" config MFD_CORE
@@ -20,6 +21,23 @@ config MFD_88PM860X select individual components like voltage regulators, RTC and battery-charger under the corresponding menus. +config MFD_DA9058 + tristate "Dialog Semiconductor DA9058 PMIC Support" + depends on I2C + select REGMAP_I2C + select REGMAP_IRQ + select MFD_CORE + help + Say yes here for support of Dialog Semiconductor DA9058. This is + a Power Management IC. This driver provides common support for + accessing the device as well as the I2C interface to the chip itself. + Additional drivers must be enabled in order to use the functionality + of the device. + + This driver can be built as a module, but since the functionality + of the device includes regulators it probably should be built into + the kernel. If built as a module it will be called "da9058" + config MFD_SM501 tristate "Support for Silicon Motion SM501" ---help---
drivers/mfd/Makefile +3 -0
@@ -86,6 +86,9 @@ obj-$(CONFIG_MFD_MAX8998) += max8998.o max8998-irq.o pcf50633-objs := pcf50633-core.o pcf50633-irq.o obj-$(CONFIG_MFD_PCF50633) += pcf50633.o +da9058-objs = da9058-irq.o da9058-i2c.o da9058-core.o da9058-info.o +obj-$(CONFIG_MFD_DA9058) += da9058.o + obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o obj-$(CONFIG_ABX500_CORE) += abx500-core.o
drivers/mfd/da9058-core.c new file +83 -0
83 lines not on this page · raw message
drivers/mfd/da9058-i2c.c new file +97 -0
97 lines not on this page · raw message
drivers/mfd/da9058-info.c new file +935 -0
935 lines not on this page · raw message
drivers/mfd/da9058-irq.c new file +56 -0
56 lines not on this page · raw message
include/linux/mfd/da9058/bat.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __D1982_BAT_H +#define __D1982_BAT_H + +#define DA9058_LOOK_UP_TABLE_SIZE 68 + +struct da9058_temp_capacity { +int temperature; +u32 capacity[DA9058_LOOK_UP_TABLE_SIZE ][2 ]; +}; + +struct da9058_power_table { +int temperature_points; +struct da9058_temp_capacity (*temp_tables)[]; +}; + +struct da9058_power_pdata { +int battery_type; +int bat_low_limit; +int use_automatic_adc; +struct da9058_power_table *lookup_tables; +}; + +#endif /* __D1982_BAT_H */
include/linux/mfd/da9058/codec.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __DA9058_CODEC_H +#define __DA9058_CODEC_H + +struct da9058_codec_pdata { +int i2c_addr; +struct i2c_adapter *i2c_adapter; +int amplifier_initially_on; +int amp_control_reg; +int amp_enable_mask; +}; + +#endif /* __DA9058_CODEC_H */
include/linux/mfd/da9058/conf.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __DA9058_CONF_H +#define __DA9058_CONF_H + +extern struct regmap_irq_chip da9058_irq_chip; +extern int da9058_irq_init (struct da9058 *da9058,int irq, +struct regmap_irq_chip *da9058_irq_chip)__devinit ; +extern int da9058_irq_exit (struct da9058 *da9058); +extern int da9058_add_mfd_devices (struct da9058 *da9058, +struct da9058_chip_pdata *pdata, +struct i2c_adapter *adapter)__devinit ; + +#endif /* __DA9058_CONF_H */
include/linux/mfd/da9058/core.h new file +66 -0
66 lines not on this page · raw message
include/linux/mfd/da9058/gpio.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __D1982_GPIO_H +#define __D1982_GPIO_H + +struct da9058_gpio_pdata { +int ngpio; +int gpio_base; +}; + +#endif /* __D1982_GPIO_H */
include/linux/mfd/da9058/hwmon.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __DA9058_HWMON_H +#define __DA9058_HWMON_H + +struct da9058_hwmon ; +struct da9058_hwmon { +struct da9058 *da9058; +struct platform_device *pdev; + +struct device *class_device; +struct mutex hwmon_lock; +int use_automatic_adc; +int temp_adc_resistance; +int vf_adc_resistance; +void (*exit_hwmon_platform_callback)(struct da9058_hwmon *hwmon); +void (*init_hwmon_platform_callback)(struct da9058_hwmon *hwmon); +}; + +struct da9058_hwmon_pdata { +int use_automatic_adc; +int temp_adc_resistance; +int vf_adc_resistance; +void (*init_hwmon_platform_callback)(struct da9058_hwmon *hwmon); +void (*exit_hwmon_platform_callback)(struct da9058_hwmon *hwmon); +}; + +#endif /* __DA9058_HWMON_H */
include/linux/mfd/da9058/i2c.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __DA9058_I2C_H +#define __DA9058_I2C_H + +struct da9058 ; +struct da9058_chip_pdata ; +extern struct da9058 *da9058_device_init (struct device *dev, +struct regmap *regmap,void *adapter,int irq, +struct da9058_chip_pdata *pdata)__devinit ; +extern int da9058_device_exit (struct da9058 *da9058); +extern struct regmap_config da9058_regmap_config; + +#endif /* __DA9058_I2C_H */
include/linux/mfd/da9058/irq.h new file +50 -0
50 lines not on this page · raw message
include/linux/mfd/da9058/onkey.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __DA9058_ONKEY_H +#define __DA9058_ONKEY_H + +struct da9058_onkey_pdata { +}; + +#endif /* __DA9058_ONKEY_H */
include/linux/mfd/da9058/pdata.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __DA9058_PDATA_H +#define __DA9058_PDATA_H + +struct da9058_hwmon ; +/* +* This is the Platform Data for the DA9058 PMIC chip as a whole. +*/ +struct da9058_chip_pdata { +int (*init_board_irq)(void ); +void (*init_hwmon_platform_callback)(struct da9058_hwmon *hwmon); +void (*exit_hwmon_platform_callback)(struct da9058_hwmon *hwmon); +char *platform_description; +struct i2c_adapter *i2c_adapter; +int battery_type; +int bat_low_limit; +int use_automatic_adc; +int temp_adc_resistance; +int vf_adc_resistance; +struct da9058_power_table *lookup_tables; +}; + +#endif /* __DA9058_PDATA_H */
include/linux/mfd/da9058/registers.h new file +480 -0
480 lines not on this page · raw message
include/linux/mfd/da9058/regulator.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __DA9058_REGULATOR_H +#define __DA9058_REGULATOR_H + +struct da9058_regulator_pdata { +char *regulator_name; +int regulator_id; +int min_uV; +int max_uV; +int control_voltage_step; +int control_register; +int control_enable_mask; +int ramp_register; +int ramp_enable_mask; +int fixed_voltage; +unsigned int valid_ops_mask; +unsigned int valid_modes_mask; +unsigned int always_on:1 ; +unsigned int boot_on:1 ; +int num_consumer_supplies; +struct regulator_consumer_supply *consumer_supplies; +}; + +#endif /* __DA9058_REGULATOR_H */
include/linux/mfd/da9058/rtc.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Copyright (C) 2012 Dialog Semiconductor Ltd. +* +* 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. +* +*/ + +#ifndef __DA9058_RTC_H +#define __DA9058_RTC_H + +struct da9058_rtc_pdata { +}; + +#endif /* __DA9058_RTC_H */
Signature · 1 line
end-of-patch for NEW DRIVER V3
Quoted 4 lines · Anthony Olech
if
HAS_IOMEM
+
menu "Multifunction device drivers"
This random change is still present from the first version....
drivers/mfd/da9058-core.c line 48
Quoted 10 lines
drivers/mfd/da9058-core.c new file +10
-0+/* +* the init_board_irq() call-back function should be defined in +* the machine driver initialization code and is used to set up +* the actual (probably GPIO) line as an interrupt line. +*/ +if (pdata->init_board_irq) { + ret = pdata->init_board_irq (); +if (ret) + goto failed_to_setup_the_actual_i2c_hw_irq; + }
You appear to have ignored my previous review comments about this... it still shouldn't be needed with modern kernels.
drivers/mfd/da9058-info.c line 170
Quoted 12 lines
drivers/mfd/da9058-info.c new file +12
-0+static bool da9058_register_volatile (struct device *dev,unsigned int reg) +{ +switch (reg) { +case DA9058_ADCMAN_REG : +case DA9058_ADCRESH_REG : +case DA9058_ADCRESL_REG : +case DA9058_ALARMD_REG : +case DA9058_ALARMH_REG : +case DA9058_ALARMMI_REG : +case DA9058_ALARMMO_REG : +case DA9058_ALARMS_REG : +case DA9058_ALARMY_REG :
Are all the alarm registers really volatile?
drivers/mfd/da9058-info.c line 95
Quoted 4 lines
drivers/mfd/da9058-info.c new file +4
-0+case DA9058_LDO9_REG : +case DA9058_TOFFSET_REG : +default : +return false;
Just use the default.
drivers/mfd/da9058-info.c line 242
Quoted 3 lines
drivers/mfd/da9058-info.c new file +3
-0+static struct regulator_consumer_supply platform_vddarm_consumers[] = { + {.supply ="vcc" ,} +};
No, this and all your other regulator configuration is board specific.
Quoted 13 lines
-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: 15 August 2012 19:53
To: Opensource [Anthony Olech]
Cc: Samuel Ortiz; Arnd Bergmann; Mauro Carvalho Chehab; Steven Toth; Michael Krufky; LKML; David Dajun Chen
Subject: Re: [NEW DRIVER V3 1/8] DA9058 MFD core driverQuoted 4 lines · Anthony Olech
if
HAS_IOMEM
+
menu "Multifunction device drivers"This random change is still present from the first version....
Quoted 12 lines
drivers/mfd/da9058-core.c line 48
Quoted 10 lines
drivers/mfd/da9058-core.c new file +10
-0+/* +* the init_board_irq() call-back function should be defined in +* the machine driver initialization code and is used to set up +* the actual (probably GPIO) line as an interrupt line. +*/ +if (pdata->init_board_irq) { + ret = pdata->init_board_irq (); +if (ret) + goto failed_to_setup_the_actual_i2c_hw_irq; + }You appear to have ignored my previous review comments about this... it still shouldn't be needed with modern kernels.
The comment you made was "Why is this conditional? With irqdomains there's no real reason to not allocate the IRQs even if you can't usefully use them and it helps make the code simpler."
I obviously did not understand, because you also wrote that the driver must not rely of platform data. That therefore means that the call-back function pdata->init_board_irq might be NULL, which in turn means that a check must be done.
The only other interpretation of your comment is that the h/w IRQ line setup code must be done in the machine driver, in my case for testing is arch/arm/mach-s3c64xx/mach-smdk6410.c But that view is contricted by the init call-backs from the wm8350 and wm1192 drivers.
I am confused, but it does make sense to do the GPIO --> IRQ initialization in the machine driver, so I will try to do that. But who would be responsible for changing the wm8350 and wm1192 drivers to also follow that philosophy?
Quoted 5 lines
Quoted 5 lines
drivers/mfd/da9058-info.c new file +5
-0+static bool da9058_register_volatile (struct device *dev,unsigned int +reg) { +switch (reg) { +case DA9058_ADCMAN_REG : +case DA9058_ADCRESH_REG :
Quoted 8 lines
drivers/mfd/da9058-info.c line 42
Quoted 7 lines
drivers/mfd/da9058-info.c new file +7
-0+case DA9058_ADCRESL_REG : +case DA9058_ALARMD_REG : +case DA9058_ALARMH_REG : +case DA9058_ALARMMI_REG : +case DA9058_ALARMMO_REG : +case DA9058_ALARMS_REG : +case DA9058_ALARMY_REG :Are all the alarm registers really volatile?
register DA9058_ADCMAN_REG has one bit that is set by the PMIC register DA9058_ADCRESH_REG has all bits set by the PMIC register DA9058_ADCRESL_REG has some bits set by the PMIC
so those are volatile
the registers DA9058_ALARMD... are, on detailed inspection of the chip documentation, not volatile. I misread the docs previous. I will make the change. Well done for spotting my mistake - thanks!
Quoted 5 lines
drivers/mfd/da9058-info.c line 95
Quoted 4 lines
drivers/mfd/da9058-info.c new file +4
-0+case DA9058_LDO9_REG : +case DA9058_TOFFSET_REG : +default : +return false;Just use the default.
The compiler will (I hope) produce the same code even if some of the default values are enumerated. I produced those call-backs by starting with all the registers and moving the cases around. I seemed a good idea at the time. Your objection, I presume, is based on source file size or aesthetics, but I will eliminate the functionally redundant cases.
Quoted 4 lines
drivers/mfd/da9058-info.c line 242
Quoted 3 lines
drivers/mfd/da9058-info.c new file +3
-0+static struct regulator_consumer_supply platform_vddarm_consumers[] = { + {.supply ="vcc" ,} +};No, this and all your other regulator configuration is board specific.
I will remove that.
Thank you Mark for the review.
Tony Olech
On Thu, Aug 16, 2012 at 11:34:56AM +0000, Opensource [Anthony Olech] wrote:
Fix your mail configuration to word wrap at something less than 80 columns within paragraphs, your mails are currently extremely hard to read.
Quoted 3 lines
The only other interpretation of your comment is that the h/w IRQ line setup code must be done in the machine driver, in my case for testing is
arch/arm/mach-s3c64xx/mach-smdk6410.cBut that view is contricted by the init call-backs from the wm8350 and wm1192 drivers.
This board driver is not a modern driver, configuration callbacks used to be used but this is no longer be something that's needed.
Quoted 3 lines
I am confused, but it does make sense to do the GPIO --> IRQ initialization in the machine driver, so I will try to do that. But who would be responsible for changing the wm8350 and wm1192 drivers to also follow that philosophy?
If someone has the time and enthusiasm it might be worthwhile, but it's not clear that this is the case.