Re: [NEW DRIVER V5 6/7] drivers/hwmon: DA9058 HWMON driver

2013-04-17 Thread Guenter Roeck
On Wed, Apr 17, 2013 at 05:33:36PM +0100, Anthony Olech wrote:
> This patch is relative to linux next-20130417
> 
> This is the HWMON component driver of the Dialog DA9058 PMIC.
> This driver is just one component of the whole DA9058 PMIC driver.
> It depends on the CORE and ADC component drivers of the DA9058 MFD.
> 
> Changes relative to V3 of this patch:
> - rebased to latest tagged linux-next - previously relative to mainline
> Documentation/hwmon/da9058
> - added final NL
> drivers/hwmon/Kconfig
> - changed dependancy from I2C to MFD
> drivers/hwmon/Makefile
> - put in alphabetical order
> drivers/hwmon/da9058-hwmon.c
> - aligned subsequent lines of function declarations
> - used single function for all slow labels
> - used recommended ..._label as function name
> - error conditions are returned as negative integers
> - chaned to suggested return value casting
> - removed all constant sysfile atributes except the labels
> - corrected parameter to adc read function to unsigned
> - used suggest name 'input' instead of 'value'
> - changed first temp attribute to temp1
> - fixed expression error to boolean and from bitwise and
> - removed redundant return statement
> - removed race condition by initializing before create sysfs
> - corected alignments on broken long lines
> 
> Signed-off-by: Anthony Olech 
> Signed-off-by: David Dajun Chen 
> ---
>  Documentation/hwmon/da9058   |   39 +
>  drivers/hwmon/Kconfig|   10 ++
>  drivers/hwmon/Makefile   |3 +-
>  drivers/hwmon/da9058-hwmon.c |  349 
> ++
>  4 files changed, 400 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/hwmon/da9058
>  create mode 100644 drivers/hwmon/da9058-hwmon.c
> 
> diff --git a/Documentation/hwmon/da9058 b/Documentation/hwmon/da9058
> new file mode 100644
> index 000..eaedfe7
> --- /dev/null
> +++ b/Documentation/hwmon/da9058
> @@ -0,0 +1,39 @@
> +Kernel driver da9058-hwmon
> +==
> +
> +Supported chips:
> +  * Dialog Semiconductor DA9058 PMIC
> +Prefix: 'da9058'
> +Datasheet:
> + http://www.dialog-semiconductor.com/products/power-management/da9058
> +
> +Authors: Opensource [Anthony Olech] 
> +
> +Description
> +---
> +
> +The DA9058 PMIC contains a 5 channel ADC which can be used to monitor a
> +range of system operating parameters, including the battery voltage and
> +temperature.  The ADC measures voltage, but two of the ADC channels can
> +be configured to supply a current, so that if an NTC termister is connected
> +then the voltage reading can be converted to a temperature. Currently the
> +driver provides reporting of all the input values but does not provide any
> +alarms.
> +
> +Voltage Monitoring
> +--
> +
> +Voltages are sampled in either 'automatic' or 'manual' mode, which is an
> +initialization parameter set in the platform data by the machine driver.
> +In manual mode the ADC conversion is 12 bit and in automatic mode it is
> +10 bit. However all the raw readings are reported as 12 bit numbers.
> +
> +Physical Limits
> +---
> +
> +vbat   2500 - 4500 milliVolts
> +tbat   0- 2500 milliVolts
> +adc0- 2500 milliVolts
> +vfpin  0- 4095 milliVolts
> +tjunc  there is a correction factor programmed during manufacturing
> +
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index da93094..8014af2 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -324,6 +324,16 @@ config SENSORS_ATXP1
> This driver can also be built as a module.  If so, the module
> will be called atxp1.
>  
> +config SENSORS_DA9058
> + tristate "Dialog Semiconductor DA9058 ADC"
> + depends on MFD_DA9058 && DA9058_ADC
> + help
> +   If you say yes here you get support for the hardware monitoring
> +   functionality of the Dialog Semiconductor DA9058 PMIC.
> +
> +   This driver can also be built as a module.  If so, the module
> +   will be called da9058-hwmon.
> +
>  config SENSORS_DS620
>   tristate "Dallas Semiconductor DS620"
>   depends on I2C
> diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
> index c51b0dc..5b7705a 100644
> --- a/drivers/hwmon/Makefile
> +++ b/drivers/hwmon/Makefile
> @@ -46,7 +46,8 @@ obj-$(CONFIG_SENSORS_ASC7621)   += asc7621.o
>  obj-$(CONFIG_SENSORS_ATXP1)  += atxp1.o
>  obj-$(CONFIG_SENSORS_CORETEMP)   += coretemp.o
>  obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o
> -obj-$(CONFIG_SENSORS_DA9055)+= da9055-hwmon.o
> +obj-$(CONFIG_SENSORS_DA9055) += da9055-hwmon.o
> +obj-$(CONFIG_SENSORS_DA9058) += da9058-hwmon.o
>  obj-$(CONFIG_SENSORS_DME1737)+= dme1737.o
>  obj-$(CONFIG_SENSORS_DS620)  += ds620.o
>  obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
> diff --git a/drivers/hwmon/da9058-hwmon.c b/drivers/hwmon/da9058-hwmon.c
> new file mode 100644
> index 000..b273f58
> --- /dev/null
> +++ b/drivers/hwmon/da9058-hwmon.c
> @@ -0,0 +1,349 @@
> +/*
> + *  

Re: [NEW DRIVER V5 6/7] drivers/hwmon: DA9058 HWMON driver

2013-04-17 Thread Guenter Roeck
On Wed, Apr 17, 2013 at 05:33:36PM +0100, Anthony Olech wrote:
 This patch is relative to linux next-20130417
 
 This is the HWMON component driver of the Dialog DA9058 PMIC.
 This driver is just one component of the whole DA9058 PMIC driver.
 It depends on the CORE and ADC component drivers of the DA9058 MFD.
 
 Changes relative to V3 of this patch:
 - rebased to latest tagged linux-next - previously relative to mainline
 Documentation/hwmon/da9058
 - added final NL
 drivers/hwmon/Kconfig
 - changed dependancy from I2C to MFD
 drivers/hwmon/Makefile
 - put in alphabetical order
 drivers/hwmon/da9058-hwmon.c
 - aligned subsequent lines of function declarations
 - used single function for all slow labels
 - used recommended ..._label as function name
 - error conditions are returned as negative integers
 - chaned to suggested return value casting
 - removed all constant sysfile atributes except the labels
 - corrected parameter to adc read function to unsigned
 - used suggest name 'input' instead of 'value'
 - changed first temp attribute to temp1
 - fixed expression error to boolean and from bitwise and
 - removed redundant return statement
 - removed race condition by initializing before create sysfs
 - corected alignments on broken long lines
 
 Signed-off-by: Anthony Olech anthony.olech.opensou...@diasemi.com
 Signed-off-by: David Dajun Chen david.c...@diasemi.com
 ---
  Documentation/hwmon/da9058   |   39 +
  drivers/hwmon/Kconfig|   10 ++
  drivers/hwmon/Makefile   |3 +-
  drivers/hwmon/da9058-hwmon.c |  349 
 ++
  4 files changed, 400 insertions(+), 1 deletion(-)
  create mode 100644 Documentation/hwmon/da9058
  create mode 100644 drivers/hwmon/da9058-hwmon.c
 
 diff --git a/Documentation/hwmon/da9058 b/Documentation/hwmon/da9058
 new file mode 100644
 index 000..eaedfe7
 --- /dev/null
 +++ b/Documentation/hwmon/da9058
 @@ -0,0 +1,39 @@
 +Kernel driver da9058-hwmon
 +==
 +
 +Supported chips:
 +  * Dialog Semiconductor DA9058 PMIC
 +Prefix: 'da9058'
 +Datasheet:
 + http://www.dialog-semiconductor.com/products/power-management/da9058
 +
 +Authors: Opensource [Anthony Olech] anthony.olech.opensou...@diasemi.com
 +
 +Description
 +---
 +
 +The DA9058 PMIC contains a 5 channel ADC which can be used to monitor a
 +range of system operating parameters, including the battery voltage and
 +temperature.  The ADC measures voltage, but two of the ADC channels can
 +be configured to supply a current, so that if an NTC termister is connected
 +then the voltage reading can be converted to a temperature. Currently the
 +driver provides reporting of all the input values but does not provide any
 +alarms.
 +
 +Voltage Monitoring
 +--
 +
 +Voltages are sampled in either 'automatic' or 'manual' mode, which is an
 +initialization parameter set in the platform data by the machine driver.
 +In manual mode the ADC conversion is 12 bit and in automatic mode it is
 +10 bit. However all the raw readings are reported as 12 bit numbers.
 +
 +Physical Limits
 +---
 +
 +vbat   2500 - 4500 milliVolts
 +tbat   0- 2500 milliVolts
 +adc0- 2500 milliVolts
 +vfpin  0- 4095 milliVolts
 +tjunc  there is a correction factor programmed during manufacturing
 +
 diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
 index da93094..8014af2 100644
 --- a/drivers/hwmon/Kconfig
 +++ b/drivers/hwmon/Kconfig
 @@ -324,6 +324,16 @@ config SENSORS_ATXP1
 This driver can also be built as a module.  If so, the module
 will be called atxp1.
  
 +config SENSORS_DA9058
 + tristate Dialog Semiconductor DA9058 ADC
 + depends on MFD_DA9058  DA9058_ADC
 + help
 +   If you say yes here you get support for the hardware monitoring
 +   functionality of the Dialog Semiconductor DA9058 PMIC.
 +
 +   This driver can also be built as a module.  If so, the module
 +   will be called da9058-hwmon.
 +
  config SENSORS_DS620
   tristate Dallas Semiconductor DS620
   depends on I2C
 diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
 index c51b0dc..5b7705a 100644
 --- a/drivers/hwmon/Makefile
 +++ b/drivers/hwmon/Makefile
 @@ -46,7 +46,8 @@ obj-$(CONFIG_SENSORS_ASC7621)   += asc7621.o
  obj-$(CONFIG_SENSORS_ATXP1)  += atxp1.o
  obj-$(CONFIG_SENSORS_CORETEMP)   += coretemp.o
  obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o
 -obj-$(CONFIG_SENSORS_DA9055)+= da9055-hwmon.o
 +obj-$(CONFIG_SENSORS_DA9055) += da9055-hwmon.o
 +obj-$(CONFIG_SENSORS_DA9058) += da9058-hwmon.o
  obj-$(CONFIG_SENSORS_DME1737)+= dme1737.o
  obj-$(CONFIG_SENSORS_DS620)  += ds620.o
  obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
 diff --git a/drivers/hwmon/da9058-hwmon.c b/drivers/hwmon/da9058-hwmon.c
 new file mode 100644
 index 000..b273f58
 --- /dev/null
 +++ b/drivers/hwmon/da9058-hwmon.c
 @@ -0,0 +1,349 @@
 +/*
 + *  Copyright (C) 2012 Dialog Semiconductor Ltd.
 + *