Skip to contentSkip to conversation

DA9058 MFD core driver

PATCH Superseded Anthony Olech 1 participant 1 message Apr 12, 2013

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/7 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.

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.

---
 drivers/mfd/Kconfig                  |   18 +
 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/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 +
 19 files changed, 2022 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/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
index c346941..c7a7d62 100644
@@ -3,6 +3,7 @@
 #
 
 if HAS_IOMEM
+
 menu "Multifunction device drivers"
 
 config MFD_CORE
@@ -45,6 +46,23 @@ config MFD_88PM805
 	  components like codec device, headset/Mic device 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
index b90409c..c6a00f9 100644
@@ -111,6 +111,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/bat.h new file +33 -0
new file mode 100644
index 0000000..71ebb56
@@ -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
new file mode 100644
index 0000000..dd0d479
@@ -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
new file mode 100644
index 0000000..0445162
@@ -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
new file mode 100644
index 0000000..b61eee7
@@ -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
new file mode 100644
index 0000000..5d00ba4
@@ -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
new file mode 100644
index 0000000..e18db523
@@ -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
new file mode 100644
index 0000000..8b95117
@@ -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
new file mode 100644
index 0000000..321e15f
@@ -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
new file mode 100644
index 0000000..b5f1e8d
@@ -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
new file mode 100644
index 0000000..aa597df
@@ -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 V4