Re: [PATCH v3 3/7] usb: mtu3: support ip-sleep wakeup for MT8183
On Wed, 2019-09-11 at 11:44 -0700, Guenter Roeck wrote: > On Fri, Aug 30, 2019 at 03:40:50PM +0800, Chunfeng Yun wrote: > > Support USB wakeup by ip-sleep mode for MT8183, it's similar to > > MT8173 > > > > Signed-off-by: Chunfeng Yun > > --- > > v3: changes micros define > > > > v2: no changes > > --- > > drivers/usb/mtu3/mtu3_host.c | 14 +- > > 1 file changed, 13 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c > > index c871b94f3e6f..4f8208885ebd 100644 > > --- a/drivers/usb/mtu3/mtu3_host.c > > +++ b/drivers/usb/mtu3/mtu3_host.c > > @@ -18,6 +18,12 @@ > > #include "mtu3.h" > > #include "mtu3_dr.h" > > > > +/* mt8183 etc */ > > +#define PERI_WK_CTRL0 0x20 > > +#define WC0_IS_C(x)(((x) & 0xf) << 28) /* cycle debounce */ > > +#define WC0_IS_P BIT(12) /* polarity */ > > +#define WC0_IS_EN BIT(6) > > + > > For 64-bit builds, this results in: > > drivers/usb/mtu3/mtu3_host.c: In function ‘ssusb_wakeup_ip_sleep_set’: > ./include/linux/bits.h:6:19: warning: > conversion from ‘long unsigned int’ to ‘u32’ {aka ‘unsigned int’} > changes value from ‘18446744073441120320’ to ‘4026536000’ [-Woverflow] > > since WC0_IS_C() is sign extended to 64 bit and then truncated. Got it, thanks a lot > > Observed with gcc 7.4.0 and 8.3.0. > > Guenter > > > /* mt8173 etc */ > > #define PERI_WK_CTRL1 0x4 > > #define WC1_IS_C(x)(((x) & 0xf) << 26) /* cycle debounce */ > > @@ -30,7 +36,8 @@ > > #define SSC_SPM_INT_EN BIT(1) > > > > enum ssusb_uwk_vers { > > - SSUSB_UWK_V1 = 1, > > + SSUSB_UWK_V0 = 0, > > + SSUSB_UWK_V1, > > SSUSB_UWK_V2, > > }; > > > > @@ -43,6 +50,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk > > *ssusb, bool enable) > > u32 reg, msk, val; > > > > switch (ssusb->uwk_vers) { > > + case SSUSB_UWK_V0: > > + reg = ssusb->uwk_reg_base + PERI_WK_CTRL0; > > + msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P; > > + val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0; > > + break; > > case SSUSB_UWK_V1: > > reg = ssusb->uwk_reg_base + PERI_WK_CTRL1; > > msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
Re: [PATCH v3 3/7] usb: mtu3: support ip-sleep wakeup for MT8183
On Fri, Aug 30, 2019 at 03:40:50PM +0800, Chunfeng Yun wrote: > Support USB wakeup by ip-sleep mode for MT8183, it's similar to > MT8173 > > Signed-off-by: Chunfeng Yun > --- > v3: changes micros define > > v2: no changes > --- > drivers/usb/mtu3/mtu3_host.c | 14 +- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c > index c871b94f3e6f..4f8208885ebd 100644 > --- a/drivers/usb/mtu3/mtu3_host.c > +++ b/drivers/usb/mtu3/mtu3_host.c > @@ -18,6 +18,12 @@ > #include "mtu3.h" > #include "mtu3_dr.h" > > +/* mt8183 etc */ > +#define PERI_WK_CTRL00x20 > +#define WC0_IS_C(x) (((x) & 0xf) << 28) /* cycle debounce */ > +#define WC0_IS_P BIT(12) /* polarity */ > +#define WC0_IS_ENBIT(6) > + For 64-bit builds, this results in: drivers/usb/mtu3/mtu3_host.c: In function ‘ssusb_wakeup_ip_sleep_set’: ./include/linux/bits.h:6:19: warning: conversion from ‘long unsigned int’ to ‘u32’ {aka ‘unsigned int’} changes value from ‘18446744073441120320’ to ‘4026536000’ [-Woverflow] since WC0_IS_C() is sign extended to 64 bit and then truncated. Observed with gcc 7.4.0 and 8.3.0. Guenter > /* mt8173 etc */ > #define PERI_WK_CTRL10x4 > #define WC1_IS_C(x) (((x) & 0xf) << 26) /* cycle debounce */ > @@ -30,7 +36,8 @@ > #define SSC_SPM_INT_EN BIT(1) > > enum ssusb_uwk_vers { > - SSUSB_UWK_V1 = 1, > + SSUSB_UWK_V0 = 0, > + SSUSB_UWK_V1, > SSUSB_UWK_V2, > }; > > @@ -43,6 +50,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk > *ssusb, bool enable) > u32 reg, msk, val; > > switch (ssusb->uwk_vers) { > + case SSUSB_UWK_V0: > + reg = ssusb->uwk_reg_base + PERI_WK_CTRL0; > + msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P; > + val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0; > + break; > case SSUSB_UWK_V1: > reg = ssusb->uwk_reg_base + PERI_WK_CTRL1; > msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
Re: [PATCH v3 3/7] usb: mtu3: support ip-sleep wakeup for MT8183
Hi Chunfeng, I love your patch! Perhaps something to improve: [auto build test WARNING on linus/master] [cannot apply to v5.3-rc6 next-20190830] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Chunfeng-Yun/add-support-USB-for-MT8183/20190901-163637 config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 7.4.0 reproduce: 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 GCC_VERSION=7.4.0 make.cross ARCH=ia64 If you fix the issue, kindly add following tag Reported-by: kbuild test robot All warnings (new ones prefixed by >>): In file included from include/linux/bitops.h:5:0, from include/linux/kernel.h:12, from include/linux/clk.h:13, from drivers//usb/mtu3/mtu3_host.c:10: drivers//usb/mtu3/mtu3_host.c: In function 'ssusb_wakeup_ip_sleep_set': >> include/linux/bits.h:8:19: warning: large integer implicitly truncated to >> unsigned type [-Woverflow] #define BIT(nr) (UL(1) << (nr)) ^ >> drivers//usb/mtu3/mtu3_host.c:25:19: note: in expansion of macro 'BIT' #define WC0_IS_EN BIT(6) ^~~ >> drivers//usb/mtu3/mtu3_host.c:55:9: note: in expansion of macro 'WC0_IS_EN' msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P; ^ -- In file included from include/linux/bitops.h:5:0, from include/linux/kernel.h:12, from include/linux/clk.h:13, from drivers/usb/mtu3/mtu3_host.c:10: drivers/usb/mtu3/mtu3_host.c: In function 'ssusb_wakeup_ip_sleep_set': >> include/linux/bits.h:8:19: warning: large integer implicitly truncated to >> unsigned type [-Woverflow] #define BIT(nr) (UL(1) << (nr)) ^ drivers/usb/mtu3/mtu3_host.c:25:19: note: in expansion of macro 'BIT' #define WC0_IS_EN BIT(6) ^~~ drivers/usb/mtu3/mtu3_host.c:55:9: note: in expansion of macro 'WC0_IS_EN' msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P; ^ vim +/WC0_IS_EN +55 drivers//usb/mtu3/mtu3_host.c > 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 18 #include "mtu3.h" 19 #include "mtu3_dr.h" 20 21 /* mt8183 etc */ 22 #define PERI_WK_CTRL0 0x20 23 #define WC0_IS_C(x) (((x) & 0xf) << 28) /* cycle debounce */ 24 #define WC0_IS_PBIT(12) /* polarity */ > 25 #define WC0_IS_EN BIT(6) 26 27 /* mt8173 etc */ 28 #define PERI_WK_CTRL1 0x4 29 #define WC1_IS_C(x) (((x) & 0xf) << 26) /* cycle debounce */ 30 #define WC1_IS_EN BIT(25) 31 #define WC1_IS_PBIT(6) /* polarity for ip sleep */ 32 33 /* mt2712 etc */ 34 #define PERI_SSUSB_SPM_CTRL 0x0 35 #define SSC_IP_SLEEP_EN BIT(4) 36 #define SSC_SPM_INT_EN BIT(1) 37 38 enum ssusb_uwk_vers { 39 SSUSB_UWK_V0 = 0, 40 SSUSB_UWK_V1, 41 SSUSB_UWK_V2, 42 }; 43 44 /* 45 * ip-sleep wakeup mode: 46 * all clocks can be turn off, but power domain should be kept on 47 */ 48 static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable) 49 { 50 u32 reg, msk, val; 51 52 switch (ssusb->uwk_vers) { 53 case SSUSB_UWK_V0: 54 reg = ssusb->uwk_reg_base + PERI_WK_CTRL0; > 55 msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P; 56 val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0; 57 break; 58 case SSUSB_UWK_V1: 59 reg = ssusb->uwk_reg_base + PERI_WK_CTRL1; 60 msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P; 61 val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0; 62 break; 63 case SSUSB_UWK_V2: 64 reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL; 65 msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN; 66 val = enable ? msk : 0; 67 break; 68 default: 69 return; 70 } 71 regmap_update_bits(ssusb->uwk, reg, msk, val); 72 } 73 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[PATCH v3 3/7] usb: mtu3: support ip-sleep wakeup for MT8183
Support USB wakeup by ip-sleep mode for MT8183, it's similar to MT8173 Signed-off-by: Chunfeng Yun --- v3: changes micros define v2: no changes --- drivers/usb/mtu3/mtu3_host.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c index c871b94f3e6f..4f8208885ebd 100644 --- a/drivers/usb/mtu3/mtu3_host.c +++ b/drivers/usb/mtu3/mtu3_host.c @@ -18,6 +18,12 @@ #include "mtu3.h" #include "mtu3_dr.h" +/* mt8183 etc */ +#define PERI_WK_CTRL0 0x20 +#define WC0_IS_C(x)(((x) & 0xf) << 28) /* cycle debounce */ +#define WC0_IS_P BIT(12) /* polarity */ +#define WC0_IS_EN BIT(6) + /* mt8173 etc */ #define PERI_WK_CTRL1 0x4 #define WC1_IS_C(x)(((x) & 0xf) << 26) /* cycle debounce */ @@ -30,7 +36,8 @@ #define SSC_SPM_INT_EN BIT(1) enum ssusb_uwk_vers { - SSUSB_UWK_V1 = 1, + SSUSB_UWK_V0 = 0, + SSUSB_UWK_V1, SSUSB_UWK_V2, }; @@ -43,6 +50,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable) u32 reg, msk, val; switch (ssusb->uwk_vers) { + case SSUSB_UWK_V0: + reg = ssusb->uwk_reg_base + PERI_WK_CTRL0; + msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P; + val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0; + break; case SSUSB_UWK_V1: reg = ssusb->uwk_reg_base + PERI_WK_CTRL1; msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P; -- 2.23.0