From patchwork Tue Feb 9 09:53:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 12077637 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=-22.3 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,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 6E7E6C433DB for ; Tue, 9 Feb 2021 09:54:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 08FFD64E77 for ; Tue, 9 Feb 2021 09:54:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08FFD64E77 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=zHanGrB83hQoYLWsfbAvqN/zjncd3xgsHZ7Z/u/3Vns=; b=K1Fc8F+GcZDTSkhYABLFNEdNE kHmi/MmZp66qnNMKyPe52XvSel3lPd9wZMBET9GHD3C21kJNvjTYauBSlB6ND2yLN8hp3ftVvd/hO abtKA5r0n2pLEYAyoV+D9QDuHUeLRFNsE8A7qRxVO8CPgN8gsl2pt6MfP/fXdXCcSLQ0axopA0Z2F LpZKd78eUiIxNvyrFfN9LRyEv/10Xg2xuIz3AQz5eyLXt+H5X4fnitopI/p0DMLuPm3TMnGu4abHz TY/suA9mx/yiFEjp67pIDURZt2NJhoXn++FROcAwSaRsXmPeKvjinIs+r3jao+o7xqMokgSOX4MgF vAlVqIx7A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9PiI-0008R1-8i; Tue, 09 Feb 2021 09:53:42 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9Pi6-0008Lu-Ma for linux-arm-kernel@lists.infradead.org; Tue, 09 Feb 2021 09:53:31 +0000 Received: by mail-ej1-x62e.google.com with SMTP id l25so12972874eja.9 for ; Tue, 09 Feb 2021 01:53:27 -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=kH2IpWZSoU7LW6R55FxG2fdVhcdDOZnt8IKAlaXn2Os=; b=jZukgeg/LBUT2AFJCMDjAdquPLJG9ll9QRW80i5PgBJgg0QuhC5KrKrmM52fQ7tLPU hjPZPeQeZf29nSwCJc6/nOmNPpAmaNGPr0+8KAjifuIIbGdPQXV5homhK38I3LFH1x08 ESh9Ss+Ov26bPlWYFbqu7anFCl/n5/LacIQaBITUtzcbr4vMX0pYTQ9uvpK8dF8sWYUh zABcT3AqeopL2Ahx0APjilN0MXrFHw5O/IMOXNAsPNy7fkzC0MhX2rAbVLo68+4CmB0z Ogxn6nk2eVQGMoDvpg+fFShRkwr/pSWeMG0Ercob3Ni+w/py+MGriWPWKb9yvnNPDrZv jFsg== 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=kH2IpWZSoU7LW6R55FxG2fdVhcdDOZnt8IKAlaXn2Os=; b=uMT5sfvnwqo90NAk90gkQRrS4mcQKlW3VgH2drEF++40hQXDj7nsZgR9aqAvvZwTex RV7Q+S9g/Vof+fTLkSnSKfHP+krUyEYq/KGfSr/nfc4b2d2HlZPN6eLVkfZhVO6kHgMJ NlKCtkYq0lGhTtC1jsPz+5NHPy86kVLLlK3xYi7KuLPnCXNnSiARRqEk5TBsp2Bf2YRL QhCoU7xeyoJfRfLDf2jGUsPbEULkiXYeLD7b0EqU+zeP+mGNxQ6VPHAUMaCwty2qCaHL j8Va5YrSoc580fV26k1avM+qsYhDfTGx7IZkLEHARmlBBKxZtsMPbhzOJ6BF7hn8CQ7j 2Kbw== X-Gm-Message-State: AOAM533Lv1CXnrtnXGMSiZnq3ikkIkxJr40SKY48Xv/xRVy0kJTR7tcn 3vKIwznm/IQuWaWNWaOjnvYzVw== X-Google-Smtp-Source: ABdhPJyNdJEyeK6H4oxf1gdNfOAMY6MonFBUSvcYuEIE0IV+c0h6Yyl6X354S2mwVRxbgf44CNlXsA== X-Received: by 2002:a17:907:20c4:: with SMTP id qq4mr20479872ejb.495.1612864406681; Tue, 09 Feb 2021 01:53:26 -0800 (PST) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id v26sm11457148edw.23.2021.02.09.01.53.26 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 01:53:26 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, michal.simek@xilinx.com, git@xilinx.com Subject: [PATCH 1/2] dt-bindings: usb: misc: Add binding for Microchip usb5744 hub Date: Tue, 9 Feb 2021 10:53:19 +0100 Message-Id: <076994fc051e9230a3fef9e3eb5ec932104ef16a.1612864393.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210209_045330_790630_E1942F91 X-CRM114-Status: GOOD ( 16.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Piyush Mehta , linux-usb@vger.kernel.org, Rob Herring , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Piyush Mehta Added dt binding for usb5744 driver. Signed-off-by: Piyush Mehta Signed-off-by: Michal Simek --- .../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 09:53:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 12077639 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.3 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,URIBL_BLOCKED, 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 5EA33C433E0 for ; Tue, 9 Feb 2021 09:55:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 009A264E77 for ; Tue, 9 Feb 2021 09:55:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 009A264E77 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=TmEr9sv2JwLgdeM8HwetXOkRbVvK/OLKEtXM4nun7PM=; b=Xf3qoBwTSuh3wiCqM9etz0MwD 6ydQjae/YV1z7DLtNJcdSrEECG6ucjgvNPMyoIcgCW00yq27pqtkZCTuQ83gV59YsEgz03HIOI+7h uBkxaR3rOwp6LoJ9pzymclZ51e9ubTZ1jZ9sBxCiEf8ZYI34mNZqAU5nl7c09wnqu4fCoGkY4blw2 sT+aH3J5N6Lfw048B27gRrhYF2mXu+DQMb/mD6sFwDFg+LpmFKE6sH79NozIJEydwWBp6uDWN6crR OBb50E0vNZiU0b84Du5wxqLVIIT+76vpYKMFFApfsHpLzdxeI8JAcu3x2jIknXjvhCI/yURzd5GAt rKEdbgV1w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9PiT-0008Vw-4k; Tue, 09 Feb 2021 09:53:53 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9Pi7-0008ML-3q for linux-arm-kernel@lists.infradead.org; Tue, 09 Feb 2021 09:53:32 +0000 Received: by mail-ej1-x62f.google.com with SMTP id w1so30193084ejf.11 for ; Tue, 09 Feb 2021 01:53:28 -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=l6McvaymhglpJsw5cFqu8G0AvV7wzVMGX2JtuLfyQvE=; b=QWCLLvI+tNV6X5F6ZqgMQRyLnZdhzEPovZRp83/KNkzxUZ9/ITTEBJxAuhlkVQ0CPb BVUsI9fsUjGmDdn7K2v9fDj20axZ+Y6iHLD4eMD5BTKkbSKQKFCTqvL8ErLuMGo0xvf0 +smK57GbogO7H3Byokw5zuL0DNW7r9Umajzd+RKjC1vYVL4pWRB/S+zazPp4z/GFveBc z4OW5OepIvQ4Gu7T/CmnEBqtu+SLJBHbMLNDZbGM93gIYNgGz58oYdBsIxR64D0DfpUU E9S5ez1u7hFF/jg8y6T2stSplrHuL6bRvEwp9TLKrKLjrecBXayaOrGEXeoqGXPpA6O4 PJAA== 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=l6McvaymhglpJsw5cFqu8G0AvV7wzVMGX2JtuLfyQvE=; b=uEBtMQGkdWYTwGnjVMX/98qsJS7uh3vmURzvaexsNdv4i5m74i3lmGxi72EenoVn66 Tp5tCEcRvODfUg3USCdGXNaNh1BNKc5xAec471+ouDggnPqsAD9O9ApCCbOYNaTglfZK 2Fqyg6jwP++vYBE/zMSkzm4V5DGfn8JQgF4UmRHr6/LRpYi81+mOVjqqFrWGLY9zoO3e YBB2C230HYNfWmXOPKWdCAveGHmf9LafJxE5xDpwWekG0Dc7++tOfkgtkae8rOmeCT6I T2nC0gRqIBqMgxQpatxa1WBa3X7UiuPTz93d0tHAlzSeB2b3Mcya8uxJSskhPU3SLnpw jlfg== X-Gm-Message-State: AOAM533ujjsoqWIK7ha6mJEzrPS42ReXRcrE6Cff+vjSYtQcuTHUnnwG 6ToLek6CrsDZaCZ8Y6/xjCfwOQ== X-Google-Smtp-Source: ABdhPJxiRvcNejewspSY8w7zq0dyXQJIDHDWET7hs+GP+g66T0jmvNHtYJeUVaqC8kV6+sTAr20kXw== X-Received: by 2002:a17:906:80b:: with SMTP id e11mr21316977ejd.269.1612864408059; Tue, 09 Feb 2021 01:53:28 -0800 (PST) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id a1sm8308589edj.6.2021.02.09.01.53.27 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Feb 2021 01:53:27 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, michal.simek@xilinx.com, git@xilinx.com Subject: [PATCH 2/2] usb: misc: usb5744: Add support for USB hub controller Date: Tue, 9 Feb 2021 10:53:20 +0100 Message-Id: X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210209_045331_222781_D3C20278 X-CRM114-Status: GOOD ( 28.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-usb@vger.kernel.org, "Alexander A. Klimov" , Piyush Mehta , Masahiro Yamada , Al Cooper , Alan Stern , Bastien Nocera , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- 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..30335b5c4f88 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig @@ -242,6 +242,15 @@ config USB_HUB_USB251XB parameters may be set in devicetree or platform data. Say Y or M here if you need to configure such a device via SMBus. +config USB_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_HSIC_USB3503 tristate "USB3503 HSIC to USB20 Driver" depends on I2C diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile index 5f4e598573ab..5920146a506a 100644 --- a/drivers/usb/misc/Makefile +++ b/drivers/usb/misc/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_USB_USS720) += uss720.o obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o obj-$(CONFIG_USB_YUREX) += yurex.o obj-$(CONFIG_USB_HUB_USB251XB) += usb251xb.o +obj-$(CONFIG_USB_USB5744) += usb5744.o obj-$(CONFIG_USB_HSIC_USB3503) += usb3503.o obj-$(CONFIG_USB_HSIC_USB4604) += usb4604.o obj-$(CONFIG_USB_CHAOSKEY) += chaoskey.o 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");