Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp593541pxb; Wed, 27 Jan 2021 16:08:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJx28a68gGwvUJuPh3cSw4WFix9AwkBeYbnzd93rs+JS3l98/LMvfg2gEge3bme1eHjVNu/J X-Received: by 2002:a17:906:5958:: with SMTP id g24mr8541395ejr.377.1611792505968; Wed, 27 Jan 2021 16:08:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792505; cv=none; d=google.com; s=arc-20160816; b=wcDbG3QKpSy+1xLg47JJUXapelodvOpoeAlCjpIbqtFVQ7ruX+tXZ/kecsZIjy92e+ 0EjIxfrtYYv1icq3CPY4/yrTmaz/I2LnlcX0vYy/cEJpz2hFwHMoa/eE4ficXkNrAZBO evCr6d4qTY+CThMxGIqmAuFU3bpNsHkMqgIdR8agDA+3XV/jsRMlSHPb8fkW9fYKHv2W Ul9N1To7eSETsNxc0oGht4wxNpMVoea8l8f6spXEXrPqJz/iwziscJM91via0D6MjOLK k/VO2VbjNkRYgkFvMhEv1ADHsbQcZzPQKSGAnX4kAX2WaP6B1mtASOtaZ0VmnNxOFTB4 I8rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=GeJaesgthr0mk4iGMDqSMF1dRClFmPdFj+BCjJl0C4Y=; b=gHXnqxycWAjNGj4S/fvuX1kSe3NJV174G769YZoWx/46crQjyjjDKjOdoUwhDi7du+ rNuwS/kNRiNYaiQnOY478og+O/LqU1WUtlk0gEZrnY4m4aOFdlc3qY19SLeh0HeX0/1d U4e+i2bqB0DMk2fuF1Vp70qFlcVJxcBkdswAMLolXYmlaRb4h5DG06YVbDHSXcdm8AlE sRZaWiNHFeGKH70hHyEPnmgxcOTNL0xU3DvUu4vJCy/mRypGJ+UtlaBNk7ovmdBs/rIY M3zT44n3kMrQLBqld4BJEa1j/3Y0Mf05EqgU9BFNTpWqH5MTB8W/Sh5SvVKELPvYMdcb oKig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i22si1509130ejb.513.2021.01.27.16.08.02; Wed, 27 Jan 2021 16:08:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343832AbhA0Rbk (ORCPT + 99 others); Wed, 27 Jan 2021 12:31:40 -0500 Received: from foss.arm.com ([217.140.110.172]:57012 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235791AbhA0R3Y (ORCPT ); Wed, 27 Jan 2021 12:29:24 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43DA814FF; Wed, 27 Jan 2021 09:26:29 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2C3893F66E; Wed, 27 Jan 2021 09:26:27 -0800 (PST) From: Andre Przywara To: Maxime Ripard , Chen-Yu Tsai Cc: Jernej Skrabec , Samuel Holland , Icenowy Zheng , Rob Herring , =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= , Shuosheng Huang , Yangtao Li , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Kishon Vijay Abraham I , Vinod Koul Subject: [PATCH v5 17/20] phy: sun4i-usb: Rework HCI PHY (aka. "pmu_unk1") handling Date: Wed, 27 Jan 2021 17:24:57 +0000 Message-Id: <20210127172500.13356-18-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20210127172500.13356-1-andre.przywara@arm.com> References: <20210127172500.13356-1-andre.przywara@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As Icenowy pointed out, newer manuals (starting with H6) actually document the register block at offset 0x800 as "HCI controller and PHY interface", also describe the bits in our "PMU_UNK1" register. Let's put proper names to those "unknown" variables and symbols. While we are at it, generalise the existing code by allowing a bitmap of bits to clear, to cover newer SoCs: The A100 and H616 use a different bit for the SIDDQ control. Signed-off-by: Andre Przywara Acked-by: Maxime Ripard --- drivers/phy/allwinner/phy-sun4i-usb.c | 29 +++++++++++---------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index 788dd5cdbb7d..539209fe3468 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c @@ -43,7 +43,7 @@ #define REG_PHYCTL_A33 0x10 #define REG_PHY_OTGCTL 0x20 -#define REG_PMU_UNK1 0x10 +#define REG_HCI_PHY_CTL 0x10 #define PHYCTL_DATA BIT(7) @@ -115,9 +115,9 @@ struct sun4i_usb_phy_cfg { int hsic_index; enum sun4i_usb_phy_type type; u32 disc_thresh; + u32 hci_phy_ctl_siddq; u8 phyctl_offset; bool dedicated_clocks; - bool enable_pmu_unk1; bool phy0_dual_route; int missing_phys; }; @@ -288,6 +288,12 @@ static int sun4i_usb_phy_init(struct phy *_phy) return ret; } + if (phy->pmu && data->cfg->hci_phy_ctl_siddq) { + val = readl(phy->pmu + REG_HCI_PHY_CTL); + val &= ~data->cfg->hci_phy_ctl_siddq; + writel(val, phy->pmu + REG_HCI_PHY_CTL); + } + if (data->cfg->type == sun8i_a83t_phy || data->cfg->type == sun50i_h6_phy) { if (phy->index == 0) { @@ -297,11 +303,6 @@ static int sun4i_usb_phy_init(struct phy *_phy) writel(val, data->base + data->cfg->phyctl_offset); } } else { - if (phy->pmu && data->cfg->enable_pmu_unk1) { - val = readl(phy->pmu + REG_PMU_UNK1); - writel(val & ~2, phy->pmu + REG_PMU_UNK1); - } - /* Enable USB 45 Ohm resistor calibration */ if (phy->index == 0) sun4i_usb_phy_write(phy, PHY_RES45_CAL_EN, 0x01, 1); @@ -863,7 +864,6 @@ static const struct sun4i_usb_phy_cfg sun4i_a10_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = false, - .enable_pmu_unk1 = false, }; static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = { @@ -872,7 +872,6 @@ static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = { .disc_thresh = 2, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = false, - .enable_pmu_unk1 = false, }; static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = { @@ -881,7 +880,6 @@ static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = true, - .enable_pmu_unk1 = false, }; static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = { @@ -890,7 +888,6 @@ static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = { .disc_thresh = 2, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = false, - .enable_pmu_unk1 = false, }; static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = { @@ -899,7 +896,6 @@ static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = true, - .enable_pmu_unk1 = false, }; static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = { @@ -908,7 +904,6 @@ static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A33, .dedicated_clocks = true, - .enable_pmu_unk1 = false, }; static const struct sun4i_usb_phy_cfg sun8i_a83t_cfg = { @@ -925,7 +920,7 @@ static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A33, .dedicated_clocks = true, - .enable_pmu_unk1 = true, + .hci_phy_ctl_siddq = BIT(1), .phy0_dual_route = true, }; @@ -935,7 +930,7 @@ static const struct sun4i_usb_phy_cfg sun8i_r40_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A33, .dedicated_clocks = true, - .enable_pmu_unk1 = true, + .hci_phy_ctl_siddq = BIT(1), .phy0_dual_route = true, }; @@ -945,7 +940,7 @@ static const struct sun4i_usb_phy_cfg sun8i_v3s_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A33, .dedicated_clocks = true, - .enable_pmu_unk1 = true, + .hci_phy_ctl_siddq = BIT(1), .phy0_dual_route = true, }; @@ -955,7 +950,7 @@ static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A33, .dedicated_clocks = true, - .enable_pmu_unk1 = true, + .hci_phy_ctl_siddq = BIT(1), .phy0_dual_route = true, }; -- 2.17.5