From patchwork Mon Jul 18 11:15:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 9234425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECFD26075D for ; Mon, 18 Jul 2016 11:14:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD972200F5 for ; Mon, 18 Jul 2016 11:14:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2368228C8; Mon, 18 Jul 2016 11:14:22 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 62AF3200F5 for ; Mon, 18 Jul 2016 11:14:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bP6Tk-0000si-Q6; Mon, 18 Jul 2016 11:12:52 +0000 Received: from mail-db5eur01on0071.outbound.protection.outlook.com ([104.47.2.71] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bP6SA-00007x-8p for linux-arm-kernel@lists.infradead.org; Mon, 18 Jul 2016 11:11:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=wiJy9L/e8b0XHUQO86e0++AEcgjbj/1pRP+C0EJEKfI=; b=tlyz8+GPM03UcjFT9sFVC9tGZM2mF3ZEr7F6ism2+Udm+j5EB6hOv+gGGCRHl0M7LR0+XhsnSQcKnhtUVdPBIIPAqSrmdtBR80J/TiHHlrDGpIYHeg2TxBtR4DD3QsP2HF8Q0aCp4AiK/dXPhz4t0EVGeC3L08IsOr3wpkkQ5hc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jun.li@nxp.com; Received: from b51421-server.ap.freescale.net (192.158.241.86) by HE1PR04MB2140.eurprd04.prod.outlook.com (10.166.76.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.5; Mon, 18 Jul 2016 11:10:50 +0000 From: Li Jun To: , , Subject: [PATCH 4/4] usb: chipidea: imx: set over current polarity per dts setting Date: Mon, 18 Jul 2016 19:15:47 +0800 Message-ID: <1468840547-17899-4-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468840547-17899-1-git-send-email-jun.li@nxp.com> References: <1468840547-17899-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [192.158.241.86] X-ClientProxiedBy: SG2PR06CA0028.apcprd06.prod.outlook.com (10.163.105.38) To HE1PR04MB2140.eurprd04.prod.outlook.com (10.166.76.12) X-MS-Office365-Filtering-Correlation-Id: dedeb820-4c98-4147-b681-08d3aefc30b0 X-Microsoft-Exchange-Diagnostics: 1; HE1PR04MB2140; 2:9o0XINvJ2deQJqv2pUJh+29NbdANiSOGSEuCOPuvJhY5waq9AJTafqtW+xqxe6mLoQidB5fe/LFApYIebjMm8XHhkcus7EUlo7xHsDHseu8K6TUGXwedNfXln+ZPEJwwqaEvzhl9Cr22togsYqLHSv3N3kP4MqPwkmkc0FpUzvFd4PnounA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RFJwmvMOavvyXblU7VDn2xgB23dYvoZ6DkQ3BPrBhHumvlaPJj7E5FUfeHSs+kVi3PQ03ZL1h5o+REZryTTMWcueGT79nQVjxii2iJNiOVAkF8+YKuwx18QToOjOA3jQGcTV3+ZrbFl25oCpjk/Mf8AEM1jZPf7JyaPSv1yR2BC1kXP4KMD92N3GoGdASAOfexxDtWPP+i82T3IEAVd+Xvod6DW+7TdloCG2vaI5xu58RG3biQDFbEDxnjn8dYpeSYBd2nBwPP6OFEQE+o3exwveU+KZFga/rkgm7eq3XaPh8Osg8qCX1NYcecFItrDF3HoZR; 4:h5fEaRT2L1m2afqay5dStveLwINoen7cUosSGY1KDStxgctV9c4G72dS6ZNoNPV9truV7jhIHwX6nTINZ1WPeZvjOsxYR+f6J0XN4+NfvPhxCb85c0GYbRHMmTkU7KaRNj7ZWDHUyv7xDSWic9h5tK2DiaiNoWM/dWBFCwPzS2qHFMnZ4K6GiIla24plO7sfggMPVO621dDjitu1b5eWoHf0JiSETh4tD2YmsPd2pD86fu/jVq1VQyPjm0ljb8t99/Sis+JeI3JkRSTyqoF+9e/JwK2vT+jt2g1Poq7ZTphw702r67AXET9zQYP6nlr70NQ+13UA0UHJ+nTF1waHl1YJfD1paMIe6KHL5pZHvXwBCBcFiCLTY3gVayPyWezc+FVrFpb5Ecern/3BIKz7tw+KLm7xGpQL6xedEH+0iQJFrkVBKbL7QCDX8ZUDg6h4 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:HE1PR04MB2140; BCL:0; PCL:0; RULEID:; SRVR:HE1PR04MB2140; X-Forefront-PRVS: 00073DB75F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(5003940100001)(2906002)(4326007)(189998001)(42186005)(66066001)(47776003)(5001770100001)(97736004)(3846002)(36756003)(586003)(229853001)(6116002)(105586002)(81156014)(81166006)(101416001)(19580395003)(68736007)(48376002)(19580405001)(8676002)(50986999)(76176999)(50466002)(86362001)(92566002)(106356001)(2950100001)(33646002)(305945005)(7736002)(7846002)(77096005)(50226002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR04MB2140; H:b51421-server.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR04MB2140; 23:6pABeqStD7+VISCfJ3dtyVMV91pCDTauTiwaDlLf1?= =?us-ascii?Q?/Cm2Igeim0Bd3NycezIwlLgjBzLQltK4ZnGNaZQxIrqIOvYibfLNvgG08Net?= =?us-ascii?Q?lcWn7rrVLWSbyq6Z1AVEHraB/eYsJAFgBXnvjtlB4ijnax2eRgsAcyl0g1PU?= =?us-ascii?Q?M7PXgiQ0PbOu29uvATuUbXRyU0exSGgFKz/Ie6Q5aZFtx4f8RhP/u5j4ndTk?= =?us-ascii?Q?iHZCesIRrNDEpXPAqOGKV7Oh0l/AcT2NNzbKWmo6ZlzwlUJwqVU32Sw69UYl?= =?us-ascii?Q?2ahDFS6noCNY9xiegh8LcE/pIVt/AAXVJWYZpvxfJ2VWR65odUUS5ovYGQjp?= =?us-ascii?Q?Od5n/4wYwb00DKkd4FPsW0S4qU1XfFq0clkg40V/bDA79A1K+9zgINnwdonS?= =?us-ascii?Q?uzuQuIS69nV9nhIHGmsOmtSrbqTJnak2hPSuE0hZhfypVegjwzqsYEQyBsL6?= =?us-ascii?Q?ZXDZoXJCtV7zSj2lyq6vJSKqPVBs1DhALKnnEdlYp79uDv3EsJ8zJx98Jn3E?= =?us-ascii?Q?41qE2cw64CKMKEN9WjlWFRx7aKO/dEhMzI5ZtF1arHcdFjswjtiHV7H9j+m1?= =?us-ascii?Q?ztra8GxBwMhrXAp+2T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PvesKnIy+wA3FUAbymGo29VDdWoE9XTVq8y+Mn7dFW030dDC84aQuCN4MW1cMA==; 24:BeHFQx7eEocC9dD7V9II8f3LxmQT28Jhm2I+XiHVr0Uxz2HoE2Jl8JwXqXw95Bxc6XlKCtMauYjwpgiPwfCPIe46O+kHchSsyQNu4KxWp4c=; 7:z5v0UZsG8Q4NjLCxo66wX1IrSKL4OQvy7qldY2fe0IaIP6Xzo4VIsNvAd5FPgexFtmdhAvm3uXJiVL/10xVvL9Hiw9QIK8RD0Qa8eSy+myVg22kdZVHZoi9Tqpwtq6v4DgGF2Q9gZZ35gGe1BimmLnyUxFOcz/d4ossDeSoa6xA/VlOEzyzvCFPMBEKiMkT1r6Amgi1IK1nbfYR2y0Ss4ArzFMZ2k7yuFm61juV9WglDEd8HEJ84kWUfTW4sl7FV SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2016 11:10:50.7898 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB2140 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160718_041114_762238_4881BB31 X-CRM114-Status: GOOD ( 13.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Li Jun Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP With over-current-polarity property added, imx usb over current polarity can be configed to be low or high active, since the default setting value(0) is for active high, so keep this setting for those legacy platforms without this property specified. Signed-off-by: Li Jun --- drivers/usb/chipidea/ci_hdrc_imx.c | 9 +++++++++ drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 30 +++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index dedc33e..61e712b 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -140,6 +140,15 @@ 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_property_read_u32(np, "over-current-polarity", &ret)) + data->oc_polarity = ret ? 1 : 0; + else + /* + * Keep the oc polarity setting of legacy + * platforms unchanged. + */ + data->oc_polarity = 1; + if (of_find_property(np, "external-vbus-divider", NULL)) data->evdo = 1; diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h index 635717e..409aa5ca8 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.h +++ b/drivers/usb/chipidea/ci_hdrc_imx.h @@ -17,6 +17,7 @@ struct imx_usbmisc_data { int index; unsigned int disable_oc:1; /* over current detect disabled */ + unsigned int oc_polarity:1; /* over current polarity if oc enabled */ unsigned int evdo:1; /* set external vbus divider option */ }; diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index ab8b027..193dbe4 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -56,6 +56,7 @@ #define MX6_BM_NON_BURST_SETTING BIT(1) #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_ID_WAKEUP BIT(16) #define MX6_BM_VBUS_WAKEUP BIT(17) @@ -266,11 +267,18 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) spin_lock_irqsave(&usbmisc->lock, flags); + reg = readl(usbmisc->base + data->index * 4); if (data->disable_oc) { - reg = readl(usbmisc->base + data->index * 4); - writel(reg | MX6_BM_OVER_CUR_DIS, - usbmisc->base + data->index * 4); + 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; } + writel(reg, usbmisc->base + data->index * 4); /* SoC non-burst setting */ reg = readl(usbmisc->base + data->index * 4); @@ -365,10 +373,18 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) return -EINVAL; spin_lock_irqsave(&usbmisc->lock, flags); + reg = readl(usbmisc->base); if (data->disable_oc) { - reg = readl(usbmisc->base); - writel(reg | MX6_BM_OVER_CUR_DIS, usbmisc->base); + 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; } + writel(reg, usbmisc->base); reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK; @@ -492,6 +508,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = { .compatible = "fsl,imx6ul-usbmisc", .data = &imx6sx_usbmisc_ops, }, + { + .compatible = "fsl,imx7d-usbmisc", + .data = &imx7d_usbmisc_ops, + }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);