From patchwork Tue Nov 27 18:50:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Starr X-Patchwork-Id: 10701311 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 7BA4E13AD for ; Tue, 27 Nov 2018 18:55:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EE2B2B89A for ; Tue, 27 Nov 2018 18:55:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 634012B9FB; Tue, 27 Nov 2018 18:55:34 +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 DDFCE2B89A for ; Tue, 27 Nov 2018 18:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729162AbeK1FyW convert rfc822-to-8bit (ORCPT ); Wed, 28 Nov 2018 00:54:22 -0500 Received: from mail.hedonline.com ([12.133.124.242]:43358 "EHLO HED-Exchange.hed.local" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726445AbeK1FyW (ORCPT ); Wed, 28 Nov 2018 00:54:22 -0500 X-Greylist: delayed 309 seconds by postgrey-1.27 at vger.kernel.org; Wed, 28 Nov 2018 00:54:21 EST 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; Tue, 27 Nov 2018 12:50:23 -0600 From: Matthew Starr To: "linux-usb@vger.kernel.org" CC: Peter Chen Subject: [PATCH] usb: chipidea: imx: Allow OC polarity active low Thread-Topic: [PATCH] usb: chipidea: imx: Allow OC polarity active low Thread-Index: AdSGgc24SzmqjXiWS+ufZi5GnbiUyA== Date: Tue, 27 Nov 2018 18:50:22 +0000 Message-ID: <3C8219BAE02B894A9C69304A12E8AA06CA27A475@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 --- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 4 ++-- drivers/usb/chipidea/ci_hdrc_imx.c | 2 +- drivers/usb/chipidea/usbmisc_imx.c | 10 ++++++---- 3 files changed, 9 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..39223708e859 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -341,8 +341,9 @@ 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); + /* Low active */ + reg &= ~(MX6_BM_OVER_CUR_DIS); + reg |= MX6_BM_OVER_CUR_POLARITY; } else { reg &= ~(MX6_BM_OVER_CUR_DIS); } @@ -445,8 +446,9 @@ 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 */ - reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY); + /* Low active */ + reg &= ~(MX6_BM_OVER_CUR_DIS); + reg |= MX6_BM_OVER_CUR_POLARITY; } writel(reg, usbmisc->base);