From patchwork Thu Sep 27 20:08:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11801 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 8978A24140 for ; Thu, 27 Sep 2012 20:09:56 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3A9CBA18351 for ; Thu, 27 Sep 2012 20:09:56 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so5234801iej.11 for ; Thu, 27 Sep 2012 13:09:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=5y5lGaT+lPy9IYScrOCIjXc8svBthmqCi1AvpX3kpac=; b=Zk22bj1Xyr4c9+vZ2Rm5dfWQEtVvUg5fEzwBMhGtHz2JVCrGYmQ3mfFs8PrgTR+9iy SezsHI7wMp1JZa3JIDY45o5b/abzCybnwSvNh71Yo5Zn9zwgt30/p8/jMyMRo7XyRWTI skObcvlmfaeAUSat0RKSD760XDVEzvai9fRHHX+Us756Pm5ZnScZ17buqjprFSMLm5Kz mp3EPVOcV8jlZmJwq6ZFiInG9zQaA18t+qoJrFk34/033+RvZqFMFr/wDw43whhX2EAn 44yrZKl3IbP2GahXHuZscPnvgxKNs8WMNBn9Wt/flLujox75I7/crO6ZVBsTD8dWwrDt n/1w== Received: by 10.50.0.193 with SMTP id 1mr4747517igg.0.1348776595942; Thu, 27 Sep 2012 13:09:55 -0700 (PDT) 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.50.184.232 with SMTP id ex8csp436326igc; Thu, 27 Sep 2012 13:09:55 -0700 (PDT) Received: by 10.68.232.71 with SMTP id tm7mr14542381pbc.118.1348776595370; Thu, 27 Sep 2012 13:09:55 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id vn9si8390651pbc.17.2012.09.27.13.09.55 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:55 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) client-ip=209.85.220.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) smtp.mail=mathieu.poirier@linaro.org Received: by mail-pa0-f50.google.com with SMTP id hz11so1847989pad.37 for ; Thu, 27 Sep 2012 13:09:55 -0700 (PDT) Received: by 10.68.201.104 with SMTP id jz8mr14616724pbc.141.1348776595144; Thu, 27 Sep 2012 13:09:55 -0700 (PDT) Received: from localhost.localdomain (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPS id sa2sm1587890pbc.4.2012.09.27.13.09.53 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:54 -0700 (PDT) From: mathieu.poirier@linaro.org To: patches@linaro.org Subject: [PATCH 28/57] power: ab8500 - Accessing Autopower register fails Date: Thu, 27 Sep 2012 14:08:45 -0600 Message-Id: <1348776554-10019-29-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> References: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> X-Gm-Message-State: ALoCoQkcZtrLDZM3/Y/eAaipP24gvHKFcF9ErU/bccCZAEeq2vLuGUstYjBhqlm8Y+rLigZmuzBd From: Nicolas Guion The fallback software control register has moved in the ab8505 and ab9540. Signed-off-by: Marcus Cooper Signed-off-by: Mathieu Poirier Reviewed-by: Mattias WALLIN Reviewed-by: Nicolas GUION Reviewed-by: Jonas ABERG --- drivers/power/ab8500_charger.c | 53 +++++++++++++++++++++++++++------------- 1 files changed, 36 insertions(+), 17 deletions(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 0a781a0..ee5ad7b 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -92,6 +92,8 @@ #define CHG_WD_INTERVAL (60 * HZ) +#define AB8500_SW_CONTROL_FALLBACK 0x03 + /* UsbLineStatus register - usb types */ enum ab8500_charger_link_status { USB_STAT_NOT_CONFIGURED, @@ -307,42 +309,59 @@ static enum power_supply_property ab8500_charger_usb_props[] = { static void ab8500_enable_disable_sw_fallback(struct ab8500_charger *di, bool fallback) { + u8 val; u8 reg; + u8 bank; + u8 bit; int ret; dev_dbg(di->dev, "SW Fallback: %d\n", fallback); + if (is_ab8500(di->parent)) { + bank = 0x15; + reg = 0x0; + bit = 3; + } else { + bank = AB8500_SYS_CTRL1_BLOCK; + reg = AB8500_SW_CONTROL_FALLBACK; + bit = 0; + } + /* read the register containing fallback bit */ - ret = abx500_get_register_interruptible(di->dev, 0x15, 0x00, ®); - if (ret) { - dev_err(di->dev, "%d write failed\n", __LINE__); + ret = abx500_get_register_interruptible(di->dev, bank, reg, &val); + if (ret < 0) { + dev_err(di->dev, "%d read failed\n", __LINE__); return; } - /* enable the OPT emulation registers */ - ret = abx500_set_register_interruptible(di->dev, 0x11, 0x00, 0x2); - if (ret) { - dev_err(di->dev, "%d write failed\n", __LINE__); - return; + if (is_ab8500(di->parent)) { + /* enable the OPT emulation registers */ + ret = abx500_set_register_interruptible(di->dev, + 0x11, 0x00, 0x2); + if (ret) { + dev_err(di->dev, "%d write failed\n", __LINE__); + goto disable_otp; + } } if (fallback) - reg |= 0x8; + val |= (1 << bit); else - reg &= ~0x8; + val &= ~(1 << bit); /* write back the changed fallback bit value to register */ - ret = abx500_set_register_interruptible(di->dev, 0x15, 0x00, reg); + ret = abx500_set_register_interruptible(di->dev, bank, reg, val); if (ret) { dev_err(di->dev, "%d write failed\n", __LINE__); - return; } - /* disable the set OTP registers again */ - ret = abx500_set_register_interruptible(di->dev, 0x11, 0x00, 0x0); - if (ret) { - dev_err(di->dev, "%d write failed\n", __LINE__); - return; +disable_otp: + if (is_ab8500(di->parent)) { + /* disable the set OTP registers again */ + ret = abx500_set_register_interruptible(di->dev, + 0x11, 0x00, 0x0); + if (ret) + dev_err(di->dev, "%d write failed\n", __LINE__); } }