From patchwork Thu Jul 12 16:04:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 10521881 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 F1035602B3 for ; Thu, 12 Jul 2018 16:05:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBBE528807 for ; Thu, 12 Jul 2018 16:05:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE4F429243; Thu, 12 Jul 2018 16:05:14 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 2A44D28807 for ; Thu, 12 Jul 2018 16:05:14 +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:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gtbbdDdIYxp2/s+m2qrlJfSL8JRMnVAhrh/S6EzbWTk=; b=HdAExV3rnlQWFEx3bYtyW9Sz6V NxBQmpyJwfUi2wRZPlfCvbpfSoZSiBneyGyNvt765ufg7+QRQKyQcGq0P7rnHNI0r4IYojyEz8iX4 TIjFsvv32yBtLyXjSSum/MIhFC/1DWRug376C9kLBEmtyyEkto5DrdbCaL5MM+YuYEfPUx91N9Qaq FVVIstPHLGTJzAVXuqRY7DbRQu4esK4Hk4Mt2vndHYTn9wuaP/P0/MKbkcGEelRjRZ24P699X5tZs zTcUZRH/VOQyiubg5yXDhJdrGlrQq0DufKTV4uaegtlk7y5e3xdTH3fZO9/t57+UVnukkPasOoaAL rdEPTyAQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fde5f-0001jh-TV; Thu, 12 Jul 2018 16:05:11 +0000 Received: from mirror2.csie.ntu.edu.tw ([140.112.30.76] helo=wens.csie.org) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fde5c-0000Qr-39 for linux-arm-kernel@lists.infradead.org; Thu, 12 Jul 2018 16:05:09 +0000 Received: by wens.csie.org (Postfix, from userid 1000) id D6E675FB6F; Fri, 13 Jul 2018 00:04:53 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , Lee Jones Subject: [PATCH v3 2/5] mfd: axp20x: Add self-working mode support for AXP806 Date: Fri, 13 Jul 2018 00:04:49 +0800 Message-Id: <20180712160452.5516-3-wens@csie.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180712160452.5516-1-wens@csie.org> References: <20180712160452.5516-1-wens@csie.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180712_090508_299457_EF1160F0 X-CRM114-Status: GOOD ( 13.06 ) 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, Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, Icenowy Zheng 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 The AXP806 can operate in a standalone "self-working" mode, in which it is also responsible for power control of the overall system. This mode is similar to the master mode, but the EN/PWRON pin functions as a power button, instead of a level-triggered enable switch. This patch adds code checking for the new "x-powers,self-working-mode" property, and a separate mfd_cell list that includes the power button (PEK) sub-device. Reviewed-by: Icenowy Zheng Tested-by: Icenowy Zheng Acked-for-MFD-by: Lee Jones Acked-by: Maxime Ripard Signed-off-by: Chen-Yu Tsai --- drivers/mfd/axp20x.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 9a2ef3d9b8f8..0be511dd93d0 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -221,6 +221,11 @@ static const struct resource axp803_pek_resources[] = { DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"), }; +static const struct resource axp806_pek_resources[] = { + DEFINE_RES_IRQ_NAMED(AXP806_IRQ_POK_RISE, "PEK_DBR"), + DEFINE_RES_IRQ_NAMED(AXP806_IRQ_POK_FALL, "PEK_DBF"), +}; + static const struct resource axp809_pek_resources[] = { DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_RIS_EDGE, "PEK_DBR"), DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"), @@ -730,6 +735,15 @@ static const struct mfd_cell axp803_cells[] = { { .name = "axp20x-regulator" }, }; +static const struct mfd_cell axp806_self_working_cells[] = { + { + .name = "axp221-pek", + .num_resources = ARRAY_SIZE(axp806_pek_resources), + .resources = axp806_pek_resources, + }, + { .name = "axp20x-regulator" }, +}; + static const struct mfd_cell axp806_cells[] = { { .id = 2, @@ -842,8 +856,14 @@ int axp20x_match_device(struct axp20x_dev *axp20x) axp20x->regmap_irq_chip = &axp803_regmap_irq_chip; break; case AXP806_ID: - axp20x->nr_cells = ARRAY_SIZE(axp806_cells); - axp20x->cells = axp806_cells; + if (of_property_read_bool(axp20x->dev->of_node, + "x-powers,self-working-mode")) { + axp20x->nr_cells = ARRAY_SIZE(axp806_self_working_cells); + axp20x->cells = axp806_self_working_cells; + } else { + axp20x->nr_cells = ARRAY_SIZE(axp806_cells); + axp20x->cells = axp806_cells; + } axp20x->regmap_cfg = &axp806_regmap_config; axp20x->regmap_irq_chip = &axp806_regmap_irq_chip; break; @@ -901,7 +921,9 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) */ if (axp20x->variant == AXP806_ID) { if (of_property_read_bool(axp20x->dev->of_node, - "x-powers,master-mode")) + "x-powers,master-mode") || + of_property_read_bool(axp20x->dev->of_node, + "x-powers,self-working-mode")) regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, AXP806_REG_ADDR_EXT_ADDR_MASTER_MODE); else