From patchwork Wed Jan 15 22:00:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 205656 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=-6.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 8AC04C32771 for ; Wed, 15 Jan 2020 22:00:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DC6C2465A for ; Wed, 15 Jan 2020 22:00:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="ENd49xo0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729476AbgAOWA2 (ORCPT ); Wed, 15 Jan 2020 17:00:28 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:43838 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgAOWA1 (ORCPT ); Wed, 15 Jan 2020 17:00:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1579125621; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VtIMb3JFSwTADsQXrqeQRTnzP1HYxEvX4EAo2GKiNIw=; b=ENd49xo0Fa3xksh/Ka5tR233pTD9BgR8xyHHdy1cqX4SPscnpPkANtrt0IGxDUpBueMYuq zFj6ZUlwDYRKmJH7bF6yxUmGAtph3DJuNhXog4Mf43V0KslxoiOiPmForhuhkVWS8bYuWR CPCJU78M4K9QWsGu4UUmOLs7N0DuTzY= From: Paul Cercueil To: Bin Liu , Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: od@zcrc.me, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [PATCH 1/5] dt-bindings: usb: Convert jz4740-musb doc to YAML Date: Wed, 15 Jan 2020 19:00:04 -0300 Message-Id: <20200115220008.91445-2-paul@crapouillou.net> In-Reply-To: <20200115220008.91445-1-paul@crapouillou.net> References: <20200115220008.91445-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Convert ingenic,jz4740-musb.txt to ingenic,musb.yaml, and add the new ingenic,jz4770-musb compatible string in the process. Signed-off-by: Paul Cercueil --- .../bindings/usb/ingenic,jz4740-musb.txt | 32 --------- .../devicetree/bindings/usb/ingenic,musb.yaml | 72 +++++++++++++++++++ 2 files changed, 72 insertions(+), 32 deletions(-) delete mode 100644 Documentation/devicetree/bindings/usb/ingenic,jz4740-musb.txt create mode 100644 Documentation/devicetree/bindings/usb/ingenic,musb.yaml diff --git a/Documentation/devicetree/bindings/usb/ingenic,jz4740-musb.txt b/Documentation/devicetree/bindings/usb/ingenic,jz4740-musb.txt deleted file mode 100644 index 16808721f3ff..000000000000 --- a/Documentation/devicetree/bindings/usb/ingenic,jz4740-musb.txt +++ /dev/null @@ -1,32 +0,0 @@ -Ingenic JZ4740 MUSB driver - -Required properties: - -- compatible: Must be "ingenic,jz4740-musb" -- reg: Address range of the UDC register set -- interrupts: IRQ number related to the UDC hardware -- interrupt-names: must be "mc" -- clocks: phandle to the "udc" clock -- clock-names: must be "udc" -- phys: phandle to the USB PHY - -Example: - -usb_phy: usb-phy@0 { - compatible = "usb-nop-xceiv"; - #phy-cells = <0>; -}; - -udc: usb@13040000 { - compatible = "ingenic,jz4740-musb"; - reg = <0x13040000 0x10000>; - - interrupt-parent = <&intc>; - interrupts = <24>; - interrupt-names = "mc"; - - clocks = <&cgu JZ4740_CLK_UDC>; - clock-names = "udc"; - - phys = <&usb_phy>; -}; diff --git a/Documentation/devicetree/bindings/usb/ingenic,musb.yaml b/Documentation/devicetree/bindings/usb/ingenic,musb.yaml new file mode 100644 index 000000000000..f8902ee83e56 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/ingenic,musb.yaml @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/ingenic,musb.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ingenic JZ47xx USB IP DT bindings + +maintainers: + - Paul Cercueil + +properties: + $nodename: + pattern: '^usb@.*' + + compatible: + oneOf: + - const: ingenic,jz4770-musb + - const: ingenic,jz4740-musb + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: udc + + interrupts: + maxItems: 1 + + interrupt-names: + items: + - const: mc + + phys: + description: PHY specifier for the USB PHY + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - interrupt-names + - phys + +additionalProperties: false + +examples: + - | + #include + usb_phy: usb-phy@0 { + compatible = "usb-nop-xceiv"; + #phy-cells = <0>; + }; + + udc: usb@13040000 { + compatible = "ingenic,jz4740-musb"; + reg = <0x13040000 0x10000>; + + interrupt-parent = <&intc>; + interrupts = <24>; + interrupt-names = "mc"; + + clocks = <&cgu JZ4740_CLK_UDC>; + clock-names = "udc"; + + phys = <&usb_phy>; + }; From patchwork Wed Jan 15 22:00:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 205655 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=-6.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 E22B1C32771 for ; Wed, 15 Jan 2020 22:00:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B36A024679 for ; Wed, 15 Jan 2020 22:00:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="IBtXLBxt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730398AbgAOWAm (ORCPT ); Wed, 15 Jan 2020 17:00:42 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:44224 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729961AbgAOWAm (ORCPT ); Wed, 15 Jan 2020 17:00:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1579125629; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o0QKlji5RuJwNwqT1PaIgqk7BHyyDrNKJSEO5Wrxdxg=; b=IBtXLBxtItAaTVAKFiypmZgwU3KC/lWmGct4HUMmfLKmIoWzs9bwTMQSnq5uRWug/8zj3M aBWf3hPGrNxk3T4nx2qfZBtdv5WyvinmHtOOI7BThGwl4SseqqX92UdC6MfuFY1Hj2Yob/ ERDkWy5Y9TWStkE4dnfBE6+bBEzG7/c= From: Paul Cercueil To: Bin Liu , Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: od@zcrc.me, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [PATCH 3/5] usb: musb: jz4740: Register USB role switch Date: Wed, 15 Jan 2020 19:00:06 -0300 Message-Id: <20200115220008.91445-4-paul@crapouillou.net> In-Reply-To: <20200115220008.91445-1-paul@crapouillou.net> References: <20200115220008.91445-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Register a USB role switch, in order to get notified by the connector driver when the USB role changes. The notification is then transmitted to the PHY. Signed-off-by: Paul Cercueil --- drivers/usb/musb/Kconfig | 1 + drivers/usb/musb/jz4740.c | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index c4b349e074c1..3268adb7d7cf 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -113,6 +113,7 @@ config USB_MUSB_JZ4740 depends on MIPS || COMPILE_TEST depends on USB_MUSB_GADGET depends on USB=n || USB_OTG_BLACKLIST_HUB + select USB_ROLE_SWITCH config USB_MUSB_MEDIATEK tristate "MediaTek platforms" diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c index aa32b5af0c1f..bbfeb9881788 100644 --- a/drivers/usb/musb/jz4740.c +++ b/drivers/usb/musb/jz4740.c @@ -12,13 +12,16 @@ #include #include #include +#include #include #include "musb_core.h" struct jz4740_glue { struct platform_device *pdev; + struct musb *musb; struct clk *clk; + struct usb_role_switch *role_sw; }; static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci) @@ -72,11 +75,38 @@ static const struct musb_hdrc_config jz4740_musb_config = { .fifo_cfg_size = ARRAY_SIZE(jz4740_musb_fifo_cfg), }; +static int jz4740_musb_role_switch_set(struct device *dev, enum usb_role role) +{ + struct jz4740_glue *glue = dev_get_drvdata(dev); + struct usb_phy *phy = glue->musb->xceiv; + + switch (role) { + case USB_ROLE_NONE: + atomic_notifier_call_chain(&phy->notifier, USB_EVENT_NONE, phy); + break; + case USB_ROLE_DEVICE: + atomic_notifier_call_chain(&phy->notifier, USB_EVENT_VBUS, phy); + break; + case USB_ROLE_HOST: + atomic_notifier_call_chain(&phy->notifier, USB_EVENT_ID, phy); + break; + } + + return 0; +} + static int jz4740_musb_init(struct musb *musb) { struct device *dev = musb->controller->parent; + struct jz4740_glue *glue = dev_get_drvdata(dev); + struct usb_role_switch_desc role_sw_desc = { + .set = jz4740_musb_role_switch_set, + .fwnode = dev_fwnode(dev), + }; int err; + glue->musb = musb; + if (dev->of_node) musb->xceiv = devm_usb_get_phy_by_phandle(dev, "phys", 0); else @@ -88,6 +118,12 @@ static int jz4740_musb_init(struct musb *musb) return err; } + glue->role_sw = usb_role_switch_register(dev, &role_sw_desc); + if (IS_ERR(glue->role_sw)) { + dev_err(dev, "Failed to register USB role switch"); + return PTR_ERR(glue->role_sw); + } + /* * Silicon does not implement ConfigData register. * Set dyn_fifo to avoid reading EP config from hardware. @@ -99,10 +135,20 @@ static int jz4740_musb_init(struct musb *musb) return 0; } +static int jz4740_musb_exit(struct musb *musb) +{ + struct jz4740_glue *glue = dev_get_drvdata(musb->controller->parent); + + usb_role_switch_unregister(glue->role_sw); + + return 0; +} + static const struct musb_platform_ops jz4740_musb_ops = { .quirks = MUSB_DMA_INVENTRA | MUSB_INDEXED_EP, .fifo_mode = 2, .init = jz4740_musb_init, + .exit = jz4740_musb_exit, #ifdef CONFIG_USB_INVENTRA_DMA .dma_init = musbhs_dma_controller_create_noirq, .dma_exit = musbhs_dma_controller_destroy, From patchwork Wed Jan 15 22:00:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 205654 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=-6.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 83239C32771 for ; Wed, 15 Jan 2020 22:01:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5875124679 for ; Wed, 15 Jan 2020 22:01:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="tulUk7sZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730546AbgAOWA5 (ORCPT ); Wed, 15 Jan 2020 17:00:57 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:44606 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729959AbgAOWA4 (ORCPT ); Wed, 15 Jan 2020 17:00:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1579125637; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oi4tThBuGksudZcJhgPfDegJg+rUgBw/w8H281SWb+E=; b=tulUk7sZMgZ7EekU08yWMhNNs5Z/E6ip0NUVc3XM+e7RPK5M/J1zs5F+AgE8StvYWcS25i zpk9xs1g0JaBCvra7krM2q5/nzNHbLBr2rLHemP3HR97q7Yv+V0pltoV1NiSxjpHNKxvZO qJ6gnJH2tpVyV8fViOizXCKzDJFCXYw= From: Paul Cercueil To: Bin Liu , Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: od@zcrc.me, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [PATCH 5/5] usb: musb: jz4740: Add support for the JZ4770 Date: Wed, 15 Jan 2020 19:00:08 -0300 Message-Id: <20200115220008.91445-6-paul@crapouillou.net> In-Reply-To: <20200115220008.91445-1-paul@crapouillou.net> References: <20200115220008.91445-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support for probing the jz4740-musb driver on the JZ4770 SoC. The USB IP in the JZ4770 works the same Inventra IP as for the JZ4740, but it features more endpoints, and officially supports OTG. Signed-off-by: Paul Cercueil --- drivers/usb/musb/jz4740.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c index b6747bad4fb2..8c52a1fa6fbc 100644 --- a/drivers/usb/musb/jz4740.c +++ b/drivers/usb/musb/jz4740.c @@ -161,6 +161,33 @@ static const struct musb_hdrc_platform_data jz4740_musb_pdata = { .platform_ops = &jz4740_musb_ops, }; +static struct musb_fifo_cfg jz4770_musb_fifo_cfg[] = { + { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, + { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, + { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, + { .hw_ep_num = 2, .style = FIFO_RX, .maxpacket = 512, }, + { .hw_ep_num = 3, .style = FIFO_TX, .maxpacket = 512, }, + { .hw_ep_num = 3, .style = FIFO_RX, .maxpacket = 512, }, + { .hw_ep_num = 4, .style = FIFO_TX, .maxpacket = 512, }, + { .hw_ep_num = 4, .style = FIFO_RX, .maxpacket = 512, }, + { .hw_ep_num = 5, .style = FIFO_TX, .maxpacket = 512, }, + { .hw_ep_num = 5, .style = FIFO_RX, .maxpacket = 512, }, +}; + +static struct musb_hdrc_config jz4770_musb_config = { + .multipoint = 1, + .num_eps = 11, + .ram_bits = 11, + .fifo_cfg = jz4770_musb_fifo_cfg, + .fifo_cfg_size = ARRAY_SIZE(jz4770_musb_fifo_cfg), +}; + +static const struct musb_hdrc_platform_data jz4770_musb_pdata = { + .mode = MUSB_PERIPHERAL, /* TODO: support OTG */ + .config = &jz4770_musb_config, + .platform_ops = &jz4740_musb_ops, +}; + static int jz4740_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -248,6 +275,7 @@ static int jz4740_remove(struct platform_device *pdev) static const struct of_device_id jz4740_musb_of_match[] = { { .compatible = "ingenic,jz4740-musb", .data = &jz4740_musb_pdata }, + { .compatible = "ingenic,jz4770-musb", .data = &jz4770_musb_pdata }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, jz4740_musb_of_match);