Commit 8e2747f0 authored by Marek Belisko's avatar Marek Belisko Committed by Anton Vorontsov

rx51_battery: Replace hardcoded channels values.

In twl4030_madc header exist defines for fixed channels + add rx51
specific channels and replace all hardcoded channels values.
Signed-off-by: default avatarMarek Belisko <marek.belisko@open-nandra.com>
Signed-off-by: default avatarAnton Vorontsov <anton@enomsg.org>
parent d7bf353f
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c/twl4030-madc.h> #include <linux/i2c/twl4030-madc.h>
/* RX51 specific channels */
#define TWL4030_MADC_BTEMP_RX51 TWL4030_MADC_ADCIN0
#define TWL4030_MADC_BCI_RX51 TWL4030_MADC_ADCIN4
struct rx51_device_info { struct rx51_device_info {
struct device *dev; struct device *dev;
struct power_supply bat; struct power_supply bat;
...@@ -37,7 +41,7 @@ static int rx51_battery_read_adc(int channel) ...@@ -37,7 +41,7 @@ static int rx51_battery_read_adc(int channel)
{ {
struct twl4030_madc_request req; struct twl4030_madc_request req;
req.channels = 1 << channel; req.channels = channel;
req.do_avg = 1; req.do_avg = 1;
req.method = TWL4030_MADC_SW1; req.method = TWL4030_MADC_SW1;
req.func_cb = NULL; req.func_cb = NULL;
...@@ -56,7 +60,7 @@ static int rx51_battery_read_adc(int channel) ...@@ -56,7 +60,7 @@ static int rx51_battery_read_adc(int channel)
*/ */
static int rx51_battery_read_voltage(struct rx51_device_info *di) static int rx51_battery_read_voltage(struct rx51_device_info *di)
{ {
int voltage = rx51_battery_read_adc(12); int voltage = rx51_battery_read_adc(TWL4030_MADC_VBAT);
if (voltage < 0) if (voltage < 0)
return voltage; return voltage;
...@@ -108,7 +112,7 @@ static int rx51_battery_read_temperature(struct rx51_device_info *di) ...@@ -108,7 +112,7 @@ static int rx51_battery_read_temperature(struct rx51_device_info *di)
{ {
int min = 0; int min = 0;
int max = ARRAY_SIZE(rx51_temp_table2) - 1; int max = ARRAY_SIZE(rx51_temp_table2) - 1;
int raw = rx51_battery_read_adc(0); int raw = rx51_battery_read_adc(TWL4030_MADC_BTEMP_RX51);
/* Zero and negative values are undefined */ /* Zero and negative values are undefined */
if (raw <= 0) if (raw <= 0)
...@@ -142,7 +146,7 @@ static int rx51_battery_read_temperature(struct rx51_device_info *di) ...@@ -142,7 +146,7 @@ static int rx51_battery_read_temperature(struct rx51_device_info *di)
*/ */
static int rx51_battery_read_capacity(struct rx51_device_info *di) static int rx51_battery_read_capacity(struct rx51_device_info *di)
{ {
int capacity = rx51_battery_read_adc(4); int capacity = rx51_battery_read_adc(TWL4030_MADC_BCI_RX51);
if (capacity < 0) if (capacity < 0)
return capacity; return capacity;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment