aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/pm2301_charger.c
diff options
context:
space:
mode:
authorlme00437 <benoit.gauthier-nonst@stericsson.com>2012-11-13 08:43:48 -0500
committerLee Jones <lee.jones@linaro.org>2013-03-06 23:35:55 -0500
commita21e22f2f36c65c8453575ffd0cc8267134bb30a (patch)
treefb78409f465950e95646e9fc489e227a35c907c3 /drivers/power/pm2301_charger.c
parent3c01b3676f3fa3813b02742a1816c9d2eff1b27e (diff)
pm2301-charger: lpn pin used only in C2C boards
This patch restricts use of LPN pin to C2C boards to avoid conflict on HSI for GPIO 60 use. Signed-off-by: Benoit GAUTHIER <benoit.gauthier-xsig@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Mustapha BEN-ZOUBEIR <mustapha.ben.zoubeir-xsig@stericsson.com> Reviewed-by: Philippe LANGLAIS <philippe.langlais@stericsson.com> Tested-by: Benoit GAUTHIER <benoit.gauthier-xsig@stericsson.com>
Diffstat (limited to 'drivers/power/pm2301_charger.c')
-rw-r--r--drivers/power/pm2301_charger.c66
1 files changed, 32 insertions, 34 deletions
diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
index 87ddc658413f..12aeed34bd4f 100644
--- a/drivers/power/pm2301_charger.c
+++ b/drivers/power/pm2301_charger.c
@@ -113,17 +113,16 @@ static const struct i2c_device_id pm2xxx_ident[] = {
113 113
114static void set_lpn_pin(struct pm2xxx_charger *pm2) 114static void set_lpn_pin(struct pm2xxx_charger *pm2)
115{ 115{
116 gpio_set_value(pm2->lpn_pin, 1); 116 if (!pm2->ac.charger_connected && gpio_is_valid(pm2->lpn_pin)) {
117 usleep_range(SLEEP_MIN, SLEEP_MAX); 117 gpio_set_value(pm2->lpn_pin, 1);
118 118 usleep_range(SLEEP_MIN, SLEEP_MAX);
119 return; 119 }
120} 120}
121 121
122static void clear_lpn_pin(struct pm2xxx_charger *pm2) 122static void clear_lpn_pin(struct pm2xxx_charger *pm2)
123{ 123{
124 gpio_set_value(pm2->lpn_pin, 0); 124 if (!pm2->ac.charger_connected && gpio_is_valid(pm2->lpn_pin))
125 125 gpio_set_value(pm2->lpn_pin, 0);
126 return;
127} 126}
128 127
129static int pm2xxx_reg_read(struct pm2xxx_charger *pm2, int reg, u8 *val) 128static int pm2xxx_reg_read(struct pm2xxx_charger *pm2, int reg, u8 *val)
@@ -1035,14 +1034,6 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
1035 1034
1036 pm2->bat = pl_data->battery; 1035 pm2->bat = pl_data->battery;
1037 1036
1038 /*get lpn GPIO from platform data*/
1039 if (!pm2->pdata->lpn_gpio) {
1040 dev_err(pm2->dev, "no lpn gpio data supplied\n");
1041 ret = -EINVAL;
1042 goto free_device_info;
1043 }
1044 pm2->lpn_pin = pm2->pdata->lpn_gpio;
1045
1046 if (!i2c_check_functionality(i2c_client->adapter, 1037 if (!i2c_check_functionality(i2c_client->adapter,
1047 I2C_FUNC_SMBUS_BYTE_DATA | 1038 I2C_FUNC_SMBUS_BYTE_DATA |
1048 I2C_FUNC_SMBUS_READ_WORD_DATA)) { 1039 I2C_FUNC_SMBUS_READ_WORD_DATA)) {
@@ -1146,23 +1137,28 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
1146 1137
1147 mutex_init(&pm2->lock); 1138 mutex_init(&pm2->lock);
1148 1139
1149 /* 1140 if (gpio_is_valid(pm2->pdata->lpn_gpio)) {
1150 * Charger detection mechanism requires pulling up the LPN pin 1141 /* get lpn GPIO from platform data */
1151 * while i2c communication if Charger is not connected 1142 pm2->lpn_pin = pm2->pdata->lpn_gpio;
1152 * LPN pin of PM2301 is GPIO60 of AB9540
1153 */
1154 ret = gpio_request(pm2->lpn_pin, "pm2301_lpm_gpio");
1155 if (ret < 0) {
1156 dev_err(pm2->dev, "pm2301_lpm_gpio request failed\n");
1157 goto disable_pm2_irq_wake;
1158 }
1159 ret = gpio_direction_output(pm2->lpn_pin, 0);
1160 if (ret < 0) {
1161 dev_err(pm2->dev, "pm2301_lpm_gpio direction failed\n");
1162 goto free_gpio;
1163 }
1164 1143
1165 set_lpn_pin(pm2); 1144 /*
1145 * Charger detection mechanism requires pulling up the LPN pin
1146 * while i2c communication if Charger is not connected
1147 * LPN pin of PM2301 is GPIO60 of AB9540
1148 */
1149 ret = gpio_request(pm2->lpn_pin, "pm2301_lpm_gpio");
1150
1151 if (ret < 0) {
1152 dev_err(pm2->dev, "pm2301_lpm_gpio request failed\n");
1153 goto disable_pm2_irq_wake;
1154 }
1155 ret = gpio_direction_output(pm2->lpn_pin, 0);
1156 if (ret < 0) {
1157 dev_err(pm2->dev, "pm2301_lpm_gpio direction failed\n");
1158 goto free_gpio;
1159 }
1160 set_lpn_pin(pm2);
1161 }
1166 1162
1167 /* read interrupt registers */ 1163 /* read interrupt registers */
1168 for (i = 0; i < PM2XXX_NUM_INT_REG; i++) 1164 for (i = 0; i < PM2XXX_NUM_INT_REG; i++)
@@ -1184,7 +1180,8 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
1184 return 0; 1180 return 0;
1185 1181
1186free_gpio: 1182free_gpio:
1187 gpio_free(pm2->lpn_pin); 1183 if (gpio_is_valid(pm2->lpn_pin))
1184 gpio_free(pm2->lpn_pin);
1188disable_pm2_irq_wake: 1185disable_pm2_irq_wake:
1189 disable_irq_wake(gpio_to_irq(pm2->pdata->gpio_irq_number)); 1186 disable_irq_wake(gpio_to_irq(pm2->pdata->gpio_irq_number));
1190unregister_pm2xxx_interrupt: 1187unregister_pm2xxx_interrupt:
@@ -1229,7 +1226,8 @@ static int pm2xxx_wall_charger_remove(struct i2c_client *i2c_client)
1229 1226
1230 power_supply_unregister(&pm2->ac_chg.psy); 1227 power_supply_unregister(&pm2->ac_chg.psy);
1231 1228
1232 gpio_free(pm2->lpn_pin); 1229 if (gpio_is_valid(pm2->lpn_pin))
1230 gpio_free(pm2->lpn_pin);
1233 1231
1234 kfree(pm2); 1232 kfree(pm2);
1235 1233
@@ -1266,7 +1264,7 @@ static void __exit pm2xxx_charger_exit(void)
1266 i2c_del_driver(&pm2xxx_charger_driver); 1264 i2c_del_driver(&pm2xxx_charger_driver);
1267} 1265}
1268 1266
1269subsys_initcall_sync(pm2xxx_charger_init); 1267device_initcall_sync(pm2xxx_charger_init);
1270module_exit(pm2xxx_charger_exit); 1268module_exit(pm2xxx_charger_exit);
1271 1269
1272MODULE_LICENSE("GPL v2"); 1270MODULE_LICENSE("GPL v2");