From patchwork Wed Feb 22 19:42:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rask Ingemann Lambertsen X-Patchwork-Id: 9587441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 07FB06051E for ; Wed, 22 Feb 2017 19:52:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDBF5285C3 for ; Wed, 22 Feb 2017 19:52:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E15932867D; Wed, 22 Feb 2017 19:52:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7C29B285C3 for ; Wed, 22 Feb 2017 19:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date:To:Subject: From:References:In-Reply-To:Message-Id:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=isKEnU5GWIShX+88jhRucsciBLQuNIavzKLJYtOkYWU=; b=lH5kCsZRJTjgk4UWxVNwsTy6k8 nRwg3t6nUS2xhIsaWhARPyF+925tLyFUUk8rjsLotE4/MrUKSBKEsiJKuFfCZ5McUfsGQJT3Q0OZh PaqMEh/5qtNufNAGbpjcwCW2QFW+D4LF5/a5kInHmbpZvB+jnsufjWYigMMKmldc37lOtSfRjnwHN TMFNe2ELpvYS7dPsrLiIlmuGnCvdh3VKZRfT7y9E/Uohi7AeWAjo+qhx4jA7jrMeCj51uHOjnZx4E thlhpUE5J4sjJbcNCeS801dJvGc0Wsb8Eb6nOGQXcu6cM07EE/k4szriVmUAb5+LwTFyu9xk6SRPL XW9cLTng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cgcxp-00078N-Se; Wed, 22 Feb 2017 19:52:37 +0000 Received: from customer-2a00-7660-0ca7-0000-b82e-b0d9-6ee6-cf12.ip6.gigabit.dk ([2a00:7660:ca7:0:b82e:b0d9:6ee6:cf12] helo=customer-2a00-7660-0ca7-0000-0000-0000-0000-0b1b.ip6.gigabit.dk) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cgcwv-0006vQ-DS for linux-arm-kernel@lists.infradead.org; Wed, 22 Feb 2017 19:51:43 +0000 Received: by customer-2a00-7660-0ca7-0000-0000-0000-0000-0b1b.ip6.gigabit.dk (Postfix, from userid 1000) id DC1D4318681; Wed, 22 Feb 2017 20:42:02 +0100 (CET) Message-Id: In-Reply-To: References: From: Rask Ingemann Lambertsen Subject: [PATCH v2 2/2] mfd: axp20x: Add support for dts property "xpowers,master-mode" To: Chen-Yu Tsai , Lee Jones , Rob Herring , Mark Rutland Date: Wed, 22 Feb 2017 20:42:02 +0100 (CET) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170222_115141_642889_9979A92C X-CRM114-Status: GOOD ( 15.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP commit b101829a029a ("mfd: axp20x: Fix AXP806 access errors on cold boot") was intended to fix the case where a board uses an AXP806 in slave mode, but the boot loader leaves it in master mode for lack of AXP806 support. But now the driver breaks on boards where the PMIC is operating in master mode. This patch lets the driver use the new device tree property "xpowers,master-mode" to set the correct operating mode for the board. Fixes: 8824ee857348 ("mfd: axp20x: Add support for AXP806 PMIC") Signed-off-by: Rask Ingemann Lambertsen Acked-by: Chen-Yu Tsai --- Changes from v1 to v2: Changed the commit message such that Fixes: points to the commit which added the AXP806 driver because the property should have been included from the beginning of the AXP806 support. drivers/mfd/axp20x.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 25115fe..0512900 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -31,6 +31,7 @@ #define AXP20X_OFF 0x80 +#define AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE 0 #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE BIT(4) static const char * const axp20x_model_names[] = { @@ -877,15 +878,19 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) * the these device addressing bits (in the upper 4 bits of the * registers) match. * - * Since we only support an AXP806 chained to an AXP809 in slave - * mode, and there isn't any existing hardware which uses AXP806 - * in master mode, or has 2 AXP806s in the same system, we can - * just program the register address extension to the slave mode - * address. + * By default we support an AXP806 chained to an AXP809 in slave + * mode. Boards which use an AXP806 in master mode can set the + * property "x-powers,master-mode" to override the default. */ - if (axp20x->variant == AXP806_ID) - regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, - AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE); + if (axp20x->variant == AXP806_ID) { + if (of_property_read_bool(axp20x->dev->of_node, + "x-powers,master-mode")) + regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, + AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE); + else + regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, + AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE); + } ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq, IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags,