Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Led and similar #13

Merged
merged 14 commits into from
Commits on Mar 24, 2013
  1. @LorDClockaN

    add build script

    LorDClockaN authored
Commits on Mar 25, 2013
  1. @LorDClockaN

    Update gitignore

    LorDClockaN authored
  2. @LorDClockaN

    backlight: enable hidden sysfs for color enhance

    maxl authored LorDClockaN committed
  3. @LorDClockaN

    battery: cleanup that log mess

    maxl authored LorDClockaN committed
  4. @LorDClockaN

    nct1008: cleanup that log mess

    maxl authored LorDClockaN committed
  5. @LorDClockaN

    led: derp - dont change backlight_mode

    maxl authored LorDClockaN committed
  6. @LorDClockaN
  7. @LorDClockaN

    led: another derp

    maxl authored LorDClockaN committed
  8. @LorDClockaN
Commits on Mar 26, 2013
  1. @LorDClockaN
  2. @LorDClockaN

    led: cleanup that log mess

    maxl authored LorDClockaN committed
  3. @LorDClockaN

    led: limit BLN brightness to button brightness

    maxl authored LorDClockaN committed
    Conflicts:
    	drivers/leds/leds-lp5521_htc.c
Commits on Mar 30, 2013
  1. @LorDClockaN

    mpdec: fixed compile warning

    maxl authored LorDClockaN committed
  2. @LorDClockaN

    leds: add custom option if slow blink brightness should be limited to…

    maxl authored LorDClockaN committed
    … button brightness - default is true
This page is out of date. Refresh to see the latest.
View
2  .gitignore
@@ -33,6 +33,8 @@ modules.builtin
*.patch
*.gcno
*.xzkern
+*.symvers
+*_autoconf.h
#
# Top-level generic files
View
2  arch/arm/configs/ap33_android_cpuquiet_defconfig
@@ -38,7 +38,7 @@ CONFIG_IRQ_WORK=y
CONFIG_EXPERIMENTAL=y
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
-CONFIG_LOCALVERSION="ncx_314_v31"
+CONFIG_LOCALVERSION="ncx_318_v31e"
CONFIG_LOCALVERSION_AUTO=y
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_LZMA=y
View
2  arch/arm/mach-tegra/board-endeavoru.c
@@ -180,7 +180,7 @@ static struct led_i2c_config lp5521_led_config[] = {
{
.name = "button-backlight",
.led_cur = 2,
- .led_lux = 55,
+ .led_lux = 50,
},
};
View
6 arch/arm/mach-tegra/htc_battery_core.c
@@ -51,6 +51,9 @@ static ssize_t htc_battery_charger_ctrl_timer(struct device *dev,
.store = NULL, \
}
+#define BATTERY_DEBUG 0
+
+#if BATTERY_DEBUG
#define BATT_LOG(fmt, ...) do { \
struct timespec ts; \
struct rtc_time tm; \
@@ -61,6 +64,9 @@ static ssize_t htc_battery_charger_ctrl_timer(struct device *dev,
ktime_to_ns(ktime_get()), tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, \
tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec); \
} while (0)
+#else
+#define BATT_LOG(fmt, ...)
+#endif
#define BATT_ERR(fmt, ...) do { \
struct timespec ts; \
View
6 arch/arm/mach-tegra/htc_battery_tps80032.c
@@ -53,6 +53,9 @@
#define SET_FAKE_TEMP 0x4000
#define SET_FAKE_CAPACITY 0x8000
+#define BATTERY_DEBUG 0
+
+#if BATTERY_DEBUG
#define BATT_LOG(fmt, ...) do { \
struct timespec ts; \
struct rtc_time tm; \
@@ -63,6 +66,9 @@
ktime_to_ns(ktime_get()), tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, \
tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec); \
} while (0)
+#else
+#define BATT_LOG(fmt, ...)
+#endif
#define BATT_ERR(fmt, ...) do { \
struct timespec ts; \
View
1  arch/arm/mach-tegra/tegra_mpdecision.c
@@ -423,7 +423,6 @@ static void tegra_mpdec_work_thread(struct work_struct *work)
static int lpdown_req = 0;
cputime64_t on_time = 0;
bool suspended = false;
- unsigned int core_to_online;
if (ktime_to_ms(ktime_get()) <= tegra_mpdec_tuners_ins.startdelay)
goto out;
View
32 build.sh
@@ -0,0 +1,32 @@
+# Script taken from Imoseyon and modified by LorD CLockaN #
+
+
+#TOOLCHAIN=/home/lord/android/system/prebuilt/linux-x86/toolchain/arm-2011/bin/
+#TOOLCHAIN=/home/lord/android/system/prebuilt/linux-x86/toolchain/arm-eabi-4.5.4/bin/
+#TOOLCHAIN_PREFIX=arm-eabi-
+
+PATH=$PATH:/home/lord/source/kernels/arm-a9-eabi/bin/
+export CCOMPILER=/home/lord/source/kernels/arm-a9-eabi/bin/arm-a9-eabi-
+
+make ARCH=arm ap33_android_cpuquiet_defconfig
+
+make -j16 ARCH=arm CROSS_COMPILE=$CCOMPILER
+
+make ARCH=arm CROSS_COMPILE=/home/lord/source/kernels/arm-a9-eabi/bin/arm-a9-eabi- -C drivers/net/wireless/compat-wireless_R5.SP2.03 KLIB=`pwd` KLIB_BUILD=`pwd` clean -j20
+
+make ARCH=arm CROSS_COMPILE=/home/lord/source/kernels/arm-a9-eabi/bin/arm-a9-eabi- -C drivers/net/wireless/compat-wireless_R5.SP2.03 KLIB=`pwd` KLIB_BUILD=`pwd` -j20
+
+
+cp arch/arm/boot/zImage ../finished/OneXzimage;
+
+find . -iname "*.ko" -exec cp {} ../finished/OneXmodules \;
+
+cp -f drivers/net/wireless/compat-wireless_R5.SP2.03/net/wireless/cfg80211.ko ../finished/OneXmodules
+
+echo "";
+echo "COMPILING FINISHED!!!";
+echo "";
+echo "Press any key to do a \"make clean\" or CTRL+C to skip it";
+read;
+alias make='make -j16 ARCH=arm CROSS_COMPILE=$CCOMPILER'
+make clean
View
247 drivers/leds/leds-lp5521_htc.c
@@ -31,18 +31,20 @@
#define LP5521_MAX_LEDS 3 /* Maximum number of LEDs */
#define LED_DEBUG 0
#if LED_DEBUG
- #define D(x...) printk(KERN_DEBUG "[LED]" x)
- #define I(x...) printk(KERN_INFO "[LED]" x)
+ #define D(x...) pr_info("[LED]" x)
#else
#define D(x...)
- #define I(x...)
#endif
+#define I(x...) pr_info("[LED]" x)
+#define E(x...) pr_err("[LED]" x)
+
static int led_rw_delay;
static int current_state, current_blink, current_time;
static int current_currents = 0, current_lut_coefficient, current_pwm_coefficient;
static int current_mode, backlight_mode, suspend_mode, offtimer_mode;
-static int amber_mode, button_brightness, slow_blink_brightness;
+static int amber_mode, button_brightness, slow_blink_brightness, slow_blink_brightness_limit = 1;
+static int button_brightness_board;
static struct regulator *regulator;
static struct i2c_client *private_lp5521_client;
static struct mutex led_mutex;
@@ -104,7 +106,7 @@ static int __init lp5521_led_tag(char *tag)
}
__setup("led=", lp5521_led_tag);
-static char *hex2string(uint8_t *data, int len)
+char *hex2string(uint8_t *data, int len)
{
static char buf[LED_I2C_WRITE_BLOCK_SIZE*4];
int i;
@@ -135,12 +137,12 @@ static int i2c_write_block(struct i2c_client *client, uint8_t addr,
}
};
- dev_dbg(&client->dev, "W [%02X] = %s\n",
+ D("W [%02X] = %s\n",
addr, hex2string(data, length));
cdata = i2c_get_clientdata(client);
if (length + 1 > LED_I2C_WRITE_BLOCK_SIZE) {
- dev_err(&client->dev, "[LED] i2c_write_block length too long\n");
+ E("i2c_write_block length too long\n");
return -E2BIG;
}
@@ -156,7 +158,7 @@ static int i2c_write_block(struct i2c_client *client, uint8_t addr,
msleep(led_rw_delay);
}
if (retry >= I2C_WRITE_RETRY_TIMES) {
- dev_err(&client->dev, "[LED] i2c_write_block retry over %d times\n",
+ E("i2c_write_block retry over %d times\n",
I2C_WRITE_RETRY_TIMES);
mutex_unlock(&cdata->led_i2c_rw_mutex);
return -EIO;
@@ -172,13 +174,13 @@ static void lp5521_led_enable(struct i2c_client *client)
uint8_t data;
struct led_i2c_platform_data *pdata;
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
pdata = client->dev.platform_data;
/* === led pin enable === */
ret = gpio_direction_output(pdata->ena_gpio, 1);
if (ret < 0) {
- pr_err("[LED] %s: gpio_direction_output high failed %d\n", __func__, ret);
+ E("%s: gpio_direction_output high failed %d\n", __func__, ret);
gpio_free(pdata->ena_gpio);
}
mutex_lock(&led_mutex);
@@ -202,8 +204,6 @@ static void lp5521_led_enable(struct i2c_client *client)
data = 0x03;
ret = i2c_write_block(client, 0x01, &data, 1);
mutex_unlock(&led_mutex);
-
- I(" %s ---\n" , __func__);
}
static void lp5521_green_on(struct i2c_client *client)
@@ -212,7 +212,7 @@ static void lp5521_green_on(struct i2c_client *client)
int ret;
struct led_i2c_platform_data *pdata;
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
pdata = client->dev.platform_data;
if( current_mode == 0 && backlight_mode == 0 )
lp5521_led_enable(client);
@@ -236,7 +236,6 @@ static void lp5521_green_on(struct i2c_client *client)
ret = i2c_write_block(client, 0x00, &data, 1);
udelay(500);
mutex_unlock(&led_mutex);
- I(" %s ---\n" , __func__);
}
static void lp5521_green_blink(struct i2c_client *client)
@@ -245,7 +244,7 @@ static void lp5521_green_blink(struct i2c_client *client)
int ret;
struct led_i2c_platform_data *pdata;
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
pdata = client->dev.platform_data;
if( current_mode == 0 && backlight_mode == 0 )
lp5521_led_enable(client);
@@ -308,7 +307,6 @@ static void lp5521_green_blink(struct i2c_client *client)
ret = i2c_write_block(client, 0x00, &data, 1);
udelay(500);
mutex_unlock(&led_mutex);
- I(" %s ---\n" , __func__);
}
static void lp5521_amber_on(struct i2c_client *client)
@@ -317,7 +315,7 @@ static void lp5521_amber_on(struct i2c_client *client)
int ret;
struct led_i2c_platform_data *pdata;
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
pdata = client->dev.platform_data;
if( current_mode == 0 && backlight_mode == 0 )
lp5521_led_enable(client);
@@ -341,7 +339,6 @@ static void lp5521_amber_on(struct i2c_client *client)
ret = i2c_write_block(client, 0x00, &data, 1);
udelay(500);
mutex_unlock(&led_mutex);
- I(" %s ---\n" , __func__);
}
static void lp5521_amber_blink(struct i2c_client *client)
@@ -350,7 +347,7 @@ static void lp5521_amber_blink(struct i2c_client *client)
int ret;
struct led_i2c_platform_data *pdata;
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
pdata = client->dev.platform_data;
if( current_mode == 0 && backlight_mode == 0 )
lp5521_led_enable(client);
@@ -406,7 +403,6 @@ static void lp5521_amber_blink(struct i2c_client *client)
ret = i2c_write_block(client, 0x00, &data, 1);
udelay(550);
mutex_unlock(&led_mutex);
- I(" %s ---\n" , __func__);
}
static void lp5521_amber_low_blink(struct i2c_client *client)
@@ -415,7 +411,7 @@ static void lp5521_amber_low_blink(struct i2c_client *client)
int ret;
struct led_i2c_platform_data *pdata;
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
pdata = client->dev.platform_data;
if( current_mode == 0 && backlight_mode == 0 )
lp5521_led_enable(client);
@@ -470,7 +466,6 @@ static void lp5521_amber_low_blink(struct i2c_client *client)
ret = i2c_write_block(client, 0x00, &data, 1);
udelay(550);
mutex_unlock(&led_mutex);
- I(" %s ---\n" , __func__);
}
static void lp5521_dual_color_blink(struct i2c_client *client)
@@ -479,7 +474,7 @@ static void lp5521_dual_color_blink(struct i2c_client *client)
int ret;
struct led_i2c_platform_data *pdata;
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
pdata = client->dev.platform_data;
if( current_mode == 0 && backlight_mode == 0 )
lp5521_led_enable(client);
@@ -574,22 +569,19 @@ static void lp5521_dual_color_blink(struct i2c_client *client)
ret = i2c_write_block(client, 0x00, &data, 1);
udelay(550);
mutex_unlock(&led_mutex);
- I(" %s ---\n" , __func__);
}
static inline int button_brightness_adjust(struct i2c_client *client) {
uint8_t data = 0x00;
int ret = 0, brightness;
- I("%s, current_mode: %d, backlight_mode: %d", __func__, current_mode, backlight_mode);
+ D("%s, current_mode: %d, backlight_mode: %d\n", __func__, current_mode, backlight_mode);
// if buttons are not on do nothing
if (current_mode == 0 && backlight_mode == 0)
return ret;
brightness = button_brightness;
- backlight_mode = 1;
mutex_lock(&led_mutex);
- I("locked %s", __func__);
data = (u8)brightness;
ret = i2c_write_block(client, 0x04, &data, 1);
@@ -601,14 +593,13 @@ static inline int button_brightness_adjust(struct i2c_client *client) {
static inline int button_fade_in(struct i2c_client *client) {
uint8_t data = 0x00;
int i, ret, brightness;
- I("%s, current_mode: %d, backlight_mode: %d", __func__, current_mode, backlight_mode);
+ D("%s, current_mode: %d, backlight_mode: %d\n", __func__, current_mode, backlight_mode);
if (current_mode == 0 && backlight_mode == 0)
lp5521_led_enable(client);
brightness = button_brightness/5;
backlight_mode = 1;
mutex_lock(&led_mutex);
- I("locked %s", __func__);
/* === set blue pwm to 255 === */
for (i=1;i<=5;i++) {
@@ -627,11 +618,11 @@ static inline int button_fade_out(struct i2c_client *client) {
int i, ret, brightness;
struct led_i2c_platform_data *pdata;
+ D("%s, current_mode: %d, backlight_mode: %d\n", __func__, current_mode, backlight_mode);
pdata = client->dev.platform_data;
brightness = button_brightness/5;
backlight_mode = 0;
mutex_lock(&led_mutex);
- I("locked %s\n", __func__);
/* === set blue pwm to 0 === */
for (i=4;i>=0;i--) {
@@ -649,14 +640,14 @@ static inline int button_fade_out(struct i2c_client *client) {
ret = i2c_write_block(client, 0x0d, &data, 1);
udelay(550);
gpio_direction_output(pdata->ena_gpio, 0);
- I(" no LED command now in suspend, reset chip & gpio, no ack in i2c 0x32 is correct in LED chip lp5521.\n");
+ D("no LED command now in suspend, reset chip & gpio, no ack in i2c 0x32 is correct in LED chip lp5521.\n");
} else {
/* === disable CHIP_EN === */
data = 0x00;
ret = i2c_write_block(client, 0x00, &data, 1);
udelay(550);
gpio_direction_output(pdata->ena_gpio, 0);
- I(" no LED command now, disable chip & gpio.\n");
+ D("no LED command now, disable chip & gpio.\n");
}
}
mutex_unlock(&led_mutex);
@@ -682,26 +673,22 @@ static void button_fade_work_func(struct work_struct *work)
if (ret < 0)
I(" %s: mode=%d, ret=%d\n", __func__, fade_work->fade_mode, ret);
-
- D(" %s\n", __func__);
}
static void lp5521_backlight_on(struct i2c_client *client)
{
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
button_fade_work.fade_mode = 1;
button_fade_work.client = client;
queue_work(led_powerkey_work_queue, (struct work_struct *) &button_fade_work);
- I(" %s ---\n" , __func__);
}
static void lp5521_backlight_off(struct i2c_client *client)
{
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
button_fade_work.fade_mode = 0;
button_fade_work.client = client;
queue_work(led_powerkey_work_queue, (struct work_struct *) &button_fade_work);
- I(" %s ---\n" , __func__);
}
static void lp5521_dual_off(struct i2c_client *client)
@@ -710,7 +697,7 @@ static void lp5521_dual_off(struct i2c_client *client)
int ret;
struct led_i2c_platform_data *pdata;
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
pdata = client->dev.platform_data;
mutex_lock(&led_mutex);
/* === set green pwm to 0 === */
@@ -738,29 +725,27 @@ static void lp5521_dual_off(struct i2c_client *client)
ret = i2c_write_block(client, 0x0d, &data, 1);
udelay(550);
gpio_direction_output(pdata->ena_gpio, 0);
- I(" no LED command now in suspend, reset chip & gpio, no ack in i2c 0x32 is correct in LED chip lp5521.\n");
+ D("no LED command now in suspend, reset chip & gpio, no ack in i2c 0x32 is correct in LED chip lp5521.\n");
} else {
/* === disable CHIP_EN === */
data = 0x00;
ret = i2c_write_block(client, 0x00, &data, 1);
udelay(550);
gpio_direction_output(pdata->ena_gpio, 0);
- I(" no LED command now in idle, disable chip & gpio.\n");
+ D("no LED command now in idle, disable chip & gpio.\n");
}
}
mutex_unlock(&led_mutex);
- I(" %s ---\n" , __func__);
}
void lp5521_led_current_set_for_key(int brightness_key)
{
- I(" %s +++\n" , __func__);
+ D("%s\n" , __func__);
if (brightness_key)
backlight_mode = brightness_key + 1;
else
backlight_mode = 0;
queue_work(led_powerkey_work_queue, &led_powerkey_work);
- I(" %s ---\n" , __func__);
}
void led_behavior(struct i2c_client *client, int val)
@@ -871,12 +856,11 @@ static void led_powerkey_work_func(struct work_struct *work)
fade_in_steps = fade_out_steps = 3;
- I(" %s +++\n" , __func__);
+ D("%s, current_mode: %d, backlight_mode: %d\n", __func__, current_mode, backlight_mode);
pdata = client->dev.platform_data;
- if (current_mode == 0 && backlight_mode == 0)
+ if(current_mode == 0 )
lp5521_led_enable(client);
mutex_lock(&led_mutex);
- I("%s, backlight_mode: %d\n", __func__, backlight_mode);
if (backlight_mode >= 2) {
if(current_mode == 1) {
/* === load program with green direct and blue load program === */
@@ -992,7 +976,7 @@ static void led_powerkey_work_func(struct work_struct *work)
D("Last address was: 0x%x\n", address-1);
if(address > 0x70) {
- printk(KERN_WARNING "[LED] Too many instructions for backlight programm!");
+ E("Too many instructions for backlight programm!");
}
}
if(current_mode == 1) {
@@ -1111,13 +1095,11 @@ static void led_powerkey_work_func(struct work_struct *work)
ret = i2c_write_block(client, 0x00, &data, 1);
udelay(550);
gpio_direction_output(pdata->ena_gpio, 0);
- I(" no LED command now, disable chip & gpio.\n");
+ D("no LED command now, disable chip & gpio.\n");
}
}
mutex_unlock(&led_mutex);
- I(" %s ---\n" , __func__);
-
}
static void led_work_func(struct work_struct *work)
@@ -1125,23 +1107,22 @@ static void led_work_func(struct work_struct *work)
struct i2c_client *client = private_lp5521_client;
struct lp5521_led *ldata;
- I(" %s +++\n" , __func__);
+ D("%s\n", __func__);
ldata = container_of(work, struct lp5521_led, led_work);
if ( offtimer_mode == current_mode )
lp5521_dual_off(client);
offtimer_mode = 0;
- I(" %s ---\n" , __func__);
}
static void led_alarm_handler(struct alarm *alarm)
{
struct lp5521_led *ldata;
- I(" %s +++\n" , __func__);
+ D("%s\n", __func__);
ldata = container_of(alarm, struct lp5521_led, led_alarm);
queue_work(g_led_work_queue, &ldata->led_work);
- I(" %s ---\n" , __func__);
}
+
static ssize_t lp5521_led_off_timer_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -1158,14 +1139,18 @@ static ssize_t lp5521_led_off_timer_store(struct device *dev,
uint16_t off_timer;
ktime_t interval;
ktime_t next_alarm;
+ int ret;
min = -1;
sec = -1;
led_cdev = (struct led_classdev *)dev_get_drvdata(dev);
ldata = container_of(led_cdev, struct lp5521_led, cdev);
- sscanf(buf, "%d %d", &min, &sec);
- I(" %s , min = %d, sec = %d, current_mode=%d dev_name=%s\n" , __func__, min, sec, current_mode, ldata->cdev.name);
+ ret = sscanf(buf, "%d %d", &min, &sec);
+ if (ret!=2)
+ return -EINVAL;
+
+ D("%s , min = %d, sec = %d, current_mode=%d dev_name=%s\n" , __func__, min, sec, current_mode, ldata->cdev.name);
if (min < 0 || min > 255)
return -EINVAL;
if (sec < 0 || sec > 255)
@@ -1190,7 +1175,7 @@ static ssize_t lp5521_led_off_timer_store(struct device *dev,
alarm_cancel(&ldata->led_alarm);
cancel_work_sync(&ldata->led_work);
offtimer_mode = current_mode;
- I(" %s , off_timer = %d\n" , __func__, off_timer);
+ D("%s , off_timer = %d\n" , __func__, off_timer);
if (off_timer) {
interval = ktime_set(off_timer, 0);
next_alarm = ktime_add(alarm_get_elapsed_realtime(), interval);
@@ -1216,11 +1201,14 @@ static ssize_t lp5521_led_blink_store(struct device *dev,
struct i2c_client *client = private_lp5521_client;
struct led_classdev *led_cdev;
struct lp5521_led *ldata;
- int val;
+ int val, ret;
val = -1;
- sscanf(buf, "%d", &val);
- I(" %s , val = %d\n" , __func__, val);
+ ret = sscanf(buf, "%d", &val);
+ if (ret!=1)
+ return -EINVAL;
+
+ D("%s , val = %d\n" , __func__, val);
if (val < 0 )
val = 0;
else if (val > 255)
@@ -1278,14 +1266,18 @@ static ssize_t lp5521_led_slow_blink_store(struct device *dev,
{
struct led_classdev *led_cdev;
struct lp5521_led *ldata;
- int val;
+ int val, ret;
led_cdev = (struct led_classdev *)dev_get_drvdata(dev);
ldata = container_of(led_cdev, struct lp5521_led, cdev);
val = 0;
- sscanf(buf, "%d", &val);
- I(" %s , val = %d\n" , __func__, val);
+ ret = sscanf(buf, "%d", &val);
+ if (ret!=1)
+ return -EINVAL;
+
+ D("%s , val = %d\n" , __func__, val);
+
if (val < 0 )
val = 0;
else if (val > 255)
@@ -1294,7 +1286,11 @@ static ssize_t lp5521_led_slow_blink_store(struct device *dev,
if(val) {
if(!strcmp(ldata->cdev.name, "button-backlight")) {
if(backlight_mode != 3 || val != slow_blink_brightness) {
- slow_blink_brightness = val;
+ // limit it to button brightness value
+ if(slow_blink_brightness_limit)
+ slow_blink_brightness = button_brightness;
+ else
+ slow_blink_brightness = val;
lp5521_led_current_set_for_key(2);
}
}
@@ -1329,11 +1325,13 @@ static ssize_t lp5521_led_currents_store(struct device *dev,
uint8_t data = 0x00;
int val, ret;
- sscanf(buf, "%d", &val);
- I(" %s , val = %d\n" , __func__, val);
- if (val < 0 || val > 3)
+ ret = sscanf(buf, "%d", &val);
+
+ if (ret!=1 || val < 0 || val > 3)
return -EINVAL;
-
+
+ D("%s , val = %d\n" , __func__, val);
+
current_currents = val;
led_cdev = (struct led_classdev *)dev_get_drvdata(dev);
ldata = container_of(led_cdev, struct lp5521_led, cdev);
@@ -1382,10 +1380,12 @@ static ssize_t lp5521_led_pwm_coefficient_store(struct device *dev,
uint8_t data = 0x00;
int val, ret;
- sscanf(buf, "%d", &val);
- I(" %s , val = %d\n" , __func__, val);
- if (val < 0 || val > 100)
+ ret = sscanf(buf, "%d", &val);
+ if (ret!=1 || val < 0 || val > 100)
return -EINVAL;
+
+ D("%s , val = %d\n" , __func__, val);
+
current_pwm_coefficient = val;
led_cdev = (struct led_classdev *)dev_get_drvdata(dev);
ldata = container_of(led_cdev, struct lp5521_led, cdev);
@@ -1430,10 +1430,12 @@ static ssize_t lp5521_led_lut_coefficient_store(struct device *dev,
uint8_t data = 0x00;
int val, ret;
- sscanf(buf, "%d", &val);
- I(" %s , val = %d\n" , __func__, val);
- if (val < 0 || val > 100)
+ ret = sscanf(buf, "%d", &val);
+ if (ret!=1 || val < 0 || val > 100)
return -EINVAL;
+
+ D("%s , val = %d\n" , __func__, val);
+
current_lut_coefficient = val;
led_cdev = (struct led_classdev *)dev_get_drvdata(dev);
ldata = container_of(led_cdev, struct lp5521_led, cdev);
@@ -1469,12 +1471,22 @@ static ssize_t lp5521_led_button_brightness_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ int ret = 0;
+ unsigned int temp;
struct i2c_client *client = private_lp5521_client;
- sscanf(buf, "%d", &button_brightness);
- if (button_brightness < 0) button_brightness=0;
- if (button_brightness > 255) button_brightness=255;
+ ret = sscanf(buf, "%d", &temp);
+ if (ret!=1 || temp < 0 || temp > 255)
+ return -EINVAL;
+ D("%s , val = %d\n" , __func__, temp);
+
+ // 0 will reset it to the boards default value
+ if (temp == 0)
+ button_brightness = button_brightness_board;
+ else
+ button_brightness = temp;
+
button_brightness_adjust(client);
return count;
@@ -1484,25 +1496,52 @@ static DEVICE_ATTR(button_brightness, 0644, lp5521_led_button_brightness_show,
lp5521_led_button_brightness_store);
+static ssize_t lp5521_slow_blink_brightness_limit_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", slow_blink_brightness_limit);
+}
+
+static ssize_t lp5521_slow_blink_brightness_limit_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret = 0;
+ unsigned int temp;
+
+ ret = sscanf(buf, "%d", &temp);
+ if (ret!=1 || temp < 0 || temp > 1)
+ return -EINVAL;
+
+ D("%s , val = %d\n" , __func__, temp);
+
+ slow_blink_brightness_limit = temp;
+
+ return count;
+}
+
+static DEVICE_ATTR(slow_blink_brightness_limit, 0644, lp5521_slow_blink_brightness_limit_show,
+ lp5521_slow_blink_brightness_limit_store);
+
static void lp5521_led_early_suspend(struct early_suspend *handler)
{
struct i2c_client *client = private_lp5521_client;
- printk("[LED][SUSPEND] lp5521_led_early_suspend +++\n");
+ I("%s start\n", __func__);
suspend_mode = 1;
if( backlight_mode == 1 )
lp5521_backlight_off(client);
else if ( backlight_mode == 2 )
lp5521_led_current_set_for_key(0);
- printk("[LED][SUSPEND] lp5521_led_early_suspend ---\n");
+ I("%s end\n", __func__);
}
static void lp5521_led_late_resume(struct early_suspend *handler)
{
- printk("[LED][RESUME] lp5521_led_late_resume +++\n");
+ I("%s start\n", __func__);
suspend_mode = 0;
- printk("[LED][RESUME] lp5521_led_late_resume ---\n");
+ I("%s end\n", __func__);
}
static int lp5521_led_probe(struct i2c_client *client
@@ -1513,13 +1552,13 @@ static int lp5521_led_probe(struct i2c_client *client
struct led_i2c_platform_data *pdata;
int ret, i;
- printk("[LED][PROBE] led driver probe +++\n");
+ I("%s probe start\n", __func__);
/* === init platform and client data === */
cdata = kzalloc(sizeof(struct lp5521_chip), GFP_KERNEL);
if (!cdata) {
ret = -ENOMEM;
- dev_err(&client->dev, "[LED][PROBE_ERR] failed on allocat cdata\n");
+ E("failed on allocat cdata\n");
goto err_cdata;
}
i2c_set_clientdata(client, cdata);
@@ -1528,7 +1567,7 @@ static int lp5521_led_probe(struct i2c_client *client
pdata = client->dev.platform_data;
if (!pdata) {
ret = -EBUSY;
- dev_err(&client->dev, "[LED][PROBE_ERR] failed on get pdata\n");
+ E("failed on get pdata\n");
goto err_exit;
}
led_rw_delay = 5;
@@ -1536,17 +1575,18 @@ static int lp5521_led_probe(struct i2c_client *client
/* === led enable pin === */
ret = gpio_request(pdata->ena_gpio, "led_enable");
if (ret < 0) {
- pr_err("[LED] %s: gpio_request failed %d\n", __func__, ret);
+ E("%s: gpio_request failed %d\n", __func__, ret);
return ret;
}
ret = gpio_direction_output(pdata->ena_gpio, lp5521_led_tag_status ? 1 : 0);
if (ret < 0) {
- pr_err("[LED] %s: gpio_direction_output failed %d\n", __func__, ret);
+ E("%s: gpio_direction_output failed %d\n", __func__, ret);
gpio_free(pdata->ena_gpio);
return ret;
}
tegra_gpio_enable(pdata->ena_gpio);
button_brightness = pdata->led_config[2].led_lux * 255 / 100;
+ button_brightness_board = button_brightness;
slow_blink_brightness = 0;
private_lp5521_client = client;
@@ -1563,44 +1603,49 @@ static int lp5521_led_probe(struct i2c_client *client
cdata->leds[i].cdev.brightness_set = lp5521_led_birghtness_set;
ret = led_classdev_register(dev, &cdata->leds[i].cdev);
if (ret < 0) {
- dev_err(dev, "couldn't register led[%d]\n", i);
+ E("couldn't register led[%d]\n", i);
return ret;
}
ret = device_create_file(cdata->leds[i].cdev.dev, &dev_attr_blink);
if (ret < 0) {
- pr_err("%s: failed on create attr blink [%d]\n", __func__, i);
+ E("%s: failed on create attr blink [%d]\n", __func__, i);
goto err_register_attr_blink;
}
ret = device_create_file(cdata->leds[i].cdev.dev, &dev_attr_slow_blink);
if (ret < 0) {
- pr_err("%s: failed on create attr slow_blink [%d]\n", __func__, i);
+ E("%s: failed on create attr slow_blink [%d]\n", __func__, i);
goto err_register_attr_slow_blink;
}
ret = device_create_file(cdata->leds[i].cdev.dev, &dev_attr_off_timer);
if (ret < 0) {
- pr_err("%s: failed on create attr off_timer [%d]\n", __func__, i);
+ E("%s: failed on create attr off_timer [%d]\n", __func__, i);
goto err_register_attr_off_timer;
}
ret = device_create_file(cdata->leds[i].cdev.dev, &dev_attr_currents);
if (ret < 0) {
- pr_err("%s: failed on create attr currents [%d]\n", __func__, i);
+ E("%s: failed on create attr currents [%d]\n", __func__, i);
goto err_register_attr_currents;
}
ret = device_create_file(cdata->leds[i].cdev.dev, &dev_attr_pwm_coefficient);
if (ret < 0) {
- pr_err("%s: failed on create attr pwm_coefficient [%d]\n", __func__, i);
+ E("%s: failed on create attr pwm_coefficient [%d]\n", __func__, i);
goto err_register_attr_pwm_coefficient;
}
ret = device_create_file(cdata->leds[i].cdev.dev, &dev_attr_lut_coefficient);
if (ret < 0) {
- pr_err("%s: failed on create attr lut_coefficient [%d]\n", __func__, i);
+ E("%s: failed on create attr lut_coefficient [%d]\n", __func__, i);
goto err_register_attr_lut_coefficient;
}
ret = device_create_file(cdata->leds[i].cdev.dev, &dev_attr_button_brightness);
if (ret < 0) {
- pr_err("%s: failed on create attr button_brightness [%d]\n", __func__, i);
+ E("%s: failed on create attr button_brightness [%d]\n", __func__, i);
goto err_register_attr_button_brightness;
}
+ ret = device_create_file(cdata->leds[i].cdev.dev, &dev_attr_slow_blink_brightness_limit);
+ if (ret < 0) {
+ E("%s: failed on create attr slow_blink_brightness_limit [%d]\n", __func__, i);
+ goto err_register_attr_slow_blink_brightness_limit;
+ }
INIT_WORK(&cdata->leds[i].led_work, led_work_func);
alarm_init(&cdata->leds[i].led_alarm,
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP,
@@ -1612,13 +1657,13 @@ static int lp5521_led_probe(struct i2c_client *client
/* === create device node === */
ret = device_create_file(&client->dev, &dev_attr_behavior);
if (ret) {
- dev_err(&client->dev, "device_create_file failed\n");
+ E( "device_create_file failed\n");
goto err_fun_init;
}
regulator = regulator_get(NULL, "v_led_3v3");
if( (regulator==NULL) | (IS_ERR(regulator)))
- pr_err("Fail to get regulator: v_led_3v3");
+ E("Fail to get regulator: v_led_3v3");
regulator_enable(regulator);
mutex_init(&cdata->led_i2c_rw_mutex);
@@ -1634,12 +1679,17 @@ static int lp5521_led_probe(struct i2c_client *client
led_behavior(client, lp5521_led_tag_status);
}
- printk("[LED][PROBE] led driver probe ---\n");
+ I("%s success!\n", __func__);
return 0;
err_fun_init:
device_remove_file(&client->dev, &dev_attr_behavior);
kfree(cdata);
+
+err_register_attr_slow_blink_brightness_limit:
+ for (i = 0; i < pdata->num_leds; i++) {
+ device_remove_file(cdata->leds[i].cdev.dev,&dev_attr_slow_blink_brightness_limit);
+ }
err_register_attr_button_brightness:
for (i = 0; i < pdata->num_leds; i++) {
device_remove_file(cdata->leds[i].cdev.dev,&dev_attr_button_brightness);
@@ -1701,6 +1751,7 @@ static int __devexit lp5521_led_remove(struct i2c_client *client)
device_remove_file(cdata->leds[i].cdev.dev,&dev_attr_pwm_coefficient);
device_remove_file(cdata->leds[i].cdev.dev,&dev_attr_lut_coefficient);
device_remove_file(cdata->leds[i].cdev.dev,&dev_attr_button_brightness);
+ device_remove_file(cdata->leds[i].cdev.dev,&dev_attr_slow_blink_brightness_limit);
led_classdev_unregister(&cdata->leds[i].cdev);
}
destroy_workqueue(g_led_work_queue);
View
106 drivers/misc/nct1008.c
@@ -32,6 +32,17 @@
#include <linux/delay.h>
#include <linux/regulator/consumer.h>
+#define TMS_DEBUG 0
+
+#if TMS_DEBUG
+ #define D(x...) pr_info("[TMS]" x)
+#else
+ #define D(x...)
+#endif
+
+#define I(x...) pr_info("[TMS]" x)
+#define E(x...) pr_err("[TMS]" x)
+
/* Register Addresses */
#define LOCAL_TEMP_RD 0x00
#define EXT_TEMP_RD_HI 0x01
@@ -145,7 +156,7 @@ static int nct1008_get_temp(struct device *dev, long *etemp, long *itemp)
return 0;
error:
- dev_err(&client->dev, "\n error in file=: %s %s() line=%d: "
+ E("error in file=: %s %s() line=%d: "
"error=%d ", __FILE__, __func__, __LINE__, value);
return value;
}
@@ -208,7 +219,7 @@ static ssize_t nct1008_show_temp_overheat(struct device *dev,
return snprintf(buf, MAX_STR_PRINT, "%d %d\n", temp, temp2);
error:
- dev_err(dev, "%s: failed to read temperature-overheat "
+ E("%s: failed to read temperature-overheat "
"\n", __func__);
return snprintf(buf, MAX_STR_PRINT, " Rd overheat Error\n");
}
@@ -228,12 +239,12 @@ static ssize_t nct1008_set_temp_overheat(struct device *dev,
unsigned int ret;
if (strict_strtol(buf, 0, &num)) {
- dev_err(dev, "\n file: %s, line=%d return %s() ", __FILE__,
+ E("file: %s, line=%d return %s() ", __FILE__,
__LINE__, __func__);
return -EINVAL;
}
if (((int)num < NCT1008_MIN_TEMP) || ((int)num >= NCT1008_MAX_TEMP)) {
- dev_err(dev, "\n file: %s, line=%d return %s() ", __FILE__,
+ E("file: %s, line=%d return %s() ", __FILE__,
__LINE__, __func__);
return -EINVAL;
}
@@ -247,9 +258,9 @@ static ssize_t nct1008_set_temp_overheat(struct device *dev,
if (currTemp >= (int)num) {
ret = nct1008_show_temp(dev, attr, bufTemp);
ret = nct1008_show_temp_overheat(dev, attr, bufOverheat);
- dev_err(dev, "\nCurrent temp: %s ", bufTemp);
- dev_err(dev, "\nOld overheat limit: %s ", bufOverheat);
- dev_err(dev, "\nReset from overheat: curr temp=%ld, "
+ E("Current temp: %s ", bufTemp);
+ E("Old overheat limit: %s ", bufOverheat);
+ E("Reset from overheat: curr temp=%ld, "
"new overheat temp=%d\n\n", currTemp, (int)num);
}
@@ -266,7 +277,7 @@ static ssize_t nct1008_set_temp_overheat(struct device *dev,
goto error;
return count;
error:
- dev_err(dev, " %s: failed to set temperature-overheat\n", __func__);
+ E("%s: failed to set temperature-overheat\n", __func__);
return err;
}
@@ -292,7 +303,7 @@ static ssize_t nct1008_show_temp_alert(struct device *dev,
return snprintf(buf, MAX_STR_PRINT, "lo:%d hi:%d\n", temp_lo, temp_hi);
error:
- dev_err(dev, "%s: failed to read temperature-alert\n", __func__);
+ E("%s: failed to read temperature-alert\n", __func__);
return snprintf(buf, MAX_STR_PRINT, " Rd alert Error\n");
}
@@ -307,12 +318,12 @@ static ssize_t nct1008_set_temp_alert(struct device *dev,
struct nct1008_platform_data *pdata = client->dev.platform_data;
if (strict_strtol(buf, 0, &num)) {
- dev_err(dev, "\n file: %s, line=%d return %s() ", __FILE__,
+ E("file: %s, line=%d return %s() ", __FILE__,
__LINE__, __func__);
return -EINVAL;
}
if (((int)num < NCT1008_MIN_TEMP) || ((int)num >= NCT1008_MAX_TEMP)) {
- dev_err(dev, "\n file: %s, line=%d return %s() ", __FILE__,
+ E("file: %s, line=%d return %s() ", __FILE__,
__LINE__, __func__);
return -EINVAL;
}
@@ -332,7 +343,7 @@ static ssize_t nct1008_set_temp_alert(struct device *dev,
return count;
error:
- dev_err(dev, "%s: failed to set temperature-alert "
+ E("%s: failed to set temperature-alert "
"\n", __func__);
return err;
}
@@ -354,14 +365,14 @@ static ssize_t nct1008_show_ext_temp(struct device *dev,
* ADC does not write to it) until it is read */
data_lo = i2c_smbus_read_byte_data(client, EXT_TEMP_RD_LO);
if (data_lo < 0) {
- dev_err(&client->dev, "%s: failed to read "
+ E("%s: failed to read "
"ext_temperature, i2c error=%d\n", __func__, data_lo);
goto error;
}
data = i2c_smbus_read_byte_data(client, EXT_TEMP_RD_HI);
if (data < 0) {
- dev_err(&client->dev, "%s: failed to read "
+ E("%s: failed to read "
"ext_temperature, i2c error=%d\n", __func__, data);
goto error;
}
@@ -462,13 +473,13 @@ static int __init nct1008_debuginit(struct nct1008_data *nct)
d = debugfs_create_file("nct1008", S_IRUGO, NULL,
(void *)nct, &debug_fops);
if ((!d) || IS_ERR(d)) {
- dev_err(&nct->client->dev, "Error: %s debugfs_create_file"
+ E("Error: %s debugfs_create_file"
" returned an error\n", __func__);
err = -ENOENT;
goto end;
}
if (d == ERR_PTR(-ENODEV)) {
- dev_err(&nct->client->dev, "Error: %s debugfs not supported "
+ E("Error: %s debugfs not supported "
"error=-ENODEV\n", __func__);
err = -ENODEV;
} else {
@@ -492,7 +503,7 @@ static int nct1008_enable(struct i2c_client *client)
err = i2c_smbus_write_byte_data(client, CONFIG_WR,
data->config & ~STANDBY_BIT);
if (err < 0)
- dev_err(&client->dev, "%s, line=%d, i2c write error=%d\n",
+ E("%s, line=%d, i2c write error=%d\n",
__func__, __LINE__, err);
return err;
}
@@ -505,7 +516,7 @@ static int nct1008_disable(struct i2c_client *client)
err = i2c_smbus_write_byte_data(client, CONFIG_WR,
data->config | STANDBY_BIT);
if (err < 0)
- dev_err(&client->dev, "%s, line=%d, i2c write error=%d\n",
+ E("%s, line=%d, i2c write error=%d\n",
__func__, __LINE__, err);
return err;
}
@@ -576,7 +587,7 @@ static void nct1008_polling_func(struct work_struct *work)
goto error;
temp_local = value_to_temperature(pdata->ext_range, value);
- printk(KERN_INFO "[TMS] cpu temp = %d.%d, local temp = %d\n", temp_ext_hi,
+ D("cpu temp = %d.%d, local temp = %d\n", temp_ext_hi,
temp_ext_lo * 25, temp_local);
if (temp_ext_hi >= 70)
@@ -621,11 +632,11 @@ static void nct1008_read_temp_func(struct work_struct *work)
if (intr_status < 0)
goto error;
- printk(KERN_INFO "[TMS] cpu temp = %d.%d, local temp = %d, status = %d\n",
+ D("cpu temp = %d.%d, local temp = %d, status = %d\n",
temp_ext_hi, temp_ext_lo * 25, temp_local, intr_status);
if (intr_status & (BIT(0) | BIT(1)))
- printk(KERN_INFO "[TMS] overheat, prepare to reboot...\n");
+ I("overheat, prepare to reboot...\n");
schedule_delayed_work(&data->read_temp_work, msecs_to_jiffies(1000));
@@ -663,11 +674,10 @@ static void nct1008_power_control(struct nct1008_data *data, bool is_enable)
data->nct_reg = regulator_get(NULL, data->plat_data.reg_name);
if (IS_ERR_OR_NULL(data->nct_reg)) {
if (PTR_ERR(data->nct_reg) == -ENODEV)
- dev_info(&data->client->dev,
- "no regulator found for vdd."
+ I("no regulator found for vdd."
" Assuming vdd is always powered");
else
- dev_warn(&data->client->dev, "Error [%ld] in "
+ E("Error [%ld] in "
"getting the regulator handle for"
" vdd\n", PTR_ERR(data->nct_reg));
data->nct_reg = NULL;
@@ -680,12 +690,12 @@ static void nct1008_power_control(struct nct1008_data *data, bool is_enable)
ret = regulator_disable(data->nct_reg);
if (ret < 0)
- dev_err(&data->client->dev, "Error in %s rail vdd_nct%s, "
+ E("Error in %s rail vdd_nct%s, "
"error %d\n", (is_enable) ? "enabling" : "disabling",
(data->chip == NCT72) ? "72" : "1008",
ret);
else
- dev_info(&data->client->dev, "success in %s rail vdd_nct%s\n",
+ I("success in %s rail vdd_nct%s\n",
(is_enable) ? "enabling" : "disabling",
(data->chip == NCT72) ? "72" : "1008");
}
@@ -700,13 +710,14 @@ static int __devinit nct1008_configure_sensor(struct nct1008_data* data)
int err;
int config;
+ I("%s\n", __func__);
if (!pdata || !pdata->supported_hwrev)
return -ENODEV;
/* Read config */
value = i2c_smbus_read_byte_data(data->client, CONFIG_RD);
if (value < 0)
- printk(KERN_INFO "[TMS] read config fail\n");
+ E("read config fail\n");
config = value & 4;
/* Place in Standby */
@@ -771,9 +782,8 @@ static int __devinit nct1008_configure_sensor(struct nct1008_data* data)
goto error;
}
temp = value_to_temperature(config, value);
- dev_dbg(&client->dev, "\n initial local temp = %d ", temp);
- printk(KERN_INFO "[TMS] local temp = %d\n", temp);
+ D("local temp = %d\n", temp);
value = i2c_smbus_read_byte_data(client, EXT_TEMP_RD_LO);
if (value < 0) {
@@ -789,14 +799,11 @@ static int __devinit nct1008_configure_sensor(struct nct1008_data* data)
temp = value_to_temperature(config, value);
if (temp2 > 0) {
- dev_dbg(&client->dev, "\n initial ext temp = %d.%d deg",
- temp, temp2 * 25);
- printk(KERN_INFO "[TMS] remote temp = %d.%d\n",
+ D("remote temp = %d.%d\n",
temp, temp2 * 25);
}
else {
- dev_dbg(&client->dev, "\n initial ext temp = %d.0 deg", temp);
- printk(KERN_INFO "[TMS] remote temp = %d.0\n", temp);
+ D("remote temp = %d.0\n", temp);
}
/* Remote channel offset */
@@ -819,13 +826,14 @@ static int __devinit nct1008_configure_sensor(struct nct1008_data* data)
/* register sysfs hooks */
err = sysfs_create_group(&client->dev.kobj, &nct1008_attr_group);
if (err < 0) {
- dev_err(&client->dev, "\n sysfs create err=%d ", err);
+ E("sysfs create err=%d ", err);
goto error;
}
+ I("%s success!\n", __func__);
return 0;
error:
- dev_err(&client->dev, "\n exit %s, err=%d ", __func__, err);
+ E("exit %s, err=%d ", __func__, err);
return err;
}
@@ -876,7 +884,7 @@ int nct1008_thermal_set_limits(struct nct1008_data *data,
if (data->current_lo_limit != lo_limit) {
value = temperature_to_value(extended_range, lo_limit);
- pr_debug("%s: set lo_limit %ld\n", __func__, lo_limit);
+ D("%s: set lo_limit %ld\n", __func__, lo_limit);
err = i2c_smbus_write_byte_data(data->client,
EXT_TEMP_LO_LIMIT_HI_BYTE_WR, value);
if (err)
@@ -887,7 +895,7 @@ int nct1008_thermal_set_limits(struct nct1008_data *data,
if (data->current_hi_limit != hi_limit) {
value = temperature_to_value(extended_range, hi_limit);
- pr_debug("%s: set hi_limit %ld\n", __func__, hi_limit);
+ D("%s: set hi_limit %ld\n", __func__, hi_limit);
err = i2c_smbus_write_byte_data(data->client,
EXT_TEMP_HI_LIMIT_HI_BYTE_WR, value);
if (err)
@@ -961,6 +969,8 @@ static int __devinit nct1008_probe(struct i2c_client *client,
if (!data)
return -ENOMEM;
+ I("%s: probe start: client->irq = %d\n", __func__, client->irq);
+
data->client = client;
data->chip = id->driver_data;
memcpy(&data->plat_data, client->dev.platform_data,
@@ -972,23 +982,22 @@ static int __devinit nct1008_probe(struct i2c_client *client,
* in nct1008_configure_sensor function */
err = nct1008_configure_sensor(data); /* sensor is in standby */
if (err < 0) {
- dev_err(&client->dev, "\n error file: %s : %s(), line=%d ",
+ E("error file: %s : %s(), line=%d ",
__FILE__, __func__, __LINE__);
goto error;
}
err = nct1008_configure_irq(data);
if (err < 0) {
- dev_err(&client->dev, "\n error file: %s : %s(), line=%d ",
+ E("error file: %s : %s(), line=%d ",
__FILE__, __func__, __LINE__);
goto error;
}
- dev_info(&client->dev, "%s: initialized\n", __func__);
/* extended range recommended step 5 is in nct1008_enable function */
err = nct1008_enable(client); /* sensor is running */
if (err < 0) {
- dev_err(&client->dev, "Error: %s, line=%d, error=%d\n",
+ E("Error: %s, line=%d, error=%d\n",
__func__, __LINE__, err);
goto error;
}
@@ -1007,10 +1016,11 @@ static int __devinit nct1008_probe(struct i2c_client *client,
schedule_delayed_work(&data->polling_work, msecs_to_jiffies(10000));
nct1008_ready = 1;
+ I("%s: probe success!\n", __func__);
return 0;
error:
- dev_err(&client->dev, "\n exit %s, err=%d ", __func__, err);
+ E("exit %s, err=%d ", __func__, err);
nct1008_power_control(data, false);
if (data->nct_reg)
regulator_put(data->nct_reg);
@@ -1022,14 +1032,12 @@ static int __devexit nct1008_remove(struct i2c_client *client)
{
struct nct1008_data *data = i2c_get_clientdata(client);
- printk(KERN_INFO "[TMS] nct1008_remove\n");
-
if (data->dent)
debugfs_remove(data->dent);
free_irq(data->client->irq, data);
- printk(KERN_INFO "[TMS] free irq(%d)\n", client->irq);
+ I("%s free irq(%d)\n", __func__, client->irq);
cancel_work_sync(&data->work);
sysfs_remove_group(&client->dev.kobj, &nct1008_attr_group);
@@ -1048,7 +1056,7 @@ static int nct1008_suspend(struct i2c_client *client, pm_message_t state)
int err;
struct nct1008_data *data = i2c_get_clientdata(client);
- printk(KERN_INFO "[TMS] disable irq(%d)\n", client->irq);
+ I("%s disable irq(%d)\n", __func__, client->irq);
polling = 0;
cancel_delayed_work(&data->polling_work);
@@ -1065,12 +1073,12 @@ static int nct1008_resume(struct i2c_client *client)
err = nct1008_enable(client);
if (err < 0) {
- dev_err(&client->dev, "Error: %s, error=%d\n",
+ E("Error: %s, error=%d\n",
__func__, err);
return err;
}
- printk(KERN_INFO "[TMS] enable irq(%d)\n", client->irq);
+ I("%s enable irq(%d)\n", __func__, client->irq);
enable_irq(client->irq);
View
112 drivers/power/tps80032_charger.c
@@ -13,9 +13,6 @@
*
*/
-#define PR_TAG "[BATT][chg]"
-#define pr_fmt(fmt) PR_TAG fmt
-
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -29,11 +26,22 @@
#include <linux/tps80032_charger.h>
#include <linux/delay.h>
+#define CHARGER_DEBUG 0
+
+#if CHARGER_DEBUG
+ #define D(x...) pr_info("[BATT][CHG]" x)
+#else
+ #define D(x...)
+#endif
+
+#define I(x...) pr_info("[BATT][CHG]" x)
+#define E(x...) pr_err("[BATT][CHG]" x)
+
/* used for debug if function called */
#define FUNC_CALL_CHECK 0
#if FUNC_CALL_CHECK
-#define CHECK_LOG() pr_info("%s\n", __func__)
+#define CHECK_LOG() D("[BATT][CHG] %s\n", __func__)
#else
#define CHECK_LOG() (void)0
#endif
@@ -118,7 +126,7 @@ static int tps80032_charger_regulation_voltage_set(int regh)
ret = tps80031_update(charger_data->parent_dev, SLAVE_ID2,
CHARGERUSB_VOREG, regh, 0x3F);
if (ret < 0) {
- pr_err("%s(): Failed in updating register 0x%02x\n",
+ E("%s(): Failed in updating register 0x%02x\n",
__func__, regh);
}
mutex_unlock(&charger_data->data_lock);
@@ -154,7 +162,7 @@ void tps80032_charger_dump_status(int cond)
ANTICOLLAPSE_CTRL1, &regh[9]);
tps80031_read(charger_data->parent_dev, SLAVE_ID2,
CHARGERUSB_CTRL1, &regh[10]);
- pr_info("Check %d: "
+ D("Check %d: "
"STS=0x%X, STAT1=0x%X, INT1=0x%X, "
"INT2=0x%X, CINL=0x%X, VO=0x%X, "
"VI=0x%X, VOL=0x%X, VIL=0x%X, "
@@ -171,7 +179,7 @@ EXPORT_SYMBOL_GPL(tps80032_charger_dump_status);
ret = tps80031_write(charger_data->parent_dev, SLAVE_ID2, \
(offset), (value)); \
if (ret < 0) { \
- pr_err("%s(): Failed in writing register 0x%02x\n", \
+ E("%s(): Failed in writing register 0x%02x\n", \
__func__, offset); \
goto tps80032_i2c_err; \
} \
@@ -181,7 +189,7 @@ EXPORT_SYMBOL_GPL(tps80032_charger_dump_status);
ret = tps80031_update(charger_data->parent_dev, SLAVE_ID2, \
(offset), (value), (mask)); \
if (ret < 0) { \
- pr_err("%s(): Failed in updating register 0x%02x\n", \
+ E("%s(): Failed in updating register 0x%02x\n", \
__func__, (offset)); \
goto tps80032_i2c_err; \
} \
@@ -191,7 +199,7 @@ EXPORT_SYMBOL_GPL(tps80032_charger_dump_status);
ret = tps80031_read(charger_data->parent_dev, SLAVE_ID2, \
(offset), (value)); \
if (ret < 0) { \
- pr_err("%s(): Failed in readinging register 0x%02x\n", \
+ E("%s(): Failed in readinging register 0x%02x\n", \
__func__, (offset)); \
goto tps80032_i2c_err; \
} \
@@ -205,13 +213,13 @@ int tps80032_charger_set_ctrl(u32 ctl)
CHECK_LOG();
if (tps80032_charger_initial < 0) {
- pr_info("tps80032 charger not ready, state = %d!!\n", tps80032_charger_initial);
+ D("tps80032 charger not ready, state = %d!!\n", tps80032_charger_initial);
return 0;
}
switch (ctl) {
case POWER_SUPPLY_DISABLE_CHARGE:
- pr_info("Switch charger OFF\n");
+ D("Switch charger OFF\n");
tps80032_charger_dump_status(0);
@@ -223,7 +231,7 @@ int tps80032_charger_set_ctrl(u32 ctl)
break;
case POWER_SUPPLY_ENABLE_SLOW_CHARGE:
- pr_info("Switch charger ON: SLOW\n");
+ D("Switch charger ON: SLOW\n");
tps80032_charger_dump_status(0);
@@ -245,7 +253,7 @@ int tps80032_charger_set_ctrl(u32 ctl)
break;
case POWER_SUPPLY_ENABLE_FAST_CHARGE:
- pr_info("Switch charger ON: FAST\n");
+ D("Switch charger ON: FAST\n");
tps80032_charger_dump_status(0);
@@ -270,7 +278,7 @@ int tps80032_charger_set_ctrl(u32 ctl)
break;
case POWER_SUPPLY_ENABLE_INTERNAL:
- pr_info("Switch charger BOOST\n");
+ D("Switch charger BOOST\n");
tps80032_charger_dump_status(0);
TPS80032_ID2_I2C_WRITE(CHARGERUSB_CTRL1, 0x40);
@@ -281,46 +289,46 @@ int tps80032_charger_set_ctrl(u32 ctl)
case POWER_SUPPLY_ENABLE_WIRELESS_CHARGE:
case POWER_SUPPLY_ENABLE_SLOW_HV_CHARGE:
case POWER_SUPPLY_ENABLE_FAST_HV_CHARGE:
- pr_err("charger control %d is not supportted now!!\n", ctl);
+ E("charger control %d is not supportted now!!\n", ctl);
ret = -EINVAL;
break;
case OVERTEMP_VREG:
regh = 0x19;
tps80032_charger_regulation_voltage_set(regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VOREG, &regh);
- pr_info("Switch charger OVERTEMP_VREG: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
+ D("Switch charger OVERTEMP_VREG: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
break;
case UNDERTEMP_VREG:
regh = 0x1E;
tps80032_charger_regulation_voltage_set(regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VOREG, &regh);
- pr_info("Switch charger UNDERTEMP_VREG: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
+ D("Switch charger UNDERTEMP_VREG: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
break;
case NORMALTEMP_VREG:
regh = 0x23;
tps80032_charger_regulation_voltage_set(regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VOREG, &regh);
- pr_info("Switch charger NORMALTEMP_VREG: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
+ D("Switch charger NORMALTEMP_VREG: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
break;
case NORMALTEMP_VREG_HV:
regh = 0x28;
tps80032_charger_regulation_voltage_set(regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VOREG, &regh);
- pr_info("Switch charger NORMALTEMP_VREG_HV: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
+ D("Switch charger NORMALTEMP_VREG_HV: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
break;
case NORMALTEMP_VREG_HV4340:
regh = 0x2A;
tps80032_charger_regulation_voltage_set(regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VOREG, &regh);
- pr_info("Switch charger NORMALTEMP_VREG_HV4340: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
+ D("Switch charger NORMALTEMP_VREG_HV4340: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
break;
case ENABLE_HIZ_CHG:
- pr_info("Switch charger HIZ\n");
+ D("Switch charger HIZ\n");
tps80032_charger_dump_status(0);
@@ -333,102 +341,102 @@ int tps80032_charger_set_ctrl(u32 ctl)
regh = 0x29;
tps80032_charger_regulation_voltage_set(regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VOREG, &regh);
- pr_info("Switch charger NORMALTEMP_VREG_HV4320: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
+ D("Switch charger NORMALTEMP_VREG_HV4320: regh 0x%X=%x\n", CHARGERUSB_VOREG, regh);
break;
case ALLTEMP_VSYS_DISABLE:
regh = 0x02;
TPS80032_ID2_I2C_WRITE(CHARGERUSB_VSYSREG, regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VSYSREG, &regh);
- pr_info("Switch charger ALLTEMP_VSYS_DISABLE: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
+ D("Switch charger ALLTEMP_VSYS_DISABLE: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
break;
case NORMALTEMP_VSYS_4400:
regh = 0x2D | 0x80;
TPS80032_ID2_I2C_WRITE(CHARGERUSB_VSYSREG, regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VSYSREG, &regh);
- pr_info("Switch charger NORMALTEMP_VSYS_4400: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
+ D("Switch charger NORMALTEMP_VSYS_4400: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
break;
case NORMALTEMP_VSYS_4440:
regh = 0x2F | 0x80;
TPS80032_ID2_I2C_WRITE(CHARGERUSB_VSYSREG, regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VSYSREG, &regh);
- pr_info("Switch charger NORMALTEMP_VSYS_4440: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
+ D("Switch charger NORMALTEMP_VSYS_4440: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
break;
case OVERTEMP_VSYS_4300:
regh = 0x28 | 0x80;
TPS80032_ID2_I2C_WRITE(CHARGERUSB_VSYSREG, regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VSYSREG, &regh);
- pr_info("Switch charger OVERTEMP_VSYS_4300: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
+ D("Switch charger OVERTEMP_VSYS_4300: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
break;
case OVERTEMP_VSYS_4340:
regh = 0x2A | 0x80;
TPS80032_ID2_I2C_WRITE(CHARGERUSB_VSYSREG, regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VSYSREG, &regh);
- pr_info("Switch charger OVERTEMP_VSYS_4340: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
+ D("Switch charger OVERTEMP_VSYS_4340: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
break;
case OVERTEMP_VSYS_4140:
regh = 0x20 | 0x80;
TPS80032_ID2_I2C_WRITE(CHARGERUSB_VSYSREG, regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VSYSREG, &regh);
- pr_info("Switch charger OVERTEMP_VSYS_4140: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
+ D("Switch charger OVERTEMP_VSYS_4140: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
break;
case UNDERTEMP_VSYS_4200:
regh = 0x23 | 0x80;
TPS80032_ID2_I2C_WRITE(CHARGERUSB_VSYSREG, regh);
TPS80032_ID2_I2C_READ(CHARGERUSB_VSYSREG, &regh);
- pr_info("Switch charger UNDERTEMP_VSYS_4200: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
+ D("Switch charger UNDERTEMP_VSYS_4200: regh 0x%X=%x\n", CHARGERUSB_VSYSREG, regh);
break;
case CHECK_INT1:
TPS80032_ID2_I2C_READ(CHARGERUSB_STATUS_INT1, &regh);
- pr_info("Switch charger CHECK_INT1: regh 0x%xh=%x\n", CHARGERUSB_STATUS_INT1, regh);
+ D("Switch charger CHECK_INT1: regh 0x%xh=%x\n", CHARGERUSB_STATUS_INT1, regh);
ret = (int)regh;
break;
case CHECK_INT2:
TPS80032_ID2_I2C_READ(CHARGERUSB_STATUS_INT2, &regh);
- pr_info("Switch charger CHECK_INT2: regh 0x%xh=%x\n", CHARGERUSB_STATUS_INT2, regh);
+ D("Switch charger CHECK_INT2: regh 0x%xh=%x\n", CHARGERUSB_STATUS_INT2, regh);
ret = (int)regh;
break;
case ENABLE_LIMITED_CHG:
tps80032_low_chg = 1;
TPS80032_ID2_I2C_WRITE(CHARGERUSB_VICHRG, 0x00);
TPS80032_ID2_I2C_READ(CHARGERUSB_VICHRG, &regh);
- pr_info("Switch charger ON (LIMITED): regh 0x%x=%x low_chg=%u\n", CHARGERUSB_VICHRG, regh, tps80032_low_chg);
+ D("Switch charger ON (LIMITED): regh 0x%x=%x low_chg=%u\n", CHARGERUSB_VICHRG, regh, tps80032_low_chg);
break;
case CLEAR_LIMITED_CHG:
tps80032_low_chg = 0;
TPS80032_ID2_I2C_WRITE(CHARGERUSB_VICHRG, 0x0A);
TPS80032_ID2_I2C_READ(CHARGERUSB_VICHRG, &regh);
- pr_info("Switch charger OFF (LIMITED): regh 0x%x=%x low_chg=%u\n", CHARGERUSB_VICHRG, regh, tps80032_low_chg);
+ D("Switch charger OFF (LIMITED): regh 0x%x=%x low_chg=%u\n", CHARGERUSB_VICHRG, regh, tps80032_low_chg);
break;
case SET_ICL_NORMAL:
tps80032_icl_750 = 0;
if (tps80032_charger_state == 2) {
TPS80032_ID2_I2C_UPDATE(CHARGERUSB_CINLIMIT, 0x2A, 0x3F);
TPS80032_ID2_I2C_READ(CHARGERUSB_CINLIMIT, &regh);
- pr_info("Switch charger SET_ICL_NORMAL: regh 0x%x=0x%x\n", CHARGERUSB_CINLIMIT, regh);
+ D("Switch charger SET_ICL_NORMAL: regh 0x%x=0x%x\n", CHARGERUSB_CINLIMIT, regh);
} else
- pr_info("Switch charger SET_ICL_NORMAL \n");
+ D("Switch charger SET_ICL_NORMAL \n");
break;
case SET_ICL750:
tps80032_icl_750 = 1;
if (tps80032_charger_state == 2) {
TPS80032_ID2_I2C_UPDATE(CHARGERUSB_CINLIMIT, 0x0E, 0x3F);
TPS80032_ID2_I2C_READ(CHARGERUSB_CINLIMIT, &regh);
- pr_info("Switch charger SET_ICL750: regh 0x%x=0x%x\n", CHARGERUSB_CINLIMIT, regh);
+ D("Switch charger SET_ICL750: regh 0x%x=0x%x\n", CHARGERUSB_CINLIMIT, regh);
} else
- pr_info("Switch charger SET_ICL750 \n");
+ D("Switch charger SET_ICL750 \n");
break;
case CHECK_CHG:
case CHECK_CONTROL:
default:
- pr_err("charger control %d is not supportted now!!\n", ctl);
+ E("charger control %d is not supportted now!!\n", ctl);
ret = -EINVAL;
}
@@ -504,10 +512,10 @@ static irqreturn_t int_chg_isr(int irq, void *dev_id)
ret = tps80031_read(charger_data->parent_dev, SLAVE_ID2,
CHARGERUSB_INT_STATUS, &chg_status);
if (ret < 0) {
- pr_err("%s(): Failed in reading register 0x%02x\n",
+ E("%s(): Failed in reading register 0x%02x\n",
__func__, CHARGERUSB_INT_STATUS);
} else {
- pr_info("%s():The status of CHARGERUSB_INT_STATUS is 0x%02x\n",
+ D("%s():The status of CHARGERUSB_INT_STATUS is 0x%02x\n",
__func__, chg_status);
chg_int_chg_work_func(NULL);
}
@@ -525,12 +533,12 @@ static void chg_linch_work_func(struct work_struct *work)
ret = tps80031_read(charger_data->parent_dev, SLAVE_ID2,
LINEAR_CHRG_STS, &linch_status);
if (ret < 0) {
- pr_err("%s(): Failed in reading register 0x%02x\n",
+ E("%s(): Failed in reading register 0x%02x\n",
__func__, LINEAR_CHRG_STS);
return;
}
- pr_info("%s():The status of LINEAR_CHRG_STS is 0x%02x\n",
+ D("%s():The status of LINEAR_CHRG_STS is 0x%02x\n",
__func__, linch_status);
if (!!(linch_status && END_OF_CHARGE)) {
send_tps_chg_int_notify(CHG_CHARGE_DONE, 1);
@@ -572,7 +580,7 @@ static ssize_t tps80032_charger_charge_done_show(struct device *dev,
ret = tps80031_read(charger_data->parent_dev, SLAVE_ID2,
LINEAR_CHRG_STS, &linch_status);
if (ret < 0) {
- pr_err("%s(): Failed in reading register 0x%02x\n",
+ E("%s(): Failed in reading register 0x%02x\n",
__func__, LINEAR_CHRG_STS);
return scnprintf(buf, PAGE_SIZE, "0\n");
}
@@ -590,7 +598,7 @@ static ssize_t tps80032_charger_charge_enabled_show(struct device *dev,
ret = tps80031_read(charger_data->parent_dev, SLAVE_ID2,
CONTROLLER_STAT1, &status);
if (ret < 0) {
- pr_err("%s(): Failed in reading register 0x%02x\n",
+ E("%s(): Failed in reading register 0x%02x\n",
__func__, CONTROLLER_STAT1);
return scnprintf(buf, PAGE_SIZE, "0\n");
}
@@ -608,7 +616,7 @@ static ssize_t tps80032_charger_vsys_reg_show(struct device *dev,
ret = tps80031_read(charger_data->parent_dev, SLAVE_ID2,
CHARGERUSB_VSYSREG, &status);
if (ret < 0) {
- pr_err("%s(): Failed in reading register 0x%02x\n",
+ E("%s(): Failed in reading register 0x%02x\n",
__func__, CHARGERUSB_VSYSREG);
return scnprintf(buf, PAGE_SIZE, "0\n");
}
@@ -648,11 +656,11 @@ static int __devinit tps80032_charger_probe(struct platform_device *pdev)
int ret = 0;
u8 regh;
- CHECK_LOG();
+ I("%s: probe start\n", __func__);
charger_data = kzalloc(sizeof(struct tps80032_charger_data), GFP_KERNEL);
if (!charger_data) {
- pr_err("%s:Unable to allocat memory!!\n", __func__);
+ E("%s:Unable to allocat memory!!\n", __func__);
return -ENOMEM;
}
@@ -663,7 +671,7 @@ static int __devinit tps80032_charger_probe(struct platform_device *pdev)
tps80032_wq = create_singlethread_workqueue("tps80032");
if (!tps80032_wq) {
- pr_err("Failed to create tps80032 workqueue.\n");
+ E("Failed to create tps80032 workqueue.\n");
kfree(charger_data);
ret = -ENOMEM;
goto wq_create_fail;
@@ -672,7 +680,7 @@ static int __devinit tps80032_charger_probe(struct platform_device *pdev)
ret = request_threaded_irq(pdata->int_chg_irq, NULL,
int_chg_isr, 0, "tps80032-chg", charger_data);
if (ret) {
- pr_err("Unable to register irq %d; error %d\n",
+ E("Unable to register irq %d; error %d\n",
pdata->int_chg_irq, ret);
goto irq_chg_fail;
}
@@ -682,7 +690,7 @@ static int __devinit tps80032_charger_probe(struct platform_device *pdev)
ret = request_threaded_irq(pdata->linch_gated_irq, NULL,
linch_status_isr, 0, "tps80032-linch", charger_data);
if (ret) {
- pr_err("Unable to register irq %d; error %d\n",
+ E("Unable to register irq %d; error %d\n",
pdata->linch_gated_irq, ret);
goto irq_linch_fail;
} else {
@@ -694,7 +702,7 @@ static int __devinit tps80032_charger_probe(struct platform_device *pdev)
ret = request_threaded_irq(pdata->fault_wdg_irq, NULL,
watchdog_expire_isr, 0, "tps80032-wdg", charger_data);
if (ret) {
- pr_err("Unable to register irq %d; error %d\n",
+ E("Unable to register irq %d; error %d\n",
pdata->fault_wdg_irq, ret);
goto irq_wdg_fail;
} else {
@@ -709,7 +717,7 @@ static int __devinit tps80032_charger_probe(struct platform_device *pdev)
TPS80032_ID2_I2C_WRITE(CHARGERUSB_CTRL3, regh);
tps80032_charger_initial = 1;
- pr_info("Driver registration done\n");
+ I("%s: probe success!\n", __func__);
return 0;
tps80032_i2c_err:
View
138 drivers/power/tps80032_gauge.c
@@ -11,10 +11,6 @@
* GNU General Public License for more details.
*/
-/* for pr_xxx log */
-#define PR_TAG "[PMU_GAU]"
-#define pr_fmt(fmt) PR_TAG fmt
-
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
@@ -30,11 +26,22 @@
#include <linux/workqueue.h>
#include <asm/div64.h>
-#define FUNC_CALL_CHECK 0
#define GAUGE_DEBUG 0
+#if GAUGE_DEBUG
+ #define D(x...) pr_info("[BATT][GAUGE]" x)
+#else
+ #define D(x...)
+#endif
+
+#define I(x...) pr_info("[BATT][GAUGE]" x)
+#define E(x...) pr_err("[BATT][GAUGE]" x)
+
+/* used for debug if function called */
+#define FUNC_CALL_CHECK 0
+
#if FUNC_CALL_CHECK
-#define CHECK_LOG() pr_info("%s\n", __func__)
+#define CHECK_LOG() D("[BATT][GAUGE] %s\n", __func__)
#else
#define CHECK_LOG() (void)0
#endif
@@ -118,7 +125,7 @@ static int do_gauge_calibration(void)
ret = tps80031_read(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_FG_REG_00, &value);
if (ret < 0) {
- pr_err("%s:read register TPS80032_FG_REG_00 fail\n"
+ E("%s:read register TPS80032_FG_REG_00 fail\n"
, __func__);
goto gauge_fail;
}
@@ -126,7 +133,7 @@ static int do_gauge_calibration(void)
ret = tps80031_write(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_FG_REG_00, value | CC_CAL_EN);
if (ret < 0) {
- pr_err("%s:write register TPS80032_FG_REG_00"
+ E("%s:write register TPS80032_FG_REG_00"
" fail value %lu\n"
, __func__, value | CC_CAL_EN);
goto gauge_fail;
@@ -148,7 +155,7 @@ static void cc_autocal_done_func(struct work_struct *work)
ret = tps80031_read(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_FG_REG_08, value);
if (ret < 0) {
- pr_err("%s:read register TPS80032_FG_REG_08 fail\n"
+ E("%s:read register TPS80032_FG_REG_08 fail\n"
, __func__);
goto read_gauge_fail;
}
@@ -156,7 +163,7 @@ static void cc_autocal_done_func(struct work_struct *work)
ret = tps80031_read(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_FG_REG_09, value + 1);
if (ret < 0) {
- pr_err("%s:read register TPS80032_FG_REG_09 fail\n"
+ E("%s:read register TPS80032_FG_REG_09 fail\n"
, __func__);
goto read_gauge_fail;
}
@@ -203,7 +210,7 @@ static int reset_gauge(enum update_rate ur_select)
CHECK_LOG();
if (ur_select > URSTOP) {
- pr_err("%s: No such gauge update selections"
+ E("%s: No such gauge update selections"
" value=%d\n"
, __func__, ur_select);
ret = -EINVAL;
@@ -220,7 +227,7 @@ static int reset_gauge(enum update_rate ur_select)
ret = tps80031_write(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_TOGGLE1, value);
if (ret < 0) {
- pr_err("%s:write register TPS80032_TOGGLE1"
+ E("%s:write register TPS80032_TOGGLE1"
" fail value %d\n"
, __func__, value);
goto gauge_fail;
@@ -233,7 +240,7 @@ static int reset_gauge(enum update_rate ur_select)
ret = tps80031_write(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_FG_REG_00, value);
if (ret < 0) {
- pr_err("%s:write register TPS80032_FG_REG_00"
+ E("%s:write register TPS80032_FG_REG_00"
" fail value %u\n"
, __func__, value);
goto gauge_fail;
@@ -244,7 +251,7 @@ static int reset_gauge(enum update_rate ur_select)
ret = tps80031_write(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_FG_REG_00, value);
if (ret < 0) {
- pr_err("%s:write register TPS80032_FG_REG_00"
+ E("%s:write register TPS80032_FG_REG_00"
" fail value %u\n"
, __func__, value);
goto gauge_fail;
@@ -289,7 +296,7 @@ static int set_gauge_counter(struct tps80032_gauge_counter *gauge_counter)
CHECK_LOG();
if (gauge_counter->pass_time > 0 && !!(gauge_counter->pass_time && 0x7F000000)) {
- pr_err("%s: SET_COUNTER paramter pass_timer might cause overflow reject\n", __func__);
+ E("%s: SET_COUNTER paramter pass_timer might cause overflow reject\n", __func__);
ret = -EFAULT;
goto value_overflow;
}
@@ -297,9 +304,7 @@ static int set_gauge_counter(struct tps80032_gauge_counter *gauge_counter)
temp = gauge_counter->accum_current < 0 ?
-1 * gauge_counter->accum_current : gauge_counter->accum_current;
-#if GAUGE_DEBUG
- pr_info("accum_current = %d => temp(unsigned) = %lld\n", gauge_counter->accum_current, temp);
-#endif
+ D("accum_current = %d => temp(unsigned) = %lld\n", gauge_counter->accum_current, temp);
if (gauge_data->rate_select == URSTOP)
goto gauge_fail;
@@ -312,14 +317,13 @@ static int set_gauge_counter(struct tps80032_gauge_counter *gauge_counter)
do_div(temp, ((V_FS * 1000) * AMPLIFIER / R_S));
cc_accum = gauge_counter->accum_current < 0 ? -1 * ((int) temp) : (int) temp;
-#if GAUGE_DEBUG
- pr_info("temp(unsigned) = %lld => cc_accum=%d\n", temp, cc_accum);
-#endif
+
+ D("temp(unsigned) = %lld => cc_accum=%d\n", temp, cc_accum);
ret = tps80031_read(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_FG_REG_00, &value);
if (ret < 0) {
- pr_err("%s:read register TPS80032_FG_REG_00 fail\n"
+ E("%s:read register TPS80032_FG_REG_00 fail\n"
, __func__);
goto i2c_fail;
}
@@ -327,7 +331,7 @@ static int set_gauge_counter(struct tps80032_gauge_counter *gauge_counter)
ret = tps80031_write(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_FG_REG_00, value | CC_PAUSE);
if (ret < 0) {
- pr_err("%s:write register TPSS80032_FG_REG_00"
+ E("%s:write register TPSS80032_FG_REG_00"
" faild value %lu\n"
, __func__, value | CC_PAUSE);
goto i2c_fail;
@@ -339,7 +343,7 @@ static int set_gauge_counter(struct tps80032_gauge_counter *gauge_counter)
ret = tps80031_write(gauge_data->parent_dev, SLAVE_ID2,
TPS80032_FG_REG_01 + i, cc_sample_cntr & 0xFF);
if (ret < 0) {
- pr_err("%s:write register TPS80032_FG_REG_0%d"
+ E("%s:write register TPS80032_FG_REG_0%d"
" fail\n"
, __func__, i + 1);
goto i2c_fail;