Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp314235pxu; Fri, 11 Dec 2020 03:03:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+fSZlJVTnx+hbANFGgw/D4rmU81mKEmJ4beCm5uVwiwxjxsE9REbbdIjInRP8vGiQyu/f X-Received: by 2002:a17:906:1758:: with SMTP id d24mr10770262eje.287.1607684618478; Fri, 11 Dec 2020 03:03:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607684618; cv=none; d=google.com; s=arc-20160816; b=b1LftiPc93Uks/I/rFUup8akX4haxK4LG+8RF4N27Qo+HeqhexNosKc1JCfzAyP3Ws ebGDtz9v50Kt5il+NzBb4zSdCwqNBh2yOGKBLVOTgbZnAMng23xHJLlWRrUl0e5ELQuD dToXhihV9zjmEDsN4ZSGr34YjoYoTWKDerGxMc6Ms7LUl1QRq3JUdvs/QkfgPoyUB0K/ DnHhwLnoP9coEOSxad1PWX877OJenJKXP3yYr7vcn4ZxVzGtpGLwXnkGGt9yFIgkU6+Z RtYJrLcczSJaXbzh8ex0FlNfi/5dRgkL+84zI+L2GVzvjvEHHaywzq4PAWoQKnytbRO0 MLeg== 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=c63CVQCl78/M+G/nom81B56Ew2vGlOftggIVqrAApR4=; b=tGTKH1tSkN632W9v8JA0vtLHwNbeWnGndaVqzz2AH4t+Om7NLjLS3VFHfsMUU1P8oH MG//wh8vrh+p6iu2W3xaNw7e/goFuhsZEyxPJOmhTkNVkIgF2PWr4XAIqfKEUA2LTo0p npj0F++ojiKPDUnKhUuV3Z4i2pJd/dS+XHJqxDoKqB0yFMtFHfMZ5TCFEy+0JCDuDSaE 28h48THZ2grc8T3OkAgbcGJeIccMcKxUfkiOlwBjO8EZ23FQ8h78dVViTwOME0gyaQgs N6QiuKHQyTdDVZHExvfgBKVcgsyeuo48qKmtnXAQ+wpemyYeVWdCAjto8AFmC+8pLj/a TPrA== 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 z6si4129329ejw.244.2020.12.11.03.03.13; Fri, 11 Dec 2020 03:03:38 -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 S2394940AbgLKBYI (ORCPT + 99 others); Thu, 10 Dec 2020 20:24:08 -0500 Received: from foss.arm.com ([217.140.110.172]:49840 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394756AbgLKBVg (ORCPT ); Thu, 10 Dec 2020 20:21:36 -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 B0DBD1529; Thu, 10 Dec 2020 17:20:27 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 978983F66B; Thu, 10 Dec 2020 17:20:25 -0800 (PST) From: Andre Przywara To: Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec Cc: Icenowy Zheng , Linus Walleij , 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 v2 14/21] phy: sun4i-usb: Rework "pmu_unk1" handling Date: Fri, 11 Dec 2020 01:19:27 +0000 Message-Id: <20201211011934.6171-15-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20201211011934.6171-1-andre.przywara@arm.com> References: <20201211011934.6171-1-andre.przywara@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Newer SoCs (A100, H616) need to clear a different bit in our "unknown" PMU PHY register. Generalise the existing code by allowing configs to specify a bitmask of bits to clear. Signed-off-by: Andre Przywara --- drivers/phy/allwinner/phy-sun4i-usb.c | 28 +++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index 651d5e2a25ce..4ba0699e0bb4 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c @@ -115,9 +115,9 @@ struct sun4i_usb_phy_cfg { int hsic_index; enum sun4i_usb_phy_type type; u32 disc_thresh; + u32 pmu_unk1_clrbits; 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->pmu_unk1_clrbits) { + val = readl(phy->pmu + REG_PMU_UNK1); + val &= ~data->cfg->pmu_unk1_clrbits; + writel(val, phy->pmu + REG_PMU_UNK1); + } + 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); @@ -867,7 +868,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 = { @@ -876,7 +876,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 = { @@ -885,7 +884,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 = { @@ -894,7 +892,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 = { @@ -903,7 +900,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 = { @@ -912,7 +908,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 = { @@ -929,7 +924,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, + .pmu_unk1_clrbits = BIT(1), .phy0_dual_route = true, }; @@ -939,7 +934,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, + .pmu_unk1_clrbits = BIT(1), .phy0_dual_route = true, }; @@ -949,7 +944,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, + .pmu_unk1_clrbits = BIT(1), .phy0_dual_route = true, }; @@ -959,7 +954,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, + .pmu_unk1_clrbits = BIT(1), .phy0_dual_route = true, }; @@ -969,7 +964,6 @@ static const struct sun4i_usb_phy_cfg sun50i_h6_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A33, .dedicated_clocks = true, - .enable_pmu_unk1 = true, .phy0_dual_route = true, .missing_phys = BIT(1) | BIT(2), }; -- 2.17.5