From patchwork Mon Jan 16 19:14:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Icenowy Zheng X-Patchwork-Id: 9519335 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 956F96020B for ; Mon, 16 Jan 2017 19:16:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8548328306 for ; Mon, 16 Jan 2017 19:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 782BF2832F; Mon, 16 Jan 2017 19:16:54 +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=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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 062D728306 for ; Mon, 16 Jan 2017 19:16:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cTClu-0002Mg-0X; Mon, 16 Jan 2017 19:16:50 +0000 Received: from forward9j.cmail.yandex.net ([5.255.227.110]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTClW-0001yv-Gq for linux-arm-kernel@lists.infradead.org; Mon, 16 Jan 2017 19:16:28 +0000 Received: from smtp3m.mail.yandex.net (smtp3m.mail.yandex.net [IPv6:2a02:6b8:0:2519::125]) by forward9j.cmail.yandex.net (Yandex) with ESMTP id 6523F223BC; Mon, 16 Jan 2017 22:16:03 +0300 (MSK) Received: from smtp3m.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp3m.mail.yandex.net (Yandex) with ESMTP id 296CE28409F8; Mon, 16 Jan 2017 22:15:55 +0300 (MSK) Received: by smtp3m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id h4aXT6W1l1-FZj8sVa7; Mon, 16 Jan 2017 22:15:47 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aosc.xyz; s=mail; t=1484594155; bh=/wNOTRXZwAjdhh5Vl+zxH9GiAfmYAsh3GMyHi3rUmCo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=WGVYh6e92IFZDt99go4rSoPnegX/+azCbHdJ1MziUuSjEmLsDjjr0+fhinvwGSvhE QzAWeAE9JhRNB3fGrFg0GDuEQ8LGxc3iQ8/XdAEC6X+6fduRtlHRhFZCZbqXXFOUFU JPDnF7ZpOpN+YIO+6sxVcCwpQr4fO+sffNvM3EsQ= Authentication-Results: smtp3m.mail.yandex.net; dkim=pass header.i=@aosc.xyz X-Yandex-ForeignMX: FR X-Yandex-Suid-Status: 1 0, 1 0, 1 0, 1 0, 1 0, 1 0, 1 0, 1 0, 1 0, 1 0, 1 0, 1 1130000036118848 From: Icenowy Zheng To: Rob Herring , Maxime Ripard , Chen-Yu Tsai , Kishon Vijay Abraham I , Greg Kroah-Hartman , Bin Liu Subject: [PATCH 1/4] phy: sun4i-usb: support PHY0 on H3 in MUSB mode Date: Tue, 17 Jan 2017 03:14:46 +0800 Message-Id: <20170116191449.50397-2-icenowy@aosc.xyz> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170116191449.50397-1-icenowy@aosc.xyz> References: <20170116191449.50397-1-icenowy@aosc.xyz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170116_111627_004975_420C5CD6 X-CRM114-Status: GOOD ( 13.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 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-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Icenowy Zheng , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 The PHY0 on H3 can be wired either to MUSB controller or OHCI/EHCI controller. The original driver wired it to OHCI/EHCI controller; however, as the code to use PHY0 as OHCI/EHCI is missing, it makes the PHY fully unusable. Rename the register (according to its function and the name in BSP driver), and remove the code which wires the PHY0 to OHCI/EHCI, as MUSB can support both peripheral and host mode (although the host mode of MUSB is buggy). The register that is renamed is now unused, as its initial value is just MUSB mode. However, when OHCI/EHCI mode support is added, the register can be used again. Signed-off-by: Icenowy Zheng --- drivers/phy/phy-sun4i-usb.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index bf28a0fdd569..6b193a635c6b 100644 --- a/drivers/phy/phy-sun4i-usb.c +++ b/drivers/phy/phy-sun4i-usb.c @@ -49,7 +49,7 @@ #define REG_PHYBIST 0x08 #define REG_PHYTUNE 0x0c #define REG_PHYCTL_A33 0x10 -#define REG_PHY_UNK_H3 0x20 +#define REG_PHY_OTGCTL 0x20 #define REG_PMU_UNK1 0x10 @@ -269,23 +269,16 @@ static int sun4i_usb_phy_init(struct phy *_phy) writel(val & ~2, phy->pmu + REG_PMU_UNK1); } - if (data->cfg->type == sun8i_h3_phy) { - if (phy->index == 0) { - val = readl(data->base + REG_PHY_UNK_H3); - writel(val & ~1, data->base + REG_PHY_UNK_H3); - } - } else { - /* Enable USB 45 Ohm resistor calibration */ - if (phy->index == 0) - sun4i_usb_phy_write(phy, PHY_RES45_CAL_EN, 0x01, 1); + /* Enable USB 45 Ohm resistor calibration */ + if (phy->index == 0) + sun4i_usb_phy_write(phy, PHY_RES45_CAL_EN, 0x01, 1); - /* Adjust PHY's magnitude and rate */ - sun4i_usb_phy_write(phy, PHY_TX_AMPLITUDE_TUNE, 0x14, 5); + /* Adjust PHY's magnitude and rate */ + sun4i_usb_phy_write(phy, PHY_TX_AMPLITUDE_TUNE, 0x14, 5); - /* Disconnect threshold adjustment */ - sun4i_usb_phy_write(phy, PHY_DISCON_TH_SEL, - data->cfg->disc_thresh, 2); - } + /* Disconnect threshold adjustment */ + sun4i_usb_phy_write(phy, PHY_DISCON_TH_SEL, + data->cfg->disc_thresh, 2); sun4i_usb_phy_passby(phy, 1);