MT8186 SMI SUPPORT
Yong Wu
maintainerv2 cover MT8186 SMI SUPPORT
This patchset adds mt8186 smi support, mainly adds a sleep control function.
Change note:
v2: 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 (6):
dt-bindings: memory: mtk-smi: Fix larb-id dtbs_check warning
dt-bindings: memory: mtk-smi: Fix the larb clock/clock-names dtbs
warning
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 | 4 +- .../memory-controllers/mediatek,smi-larb.yaml | 10 ++-- drivers/memory/mtk-smi.c | 50 ++++++++++++++++++- 3 files changed, 57 insertions(+), 7 deletions(-)
Signature · 1 line
2.18.0
Yong Wu
maintainerPATCH v2 1/6 dt-bindings: memory: mtk-smi: Fix larb-id dtbs_check warning
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.yaml
--- .../bindings/memory-controllers/mediatek,smi-larb.yaml | 1 - 1 file changed, 1 deletion(-)
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +0 -1
@@ -108,7 +108,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 v2 1/6] dt-bindings: memory: mtk-smi: Fix larb-id dtbs_check warning
Quoted 8 lines · Yong Wu
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.yaml
Please explain why larb-id is not necessary on mediatek,mt8167-smi-larb. IOW, what logical error was there (except the dtschema pointed out issue).
Quoted 7 lines
Fixes 27bb0e42855a ("dt-bindings: memory: mediatek: Convert SMI to DT schema")Signed-off-by Yong Wu <[email protected]>--- .../bindings/memory-controllers/mediatek,smi-larb.yaml | 1 - 1 file changed, 1 deletion(-)
Best regards,
Krzysztof
Yong Wu
maintainerPATCH v2 2/6 dt-bindings: memory: mtk-smi: Fix the larb clock/clock-names dtbs warning
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 clock and clock-names are 2.
--- .../bindings/memory-controllers/mediatek,smi-larb.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +3 -3
@@ -80,10 +80,10 @@ allOf: then: properties: clock: - items: - minItems: 3 - maxItems: 3 + minItems: 2 + maxItems: 3 clock-names: + minItems: 2 items: - const: apb - const: smi
Signature · 1 line
2.18.0
Re: [PATCH v2 2/6] dt-bindings: memory: mtk-smi: Fix the larb clock/clock-names dtbs warning
Quoted 30 lines · Yong Wu
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.yamlIf 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 clock and clock-names are 2.
Fixes 27bb0e42855a ("dt-bindings: memory: mediatek: Convert SMI to DT schema")Signed-off-by Yong Wu <[email protected]>--- .../bindings/memory-controllers/mediatek,smi-larb.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +0
-0
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml allOf: · line 82
Quoted 3 lines
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +0
-0@@ -80,10 +80,10 @@ allOf: then: properties: clock:
Separate patch:
This should be clocks. The same in second if. Now it is simply not working...
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml allOf: · line 83
Quoted 1 line
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +0
-1- items:
Putting min/maxItems under items is wrong. The second if also needs the fixing. Please make it a separate patch before this one.
The schema was clearly not tested before...
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml allOf: · line 89
Quoted 10 lines
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +3
-2- minItems: 3 - maxItems: 3 + minItems: 2 + maxItems: 3 clock-names: + minItems: 2 items: - const: apb - const: smi
Best regards,
Krzysztof
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Yong Wu
maintainerRe: [PATCH v2 2/6] dt-bindings: memory: mtk-smi: Fix the larb clock/clock-names dtbs warning
Quoted 51 lines · Krzysztof Kozlowski
Quoted 42 lines · Yong Wu
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.yamlIf 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 clock and clock-names are 2.Fixes 27bb0e42855a ("dt-bindings: memory: mediatek: Convert SMI toDT schema")
Signed-off-by Yong Wu <[email protected]>--- .../bindings/memory-controllers/mediatek,smi-larb.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)(quoted diff) +0
-0
controllers/mediatek,smi-larb.yaml
b/Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml
index80907e357892..884c0c74e5e4100644
--- a/Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml
+++ b/Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yamlDocumentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml allOf: · line 82
Quoted 3 lines
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +0
-0@@ -80,10 +80,10 @@ allOf: then: properties: clock:Separate patch:
This should be clocks. The same in second if. Now it is simply not working...
Quoted 5 lines
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml allOf: · line 83
Quoted 1 line
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +0
-1- items:Putting min/maxItems under items is wrong. The second if also needs the
fixing. Please make it a separate patch before this one.
Oh. I will use a new patch for renaming "clock" to "clocks" and removing the "items".
Thanks.
Quoted 18 lines
The schema was clearly not tested before...
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml allOf: · line 89
Quoted 10 lines
Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.yaml +3
-2- minItems: 3 - maxItems: 3 + minItems: 2 + maxItems: 3 clock-names: + minItems: 2 items: - const: apb - const: smiBest regards,
Krzysztof
Yong Wu
maintainerPATCH v2 3/6 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
@@ -127,6 +128,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:
@@ -108,6 +110,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
Yong Wu
maintainerPATCH v2 4/6 memory: mtk-smi: Fix the return value for clk_bulk_prepare_enable
In reply to Yong WuThe successful return value for clk_bulk_prepare_enable is 0, rather than "< 0". Fix this.
--- 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 v2 4/6] memory: mtk-smi: Fix the return value for clk_bulk_prepare_enable
Il 11/01/22 07:39, Yong Wu ha scritto:
Quoted 3 lines
The successful return value for
clk_bulk_prepare_enableis 0, rather than "< 0". Fix this.
Hello! Thanks for this commit!
However, there are a few comments...
This description is a bit confusing, please reword it, something like...
"Function clk_bulk_prepare_enable() returns 0 for success or a negative number for error. Fix this code style issue."
In any case, you're not fixing any bad logic issue here, as the function will never return anything > 0.
What you're fixing is a common pattern usage issue, so the Fixes tag can be removed since it's not really useful to schedule this commit for backport over older stable versions.
After the requested changes:
Quoted 20 lines
Fixes 0e14917c57f9 ("memory: mtk-smi: Use clk_bulk clock ops")Signed-off-by Yong Wu <[email protected]>--- 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 */
Yong Wu
maintainerRe: [PATCH v2 4/6] memory: mtk-smi: Fix the return value for clk_bulk_prepare_enable
Quoted 9 lines · AngeloGioacchino Del Regno
Il 11/01/22 07:39, Yong Wu ha scritto:
Quoted 4 lines
The successful return value for
clk_bulk_prepare_enableis 0, rather than
"< 0". Fix this.Hello! Thanks for this commit!
However, there are a few comments...
Quoted 6 lines
This description is a bit confusing, please reword it, something like...
"Function
clk_bulk_prepare_enable()returns 0 for success or a negative
number for error. Fix this code style issue."
Thanks for your quickly reviewing.
I will use this in next version and remove the "Fixes" tag.
Quoted 41 lines
In any case, you're not fixing any bad logic issue here, as the function
will never return anything > 0.What you're fixing is a common pattern usage issue, so the Fixes tag can be
removed since it's not really useful to schedule this commit for backport
over older stable versions.After the requested changes:
Reviewed-by: AngeloGioacchino Del Regno <
[email protected]>Quoted 22 lines
Fixes 0e14917c57f9 ("memory: mtk-smi: Use clk_bulk clock ops")Signed-off-by Yong Wu <[email protected]>--- 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 */
Re: [PATCH v2 4/6] memory: mtk-smi: Fix the return value for clk_bulk_prepare_enable
In reply to Yong WuQuoted 2 lines · Yong Wu
The successful return value for
clk_bulk_prepare_enableis 0, rather than "< 0". Fix this.
I do not understand. The commit description does not match the code. What is the error here?
Quoted 2 lines
Fixes 0e14917c57f9 ("memory: mtk-smi: Use clk_bulk clock ops")
There is no bug to fix...
Quoted 11 lines
Signed-off-by Yong Wu <[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
maintainerPATCH v2 5/6 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 | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
drivers/memory/mtk-smi.c +34 -1
@@ -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_warn (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,9 +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 =0 ; + +if (MTK_SMI_CAPS (larb->larb_gen->flags_general,MTK_SMI_FLAG_SLEEP_CTL )) + ret =mtk_smi_larb_sleep_ctrl_enable (larb);clk_bulk_disable_unprepare (larb->smi.clk_num, larb->smi.clks); -return 0 ; +return ret; }static const struct dev_pm_ops smi_larb_pm_ops = {
Signature · 6 lines
2.18.0 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 5/6] memory: mtk-smi: Add sleep ctrl function
Il 11/01/22 07:39, Yong Wu ha scritto:
Quoted 9 lines
Sleep 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.
Signed-off-by Anan Sun <[email protected]>Signed-off-by Yong Wu <[email protected]>
Re: [PATCH v2 5/6] memory: mtk-smi: Add sleep ctrl function
In reply to Yong WuQuoted 83 lines · Yong Wu
Sleep 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.
Signed-off-by Anan Sun <[email protected]>Signed-off-by Yong Wu <[email protected]>--- drivers/memory/mtk-smi.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)drivers/memory/mtk-smi.c +29
-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_warn (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,9 +521,13 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev)static int __maybe_unused mtk_smi_larb_suspend (struct device *dev)
drivers/memory/mtk-smi.c static int __maybe_unused mtk_smi_larb_resume(struct device *dev) · line 530
Quoted 10 lines
drivers/memory/mtk-smi.c +5
-1{struct mtk_smi_larb *larb =dev_get_drvdata (dev); +int ret =0 ; + +if (MTK_SMI_CAPS (larb->larb_gen->flags_general,MTK_SMI_FLAG_SLEEP_CTL )) + ret =mtk_smi_larb_sleep_ctrl_enable (larb);clk_bulk_disable_unprepare (larb->smi.clk_num, larb->smi.clks); -return 0 ; +return ret;
I am wondering whether disabling clocks in error case is a proper step. On suspend error, the PM core won't run any further callbacks on this device. This means, it won't be resumed and your clocks stay disabled. I think you should return early and leave the device in active state in case of error.
Best regards,
Krzysztof
Yong Wu
maintainerRe: [PATCH v2 5/6] memory: mtk-smi: Add sleep ctrl function
Quoted 18 lines · Krzysztof Kozlowski
Quoted 17 lines · Yong Wu
Sleep 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.Signed-off-by Anan Sun <[email protected]>Signed-off-by Yong Wu <[email protected]>--- drivers/memory/mtk-smi.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
[...]
Quoted 11 lines
Quoted 11 lines
drivers/memory/mtk-smi.c +4
-0@@ -492,9 +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 =0 ; + +if (MTK_SMI_CAPS (larb->larb_gen->flags_general,MTK_SMI_FLAG_SLEEP_CTL )) + ret =mtk_smi_larb_sleep_ctrl_enable (larb);
Quoted 11 lines
drivers/memory/mtk-smi.c static int __maybe_unused mtk_smi_larb_resume(struct device *dev) · line 530
Quoted 3 lines
drivers/memory/mtk-smi.c +1
-1clk_bulk_disable_unprepare (larb->smi.clk_num, larb->smi.clks); -return 0 ; +return ret;I am wondering whether disabling clocks in error case is a proper step.
On suspend error, the PM core won't run any further callbacks on this device. This means, it won't be resumed and your clocks stay disabled. I
think you should return early and leave the device in active state in case of error.
oh, Yes. Thanks for pointing this out.
I will fix this in next version.
Quoted 9 lines
Best regards,
Krzysztof_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Yong Wu
maintainerPATCH v2 6/6 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}, {}
@@ -577,6 +583,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,
@@ -611,6 +623,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