2017-08-04 01:32:46

by Honghui Zhang

[permalink] [raw]
Subject: [PATCH v3 0/4] Add larbid init routine for mediatek's gen1 smi larb driver

From: Honghui Zhang <[email protected]>

Mediatek's gen1 smi need the hardware larb-id to identify the offset for
the register which controls whether enable iommu for this larb.
In the commit 3c8f4ad85c4b ("memory/mediatek: add support for mt2701"),
the larbid was used without properly initialized. This patchset fixed
that.
Also include a patch which using the of_device_get_match_data helper to
simplify the code.
This patchset was base on 4.13-rc1.

Change since v2:
- Using compatible strings of "mediatek,larb-id" instead of "mediatek,larbid"
to make it a bit easier to read.
- Put the v2 of the patch ("memory: mtk-smi: Use of_device_get_match_data helper")[1]
in this patchset to make the changes easier for review.
- Add the reivewer's tag in commit messages.

Change since v1:
- Using mtk_smi_larb_gen to identify whether larbid was needed instead of
checking hard code bindings.

[1] https://patchwork.kernel.org/patch/9864719

Honghui Zhang (4):
memory: mtk-smi: Use of_device_get_match_data helper
memory: mtk-smi: add larbid handle routine
dt-bindings: mediatek: add descriptions for larbid
arm: dts: mediatek: add larbid property for larb

.../memory-controllers/mediatek,smi-larb.txt | 15 +++++++++++++
arch/arm/boot/dts/mt2701.dtsi | 3 +++
drivers/memory/mtk-smi.c | 26 ++++++++++++----------
3 files changed, 32 insertions(+), 12 deletions(-)

--
2.6.4


2017-08-04 01:32:49

by Honghui Zhang

[permalink] [raw]
Subject: [PATCH v3 2/4] memory: mtk-smi: add larbid handle routine

From: Honghui Zhang <[email protected]>

In the commit 3c8f4ad85c4b ("memory/mediatek: add support for mt2701"),
the larb->larbid was added but not initialized.
Mediatek's gen1 smi need this hardware larbid information to get the
register offset which controls whether enable iommu for this larb.
This patch add the initialize routine for larbid.

Reviewed-by: Matthias Brugger <[email protected]>
Signed-off-by: Honghui Zhang <[email protected]>
---
drivers/memory/mtk-smi.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index 2b798bb4..a3ff19a 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -42,6 +42,7 @@
#define SMI_SECUR_CON_VAL_DOMAIN(id) (0x3 << ((((id) & 0x7) << 2) + 1))

struct mtk_smi_larb_gen {
+ bool need_larbid;
int port_in_larb[MTK_LARB_NR_MAX + 1];
void (*config_port)(struct device *);
};
@@ -214,6 +215,7 @@ static const struct mtk_smi_larb_gen mtk_smi_larb_mt8173 = {
};

static const struct mtk_smi_larb_gen mtk_smi_larb_mt2701 = {
+ .need_larbid = true,
.port_in_larb = {
LARB0_PORT_OFFSET, LARB1_PORT_OFFSET,
LARB2_PORT_OFFSET, LARB3_PORT_OFFSET
@@ -240,6 +242,7 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *smi_node;
struct platform_device *smi_pdev;
+ int err;

if (!dev->pm_domain)
return -EPROBE_DEFER;
@@ -263,6 +266,15 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)
return PTR_ERR(larb->smi.clk_smi);
larb->smi.dev = dev;

+ if (larb->larb_gen->need_larbid) {
+ err = of_property_read_u32(dev->of_node, "mediatek,larb-id",
+ &larb->larbid);
+ if (err) {
+ dev_err(dev, "missing larbid property\n");
+ return err;
+ }
+ }
+
smi_node = of_parse_phandle(dev->of_node, "mediatek,smi", 0);
if (!smi_node)
return -EINVAL;
--
2.6.4

2017-08-04 01:33:12

by Honghui Zhang

[permalink] [raw]
Subject: [PATCH v3 4/4] arm: dts: mediatek: add larbid property for larb

From: Honghui Zhang <[email protected]>

Add mediatek's hardware id information for smi larb.

Signed-off-by: Honghui Zhang <[email protected]>
---
arch/arm/boot/dts/mt2701.dtsi | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
index f1efdc6..d95bfe0 100644
--- a/arch/arm/boot/dts/mt2701.dtsi
+++ b/arch/arm/boot/dts/mt2701.dtsi
@@ -533,6 +533,7 @@
compatible = "mediatek,mt2701-smi-larb";
reg = <0 0x14010000 0 0x1000>;
mediatek,smi = <&smi_common>;
+ mediatek,larb-id = <0>;
clocks = <&mmsys CLK_MM_SMI_LARB0>,
<&mmsys CLK_MM_SMI_LARB0>;
clock-names = "apb", "smi";
@@ -549,6 +550,7 @@
compatible = "mediatek,mt2701-smi-larb";
reg = <0 0x15001000 0 0x1000>;
mediatek,smi = <&smi_common>;
+ mediatek,larb-id = <2>;
clocks = <&imgsys CLK_IMG_SMI_COMM>,
<&imgsys CLK_IMG_SMI_COMM>;
clock-names = "apb", "smi";
@@ -579,6 +581,7 @@
compatible = "mediatek,mt2701-smi-larb";
reg = <0 0x16010000 0 0x1000>;
mediatek,smi = <&smi_common>;
+ mediatek,larb-id = <1>;
clocks = <&vdecsys CLK_VDEC_CKGEN>,
<&vdecsys CLK_VDEC_LARB>;
clock-names = "apb", "smi";
--
2.6.4

2017-08-04 01:32:44

by Honghui Zhang

[permalink] [raw]
Subject: [PATCH v3 1/4] memory: mtk-smi: Use of_device_get_match_data helper

From: Honghui Zhang <[email protected]>

Replace custom code with generic helper to retrieve driver data.

Signed-off-by: Honghui Zhang <[email protected]>
---
drivers/memory/mtk-smi.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index 4afbc41..2b798bb4 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -240,20 +240,15 @@ static int mtk_smi_larb_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *smi_node;
struct platform_device *smi_pdev;
- const struct of_device_id *of_id;

if (!dev->pm_domain)
return -EPROBE_DEFER;

- of_id = of_match_node(mtk_smi_larb_of_ids, pdev->dev.of_node);
- if (!of_id)
- return -EINVAL;
-
larb = devm_kzalloc(dev, sizeof(*larb), GFP_KERNEL);
if (!larb)
return -ENOMEM;

- larb->larb_gen = of_id->data;
+ larb->larb_gen = of_device_get_match_data(dev);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
larb->base = devm_ioremap_resource(dev, res);
if (IS_ERR(larb->base))
@@ -319,7 +314,6 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct mtk_smi *common;
struct resource *res;
- const struct of_device_id *of_id;
enum mtk_smi_gen smi_gen;

if (!dev->pm_domain)
@@ -338,17 +332,13 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
if (IS_ERR(common->clk_smi))
return PTR_ERR(common->clk_smi);

- of_id = of_match_node(mtk_smi_common_of_ids, pdev->dev.of_node);
- if (!of_id)
- return -EINVAL;
-
/*
* for mtk smi gen 1, we need to get the ao(always on) base to config
* m4u port, and we need to enable the aync clock for transform the smi
* clock into emi clock domain, but for mtk smi gen2, there's no smi ao
* base.
*/
- smi_gen = (enum mtk_smi_gen)of_id->data;
+ smi_gen = (enum mtk_smi_gen)of_device_get_match_data(dev);
if (smi_gen == MTK_SMI_GEN1) {
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
common->smi_ao_base = devm_ioremap_resource(dev, res);
--
2.6.4

2017-08-04 01:33:34

by Honghui Zhang

[permalink] [raw]
Subject: [PATCH v3 3/4] dt-bindings: mediatek: add descriptions for larbid

From: Honghui Zhang <[email protected]>

This patch add larbid descritptions for mediatek's gen1 smi larb hardware.

Acked-by: Rob Herring <[email protected]>
Signed-off-by: Honghui Zhang <[email protected]>
---
.../bindings/memory-controllers/mediatek,smi-larb.txt | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt b/Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
index 21277a5..ddf46b8 100644
--- a/Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
+++ b/Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt
@@ -15,6 +15,9 @@ Required properties:
the register.
- "smi" : It's the clock for transfer data and command.

+Required property for mt2701:
+- mediatek,larb-id :the hardware id of this larb.
+
Example:
larb1: larb@16010000 {
compatible = "mediatek,mt8173-smi-larb";
@@ -25,3 +28,15 @@ Example:
<&vdecsys CLK_VDEC_LARB_CKEN>;
clock-names = "apb", "smi";
};
+
+Example for mt2701:
+ larb0: larb@14010000 {
+ compatible = "mediatek,mt2701-smi-larb";
+ reg = <0 0x14010000 0 0x1000>;
+ mediatek,smi = <&smi_common>;
+ mediatek,larb-id = <0>;
+ clocks = <&mmsys CLK_MM_SMI_LARB0>,
+ <&mmsys CLK_MM_SMI_LARB0>;
+ clock-names = "apb", "smi";
+ power-domains = <&scpsys MT2701_POWER_DOMAIN_DISP>;
+ };
--
2.6.4

2017-08-04 10:06:37

by Joerg Roedel

[permalink] [raw]
Subject: Re: [PATCH v3 0/4] Add larbid init routine for mediatek's gen1 smi larb driver

On Fri, Aug 04, 2017 at 09:32:24AM +0800, [email protected] wrote:
> Honghui Zhang (4):
> memory: mtk-smi: Use of_device_get_match_data helper
> memory: mtk-smi: add larbid handle routine
> dt-bindings: mediatek: add descriptions for larbid
> arm: dts: mediatek: add larbid property for larb
>
> .../memory-controllers/mediatek,smi-larb.txt | 15 +++++++++++++
> arch/arm/boot/dts/mt2701.dtsi | 3 +++
> drivers/memory/mtk-smi.c | 26 ++++++++++++----------
> 3 files changed, 32 insertions(+), 12 deletions(-)

Applied, thanks.

2017-08-04 14:28:42

by Matthias Brugger

[permalink] [raw]
Subject: Re: [PATCH v3 0/4] Add larbid init routine for mediatek's gen1 smi larb driver



On 08/04/2017 12:06 PM, Joerg Roedel wrote:
> On Fri, Aug 04, 2017 at 09:32:24AM +0800, [email protected] wrote:
>> Honghui Zhang (4):
>> memory: mtk-smi: Use of_device_get_match_data helper
>> memory: mtk-smi: add larbid handle routine
>> dt-bindings: mediatek: add descriptions for larbid
>> arm: dts: mediatek: add larbid property for larb
>>
>> .../memory-controllers/mediatek,smi-larb.txt | 15 +++++++++++++
>> arch/arm/boot/dts/mt2701.dtsi | 3 +++
>> drivers/memory/mtk-smi.c | 26 ++++++++++++----------
>> 3 files changed, 32 insertions(+), 12 deletions(-)
>
> Applied, thanks.
>

I just pushed patch 4/4 to v4.13-next/dts32

Thanks everybody!