From patchwork Thu Jul 26 18:36:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Parameswaran X-Patchwork-Id: 10546307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC6A514BC for ; Thu, 26 Jul 2018 18:37:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEF4F2BBFF for ; Thu, 26 Jul 2018 18:37:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D071D2BC02; Thu, 26 Jul 2018 18:37:54 +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 801D72BBFF for ; Thu, 26 Jul 2018 18:37:54 +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=fiOp8n75ejrbw2C4WYBGRfoBw13U6HhLlyOqLk9VFUs=; b=gFFu8/mn5fyTfCsT94Td1tPEiV wzUneLgJL2JWETxo2FA9vRuYltqVifpeCe4uAi4oc4EnSoyBadtrEC4ICj9PPH82O2dZ3Gp1q4Jw9 Qn/I4nCjaz0cuNgUMT5nsk3rpTakTD5DCnoZUqo8JkdFl/0Ao2BladqnBb+/3Tub1ugw70eFon2e1 pTlZg0DORfdoNc8Ctk8oSIEvALT1oxnhO6CetkVx53CbnlauOjir5odowYLmVqFKM3v9E2uwRWtz5 I5HTHx24FP/JKZFv6PUEbzms3FH5y5Fw2cRFcetDaLLJWtPrKUYsC/5LClJMHa48JtIW6z51WuGF5 axdrxTkg==; 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 1fil93-0002Ka-EP; Thu, 26 Jul 2018 18:37:49 +0000 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fil87-0000uC-VW for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2018 18:36:53 +0000 Received: by mail-qt0-x244.google.com with SMTP id e19-v6so2572977qtp.8 for ; Thu, 26 Jul 2018 11:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U06FaEejxyxvjAYaxOat2qv5fl7gaHh65Nf8HRFkW30=; b=iKW1K+zFeuKqGM3QvPsDT28zCqN+1KJCTfmkloSeyTV98rdaEczFQrO+5w92nftoOH 8YjpOYcg9GsfLVwbQLv1FaV8rcQjrNv8jgm5Ybk8a6yQCSeS0jbAFxOHlPxMiqA8w3Qo YCKPlCnUW2Lyu7OuMiGg5T/0J8wnxbSmkUoVQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U06FaEejxyxvjAYaxOat2qv5fl7gaHh65Nf8HRFkW30=; b=fckPng/9XddMkXUHHEKzC2Z4OFSkZ6saDlGW40LSGCxaUEgFGObcOy2qkRD+e4jsAO qC5NYML965X08kTk2RUMgDzHnTvUUVF4gGdqNTRRz8jiZcROyLRw3rhyJAv5LrLqxUZ0 AYeSsnB4VJpCkJEs0d3bwZxTHv2Y+SMmGZuceKfLgE0GTiT516tILk16FjRLiqgFYdLt PWsWTYC7jZBGVRolKki5Xy/ZU6yKjGf0+hRwF1RAKTbl3uqBJc/XsKG2ct9shb83cd9Y we2Kt57WNxTjCYXA5IAy8SdPrvvGaJaZOOY20fIaP98obC75PEaXBUdqi8byJfYRB9Vb UXIQ== X-Gm-Message-State: AOUpUlFYTUG3Us9twYKO0qXpBjzhR2Hf1Zdwtaeoe2s7txgJrZUqMNbv pHl3UaLIYFVJVxwmBJw9K+EC0A== X-Google-Smtp-Source: AAOMgpcHy5ED9ay2VhEUp4xZ8PGdvBS6bC6RmPb5qWrtzTuBDgM+pRtFgf9yyTj1NCKJixohwNUeQQ== X-Received: by 2002:a0c:8441:: with SMTP id l59-v6mr2785673qva.5.1532630200886; Thu, 26 Jul 2018 11:36:40 -0700 (PDT) Received: from lbrmn-lnxub86.ric.broadcom.com ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id a187-v6sm1383359qkd.47.2018.07.26.11.36.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Jul 2018 11:36:40 -0700 (PDT) From: Arun Parameswaran To: "David S. Miller" , Florian Fainelli , Andrew Lunn , Rob Herring , Mark Rutland , Ray Jui , Scott Branden , Catalin Marinas , Will Deacon Subject: [PATCH 6/7] net: phy: Add pm support to Broadcom iProc mdio mux driver Date: Thu, 26 Jul 2018 11:36:23 -0700 Message-Id: <1532630184-29450-7-git-send-email-arun.parameswaran@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532630184-29450-1-git-send-email-arun.parameswaran@broadcom.com> References: <1532630184-29450-1-git-send-email-arun.parameswaran@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180726_113652_165159_1BFB065E X-CRM114-Status: GOOD ( 16.03 ) 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, netdev@vger.kernel.org, Arun Parameswaran , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, 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 Add support for suspend and resume to the Broadcom iProc mdio mux driver. Signed-off-by: Arun Parameswaran --- drivers/net/phy/mdio-mux-bcm-iproc.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c index 6b400dd..89c18d6 100644 --- a/drivers/net/phy/mdio-mux-bcm-iproc.c +++ b/drivers/net/phy/mdio-mux-bcm-iproc.c @@ -51,13 +51,25 @@ #define MDIO_OPERATING_FREQUENCY 11000000 #define MDIO_RATE_ADJ_DIVIDENT 1 +#define MDIO_NUM_OF_REGS_TO_RESTORE 2 + struct iproc_mdiomux_desc { void *mux_handle; void __iomem *base; struct device *dev; struct mii_bus *mii_bus; struct clk *core_clk; +#ifdef CONFIG_PM_SLEEP + u32 restore_regs[MDIO_NUM_OF_REGS_TO_RESTORE]; +#endif +}; + +#ifdef CONFIG_PM_SLEEP +static const u16 restore_reg_offsets[MDIO_NUM_OF_REGS_TO_RESTORE] = { + MDIO_RATE_ADJ_EXT_OFFSET, + MDIO_RATE_ADJ_INT_OFFSET, }; +#endif static void mdio_mux_iproc_config_clk(struct iproc_mdiomux_desc *md) { @@ -258,6 +270,35 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int mdio_mux_iproc_suspend(struct device *dev) +{ + int i; + struct iproc_mdiomux_desc *md = dev_get_drvdata(dev); + + for (i = 0; i < MDIO_NUM_OF_REGS_TO_RESTORE; i++) + md->restore_regs[i] = readl(md->base + + restore_reg_offsets[i]); + + return 0; +} + +static int mdio_mux_iproc_resume(struct device *dev) +{ + int i; + struct iproc_mdiomux_desc *md = dev_get_drvdata(dev); + + for (i = 0; i < MDIO_NUM_OF_REGS_TO_RESTORE; i++) + writel(md->restore_regs[i], + md->base + restore_reg_offsets[i]); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(mdio_mux_iproc_pm_ops, + mdio_mux_iproc_suspend, mdio_mux_iproc_resume); + static const struct of_device_id mdio_mux_iproc_match[] = { { .compatible = "brcm,mdio-mux-iproc", @@ -270,6 +311,7 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev) .driver = { .name = "mdio-mux-iproc", .of_match_table = mdio_mux_iproc_match, + .pm = &mdio_mux_iproc_pm_ops, }, .probe = mdio_mux_iproc_probe, .remove = mdio_mux_iproc_remove,