Subject: [PATCH 1/2] dt-bindings: usb: mtu3: Add MT8195 MTU3 ip-sleep support

Of the four USB controllers present on the MediaTek MT8195 SoC, three
of them (0, 2 and 3) are behind MTU3: add wakeup controls for them.

Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
index a59d91243ac8..d4e187c78a0b 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
@@ -185,7 +185,10 @@ properties:
2 - used by mt2712 etc, revision 2 with following IPM rule;
101 - used by mt8183, specific 1.01;
102 - used by mt8192, specific 1.02;
- enum: [1, 2, 101, 102]
+ 103 - used by mt8195, IP0, specific 1.03;
+ 105 - used by mt8195, IP2, specific 1.05;
+ 106 - used by mt8195, IP3, specific 1.06;
+ enum: [1, 2, 101, 102, 103, 105, 106]

mediatek,u3p-dis-msk:
$ref: /schemas/types.yaml#/definitions/uint32
--
2.43.0



Subject: [PATCH 2/2] usb: mtu3: Add MT8195 MTU3 ip-sleep wakeup support

Add support for the ip-sleep wakeup functionality on the three MTU3
controllers found on the MT8195 SoC.

Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/usb/mtu3/mtu3_host.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index 9f2be22af844..85f49e00e8db 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -34,6 +34,19 @@
#define WC0_SSUSB0_CDEN BIT(6)
#define WC0_IS_SPM_EN BIT(1)

+/* mt8195 */
+#define PERI_WK_CTRL0_8195 0x04
+#define WC0_IS_P_95 BIT(30) /* polarity */
+#define WC0_IS_C_95(x) ((u32)(((x) & 0x7) << 27))
+#define WC0_IS_EN_P3_95 BIT(26)
+#define WC0_IS_EN_P2_95 BIT(25)
+#define WC0_IS_EN_P1_95 BIT(24)
+
+#define PERI_WK_CTRL1_8195 0x20
+#define WC1_IS_C_95(x) ((u32)(((x) & 0xf) << 28))
+#define WC1_IS_P_95 BIT(12)
+#define WC1_IS_EN_P0_95 BIT(6)
+
/* mt2712 etc */
#define PERI_SSUSB_SPM_CTRL 0x0
#define SSC_IP_SLEEP_EN BIT(4)
@@ -44,6 +57,9 @@ enum ssusb_uwk_vers {
SSUSB_UWK_V2,
SSUSB_UWK_V1_1 = 101, /* specific revision 1.01 */
SSUSB_UWK_V1_2, /* specific revision 1.02 */
+ SSUSB_UWK_V1_3, /* mt8195 IP0 */
+ SSUSB_UWK_V1_5 = 105, /* mt8195 IP2 */
+ SSUSB_UWK_V1_6, /* mt8195 IP3 */
};

/*
@@ -70,6 +86,21 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
msk = WC0_SSUSB0_CDEN | WC0_IS_SPM_EN;
val = enable ? msk : 0;
break;
+ case SSUSB_UWK_V1_3:
+ reg = ssusb->uwk_reg_base + PERI_WK_CTRL1_8195;
+ msk = WC1_IS_EN_P0_95 | WC1_IS_C_95(0xf) | WC1_IS_P_95;
+ val = enable ? (WC1_IS_EN_P0_95 | WC1_IS_C_95(0x1)) : 0;
+ break;
+ case SSUSB_UWK_V1_5:
+ reg = ssusb->uwk_reg_base + PERI_WK_CTRL0_8195;
+ msk = WC0_IS_EN_P2_95 | WC0_IS_C_95(0x7) | WC0_IS_P_95;
+ val = enable ? (WC0_IS_EN_P2_95 | WC0_IS_C_95(0x1)) : 0;
+ break;
+ case SSUSB_UWK_V1_6:
+ reg = ssusb->uwk_reg_base + PERI_WK_CTRL0_8195;
+ msk = WC0_IS_EN_P3_95 | WC0_IS_C_95(0x7) | WC0_IS_P_95;
+ val = enable ? (WC0_IS_EN_P3_95 | WC0_IS_C_95(0x1)) : 0;
+ break;
case SSUSB_UWK_V2:
reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
--
2.43.0


2024-01-12 17:04:33

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: usb: mtu3: Add MT8195 MTU3 ip-sleep support

On Fri, Jan 12, 2024 at 02:32:21PM +0100, AngeloGioacchino Del Regno wrote:
> Of the four USB controllers present on the MediaTek MT8195 SoC, three
> of them (0, 2 and 3) are behind MTU3: add wakeup controls for them.
>
> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>

Acked-by: Conor Dooley <[email protected]>

Cheers,
Conor.

> ---
> Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
> index a59d91243ac8..d4e187c78a0b 100644
> --- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
> +++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
> @@ -185,7 +185,10 @@ properties:
> 2 - used by mt2712 etc, revision 2 with following IPM rule;
> 101 - used by mt8183, specific 1.01;
> 102 - used by mt8192, specific 1.02;
> - enum: [1, 2, 101, 102]
> + 103 - used by mt8195, IP0, specific 1.03;
> + 105 - used by mt8195, IP2, specific 1.05;
> + 106 - used by mt8195, IP3, specific 1.06;
> + enum: [1, 2, 101, 102, 103, 105, 106]
>
> mediatek,u3p-dis-msk:
> $ref: /schemas/types.yaml#/definitions/uint32
> --
> 2.43.0
>


Attachments:
(No filename) (1.38 kB)
signature.asc (235.00 B)
Download all attachments

2024-01-22 07:53:29

by Matthias Brugger

[permalink] [raw]
Subject: Re: [PATCH 1/2] dt-bindings: usb: mtu3: Add MT8195 MTU3 ip-sleep support



On 12/01/2024 14:32, AngeloGioacchino Del Regno wrote:
> Of the four USB controllers present on the MediaTek MT8195 SoC, three
> of them (0, 2 and 3) are behind MTU3: add wakeup controls for them.
>
> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>

Reviewed-by: Matthias Brugger <[email protected]>

> ---
> Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
> index a59d91243ac8..d4e187c78a0b 100644
> --- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
> +++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
> @@ -185,7 +185,10 @@ properties:
> 2 - used by mt2712 etc, revision 2 with following IPM rule;
> 101 - used by mt8183, specific 1.01;
> 102 - used by mt8192, specific 1.02;
> - enum: [1, 2, 101, 102]
> + 103 - used by mt8195, IP0, specific 1.03;
> + 105 - used by mt8195, IP2, specific 1.05;
> + 106 - used by mt8195, IP3, specific 1.06;
> + enum: [1, 2, 101, 102, 103, 105, 106]
>
> mediatek,u3p-dis-msk:
> $ref: /schemas/types.yaml#/definitions/uint32

2024-01-22 08:00:54

by Matthias Brugger

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: mtu3: Add MT8195 MTU3 ip-sleep wakeup support



On 12/01/2024 14:32, AngeloGioacchino Del Regno wrote:
> Add support for the ip-sleep wakeup functionality on the three MTU3
> controllers found on the MT8195 SoC.
>
> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
> ---
> drivers/usb/mtu3/mtu3_host.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
> index 9f2be22af844..85f49e00e8db 100644
> --- a/drivers/usb/mtu3/mtu3_host.c
> +++ b/drivers/usb/mtu3/mtu3_host.c
> @@ -34,6 +34,19 @@
> #define WC0_SSUSB0_CDEN BIT(6)
> #define WC0_IS_SPM_EN BIT(1)
>
> +/* mt8195 */
> +#define PERI_WK_CTRL0_8195 0x04
> +#define WC0_IS_P_95 BIT(30) /* polarity */
> +#define WC0_IS_C_95(x) ((u32)(((x) & 0x7) << 27))
> +#define WC0_IS_EN_P3_95 BIT(26)
> +#define WC0_IS_EN_P2_95 BIT(25)
> +#define WC0_IS_EN_P1_95 BIT(24)

Not used, shouldn't we drop that?

Regards,
Matthias

> +
> +#define PERI_WK_CTRL1_8195 0x20
> +#define WC1_IS_C_95(x) ((u32)(((x) & 0xf) << 28))
> +#define WC1_IS_P_95 BIT(12)
> +#define WC1_IS_EN_P0_95 BIT(6)
> +
> /* mt2712 etc */
> #define PERI_SSUSB_SPM_CTRL 0x0
> #define SSC_IP_SLEEP_EN BIT(4)
> @@ -44,6 +57,9 @@ enum ssusb_uwk_vers {
> SSUSB_UWK_V2,
> SSUSB_UWK_V1_1 = 101, /* specific revision 1.01 */
> SSUSB_UWK_V1_2, /* specific revision 1.02 */
> + SSUSB_UWK_V1_3, /* mt8195 IP0 */
> + SSUSB_UWK_V1_5 = 105, /* mt8195 IP2 */
> + SSUSB_UWK_V1_6, /* mt8195 IP3 */
> };
>
> /*
> @@ -70,6 +86,21 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
> msk = WC0_SSUSB0_CDEN | WC0_IS_SPM_EN;
> val = enable ? msk : 0;
> break;
> + case SSUSB_UWK_V1_3:
> + reg = ssusb->uwk_reg_base + PERI_WK_CTRL1_8195;
> + msk = WC1_IS_EN_P0_95 | WC1_IS_C_95(0xf) | WC1_IS_P_95;
> + val = enable ? (WC1_IS_EN_P0_95 | WC1_IS_C_95(0x1)) : 0;
> + break;
> + case SSUSB_UWK_V1_5:
> + reg = ssusb->uwk_reg_base + PERI_WK_CTRL0_8195;
> + msk = WC0_IS_EN_P2_95 | WC0_IS_C_95(0x7) | WC0_IS_P_95;
> + val = enable ? (WC0_IS_EN_P2_95 | WC0_IS_C_95(0x1)) : 0;
> + break;
> + case SSUSB_UWK_V1_6:
> + reg = ssusb->uwk_reg_base + PERI_WK_CTRL0_8195;
> + msk = WC0_IS_EN_P3_95 | WC0_IS_C_95(0x7) | WC0_IS_P_95;
> + val = enable ? (WC0_IS_EN_P3_95 | WC0_IS_C_95(0x1)) : 0;
> + break;
> case SSUSB_UWK_V2:
> reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
> msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;

Subject: Re: [PATCH 2/2] usb: mtu3: Add MT8195 MTU3 ip-sleep wakeup support

Il 22/01/24 08:58, Matthias Brugger ha scritto:
>
>
> On 12/01/2024 14:32, AngeloGioacchino Del Regno wrote:
>> Add support for the ip-sleep wakeup functionality on the three MTU3
>> controllers found on the MT8195 SoC.
>>
>> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
>> ---
>>   drivers/usb/mtu3/mtu3_host.c | 31 +++++++++++++++++++++++++++++++
>>   1 file changed, 31 insertions(+)
>>
>> diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
>> index 9f2be22af844..85f49e00e8db 100644
>> --- a/drivers/usb/mtu3/mtu3_host.c
>> +++ b/drivers/usb/mtu3/mtu3_host.c
>> @@ -34,6 +34,19 @@
>>   #define WC0_SSUSB0_CDEN        BIT(6)
>>   #define WC0_IS_SPM_EN        BIT(1)
>> +/* mt8195 */
>> +#define PERI_WK_CTRL0_8195    0x04
>> +#define WC0_IS_P_95        BIT(30)    /* polarity */
>> +#define WC0_IS_C_95(x)        ((u32)(((x) & 0x7) << 27))
>> +#define WC0_IS_EN_P3_95        BIT(26)
>> +#define WC0_IS_EN_P2_95        BIT(25)
>> +#define WC0_IS_EN_P1_95        BIT(24)
>
> Not used, shouldn't we drop that?
>

Hey Matthias!

Thanks for catching that - yeah that bit exists, but cannot be used in MTU3, so
it has to be dropped.

Sending a v2 in a jiffy....... or two. :-)

Cheers,
Angelo

> Regards,
> Matthias
>
>> +
>> +#define PERI_WK_CTRL1_8195    0x20
>> +#define WC1_IS_C_95(x)        ((u32)(((x) & 0xf) << 28))
>> +#define WC1_IS_P_95        BIT(12)
>> +#define WC1_IS_EN_P0_95        BIT(6)
>> +
>>   /* mt2712 etc */
>>   #define PERI_SSUSB_SPM_CTRL    0x0
>>   #define SSC_IP_SLEEP_EN    BIT(4)
>> @@ -44,6 +57,9 @@ enum ssusb_uwk_vers {
>>       SSUSB_UWK_V2,
>>       SSUSB_UWK_V1_1 = 101,    /* specific revision 1.01 */
>>       SSUSB_UWK_V1_2,        /* specific revision 1.02 */
>> +    SSUSB_UWK_V1_3,        /* mt8195 IP0 */
>> +    SSUSB_UWK_V1_5 = 105,    /* mt8195 IP2 */
>> +    SSUSB_UWK_V1_6,        /* mt8195 IP3 */
>>   };
>>   /*
>> @@ -70,6 +86,21 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb,
>> bool enable)
>>           msk = WC0_SSUSB0_CDEN | WC0_IS_SPM_EN;
>>           val = enable ? msk : 0;
>>           break;
>> +    case SSUSB_UWK_V1_3:
>> +        reg = ssusb->uwk_reg_base + PERI_WK_CTRL1_8195;
>> +        msk = WC1_IS_EN_P0_95 | WC1_IS_C_95(0xf) | WC1_IS_P_95;
>> +        val = enable ? (WC1_IS_EN_P0_95 | WC1_IS_C_95(0x1)) : 0;
>> +        break;
>> +    case SSUSB_UWK_V1_5:
>> +        reg = ssusb->uwk_reg_base + PERI_WK_CTRL0_8195;
>> +        msk = WC0_IS_EN_P2_95 | WC0_IS_C_95(0x7) | WC0_IS_P_95;
>> +        val = enable ? (WC0_IS_EN_P2_95 | WC0_IS_C_95(0x1)) : 0;
>> +        break;
>> +    case SSUSB_UWK_V1_6:
>> +        reg = ssusb->uwk_reg_base + PERI_WK_CTRL0_8195;
>> +        msk = WC0_IS_EN_P3_95 | WC0_IS_C_95(0x7) | WC0_IS_P_95;
>> +        val = enable ? (WC0_IS_EN_P3_95 | WC0_IS_C_95(0x1)) : 0;
>> +        break;
>>       case SSUSB_UWK_V2:
>>           reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
>>           msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;