From patchwork Fri Feb 15 12:56:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14903 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 5152823E01 for ; Fri, 15 Feb 2013 12:57:58 +0000 (UTC) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by fiordland.canonical.com (Postfix) with ESMTP id E9AD2A1844A for ; Fri, 15 Feb 2013 12:57:57 +0000 (UTC) Received: by mail-vb0-f44.google.com with SMTP id fr13so2085658vbb.31 for ; Fri, 15 Feb 2013 04:57:57 -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=a65uA+7Rqh4+Ai9WjclXrpRo93dKCYvl03yLyOy8XCU=; b=SHXjZxlh++C82DZJ5BYwGL1ISt3sPsKpYTWgGp6er1RVXLFsn5cK0Maj/L8lqud6lj zquBVkgSw0d4kIbyPyf5WtF1VtO+Yj4mHpK5myXB3z+zbjAI8LBwhZGplgOb4LVdWamZ 6szpjc3si/3o5Y/wZ/YJVXT/bsgxSeskEgsnza8BUXIgYmB0iKA5RFJdiQXkn2P5O+6K lnmqbhqwTmNdbnWJvIhG9dXY1RzWhsmNT3xiriuGj2db/+gL744Ms/Vkie4Z09JxUeUp GWPLIsqiSZScbRUtcNaX5rv8mLjTBTc8NMRbg23bN44r6TyxS/fGVw5+v3bvYaoovLLR TAeg== X-Received: by 10.52.69.74 with SMTP id c10mr2661387vdu.3.1360933077442; Fri, 15 Feb 2013 04:57:57 -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 oa5csp11397vcb; Fri, 15 Feb 2013 04:57:56 -0800 (PST) X-Received: by 10.194.103.163 with SMTP id fx3mr3928263wjb.58.1360933076355; Fri, 15 Feb 2013 04:57:56 -0800 (PST) Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by mx.google.com with ESMTPS id fs9si1042525wib.107.2013.02.15.04.57.55 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:57:56 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.43 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.43; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.43 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-wg0-f43.google.com with SMTP id e12so2797265wge.22 for ; Fri, 15 Feb 2013 04:57:55 -0800 (PST) X-Received: by 10.194.88.202 with SMTP id bi10mr4150896wjb.5.1360933075837; Fri, 15 Feb 2013 04:57:55 -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 j4sm2852410wiz.10.2013.02.15.04.57.54 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:57:55 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sameo@linux.intel.com Cc: arnd@arndb.de, linus.walleij@stericsson.com, Rajkumar Kasirajan , Per Forlin , Lee Jones Subject: [PATCH 18/35] mfd: ab8500-sysctrl: Update correct turn on status Date: Fri, 15 Feb 2013 12:56:49 +0000 Message-Id: <1360933026-30325-19-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360933026-30325-1-git-send-email-lee.jones@linaro.org> References: <1360933026-30325-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQnyU8sUQLAej9R3fT6l33CTi115lq7Bxze5ocRdV5xqxb9JL2fRlOTFh9/Nyj2Aacj/R9Xl From: Rajkumar Kasirajan In L9540, turn_on_status register is not updated correctly if the device is rebooted with AC/USB charger connected. Due to this, the device boots android instead of entering into charge only mode. Read the AC/USB status register to detect the charger presence and update the turn on status manually. Signed-off-by: Rajkumar Kasirajan Signed-off-by: Per Forlin Signed-off-by: Lee Jones Reviewed-by: Rupesh KUMAR Reviewed-by: Philippe LANGLAIS Tested-by: Rupesh KUMAR Tested-by: Philippe LANGLAIS --- drivers/mfd/ab8500-core.c | 39 +++++++++++++++++++++++++++++++++++++ drivers/mfd/ab8500-sysctrl.c | 2 +- include/linux/mfd/abx500/ab8500.h | 11 +++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index f5ceb2e..bbbd6e4 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -113,6 +113,13 @@ #define AB8500_TURN_ON_STATUS 0x00 +#define AB8500_CH_USBCH_STAT1_REG 0x02 +#define VBUS_DET_DBNC100 0x02 +#define VBUS_DET_DBNC1 0x01 + +static DEFINE_SPINLOCK(on_stat_lock); +static u8 turn_on_stat_mask = 0xFF; +static u8 turn_on_stat_set; static bool no_bm; /* No battery management */ module_param(no_bm, bool, S_IRUGO); @@ -1329,6 +1336,15 @@ static ssize_t show_switch_off_status(struct device *dev, return sprintf(buf, "%#x\n", value); } +/* use mask and set to override the register turn_on_stat value */ +void ab8500_override_turn_on_stat(u8 mask, u8 set) +{ + spin_lock(&on_stat_lock); + turn_on_stat_mask = mask; + turn_on_stat_set = set; + spin_unlock(&on_stat_lock); +} + /* * ab8500 has turned on due to (TURN_ON_STATUS): * 0x01 PORnVbat @@ -1352,6 +1368,20 @@ static ssize_t show_turn_on_status(struct device *dev, AB8500_TURN_ON_STATUS, &value); if (ret < 0) return ret; + + /* + * In L9540, turn_on_status register is not updated correctly if + * the device is rebooted with AC/USB charger connected. Due to + * this, the device boots android instead of entering into charge + * only mode. Read the AC/USB status register to detect the charger + * presence and update the turn on status manually. + */ + if (is_ab9540(ab8500)) { + spin_lock(&on_stat_lock); + value = (value & turn_on_stat_mask) | turn_on_stat_set; + spin_unlock(&on_stat_lock); + } + return sprintf(buf, "%#x\n", value); } @@ -1564,6 +1594,15 @@ static int ab8500_probe(struct platform_device *pdev) if (plat && plat->init) plat->init(ab8500); + if (is_ab9540(ab8500)) { + ret = get_register_interruptible(ab8500, AB8500_CHARGER, + AB8500_CH_USBCH_STAT1_REG, &value); + if (ret < 0) + return ret; + if ((value & VBUS_DET_DBNC1) && (value & VBUS_DET_DBNC100)) + ab8500_override_turn_on_stat(~AB8500_POW_KEY_1_ON, + AB8500_VBUS_DET); + } /* Clear and mask all interrupts */ for (i = 0; i < ab8500->mask_size; i++) { diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index ab6bfd3..6ac63a0 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c @@ -21,7 +21,7 @@ void ab8500_power_off(void) { sigset_t old; sigset_t all; - static char *pss[] = {"ab8500_ac", "ab8500_usb"}; + static char *pss[] = {"ab8500_ac", "pm2301", "ab8500_usb"}; int i; bool charger_present = false; union power_supply_propval val; diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h index 06a8292..6748129 100644 --- a/include/linux/mfd/abx500/ab8500.h +++ b/include/linux/mfd/abx500/ab8500.h @@ -308,6 +308,15 @@ enum ab8500_version { #define AB9540_NUM_IRQ_REGS 20 #define AB8540_NUM_IRQ_REGS 27 +/* Turn On Status Event */ +#define AB8500_POR_ON_VBAT 0x01 +#define AB8500_POW_KEY_1_ON 0x02 +#define AB8500_POW_KEY_2_ON 0x04 +#define AB8500_RTC_ALARM 0x08 +#define AB8500_MAIN_CH_DET 0x10 +#define AB8500_VBUS_DET 0x20 +#define AB8500_USB_ID_DET 0x40 + /** * struct ab8500 - ab8500 internal structure * @dev: parent device @@ -468,6 +477,8 @@ static inline int is_ab8540_2p0(struct ab8500 *ab) return is_ab8540(ab) && (ab->chip_id == AB8500_CUT2P0); } +void ab8500_override_turn_on_stat(u8 mask, u8 set); + #ifdef CONFIG_AB8500_DEBUG void ab8500_dump_all_banks(struct device *dev); void ab8500_debug_register_interrupt(int line);