From patchwork Fri Nov 30 23:29:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Starr X-Patchwork-Id: 10707403 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 B294414DB for ; Fri, 30 Nov 2018 23:29:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A555B302EE for ; Fri, 30 Nov 2018 23:29:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9986330300; Fri, 30 Nov 2018 23:29:16 +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.9 required=2.0 tests=BAYES_00,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 19E77302EE for ; Fri, 30 Nov 2018 23:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726757AbeLAKkK convert rfc822-to-8bit (ORCPT ); Sat, 1 Dec 2018 05:40:10 -0500 Received: from mail.hedonline.com ([12.133.124.242]:11828 "EHLO HED-Exchange.hed.local" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725867AbeLAKkK (ORCPT ); Sat, 1 Dec 2018 05:40:10 -0500 Received: from HED-EXCHANGE.hed.local ([fe80::4dca:ec11:8ab6:1fd3]) by HED-Exchange.hed.local ([fe80::4dca:ec11:8ab6:1fd3%21]) with mapi id 14.03.0319.002; Fri, 30 Nov 2018 17:29:14 -0600 From: Matthew Starr To: "linux-usb@vger.kernel.org" CC: "Peter Chen (Peter.Chen@nxp.com)" , "Fabio Estevam (festevam@gmail.com)" , =?iso-8859-1?q?U?= =?iso-8859-1?q?we_Kleine-K=F6nig?= Subject: [PATCH v2] usb: chipidea: imx: Allow OC polarity active low Thread-Topic: [PATCH v2] usb: chipidea: imx: Allow OC polarity active low Thread-Index: AdSJA28GF3aBIm/jTeeouijLjWKHeg== Date: Fri, 30 Nov 2018 23:29:13 +0000 Message-ID: <3C8219BAE02B894A9C69304A12E8AA06CA27C613@HED-Exchange.hed.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.1.90] MIME-Version: 1.0 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 The implementation for setting the over current polarity has always been the over-current-active-high property. The problem with this is there is no way to enable over current active low polarity since the default state of the register bit that controls the over current polarity is a 0 which means active high. This value never actually did anything since active high is already the default state. Also it is not used in any device tree source in the kernel. The default register bit state was verified by checking the i.MX6Q and i.MX7Dual reference manuals. The change replaces the over-current-active-high property with the over-current-active-low property. Without this property the over current polarity will be active high by default like it always has been. With the property the over current polarity will be active low. Signed-off-by: Matthew Starr --- .../devicetree/bindings/usb/ci-hdrc-usb2.txt | 4 ++-- drivers/usb/chipidea/ci_hdrc_imx.c | 2 +- drivers/usb/chipidea/usbmisc_imx.c | 12 ++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt index 529e51879fb2..3dee58037839 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt @@ -87,8 +87,8 @@ i.mx specific properties - fsl,usbmisc: phandler of non-core register device, with one argument that indicate usb controller index - disable-over-current: disable over current detect -- over-current-active-high: over current signal polarity is high active, - typically over current signal polarity is low active. +- over-current-active-low: over current signal polarity is low active, + the default signal polarity is high active. - external-vbus-divider: enables off-chip resistor divider for Vbus Example: diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 09b37c0d075d..f7069544fb42 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -135,7 +135,7 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) if (of_find_property(np, "disable-over-current", NULL)) data->disable_oc = 1; - if (of_find_property(np, "over-current-active-high", NULL)) + if (of_find_property(np, "over-current-active-low", NULL)) data->oc_polarity = 1; if (of_find_property(np, "external-vbus-divider", NULL)) diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index def80ff547e4..b39ba76b874f 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -341,10 +341,11 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) if (data->disable_oc) { reg |= MX6_BM_OVER_CUR_DIS; } else if (data->oc_polarity == 1) { - /* High active */ - reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY); - } else { + /* Low active */ reg &= ~(MX6_BM_OVER_CUR_DIS); + reg |= MX6_BM_OVER_CUR_POLARITY; + } else { + reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY); } writel(reg, usbmisc->base + data->index * 4); @@ -445,7 +446,10 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) if (data->disable_oc) { reg |= MX6_BM_OVER_CUR_DIS; } else if (data->oc_polarity == 1) { - /* High active */ + /* Low active */ + reg &= ~(MX6_BM_OVER_CUR_DIS); + reg |= MX6_BM_OVER_CUR_POLARITY; + else { reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY); } writel(reg, usbmisc->base);