From patchwork Tue Feb 9 10:48:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 379734 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=-21.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 DDCEAC433E0 for ; Tue, 9 Feb 2021 10:51:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A58CD60202 for ; Tue, 9 Feb 2021 10:51:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232057AbhBIKvB (ORCPT ); Tue, 9 Feb 2021 05:51:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232083AbhBIKsy (ORCPT ); Tue, 9 Feb 2021 05:48:54 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2865FC061793 for ; Tue, 9 Feb 2021 02:48:14 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id s3so22836293edi.7 for ; Tue, 09 Feb 2021 02:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P0/ds6TqyQAWLEqEisftvaogVWIhX2wWYb95Z1KhnN4=; b=bcMsBCW+9HiNELwvyzTbp9GO8Pm+mluEh0lDlaxb9Vd+6ItEuK1Lzko6p10rtbypY6 Yg4AJvhODI49GathqCahEaiXaSo4iGy1XQmzQfe2AXZ8sjkSOiYhNoNhytd8wvMnrYW6 E6zQTgAVTckX3Cly7GrmjhFdL96mXLsENwy4ujqVuvTq21YLmSMz3SVYL6InGoTJjpjq nQUGIKTjV9Ejx/Q4NOOyRn7EVIAsJJ6P/FfHERAw7Uisp5gMuAbU3sNdV6kVmW56LJg3 6KoYH7I/7dA6LQ6uLVPw8TpYurvfbXHzmk334lZgPGV8Z57QvpMddv2rewnAQsqujkna iviw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=P0/ds6TqyQAWLEqEisftvaogVWIhX2wWYb95Z1KhnN4=; b=g/ELJCNZBVZgvOBDUMXDQYdqlBcma/UxRISoGGUInH2BdBcQnviF45+2TyNzDoqSAi 7NhRoBRgFMxV6sX0V1sNhswGyCOQ3lAZGlCsZI8akpsNACRNjDmuEdRRw85aSb/CBYDr q2XalWqp1O3srqg1f3JODVjED4bGiTryQzz++CbJGrCnf+mrE1UUUNRlXyT73ivT2ooO kZTwemArv+ADj5wflEs05SdO0verfJ7gAPhEdB+ymgt6Q5jaCwZ9obBIuW2PAmN7z/QJ VBuW9EMjHT0Lnk50goShHkjX6WonSo/fWBLd0vfM/dwdko0Q/ixrqJNIz8SCmnM4pW90 N+uw== X-Gm-Message-State: AOAM533zfCRBzElBaeZXM+PYfIaa8Y1hJG17MIKnQ2vfSTs9Vu8KokeM edUzjeoLdOJqyGB/HKRS+YbuKA== X-Google-Smtp-Source: ABdhPJzBcV5KCgtMy0P0CJf8soqGHUHtOEc4yMLz7EY8MjXZpHHuBmZSDzu+X3wGL9lrdIY/IgIgEg== X-Received: by 2002:a05:6402:3553:: with SMTP id f19mr22313795edd.271.1612867692886; Tue, 09 Feb 2021 02:48:12 -0800 (PST) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id p25sm11025831eds.55.2021.02.09.02.48.12 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 02:48:12 -0800 (PST) Sender: Michal Simek From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, michal.simek@xilinx.com, git@xilinx.com Cc: Piyush Mehta , Greg Kroah-Hartman , Rob Herring , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH v2 1/2] dt-bindings: usb: misc: Add binding for Microchip usb5744 hub Date: Tue, 9 Feb 2021 11:48:09 +0100 Message-Id: <076994fc051e9230a3fef9e3eb5ec932104ef16a.1612867682.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Piyush Mehta Added dt binding for usb5744 driver. Signed-off-by: Piyush Mehta Signed-off-by: Michal Simek --- Changes in v2: None .../bindings/usb/microchip,usb5744.yaml | 56 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/microchip,usb5744.yaml diff --git a/Documentation/devicetree/bindings/usb/microchip,usb5744.yaml b/Documentation/devicetree/bindings/usb/microchip,usb5744.yaml new file mode 100644 index 000000000000..fe222f6db81d --- /dev/null +++ b/Documentation/devicetree/bindings/usb/microchip,usb5744.yaml @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/usb/microchip,usb5744.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Bindings for the Microchip USB5744 4-port Hub Controller + +description: + Microchip’s USB5744 SmartHub™ IC is a 4 port, SuperSpeed (SS)/Hi-Speed (HS), + low power, low pin count configurable and fully compliant with the USB 3.1 + Gen 1 specification. The USB5744 also supports Full Speed (FS) and Low Speed + (LS) USB signaling, offering complete coverage of all defined USB operating + speeds. The new SuperSpeed hubs operate in parallel with the USB 2.0 + controller, so 5 Gbps SuperSpeed data transfers are not affected by slower + USB 2.0 traffic. + +maintainers: + - Piyush Mehta + - Michal Simek + +properties: + compatible: + const: microchip,usb5744 + + reg: + maxItems: 1 + description: | + Specifies the i2c slave address, it is required and should be 0x2d + if I2C is used. + + reset-gpios: + maxItems: 1 + description: + The phandle and specifier for the GPIO that controls the RESET line of + USB hub. + +required: + - compatible + +additionalProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + usb5744@2d { + compatible = "microchip,usb5744"; + reg = <0x2d>; + reset-gpios = <&gpio 44 GPIO_ACTIVE_HIGH>; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 41e8d3d7faec..7439471b5d37 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2697,6 +2697,7 @@ W: http://wiki.xilinx.com T: git https://github.com/Xilinx/linux-xlnx.git F: Documentation/devicetree/bindings/i2c/cdns,i2c-r1p10.yaml F: Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml +F: Documentation/devicetree/bindings/usb/microchip,usb5744.yaml F: arch/arm/mach-zynq/ F: drivers/block/xsysace.c F: drivers/clocksource/timer-cadence-ttc.c From patchwork Tue Feb 9 10:48:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 380618 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 B8E2EC433DB for ; Tue, 9 Feb 2021 10:51:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75E2F64DC3 for ; Tue, 9 Feb 2021 10:51:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232075AbhBIKvE (ORCPT ); Tue, 9 Feb 2021 05:51:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232086AbhBIKs4 (ORCPT ); Tue, 9 Feb 2021 05:48:56 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FE09C0617A7 for ; Tue, 9 Feb 2021 02:48:15 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id q2so22840836edi.4 for ; Tue, 09 Feb 2021 02:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t7zgHA0yWG/zOGIQXOsMzCh7zWsu/9Pw2PZf498lKCU=; b=ZO6cmxiGQwUsYyuV+tGsUpkOXsuXQbzgeqV6DS8ojlPQEB6SPdcOTWKZEwG9h0vMKx //ycz1QHRqKAVOQz+s8vuRcgnwe+oTElxSl95XKRyFMbhUcSwnQLRksWFQgpETYQKnyq RFHkIhKZ3UTmTy0jqPWMFJ6XAA1Zq1uGUKSuNAZJmCXnj8QygIueeDG9tult4GjMHjyl w1gDvmhzp4LmLD0Syjdd1e5XGkB4dkMSyLmYGhZ4VYgL9NVVE17NVeOBbT4Qi1n7vhK8 JfjtDzqkTnbMzvKDL1jx4CXnpnA+n9xOnP0huI2tlWNA8hgXTi8GW3yErHkCSeIUYTWb G7jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=t7zgHA0yWG/zOGIQXOsMzCh7zWsu/9Pw2PZf498lKCU=; b=b9E70vh2SDjGMtrCx6JFQ/sUlouU4SYc14ZAmRkODCUu4YGlO2OUqrYEOTsbLCnvYG 8z40O0gU0KE4jsqj2SUC3N4PWaWz36BfOb13rY5cgXOJUJ/tKRnLFnUhIgC3HqzvDHbC L5cxyAWIfmINqIhYMYeu69q85tBclqqMOHRX0RXBmCdKe0vByeVExUZ17P0v4K+FBFQB Imrc7nc+9kZIY3bqk/C5lAuCvIg7d+58D6c78cJoEais7sO/oockXckxa3lBiHsr4UEG rKLBH8OqnpSu/enN4aBhrh/BpyAb5wbiw+bDAgsK+IhlUn2pFqJYx6bnwYGp4tN+ZPAK SZGQ== X-Gm-Message-State: AOAM533s/onsCsHeRzd9ttmRBsOj1lVivtjVGv/HOII6BAqmRD4yw1Mt Gu9BE0Je+lY7DYlevDFC4tPlFQ== X-Google-Smtp-Source: ABdhPJylIwDSHVfFo7SvceeTerSpNKHQyMZ8dMDgMnoTJRG2/bupOzgwtk54nFPXRze2lmIQH7Ey2g== X-Received: by 2002:a05:6402:b8c:: with SMTP id cf12mr21850207edb.320.1612867694348; Tue, 09 Feb 2021 02:48:14 -0800 (PST) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id d3sm3677300edk.82.2021.02.09.02.48.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 02:48:14 -0800 (PST) Sender: Michal Simek From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, michal.simek@xilinx.com, git@xilinx.com Cc: Piyush Mehta , Al Cooper , Alan Stern , "Alexander A. Klimov" , Bastien Nocera , Greg Kroah-Hartman , Masahiro Yamada , linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org Subject: [PATCH v2 2/2] usb: misc: usb5744: Add support for USB hub controller Date: Tue, 9 Feb 2021 11:48:10 +0100 Message-Id: X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Piyush Mehta This patch adds a USB GPIO based hub reset for USB5744 hub. This usb5744 driver trigger hub reset signal after soft reset or core Reset. The HUB needs to be resetted after completion of phy initialization. After the toggling of gpio, hub configure using i2c usb attached command. USB5744 hub can be used without any I2C connection, is handled by a simple platform device driver. As part of the reset, sets the direction of the pin to output before toggling the pin. Delay of millisecond is added in between low and high to meet the setup and hold time requirement of the reset. Signed-off-by: Piyush Mehta Signed-off-by: Michal Simek --- Changes in v2: - s/USB_USB5744/USB_HUB_USB5744/g - Fix order in Makefile and Kconfig MAINTAINERS | 1 + drivers/usb/misc/Kconfig | 9 +++ drivers/usb/misc/Makefile | 1 + drivers/usb/misc/usb5744.c | 115 +++++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 drivers/usb/misc/usb5744.c diff --git a/MAINTAINERS b/MAINTAINERS index 7439471b5d37..56d1fcdd24f6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2706,6 +2706,7 @@ F: drivers/edac/synopsys_edac.c F: drivers/i2c/busses/i2c-cadence.c F: drivers/i2c/busses/i2c-xiic.c F: drivers/mmc/host/sdhci-of-arasan.c +F: drivers/usb/misc/usb5744.c N: zynq N: xilinx diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index 8f1144359012..9995a5701fd9 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig @@ -255,6 +255,15 @@ config USB_HSIC_USB4604 help This option enables support for SMSC USB4604 HSIC to USB 2.0 Driver. +config USB_HUB_USB5744 + tristate "Microchip USB5744 Hub driver" + depends on I2C + depends on GPIOLIB + help + This option enables support for Microchip USB5744 Hub. This driver + optionally reset the hub using gpio pin and configure hub via i2c if + connected. + config USB_LINK_LAYER_TEST tristate "USB Link Layer Test driver" help diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 5f4e598573ab..fbb9adf08f8c 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile @@ -27,6 +27,7 @@ obj-$(CONFIG_USB_YUREX) += yurex.o obj-$(CONFIG_USB_HUB_USB251XB) += usb251xb.o obj-$(CONFIG_USB_HSIC_USB3503) += usb3503.o obj-$(CONFIG_USB_HSIC_USB4604) += usb4604.o +obj-$(CONFIG_USB_HUB_USB5744) += usb5744.o obj-$(CONFIG_USB_CHAOSKEY) += chaoskey.o obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ diff --git a/drivers/usb/misc/usb5744.c b/drivers/usb/misc/usb5744.c new file mode 100644 index 000000000000..729b76345c69 --- /dev/null +++ b/drivers/usb/misc/usb5744.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Driver for the Microchip USB5744 4-port hub. + * + * Copyright (c) 2021 Xilinx, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include + +static int usb5744_init_hw(struct device *dev) +{ + struct gpio_desc *reset_gpio; + + reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(reset_gpio)) { + dev_err(dev, "Failed to bind reset gpio"); + return -ENODEV; + } + + if (reset_gpio) { + /* Toggle RESET_N to reset the hub. */ + gpiod_set_value(reset_gpio, 0); + usleep_range(5, 20); /* trstia */ + gpiod_set_value(reset_gpio, 1); + usleep_range(5000, 10000); /* tcsh */ + } + + return 0; +} + +static int usb5744_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct device *dev = &client->dev; + int ret; + + /* Trigger gpio reset to the hub. */ + ret = usb5744_init_hw(dev); + if (ret) + return ret; + + /* Send SMBus command to boot hub. */ + ret = i2c_smbus_write_word_data(client, 0xAA, swab16(0x5600)); + if (ret < 0) + dev_err(dev, "Sending boot command failed"); + + return ret; +} + +static int usb5744_platform_probe(struct platform_device *pdev) +{ + /* Trigger gpio reset to the hub. */ + return usb5744_init_hw(&pdev->dev); +} + +static const struct i2c_device_id usb5744_id[] = { + { "usb5744", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, usb5744_id); + +static struct i2c_driver usb5744_i2c_driver = { + .driver = { + .name = "usb5744", + }, + .probe = usb5744_i2c_probe, + .id_table = usb5744_id, +}; + +static const struct of_device_id usb5744_platform_id[] = { + { .compatible = "microchip,usb5744", }, + { } +}; + +static struct platform_driver usb5744_platform_driver = { + .driver = { + .name = "microchip,usb5744", + .of_match_table = usb5744_platform_id, + }, + .probe = usb5744_platform_probe, +}; + +static int __init usb5744_init(void) +{ + int err; + + err = i2c_add_driver(&usb5744_i2c_driver); + if (err != 0) + pr_err("usb5744: Failed to register I2C driver: %d\n", err); + + err = platform_driver_register(&usb5744_platform_driver); + if (err != 0) + pr_err("usb5744: Failed to register platform driver: %d\n", + err); + return 0; +} +module_init(usb5744_init); + +static void __exit usb5744_exit(void) +{ + platform_driver_unregister(&usb5744_platform_driver); + i2c_del_driver(&usb5744_i2c_driver); +} +module_exit(usb5744_exit); + +MODULE_AUTHOR("Piyush Mehta "); +MODULE_AUTHOR("Michal Simek "); +MODULE_DESCRIPTION("USB5744 Hub"); +MODULE_LICENSE("GPL v2");