MT8186 SMI SUPPORT
Yong Wu
maintainerv3 cover MT8186 SMI SUPPORT
This patchset adds mt8186 smi support.
mainly adds a sleep control function.
Change note:
v3: a) Add a new binding patch for renaming "clock" to "clocks".
b) Reword the title for the binding patches, more detailed.
c) Add the sleep control error path: if err, return directly. also change the log from dev_warn to dev_err.
v2: https://lore.kernel.org/linux-devicetree/[email protected]/
a) Add two patches for the "make dtbs_check" warning.
b) Seperate the "sleep control" into two functions.
And add a "TODO" comment while sleep control fails.
v1: https://lore.kernel.org/linux-mediatek/[email protected]/
Base on v5.16-rc1.
Yong Wu (7):
dt-bindings: memory: mtk-smi: Rename clock to clocks
dt-bindings: memory: mtk-smi: No need mediatek,larb-id for mt8167
dt-bindings: memory: mtk-smi: Correct minItems to 2 for the gals
clocks
dt-bindings: memory: mediatek: Add mt8186 support
memory: mtk-smi: Fix the return value for clk_bulk_prepare_enable
memory: mtk-smi: Add sleep ctrl function
memory: mtk-smi: mt8186: Add smi support
.../mediatek,smi-common.yaml | 32 ++++++------ .../memory-controllers/mediatek,smi-larb.yaml | 19 +++---- drivers/memory/mtk-smi.c | 51 ++++++++++++++++++- 3 files changed, 75 insertions(+), 27 deletions(-)
Signature · 1 line
2.18.0
Yong Wu
maintainerPATCH v3 1/7 dt-bindings: memory: mtk-smi: Rename clock to clocks
The property "clock" should be rename to "clocks", and delete the "items", the minItems/maxItems should not be put under "items".
--- .../mediatek,smi-common.yaml | 28 ++++++++----------- .../memory-controllers/mediatek,smi-larb.yaml | 14 ++++------ 2 files changed, 18 insertions(+), 24 deletions(-)
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-common.yaml +12 -16
@@ -88,10 +88,9 @@ allOf: - mediatek,mt2701-smi-common then: properties: - clock: - items: - minItems: 3 - maxItems: 3 + clocks: + minItems: 3 + maxItems: 3 clock-names: items: - const: apb
@@ -108,10 +107,9 @@ allOf: required: - mediatek,smi properties: - clock: - items: - minItems: 3 - maxItems: 3 + clocks: + minItems: 3 + maxItems: 3 clock-names: items: - const: apb
@@ -133,10 +131,9 @@ allOf: then: properties: - clock: - items: - minItems: 4 - maxItems: 4 + clocks: + minItems: 4 + maxItems: 4 clock-names: items: - const: apb
@@ -146,10 +143,9 @@ allOf: else: # for gen2 HW that don't have gals properties: - clock: - items: - minItems: 2 - maxItems: 2 + clocks: + minItems: 2 + maxItems: 2 clock-names: items: - const: apb
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +6 -8
@@ -79,10 +79,9 @@ allOf: then: properties: - clock: - items: - minItems: 3 - maxItems: 3 + clocks: + minItems: 3 + maxItems: 3 clock-names: items: - const: apb
@@ -91,10 +90,9 @@ allOf: else: properties: - clock: - items: - minItems: 2 - maxItems: 2 + clocks: + minItems: 2 + maxItems: 2 clock-names: items: - const: apb
Signature · 1 line
2.18.0
Re: [PATCH v3 1/7] dt-bindings: memory: mtk-smi: Rename clock to clocks
Il 13/01/22 12:10, Yong Wu ha scritto:
Quoted 5 lines
The property "clock" should be rename to "clocks", and delete the "items", the minItems/maxItems should not be put under "items".
Fixes 27bb0e42855a ("dt-bindings: memory: mediatek: Convert SMI to DT schema")Signed-off-by Yong Wu <[email protected]>
Yong Wu
maintainerPATCH v3 2/7 dt-bindings: memory: mtk-smi: No need mediatek,larb-id for mt8167
In reply to Yong WuMute the warning from "make dtbs_check":
larb@14016000: 'mediatek,larb-id' is a required property
arch/arm64/boot/dts/mediatek/mt8167-pumpkin.dt.yaml larb@15001000: 'mediatek,larb-id' is a required property arch/arm64/boot/dts/mediatek/mt8167-pumpkin.dt.yaml larb@16010000: 'mediatek,larb-id' is a required property arch/arm64/boot/dts/mediatek/mt8167-pumpkin.dt.yaml
As the description of mediatek,larb-id, the property is only required when the larbid is not consecutive from its IOMMU point of view.
Also, from the description of mediatek,larbs in Documentation/devicetree/bindings/iommu/mediatek,iommu.yaml, all the larbs must sort by the larb index.
In mt8167, there is only one IOMMU HW and three larbs. The drivers already know its larb index from the mediatek,larbs property of IOMMU, thus no need this property.
--- .../bindings/memory-controllers/mediatek,smi-larb.yaml | 1 - 1 file changed, 1 deletion(-)
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +0 -1
@@ -106,7 +106,6 @@ allOf: - mediatek,mt2701-smi-larb - mediatek,mt2712-smi-larb - mediatek,mt6779-smi-larb - - mediatek,mt8167-smi-larb - mediatek,mt8192-smi-larb - mediatek,mt8195-smi-larb
Signature · 1 line
2.18.0
Re: [PATCH v3 2/7] dt-bindings: memory: mtk-smi: No need mediatek,larb-id for mt8167
Il 13/01/22 12:10, Yong Wu ha scritto:
Quoted 16 lines
Mute the warning from "make
dtbs_check":larb@14016000: 'mediatek,larb-id' is a required property
arch/arm64/boot/dts/mediatek/mt8167-pumpkin.dt.yaml larb@15001000: 'mediatek,larb-id' is a required property arch/arm64/boot/dts/mediatek/mt8167-pumpkin.dt.yaml larb@16010000: 'mediatek,larb-id' is a required property arch/arm64/boot/dts/mediatek/mt8167-pumpkin.dt.yamlAs the description of mediatek,larb-id, the property is only required when the larbid is not consecutive from its IOMMU point of view.
Also, from the description of mediatek,larbs in
Documentation/devicetree/bindings/iommu/mediatek,iommu.yaml, all the larbs must sort by the larb index.
Quoted 6 lines
In mt8167, there is only one IOMMU HW and three larbs. The drivers already know its larb index from the mediatek,larbs property of IOMMU, thus no need this property.
Fixes 27bb0e42855a ("dt-bindings: memory: mediatek: Convert SMI to DT schema")Signed-off-by Yong Wu <[email protected]>
Yong Wu
maintainerPATCH v3 3/7 dt-bindings: memory: mtk-smi: Correct minItems to 2 for the gals clocks
In reply to Yong WuMute the warning from "make dtbs_check":
larb@14017000: clock-names: ['apb', 'smi'] is too short
arch/arm64/boot/dts/mediatek/mt8183-evb.dt.yaml arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dt.yaml ...
larb@16010000: clock-names: ['apb', 'smi'] is too short
arch/arm64/boot/dts/mediatek/mt8183-evb.dt.yaml arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dt.yaml
larb@17010000: clock-names: ['apb', 'smi'] is too short
arch/arm64/boot/dts/mediatek/mt8183-evb.dt.yaml arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dt.yaml
If a platform's larb supports gals, there will be some larbs have one more "gals" clock while the others still only need "apb"/"smi" clocks, then the minItems for clocks and clock-names are 2.
--- .../bindings/memory-controllers/mediatek,smi-larb.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +2 -1
@@ -80,9 +80,10 @@ allOf: then: properties: clocks: - minItems: 3 + minItems: 2 maxItems: 3 clock-names: + minItems: 2 items: - const: apb - const: smi
Signature · 1 line
2.18.0
Re: [PATCH v3 3/7] dt-bindings: memory: mtk-smi: Correct minItems to 2 for the gals clocks
Il 13/01/22 12:10, Yong Wu ha scritto:
Quoted 15 lines
Mute the warning from "make
dtbs_check":larb@14017000: clock-names: ['apb', 'smi'] is too short
arch/arm64/boot/dts/mediatek/mt8183-evb.dt.yaml arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dt.yaml ...larb@16010000: clock-names: ['apb', 'smi'] is too short
arch/arm64/boot/dts/mediatek/mt8183-evb.dt.yaml arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dt.yamllarb@17010000: clock-names: ['apb', 'smi'] is too short
arch/arm64/boot/dts/mediatek/mt8183-evb.dt.yaml arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dt.yaml
Quoted 6 lines
If a platform's larb supports gals, there will be some larbs have one more "gals" clock while the others still only need "apb"/"smi" clocks, then the minItems for clocks and clock-names are 2.
Fixes 27bb0e42855a ("dt-bindings: memory: mediatek: Convert SMI to DT schema")Signed-off-by Yong Wu <[email protected]>
Yong Wu
maintainerPATCH v3 4/7 dt-bindings: memory: mediatek: Add mt8186 support
In reply to Yong WuAdd mt8186 smi support in the bindings.
--- .../bindings/memory-controllers/mediatek,smi-common.yaml | 4 +++- .../bindings/memory-controllers/mediatek,smi-larb.yaml | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-common.yaml +3 -1
@@ -16,7 +16,7 @@ description: | MediaTek SMI have two generations of HW architecture, here is the list which generation the SoCs use: generation 1: mt2701 and mt7623. - generation 2: mt2712, mt6779, mt8167, mt8173, mt8183, mt8192 and mt8195. + generation 2: mt2712, mt6779, mt8167, mt8173, mt8183, mt8186, mt8192 and mt8195. There's slight differences between the two SMI, for generation 2, the register which control the iommu port is at each larb's register base. But
@@ -35,6 +35,7 @@ properties: - mediatek,mt8167-smi-common - mediatek,mt8173-smi-common - mediatek,mt8183-smi-common + - mediatek,mt8186-smi-common - mediatek,mt8192-smi-common - mediatek,mt8195-smi-common-vdo - mediatek,mt8195-smi-common-vpp
@@ -125,6 +126,7 @@ allOf: enum: - mediatek,mt6779-smi-common - mediatek,mt8183-smi-common + - mediatek,mt8186-smi-common - mediatek,mt8192-smi-common - mediatek,mt8195-smi-common-vdo - mediatek,mt8195-smi-common-vpp
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +3 -0
@@ -23,6 +23,7 @@ properties: - mediatek,mt8167-smi-larb - mediatek,mt8173-smi-larb - mediatek,mt8183-smi-larb + - mediatek,mt8186-smi-larb - mediatek,mt8192-smi-larb - mediatek,mt8195-smi-larb
@@ -75,6 +76,7 @@ allOf: compatible: enum: - mediatek,mt8183-smi-larb + - mediatek,mt8186-smi-larb - mediatek,mt8195-smi-larb then:
@@ -107,6 +109,7 @@ allOf: - mediatek,mt2701-smi-larb - mediatek,mt2712-smi-larb - mediatek,mt6779-smi-larb + - mediatek,mt8186-smi-larb - mediatek,mt8192-smi-larb - mediatek,mt8195-smi-larb
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v3 4/7] dt-bindings: memory: mediatek: Add mt8186 support
Il 13/01/22 12:10, Yong Wu ha scritto:
Quoted 4 lines
Add mt8186 smi support in the bindings.
Signed-off-by Yong Wu <[email protected]>Acked-by Rob Herring <[email protected]>
Yong Wu
maintainerPATCH v3 5/7 memory: mtk-smi: Fix the return value for clk_bulk_prepare_enable
In reply to Yong WuFunction clk_bulk_prepare_enable() returns 0 for success or a negative number for error. Fix this code style issue.
--- drivers/memory/mtk-smi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/mtk-smi.c +1 -1
@@ -480,7 +480,7 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev)int ret; ret =clk_bulk_prepare_enable (larb->smi.clk_num, larb->smi.clks); -if (ret <0 ) +if (ret)return ret;/* Configure the basic setting for this larb */
Signature · 1 line
2.18.0
Re: [PATCH v3 5/7] memory: mtk-smi: Fix the return value for clk_bulk_prepare_enable
Quoted 2 lines · Yong Wu
Function
clk_bulk_prepare_enable()returns 0 for success or a negative number for error. Fix this code style issue.
The message does not really make sense. If negative is returned, then the check (ret < 0) was correct.
I guess you wanted to say that common code style is to check for any non-zero return value, just like it's implementation in clk.h does.
I'll adjust the commit msg when applying.
Quoted 13 lines
Signed-off-by Yong Wu <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>--- drivers/memory/mtk-smi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/memory/mtk-smi.c +0
-0
drivers/memory/mtk-smi.c static int __maybe_unused mtk_smi_larb_resume(struct device *dev) · line 486
Quoted 8 lines
drivers/memory/mtk-smi.c +1
-1@@ -480,7 +480,7 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev)int ret; ret =clk_bulk_prepare_enable (larb->smi.clk_num, larb->smi.clks); -if (ret <0 ) +if (ret)return ret;/* Configure the basic setting for this larb */
Best regards,
Krzysztof
Yong Wu
maintainerRe: [PATCH v3 5/7] memory: mtk-smi: Fix the return value for clk_bulk_prepare_enable
Quoted 5 lines · Krzysztof Kozlowski
Quoted 3 lines · Yong Wu
Function
clk_bulk_prepare_enable()returns 0 for success or a negative
number for error. Fix this code style issue.
Quoted 7 lines
The message does not really make sense. If negative is returned, then the check (ret < 0) was correct.
I guess you wanted to say that common code style is to check for any non-zero return value, just like it's implementation in
clk.hdoes.I'll adjust the commit msg when applying.
Thanks for the help.
Quoted 27 lines
Quoted 23 lines
Signed-off-by Yong Wu <[email protected]>Reviewed-by AngeloGioacchino Del Regno <--- drivers/memory/mtk-smi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/memory/mtk-smi.c +1
-1@@ -480,7 +480,7 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev) int ret; ret =clk_bulk_prepare_enable (larb->smi.clk_num, larb- >smi.clks); -if (ret <0 ) +if (ret)return ret;Quoted 1 line
/* Configure the basic setting for this larb */
Best regards,
Krzysztof
Yong Wu
maintainerPATCH v3 6/7 memory: mtk-smi: Add sleep ctrl function
In reply to Yong WuSleep control means that when the larb goes to sleep, we should wait a bit until all the current commands are finished. Thus, when the larb runtime suspends, we need to enable this function to wait until all the existed commands are finished. When the larb resumes, just disable this function. This function only improves the safety of bus. Add a new flag for this function. Prepare for mt8186.
--- drivers/memory/mtk-smi.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/memory/mtk-smi.c +36 -0
@@ -8,6 +8,7 @@#include <linux/device.h> #include <linux/err.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_platform.h>
@@ -32,6 +33,10 @@#define SMI_DUMMY 0x444/* SMI LARB */ +#define SMI_LARB_SLP_CON 0xc +#define SLP_PROT_EN BIT(0) +#define SLP_PROT_RDY BIT(16) +#define SMI_LARB_CMD_THRT_CON 0x24#define SMI_LARB_THRT_RD_NU_LMT_MSK GENMASK(7, 4)#define SMI_LARB_THRT_RD_NU_LMT (5 << 4)
@@ -81,6 +86,7 @@#define MTK_SMI_FLAG_THRT_UPDATE BIT(0)#define MTK_SMI_FLAG_SW_FLAG BIT(1) +#define MTK_SMI_FLAG_SLEEP_CTL BIT(2)#define MTK_SMI_CAPS (flags, _x) (!!((flags) & (_x)))struct mtk_smi_reg_pair {
@@ -371,6 +377,26 @@ static const struct of_device_id mtk_smi_larb_of_ids[] = { {} }; +static int mtk_smi_larb_sleep_ctrl_enable (struct mtk_smi_larb *larb) +{ +int ret; +u32 tmp; + +writel_relaxed (SLP_PROT_EN , larb->base +SMI_LARB_SLP_CON ); + ret =readl_poll_timeout_atomic (larb->base +SMI_LARB_SLP_CON , + tmp, !!(tmp &SLP_PROT_RDY ),10 ,1000 ); +if (ret) { +/* TODO: Reset this larb if it fails here. */ +dev_err (larb->smi.dev,"sleep ctrl is not ready(0x%x).\n" , tmp); + } +return ret; +} + +static void mtk_smi_larb_sleep_ctrl_disable (struct mtk_smi_larb *larb) +{ +writel_relaxed (0 , larb->base +SMI_LARB_SLP_CON ); +} +static int mtk_smi_device_link_common (struct device *dev,struct device **com_dev) {struct platform_device *smi_com_pdev;
@@ -483,6 +509,9 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev)if (ret)return ret; +if (MTK_SMI_CAPS (larb->larb_gen->flags_general,MTK_SMI_FLAG_SLEEP_CTL )) +mtk_smi_larb_sleep_ctrl_disable (larb); +/* Configure the basic setting for this larb */ larb_gen->config_port (dev);
@@ -492,6 +521,13 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev)static int __maybe_unused mtk_smi_larb_suspend (struct device *dev) {struct mtk_smi_larb *larb =dev_get_drvdata (dev); +int ret; + +if (MTK_SMI_CAPS (larb->larb_gen->flags_general,MTK_SMI_FLAG_SLEEP_CTL )) { + ret =mtk_smi_larb_sleep_ctrl_enable (larb); +if (ret) +return ret; + }clk_bulk_disable_unprepare (larb->smi.clk_num, larb->smi.clks);return 0 ;
Signature · 1 line
2.18.0
Yong Wu
maintainerPATCH v3 7/7 memory: mtk-smi: mt8186: Add smi support
In reply to Yong WuAdd mt8186 SMI support.
--- drivers/memory/mtk-smi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/memory/mtk-smi.c +13 -0
@@ -355,6 +355,11 @@ static const struct mtk_smi_larb_gen mtk_smi_larb_mt8183 = {/* IPU0 | IPU1 | CCU */ }; +static const struct mtk_smi_larb_gen mtk_smi_larb_mt8186 = { + .config_port = mtk_smi_larb_config_port_gen2_general, + .flags_general =MTK_SMI_FLAG_SLEEP_CTL , +}; +static const struct mtk_smi_larb_gen mtk_smi_larb_mt8192 = { .config_port = mtk_smi_larb_config_port_gen2_general, };
@@ -372,6 +377,7 @@ static const struct of_device_id mtk_smi_larb_of_ids[] = { {.compatible = "mediatek,mt8167-smi-larb", .data = &mtk_smi_larb_mt8167}, {.compatible = "mediatek,mt8173-smi-larb", .data = &mtk_smi_larb_mt8173}, {.compatible = "mediatek,mt8183-smi-larb", .data = &mtk_smi_larb_mt8183}, + {.compatible = "mediatek,mt8186-smi-larb", .data = &mtk_smi_larb_mt8186}, {.compatible = "mediatek,mt8192-smi-larb", .data = &mtk_smi_larb_mt8192}, {.compatible = "mediatek,mt8195-smi-larb", .data = &mtk_smi_larb_mt8195}, {}
@@ -580,6 +586,12 @@ static const struct mtk_smi_common_plat mtk_smi_common_mt8183 = { F_MMU1_LARB(7), }; +static const struct mtk_smi_common_plat mtk_smi_common_mt8186 = { + .type =MTK_SMI_GEN2 , + .has_gals = true, + .bus_sel =F_MMU1_LARB (1 ) |F_MMU1_LARB (4 ) |F_MMU1_LARB (7 ), +}; +static const struct mtk_smi_common_plat mtk_smi_common_mt8192 = { .type =MTK_SMI_GEN2 , .has_gals = true,
@@ -614,6 +626,7 @@ static const struct of_device_id mtk_smi_common_of_ids[] = { {.compatible = "mediatek,mt8167-smi-common", .data = &mtk_smi_common_gen2}, {.compatible = "mediatek,mt8173-smi-common", .data = &mtk_smi_common_gen2}, {.compatible = "mediatek,mt8183-smi-common", .data = &mtk_smi_common_mt8183}, + {.compatible = "mediatek,mt8186-smi-common", .data = &mtk_smi_common_mt8186}, {.compatible = "mediatek,mt8192-smi-common", .data = &mtk_smi_common_mt8192}, {.compatible = "mediatek,mt8195-smi-common-vdo", .data = &mtk_smi_common_mt8195_vdo}, {.compatible = "mediatek,mt8195-smi-common-vpp", .data = &mtk_smi_common_mt8195_vpp},
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Krzysztof Kozlowski
AppliedQuoted 10 lines · Yong Wu
This patchset adds mt8186 smi support.
mainly adds a sleep control function.Change note:
v3: a) Add a new binding patch for renaming "clock" to "clocks".
b) Reword the title for the binding patches, more detailed.
c) Add the sleep control error path: if err, return directly. also change the log fromdev_warntodev_err.[...]
Applied, thanks!
[1/7] dt-bindings: memory: mtk-smi: Rename clock to clocks
commit: 5bf7fa48374eafe29dbb30448a0b0c083853583f
[2/7] dt-bindings: memory: mtk-smi: No need mediatek,larb-id for mt8167
commit: ddc3a324889686ec9b358de20fdeec0d2668c7a8
[3/7] dt-bindings: memory: mtk-smi: Correct minItems to 2 for the gals clocks
commit: 996ebc0e332bfb3091395f9bd286d8349a57be62
[4/7] dt-bindings: memory: mediatek: Add mt8186 support
commit: 6d86f23c35fe7b479ceef4d3f1eef925996945fd
[5/7] memory: mtk-smi: Fix the return value for clk_bulk_prepare_enable
commit: a6945f4566d4f77a4054720f6649ff921fe1ae64
[6/7] memory: mtk-smi: Add sleep ctrl function
commit: 8956500e5d5bf541a945299999b0bf4866dc0daf
[7/7] memory: mtk-smi: mt8186: Add smi support
commit: 86a010bfc73983aa8cd914f1e5f73962b0406678Best regards,
Signature · 5 lines
Krzysztof Kozlowski <[email protected]> _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu