Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp834688imu; Wed, 23 Jan 2019 06:32:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN6E3VUbZjJ3FGsb1pbeC+Z8q9evJ9Zy3AInNmCFdcDKjjr2d0pXWxYeSSRUw/2lw6/ooLu6 X-Received: by 2002:a17:902:bc3:: with SMTP id 61mr2423896plr.15.1548253963114; Wed, 23 Jan 2019 06:32:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548253963; cv=none; d=google.com; s=arc-20160816; b=gvsr2OegDMOeZBjf3j2JNwUPE+jYIOMMGFEuKeqrCGaTzCj+C/3Qggm6iYL+wpI1el VlglzT1BbCwuPjmXVPXrT/HhWeuX+KGdSUUKX2B98mjWGv6mDt0d1olBfV8GY5wLjUnJ 5SgIxqQ3zox2UwFHconIjpm5h5ZJzJF0LJxnB8vM7nKx1IYz76oaRcoxxhrDmrnn6bY3 D+4WLcmOWl9a0E1vlXu4qd2Fm6fEQUnQPmmlRbHibxRlMA9Oahyi0vzxBHsx8T+DrRiW cNajiFOQWxQYQEPdX9mcFLWpDlES3+hOoX1XPghJ5bZ18BrgQ2U11CI9wa2eYqATDe3D Uq/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BHa2n+VIhYAHaurhPdoBqJOiNMLhCkwOpdS1XWuqr5k=; b=afmOhb7QZaID3PUH7eiFydLG3CmIXJKHws78mIxtii5fvS0XVSjYbcOOChFIZ1BqGc wfvcMIqaxe/4xtpErCJowBqAk6xMdBgKb4EMrW0CYNUanncqlgNLUJmZ98jfPRa6V6JT wMd4aAQlVqO3o/VehYr7/WcZiEDhZlo9z7LiDqn3eIhLecJJNI6Vaw0QJZZiPHRH+6GH bm1Oq4aBsfmbUXn81SPYcgd9qKbhVph05PGxnemu/HNXpjJT1Q+54+Ky/9xD7qE2ihk+ PamS2LBvFiGMpWpIV9Tl8GgIgEZSj1TovGMDgLi95nDbgj3Gd1EfdDs161DSECgISomP bPYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h68si18508723plb.375.2019.01.23.06.32.26; Wed, 23 Jan 2019 06:32:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726976AbfAWObK (ORCPT + 99 others); Wed, 23 Jan 2019 09:31:10 -0500 Received: from mx1.emlix.com ([46.4.235.150]:38004 "EHLO mx1.emlix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbfAWObI (ORCPT ); Wed, 23 Jan 2019 09:31:08 -0500 Received: from mailer.emlix.com (unknown [81.20.119.6]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id A86D025F1FE; Wed, 23 Jan 2019 15:31:05 +0100 (CET) From: Philipp Puschmann To: gregkh@linuxfoundation.org Cc: robh+dt@kernel.org, mark.rutland@arm.com, Peter.Chen@nxp.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Philipp Puschmann Subject: [PATCH v4 2/2] usb: chipidea: imx: set power polarity Date: Wed, 23 Jan 2019 15:31:03 +0100 Message-Id: <20190123143103.16891-2-philipp.puschmann@emlix.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190123143103.16891-1-philipp.puschmann@emlix.com> References: <20190123143103.16891-1-philipp.puschmann@emlix.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v4: use of_property_read_bool, also apply to imx7d 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 e81de9ca8729..27c042f01018 100644 --- a/drivers/usb/chipidea/ci_hdrc_imx.c +++ b/drivers/usb/chipidea/ci_hdrc_imx.c @@ -152,8 +152,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); -- 2.20.1