diff mbox series

[RESEND,v3,2/2] phy: mediatek: tphy: add debugfs files

Message ID 20221025054233.9763-2-chunfeng.yun@mediatek.com (mailing list archive)
State New, archived
Headers show
Series [RESEND,v3,1/2] phy: core: add debugfs root | expand

Commit Message

Chunfeng Yun Oct. 25, 2022, 5:42 a.m. UTC
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 <chunfeng.yun@mediatek.com>
---
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 | 403 +++++++++++++++++++++++++++-
 2 files changed, 407 insertions(+), 1 deletion(-)

Comments

Chunfeng Yun Nov. 4, 2022, 1:29 a.m. UTC | #1
On Sat, 2022-10-29 at 08:46 +0800, kernel test robot wrote:
> Hi Chunfeng,
> 
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on linus/master]
> [also build test WARNING on v6.1-rc2 next-20221028]
> [If your patch is applied to the wrong git tree, kindly drop us a
> note.
> And when submitting patch, we suggest to use '--base' as documented
> in
> 
https://urldefense.com/v3/__https://git-scm.com/docs/git-format-patch*_base_tree_information__;Iw!!CTRNKA9wMg0ARbw!z3s2-V0HQmy7WniZmIk27fAkjJ-SWgBBh_9yIedH9eC1yz0opmDxTk9SKAYSolmkDxbL$
>  ]
> 
> url:    
> https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux/commits/Chunfeng-Yun/phy-core-add-debugfs-root/20221025-134424__;!!CTRNKA9wMg0ARbw!z3s2-V0HQmy7WniZmIk27fAkjJ-SWgBBh_9yIedH9eC1yz0opmDxTk9SKAYSog09qFwS$
>  
> patch link:    
> https://lore.kernel.org/r/20221025054233.9763-2-chunfeng.yun%40mediatek.com
> patch subject: [PATCH RESEND v3 2/2] phy: mediatek: tphy: add debugfs
> files
> config: powerpc-allyesconfig
> compiler: clang version 16.0.0 (
> https://urldefense.com/v3/__https://github.com/llvm/llvm-project__;!!CTRNKA9wMg0ARbw!z3s2-V0HQmy7WniZmIk27fAkjJ-SWgBBh_9yIedH9eC1yz0opmDxTk9SKAYSoj8X7Pu_$
> $  791a7ae1ba3efd6bca96338e10ffde557ba83920)
> reproduce (this is a W=1 build):
>         wget 
> https://urldefense.com/v3/__https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross__;!!CTRNKA9wMg0ARbw!z3s2-V0HQmy7WniZmIk27fAkjJ-SWgBBh_9yIedH9eC1yz0opmDxTk9SKAYSont3c9j-$
>   -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # install powerpc cross compiling tool for clang build
>         # apt-get install binutils-powerpc-linux-gnu
>         # 
> https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux/commit/6dae09cf2d77be80664d0ec84f631c6282fdb728__;!!CTRNKA9wMg0ARbw!z3s2-V0HQmy7WniZmIk27fAkjJ-SWgBBh_9yIedH9eC1yz0opmDxTk9SKAYSoou8Is0N$
>  
>         git remote add linux-review 
> https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux__;!!CTRNKA9wMg0ARbw!z3s2-V0HQmy7WniZmIk27fAkjJ-SWgBBh_9yIedH9eC1yz0opmDxTk9SKAYSovcqtevR$
>  
>         git fetch --no-tags linux-review Chunfeng-Yun/phy-core-add-
> debugfs-root/20221025-134424
>         git checkout 6dae09cf2d77be80664d0ec84f631c6282fdb728
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross
> W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/phy/mediatek/
> drivers/staging/rtl8723bs/ drivers/tty/serial/
> 
> If you fix the issue, kindly add following tag where applicable
> > Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>                    BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)
> >     \
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~
>    note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-
> limit=0 to see all)
>    include/linux/compiler_types.h:357:22: note: expanded from macro
> 'compiletime_assert'
>            _compiletime_assert(condition, msg, __compiletime_assert_,
> __COUNTER__)
>            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>    include/linux/compiler_types.h:345:23: note: expanded from macro
> '_compiletime_assert'
>            __compiletime_assert(condition, msg, prefix, suffix)
>            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler_types.h:337:9: note: expanded from macro
> '__compiletime_assert'
>                    if
> (!(condition))                                       \
>                          ^~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:479:4: warning: result of
> comparison of constant 18446744073709551615 with expression of type
> 'typeof (_Generic((mask_), char: (unsigned char)0, unsigned char:
> (unsigned char)0, signed char: (unsigned char)0, unsigned short:
> (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned
> int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long:
> (unsigned long)0, unsigned long long: (unsigned long long)0, long
> long: (unsigned long long)0, default: (mask_)))' (aka 'unsigned
> long') is always false [-Wtautological-constant-out-of-range-compare]
>                            mtk_phy_update_field(u2_banks->misc +
> U3P_MISC_REG1,
>                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-io.h:43:34: note: expanded from macro
> 'mtk_phy_update_field'
>            mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \
>                                            ^~~~~~~~~~~~~~~~~~~~~~
>    include/linux/bitfield.h:114:3: note: expanded from macro
> 'FIELD_PREP'
>                    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP:
> ");    \
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~
>    include/linux/bitfield.h:71:53: note: expanded from macro
> '__BF_FIELD_CHECK'
>                    BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)
> >     \
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~
>    note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-
> limit=0 to see all)
>    include/linux/compiler_types.h:357:22: note: expanded from macro
> 'compiletime_assert'
>            _compiletime_assert(condition, msg, __compiletime_assert_,
> __COUNTER__)
>            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>    include/linux/compiler_types.h:345:23: note: expanded from macro
> '_compiletime_assert'
>            __compiletime_assert(condition, msg, prefix, suffix)
>            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler_types.h:337:9: note: expanded from macro
> '__compiletime_assert'
>                    if
> (!(condition))                                       \
>                          ^~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:484:3: warning: result of
> comparison of constant 18446744073709551615 with expression of type
> 'typeof (_Generic((mask_), char: (unsigned char)0, unsigned char:
> (unsigned char)0, signed char: (unsigned char)0, unsigned short:
> (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned
> int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long:
> (unsigned long)0, unsigned long long: (unsigned long long)0, long
> long: (unsigned long long)0, default: (mask_)))' (aka 'unsigned
> long') is always false [-Wtautological-constant-out-of-range-compare]
>                    mtk_phy_update_field(com + U3P_USBPHYACR1,
> PA1_RG_INTR_CAL, val);
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-io.h:43:34: note: expanded from macro
> 'mtk_phy_update_field'
>            mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \
>                                            ^~~~~~~~~~~~~~~~~~~~~~
>    include/linux/bitfield.h:114:3: note: expanded from macro
> 'FIELD_PREP'
>                    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP:
> ");    \
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~
>    include/linux/bitfield.h:71:53: note: expanded from macro
> '__BF_FIELD_CHECK'
>                    BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)
> >     \
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~
>    note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-
> limit=0 to see all)
>    include/linux/compiler_types.h:357:22: note: expanded from macro
> 'compiletime_assert'
>            _compiletime_assert(condition, msg, __compiletime_assert_,
> __COUNTER__)
>            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>    include/linux/compiler_types.h:345:23: note: expanded from macro
> '_compiletime_assert'
>            __compiletime_assert(condition, msg, prefix, suffix)
>            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler_types.h:337:9: note: expanded from macro
> '__compiletime_assert'
>                    if
> (!(condition))                                       \
>                          ^~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:488:3: warning: result of
> comparison of constant 18446744073709551615 with expression of type
> 'typeof (_Generic((mask_), char: (unsigned char)0, unsigned char:
> (unsigned char)0, signed char: (unsigned char)0, unsigned short:
> (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned
> int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long:
> (unsigned long)0, unsigned long long: (unsigned long long)0, long
> long: (unsigned long long)0, default: (mask_)))' (aka 'unsigned
> long') is always false [-Wtautological-constant-out-of-range-compare]
>                    mtk_phy_update_field(com + U3P_USBPHYACR6,
> PA6_RG_U2_DISCTH, val);
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-io.h:43:34: note: expanded from macro
> 'mtk_phy_update_field'
>            mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \
>                                            ^~~~~~~~~~~~~~~~~~~~~~
>    include/linux/bitfield.h:114:3: note: expanded from macro
> 'FIELD_PREP'
>                    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP:
> ");    \
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~
>    include/linux/bitfield.h:71:53: note: expanded from macro
> '__BF_FIELD_CHECK'
>                    BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)
> >     \
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~
>    note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-
> limit=0 to see all)
>    include/linux/compiler_types.h:357:22: note: expanded from macro
> 'compiletime_assert'
>            _compiletime_assert(condition, msg, __compiletime_assert_,
> __COUNTER__)
>            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>    include/linux/compiler_types.h:345:23: note: expanded from macro
> '_compiletime_assert'
>            __compiletime_assert(condition, msg, prefix, suffix)
>            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler_types.h:337:9: note: expanded from macro
> '__compiletime_assert'
>                    if
> (!(condition))                                       \
>                          ^~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:492:3: warning: result of
> comparison of constant 18446744073709551615 with expression of type
> 'typeof (_Generic((mask_), char: (unsigned char)0, unsigned char:
> (unsigned char)0, signed char: (unsigned char)0, unsigned short:
> (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned
> int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long:
> (unsigned long)0, unsigned long long: (unsigned long long)0, long
> long: (unsigned long long)0, default: (mask_)))' (aka 'unsigned
> long') is always false [-Wtautological-constant-out-of-range-compare]
>                    mtk_phy_update_field(com + U3P_USBPHYACR6,
> PA6_RG_U2_PRE_EMP, val);
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-io.h:43:34: note: expanded from macro
> 'mtk_phy_update_field'
>            mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \
>                                            ^~~~~~~~~~~~~~~~~~~~~~
>    include/linux/bitfield.h:114:3: note: expanded from macro
> 'FIELD_PREP'
>                    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP:
> ");    \
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~
>    include/linux/bitfield.h:71:53: note: expanded from macro
> '__BF_FIELD_CHECK'
>                    BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)
> >     \
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~
>    note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-
> limit=0 to see all)
>    include/linux/compiler_types.h:357:22: note: expanded from macro
> 'compiletime_assert'
>            _compiletime_assert(condition, msg, __compiletime_assert_,
> __COUNTER__)
>            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>    include/linux/compiler_types.h:345:23: note: expanded from macro
> '_compiletime_assert'
>            __compiletime_assert(condition, msg, prefix, suffix)
>            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler_types.h:337:9: note: expanded from macro
> '__compiletime_assert'
>                    if
> (!(condition))                                       \
>                          ^~~~~~~~~
> > > drivers/phy/mediatek/phy-mtk-tphy.c:556:2: warning: variable
> > > 'val' is used uninitialized whenever switch default is taken [-
> > > Wsometimes-uninitialized]
> 
>            default:
>            ^~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:561:45: note: uninitialized
> use occurs here
>            seq_printf(sf, "%s : %d [0, %d]\n", fname, val, max);
>                                                       ^~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:524:9: note: initialize the
> variable 'val' to silence this warning
>            u32 val, tmp, max;
>                   ^
>                    = 0
> > > drivers/phy/mediatek/phy-mtk-tphy.c:556:2: warning: variable
> > > 'max' is used uninitialized whenever switch default is taken [-
> > > Wsometimes-uninitialized]
> 
>            default:
>            ^~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:561:50: note: uninitialized
> use occurs here
>            seq_printf(sf, "%s : %d [0, %d]\n", fname, val, max);
>                                                            ^~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:524:19: note: initialize the
> variable 'max' to silence this warning
>            u32 val, tmp, max;
>                             ^
>                              = 0
>    drivers/phy/mediatek/phy-mtk-tphy.c:593:3: warning: result of
> comparison of constant 18446744073709551615 with expression of type
> 'typeof (_Generic((mask_), char: (unsigned char)0, unsigned char:
> (unsigned char)0, signed char: (unsigned char)0, unsigned short:
> (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned
> int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long:
> (unsigned long)0, unsigned long long: (unsigned long long)0, long
> long: (unsigned long long)0, default: (mask_)))' (aka 'unsigned
> long') is always false [-Wtautological-constant-out-of-range-compare]
>                    mtk_phy_update_field(phyd + U3P_U3_PHYD_RSV,
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-io.h:43:34: note: expanded from macro
> 'mtk_phy_update_field'
>            mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \
>                                            ^~~~~~~~~~~~~~~~~~~~~~
>    include/linux/bitfield.h:114:3: note: expanded from macro
> 'FIELD_PREP'
>                    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP:
> ");    \
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~
>    include/linux/bitfield.h:71:53: note: expanded from macro
> '__BF_FIELD_CHECK'
>                    BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)
> >     \
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~
>    note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-
> limit=0 to see all)
>    include/linux/compiler_types.h:357:22: note: expanded from macro
> 'compiletime_assert'
>            _compiletime_assert(condition, msg, __compiletime_assert_,
> __COUNTER__)
>            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>    include/linux/compiler_types.h:345:23: note: expanded from macro
> '_compiletime_assert'
>            __compiletime_assert(condition, msg, prefix, suffix)
>            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler_types.h:337:9: note: expanded from macro
> '__compiletime_assert'
>                    if
> (!(condition))                                       \
>                          ^~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:598:3: warning: result of
> comparison of constant 18446744073709551615 with expression of type
> 'typeof (_Generic((mask_), char: (unsigned char)0, unsigned char:
> (unsigned char)0, signed char: (unsigned char)0, unsigned short:
> (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned
> int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long:
> (unsigned long)0, unsigned long long: (unsigned long long)0, long
> long: (unsigned long long)0, default: (mask_)))' (aka 'unsigned
> long') is always false [-Wtautological-constant-out-of-range-compare]
>                    mtk_phy_update_field(u3_banks->phya +
> U3P_U3_PHYA_REG0, P3A_RG_IEXT_INTR, val);
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-io.h:43:34: note: expanded from macro
> 'mtk_phy_update_field'
>            mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \
>                                            ^~~~~~~~~~~~~~~~~~~~~~
>    include/linux/bitfield.h:114:3: note: expanded from macro
> 'FIELD_PREP'
>                    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP:
> ");    \
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~
>    include/linux/bitfield.h:71:53: note: expanded from macro
> '__BF_FIELD_CHECK'
>                    BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)
> >     \
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~
>    note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-
> limit=0 to see all)
>    include/linux/compiler_types.h:357:22: note: expanded from macro
> 'compiletime_assert'
>            _compiletime_assert(condition, msg, __compiletime_assert_,
> __COUNTER__)
>            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>    include/linux/compiler_types.h:345:23: note: expanded from macro
> '_compiletime_assert'
>            __compiletime_assert(condition, msg, prefix, suffix)
>            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler_types.h:337:9: note: expanded from macro
> '__compiletime_assert'
>                    if
> (!(condition))                                       \
>                          ^~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:602:3: warning: result of
> comparison of constant 18446744073709551615 with expression of type
> 'typeof (_Generic((mask_), char: (unsigned char)0, unsigned char:
> (unsigned char)0, signed char: (unsigned char)0, unsigned short:
> (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned
> int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long:
> (unsigned long)0, unsigned long long: (unsigned long long)0, long
> long: (unsigned long long)0, default: (mask_)))' (aka 'unsigned
> long') is always false [-Wtautological-constant-out-of-range-compare]
>                    mtk_phy_update_field(phyd + U3P_U3_PHYD_IMPCAL0,
> P3D_RG_TX_IMPEL, val);
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-io.h:43:34: note: expanded from macro
> 'mtk_phy_update_field'
>            mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \
>                                            ^~~~~~~~~~~~~~~~~~~~~~
>    include/linux/bitfield.h:114:3: note: expanded from macro
> 'FIELD_PREP'
>                    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP:
> ");    \
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~
>    include/linux/bitfield.h:71:53: note: expanded from macro
> '__BF_FIELD_CHECK'
>                    BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)
> >     \
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~
>    note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-
> limit=0 to see all)
>    include/linux/compiler_types.h:357:22: note: expanded from macro
> 'compiletime_assert'
>            _compiletime_assert(condition, msg, __compiletime_assert_,
> __COUNTER__)
>            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>    include/linux/compiler_types.h:345:23: note: expanded from macro
> '_compiletime_assert'
>            __compiletime_assert(condition, msg, prefix, suffix)
>            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler_types.h:337:9: note: expanded from macro
> '__compiletime_assert'
>                    if
> (!(condition))                                       \
>                          ^~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:607:3: warning: result of
> comparison of constant 18446744073709551615 with expression of type
> 'typeof (_Generic((mask_), char: (unsigned char)0, unsigned char:
> (unsigned char)0, signed char: (unsigned char)0, unsigned short:
> (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned
> int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long:
> (unsigned long)0, unsigned long long: (unsigned long long)0, long
> long: (unsigned long long)0, default: (mask_)))' (aka 'unsigned
> long') is always false [-Wtautological-constant-out-of-range-compare]
>                    mtk_phy_update_field(phyd + U3P_U3_PHYD_IMPCAL1,
> P3D_RG_RX_IMPEL, val);
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-io.h:43:34: note: expanded from macro
> 'mtk_phy_update_field'
>            mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \
>                                            ^~~~~~~~~~~~~~~~~~~~~~
>    include/linux/bitfield.h:114:3: note: expanded from macro
> 'FIELD_PREP'
>                    __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP:
> ");    \
>                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~
>    include/linux/bitfield.h:71:53: note: expanded from macro
> '__BF_FIELD_CHECK'
>                    BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)
> >     \
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~
>    note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-
> limit=0 to see all)
>    include/linux/compiler_types.h:357:22: note: expanded from macro
> 'compiletime_assert'
>            _compiletime_assert(condition, msg, __compiletime_assert_,
> __COUNTER__)
>            ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>    include/linux/compiler_types.h:345:23: note: expanded from macro
> '_compiletime_assert'
>            __compiletime_assert(condition, msg, prefix, suffix)
>            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/compiler_types.h:337:9: note: expanded from macro
> '__compiletime_assert'
>                    if
> (!(condition))                                       \
>                          ^~~~~~~~~
>    drivers/phy/mediatek/phy-mtk-tphy.c:785:2: warning: result of
> comparison of constant 18446744073709551615 with expression of type
> 'typeof (_Generic((mask_), char: (unsigned char)0, unsigned char:
> (unsigned char)0, signed char: (unsigned char)0, unsigned short:
> (unsigned short)0, short: (unsigned short)0, unsigned int: (unsigned
> int)0, int: (unsigned int)0, unsigned long: (unsigned long)0, long:
> (unsigned long)0, unsigned long long: (unsigned long long)0, long
> long: (unsigned long long)0, default: (mask_)))' (aka 'unsigned
> long') is always false [-Wtautological-constant-out-of-range-compare]
>            mtk_phy_update_field(com + U3P_USBPHYACR5,
> PA5_RG_U2_HSTX_SRCTRL,
>            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~
> 
> 
> vim +/val +556 drivers/phy/mediatek/phy-mtk-tphy.c
> 
>    518	
>    519	static int u3_phy_params_show(struct seq_file *sf, void
> *unused)
>    520	{
>    521		struct mtk_phy_instance *inst = sf->private;
>    522		const char *fname = file_dentry(sf->file)-
> >d_iname;
>    523		struct u3phy_banks *u3_banks = &inst->u3_banks;
>    524		u32 val, tmp, max;
>    525		int ret;
>    526	
>    527		ret = match_string(u3_phy_files,
> ARRAY_SIZE(u3_phy_files), fname);
>    528		if (ret < 0)
>    529			return ret;
>    530	
>    531		switch (ret) {
>    532		case U3P_EFUSE_EN:
>    533			tmp = readl(u3_banks->phyd +
> U3P_U3_PHYD_RSV);
>    534			val = !!(tmp &
> P3D_RG_EFUSE_AUTO_LOAD_DIS);
>    535			max = 1;
>    536			break;
>    537	
>    538		case U3P_EFUSE_INTR:
>    539			tmp = readl(u3_banks->phya +
> U3P_U3_PHYA_REG0);
>    540			val = FIELD_GET(P3A_RG_IEXT_INTR, tmp);
>    541			max = FIELD_MAX(P3A_RG_IEXT_INTR);
>    542			break;
>    543	
>    544		case U3P_EFUSE_TX_IMP:
>    545			tmp = readl(u3_banks->phyd +
> U3P_U3_PHYD_IMPCAL0);
>    546			val = FIELD_GET(P3D_RG_TX_IMPEL, tmp);
>    547			max = FIELD_MAX(P3D_RG_TX_IMPEL);
>    548			break;
>    549	
>    550		case U3P_EFUSE_RX_IMP:
>    551			tmp = readl(u3_banks->phyd +
> U3P_U3_PHYD_IMPCAL1);
>    552			val = FIELD_GET(P3D_RG_RX_IMPEL, tmp);
>    553			max = FIELD_MAX(P3D_RG_RX_IMPEL);
>    554			break;
>    555	
>  > 556		default:
>    557			seq_printf(sf, "invalid, %d\n", ret);
>    558			break;
>    559		}
>    560	
>    561		seq_printf(sf, "%s : %d [0, %d]\n", fname, val,
> max);
>    562	
>    563		return 0;
>    564	}
>    565	
> 
I'll send a new version patch to fix the warnings;

Thanks
diff mbox series

Patch

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..99677665a9c4 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -7,6 +7,7 @@ 
 
 #include <dt-bindings/phy/phy.h>
 #include <linux/clk.h>
+#include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/iopoll.h>
 #include <linux/mfd/syscon.h>
@@ -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,389 @@  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, tmp, max;
+	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 +1415,8 @@  static int mtk_phy_init(struct phy *phy)
 		return -EINVAL;
 	}
 
+	tphy_debugfs_init(tphy, instance);
+
 	return 0;
 }
 
@@ -1068,6 +1453,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 +1682,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,