From patchwork Wed Feb 27 06:51:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 10831287 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 DD2A515AC for ; Wed, 27 Feb 2019 06:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C74222CFA3 for ; Wed, 27 Feb 2019 06:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBA772CFB3; Wed, 27 Feb 2019 06:51:53 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 467892CFA3 for ; Wed, 27 Feb 2019 06:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729246AbfB0Gvw (ORCPT ); Wed, 27 Feb 2019 01:51:52 -0500 Received: from mail-eopbgr70081.outbound.protection.outlook.com ([40.107.7.81]:60384 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729345AbfB0Gvw (ORCPT ); Wed, 27 Feb 2019 01:51:52 -0500 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:X-MS-Exchange-SenderADCheck; bh=J68CMK0TSok8eCQHHdaDOanoULQjyQB96bE5YF8tPsI=; b=DL637nuTPwU7OmDukhHdasuD8DJ/O0VshYIRQchAFlKYxQ8VQddYDwAKuoD18q0c65LcnXcZu4lr47O+FmTl5G0xBUTjqDKC2TuC5qRjPr9KBeOK8tV6USn3MFK5Udopww1THrvIFpE3RlgF6gXM0vXWWSQjnCFJK8UHkZIkgCs= Received: from VI1PR04MB5327.eurprd04.prod.outlook.com (20.177.52.16) by VI1PR04MB6271.eurprd04.prod.outlook.com (20.179.26.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.15; Wed, 27 Feb 2019 06:51:34 +0000 Received: from VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::790f:a219:bcbd:6fd2]) by VI1PR04MB5327.eurprd04.prod.outlook.com ([fe80::790f:a219:bcbd:6fd2%3]) with mapi id 15.20.1643.022; Wed, 27 Feb 2019 06:51:34 +0000 From: Peter Chen To: "gregkh@linuxfoundation.org" CC: "linux-usb@vger.kernel.org" , Philipp Puschmann , Peter Chen Subject: [PATCH 3/5] usb: chipidea: imx: set power polarity Thread-Topic: [PATCH 3/5] usb: chipidea: imx: set power polarity Thread-Index: AQHUzmjgD6u7eEJzSUGThWNyBs30tg== Date: Wed, 27 Feb 2019 06:51:34 +0000 Message-ID: <20190227064908.17731-4-peter.chen@nxp.com> References: <20190227064908.17731-1-peter.chen@nxp.com> In-Reply-To: <20190227064908.17731-1-peter.chen@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.14.1 x-clientproxiedby: HK0PR03CA0034.apcprd03.prod.outlook.com (2603:1096:203:2f::22) To VI1PR04MB5327.eurprd04.prod.outlook.com (2603:10a6:803:60::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peter.chen@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2fa717e4-a516-4929-7c7f-08d69c8002ed x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB6271; x-ms-traffictypediagnostic: VI1PR04MB6271: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BVI1PR04MB6271=3B23=3AUW?= =?iso-8859-1?q?w9KASZHBjh0/2p5LKxcEwzxvwSLF1B/WJx7JyHKaG9vdWW1hL4+8GdAUMonE?= =?iso-8859-1?q?cVZs3G+oc/cn7D5RfTKNi76gc75PQJBHFDc/toSo4Kcz7pmlhAclqj0w9nU8?= =?iso-8859-1?q?LouPAwZOYI1Dze97vkZiLUUezGPQ2FMP9YD9OLaXd1I8GEHZRL0TfTIdDwqZ?= =?iso-8859-1?q?9UrfWZFBvtMzOzxWiB0Y1RVCt/P9JBFvac5NB5o8xitVEGcn56/sxPho9W57?= =?iso-8859-1?q?XU4zgyA46JsWuz5zEdaQW05ayGVTJuBQVIjdFn79Tuc59F4omTCe2H3uIF8G?= =?iso-8859-1?q?W0DnpV61Mb9ZRVH7c5bgGFvmEorcp+Cb55VVwec2HOAPlK9mWfPbdm6JPfqV?= =?iso-8859-1?q?5Jrh6NcYKvJVrD5H/bcOy+oWo0bxMdzg7uABKYGJVO6b5+9fExdbmZoRctcR?= =?iso-8859-1?q?Xxh/f7f4fCCmx1paqXxq7F26Kz5kIUQ4H25pPnQ4bn5nh3NMpF4NZLEgoLhf?= =?iso-8859-1?q?fIRvMBTTH909G5VIYkyZIVgN3s84J5XgGgPlWHbgDrKynBxum0AYF4RlV+Sx?= =?iso-8859-1?q?MTdYskuQvQ7Fj/KSrtnVCXTWzx8SLibVqnB2z83XklUOv77sTb/b7J/4l9U9?= =?iso-8859-1?q?toYa0fU/HoUtTRLNLwp9htkxDP/q73uAppDbOc6XZri02MmSuMsOMyeB7psx?= =?iso-8859-1?q?xqv5ACpila9k4v6pmohDsQMxsF8TsnwrDfhKOW2zZf88l3W30G26il3k8520?= =?iso-8859-1?q?9zz3V9eAC4v7jDiEToFo8X0TIe2+Zx6FADPw4jgh19aLXB1UExzEkA7fJha0?= =?iso-8859-1?q?Z7HnEWEm5TtsiUs5isnpznwYSfyuTuzVybuiJf7B1FvoUTxQ7gpS2M2uCaDV?= =?iso-8859-1?q?jn5zyzD/jyaFz06RSwEw6XAo+FNIYLqJemGBgyXd/KQkr40jvT7KDTN61zna?= =?iso-8859-1?q?e20/4AsCGKDyXSP1x9PfrQfnug126hY0MIk7ICmwDBCOJO+mxnRDSg2S79lu?= =?iso-8859-1?q?JYOk5P9Dlt1peQL6wsJnJXjcaTcyLuV8jBE2KVYWklojY/GFwDdwdP7pcWf2?= =?iso-8859-1?q?sk/iLMyveKaPxwL4zK36RDRqAFQ1VedWVLQi/+qj/M857GV7/qYej9RT0vKc?= =?iso-8859-1?q?Tw9xyajr+BOsf6QEdnOuZjsfZqX6KSQlNez/hA4S7torhR6eZ7ZfGu+W8zUN?= =?iso-8859-1?q?ednf219oSbYu5NDwsj9q5wEyKKsHiZaL4r8GwaIkG7KNXQIJvPPCX3XDQ5LC?= =?iso-8859-1?q?7ZmmHBudXwE/V3ElGASj55UfUv37kL25G9gWTQBIg4rB3hUEI+tikeeNPPFV?= =?iso-8859-1?q?e2kMHBaRpW2RPdeBc25DbkjddtyB8GY7jyBBqa6REDPTfdp7l50epM6Vb0GC?= =?iso-8859-1?q?Y=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0961DF5286 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(376002)(396003)(366004)(346002)(39860400002)(189003)(199004)(446003)(6486002)(6916009)(478600001)(1076003)(5660300002)(36756003)(2351001)(26005)(6512007)(106356001)(386003)(186003)(6506007)(68736007)(486006)(102836004)(5640700003)(6436002)(44832011)(105586002)(81166006)(81156014)(1730700003)(97736004)(8676002)(14454004)(54906003)(76176011)(53936002)(71200400001)(66066001)(6116002)(71190400001)(3846002)(8936002)(2501003)(2906002)(50226002)(316002)(476003)(2616005)(99286004)(25786009)(256004)(52116002)(11346002)(7736002)(86362001)(305945005)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB6271;H:VI1PR04MB5327.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 3K5wPi/F15AAAzMA24oPoGk0c8BsIA08ImEIlpHndVbIz+21Jg9rT1HZGof5bv3u5sUWTesJqTkMkh4H3AV5LGyaAi5afzLmYCx4M0HHG7Zsn26KI82Q9SlU/5R6pu2iJYlC0sGbiO5fwEGm+yTwhkvBsX8aAKA1FLA0x45qQMPeyFqFaMp8KJivtuZJVewRrXYl4irFt66zA2Y+coerk6PbH6xW0r8sMXfwIZX9NzIPCSjkGygvR5dF+Wf2wiLqHRVBAUr0i412Qq8EzftltFVmgFqHmmP/A5FcMQjY82Uag/BO+jhMH14kM5vbEbWUxqeXhHWR+dkt5qQcyIKGuwypkBZmcK7AEyPJFp4YShHDYwXPQhZWcpAPMhbvF66pvkx0Y/YjZVuc9+EPKjeBmqeOqLopuAM1vScySZSWVHI= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fa717e4-a516-4929-7c7f-08d69c8002ed X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2019 06:51:32.1837 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6271 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 From: Philipp Puschmann This patch adds support to set the power line polarity for i.MX SoCs. To let the USB controller control the power it may be necessary to configure the polarity of the power line. So far the polarity was configured by Bootloader or alternatively the power line was muxed as gpio and driven by a regulator. Also make use of of_property_read_bool. Signed-off-by: Philipp Puschmann Signed-off-by: Peter Chen --- drivers/usb/chipidea/ci_hdrc_imx.c | 4 ++-- drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c index 1ef2373c229e..d516198fcb2b 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -150,8 +150,8 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) dev_warn(dev, "No over current polarity defined\n"); } - if (of_find_property(np, "external-vbus-divider", NULL)) - data->evdo = 1; + data->pwr_pol = of_property_read_bool(np, "power-active-high"); + data->evdo = of_property_read_bool(np, "external-vbus-divider"); if (of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI) data->ulpi = 1; diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h index 7cc53e2ce564..c842e03f8767 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.h +++ b/drivers/usb/chipidea/ci_hdrc_imx.h @@ -18,6 +18,7 @@ struct imx_usbmisc_data { /* true if dt specifies polarity */ unsigned int oc_pol_configured:1; + unsigned int pwr_pol:1; /* power polarity */ unsigned int evdo:1; /* set external vbus divider option */ unsigned int ulpi:1; /* connected to an ULPI phy */ unsigned int hsic:1; /* HSIC controlller */ diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index 097ffbca0bd9..d8b67e150b12 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -63,6 +63,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_PWR_POLARITY BIT(9) #define MX6_BM_WAKEUP_ENABLE BIT(10) #define MX6_BM_UTMI_ON_CLOCK BIT(13) #define MX6_BM_ID_WAKEUP BIT(16) @@ -383,6 +384,9 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data) else if (data->oc_pol_configured) reg &= ~MX6_BM_OVER_CUR_POLARITY; } + /* If the polarity is not set keep it as setup by the bootlader */ + if (data->pwr_pol == 1) + reg |= MX6_BM_PWR_POLARITY; writel(reg, usbmisc->base + data->index * 4); /* SoC non-burst setting */ @@ -585,6 +589,9 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data) else if (data->oc_pol_configured) reg &= ~MX6_BM_OVER_CUR_POLARITY; } + /* If the polarity is not set keep it as setup by the bootlader */ + if (data->pwr_pol == 1) + reg |= MX6_BM_PWR_POLARITY; writel(reg, usbmisc->base); reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);