Add initial support for DA9150 Charger & Fuel-Gauge IC
Subsystems (5)
v4 cover Add initial support for DA9150 Charger & Fuel-Gauge IC
This patch set adds initial support for the Dialog DA9150 Integrated Charger & Fuel-Gauge IC. The device also provides GPIO and GPADC functionality.
In this patch set the following is provided:
- MFD Core support and DT bindings documentation.
- IIO GPADC support and DT bindings documentation.
- Power Supply Charger support and DT bindings documentation.
- Update to MAINTAINERS file to add DA9150 files to Dialog support list.
- Update to IIO ABI document to add info regarding input current readings.
To keep patch submission from being too large, support for GPIO and Fuel-Gauge will come after initial support patches are accepted.
This patch set is baselined against the v3.18-rc6 kernel version.
Changes in v4:
- Correct MODULE_AUTHOR lines so e-mail addresses correctly surrounded with <>.
- Update to MFD binding document to remove unnecesary I2C reference, make module description generic, and add link to interrupt binding documentation.
- For GPADC driver, irq request moved above iio related calls in probe() to mirror correctly the remove() function ordering, as requested.
- For charger driver, remove additional sysfs entries as these are not necessary (debug only).
- For charger driver, add helper function for requesting IRQs, to make probe() function cleaner/simpler.
Changes in v3:
- IRQ register and remove helper functions removed from MFD, deemed unnecessary. Drivers using helper functions updated to use direct calls to relevant kernel framework functions.
- MFD I2C file removed and code folded into -core file as requested.
- MFD core now buildable as driver module.
- Platform data structure definition moved into core header, pdata.h removed.
- Update functions in GPADC driver to be static, where appropriate.
- Change units of GPADC readings to match ABI documentation. Updates to charger driver also made to align with this modification.
- Refactor GPADC temp calculations to use scale & offset method.
- Scale values now returned as FRACTIONAL to allow for accurate conversion in user-space.
- Tidy up of GPADC scale, offset and raw functions to return from case statements with correct return types.
- Update GPADC channel macros naming to prefix with DA9150, prevent conflict.
- GPADC GPIO voltage readings actually in 6V range, updated accordingly.
- Addition to IIO ABI document to add details on input current readings.
- Small style updates to address comments.
Changes in v2:
- Drop devicetree prefix patch as this is being dealt with separately.
- IIO framework fix patch removed from set, has already been accepted/merged.
- Use __ instead of _ for protecting #ifdefs in headers.
- Moved private data & definitions to source files and remove unwanted headers.
- Bug fix to EXPORT_SYMBOL for common functions in MFD core used by sub-devices, so they can be correctly built as kernel modules.
- Removed unnecessary channels from GPADC IIO driver to simplify code.
- For GPADC IIO driver, VBAT reading now provides scale and offset values as it is a linear scale.
- GPADC read code refactored to make it tidier.
- Remove use of flag to indicate GPADC availability. IIO framework should indicate need to defer if it's not yet instantiated.
- Unwanted comments removed.
- Removed conditional shutdown of device (Charger/MFD) as this is not needed.
- Removed AC type supply from charger as device cannot differentiate. Now just uses USB supply type.
- Removed use of invalid-tbat flag from platform data as it doesn't really add anything to the driver except forcing battery present status.
- Bug fix for checking of usb_phy validity in Charger probe() function.
- Addition of common IRQ release function to allow sub-devices to explicitly tidy up IRQs when devm clean up is too late.
- Improved tidy up of resources in charger.
- Fix location of IIO GPADC related devicetree binding document so it now resides correctly under 'adc' directory.
- Add update to MAINTAINERS file to include these files in Dialog support list.
Adam Thomson (8):
mfd: Add support for DA9150 combined charger & fuel-gauge device
mfd: da9150: Add DT binding documentation for core
iio: Add support for DA9150 GPADC
iio: da9150: Add DT binding documentation for GPADC
power: Add support for DA9150 Charger
power: da9150: Add DT binding documentation for charger
MAINTAINERS: Include DA9150 files in Dialog Semiconductor support
list.
iio: Add ABI documentation for input current readings
Documentation/ABI/testing/sysfs-bus-iio | 17 + .../devicetree/bindings/iio/adc/da9150-gpadc.txt | 16 + Documentation/devicetree/bindings/mfd/da9150.txt | 43 + .../devicetree/bindings/power/da9150-charger.txt | 26 + MAINTAINERS | 4 + drivers/iio/adc/Kconfig | 9 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/da9150-gpadc.c | 410 +++++++ drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 2 +- drivers/mfd/da9150-core.c | 413 +++++++ drivers/power/Kconfig | 12 + drivers/power/Makefile | 1 + drivers/power/da9150-charger.c | 666 +++++++++++ include/linux/mfd/da9150/core.h | 68 ++ include/linux/mfd/da9150/registers.h | 1155 ++++++++++++++++++++ 16 files changed, 2854 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/da9150-gpadc.txt create mode 100644 Documentation/devicetree/bindings/mfd/da9150.txt create mode 100644 Documentation/devicetree/bindings/power/da9150-charger.txt create mode 100644 drivers/iio/adc/da9150-gpadc.c create mode 100644 drivers/mfd/da9150-core.c create mode 100644 drivers/power/da9150-charger.c create mode 100644 include/linux/mfd/da9150/core.h create mode 100644 include/linux/mfd/da9150/registers.h
--
1.9.3
PATCH v4 1/8 mfd: Add support for DA9150 combined charger & fuel-gauge device
DA9150 is a combined Charger and Fuel-Gauge IC, with additional GPIO and GPADC functionality.
--- drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 2 +- drivers/mfd/da9150-core.c | 413 ++++++++++++ include/linux/mfd/da9150/core.h | 68 ++ include/linux/mfd/da9150/registers.h | 1155 ++++++++++++++++++++++++++++++++++ 5 files changed, 1649 insertions(+), 1 deletion(-) create mode 100644 drivers/mfd/da9150-core.c create mode 100644 include/linux/mfd/da9150/core.h create mode 100644 include/linux/mfd/da9150/registers.h
drivers/mfd/Kconfig +12 -0
@@ -183,6 +183,18 @@ config MFD_DA9063 Additional drivers must be enabled in order to use the functionality of the device. +config MFD_DA9150 + tristate "Dialog Semiconductor DA9150 Charger Fuel-Gauge chip" + depends on I2C=y + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + This adds support for the DA9150 integrated charger and fuel-gauge + chip. This driver provides common support for accessing the device. + Additional drivers must be enabled in order to use the specific + features of the device. + config MFD_MC13XXX tristate depends on (SPI_MASTER || I2C)
drivers/mfd/Makefile +1 -1
@@ -113,7 +113,7 @@ obj-$(CONFIG_MFD_DA9055) += da9055.o da9063-objs := da9063-core.o da9063-irq.o da9063-i2c.o obj-$(CONFIG_MFD_DA9063) += da9063.o - +obj-$(CONFIG_MFD_DA9150) += da9150-core.o obj-$(CONFIG_MFD_MAX14577) += max14577.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o
drivers/mfd/da9150-core.c new file +413 -0
413 lines not on this page · raw message
include/linux/mfd/da9150/core.h new file +68 -0
68 lines not on this page · raw message
include/linux/mfd/da9150/registers.h new file +1155 -0
1,155 lines not on this page · raw message
--
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 2/8 mfd: da9150: Add DT binding documentation for core
In reply to Adam Thomson--- Documentation/devicetree/bindings/mfd/da9150.txt | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/da9150.txt
Documentation/devicetree/bindings/mfd/da9150.txt new file +43 -0
@@ -0,0 +1,43 @@ +Dialog Semiconductor DA9150 Combined Charger/Fuel-Gauge MFD bindings + +DA9150 consists of a group of sub-devices: + +Device Description +------ ----------- +da9150-gpadc : General Purpose ADC +da9150-charger : Battery Charger + +====== + +Required properties: +- compatible : Should be "dlg,da9150" +- reg: Specifies the I2C slave address +- interrupt-parent: Specifies the phandle of the interrupt controller to which + the IRQs from da9150 are delivered to. +- interrupts: IRQ line info for da9150 chip. +- interrupt-controller: da9150 has internal IRQs (own IRQ domain). + (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for + further information relating to interrupt properties) + +Sub-devices: +- da9150-gpadc: See Documentation/devicetree/bindings/iio/adc/da9150-gpadc.txt +- da9150-charger: See Documentation/devicetree/bindings/power/da9150-charger.txt + + +Example: + + charger_fg: da9150@58 { + compatible = "dlg,da9150"; + reg = <0x58>; + interrupt-parent = <&gpio6>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + interrupt-controller; + + gpadc: da9150-gpadc { + ... + }; + + da9150-charger { + ... + }; + };
--
1.9.3
PATCH v4 3/8 iio: Add support for DA9150 GPADC
In reply to Adam ThomsonThis patch adds support for DA9150 Charger & Fuel-Gauge IC GPADC.
--- drivers/iio/adc/Kconfig | 9 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/da9150-gpadc.c | 410 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 420 insertions(+) create mode 100644 drivers/iio/adc/da9150-gpadc.c
drivers/iio/adc/Kconfig +9 -0
@@ -127,6 +127,15 @@ config AT91_ADC help Say yes here to build support for Atmel AT91 ADC. +config DA9150_GPADC + tristate "Dialog DA9150 GPADC driver support" + depends on MFD_DA9150 + help + Say yes here to build support for Dialog DA9150 GPADC. + + This driver can also be built as a module. If chosen, the module name + will be da9150-gpadc. + config EXYNOS_ADC tristate "Exynos ADC driver support" depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || (OF && COMPILE_TEST)
drivers/iio/adc/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7887) += ad7887.o obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AT91_ADC) += at91_adc.o +obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o obj-$(CONFIG_MAX1027) += max1027.o
drivers/iio/adc/da9150-gpadc.c new file +410 -0
410 lines not on this page · raw message
--
1.9.3
Re: [PATCH v4 3/8] iio: Add support for DA9150 GPADC
Adam Thomson schrieb am 25.11.2014 um 19:25:
Quoted 2 lines
This patch adds support for DA9150 Charger & Fuel-Gauge IC GPADC.
Moving iio_map_array_register around requires an adaption of the error out path. Please see my comment inline.
Quoted 370 lines
Signed-off-by Adam Thomson <[email protected]>--- drivers/iio/adc/Kconfig | 9 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/da9150-gpadc.c | 410 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 420 insertions(+) create mode 100644 drivers/iio/adc/da9150-gpadc.cdrivers/iio/adc/Kconfig +9
-0@@ -127,6 +127,15 @@ config AT91_ADC help Say yes here to build support for Atmel AT91 ADC. +config DA9150_GPADC + tristate "Dialog DA9150 GPADC driver support" + depends on MFD_DA9150 + help + Say yes here to build support for Dialog DA9150 GPADC. + + This driver can also be built as a module. If chosen, the module name + will be da9150-gpadc. + config EXYNOS_ADC tristate "Exynos ADC driver support" depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || (OF && COMPILE_TEST)drivers/iio/adc/Makefile +1
-0@@ -14,6 +14,7 @@ obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7887) += ad7887.o obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AT91_ADC) += at91_adc.o +obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o obj-$(CONFIG_MAX1027) += max1027.odrivers/iio/adc/da9150-gpadc.c new file +324
-0@@ -0,0 +1,410 @@ +/* +* DA9150 GPADC Driver +* +* Copyright (c) 2014 Dialog Semiconductor +* +* Author: Adam Thomson <[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. +*/ + +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/interrupt.h> +#include <linux/mutex.h> +#include <linux/completion.h> +#include <linux/iio/iio.h> +#include <linux/iio/machine.h> +#include <linux/iio/driver.h> +#include <linux/mfd/da9150/core.h> +#include <linux/mfd/da9150/registers.h> + +/* Channels */ +enum da9150_gpadc_hw_channel { +DA9150_GPADC_HW_CHAN_GPIOA_2V =0 , +DA9150_GPADC_HW_CHAN_GPIOA_2V_ , +DA9150_GPADC_HW_CHAN_GPIOB_2V , +DA9150_GPADC_HW_CHAN_GPIOB_2V_ , +DA9150_GPADC_HW_CHAN_GPIOC_2V , +DA9150_GPADC_HW_CHAN_GPIOC_2V_ , +DA9150_GPADC_HW_CHAN_GPIOD_2V , +DA9150_GPADC_HW_CHAN_GPIOD_2V_ , +DA9150_GPADC_HW_CHAN_IBUS_SENSE , +DA9150_GPADC_HW_CHAN_IBUS_SENSE_ , +DA9150_GPADC_HW_CHAN_VBUS_DIV , +DA9150_GPADC_HW_CHAN_VBUS_DIV_ , +DA9150_GPADC_HW_CHAN_ID , +DA9150_GPADC_HW_CHAN_ID_ , +DA9150_GPADC_HW_CHAN_VSYS , +DA9150_GPADC_HW_CHAN_VSYS_ , +DA9150_GPADC_HW_CHAN_GPIOA_6V , +DA9150_GPADC_HW_CHAN_GPIOA_6V_ , +DA9150_GPADC_HW_CHAN_GPIOB_6V , +DA9150_GPADC_HW_CHAN_GPIOB_6V_ , +DA9150_GPADC_HW_CHAN_GPIOC_6V , +DA9150_GPADC_HW_CHAN_GPIOC_6V_ , +DA9150_GPADC_HW_CHAN_GPIOD_6V , +DA9150_GPADC_HW_CHAN_GPIOD_6V_ , +DA9150_GPADC_HW_CHAN_VBAT , +DA9150_GPADC_HW_CHAN_VBAT_ , +DA9150_GPADC_HW_CHAN_TBAT , +DA9150_GPADC_HW_CHAN_TBAT_ , +DA9150_GPADC_HW_CHAN_TJUNC_CORE , +DA9150_GPADC_HW_CHAN_TJUNC_CORE_ , +DA9150_GPADC_HW_CHAN_TJUNC_OVP , +DA9150_GPADC_HW_CHAN_TJUNC_OVP_ , +}; + +enum da9150_gpadc_channel { +DA9150_GPADC_CHAN_GPIOA =0 , +DA9150_GPADC_CHAN_GPIOB , +DA9150_GPADC_CHAN_GPIOC , +DA9150_GPADC_CHAN_GPIOD , +DA9150_GPADC_CHAN_IBUS , +DA9150_GPADC_CHAN_VBUS , +DA9150_GPADC_CHAN_ID , +DA9150_GPADC_CHAN_VSYS , +DA9150_GPADC_CHAN_VBAT , +DA9150_GPADC_CHAN_TBAT , +DA9150_GPADC_CHAN_TJUNC_CORE , +DA9150_GPADC_CHAN_TJUNC_OVP , +}; + +/* Private data */ +struct da9150_gpadc { +struct da9150 *da9150; +struct device *dev; + +struct mutex lock; +struct completion complete; +}; + + +static irqreturn_t da9150_gpadc_irq (int irq,void *data) +{ + +struct da9150_gpadc *gpadc = data; + +complete (&gpadc->complete); + +return IRQ_HANDLED ; +} + +static int da9150_gpadc_read_adc (struct da9150_gpadc *gpadc,int hw_chan) +{ +u8 result_regs[2 ]; +int result; + +mutex_lock (&gpadc->lock); + +/* Set channel & enable measurement */ +da9150_reg_write (gpadc->da9150,DA9150_GPADC_MAN , + (DA9150_GPADC_EN_MASK | + hw_chan <<DA9150_GPADC_MUX_SHIFT )); + +/* Consume left-over completion from a previous timeout */ +try_wait_for_completion (&gpadc->complete); + +/* Check for actual completion */ +wait_for_completion_timeout (&gpadc->complete,msecs_to_jiffies (5 )); + +/* Read result and status from device */ +da9150_bulk_read (gpadc->da9150,DA9150_GPADC_RES_A ,2 , result_regs); + +mutex_unlock (&gpadc->lock); + +/* Check to make sure device really has completed reading */ +if (result_regs[1 ] &DA9150_GPADC_RUN_MASK ) { +dev_err (gpadc->dev,"Timeout on channel %d of GPADC\n" , + hw_chan); +return -ETIMEDOUT ; + } + +/* LSBs - 2 bits */ + result = (result_regs[1 ] &DA9150_GPADC_RES_L_MASK ) >> +DA9150_GPADC_RES_L_SHIFT ; +/* MSBs - 8 bits */ + result |= result_regs[0 ] <<DA9150_GPADC_RES_L_BITS ; + +return result; +} + +static inline int da9150_gpadc_gpio_6v_voltage_now (int raw_val) +{ +/* Convert to mV */ +return (6 * ((raw_val *1000 ) +500 )) /1024 ; +} + +static inline int da9150_gpadc_ibus_current_avg (int raw_val) +{ +/* Convert to mA */ +return (4 * ((raw_val *1000 ) +500 )) /2048 ; +} + +static inline int da9150_gpadc_vbus_21v_voltage_now (int raw_val) +{ +/* Convert to mV */ +return (21 * ((raw_val *1000 ) +500 )) /1024 ; +} + +static inline int da9150_gpadc_vsys_6v_voltage_now (int raw_val) +{ +/* Convert to mV */ +return (3 * ((raw_val *1000 ) +500 )) /512 ; +} + +static int da9150_gpadc_read_processed (struct da9150_gpadc *gpadc,int channel, +int hw_chan,int *val) +{ +int raw_val; + + raw_val =da9150_gpadc_read_adc (gpadc, hw_chan); +if (raw_val <0 ) +return raw_val; + +switch (channel) { +case DA9150_GPADC_CHAN_GPIOA : +case DA9150_GPADC_CHAN_GPIOB : +case DA9150_GPADC_CHAN_GPIOC : +case DA9150_GPADC_CHAN_GPIOD : + *val =da9150_gpadc_gpio_6v_voltage_now (raw_val); +break ; +case DA9150_GPADC_CHAN_IBUS : + *val =da9150_gpadc_ibus_current_avg (raw_val); +break ; +case DA9150_GPADC_CHAN_VBUS : + *val =da9150_gpadc_vbus_21v_voltage_now (raw_val); +break ; +case DA9150_GPADC_CHAN_VSYS : + *val =da9150_gpadc_vsys_6v_voltage_now (raw_val); +break ; +default : +/* No processing for other channels so return raw value */ + *val = raw_val; +break ; + } + +return IIO_VAL_INT ; +} + +static int da9150_gpadc_read_scale (int channel,int *val,int *val2) +{ +switch (channel) { +case DA9150_GPADC_CHAN_VBAT : + *val =2932 ; + *val2 =1000 ; +return IIO_VAL_FRACTIONAL ; +case DA9150_GPADC_CHAN_TJUNC_CORE : +case DA9150_GPADC_CHAN_TJUNC_OVP : + *val =1000000 ; + *val2 =4420 ; +return IIO_VAL_FRACTIONAL ; +default : +return -EINVAL ; + } +} + +static int da9150_gpadc_read_offset (int channel,int *val) +{ +switch (channel) { +case DA9150_GPADC_CHAN_VBAT : + *val =1500000 /2932 ; +return IIO_VAL_INT ; +case DA9150_GPADC_CHAN_TJUNC_CORE : +case DA9150_GPADC_CHAN_TJUNC_OVP : + *val =-144 ; +return IIO_VAL_INT ; +default : +return -EINVAL ; + } +} + +static int da9150_gpadc_read_raw (struct iio_dev *indio_dev, +struct iio_chan_spec const *chan, +int *val,int *val2,long mask) +{ +struct da9150_gpadc *gpadc =iio_priv (indio_dev); + +if ((chan->channel <DA9150_GPADC_CHAN_GPIOA ) || + (chan->channel >DA9150_GPADC_CHAN_TJUNC_OVP )) +return -EINVAL ; + +switch (mask) { +case IIO_CHAN_INFO_RAW : +case IIO_CHAN_INFO_PROCESSED : +return da9150_gpadc_read_processed (gpadc, chan->channel, + chan->address, val); +case IIO_CHAN_INFO_SCALE : +return da9150_gpadc_read_scale (chan->channel, val, val2); +case IIO_CHAN_INFO_OFFSET : +return da9150_gpadc_read_offset (chan->channel, val); +default : +return -EINVAL ; + } +} + +static const struct iio_info da9150_gpadc_info = { + .read_raw = &da9150_gpadc_read_raw, + .driver_module =THIS_MODULE , +}; + +#define DA9150_GPADC_CHANNEL (_id, _hw_id, _type, chan_info, \ + _ext_name) { \ + .type = _type, \ + .indexed = 1, \ + .channel = DA9150_GPADC_CHAN_##_id, \ + .address = DA9150_GPADC_HW_CHAN_##_hw_id, \ + .info_mask_separate = chan_info, \ + .extend_name = _ext_name, \ + .datasheet_name = #_id, \ +} + +#define DA9150_GPADC_CHANNEL_RAW (_id, _hw_id, _type, _ext_name) \ + DA9150_GPADC_CHANNEL(_id, _hw_id, _type, \ + BIT(IIO_CHAN_INFO_RAW), _ext_name) + +#define DA9150_GPADC_CHANNEL_SCALED (_id, _hw_id, _type, _ext_name) \ + DA9150_GPADC_CHANNEL(_id, _hw_id, _type, \ + BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ + _ext_name) + +#define DA9150_GPADC_CHANNEL_PROCESSED (_id, _hw_id, _type, _ext_name) \ + DA9150_GPADC_CHANNEL(_id, _hw_id, _type, \ + BIT(IIO_CHAN_INFO_PROCESSED), _ext_name) + +/* Supported channels */ +static const struct iio_chan_spec da9150_gpadc_channels[] = { +DA9150_GPADC_CHANNEL_PROCESSED (GPIOA ,GPIOA_6V ,IIO_VOLTAGE ,"GPIOA" ), +DA9150_GPADC_CHANNEL_PROCESSED (GPIOB ,GPIOB_6V ,IIO_VOLTAGE ,"GPIOB" ), +DA9150_GPADC_CHANNEL_PROCESSED (GPIOC ,GPIOC_6V ,IIO_VOLTAGE ,"GPIOC" ), +DA9150_GPADC_CHANNEL_PROCESSED (GPIOD ,GPIOD_6V ,IIO_VOLTAGE ,"GPIOD" ), +DA9150_GPADC_CHANNEL_PROCESSED (IBUS ,IBUS_SENSE ,IIO_CURRENT ,"IBUS" ), +DA9150_GPADC_CHANNEL_PROCESSED (VBUS ,VBUS_DIV_ ,IIO_VOLTAGE ,"VBUS" ), +DA9150_GPADC_CHANNEL_RAW (ID ,ID ,IIO_VOLTAGE ,"ID" ), +DA9150_GPADC_CHANNEL_PROCESSED (VSYS ,VSYS ,IIO_VOLTAGE ,"VSYS" ), +DA9150_GPADC_CHANNEL_SCALED (VBAT ,VBAT ,IIO_VOLTAGE ,"VBAT" ), +DA9150_GPADC_CHANNEL_RAW (TBAT ,TBAT ,IIO_VOLTAGE ,"TBAT" ), +DA9150_GPADC_CHANNEL_SCALED (TJUNC_CORE ,TJUNC_CORE ,IIO_TEMP , +"TJUNC_CORE" ), +DA9150_GPADC_CHANNEL_SCALED (TJUNC_OVP ,TJUNC_OVP ,IIO_TEMP , +"TJUNC_OVP" ), +}; + +/* Default maps used by da9150-charger */ +static struct iio_map da9150_gpadc_default_maps[] = { + { + .consumer_dev_name ="da9150-charger" , + .consumer_channel ="CHAN_IBUS" , + .adc_channel_label ="IBUS" , + }, + { + .consumer_dev_name ="da9150-charger" , + .consumer_channel ="CHAN_VBUS" , + .adc_channel_label ="VBUS" , + }, + { + .consumer_dev_name ="da9150-charger" , + .consumer_channel ="CHAN_TJUNC" , + .adc_channel_label ="TJUNC_CORE" , + }, + { + .consumer_dev_name ="da9150-charger" , + .consumer_channel ="CHAN_VBAT" , + .adc_channel_label ="VBAT" , + }, + {}, +}; +
drivers/iio/adc/da9150-gpadc.c line 334
Quoted 10 lines
drivers/iio/adc/da9150-gpadc.c new file +10
-0+static int da9150_gpadc_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct da9150 *da9150 =dev_get_drvdata (dev->parent); +struct da9150_gpadc *gpadc; +struct iio_dev *indio_dev; +int irq, ret; + + indio_dev =devm_iio_device_alloc (&pdev->dev, +sizeof (struct da9150_gpadc ));
BTW: If you use sizeof(*gpadc) instead (like it is usually done as well), it will perfectly fit in one line.
Quoted 13 lines
drivers/iio/adc/da9150-gpadc.c new file +13
-0+if (!indio_dev) { +dev_err (&pdev->dev,"Failed to allocate IIO device\n" ); +return -ENOMEM ; + } + gpadc =iio_priv (indio_dev); + +platform_set_drvdata (pdev, indio_dev); + gpadc->da9150 = da9150; + gpadc->dev = dev; +mutex_init (&gpadc->lock); +init_completion (&gpadc->complete); + + irq =platform_get_irq_byname (pdev,"GPADC" );
drivers/iio/adc/da9150-gpadc.c line 357
Quoted 10 lines
drivers/iio/adc/da9150-gpadc.c new file +10
-0+if (irq <0 ) { +dev_err (dev,"Failed to get IRQ: %d\n" , irq); +return irq; + } + + ret =devm_request_threaded_irq (dev, irq,NULL , da9150_gpadc_irq, +IRQF_ONESHOT ,"GPADC" , gpadc); +if (ret) { +dev_err (dev,"Failed to request IRQ %d: %d\n" , irq, ret); + goto iio_map_unreg;
You need to return ret here, no jump to error out path.
Quoted 61 lines
drivers/iio/adc/da9150-gpadc.c new file +53
-1+ } + + ret =iio_map_array_register (indio_dev, da9150_gpadc_default_maps); +if (ret) { +dev_err (dev,"Failed to register IIO maps: %d\n" , ret); +return ret; + } + + indio_dev->name =dev_name (dev); + indio_dev->dev.parent = dev; + indio_dev->dev.of_node = pdev->dev.of_node; + indio_dev->info = &da9150_gpadc_info; + indio_dev->modes =INDIO_DIRECT_MODE ; + indio_dev->channels = da9150_gpadc_channels; + indio_dev->num_channels =ARRAY_SIZE (da9150_gpadc_channels); + + ret =iio_device_register (indio_dev); +if (ret) { +dev_err (dev,"Failed to register IIO device: %d\n" , ret); + goto iio_map_unreg; + } + +return 0 ; + +iio_map_unreg: +iio_map_array_unregister (indio_dev); + +return ret; +} + +static int da9150_gpadc_remove (struct platform_device *pdev) +{ +struct iio_dev *indio_dev =platform_get_drvdata (pdev); + +iio_device_unregister (indio_dev); +iio_map_array_unregister (indio_dev); + +return 0 ; +} + +static struct platform_driver da9150_gpadc_driver = { + .driver = { + .name ="da9150-gpadc" , + }, + .probe = da9150_gpadc_probe, + .remove = da9150_gpadc_remove, +}; + +module_platform_driver (da9150_gpadc_driver); + +MODULE_DESCRIPTION ("GPADC Driver for DA9150" ); +MODULE_AUTHOR ("Adam Thomson <[email protected]>" ); +MODULE_LICENSE ("GPL" ); --1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v4 3/8] iio: Add support for DA9150 GPADC
Quoted 4 lines · Hartmut Knaack
drivers/iio/adc/da9150-gpadc.c line 334
Quoted 2 lines
drivers/iio/adc/da9150-gpadc.c new file +2
-0+ indio_dev =devm_iio_device_alloc (&pdev->dev, +sizeof (struct da9150_gpadc ));BTW: If you use
sizeof(*gpadc)instead (like it is usually done as well), it will perfectly fit in one line.
I preferred to be explicit that the item is a struct, but really not that fussed either way. Also have been asked previously in a separate driver to make the same mod you mention so will update accordingly.
Quoted 6 lines
drivers/iio/adc/da9150-gpadc.c line 357
Quoted 5 lines
drivers/iio/adc/da9150-gpadc.c new file +5
-0+ ret =devm_request_threaded_irq (dev, irq,NULL , da9150_gpadc_irq, +IRQF_ONESHOT ,"GPADC" , gpadc); +if (ret) { +dev_err (dev,"Failed to request IRQ %d: %d\n" , irq, ret); + goto iio_map_unreg;You need to return ret here, no jump to error out path.
Yes, thanks. Annoyed I missed that in the re-factor. Will fix it.
PATCH v4 4/8 iio: da9150: Add DT binding documentation for GPADC
In reply to Adam Thomson--- .../devicetree/bindings/iio/adc/da9150-gpadc.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/da9150-gpadc.txt
Documentation/devicetree/bindings/iio/adc/da9150-gpadc.txt new file +16 -0
@@ -0,0 +1,16 @@ +Dialog Semiconductor DA9150 IIO GPADC bindings + +Required properties: +- compatible: "dlg,da9150-gpadc" for DA9150 IIO GPADC +- #io-channel-cells: Should be set to <1> + (See Documentation/devicetree/bindings/iio/iio-bindings.txt for further info) + +For further information on GPADC channels, see device datasheet. + + +Example: + + gpadc: da9150-gpadc { + compatible = "dlg,da9150-gpadc"; + #io-channel-cells = <1>; + };
--
1.9.3
PATCH v4 5/8 power: Add support for DA9150 Charger
In reply to Adam ThomsonThis patch adds support for DA9150 Charger & Fuel-Gauge IC Charger.
--- drivers/power/Kconfig | 12 + drivers/power/Makefile | 1 + drivers/power/da9150-charger.c | 666 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 679 insertions(+) create mode 100644 drivers/power/da9150-charger.c
drivers/power/Kconfig +12 -0
@@ -192,6 +192,18 @@ config BATTERY_DA9052 Say Y here to enable support for batteries charger integrated into DA9052 PMIC. +config CHARGER_DA9150 + tristate "Dialog Semiconductor DA9150 Charger support" + depends on MFD_DA9150 + depends on DA9150_GPADC + depends on IIO + help + Say Y here to enable support for charger unit of the DA9150 + Integrated Charger & Fuel-Gauge IC. + + This driver can also be built as a module. If so, the module will be + called da9150-charger. + config BATTERY_MAX17040 tristate "Maxim MAX17040 Fuel Gauge" depends on I2C
drivers/power/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_BATTERY_SBS) += sbs-battery.o obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o +obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.o obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o obj-$(CONFIG_BATTERY_Z2) += z2_battery.o
drivers/power/da9150-charger.c new file +666 -0
666 lines not on this page · raw message
--
1.9.3
PATCH v4 6/8 power: da9150: Add DT binding documentation for charger
In reply to Adam Thomson--- .../devicetree/bindings/power/da9150-charger.txt | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/da9150-charger.txt
Documentation/devicetree/bindings/power/da9150-charger.txt new file +26 -0
@@ -0,0 +1,26 @@ +Dialog Semiconductor DA9150 Charger Power Supply bindings + +Required properties: +- compatible: "dlg,da9150-charger" for DA9150 Charger Power Supply + +Optional properties: +- io-channels: List of phandle and IIO specifier pairs +- io-channel-names: List of channel names used by charger + ["CHAN_IBUS", "CHAN_VBUS", "CHAN_TJUNC", "CHAN_VBAT"] + (See Documentation/devicetree/bindings/iio/iio-bindings.txt for further info) + + +Example: + + da9150-charger { + compatible = "dlg,da9150-charger"; + + io-channels = <&gpadc 0>, + <&gpadc 2>, + <&gpadc 8>, + <&gpadc 5>; + io-channel-names = "CHAN_IBUS", + "CHAN_VBUS", + "CHAN_TJUNC", + "CHAN_VBAT"; + };
--
1.9.3
PATCH v4 7/8 MAINTAINERS: Include DA9150 files in Dialog Semiconductor support list.
In reply to Adam Thomson--- MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+)
MAINTAINERS +4 -0
@@ -2990,12 +2990,15 @@ S: Supported F: Documentation/hwmon/da90?? F: drivers/gpio/gpio-da90??.c F: drivers/hwmon/da90??-hwmon.c +F: drivers/iio/adc/da91??-*.c F: drivers/input/misc/da90??_onkey.c F: drivers/input/touchscreen/da9052_tsi.c F: drivers/leds/leds-da90??.c F: drivers/mfd/da903x.c F: drivers/mfd/da90??-*.c +F: drivers/mfd/da91??-*.c F: drivers/power/da9052-battery.c +F: drivers/power/da91??-*.c F: drivers/regulator/da903x.c F: drivers/regulator/da9???-regulator.[ch] F: drivers/rtc/rtc-da90??.c
@@ -3005,6 +3008,7 @@ F: include/linux/mfd/da903x.h F: include/linux/mfd/da9052/ F: include/linux/mfd/da9055/ F: include/linux/mfd/da9063/ +F: include/linux/mfd/da9150/ F: include/sound/da[79]*.h F: sound/soc/codecs/da[79]*.[ch]
--
1.9.3
PATCH v4 8/8 iio: Add ABI documentation for input current readings
In reply to Adam ThomsonAdd information on in_current related readings.
--- Documentation/ABI/testing/sysfs-bus-iio | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
Documentation/ABI/testing/sysfs-bus-iio +17 -0
@@ -92,6 +92,18 @@ Description: is required is a consistent labeling. Units after application of scale and offset are millivolts. +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_raw +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_supply_raw +KernelVersion: 3.17 +Contact: [email protected] +Description: + Raw (unscaled no bias removal etc.) current measurement from + channel Y. In special cases where the channel does not + correspond to externally available input one of the named + versions may be used. The number must always be specified and + unique to allow association with event codes. Units after + application of scale and offset are milliamps. + What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw KernelVersion: 3.2 Contact: [email protected]
@@ -227,6 +239,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_offset What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_offset What: /sys/bus/iio/devices/iio:deviceX/in_voltage_offset +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_offset +What: /sys/bus/iio/devices/iio:deviceX/in_current_offset What: /sys/bus/iio/devices/iio:deviceX/in_tempY_offset What: /sys/bus/iio/devices/iio:deviceX/in_temp_offset What: /sys/bus/iio/devices/iio:deviceX/in_pressureY_offset
@@ -249,8 +263,11 @@ Description: to the _raw output. What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_scale +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_scale +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_supply_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltage_scale +What: /sys/bus/iio/devices/iio:deviceX/in_current_scale What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale
--
1.9.3
Jonathan Cameron
maintainerRe: [PATCH v4 8/8] iio: Add ABI documentation for input current readings
Quoted 3 lines · Adam Thomson
Add information on
in_currentrelated readings.Signed-off-by Adam Thomson <[email protected]>
This one stands on it's own to applied (with some fuzz and tiny bit of rearranging) to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 51 lines
--- Documentation/ABI/testing/sysfs-bus-iio | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)Documentation/ABI/testing/sysfs-bus-iio +17
-1@@ -92,6 +92,18 @@ Description: is required is a consistent labeling. Units after application of scale and offset are millivolts. +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_raw +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_supply_raw +KernelVersion: 3.17 +Contact: [email protected] +Description: + Raw (unscaled no bias removal etc.) current measurement from + channel Y. In special cases where the channel does not + correspond to externally available input one of the named + versions may be used. The number must always be specified and + unique to allow association with event codes. Units after + application of scale and offset are milliamps. + What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw KernelVersion: 3.2 Contact: [email protected]@@ -227,6 +239,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_offset What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_offset What: /sys/bus/iio/devices/iio:deviceX/in_voltage_offset +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_offset +What: /sys/bus/iio/devices/iio:deviceX/in_current_offset What: /sys/bus/iio/devices/iio:deviceX/in_tempY_offset What: /sys/bus/iio/devices/iio:deviceX/in_temp_offset What: /sys/bus/iio/devices/iio:deviceX/in_pressureY_offset@@ -249,8 +263,11 @@ Description: to the _raw output. What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_scale +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_scale +What: /sys/bus/iio/devices/iio:deviceX/in_currentY_supply_scale What: /sys/bus/iio/devices/iio:deviceX/in_voltage_scale +What: /sys/bus/iio/devices/iio:deviceX/in_current_scale What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_scale What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale --1.9.3
RE: [PATCH v4 8/8] iio: Add ABI documentation for input current readings
Quoted 11 lines · Jonathan Cameron
Quoted 3 lines · Adam Thomson
Add information on
in_currentrelated readings.Signed-off-by Adam Thomson <[email protected]>This one stands on it's own to applied (with some fuzz and tiny bit of rearranging) to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Ok great. Thanks.