From patchwork Mon Jan 16 06:45:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 91539 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1290776qgi; Sun, 15 Jan 2017 22:46:00 -0800 (PST) X-Received: by 10.98.106.132 with SMTP id f126mr7116434pfc.1.1484549160531; Sun, 15 Jan 2017 22:46:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o9si16754054pfo.60.2017.01.15.22.46.00; Sun, 15 Jan 2017 22:46:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751432AbdAPGp5 (ORCPT + 13 others); Mon, 16 Jan 2017 01:45:57 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:19939 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751358AbdAPGpc (ORCPT ); Mon, 16 Jan 2017 01:45:32 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OJV00FN31FTR450@mailout4.w1.samsung.com>; Mon, 16 Jan 2017 06:45:29 +0000 (GMT) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170116064528eucas1p25b291bfbf4f2601d411ee1ede3e2d8b5~aLZElnPxK2654126541eucas1p2H; Mon, 16 Jan 2017 06:45:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges4.samsung.com (EUCPMTA) with SMTP id DC.0A.28517.80C6C785; Mon, 16 Jan 2017 06:45:28 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170116064527eucas1p1f0f78e9420e7d9d60d94b6e7381caeb1~aLZEBW-Wq1341013410eucas1p1I; Mon, 16 Jan 2017 06:45:27 +0000 (GMT) X-AuditID: cbfec7f4-f79716d000006f65-fd-587c6c08b166 Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E2.B9.10233.20C6C785; Mon, 16 Jan 2017 06:45:22 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OJV00BS81FJUN70@eusync2.samsung.com>; Mon, 16 Jan 2017 06:45:27 +0000 (GMT) From: Marek Szyprowski To: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Krzysztof Kozlowski , Linus Walleij , Tomasz Figa , Bartlomiej Zolnierkiewicz Subject: [PATCH 09/12] pinctrl: samsung: Add infrastructure for pin-bank retention control Date: Mon, 16 Jan 2017 07:45:04 +0100 Message-id: <1484549107-5957-10-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1484549107-5957-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLIsWRmVeSWpSXmKPExsWy7djP87ocOTURBsuaRC02zljPanH+/AZ2 iyl/ljNZbHp8jdVi8/w/jBafe48wWsw4v4/JYu2Ru+wWh9+0s1qs2vWH0YHLY+esu+wem1Z1 snncubaHzWPzknqPvi2rGD0+b5ILYIvisklJzcksSy3St0vgyvjz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RgWZGiYYlvWAO s8AEJomZnxqYQKqEBWIkNr9uZAexWQRUJW4+bwaL8wp4SMy+sJIFYp+cxMljk1lBbE6g+MR9 rWBxIQF3iRmvpjJPYORdwMiwilEktbQ4Nz232EivODG3uDQvXS85P3cTIzDstx37uWUHY9e7 4EOMAhyMSjy8C3ZURwixJpYVV+YeYpTgYFYS4XXLrIkQ4k1JrKxKLcqPLyrNSS0+xGgKdNRE ZinR5HxgTOaVxBuaGJpbGhoZW1iYGxkpifNO/XAlXEggPbEkNTs1tSC1CKaPiYNTqoHRd8d6 vVULyvs/f33iO+vzaad54Y+OfHttuHCDVdOND93Tj8e287kdlTtW72glvv7X8rX1+nP/xVz0 6VLjWbj1+qz4VzcqOuYcfLSca7+XXG/+2o4jBfscpnI6rlz7qr15BtvP65OSH99ZnPtgYoOJ aYGgVds7t2Rds5lrztr+KrVMVmMv4V+sqcRSnJFoqMVcVJwIAGgs7NCRAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170116064527eucas1p1f0f78e9420e7d9d60d94b6e7381caeb1 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170116064527eucas1p1f0f78e9420e7d9d60d94b6e7381caeb1 X-RootMTR: 20170116064527eucas1p1f0f78e9420e7d9d60d94b6e7381caeb1 References: <1484549107-5957-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Pad retention control after suspend/resume cycle should be done from pin controller driver instead of PMU (power management unit) driver to avoid possible ordering and logical dependencies. Till now it worked fine only because PMU driver registered its sys_ops after pin controller. This patch adds infrastructure to handle pad retention during pin control driver resume. Signed-off-by: Marek Szyprowski --- drivers/pinctrl/samsung/pinctrl-samsung.c | 12 ++++++--- drivers/pinctrl/samsung/pinctrl-samsung.h | 42 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 86f23842f681..95a84086a2e9 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -1075,6 +1075,9 @@ static int samsung_pinctrl_probe(struct platform_device *pdev) ctrl->eint_gpio_init(drvdata); if (ctrl->eint_wkup_init) ctrl->eint_wkup_init(drvdata); + if (ctrl->retention_data && ctrl->retention_data->init) + drvdata->retention_ctrl = ctrl->retention_data->init(drvdata, + ctrl->retention_data); platform_set_drvdata(pdev, drvdata); @@ -1127,15 +1130,15 @@ static void samsung_pinctrl_suspend_dev( if (drvdata->suspend) drvdata->suspend(drvdata); + if (drvdata->retention_ctrl && drvdata->retention_ctrl->on) + drvdata->retention_ctrl->on(drvdata); + } /** * samsung_pinctrl_resume_dev - restore pinctrl state from suspend for a device * * Restore one of the banks that was saved during suspend. - * - * We don't bother doing anything complicated to avoid glitching lines since - * we're called before pad retention is turned off. */ static void samsung_pinctrl_resume_dev(struct samsung_pinctrl_drv_data *drvdata) { @@ -1174,6 +1177,9 @@ static void samsung_pinctrl_resume_dev(struct samsung_pinctrl_drv_data *drvdata) if (widths[type]) writel(bank->pm_save[type], reg + offs[type]); } + + if (drvdata->retention_ctrl && drvdata->retention_ctrl->off) + drvdata->retention_ctrl->off(drvdata); } /** diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.h b/drivers/pinctrl/samsung/pinctrl-samsung.h index 6f7ce7539a00..6079142422f8 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.h +++ b/drivers/pinctrl/samsung/pinctrl-samsung.h @@ -185,10 +185,48 @@ struct samsung_pin_bank { }; /** + * struct samsung_retention_data: runtime pin-bank retention control data. + * @regs: array of PMU registers to control pad retention. + * @nr_regs: number of registers in @regs array. + * @value: value to store to registers to turn off retention. + * @refcnt: atomic counter if retention control affects more than one bank. + * @priv: retention control code private data + * @on: platform specific callback to enter retention mode. + * @off: platform specific callback to exit retention mode. + **/ +struct samsung_retention_ctrl { + const u32 *regs; + int nr_regs; + u32 value; + atomic_t *refcnt; + void *priv; + void (*on)(struct samsung_pinctrl_drv_data *); + void (*off)(struct samsung_pinctrl_drv_data *); +}; + +/** + * struct samsung_retention_data: represent a pin-bank retention control data. + * @regs: array of PMU registers to control pad retention. + * @nr_regs: number of registers in @regs array. + * @value: value to store to registers to turn off retention. + * @refcnt: atomic counter if retention control affects more than one bank. + * @init: platform specific callback to initialize retention control. + **/ +struct samsung_retention_data { + const u32 *regs; + int nr_regs; + u32 value; + atomic_t *refcnt; + struct samsung_retention_ctrl *(*init)(struct samsung_pinctrl_drv_data *, + const struct samsung_retention_data *); +}; + +/** * struct samsung_pin_ctrl: represent a pin controller. * @pin_banks: list of pin banks included in this controller. * @nr_banks: number of pin banks. * @nr_ext_resources: number of the extra base address for pin banks. + * @retention_data: configuration data for retention control. * @eint_gpio_init: platform specific callback to setup the external gpio * interrupts for the controller. * @eint_wkup_init: platform specific callback to setup the external wakeup @@ -198,6 +236,7 @@ struct samsung_pin_ctrl { const struct samsung_pin_bank_data *pin_banks; u32 nr_banks; int nr_ext_resources; + const struct samsung_retention_data *retention_data; int (*eint_gpio_init)(struct samsung_pinctrl_drv_data *); int (*eint_wkup_init)(struct samsung_pinctrl_drv_data *); @@ -219,6 +258,7 @@ struct samsung_pin_ctrl { * @nr_function: number of such pin functions. * @pin_base: starting system wide pin number. * @nr_pins: number of pins supported by the controller. + * @retention_ctrl: retention control runtime data. */ struct samsung_pinctrl_drv_data { struct list_head node; @@ -238,6 +278,8 @@ struct samsung_pinctrl_drv_data { unsigned int pin_base; unsigned int nr_pins; + const struct samsung_retention_ctrl *retention_ctrl; + void (*suspend)(struct samsung_pinctrl_drv_data *); void (*resume)(struct samsung_pinctrl_drv_data *); };