From patchwork Thu Nov 10 13:27:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 18127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp149933wru; Thu, 10 Nov 2022 05:34:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf5CWgJcBp5mV1+zeHOynAcLs6QGBqkP3TGlnfyZ17uLrxy9nf9GsF5BY0MmRLitcIe7Malt X-Received: by 2002:a05:6a00:3406:b0:571:825d:68b1 with SMTP id cn6-20020a056a00340600b00571825d68b1mr515729pfb.26.1668087252514; Thu, 10 Nov 2022 05:34:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668087252; cv=none; d=google.com; s=arc-20160816; b=zuYVSudfqebOWZrakneFDK51ETkSQBL4i674miQ3DHDQVmvSt2xDdY1yjpro8bmQox FlDYCA6mBF12Ve/uJZELF8hpxF23zPDSBQ4OR+MHbiYNk3c+r+RLE/p+A3DCsDa6ZBgV r+CvYjd58ZxvtnxS9q60SK7EsIs8udIO7fP4INlBgEzIXmSWgbs6Q3BtPokjjaBo7xl/ gwVEtHlhVyWAkHlZwb1An0k9uPhzKQhQmNlcTraSHbI8CRUlg0UXp1QMGYiCTHN9P8Nw 6zkl9sjrvYRRfd9S9spIbednWK/0ljIv52DL7Droc1FCNOINuo0lKvKEv60cRPWbEkd7 S96w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=S8W6/VsKY9UBnV+rl6xlAuNJ77NeZ4guQ3Yk9GbydsY=; b=nh3V6MEjYcgNUS0RDxqWfSbgLKPjPgqb30WsT5T13Zd36qolXLAhRKZYFK8R31pwkD IuaZOBMuFuF2XKKZKFx1uSfGnHxrKzV+ESRoGQF2W+jxNSklGFu84qHqaoB6TGrU2tO8 mC2N932eePQ5Jrj7fN0KzX9ymVtXOIdDFygqYASJxkqgqO7H7cS0CxDiwFwktplsKdv/ EuELlzS7fUNWp7AFyLfFzBTMRd/lJEAQbonNyZivrYjT3KEKklFgw/R1t2EYxWj1XNpe oNtIUV33Hr1vhTODN4kpbvHaEvDDNiUXz50DwKC87zUZGhwaLgKtEC6ntidAL1s6alu6 6I6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=rgnvi34R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw18-20020a17090b4d1200b0021343bcdf6csi4890375pjb.48.2022.11.10.05.33.57; Thu, 10 Nov 2022 05:34:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=rgnvi34R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbiKJN1a (ORCPT + 99 others); Thu, 10 Nov 2022 08:27:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbiKJN11 (ORCPT ); Thu, 10 Nov 2022 08:27:27 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45F0371F13 for ; Thu, 10 Nov 2022 05:27:25 -0800 (PST) X-UUID: e7d423d543bd47e0b46778ba1c5491c0-20221110 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=S8W6/VsKY9UBnV+rl6xlAuNJ77NeZ4guQ3Yk9GbydsY=; b=rgnvi34RUZgE7I1TKuea+OOjW01mxCfJArfXiccXJFrtnCcQoDcpFzeMrPjo/2uUDYfTqJ8dYLnS9fbT5KCF5J0e75m/2G7y944/SlNQYk2PT8ID7wV/Xs6/cZWSPrQfdSd+55WPcsTKE45mksLQQxRhFKcfTaToxjDhz0UhG4M=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.12,REQID:daf2ea40-0b73-4d8d-b2ef-52c26726cc5b,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:62cd327,CLOUDID:4886315d-100c-4555-952b-a62c895efded,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: e7d423d543bd47e0b46778ba1c5491c0-20221110 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 551466290; Thu, 10 Nov 2022 21:27:19 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 10 Nov 2022 21:27:18 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 10 Nov 2022 21:27:17 +0800 From: Chunfeng Yun To: Vinod Koul CC: Chunfeng Yun , Kishon Vijay Abraham I , Matthias Brugger , Nathan Chancellor , Nick Desaulniers , Tom Rix , AngeloGioacchino Del Regno , , , , , , Eddie Hung , Tianping Fang , kernel test robot Subject: [PATCH v4 1/3] phy: mediatek: fix build warning caused by clang for powerpc Date: Thu, 10 Nov 2022 21:27:14 +0800 Message-ID: <20221110132716.12294-1-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749116259103214593?= X-GMAIL-MSGID: =?utf-8?q?1749116259103214593?= Remove the temporary @mask_, this may cause build warning when use clang compiler for powerpc, but can't reproduce it when compile for arm64. the build warning is -Wtautological-constant-out-of-range-compare, and caused by "BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)" After removing @mask_, there is a "CHECK:MACRO_ARG_REUSE" when run checkpatch.pl, due to @mask is constant, no reuse problem will happen. Fixes: 84513eccd678 ("phy: mediatek: fix build warning of FIELD_PREP()") Reported-by: kernel test robot Signed-off-by: Chunfeng Yun --- v4 new patch, I'm not sure it can fix build warning, due to I don't cross compile it for powerpc using clang in office. --- drivers/phy/mediatek/phy-mtk-io.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/phy/mediatek/phy-mtk-io.h b/drivers/phy/mediatek/phy-mtk-io.h index d20ad5e5be81..58f06db822cb 100644 --- a/drivers/phy/mediatek/phy-mtk-io.h +++ b/drivers/phy/mediatek/phy-mtk-io.h @@ -39,8 +39,8 @@ static inline void mtk_phy_update_bits(void __iomem *reg, u32 mask, u32 val) /* field @mask shall be constant and continuous */ #define mtk_phy_update_field(reg, mask, val) \ ({ \ - typeof(mask) mask_ = (mask); \ - mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), "mask is not constant"); \ + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); \ }) #endif From patchwork Thu Nov 10 13:27:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 18129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp150149wru; Thu, 10 Nov 2022 05:34:39 -0800 (PST) X-Google-Smtp-Source: AMsMyM7bq8wiCuWdyKRWAbBs034JLraGr0Rj8HDZ93x65B3Q6wa5teN0k/usgsAWki+D+FDkR2Ue X-Received: by 2002:a17:90a:ea95:b0:216:df8f:14e9 with SMTP id h21-20020a17090aea9500b00216df8f14e9mr33360965pjz.222.1668087278771; Thu, 10 Nov 2022 05:34:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668087278; cv=none; d=google.com; s=arc-20160816; b=jhZ8NDF1TK0TWqgPNP7zZTqjhH6kCCpmi9zkGKfSbcY8yzwNNOOruGCLsf5XVnV9Fk f8LmEkJHSZmAAjhESqu1QUkWljrPwCyR4dWMzt8QfHJ9w4JlORnFNNEpjtVaDleafAfT rx20fW9vfGZ7P7jc60zlr65HneZ71PYpIqwz6JZt3WRGwhBTPU885vZw7XLrWgodYQWL ub0zMCiTTGQUKUd3i2tUmCd+x1uVR7lzs3gQnTyR9YeR+1JluV2gjMjV/Mb5JcKRXlgj 2AIH42jcKlSNAReku2Pf3xQhB8IdH3FEumt3bVxvSJugPhaCrSM5HNZF0sA/uPqz9aix qn3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ISjS9vItpte95t/ScfBBhnWRioYpdTc4gkkpbIxsuts=; b=r8jAPU8RfWMIhvcPR/UHqolIpTvNL5wfYWioIg+8LgXwPaWOMpWK9mhjAIIM45+aJd mGz8O+OHAxzNj7zGZUR0ok6p+DvLTtHWhLe1nuh58zmY93zhDJZ+9duLQMonaS2+wpTH dXb2SROiLTdyFYI1Cul0or0WBxCqR85MaBzqY33UHMfiDhnO4AqzSpn8L6E/I0oMyaLb 3nkYj5Q6OFNMs+ARqBiuXSgVo3IrHKXeLX64sUC1OZF/5x2QG8mkbr0PBnCmzJWOjGjR iQvcV+NKRaKKKOOtE1Fsb6FBIoyTZfUxDb+cSVQEN/9nhX2k0pI8V9fKaibZ9MyTIGZq 8d7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Td92Rnqc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y3-20020a17090abd0300b001fdd01d3d1bsi3769088pjr.168.2022.11.10.05.34.19; Thu, 10 Nov 2022 05:34:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Td92Rnqc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229488AbiKJN1c (ORCPT + 99 others); Thu, 10 Nov 2022 08:27:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbiKJN11 (ORCPT ); Thu, 10 Nov 2022 08:27:27 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ACD36A77E for ; Thu, 10 Nov 2022 05:27:25 -0800 (PST) X-UUID: 8997b60076dc475ead787c84b95da564-20221110 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=ISjS9vItpte95t/ScfBBhnWRioYpdTc4gkkpbIxsuts=; b=Td92RnqcYXUGSYJ8yLrZhJoFfgYHczI+hY0t+MsNgWA5S3S9Cdx4Cj2WwkQtv0onZoUP1P3Sr6qUacxhe+4i0gylsPL4VDSJDEed65eWw4xOZIbpO4Kg1o+05H4cfpGLX+adQFZn8Mjd0P8YnygLGeHQ3vv1NSfBIg67pxhUqck=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.12,REQID:241461dc-c833-40a3-ab01-ba0679151898,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.12,REQID:241461dc-c833-40a3-ab01-ba0679151898,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:62cd327,CLOUDID:4a86315d-100c-4555-952b-a62c895efded,B ulkID:221110212721OY81UAOK,BulkQuantity:0,Recheck:0,SF:28|17|19|48,TC:nil, Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 8997b60076dc475ead787c84b95da564-20221110 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1587391723; Thu, 10 Nov 2022 21:27:20 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 10 Nov 2022 21:27:19 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 10 Nov 2022 21:27:18 +0800 From: Chunfeng Yun To: Vinod Koul CC: Chunfeng Yun , Kishon Vijay Abraham I , Matthias Brugger , Nathan Chancellor , Nick Desaulniers , Tom Rix , AngeloGioacchino Del Regno , , , , , , Eddie Hung , Tianping Fang Subject: [PATCH v4 2/3] phy: core: add debugfs root Date: Thu, 10 Nov 2022 21:27:15 +0800 Message-ID: <20221110132716.12294-2-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110132716.12294-1-chunfeng.yun@mediatek.com> References: <20221110132716.12294-1-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749116286389828668?= X-GMAIL-MSGID: =?utf-8?q?1749116286389828668?= Add a debugfs root for phy class, then phy drivers can add debugfs files under this folder. Signed-off-by: Chunfeng Yun --- v2~v4: no changes --- drivers/phy/phy-core.c | 6 ++++++ include/linux/phy/phy.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index d93ddf1262c5..2f9f69190519 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -1204,6 +1205,9 @@ void devm_of_phy_provider_unregister(struct device *dev, } EXPORT_SYMBOL_GPL(devm_of_phy_provider_unregister); +struct dentry *phy_debug_root; +EXPORT_SYMBOL_GPL(phy_debug_root); + /** * phy_release() - release the phy * @dev: the dev member within phy @@ -1233,6 +1237,8 @@ static int __init phy_core_init(void) phy_class->dev_release = phy_release; + phy_debug_root = debugfs_create_dir("phy", NULL); + return 0; } device_initcall(phy_core_init); diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index b1413757fcc3..c398749d49b9 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -205,6 +205,8 @@ struct phy_lookup { #define devm_of_phy_provider_register_full(dev, children, xlate) \ __devm_of_phy_provider_register(dev, children, THIS_MODULE, xlate) +extern struct dentry *phy_debug_root; + static inline void phy_set_drvdata(struct phy *phy, void *data) { dev_set_drvdata(&phy->dev, data); From patchwork Thu Nov 10 13:27:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 18128 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp150152wru; Thu, 10 Nov 2022 05:34:39 -0800 (PST) X-Google-Smtp-Source: AMsMyM7Nju6HmKsOASpfSzoxFlXgJPQZkmThOgSz9NxSiSB380t3sDe98YpkovC+oq6ZbjIe7tLZ X-Received: by 2002:a17:902:d4ce:b0:187:17bd:44d7 with SMTP id o14-20020a170902d4ce00b0018717bd44d7mr58192423plg.84.1668087278902; Thu, 10 Nov 2022 05:34:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668087278; cv=none; d=google.com; s=arc-20160816; b=OCRy+blVnXvHREI2DQrZhqQd46+4hafwnKdZDtJdtoNbtQ3H5DG9ZBoF0+iFU4gKZ+ gXEp3DDj9oat37WJtrOxmgvYBj1XtXi+vMIuafJ//3O1zT6zWJXBS3O8AicmGF9eGEAb i/jXFvvGfvoFxx1laWg3DYXwDsM3kw5PbEkiCa+eIfLg32OuOosB9c4Zy3JbY3BrilMd PFyN84AhMDuPYQqDzzh63juzpM6rNDJgldODUujfccgVsZ/ZqUQR9k8gmv/ljcLJK/QX OrrDiW9U+ZSCTZnDQV+taoSXfmh7RiiFczEFF53lbgF+9UmjgnzOquK0XpozKizWRoIF b0PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F7krp4dm4Vgc2tbf/ZzNLRozKC5a7IKnCxWsP2ugBc4=; b=LVemMbo6YKripYuB6JM0hw6TtsbaypzNY4QFMR+z1XU3jhn5DCmB9gltfoN30xgiNi zYXsMsUYrTYDyv62hGQsc0VRc6SzlhGAvOpikaiOjQABhlzy3PUxwoTCK2ux797X6vKl nDPJKnWcQPq17PgrAaKJa7xheSB/0AdeFnsx0mOHK8HLgt86atuG1ju1s/yAZYuYDwNA uZarDA8nbkn9mKo7whGvrtylnHUblPue3QWHdhfhYadt0ubIwoI2DBbSukY734S3Cw/a xYKZZ0t0/XBeWYMmWXRtnZi1lXZsQbFfx5eQ6R+wRXgpGfKRAXvXFbFXVWt6HHszUSSH RlMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=XGreAKrg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k68-20020a632447000000b0041cefab5b61si19538381pgk.719.2022.11.10.05.34.22; Thu, 10 Nov 2022 05:34:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=XGreAKrg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbiKJN1f (ORCPT + 99 others); Thu, 10 Nov 2022 08:27:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbiKJN12 (ORCPT ); Thu, 10 Nov 2022 08:27:28 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3352371F17 for ; Thu, 10 Nov 2022 05:27:26 -0800 (PST) X-UUID: 54497e72dff94118ab357bbb38e449a8-20221110 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=F7krp4dm4Vgc2tbf/ZzNLRozKC5a7IKnCxWsP2ugBc4=; b=XGreAKrgW4PaMyaurW8lOmDl9oPjGfI3D1pZWq1njYw7BnvGaLToitWmqBto7qlgnLEE4/rdIg4dxiIYEAzIeZ3vKYkjXB3bk4whvLAAoD0+cNJoOoN0JbpVZU5bQvLEMWyhDdOVRRTE/XKIT2376fTRHHeRC2dm4qx4xqCIHN4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.13,REQID:171013f3-4cd6-4553-8e19-8d168182b2c5,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.13,REQID:171013f3-4cd6-4553-8e19-8d168182b2c5,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:d12e911,CLOUDID:a963e985-088c-4756-8f76-577be701e693,B ulkID:221110212721I2XC4G4F,BulkQuantity:1,Recheck:0,SF:28|17|19|48,TC:nil, Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0 X-UUID: 54497e72dff94118ab357bbb38e449a8-20221110 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1121926179; Thu, 10 Nov 2022 21:27:21 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 10 Nov 2022 21:27:20 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 10 Nov 2022 21:27:19 +0800 From: Chunfeng Yun To: Vinod Koul CC: Chunfeng Yun , Kishon Vijay Abraham I , Matthias Brugger , Nathan Chancellor , Nick Desaulniers , Tom Rix , AngeloGioacchino Del Regno , , , , , , Eddie Hung , Tianping Fang Subject: [PATCH v4 3/3] phy: mediatek: tphy: add debugfs files Date: Thu, 10 Nov 2022 21:27:16 +0800 Message-ID: <20221110132716.12294-3-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110132716.12294-1-chunfeng.yun@mediatek.com> References: <20221110132716.12294-1-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749116286451852328?= X-GMAIL-MSGID: =?utf-8?q?1749116286451852328?= These debugfs files are mainly used to make eye diagram test easier, especially helpful to do HQA test for a new IC without efuse enabled. Signed-off-by: Chunfeng Yun --- v4: fix build warning of sometimes uninitialized variable v3: fix typo of "debugfs" suggested by AngeloGioacchino v2: add CONFIG_PHY_MTK_TPHY_DEBUGFS suggested by AngeloGioacchino --- drivers/phy/mediatek/Kconfig | 5 + drivers/phy/mediatek/phy-mtk-tphy.c | 405 +++++++++++++++++++++++++++- 2 files changed, 409 insertions(+), 1 deletion(-) diff --git a/drivers/phy/mediatek/Kconfig b/drivers/phy/mediatek/Kconfig index 3125ecb5d119..e9fdfe9f519f 100644 --- a/drivers/phy/mediatek/Kconfig +++ b/drivers/phy/mediatek/Kconfig @@ -27,6 +27,11 @@ config PHY_MTK_TPHY multi-ports is first version, otherwise is second version, so you can easily distinguish them by banks layout. +config PHY_MTK_TPHY_DEBUGFS + bool "Add T-PHY Debugfs Files" + help + Say Y here to add debugfs files mainly for T-PHY HQA test. + config PHY_MTK_UFS tristate "MediaTek UFS M-PHY driver" depends on ARCH_MEDIATEK || COMPILE_TEST diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c index e906a82791bd..f220a9a409bf 100644 --- a/drivers/phy/mediatek/phy-mtk-tphy.c +++ b/drivers/phy/mediatek/phy-mtk-tphy.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -264,6 +265,8 @@ #define TPHY_CLKS_CNT 2 +#define USER_BUF_LEN(count) min_t(size_t, 8, (count)) + enum mtk_phy_version { MTK_PHY_V1 = 1, MTK_PHY_V2, @@ -310,6 +313,7 @@ struct mtk_phy_instance { struct clk_bulk_data clks[TPHY_CLKS_CNT]; u32 index; u32 type; + struct dentry *dbgfs; struct regmap *type_sw; u32 type_sw_reg; u32 type_sw_index; @@ -332,10 +336,391 @@ struct mtk_tphy { const struct mtk_phy_pdata *pdata; struct mtk_phy_instance **phys; int nphys; + struct dentry *dbgfs_root; int src_ref_clk; /* MHZ, reference clock for slew rate calibrate */ int src_coef; /* coefficient for slew rate calibrate */ }; +#if IS_ENABLED(CONFIG_PHY_MTK_TPHY_DEBUGFS) + +enum u2_phy_params { + U2P_EYE_VRT = 0, + U2P_EYE_TERM, + U2P_EFUSE_EN, + U2P_EFUSE_INTR, + U2P_DISCTH, + U2P_PRE_EMPHASIS, +}; + +enum u3_phy_params { + U3P_EFUSE_EN = 0, + U3P_EFUSE_INTR, + U3P_EFUSE_TX_IMP, + U3P_EFUSE_RX_IMP, +}; + +static const char *const u2_phy_files[] = { + [U2P_EYE_VRT] = "vrt", + [U2P_EYE_TERM] = "term", + [U2P_EFUSE_EN] = "efuse", + [U2P_EFUSE_INTR] = "intr", + [U2P_DISCTH] = "discth", + [U2P_PRE_EMPHASIS] = "preemph", +}; + +static const char *const u3_phy_files[] = { + [U3P_EFUSE_EN] = "efuse", + [U3P_EFUSE_INTR] = "intr", + [U3P_EFUSE_TX_IMP] = "tx-imp", + [U3P_EFUSE_RX_IMP] = "rx-imp", +}; + +static int u2_phy_params_show(struct seq_file *sf, void *unused) +{ + struct mtk_phy_instance *inst = sf->private; + const char *fname = file_dentry(sf->file)->d_iname; + struct u2phy_banks *u2_banks = &inst->u2_banks; + void __iomem *com = u2_banks->com; + u32 max = 0; + u32 tmp = 0; + u32 val = 0; + int ret; + + ret = match_string(u2_phy_files, ARRAY_SIZE(u2_phy_files), fname); + if (ret < 0) + return ret; + + switch (ret) { + case U2P_EYE_VRT: + tmp = readl(com + U3P_USBPHYACR1); + val = FIELD_GET(PA1_RG_VRT_SEL, tmp); + max = FIELD_MAX(PA1_RG_VRT_SEL); + break; + + case U2P_EYE_TERM: + tmp = readl(com + U3P_USBPHYACR1); + val = FIELD_GET(PA1_RG_TERM_SEL, tmp); + max = FIELD_MAX(PA1_RG_TERM_SEL); + break; + + case U2P_EFUSE_EN: + if (u2_banks->misc) { + tmp = readl(u2_banks->misc + U3P_MISC_REG1); + max = 1; + } + + val = !!(tmp & MR1_EFUSE_AUTO_LOAD_DIS); + break; + + case U2P_EFUSE_INTR: + tmp = readl(com + U3P_USBPHYACR1); + val = FIELD_GET(PA1_RG_INTR_CAL, tmp); + max = FIELD_MAX(PA1_RG_INTR_CAL); + break; + + case U2P_DISCTH: + tmp = readl(com + U3P_USBPHYACR6); + val = FIELD_GET(PA6_RG_U2_DISCTH, tmp); + max = FIELD_MAX(PA6_RG_U2_DISCTH); + break; + + case U2P_PRE_EMPHASIS: + tmp = readl(com + U3P_USBPHYACR6); + val = FIELD_GET(PA6_RG_U2_PRE_EMP, tmp); + max = FIELD_MAX(PA6_RG_U2_PRE_EMP); + break; + + default: + seq_printf(sf, "invalid, %d\n", ret); + break; + } + + seq_printf(sf, "%s : %d [0, %d]\n", fname, val, max); + + return 0; +} + +static int u2_phy_params_open(struct inode *inode, struct file *file) +{ + return single_open(file, u2_phy_params_show, inode->i_private); +} + +static ssize_t u2_phy_params_write(struct file *file, const char __user *ubuf, + size_t count, loff_t *ppos) +{ + const char *fname = file_dentry(file)->d_iname; + struct seq_file *sf = file->private_data; + struct mtk_phy_instance *inst = sf->private; + struct u2phy_banks *u2_banks = &inst->u2_banks; + void __iomem *com = u2_banks->com; + ssize_t rc; + u32 val; + int ret; + + rc = kstrtouint_from_user(ubuf, USER_BUF_LEN(count), 0, &val); + if (rc) + return rc; + + ret = match_string(u2_phy_files, ARRAY_SIZE(u2_phy_files), fname); + if (ret < 0) + return (ssize_t)ret; + + switch (ret) { + case U2P_EYE_VRT: + mtk_phy_update_field(com + U3P_USBPHYACR1, PA1_RG_VRT_SEL, val); + break; + + case U2P_EYE_TERM: + mtk_phy_update_field(com + U3P_USBPHYACR1, PA1_RG_TERM_SEL, val); + break; + + case U2P_EFUSE_EN: + if (u2_banks->misc) + mtk_phy_update_field(u2_banks->misc + U3P_MISC_REG1, + MR1_EFUSE_AUTO_LOAD_DIS, !!val); + break; + + case U2P_EFUSE_INTR: + mtk_phy_update_field(com + U3P_USBPHYACR1, PA1_RG_INTR_CAL, val); + break; + + case U2P_DISCTH: + mtk_phy_update_field(com + U3P_USBPHYACR6, PA6_RG_U2_DISCTH, val); + break; + + case U2P_PRE_EMPHASIS: + mtk_phy_update_field(com + U3P_USBPHYACR6, PA6_RG_U2_PRE_EMP, val); + break; + + default: + break; + } + + return count; +} + +static const struct file_operations u2_phy_fops = { + .open = u2_phy_params_open, + .write = u2_phy_params_write, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static void u2_phy_dbgfs_files_create(struct mtk_phy_instance *inst) +{ + u32 count = ARRAY_SIZE(u2_phy_files); + int i; + + for (i = 0; i < count; i++) + debugfs_create_file(u2_phy_files[i], 0644, inst->dbgfs, inst, &u2_phy_fops); +} + +static int u3_phy_params_show(struct seq_file *sf, void *unused) +{ + struct mtk_phy_instance *inst = sf->private; + const char *fname = file_dentry(sf->file)->d_iname; + struct u3phy_banks *u3_banks = &inst->u3_banks; + u32 val = 0; + u32 max = 0; + u32 tmp; + int ret; + + ret = match_string(u3_phy_files, ARRAY_SIZE(u3_phy_files), fname); + if (ret < 0) + return ret; + + switch (ret) { + case U3P_EFUSE_EN: + tmp = readl(u3_banks->phyd + U3P_U3_PHYD_RSV); + val = !!(tmp & P3D_RG_EFUSE_AUTO_LOAD_DIS); + max = 1; + break; + + case U3P_EFUSE_INTR: + tmp = readl(u3_banks->phya + U3P_U3_PHYA_REG0); + val = FIELD_GET(P3A_RG_IEXT_INTR, tmp); + max = FIELD_MAX(P3A_RG_IEXT_INTR); + break; + + case U3P_EFUSE_TX_IMP: + tmp = readl(u3_banks->phyd + U3P_U3_PHYD_IMPCAL0); + val = FIELD_GET(P3D_RG_TX_IMPEL, tmp); + max = FIELD_MAX(P3D_RG_TX_IMPEL); + break; + + case U3P_EFUSE_RX_IMP: + tmp = readl(u3_banks->phyd + U3P_U3_PHYD_IMPCAL1); + val = FIELD_GET(P3D_RG_RX_IMPEL, tmp); + max = FIELD_MAX(P3D_RG_RX_IMPEL); + break; + + default: + seq_printf(sf, "invalid, %d\n", ret); + break; + } + + seq_printf(sf, "%s : %d [0, %d]\n", fname, val, max); + + return 0; +} + +static int u3_phy_params_open(struct inode *inode, struct file *file) +{ + return single_open(file, u3_phy_params_show, inode->i_private); +} + +static ssize_t u3_phy_params_write(struct file *file, const char __user *ubuf, + size_t count, loff_t *ppos) +{ + const char *fname = file_dentry(file)->d_iname; + struct seq_file *sf = file->private_data; + struct mtk_phy_instance *inst = sf->private; + struct u3phy_banks *u3_banks = &inst->u3_banks; + void __iomem *phyd = u3_banks->phyd; + ssize_t rc; + u32 val; + int ret; + + rc = kstrtouint_from_user(ubuf, USER_BUF_LEN(count), 0, &val); + if (rc) + return rc; + + ret = match_string(u3_phy_files, ARRAY_SIZE(u3_phy_files), fname); + if (ret < 0) + return (ssize_t)ret; + + switch (ret) { + case U3P_EFUSE_EN: + mtk_phy_update_field(phyd + U3P_U3_PHYD_RSV, + P3D_RG_EFUSE_AUTO_LOAD_DIS, !!val); + break; + + case U3P_EFUSE_INTR: + mtk_phy_update_field(u3_banks->phya + U3P_U3_PHYA_REG0, P3A_RG_IEXT_INTR, val); + break; + + case U3P_EFUSE_TX_IMP: + mtk_phy_update_field(phyd + U3P_U3_PHYD_IMPCAL0, P3D_RG_TX_IMPEL, val); + mtk_phy_set_bits(phyd + U3P_U3_PHYD_IMPCAL0, P3D_RG_FORCE_TX_IMPEL); + break; + + case U3P_EFUSE_RX_IMP: + mtk_phy_update_field(phyd + U3P_U3_PHYD_IMPCAL1, P3D_RG_RX_IMPEL, val); + mtk_phy_set_bits(phyd + U3P_U3_PHYD_IMPCAL1, P3D_RG_FORCE_RX_IMPEL); + break; + + default: + break; + } + + return count; +} + +static const struct file_operations u3_phy_fops = { + .open = u3_phy_params_open, + .write = u3_phy_params_write, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static void u3_phy_dbgfs_files_create(struct mtk_phy_instance *inst) +{ + u32 count = ARRAY_SIZE(u3_phy_files); + int i; + + for (i = 0; i < count; i++) + debugfs_create_file(u3_phy_files[i], 0644, inst->dbgfs, inst, &u3_phy_fops); +} + +static int tphy_type_show(struct seq_file *sf, void *unused) +{ + struct mtk_phy_instance *inst = sf->private; + const char *type; + + switch (inst->type) { + case PHY_TYPE_USB2: + type = "USB2"; + break; + case PHY_TYPE_USB3: + type = "USB3"; + break; + case PHY_TYPE_PCIE: + type = "PCIe"; + break; + case PHY_TYPE_SGMII: + type = "SGMII"; + break; + case PHY_TYPE_SATA: + type = "SATA"; + break; + default: + type = ""; + } + + seq_printf(sf, "%s\n", type); + + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(tphy_type); + +static void tphy_debugfs_init(struct mtk_tphy *tphy, struct mtk_phy_instance *inst) +{ + char name[16]; + + snprintf(name, sizeof(name) - 1, "phy.%d", inst->index); + inst->dbgfs = debugfs_create_dir(name, tphy->dbgfs_root); + + debugfs_create_file("type", 0444, inst->dbgfs, inst, &tphy_type_fops); + + switch (inst->type) { + case PHY_TYPE_USB2: + u2_phy_dbgfs_files_create(inst); + break; + case PHY_TYPE_USB3: + case PHY_TYPE_PCIE: + u3_phy_dbgfs_files_create(inst); + break; + default: + break; + } +} + +static void tphy_debugfs_exit(struct mtk_phy_instance *inst) +{ + debugfs_remove_recursive(inst->dbgfs); + inst->dbgfs = NULL; +} + +static void tphy_debugfs_root_create(struct mtk_tphy *tphy) +{ + tphy->dbgfs_root = debugfs_create_dir(dev_name(tphy->dev), phy_debug_root); +} + +static void tphy_debugfs_root_remove(struct mtk_tphy *tphy) +{ + debugfs_remove_recursive(tphy->dbgfs_root); + tphy->dbgfs_root = NULL; +} + +#else + +static void tphy_debugfs_init(struct mtk_tphy *tphy, struct mtk_phy_instance *inst) +{} + +static void tphy_debugfs_exit(struct mtk_phy_instance *inst) +{} + +static void tphy_debugfs_root_create(struct mtk_tphy *tphy) +{} + +static void tphy_debugfs_root_remove(struct mtk_tphy *tphy) +{} + +#endif + static void hs_slew_rate_calibrate(struct mtk_tphy *tphy, struct mtk_phy_instance *instance) { @@ -1032,6 +1417,8 @@ static int mtk_phy_init(struct phy *phy) return -EINVAL; } + tphy_debugfs_init(tphy, instance); + return 0; } @@ -1068,6 +1455,8 @@ static int mtk_phy_exit(struct phy *phy) struct mtk_phy_instance *instance = phy_get_drvdata(phy); struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent); + tphy_debugfs_exit(instance); + if (instance->type == PHY_TYPE_USB2) u2_phy_instance_exit(tphy, instance); @@ -1295,15 +1684,29 @@ static int mtk_tphy_probe(struct platform_device *pdev) } provider = devm_of_phy_provider_register(dev, mtk_phy_xlate); + if (IS_ERR(provider)) + return dev_err_probe(dev, PTR_ERR(provider), "probe failed\n"); + + tphy_debugfs_root_create(tphy); + return 0; - return PTR_ERR_OR_ZERO(provider); put_child: of_node_put(child_np); return retval; } +static int mtk_tphy_remove(struct platform_device *pdev) +{ + struct mtk_tphy *tphy; + + tphy = platform_get_drvdata(pdev); + tphy_debugfs_root_remove(tphy); + return 0; +} + static struct platform_driver mtk_tphy_driver = { .probe = mtk_tphy_probe, + .remove = mtk_tphy_remove, .driver = { .name = "mtk-tphy", .of_match_table = mtk_tphy_id_table,