From patchwork Tue Dec 10 13:24:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 11282443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 211DF188B for ; Tue, 10 Dec 2019 13:27:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D770B20663 for ; Tue, 10 Dec 2019 13:27:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tK3eZdHT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D770B20663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org 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=KFygfPL/Jwt/MGWnxGDFL/u2/yApnTlK8o2eILtqKTI=; b=tK3eZdHTGeCOmgxHmoPAuuwzGi XoZz1AAi1a1BxhcWWSDlh6F/CPx2k0bagCYl3Dyp3tLyzIQUNf1y93J+eS5JFGUlIGurlsYyW5ZQN kXKPVab0CAebnBTjnCf8hDhddL0QZmiHo1Q3+h33UvYcq+gppGbAQub5+RgqBDhYf6VlxvDYwW6s9 xRUz5lveaG0lYT4+0rL5RMO/QEYhw6JornENc/bH4CrhtpS4jIbLKLhgfv+sJaH1PO6AcKLBiX1Na bUrAdh/8vCCud9BeZRjZXGSAbwWVzsm1HomSW7+Uo0adoPDhL4DRgWn5MsA/3tL+PR4EnQU3sm9cx Y3T04Ecg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iefXt-0006Ek-Q4; Tue, 10 Dec 2019 13:27:21 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iefV6-000277-F5 for linux-rockchip@lists.infradead.org; Tue, 10 Dec 2019 13:24:29 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 96F3E1045; Tue, 10 Dec 2019 05:24:27 -0800 (PST) Received: from DESKTOP-VLO843J.cambridge.arm.com (DESKTOP-VLO843J.cambridge.arm.com [10.1.26.198]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A23853F52E; Tue, 10 Dec 2019 05:24:26 -0800 (PST) From: Robin Murphy To: lee.jones@linaro.org Subject: [PATCH 1/4] mfd: rk808: Set global instance unconditionally Date: Tue, 10 Dec 2019 13:24:30 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191210_052428_591322_8D7240A8 X-CRM114-Status: GOOD ( 11.79 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux.amoon@gmail.com, linux-rockchip@lists.infradead.org, smoch@web.de, linux-kernel@vger.kernel.org, heiko@sntech.de MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The RK817 syscore ops rely on the global rk808_i2c_client being set, but are essentially independent of whether this driver has authority over system power control - indeed, setting the SLEEP pin functionality is most likely wanted when firmware is in charge of power via PSCI. There's also no harm in setting it unconditionally anyway, so do it. Signed-off-by: Robin Murphy --- drivers/mfd/rk808.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index 616e44e7ef98..f2f2f98552a0 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -666,6 +666,8 @@ static int rk808_probe(struct i2c_client *client, } } + rk808_i2c_client = client; + ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE, cells, nr_cells, NULL, 0, regmap_irq_get_domain(rk808->irq_data)); @@ -675,7 +677,6 @@ static int rk808_probe(struct i2c_client *client, } if (of_property_read_bool(np, "rockchip,system-power-controller")) { - rk808_i2c_client = client; pm_power_off = rk808->pm_pwroff_fn; pm_power_off_prepare = rk808->pm_pwroff_prep_fn; } From patchwork Tue Dec 10 13:24:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 11282447 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2083138C for ; Tue, 10 Dec 2019 13:27:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A7F92073B for ; Tue, 10 Dec 2019 13:27:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PsTs5hGe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A7F92073B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org 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=86YvTN7JOKLHZXRpfU0bjavFPz0JT1UXwey0vYhbENk=; b=PsTs5hGeiWO8ipuPbXcRbSqEl2 3tYxA8qYzzuqMrf8ABZCjkKD2vv1KpGKZfes5/RYe36X2rxYyOIHOpBv8/2H1xLNMUzisLKgVEuzl Ua9FyTTeXELgm11Wt9Hnbx+OSrG8N1BMCNVtdFJphEwy3g62wJS1+cYj76x9lSiuK6RR9Y75PTOaU WBWa+o1CeYnWBz8djTdFzf6KIXCIIlOerh46JSRFJI9kafD3Dd1tU1TuKsUSzVOWf0X3WVWvi8M4Q fYMxpgrnvsu0+5ALKo5wBYmoUERnNQg/L5R0DegJU9CL/E/wZLGjYdaINIKKbVA2amYbc86yP1m2O oy0emDSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iefXz-0006Kj-4p; Tue, 10 Dec 2019 13:27:27 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iefV7-00028O-HS for linux-rockchip@lists.infradead.org; Tue, 10 Dec 2019 13:24:31 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D18F2113E; Tue, 10 Dec 2019 05:24:28 -0800 (PST) Received: from DESKTOP-VLO843J.cambridge.arm.com (DESKTOP-VLO843J.cambridge.arm.com [10.1.26.198]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E38343F52E; Tue, 10 Dec 2019 05:24:27 -0800 (PST) From: Robin Murphy To: lee.jones@linaro.org Subject: [PATCH 2/4] mfd: rk808: Always register syscore ops Date: Tue, 10 Dec 2019 13:24:31 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191210_052429_643436_D6049A8E X-CRM114-Status: GOOD ( 11.42 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux.amoon@gmail.com, linux-rockchip@lists.infradead.org, smoch@web.de, linux-kernel@vger.kernel.org, heiko@sntech.de MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Registering the syscore shutdown notifier even when it's a no-op for the given RK8xx variant should be harmless, and saves a lot of bother in handling unregistering on probe failure or module removal, which has been woefully lacking. Signed-off-by: Robin Murphy --- drivers/mfd/rk808.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index f2f2f98552a0..387105830736 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -623,7 +623,6 @@ static int rk808_probe(struct i2c_client *client, nr_pre_init_regs = ARRAY_SIZE(rk817_pre_init_reg); cells = rk817s; nr_cells = ARRAY_SIZE(rk817s); - register_syscore_ops(&rk808_syscore_ops); break; default: dev_err(&client->dev, "Unsupported RK8XX ID %lu\n", @@ -667,6 +666,7 @@ static int rk808_probe(struct i2c_client *client, } rk808_i2c_client = client; + register_syscore_ops(&rk808_syscore_ops); ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE, cells, nr_cells, NULL, 0, @@ -684,6 +684,7 @@ static int rk808_probe(struct i2c_client *client, return 0; err_irq: + unregister_syscore_ops(&rk808_syscore_ops); regmap_del_irq_chip(client->irq, rk808->irq_data); return ret; } @@ -694,6 +695,8 @@ static int rk808_remove(struct i2c_client *client) regmap_del_irq_chip(client->irq, rk808->irq_data); + unregister_syscore_ops(&rk808_syscore_ops); + /** * pm_power_off may points to a function from another module. * Check if the pointer is set by us and only then overwrite it. From patchwork Tue Dec 10 13:24:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 11282449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABDAE15AB for ; Tue, 10 Dec 2019 13:27:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 857212073B for ; Tue, 10 Dec 2019 13:27:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="d4tYWdvN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 857212073B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org 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=s3jv7fzULu+C5iZ9VcniI2OqgHjb2poPyqy4XseTAdY=; b=d4tYWdvN+Ne8cleoxUScvqUINB pauKMej9PgXspBRNWY34q59+S1tjwIaI73P/rd6ELF/Hix2qVwMd9XXj8USjGDNp5VqPHggogZ+NG +priUKTO3PqnV+NtuwiAwjCXAfP2UJiwyu7yVJ0xwIxl/XzoUw3H0LOwoaVd2IasEeie1Jz+yqKoQ 1Vr30x3kTPqHaRPF5CelG2b+bb3qbgs1J39ivlM1l1GBgRGnV5nQcxjqW7Z7NQ+wmtG8dD2P8rDYU Yidr79wQmLg6ObwOlvahItKODVHqE1ZZOcAFT3J8URTR8NHKP3jk8XjMLvTYRLC8S/s/JTnbfjnMD taeA9ZdQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iefY4-0006Pd-FU; Tue, 10 Dec 2019 13:27:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iefV8-00029c-M5 for linux-rockchip@lists.infradead.org; Tue, 10 Dec 2019 13:24:32 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0C03D328; Tue, 10 Dec 2019 05:24:30 -0800 (PST) Received: from DESKTOP-VLO843J.cambridge.arm.com (DESKTOP-VLO843J.cambridge.arm.com [10.1.26.198]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1EE7B3F52E; Tue, 10 Dec 2019 05:24:29 -0800 (PST) From: Robin Murphy To: lee.jones@linaro.org Subject: [PATCH 3/4] mfd: rk808: Reduce shutdown duplication Date: Tue, 10 Dec 2019 13:24:32 +0000 Message-Id: <2376f722b917f55cbf49c5f3da0c341457900dee.1575932654.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191210_052430_862434_A8CE8BDB X-CRM114-Status: GOOD ( 15.61 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux.amoon@gmail.com, linux-rockchip@lists.infradead.org, smoch@web.de, linux-kernel@vger.kernel.org, heiko@sntech.de MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Rather than having 3 almost-identical functions plus the machinery to keep track of them, it's far simpler to just dynamically select the appropriate register field per variant. Signed-off-by: Robin Murphy --- drivers/mfd/rk808.c | 56 +++++++++++++-------------------------- include/linux/mfd/rk808.h | 1 - 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index 387105830736..657b8baa3b8a 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -449,21 +449,6 @@ static const struct regmap_irq_chip rk818_irq_chip = { static struct i2c_client *rk808_i2c_client; -static void rk805_device_shutdown(void) -{ - int ret; - struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); - - if (!rk808) - return; - - ret = regmap_update_bits(rk808->regmap, - RK805_DEV_CTRL_REG, - DEV_OFF, DEV_OFF); - if (ret) - dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n"); -} - static void rk805_device_shutdown_prepare(void) { int ret; @@ -482,29 +467,29 @@ static void rk805_device_shutdown_prepare(void) static void rk808_device_shutdown(void) { int ret; + unsigned int reg, bit; struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); if (!rk808) return; - ret = regmap_update_bits(rk808->regmap, - RK808_DEVCTRL_REG, - DEV_OFF_RST, DEV_OFF_RST); - if (ret) - dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n"); -} - -static void rk818_device_shutdown(void) -{ - int ret; - struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); - - if (!rk808) + switch (rk808->variant) { + case RK805_ID: + reg = RK805_DEV_CTRL_REG; + bit = DEV_OFF; + break; + case RK808_ID: + reg = RK808_DEVCTRL_REG, + bit = DEV_OFF_RST; + break; + case RK818_ID: + reg = RK818_DEVCTRL_REG; + bit = DEV_OFF; + break; + default: return; - - ret = regmap_update_bits(rk808->regmap, - RK818_DEVCTRL_REG, - DEV_OFF, DEV_OFF); + } + ret = regmap_update_bits(rk808->regmap, reg, bit, bit); if (ret) dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n"); } @@ -594,7 +579,6 @@ static int rk808_probe(struct i2c_client *client, nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg); cells = rk805s; nr_cells = ARRAY_SIZE(rk805s); - rk808->pm_pwroff_fn = rk805_device_shutdown; rk808->pm_pwroff_prep_fn = rk805_device_shutdown_prepare; break; case RK808_ID: @@ -604,7 +588,6 @@ static int rk808_probe(struct i2c_client *client, nr_pre_init_regs = ARRAY_SIZE(rk808_pre_init_reg); cells = rk808s; nr_cells = ARRAY_SIZE(rk808s); - rk808->pm_pwroff_fn = rk808_device_shutdown; break; case RK818_ID: rk808->regmap_cfg = &rk818_regmap_config; @@ -613,7 +596,6 @@ static int rk808_probe(struct i2c_client *client, nr_pre_init_regs = ARRAY_SIZE(rk818_pre_init_reg); cells = rk818s; nr_cells = ARRAY_SIZE(rk818s); - rk808->pm_pwroff_fn = rk818_device_shutdown; break; case RK809_ID: case RK817_ID: @@ -677,7 +659,7 @@ static int rk808_probe(struct i2c_client *client, } if (of_property_read_bool(np, "rockchip,system-power-controller")) { - pm_power_off = rk808->pm_pwroff_fn; + pm_power_off = rk808_device_shutdown; pm_power_off_prepare = rk808->pm_pwroff_prep_fn; } @@ -701,7 +683,7 @@ static int rk808_remove(struct i2c_client *client) * pm_power_off may points to a function from another module. * Check if the pointer is set by us and only then overwrite it. */ - if (rk808->pm_pwroff_fn && pm_power_off == rk808->pm_pwroff_fn) + if (pm_power_off == rk808_device_shutdown) pm_power_off = NULL; /** diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h index a59bf323f713..b038653fa87e 100644 --- a/include/linux/mfd/rk808.h +++ b/include/linux/mfd/rk808.h @@ -620,7 +620,6 @@ struct rk808 { long variant; const struct regmap_config *regmap_cfg; const struct regmap_irq_chip *regmap_irq_chip; - void (*pm_pwroff_fn)(void); void (*pm_pwroff_prep_fn)(void); }; #endif /* __LINUX_REGULATOR_RK808_H */ From patchwork Tue Dec 10 13:24:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 11282451 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D693815AB for ; Tue, 10 Dec 2019 13:27:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B02122073B for ; Tue, 10 Dec 2019 13:27:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qUaf5C2S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B02122073B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org 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=DWXepmcTEUiFYB8Mo0MQNseJKhuSl4VuSh2aTmfl2PI=; b=qUaf5C2Srfuhtp/naG9xAFuQE1 hLIbCx/5HYTpccJCtSc+FTeD5QFNmGTogGlplmRF713dV4+J8Sh1q4C5SGg3HrsB8v1Vy6JsbR+hf Njkbun8Y+uu5t78N3Tpk7O0urk5DehIJ880y1GS2CyyXA/L6dQfRXVgLJPWmNx0U7n5DosbQt9FZp Q9rkXAPwl8u1vtUVpjM7BulLHoX9N1puOxgqC3/DUgycwzznFMQHxdIWSdp3R/1lFCrh8LgyFQhsw 2d6ar0yIQQs79I3pIjRECwUOHhRHgfGTttdfv8gdieap6PEldMNAWETWQneMC35/GtMgxOTC1wAbP 0vQeBtJA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iefY8-0006Rd-5Q; Tue, 10 Dec 2019 13:27:36 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iefV9-0002At-TP for linux-rockchip@lists.infradead.org; Tue, 10 Dec 2019 13:24:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 39A411045; Tue, 10 Dec 2019 05:24:31 -0800 (PST) Received: from DESKTOP-VLO843J.cambridge.arm.com (DESKTOP-VLO843J.cambridge.arm.com [10.1.26.198]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4DD263F52E; Tue, 10 Dec 2019 05:24:30 -0800 (PST) From: Robin Murphy To: lee.jones@linaro.org Subject: [PATCH 4/4] mfd: rk808: Convert RK805 to syscore/PM ops Date: Tue, 10 Dec 2019 13:24:33 +0000 Message-Id: <8642045f0657c9e782cd698eb08777c9d4c10c8d.1575932654.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191210_052432_046693_7D0F4B08 X-CRM114-Status: GOOD ( 16.80 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux.amoon@gmail.com, linux-rockchip@lists.infradead.org, smoch@web.de, linux-kernel@vger.kernel.org, heiko@sntech.de MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org RK805 has the same kind of dual-role sleep/shutdown pin as RK809/RK817, so it makes little sense for the driver to have to have two completely different mechanisms to handle essentially the same thing. Bring RK805 in line with the RK809/RK817 flow to clean things up. Signed-off-by: Robin Murphy --- drivers/mfd/rk808.c | 58 +++++++++++++++++---------------------- include/linux/mfd/rk808.h | 1 - 2 files changed, 25 insertions(+), 34 deletions(-) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index 657b8baa3b8a..e88bdb889d3a 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -186,7 +186,6 @@ static const struct rk808_reg_data rk805_pre_init_reg[] = { {RK805_BUCK4_CONFIG_REG, RK805_BUCK3_4_ILMAX_MASK, RK805_BUCK4_ILMAX_3500MA}, {RK805_BUCK4_CONFIG_REG, BUCK_ILMIN_MASK, BUCK_ILMIN_400MA}, - {RK805_GPIO_IO_POL_REG, SLP_SD_MSK, SLEEP_FUN}, {RK805_THERMAL_REG, TEMP_HOTDIE_MSK, TEMP115C}, }; @@ -449,21 +448,6 @@ static const struct regmap_irq_chip rk818_irq_chip = { static struct i2c_client *rk808_i2c_client; -static void rk805_device_shutdown_prepare(void) -{ - int ret; - struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); - - if (!rk808) - return; - - ret = regmap_update_bits(rk808->regmap, - RK805_GPIO_IO_POL_REG, - SLP_SD_MSK, SHUTDOWN_FUN); - if (ret) - dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n"); -} - static void rk808_device_shutdown(void) { int ret; @@ -499,17 +483,29 @@ static void rk8xx_syscore_shutdown(void) struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); int ret; - if (system_state == SYSTEM_POWER_OFF && - (rk808->variant == RK809_ID || rk808->variant == RK817_ID)) { + if (system_state != SYSTEM_POWER_OFF) + return; + + switch (rk808->variant) { + case RK805_ID: + ret = regmap_update_bits(rk808->regmap, + RK805_GPIO_IO_POL_REG, + SLP_SD_MSK, + SHUTDOWN_FUN); + break; + case RK809_ID: + case RK817_ID: ret = regmap_update_bits(rk808->regmap, RK817_SYS_CFG(3), RK817_SLPPIN_FUNC_MSK, SLPPIN_DN_FUN); - if (ret) { - dev_warn(&rk808_i2c_client->dev, - "Cannot switch to power down function\n"); - } + break; + default: + return; } + if (ret) + dev_warn(&rk808_i2c_client->dev, + "Cannot switch to power down function\n"); } static struct syscore_ops rk808_syscore_ops = { @@ -579,7 +575,6 @@ static int rk808_probe(struct i2c_client *client, nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg); cells = rk805s; nr_cells = ARRAY_SIZE(rk805s); - rk808->pm_pwroff_prep_fn = rk805_device_shutdown_prepare; break; case RK808_ID: rk808->regmap_cfg = &rk808_regmap_config; @@ -658,10 +653,8 @@ static int rk808_probe(struct i2c_client *client, goto err_irq; } - if (of_property_read_bool(np, "rockchip,system-power-controller")) { + if (of_property_read_bool(np, "rockchip,system-power-controller")) pm_power_off = rk808_device_shutdown; - pm_power_off_prepare = rk808->pm_pwroff_prep_fn; - } return 0; @@ -686,13 +679,6 @@ static int rk808_remove(struct i2c_client *client) if (pm_power_off == rk808_device_shutdown) pm_power_off = NULL; - /** - * As above, check if the pointer is set by us before overwrite. - */ - if (rk808->pm_pwroff_prep_fn && - pm_power_off_prepare == rk808->pm_pwroff_prep_fn) - pm_power_off_prepare = NULL; - return 0; } @@ -702,6 +688,12 @@ static int __maybe_unused rk8xx_suspend(struct device *dev) int ret = 0; switch (rk808->variant) { + case RK805_ID: + ret = regmap_update_bits(rk808->regmap, + RK805_GPIO_IO_POL_REG, + SLP_SD_MSK, + SLEEP_FUN); + break; case RK809_ID: case RK817_ID: ret = regmap_update_bits(rk808->regmap, diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h index b038653fa87e..e07f6e61cd38 100644 --- a/include/linux/mfd/rk808.h +++ b/include/linux/mfd/rk808.h @@ -620,6 +620,5 @@ struct rk808 { long variant; const struct regmap_config *regmap_cfg; const struct regmap_irq_chip *regmap_irq_chip; - void (*pm_pwroff_prep_fn)(void); }; #endif /* __LINUX_REGULATOR_RK808_H */