From patchwork Mon Jun 21 09:39:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 12334277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D563CC48BE5 for ; Mon, 21 Jun 2021 09:39:56 +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 9EEF3611BD for ; Mon, 21 Jun 2021 09:39:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EEF3611BD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FW2wSmNaZpKMKcOKmS83Ug0glq4coYqltBfD7iX8sc4=; b=x+XTxWCxwoPOqB QKtVv0cmm3a5H04zbANrcj2VATTs8fPGJpeq2rctwKezbJ2HNymK4S0SuJXunDO4mBA9RsLIeccai q8hch9D3qUp1F+8w7wb8dP5M2n9amlrrQiul8kW+Nh+ybqSUS89g3hDEYX1LYMsLscGHJjNdkBAE/ pi+BLU1gIW1KeLSJMtCLerPGpWN4dNm+JtBTb0jPNCOXpxYZpPoD6UMUCXBA+jPzVMaAqyQJpMx2P P1Ect2iDrTeo6FzlnNiT/tIBVpHNhp4XIfxv27RzUfN/iJZkZrLo0uARY5Vk5ceBgexHCnSqLiL8h /shu1B+dhri3Rd1oCD3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvGPM-002xKc-51; Mon, 21 Jun 2021 09:39:56 +0000 Received: from relmlor1.renesas.com ([210.160.252.171] helo=relmlie5.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvGPJ-002xJb-Am for linux-phy@lists.infradead.org; Mon, 21 Jun 2021 09:39:54 +0000 X-IronPort-AV: E=Sophos;i="5.83,289,1616425200"; d="scan'208";a="85045858" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 21 Jun 2021 18:39:52 +0900 Received: from localhost.localdomain (unknown [10.226.92.241]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id EEB0A400C4C3; Mon, 21 Jun 2021 18:39:49 +0900 (JST) From: Biju Das To: Rob Herring Cc: Biju Das , Kishon Vijay Abraham I , Vinod Koul , Yoshihiro Shimoda , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Biju Das , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 01/11] dt-bindings: phy: renesas: Document RZ/G2L USB PHY Control bindings Date: Mon, 21 Jun 2021 10:39:33 +0100 Message-Id: <20210621093943.12143-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210621093943.12143-1-biju.das.jz@bp.renesas.com> References: <20210621093943.12143-1-biju.das.jz@bp.renesas.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210621_023953_529450_1258A4C2 X-CRM114-Status: GOOD ( 10.10 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Add device tree binding document for RZ/G2L USB PHY control driver. Signed-off-by: Biju Das Reviewed-by: Lad Prabhakar --- V1->V2: * Add clock properties --- .../phy/renesas,rzg2l-usbphyctrl.yaml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/renesas,rzg2l-usbphyctrl.yaml diff --git a/Documentation/devicetree/bindings/phy/renesas,rzg2l-usbphyctrl.yaml b/Documentation/devicetree/bindings/phy/renesas,rzg2l-usbphyctrl.yaml new file mode 100644 index 000000000000..8e8ba43f595d --- /dev/null +++ b/Documentation/devicetree/bindings/phy/renesas,rzg2l-usbphyctrl.yaml @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/renesas,rzg2l-usbphyctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas RZ/G2L USB2.0 PHY Control + +maintainers: + - Biju Das + +description: + The RZ/G2L USB2.0 PHY Control mainly controls reset and power down of the + USB/PHY. + +properties: + compatible: + items: + - enum: + - renesas,r9a07g044-usbphyctrl # RZ/G2{L,LC} + - const: renesas,rzg2l-usbphyctrl + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + resets: + maxItems: 1 + + power-domains: + maxItems: 1 + + '#phy-cells': + # see phy-bindings.txt in the same directory + const: 1 + description: | + The phandle's argument in the PHY specifier is the phy reset control bit + of usb phy control. + 0 = Port 1 Phy reset + 1 = Port 2 Phy reset + enum: [ 0, 1 ] + +required: + - compatible + - reg + - clocks + - '#phy-cells' + +additionalProperties: false + +examples: + - | + #include + + usbphyctrl@11c40000 { + compatible = "renesas,r9a07g044-usbphyctrl", + "renesas,rzg2l-usbphyctrl"; + reg = <0x11c40000 0x10000>; + clocks = <&cpg CPG_MOD R9A07G044_USB_PCLK>; + resets = <&cpg R9A07G044_USB_PCLK>; + power-domains = <&cpg>; + #phy-cells = <1>; + }; From patchwork Mon Jun 21 09:39:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 12334279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34DCEC48BE5 for ; Mon, 21 Jun 2021 09:40:03 +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 B3085611B0 for ; Mon, 21 Jun 2021 09:40:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3085611B0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GqNLfK6Lvuy0Mt2ufeoO1QZJ2N0as1ZzKviC7W5gsdM=; b=I4axr0sbJiDZaY 1ywWypZMAU9OWZAXahqVFf0YquadmEauLWB4T7HJGwx0qqfBy6Z6lxR8CdsLQe3JjZKX26EW7lxgn 63eZMOw+WFjcexCmr/uifMGE5r8WG5bgqIxKDeehuLfN9IZuIuOsVzpZUyTSgCautAiUAmeO/dJPm E9TSIb0b6yCukZNSky16mgF077/R3tPPYF9WHHKr9JwI7D7+SLbeZYDEUODN4peEjD6GfFHU2mBEM 4+N7jdENQWIXWXRTmgC3HM3yz1p5frXL3rtKRH4N/ewysbBHUlZ9s9RayrFQf27NZJnkHyHGwKN/6 Gkxpo+vTprF7eJyW0GGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvGPS-002xLr-8b; Mon, 21 Jun 2021 09:40:02 +0000 Received: from relmlor2.renesas.com ([210.160.252.172] helo=relmlie6.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvGPP-002xKs-DR for linux-phy@lists.infradead.org; Mon, 21 Jun 2021 09:40:01 +0000 X-IronPort-AV: E=Sophos;i="5.83,289,1616425200"; d="scan'208";a="84924651" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 21 Jun 2021 18:39:57 +0900 Received: from localhost.localdomain (unknown [10.226.92.241]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 70B48400C4E6; Mon, 21 Jun 2021 18:39:55 +0900 (JST) From: Biju Das To: Kishon Vijay Abraham I , Vinod Koul Cc: Biju Das , linux-phy@lists.infradead.org, Yoshihiro Shimoda , Geert Uytterhoeven , Chris Paterson , Biju Das , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 03/11] phy: renesas: Add RZ/G2L usb phy control driver Date: Mon, 21 Jun 2021 10:39:35 +0100 Message-Id: <20210621093943.12143-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210621093943.12143-1-biju.das.jz@bp.renesas.com> References: <20210621093943.12143-1-biju.das.jz@bp.renesas.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210621_023959_615047_171C5F01 X-CRM114-Status: GOOD ( 19.65 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Add support for RZ/G2L USB PHY Control driver. Signed-off-by: Biju Das Reviewed-by: Lad Prabhakar --- v1->v2: * Incorporated vinod's review comments. --- drivers/phy/renesas/Kconfig | 7 + drivers/phy/renesas/Makefile | 1 + drivers/phy/renesas/phy-rzg2l-usbphyctrl.c | 157 +++++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 drivers/phy/renesas/phy-rzg2l-usbphyctrl.c diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig index 111bdcae775c..2184fba12255 100644 --- a/drivers/phy/renesas/Kconfig +++ b/drivers/phy/renesas/Kconfig @@ -32,3 +32,10 @@ config PHY_RCAR_GEN3_USB3 select GENERIC_PHY help Support for USB 3.0 PHY found on Renesas R-Car generation 3 SoCs. + +config PHY_RZG2L_USBPHYCTRL + tristate "Renesas RZ/G2L USB PHY control driver" + depends on ARCH_RENESAS || COMPILE_TEST + select GENERIC_PHY + help + Support for USB PHY Control found on RZ/G2L SoCs. diff --git a/drivers/phy/renesas/Makefile b/drivers/phy/renesas/Makefile index b599ff8a4349..62acc6bde5cb 100644 --- a/drivers/phy/renesas/Makefile +++ b/drivers/phy/renesas/Makefile @@ -3,3 +3,4 @@ obj-$(CONFIG_PHY_RCAR_GEN2) += phy-rcar-gen2.o obj-$(CONFIG_PHY_RCAR_GEN3_PCIE) += phy-rcar-gen3-pcie.o obj-$(CONFIG_PHY_RCAR_GEN3_USB2) += phy-rcar-gen3-usb2.o obj-$(CONFIG_PHY_RCAR_GEN3_USB3) += phy-rcar-gen3-usb3.o +obj-$(CONFIG_PHY_RZG2L_USBPHYCTRL) += phy-rzg2l-usbphyctrl.o diff --git a/drivers/phy/renesas/phy-rzg2l-usbphyctrl.c b/drivers/phy/renesas/phy-rzg2l-usbphyctrl.c new file mode 100644 index 000000000000..f0e5555b99fe --- /dev/null +++ b/drivers/phy/renesas/phy-rzg2l-usbphyctrl.c @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Renesas RZ/G2L USB PHY control driver + * + * Copyright (C) 2021 Renesas Electronics Corporation + */ + +#include +#include +#include +#include +#include +#include + +#define RESET 0x000 + +#define SEL_PLLRESET BIT(12) +#define PLL_RESET BIT(8) + +#define PHY_RESET_PORT2 (BIT(1) | BIT(5)) +#define PHY_RESET_PORT1 (BIT(0) | BIT(4)) + +#define NUM_PORTS 2 + +struct rzg2l_usbphycontrol_drv; + +struct rzg2l_phyctrl { + struct phy *phy; + struct rzg2l_usbphycontrol_drv *drv; + u32 phy_reset_port_mask; +}; + +struct rzg2l_usbphycontrol_drv { + void __iomem *base; + struct rzg2l_phyctrl phyctrl[NUM_PORTS]; +}; + +static int rzg2l_usbphyctrl_init(struct phy *p) +{ + struct rzg2l_phyctrl *r = phy_get_drvdata(p); + struct rzg2l_usbphycontrol_drv *drv = r->drv; + void __iomem *base = drv->base; + u32 val = readl(base + RESET); + + val |= SEL_PLLRESET; + val &= ~(PLL_RESET | r->phy_reset_port_mask); + writel(val, base + RESET); + + return 0; +} + +static int rzg2l_usbphyctrl_exit(struct phy *p) +{ + struct rzg2l_phyctrl *r = phy_get_drvdata(p); + struct rzg2l_usbphycontrol_drv *drv = r->drv; + void __iomem *base = drv->base; + u32 val = readl(base + RESET); + + val |= r->phy_reset_port_mask; + if ((val & 0xFF) == (PHY_RESET_PORT1 | PHY_RESET_PORT2)) + val |= PLL_RESET; + writel(val, base + RESET); + return 0; +} + +static const struct phy_ops rzg2l_usbphyctrl_ops = { + .init = rzg2l_usbphyctrl_init, + .exit = rzg2l_usbphyctrl_exit, + .owner = THIS_MODULE, +}; + +static const struct of_device_id rzg2l_usbphyctrl_match_table[] = { + { .compatible = "renesas,rzg2l-usbphyctrl" }, + { /* Sentinel */ } +}; +MODULE_DEVICE_TABLE(of, rzg2l_usbphyctrl_match_table); + +static struct phy *rzg2l_usbphycontrol_xlate(struct device *dev, + struct of_phandle_args *args) +{ + struct rzg2l_usbphycontrol_drv *drv; + struct rzg2l_phyctrl *r; + + drv = dev_get_drvdata(dev); + if (!drv) + return ERR_PTR(-EINVAL); + + if (args->args[0] >= NUM_PORTS) + return ERR_PTR(-ENODEV); + + r = &drv->phyctrl[args->args[0]]; + + return r->phy; +} + +static int rzg2l_usbphycontrol_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct rzg2l_usbphycontrol_drv *drv; + struct phy_provider *provider; + u32 val; + int n; + + drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL); + if (!drv) + return -ENOMEM; + + drv->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(drv->base)) + return PTR_ERR(drv->base); + + for (n = 0; n < NUM_PORTS; n++) { + struct rzg2l_phyctrl *phy = &drv->phyctrl[n]; + + phy->phy = devm_phy_create(dev, NULL, &rzg2l_usbphyctrl_ops); + if (IS_ERR(phy->phy)) { + dev_err(dev, "Failed to create USBPHY Control\n"); + return PTR_ERR(phy->phy); + } + + if (n == 0) + phy->phy_reset_port_mask = PHY_RESET_PORT1; + else + phy->phy_reset_port_mask = PHY_RESET_PORT2; + + phy->drv = drv; + phy_set_drvdata(phy->phy, phy); + }; + + provider = devm_of_phy_provider_register(dev, rzg2l_usbphycontrol_xlate); + if (IS_ERR(provider)) { + dev_err(dev, "Failed to register PHY provider\n"); + return PTR_ERR(provider); + } + + dev_set_drvdata(dev, drv); + + /* put pll and phy into reset state */ + val = readl(drv->base + RESET); + val |= SEL_PLLRESET | PLL_RESET | PHY_RESET_PORT2 | PHY_RESET_PORT1; + writel(val, drv->base + RESET); + + return 0; +} + +static struct platform_driver rzg2l_usbphyctrl_driver = { + .driver = { + .name = "rzg2l_usbphyctrl", + .of_match_table = rzg2l_usbphyctrl_match_table, + }, + .probe = rzg2l_usbphycontrol_probe, +}; +module_platform_driver(rzg2l_usbphyctrl_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Renesas RZ/G2L USBPHYControl"); +MODULE_AUTHOR("biju.das.jz@bp.renesas.com>"); From patchwork Mon Jun 21 09:39:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 12334281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B80CC49EA5 for ; Mon, 21 Jun 2021 09:40:15 +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 6E6A660C3F for ; Mon, 21 Jun 2021 09:40:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E6A660C3F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oHnc8pQG1kHvtWpR+XP/ZNrNaWz0DOId18LlIr1JMr8=; b=fsAoxuqUCrl8qf LTuVUSpHnouopX5L6poT99c0E4FTQSYqvKTifRyS6ZA8uuSANmLcjKJzQFd4LfV+8xCPkvEtSBN1/ qQv3JpY1XJ9H4jYnf0109Dtwrc/x79btf80d06HuoTawyFt3wMkK2EQiQNxlUPFhteJAlghgX4JB9 TsKQjFr6VP8JYWvo9nUKb24zhHtN6msDQWe8/sdw8CfyG5pwQEL0+KnlGmh9SauFmV2GEmGfB712V 2VuceohvXwJ0/Gxm5XXKf94D1+oOuvnBrrSlA1vZcuasN5MSXCcB9GiixYXE+c0rMMKGte56my1MC ShB5kPsSzTVQaP7lwbVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvGPf-002xOD-0M; Mon, 21 Jun 2021 09:40:15 +0000 Received: from relmlor2.renesas.com ([210.160.252.172] helo=relmlie6.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvGPW-002xKs-1z for linux-phy@lists.infradead.org; Mon, 21 Jun 2021 09:40:07 +0000 X-IronPort-AV: E=Sophos;i="5.83,289,1616425200"; d="scan'208";a="84924677" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 21 Jun 2021 18:40:05 +0900 Received: from localhost.localdomain (unknown [10.226.92.241]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 0FC3F400C4E6; Mon, 21 Jun 2021 18:40:02 +0900 (JST) From: Biju Das To: Rob Herring Cc: Biju Das , Kishon Vijay Abraham I , Vinod Koul , Yoshihiro Shimoda , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Biju Das , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 05/11] dt-bindings: phy: renesas, usb2-phy: Document RZ/G2L phy bindings Date: Mon, 21 Jun 2021 10:39:37 +0100 Message-Id: <20210621093943.12143-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210621093943.12143-1-biju.das.jz@bp.renesas.com> References: <20210621093943.12143-1-biju.das.jz@bp.renesas.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210621_024006_236691_A79D9B7E X-CRM114-Status: UNSURE ( 5.84 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Document USB phy bindings for RZ/G2L SoC. Signed-off-by: Biju Das Reviewed-by: Lad Prabhakar --- .../bindings/phy/renesas,usb2-phy.yaml | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml b/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml index 0f358d5b84ef..eebba6c83aec 100644 --- a/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml +++ b/Documentation/devicetree/bindings/phy/renesas,usb2-phy.yaml @@ -17,17 +17,18 @@ properties: - items: - enum: - - renesas,usb2-phy-r7s9210 # RZ/A2 - - renesas,usb2-phy-r8a774a1 # RZ/G2M - - renesas,usb2-phy-r8a774b1 # RZ/G2N - - renesas,usb2-phy-r8a774c0 # RZ/G2E - - renesas,usb2-phy-r8a774e1 # RZ/G2H - - renesas,usb2-phy-r8a7795 # R-Car H3 - - renesas,usb2-phy-r8a7796 # R-Car M3-W - - renesas,usb2-phy-r8a77961 # R-Car M3-W+ - - renesas,usb2-phy-r8a77965 # R-Car M3-N - - renesas,usb2-phy-r8a77990 # R-Car E3 - - renesas,usb2-phy-r8a77995 # R-Car D3 + - renesas,usb2-phy-r7s9210 # RZ/A2 + - renesas,usb2-phy-r8a774a1 # RZ/G2M + - renesas,usb2-phy-r8a774b1 # RZ/G2N + - renesas,usb2-phy-r8a774c0 # RZ/G2E + - renesas,usb2-phy-r8a774e1 # RZ/G2H + - renesas,usb2-phy-r8a7795 # R-Car H3 + - renesas,usb2-phy-r8a7796 # R-Car M3-W + - renesas,usb2-phy-r8a77961 # R-Car M3-W+ + - renesas,usb2-phy-r8a77965 # R-Car M3-N + - renesas,usb2-phy-r8a77990 # R-Car E3 + - renesas,usb2-phy-r8a77995 # R-Car D3 + - renesas,usb2-phy-r9a07g044 # RZ/G2{L,LC} - const: renesas,rcar-gen3-usb2-phy reg: From patchwork Mon Jun 21 09:39:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 12334283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAAC4C48BE5 for ; Mon, 21 Jun 2021 09:40:24 +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 8DA64611B0 for ; Mon, 21 Jun 2021 09:40:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DA64611B0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9ZYSLKQnS1bcOkuQvx6qARisv3aC7SAn6MMLuOHS0TA=; b=yzv/lGFxi0CIK+ z+vv6Hd070f6Wn5eVA7FV+P/P3ttNKuznpIbiQXBrlFVSJtixDiZh4MLP9Qv1nOzWDC4vPiJKyvbZ k9BPekr6YE1QWAdbV6uxc4M/mSbs1VLn8cJVNBMfoLVeIIrJSjmEfaeFChoTW1syDSRRyH1bjiHjm s769TFTtAJ1Bk9wLGS1VdbEAC2Ke6iRlObcCt8nnEx4pijoeFQb0UMcWvWUU5ZZl6AsZ8+fzHce+n GadzJKh6fVM2Q/S2oMNP8LQwp8lu4Q95Tp0Sn4nnIL6lNuCZOEblcXX9OPYitPMxIPflIYaEZS2hm OESHc6YIGuDS7KrGVeXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvGPo-002xPR-3w; Mon, 21 Jun 2021 09:40:24 +0000 Received: from relmlor2.renesas.com ([210.160.252.172] helo=relmlie6.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvGPk-002xOt-F0 for linux-phy@lists.infradead.org; Mon, 21 Jun 2021 09:40:22 +0000 X-IronPort-AV: E=Sophos;i="5.83,289,1616425200"; d="scan'208";a="84924731" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 21 Jun 2021 18:40:19 +0900 Received: from localhost.localdomain (unknown [10.226.92.241]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 6D783400C4C6; Mon, 21 Jun 2021 18:40:17 +0900 (JST) From: Biju Das To: Yoshihiro Shimoda Cc: Biju Das , Kishon Vijay Abraham I , Vinod Koul , linux-renesas-soc@vger.kernel.org, linux-phy@lists.infradead.org, Geert Uytterhoeven , Chris Paterson , Biju Das , Prabhakar Mahadev Lad Subject: [PATCH v2 10/11] phy: renesas: phy-rcar-gen3-usb2: Add OTG support for RZ/G2L Date: Mon, 21 Jun 2021 10:39:42 +0100 Message-Id: <20210621093943.12143-11-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210621093943.12143-1-biju.das.jz@bp.renesas.com> References: <20210621093943.12143-1-biju.das.jz@bp.renesas.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210621_024020_659965_38034E00 X-CRM114-Status: GOOD ( 18.83 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org This patch adds OTG support for RZ/G2L SoC. RZ/G2L USB2.0 phy is compatible with rcar gen3, but it uses line ctrl register for OTG_ID pin changes. Apart from this it uses a different OTG-BC interrupt bit for device recognition. Signed-off-by: Biju Das Reviewed-by: Lad Prabhakar --- drivers/phy/renesas/phy-rcar-gen3-usb2.c | 63 ++++++++++++++++++------ 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c index fbc55232120e..aff0749be65d 100644 --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -64,6 +65,7 @@ /* VBCTRL */ #define USB2_VBCTRL_OCCLREN BIT(16) #define USB2_VBCTRL_DRVVBUSSEL BIT(8) +#define USB2_VBCTRL_VBOUT BIT(0) /* LINECTRL1 */ #define USB2_LINECTRL1_DPRPD_EN BIT(19) @@ -78,6 +80,10 @@ #define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */ #define USB2_ADPCTRL_DRVVBUS BIT(4) +/* RZ/G2L specific */ +#define USB2_OBINT_IDCHG_EN BIT(0) +#define USB2_LINECTRL1_USB2_IDMON BIT(0) + #define NUM_OF_PHYS 4 enum rcar_gen3_phy_index { PHY_INDEX_BOTH_HC, @@ -112,9 +118,11 @@ struct rcar_gen3_chan { struct mutex lock; /* protects rphys[...].powered */ enum usb_dr_mode dr_mode; int irq; + u32 obint_enable_bits; bool extcon_host; bool is_otg_channel; bool uses_otg_pins; + bool soc_no_adp_ctrl; }; /* @@ -172,14 +180,22 @@ static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm) static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus) { void __iomem *usb2_base = ch->base; - u32 val = readl(usb2_base + USB2_ADPCTRL); + u32 vbus_ctrl_reg = USB2_ADPCTRL; + u32 vbus_ctrl_val = USB2_ADPCTRL_DRVVBUS; + u32 val; dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus); + if (ch->soc_no_adp_ctrl) { + vbus_ctrl_reg = USB2_VBCTRL; + vbus_ctrl_val = USB2_VBCTRL_VBOUT; + } + + val = readl(usb2_base + vbus_ctrl_reg); if (vbus) - val |= USB2_ADPCTRL_DRVVBUS; + val |= vbus_ctrl_val; else - val &= ~USB2_ADPCTRL_DRVVBUS; - writel(val, usb2_base + USB2_ADPCTRL); + val &= ~vbus_ctrl_val; + writel(val, usb2_base + vbus_ctrl_reg); } static void rcar_gen3_control_otg_irq(struct rcar_gen3_chan *ch, int enable) @@ -188,9 +204,9 @@ static void rcar_gen3_control_otg_irq(struct rcar_gen3_chan *ch, int enable) u32 val = readl(usb2_base + USB2_OBINTEN); if (ch->uses_otg_pins && enable) - val |= USB2_OBINT_BITS; + val |= ch->obint_enable_bits; else - val &= ~USB2_OBINT_BITS; + val &= ~ch->obint_enable_bits; writel(val, usb2_base + USB2_OBINTEN); } @@ -252,6 +268,9 @@ static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch) if (!ch->uses_otg_pins) return (ch->dr_mode == USB_DR_MODE_HOST) ? false : true; + if (ch->soc_no_adp_ctrl) + return !!(readl(ch->base + USB2_LINECTRL1) & USB2_LINECTRL1_USB2_IDMON); + return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG); } @@ -376,16 +395,17 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch) USB2_LINECTRL1_DMRPD_EN | USB2_LINECTRL1_DM_RPD; writel(val, usb2_base + USB2_LINECTRL1); - val = readl(usb2_base + USB2_VBCTRL); - val &= ~USB2_VBCTRL_OCCLREN; - writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL); - val = readl(usb2_base + USB2_ADPCTRL); - writel(val | USB2_ADPCTRL_IDPULLUP, usb2_base + USB2_ADPCTRL); - + if (!ch->soc_no_adp_ctrl) { + val = readl(usb2_base + USB2_VBCTRL); + val &= ~USB2_VBCTRL_OCCLREN; + writel(val | USB2_VBCTRL_DRVVBUSSEL, usb2_base + USB2_VBCTRL); + val = readl(usb2_base + USB2_ADPCTRL); + writel(val | USB2_ADPCTRL_IDPULLUP, usb2_base + USB2_ADPCTRL); + } msleep(20); writel(0xffffffff, usb2_base + USB2_OBINTSTA); - writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTEN); + writel(ch->obint_enable_bits, usb2_base + USB2_OBINTEN); rcar_gen3_device_recognition(ch); } @@ -397,9 +417,9 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch) u32 status = readl(usb2_base + USB2_OBINTSTA); irqreturn_t ret = IRQ_NONE; - if (status & USB2_OBINT_BITS) { + if (status & ch->obint_enable_bits) { dev_vdbg(ch->dev, "%s: %08x\n", __func__, status); - writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA); + writel(ch->obint_enable_bits, usb2_base + USB2_OBINTSTA); rcar_gen3_device_recognition(ch); ret = IRQ_HANDLED; } @@ -535,6 +555,11 @@ static const struct phy_ops rz_g1c_phy_usb2_ops = { .owner = THIS_MODULE, }; +static const struct soc_device_attribute soc_no_adp_ctrl[] = { + { .soc_id = "r9a07g044", .data = (void *)true }, + { /* Sentinel */ } +}; + static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = { { .compatible = "renesas,usb2-phy-r8a77470", @@ -613,6 +638,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) struct phy_provider *provider; const struct phy_ops *phy_usb2_ops; int ret = 0, i; + const struct soc_device_attribute *attr; if (!dev->of_node) { dev_err(dev, "This driver needs device tree\n"); @@ -627,6 +653,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) if (IS_ERR(channel->base)) return PTR_ERR(channel->base); + channel->obint_enable_bits = USB2_OBINT_SESSVLDCHG | USB2_OBINT_IDDIGCHG; /* get irq number here and request_irq for OTG in phy_init */ channel->irq = platform_get_irq_optional(pdev, 0); channel->dr_mode = rcar_gen3_get_dr_mode(dev->of_node); @@ -634,6 +661,12 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) int ret; channel->is_otg_channel = true; + attr = soc_device_match(soc_no_adp_ctrl); + if (attr) { + channel->soc_no_adp_ctrl = attr->data; + channel->obint_enable_bits = USB2_OBINT_IDCHG_EN; + } + channel->uses_otg_pins = !of_property_read_bool(dev->of_node, "renesas,no-otg-pins"); channel->extcon = devm_extcon_dev_allocate(dev,