drivers/mfd: DA9058 MFD core driver
Subsystems (2)
PATCH v5 1/7 drivers/mfd: DA9058 MFD core driver
This patch is relative to linux next-20130417
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.
There are 3 warnings from scripts/checkpatch.pl, but since it seems to be complaining about variable names such as min_uV are in CamelCase, when it is obvious that they are not in CamelCase I have ignored them.
Changes relative to V4 of this patch:
- rebased to latest tagged linux-next - previously relative to mainline
- included adc.h for use by DA9058 ADC driver
- changed all names with uV to uv just to confuse and upset all physicists
--- drivers/mfd/Kconfig | 17 + drivers/mfd/Makefile | 3 + drivers/mfd/da9058-core.c | 74 +++ drivers/mfd/da9058-i2c.c | 97 ++++ drivers/mfd/da9058-info.c | 929 ++++++++++++++++++++++++++++++++++ drivers/mfd/da9058-irq.c | 57 +++ include/linux/mfd/da9058/adc.h | 18 + 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 | 33 ++ 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 | 30 ++ include/linux/mfd/da9058/registers.h | 480 ++++++++++++++++++ include/linux/mfd/da9058/regulator.h | 33 ++ include/linux/mfd/da9058/rtc.h | 17 + 20 files changed, 2039 insertions(+) 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/adc.h 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 +17 -0
@@ -139,6 +139,23 @@ config MFD_DA9055 This driver can be built as a module. If built as a module it will be called "da9055" +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_MC13783 tristate
drivers/mfd/Makefile +3 -0
@@ -114,6 +114,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 +74 -0
74 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 +929 -0
929 lines not on this page · raw message
drivers/mfd/da9058-irq.c new file +57 -0
57 lines not on this page · raw message
include/linux/mfd/da9058/adc.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* 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_ADC_H +#define __DA9058_ADC_H + +struct da9058_adc_pdata { +int use_automatic_adc; +}; + +#endif /* __DA9058_ADC_H */
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); +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); + +#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 +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_HWMON_H +#define __DA9058_HWMON_H + +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; +int battery_sensor_type; +}; + +struct da9058_hwmon_pdata { +int use_automatic_adc; +int temp_adc_resistance; +int vf_adc_resistance; +int battery_sensor_type; +}; + +#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); +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 +30 -0
@@ -0,0 +1,30 @@ +/* +* 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 { +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; +int battery_sensor_type; +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_step_mask; +int control_enable_mask; +int ramp_register; +int ramp_enable_mask; +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 V5
drivers/mfd/da9058-info.c line 243
Quoted 4 lines · Anthony Olech
drivers/mfd/da9058-info.c new file +4
-0+static struct regulator_consumer_supply platform_vddarm_consumers[] = { + {.supply ="vcc" ,} +}; +
This looks very system specific and should be done by the system integration for the board not the MFD.
Quoted 8 lines
drivers/mfd/da9058-info.c new file +8
-0+static struct da9058_regulator_pdata buck1_pdata = { + .regulator_name ="DA9058_BUCK1" , + .regulator_id =DA9058_BUCK_1 , + .min_uv =DA9058_BUCK12_VOLT_LOWER *1000 , + .max_uv =DA9058_BUCK12_VOLT_UPPER *1000 , + .control_voltage_step =DA9058_BUCK_VOLT_STEP *1000 , + .control_register =DA9058_BUCK1_REG , + .control_step_mask =DA9058_MAX_VSEL ,
drivers/mfd/da9058-info.c line 305
Quoted 10 lines
drivers/mfd/da9058-info.c new file +10
-0+ .control_enable_mask = DA9058_BUCK_LDO_EN, + .ramp_register = DA9058_SUPPLY_REG, + .ramp_enable_mask = DA9058_SUPPLY_VBUCK1GO, + .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE | + REGULATOR_CHANGE_STATUS, + .valid_modes_mask = REGULATOR_MODE_NORMAL, + .boot_on = 1, + .num_consumer_supplies = ARRAY_SIZE(platform_vddarm_consumers), + .consumer_supplies = platform_vddarm_consumers, +};
The regulators might be used for some totally different purpose on another system, and the configuration may be different even if the purpose is the same. The above also doesn't make much sense, you allow changing modes but only support one mode.
You need to split out the regulator_init_data and let the board set it up.