Message ID | 20200628171543.51478-4-zhouyanjie@wanyeetech.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | Add functions to operate USB PHY related clock. | expand |
Hi "周琰杰, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on clk/clk-next] [also build test WARNING on linux/master linus/master v5.8-rc3 next-20200629] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Zhou-Yanjie/Add-functions-to-operate-USB-PHY-related-clock/20200629-011858 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: alpha-allyesconfig (attached as .config) compiler: alpha-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=alpha If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): In file included from arch/alpha/include/asm/bug.h:23, from include/linux/bug.h:5, from include/linux/thread_info.h:12, from include/asm-generic/current.h:5, from ./arch/alpha/include/generated/asm/current.h:1, from include/linux/mutex.h:14, from include/linux/kernfs.h:12, from include/linux/sysfs.h:16, from include/linux/kobject.h:20, from include/linux/of.h:17, from include/linux/clk-provider.h:9, from drivers/clk/ingenic/x1000-cgu.c:7: drivers/clk/ingenic/x1000-cgu.c: In function 'x1000_otg_phy_recalc_rate': include/asm-generic/bug.h:127:34: error: expected expression before ')' token 127 | int __ret_warn_on = !!(condition); \ | ^ >> drivers/clk/ingenic/x1000-cgu.c:83:2: note: in expansion of macro 'WARN' 83 | WARN(); | ^~~~ include/asm-generic/bug.h:88:51: error: expected expression before ')' token 88 | warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \ | ^ include/asm-generic/bug.h:129:3: note: in expansion of macro '__WARN_printf' 129 | __WARN_printf(TAINT_WARN, format); \ | ^~~~~~~~~~~~~ >> drivers/clk/ingenic/x1000-cgu.c:83:2: note: in expansion of macro 'WARN' 83 | WARN(); | ^~~~ vim +/WARN +83 drivers/clk/ingenic/x1000-cgu.c 62 63 static unsigned long x1000_otg_phy_recalc_rate(struct clk_hw *hw, 64 unsigned long parent_rate) 65 { 66 u32 usbpcr1; 67 unsigned refclk_div; 68 69 usbpcr1 = readl(cgu->base + CGU_REG_USBPCR1); 70 refclk_div = usbpcr1 & USBPCR1_REFCLKDIV_MASK; 71 72 switch (refclk_div) { 73 case USBPCR1_REFCLKDIV_12: 74 return 12000000; 75 76 case USBPCR1_REFCLKDIV_24: 77 return 48000000; 78 79 case USBPCR1_REFCLKDIV_48: 80 return 48000000; 81 } 82 > 83 WARN(); 84 return parent_rate; 85 } 86 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi "周琰杰, Thank you for the patch! Yet something to improve: [auto build test ERROR on clk/clk-next] [also build test ERROR on linux/master linus/master v5.8-rc3 next-20200629] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Zhou-Yanjie/Add-functions-to-operate-USB-PHY-related-clock/20200629-011858 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: mips-randconfig-r012-20200629 (attached as .config) compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project a28d38a6bca1726d56c9b373f4c7dc5264fc7716) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install mips cross compiling tool for clang build # apt-get install binutils-mips-linux-gnu # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers/clk/ingenic/x1000-cgu.c:83:2: error: expected expression WARN(); ^ include/asm-generic/bug.h:127:34: note: expanded from macro 'WARN' int __ret_warn_on = !!(condition); \ ^ >> drivers/clk/ingenic/x1000-cgu.c:83:2: error: expected expression include/asm-generic/bug.h:129:3: note: expanded from macro 'WARN' __WARN_printf(TAINT_WARN, format); \ ^ include/asm-generic/bug.h:88:51: note: expanded from macro '__WARN_printf' warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \ ^ 2 errors generated. vim +83 drivers/clk/ingenic/x1000-cgu.c 62 63 static unsigned long x1000_otg_phy_recalc_rate(struct clk_hw *hw, 64 unsigned long parent_rate) 65 { 66 u32 usbpcr1; 67 unsigned refclk_div; 68 69 usbpcr1 = readl(cgu->base + CGU_REG_USBPCR1); 70 refclk_div = usbpcr1 & USBPCR1_REFCLKDIV_MASK; 71 72 switch (refclk_div) { 73 case USBPCR1_REFCLKDIV_12: 74 return 12000000; 75 76 case USBPCR1_REFCLKDIV_24: 77 return 48000000; 78 79 case USBPCR1_REFCLKDIV_48: 80 return 48000000; 81 } 82 > 83 WARN(); 84 return parent_rate; 85 } 86 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/clk/ingenic/x1000-cgu.c b/drivers/clk/ingenic/x1000-cgu.c index 453f3323cb99..aa043f3cf11f 100644 --- a/drivers/clk/ingenic/x1000-cgu.c +++ b/drivers/clk/ingenic/x1000-cgu.c @@ -48,8 +48,88 @@ #define USBPCR_SIDDQ BIT(21) #define USBPCR_OTG_DISABLE BIT(20) +/* bits within the USBPCR1 register */ +#define USBPCR1_REFCLKSEL_SHIFT 26 +#define USBPCR1_REFCLKSEL_MASK (0x3 << USBPCR1_REFCLKSEL_SHIFT) +#define USBPCR1_REFCLKSEL_CORE (0x2 << USBPCR1_REFCLKSEL_SHIFT) +#define USBPCR1_REFCLKDIV_SHIFT 24 +#define USBPCR1_REFCLKDIV_MASK (0x3 << USBPCR1_REFCLKDIV_SHIFT) +#define USBPCR1_REFCLKDIV_48 (0x2 << USBPCR1_REFCLKDIV_SHIFT) +#define USBPCR1_REFCLKDIV_24 (0x1 << USBPCR1_REFCLKDIV_SHIFT) +#define USBPCR1_REFCLKDIV_12 (0x0 << USBPCR1_REFCLKDIV_SHIFT) + static struct ingenic_cgu *cgu; +static unsigned long x1000_otg_phy_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + u32 usbpcr1; + unsigned refclk_div; + + usbpcr1 = readl(cgu->base + CGU_REG_USBPCR1); + refclk_div = usbpcr1 & USBPCR1_REFCLKDIV_MASK; + + switch (refclk_div) { + case USBPCR1_REFCLKDIV_12: + return 12000000; + + case USBPCR1_REFCLKDIV_24: + return 48000000; + + case USBPCR1_REFCLKDIV_48: + return 48000000; + } + + WARN(); + return parent_rate; +} + +static long x1000_otg_phy_round_rate(struct clk_hw *hw, unsigned long req_rate, + unsigned long *parent_rate) +{ + if (req_rate < 18000000) + return 12000000; + + if (req_rate < 36000000) + return 24000000; + + return 48000000; +} + +static int x1000_otg_phy_set_rate(struct clk_hw *hw, unsigned long req_rate, + unsigned long parent_rate) +{ + unsigned long flags; + u32 usbpcr1, div_bits; + + switch (req_rate) { + case 18000000: + div_bits = USBPCR1_REFCLKDIV_12; + break; + + case 24000000: + div_bits = USBPCR1_REFCLKDIV_24; + break; + + case 48000000: + div_bits = USBPCR1_REFCLKDIV_48; + break; + + default: + return -EINVAL; + } + + spin_lock_irqsave(&cgu->lock, flags); + + usbpcr1 = readl(cgu->base + CGU_REG_USBPCR1); + usbpcr1 &= ~USBPCR1_REFCLKDIV_MASK; + usbpcr1 |= div_bits; + writel(usbpcr1, cgu->base + CGU_REG_USBPCR1); + + spin_unlock_irqrestore(&cgu->lock, flags); + return 0; +} + static int x1000_usb_phy_enable(struct clk_hw *hw) { void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR; @@ -80,6 +160,10 @@ static int x1000_usb_phy_is_enabled(struct clk_hw *hw) } static const struct clk_ops x1000_otg_phy_ops = { + .recalc_rate = x1000_otg_phy_recalc_rate, + .round_rate = x1000_otg_phy_round_rate, + .set_rate = x1000_otg_phy_set_rate, + .enable = x1000_usb_phy_enable, .disable = x1000_usb_phy_disable, .is_enabled = x1000_usb_phy_is_enabled, @@ -144,7 +228,6 @@ static const struct ingenic_cgu_clk_info x1000_cgu_clocks[] = { }, }, - /* Custom (SoC-specific) OTG PHY */ [X1000_CLK_OTGPHY] = {