From patchwork Mon Oct 8 13:29:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frieder Schrempf X-Patchwork-Id: 10630807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E49E112B for ; Mon, 8 Oct 2018 13:42:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EB19292FF for ; Mon, 8 Oct 2018 13:42:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 015772931A; Mon, 8 Oct 2018 13:42:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED54D292FF for ; Mon, 8 Oct 2018 13:42:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726348AbeJHUxt (ORCPT ); Mon, 8 Oct 2018 16:53:49 -0400 Received: from mo4-p05-ob.smtp.rzone.de ([85.215.255.131]:10446 "EHLO mo4-p05-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbeJHUxs (ORCPT ); Mon, 8 Oct 2018 16:53:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1539006119; s=strato-dkim-0002; d=as-electronics.de; h=Message-Id:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=2hSVvSjMcx+xy9U5t8qp82PC39t/KkSpxS9cr9x1VVE=; b=WSbTSgYXVsRQB+vb32NHZd3D8TMlnIMt1ok+Ntxly82rHV10mq3xly6FZK3Es24ZF7 ed+NcXbZxYojZjQd+r44zCsPCJN6lOGppvyohm47EIEcT6KmL32eBB9VIUrBgpVRBMIv xmk711zS0vFFeMM6oCrFRdb+fMIVZfBLBe5fXGlfqi4tGZt1Y13cv/NyuXQo1OiEkf0x WlSHJkvVGkdzPxwiAALwPkDMzQXcY/QQXFr23Li0idk7rsktQZHcbdoykBEzfz7w5zKL vpBydu2CHYb4iAMDlYwYrW1d3vOkq2d/pAVqoHW3g6PFV1Gj5qJErSzGavi/6ySw2Vg/ 3OlQ== X-RZG-AUTH: ":LX8JdEmkW/4tAFwMkcNJIloh1hrA5u3owhPk7bdT5Fx22AatU+eLaHfutoZdl+X9BEbxz4P/994MeEDNp0afzt1sCL0HI5412k27pBvgKz+L/w==" X-RZG-CLASS-ID: mo05 Received: from fs-work.as-domain.local by smtp.strato.de (RZmta 44.2 AUTH) with ESMTPSA id h039efu98DTsHlw (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Mon, 8 Oct 2018 15:29:54 +0200 (CEST) From: Frieder Schrempf To: Peter.Chen@nxp.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Frieder Schrempf Subject: [RFC] usb: chipidea: Add minimal support for HSIC interface on i.MX6QDL Date: Mon, 8 Oct 2018 15:29:12 +0200 Message-Id: <1539005352-10909-1-git-send-email-frieder.schrempf@exceet.de> X-Mailer: git-send-email 2.7.4 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Current mainline doesn't support USB hosts 2 and 3 which only use HSIC mode and I was wondering how this would need to be implemented. The topic has been discussed before: [1] And there is some implementation in the vendor kernel: [2] It seems like two things need to be done: 1. Switch the pinmux of the strobe signal to use a pullup after the core has been initialized. 2. Enable HSIC mode and HSIC clock This patch only implements these basics in a minimal approach. You need to have an additional pinmux setting "active" in the dt, that sets the pullup. It was tested with the SMSC LAN9730 USB Ethernet adapter on the iMXceet Solo S board. [1] https://patchwork.kernel.org/patch/3541771/ [2] http://git.freescale.com/git/cgit.cgi/imx/linux-imx.git/commit/?id=cf2d3ff6b217ef41f0e594daa9615e2 Signed-off-by: Frieder Schrempf --- drivers/usb/chipidea/ci_hdrc_imx.c | 10 ++++++++++ drivers/usb/chipidea/usbmisc_imx.c | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 19f5f5f..fef8bda 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -256,6 +256,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) const struct of_device_id *of_id; const struct ci_hdrc_imx_platform_flag *imx_platform_flag; struct device_node *np = pdev->dev.of_node; + struct pinctrl *pinctrl; of_id = of_match_device(ci_hdrc_imx_dt_ids, &pdev->dev); if (!of_id) @@ -331,6 +332,15 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); } + pinctrl = devm_pinctrl_get(&pdev->dev); + if (!IS_ERR(pinctrl)) { + struct pinctrl_state *state; + + state = pinctrl_lookup_state(pinctrl, "active"); + if (!IS_ERR(state)) + pinctrl_select_state(pinctrl, state); + } + device_set_wakeup_capable(&pdev->dev, true); return 0; diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index 34ad5bf..a6556c8 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -64,10 +64,16 @@ #define MX6_BM_OVER_CUR_DIS BIT(7) #define MX6_BM_OVER_CUR_POLARITY BIT(8) #define MX6_BM_WAKEUP_ENABLE BIT(10) +#define MX6_BM_UTMI_ON_CLOCK BIT(13) #define MX6_BM_ID_WAKEUP BIT(16) #define MX6_BM_VBUS_WAKEUP BIT(17) #define MX6SX_BM_DPDM_WAKEUP_EN BIT(29) #define MX6_BM_WAKEUP_INTR BIT(31) + +#define MX6_USB_HSIC_CTRL_OFFSET 0x10 +#define MX6_BM_HSIC_CLK_ON BIT(11) +#define MX6_BM_HSIC_EN BIT(12) + #define MX6_USB_OTG1_PHY_CTRL 0x18 /* For imx6dql, it is host-only controller, for later imx6, it is otg's */ #define MX6_USB_OTG2_PHY_CTRL 0x1c @@ -351,6 +357,22 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) writel(reg | MX6_BM_NON_BURST_SETTING, usbmisc->base + data->index * 4); + /* + * Core 2 and 3 are host only and HSIC only, + * so we enable HSIC by default to make them usable + */ + if (data->index == 2 || data->index == 3) { + reg = readl(usbmisc->base + data->index * 4); + writel(reg | MX6_BM_UTMI_ON_CLOCK, + usbmisc->base + data->index * 4); + + reg = readl(usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + + (data->index - 2) * 4); + reg |= MX6_BM_HSIC_EN | MX6_BM_HSIC_CLK_ON; + writel(reg, usbmisc->base + MX6_USB_HSIC_CTRL_OFFSET + + (data->index - 2) * 4); + } + spin_unlock_irqrestore(&usbmisc->lock, flags); usbmisc_imx6q_set_wakeup(data, false);