From patchwork Fri Feb 15 12:45:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14880 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 1410723E2E for ; Fri, 15 Feb 2013 12:47:11 +0000 (UTC) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by fiordland.canonical.com (Postfix) with ESMTP id A891BA197CA for ; Fri, 15 Feb 2013 12:47:10 +0000 (UTC) Received: by mail-vc0-f181.google.com with SMTP id d16so2135370vcd.40 for ; Fri, 15 Feb 2013 04:47:10 -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=E7RsxEv7I8GOk2RN1RPfurhE2j48vys8JFu7wppM9Z8=; b=aTBanWhyXb1bc5TSz+czfVOCoTOteba5JsnrUZHa01127zRQdZDT07A0JF5AH7QBvF JuFhgJf+VXzQ32ifuLi2I9+EqSM38KBx1cLNS+ORMaHcyOuUP1iy1+cq+kY8qxCwzF4T aIDGeSypPKu1EgDiayKLGP49Vm5XCMs10THxPGfcRKJ76lvfld66pVXexCL6v8lpGRz9 lOkSn07z0f/KKmv/rV1fiiWcT8FJps2X6VLgWhrtwwmA3gyqyAGChZkWtoEzlG69rjwN ircBiiM/8qhaStMtaizEvaUcGjSs73D+MU76gb4kTC6rH34Vb3e5UrDgvQ4K4SZ09YOJ akCA== X-Received: by 10.58.85.134 with SMTP id h6mr3047867vez.18.1360932430185; Fri, 15 Feb 2013 04:47:10 -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 oa5csp10912vcb; Fri, 15 Feb 2013 04:47:04 -0800 (PST) X-Received: by 10.194.59.40 with SMTP id w8mr3884652wjq.51.1360932421427; Fri, 15 Feb 2013 04:47:01 -0800 (PST) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by mx.google.com with ESMTPS id n9si1037363wia.81.2013.02.15.04.47.01 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:47:01 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.176 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.176; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.176 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-f176.google.com with SMTP id hm14so1101086wib.3 for ; Fri, 15 Feb 2013 04:47:01 -0800 (PST) X-Received: by 10.194.77.129 with SMTP id s1mr4044098wjw.17.1360932421009; Fri, 15 Feb 2013 04:47:01 -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.58 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:47:00 -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, Rupesh Kumar , Lee Jones Subject: [PATCH 36/40] pm2301-charger: Wake device on register access Date: Fri, 15 Feb 2013 12:45:06 +0000 Message-Id: <1360932310-30065-37-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: ALoCoQn0YwgEDxRaORWwUD7Z28060h/Tbp8yQuTkDh6J42M0ZzwJmaxDKBUND4ZTnI910eP5QMca From: Rupesh Kumar When USB Dedicated or Standard host chargers are plugged into the device, chargealg attempts to disable the PM2301 AC charger, However, disabling PM2301 was failing because of it being in runtime suepend mode & LPN pin being low. Signed-off-by: Rupesh Kumar Signed-off-by: Lee Jones Reviewed-by: Marcus COOPER Reviewed-by: Philippe LANGLAIS --- drivers/power/pm2301_charger.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c index f99a0c8..ea9870d 100644 --- a/drivers/power/pm2301_charger.c +++ b/drivers/power/pm2301_charger.c @@ -128,13 +128,9 @@ static void clear_lpn_pin(struct pm2xxx_charger *pm2) static int pm2xxx_reg_read(struct pm2xxx_charger *pm2, int reg, u8 *val) { int ret; - /* - * When AC adaptor is unplugged, the host - * must put LPN high to be able to - * communicate by I2C with PM2301 - * and receive I2C "acknowledge" from PM2301. - */ - mutex_lock(&pm2->lock); + + /* wake up the device */ + pm_runtime_get_sync(pm2->dev); ret = i2c_smbus_read_i2c_block_data(pm2->config.pm2xxx_i2c, reg, 1, val); @@ -142,7 +138,6 @@ static int pm2xxx_reg_read(struct pm2xxx_charger *pm2, int reg, u8 *val) dev_err(pm2->dev, "Error reading register at 0x%x\n", reg); else ret = 0; - mutex_unlock(&pm2->lock); return ret; } @@ -150,13 +145,9 @@ static int pm2xxx_reg_read(struct pm2xxx_charger *pm2, int reg, u8 *val) static int pm2xxx_reg_write(struct pm2xxx_charger *pm2, int reg, u8 val) { int ret; - /* - * When AC adaptor is unplugged, the host - * must put LPN high to be able to - * communicate by I2C with PM2301 - * and receive I2C "acknowledge" from PM2301. - */ - mutex_lock(&pm2->lock); + + /* wake up the device */ + pm_runtime_get_sync(pm2->dev); ret = i2c_smbus_write_i2c_block_data(pm2->config.pm2xxx_i2c, reg, 1, &val); @@ -164,7 +155,6 @@ static int pm2xxx_reg_write(struct pm2xxx_charger *pm2, int reg, u8 val) dev_err(pm2->dev, "Error writing register at 0x%x\n", reg); else ret = 0; - mutex_unlock(&pm2->lock); return ret; }