From patchwork Fri Feb 15 12:45:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14878 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id AA0D223E2E for ; Fri, 15 Feb 2013 12:47:04 +0000 (UTC) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by fiordland.canonical.com (Postfix) with ESMTP id 2C099A197CC for ; Fri, 15 Feb 2013 12:47:04 +0000 (UTC) Received: by mail-ve0-f180.google.com with SMTP id jx10so2915825veb.39 for ; Fri, 15 Feb 2013 04:47:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=xAlSvz5xEWD9iWoIYuNKwBCVWGswh4XFfL4VJTr2zAI=; b=paFhd38W13p2bfZin41phev3tsI/ZdIjHXe4pHPEMw4jbWBk415h909zXTN7lKakVa SKMlDKTgzxQN5xkLitaQ5f9tk5QUBBBWwDTj9y9M/CIpYliobJsHl5itWFLfYF6Mu4FL bMZLafbceKiBAKEISA1h6QRNPBuRIHq71Izus6sLDjbdPXLWfoVUsf8d+zW0RPVcbkiL zvwCHZbm6WxGlrjI/vn+i/rihZv46D5q1vyQMrpx3Tea4dh3alWwlQQ3sfKz7/qTB1nI 0QLK4nEBxahtlghRRp928Lo/04LlbQK+iPfbDcIUyrsFZ9OVu9O4SMdOUB3avJzvDlos 6Fsw== X-Received: by 10.220.142.71 with SMTP id p7mr2944453vcu.3.1360932423661; Fri, 15 Feb 2013 04:47:03 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.221.4.5 with SMTP id oa5csp10909vcb; Fri, 15 Feb 2013 04:47:03 -0800 (PST) X-Received: by 10.180.99.227 with SMTP id et3mr3945136wib.6.1360932419558; Fri, 15 Feb 2013 04:46:59 -0800 (PST) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by mx.google.com with ESMTPS id cz9si1050832wib.14.2013.02.15.04.46.59 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:46:59 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.179 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.179; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.179 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f179.google.com with SMTP id ez12so1105602wid.6 for ; Fri, 15 Feb 2013 04:46:59 -0800 (PST) X-Received: by 10.194.108.229 with SMTP id hn5mr4089915wjb.8.1360932414531; Fri, 15 Feb 2013 04:46:54 -0800 (PST) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id bs6sm5133904wib.4.2013.02.15.04.46.52 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:46:53 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, cbouatmailru@gmail.com, sameo@linux.intel.com, lme00437 , Benoit GAUTHIER , Lee Jones Subject: [PATCH 33/40] pm2301-charger: lpn pin used only in C2C boards Date: Fri, 15 Feb 2013 12:45:03 +0000 Message-Id: <1360932310-30065-34-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360932310-30065-1-git-send-email-lee.jones@linaro.org> References: <1360932310-30065-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQmMFg4RHeuaZtY3fvouuDQ1Cx1OeMl4edLyq1Ci2RuF8u8oKlEhLUgIZpofZBQXNuTUdWh5 From: lme00437 This patch restricts use of LPN pin to C2C boards to avoid conflict on HSI for GPIO 60 use. Signed-off-by: Benoit GAUTHIER Signed-off-by: Lee Jones Reviewed-by: Mustapha BEN-ZOUBEIR Reviewed-by: Philippe LANGLAIS Tested-by: Benoit GAUTHIER --- drivers/power/pm2301_charger.c | 66 +++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c index cb1c953..eed6034 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[] = { static void set_lpn_pin(struct pm2xxx_charger *pm2) { - gpio_set_value(pm2->lpn_pin, 1); - usleep_range(SLEEP_MIN, SLEEP_MAX); - - return; + if (!pm2->ac.charger_connected && gpio_is_valid(pm2->lpn_pin)) { + gpio_set_value(pm2->lpn_pin, 1); + usleep_range(SLEEP_MIN, SLEEP_MAX); + } } static void clear_lpn_pin(struct pm2xxx_charger *pm2) { - gpio_set_value(pm2->lpn_pin, 0); - - return; + if (!pm2->ac.charger_connected && gpio_is_valid(pm2->lpn_pin)) + gpio_set_value(pm2->lpn_pin, 0); } static int pm2xxx_reg_read(struct pm2xxx_charger *pm2, int reg, u8 *val) @@ -1035,14 +1034,6 @@ static int __devinit pm2xxx_wall_charger_probe(struct i2c_client *i2c_client, pm2->bat = pl_data->battery; - /*get lpn GPIO from platform data*/ - if (!pm2->pdata->lpn_gpio) { - dev_err(pm2->dev, "no lpn gpio data supplied\n"); - ret = -EINVAL; - goto free_device_info; - } - pm2->lpn_pin = pm2->pdata->lpn_gpio; - if (!i2c_check_functionality(i2c_client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_READ_WORD_DATA)) { @@ -1146,23 +1137,28 @@ static int __devinit pm2xxx_wall_charger_probe(struct i2c_client *i2c_client, mutex_init(&pm2->lock); - /* - * Charger detection mechanism requires pulling up the LPN pin - * while i2c communication if Charger is not connected - * LPN pin of PM2301 is GPIO60 of AB9540 - */ - ret = gpio_request(pm2->lpn_pin, "pm2301_lpm_gpio"); - if (ret < 0) { - dev_err(pm2->dev, "pm2301_lpm_gpio request failed\n"); - goto disable_pm2_irq_wake; - } - ret = gpio_direction_output(pm2->lpn_pin, 0); - if (ret < 0) { - dev_err(pm2->dev, "pm2301_lpm_gpio direction failed\n"); - goto free_gpio; - } + if (gpio_is_valid(pm2->pdata->lpn_gpio)) { + /* get lpn GPIO from platform data */ + pm2->lpn_pin = pm2->pdata->lpn_gpio; - set_lpn_pin(pm2); + /* + * Charger detection mechanism requires pulling up the LPN pin + * while i2c communication if Charger is not connected + * LPN pin of PM2301 is GPIO60 of AB9540 + */ + ret = gpio_request(pm2->lpn_pin, "pm2301_lpm_gpio"); + + if (ret < 0) { + dev_err(pm2->dev, "pm2301_lpm_gpio request failed\n"); + goto disable_pm2_irq_wake; + } + ret = gpio_direction_output(pm2->lpn_pin, 0); + if (ret < 0) { + dev_err(pm2->dev, "pm2301_lpm_gpio direction failed\n"); + goto free_gpio; + } + set_lpn_pin(pm2); + } /* read interrupt registers */ for (i = 0; i < PM2XXX_NUM_INT_REG; i++) @@ -1184,7 +1180,8 @@ static int __devinit pm2xxx_wall_charger_probe(struct i2c_client *i2c_client, return 0; free_gpio: - gpio_free(pm2->lpn_pin); + if (gpio_is_valid(pm2->lpn_pin)) + gpio_free(pm2->lpn_pin); disable_pm2_irq_wake: disable_irq_wake(gpio_to_irq(pm2->pdata->gpio_irq_number)); unregister_pm2xxx_interrupt: @@ -1229,7 +1226,8 @@ static int __devexit pm2xxx_wall_charger_remove(struct i2c_client *i2c_client) power_supply_unregister(&pm2->ac_chg.psy); - gpio_free(pm2->lpn_pin); + if (gpio_is_valid(pm2->lpn_pin)) + gpio_free(pm2->lpn_pin); kfree(pm2); @@ -1266,7 +1264,7 @@ static void __exit pm2xxx_charger_exit(void) i2c_del_driver(&pm2xxx_charger_driver); } -subsys_initcall_sync(pm2xxx_charger_init); +device_initcall_sync(pm2xxx_charger_init); module_exit(pm2xxx_charger_exit); MODULE_LICENSE("GPL v2");