From patchwork Thu Nov 19 21:22:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 7661641 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 87942BF90C for ; Thu, 19 Nov 2015 21:25:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B5682205F4 for ; Thu, 19 Nov 2015 21:25:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D1AE2205B1 for ; Thu, 19 Nov 2015 21:25:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZzWhZ-00051k-AX; Thu, 19 Nov 2015 21:25:09 +0000 Received: from gloria.sntech.de ([95.129.55.99]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZzWfu-0003Jb-IT; Thu, 19 Nov 2015 21:23:29 +0000 Received: from [195.53.26.172] (helo=phil.sntech) by gloria.sntech.de with esmtpsa (TLS1.1:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZzWfT-0002ae-36; Thu, 19 Nov 2015 22:22:59 +0100 From: Heiko Stuebner To: kishon@ti.com, mturquette@baylibre.com, sboyd@codeaurora.org Subject: [PATCH v3 2/8] phy: rockchip-usb: introduce a common data-struct for the device Date: Thu, 19 Nov 2015 22:22:23 +0100 Message-Id: <1447968149-10979-3-git-send-email-heiko@sntech.de> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1447968149-10979-1-git-send-email-heiko@sntech.de> References: <1447968149-10979-1-git-send-email-heiko@sntech.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151119_132326_914453_18727744 X-CRM114-Status: GOOD ( 12.20 ) X-Spam-Score: -3.2 (---) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hl@rock-chips.com, arnd@arndb.de, linux-kernel@vger.kernel.org, dianders@chromium.org, linux-rockchip@lists.infradead.org, romain.perier@gmail.com, linux-arm-kernel@lists.infradead.org, Heiko Stuebner MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This introduces a common struct that holds data belonging to the umbrella device that contains all the phys and that we want to use later. Signed-off-by: Heiko Stuebner Reviewed-by: Douglas Anderson --- drivers/phy/phy-rockchip-usb.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c index e941444..2b4802a 100644 --- a/drivers/phy/phy-rockchip-usb.c +++ b/drivers/phy/phy-rockchip-usb.c @@ -36,9 +36,14 @@ #define SIDDQ_ON BIT(13) #define SIDDQ_OFF (0 << 13) +struct rockchip_usb_phy_base { + struct device *dev; + struct regmap *reg_base; +}; + struct rockchip_usb_phy { + struct rockchip_usb_phy_base *base; unsigned int reg_offset; - struct regmap *reg_base; struct clk *clk; struct phy *phy; }; @@ -46,7 +51,7 @@ struct rockchip_usb_phy { static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy, bool siddq) { - return regmap_write(phy->reg_base, phy->reg_offset, + return regmap_write(phy->base->reg_base, phy->reg_offset, SIDDQ_WRITE_ENA | (siddq ? SIDDQ_ON : SIDDQ_OFF)); } @@ -101,17 +106,23 @@ static void rockchip_usb_phy_action(void *data) static int rockchip_usb_phy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct rockchip_usb_phy_base *phy_base; struct rockchip_usb_phy *rk_phy; struct phy_provider *phy_provider; struct device_node *child; - struct regmap *grf; unsigned int reg_offset; int err; - grf = syscon_regmap_lookup_by_phandle(dev->of_node, "rockchip,grf"); - if (IS_ERR(grf)) { + phy_base = devm_kzalloc(dev, sizeof(*phy_base), GFP_KERNEL); + if (!phy_base) + return -ENOMEM; + + phy_base->dev = dev; + phy_base->reg_base = syscon_regmap_lookup_by_phandle(dev->of_node, + "rockchip,grf"); + if (IS_ERR(phy_base->reg_base)) { dev_err(&pdev->dev, "Missing rockchip,grf property\n"); - return PTR_ERR(grf); + return PTR_ERR(phy_base->reg_base); } for_each_available_child_of_node(dev->of_node, child) { @@ -121,6 +132,8 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev) goto put_child; } + rk_phy->base = phy_base; + if (of_property_read_u32(child, "reg", ®_offset)) { dev_err(dev, "missing reg property in node %s\n", child->name); @@ -129,7 +142,6 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev) } rk_phy->reg_offset = reg_offset; - rk_phy->reg_base = grf; err = devm_add_action(dev, rockchip_usb_phy_action, rk_phy); if (err)