diff mbox

[U-Boot,04/10] video: exynos_fimd: Add framework to disable FIMD sysmmu

Message ID 1402995979-32394-5-git-send-email-ajaykumar.rs@samsung.com
State Changes Requested
Delegated to: Minkyu Kang
Headers show

Commit Message

Ajay Kumar June 17, 2014, 9:06 a.m. UTC
On Exynos5420 and newer versions, the FIMD sysmmus are in
"on state" by default.
We have to disable them in order to make FIMD DMA work.
This patch adds the required framework to exynos_fimd driver,
and disables FIMD sysmmu on Exynos5420.

Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
---
 arch/arm/dts/exynos54xx.dtsi                 | 10 ++++++
 doc/device-tree-bindings/video/exynos-fb.txt |  2 ++
 drivers/video/exynos_fimd.c                  | 52 ++++++++++++++++++++++++++++
 include/fdtdec.h                             |  4 +++
 lib/fdtdec.c                                 |  2 ++
 5 files changed, 70 insertions(+)

Comments

Simon Glass June 20, 2014, 3:29 a.m. UTC | #1
On 17 June 2014 03:06, Ajay Kumar <ajaykumar.rs@samsung.com> wrote:
> On Exynos5420 and newer versions, the FIMD sysmmus are in
> "on state" by default.
> We have to disable them in order to make FIMD DMA work.
> This patch adds the required framework to exynos_fimd driver,
> and disables FIMD sysmmu on Exynos5420.
>
> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>

Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>

(I assume this is the same device tree binding as Linux?)
Simon Glass June 20, 2014, 3:32 a.m. UTC | #2
On 17 June 2014 03:06, Ajay Kumar <ajaykumar.rs@samsung.com> wrote:
> On Exynos5420 and newer versions, the FIMD sysmmus are in
> "on state" by default.
> We have to disable them in order to make FIMD DMA work.
> This patch adds the required framework to exynos_fimd driver,
> and disables FIMD sysmmu on Exynos5420.
>
> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>

Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Ajay kumar June 20, 2014, 6:42 a.m. UTC | #3
Hi Simon,


On Fri, Jun 20, 2014 at 8:59 AM, Simon Glass <sjg@google.com> wrote:
> On 17 June 2014 03:06, Ajay Kumar <ajaykumar.rs@samsung.com> wrote:
>> On Exynos5420 and newer versions, the FIMD sysmmus are in
>> "on state" by default.
>> We have to disable them in order to make FIMD DMA work.
>> This patch adds the required framework to exynos_fimd driver,
>> and disables FIMD sysmmu on Exynos5420.
>>
>> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
>
> Acked-by: Simon Glass <sjg@chromium.org>
> Tested-by: Simon Glass <sjg@chromium.org>
>
> (I assume this is the same device tree binding as Linux?)
Actually, No!
Kernel has a generic binding named "samsung,sysmmu-v3.3", and it is common
for all sysmmu nodes. There is a seperate IOMMU driver to handle the same.
We can port the device probing part from kernel to u-boot, but we would need
to add seperate driver(since the name is generic) to handle the same.
That driver, even though being generic, will be used only by FIMD
sysmmus(that too, just to turn them off).

Ajay
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Simon Glass June 23, 2014, 12:15 p.m. UTC | #4
Hi Ajay,

On 20 June 2014 00:42, Ajay kumar <ajaynumb@gmail.com> wrote:
> Hi Simon,
>
>
> On Fri, Jun 20, 2014 at 8:59 AM, Simon Glass <sjg@google.com> wrote:
>> On 17 June 2014 03:06, Ajay Kumar <ajaykumar.rs@samsung.com> wrote:
>>> On Exynos5420 and newer versions, the FIMD sysmmus are in
>>> "on state" by default.
>>> We have to disable them in order to make FIMD DMA work.
>>> This patch adds the required framework to exynos_fimd driver,
>>> and disables FIMD sysmmu on Exynos5420.
>>>
>>> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
>>
>> Acked-by: Simon Glass <sjg@chromium.org>
>> Tested-by: Simon Glass <sjg@chromium.org>
>>
>> (I assume this is the same device tree binding as Linux?)
> Actually, No!
> Kernel has a generic binding named "samsung,sysmmu-v3.3", and it is common
> for all sysmmu nodes. There is a seperate IOMMU driver to handle the same.
> We can port the device probing part from kernel to u-boot, but we would need
> to add seperate driver(since the name is generic) to handle the same.
> That driver, even though being generic, will be used only by FIMD
> sysmmus(that too, just to turn them off).

OK. I suppose you could add a very short new C file with a function
which finds the device tree node by its compatible string or whatever,
and then updates the hardware.

Regards,
Simon
Ajay kumar June 24, 2014, 6:59 a.m. UTC | #5
Simon,

On Mon, Jun 23, 2014 at 5:45 PM, Simon Glass <sjg@google.com> wrote:
> Hi Ajay,
>
> On 20 June 2014 00:42, Ajay kumar <ajaynumb@gmail.com> wrote:
>> Hi Simon,
>>
>>
>> On Fri, Jun 20, 2014 at 8:59 AM, Simon Glass <sjg@google.com> wrote:
>>> On 17 June 2014 03:06, Ajay Kumar <ajaykumar.rs@samsung.com> wrote:
>>>> On Exynos5420 and newer versions, the FIMD sysmmus are in
>>>> "on state" by default.
>>>> We have to disable them in order to make FIMD DMA work.
>>>> This patch adds the required framework to exynos_fimd driver,
>>>> and disables FIMD sysmmu on Exynos5420.
>>>>
>>>> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
>>>
>>> Acked-by: Simon Glass <sjg@chromium.org>
>>> Tested-by: Simon Glass <sjg@chromium.org>
>>>
>>> (I assume this is the same device tree binding as Linux?)
>> Actually, No!
>> Kernel has a generic binding named "samsung,sysmmu-v3.3", and it is common
>> for all sysmmu nodes. There is a seperate IOMMU driver to handle the same.
>> We can port the device probing part from kernel to u-boot, but we would need
>> to add seperate driver(since the name is generic) to handle the same.
>> That driver, even though being generic, will be used only by FIMD
>> sysmmus(that too, just to turn them off).
>
> OK. I suppose you could add a very short new C file with a function
> which finds the device tree node by its compatible string or whatever,
> and then updates the hardware.
Ok. I will add this.

Ajay
> Regards,
> Simon
diff mbox

Patch

diff --git a/arch/arm/dts/exynos54xx.dtsi b/arch/arm/dts/exynos54xx.dtsi
index b9f8e0b..402d12b 100644
--- a/arch/arm/dts/exynos54xx.dtsi
+++ b/arch/arm/dts/exynos54xx.dtsi
@@ -113,6 +113,16 @@ 
 		status = "disabled";
 	};
 
+	fimdm0_sysmmu@0x14640000 {
+		compatible = "samsung,sysmmu-fimdm0";
+		reg = <0x14640000 0x100>;
+	};
+
+	fimdm1_sysmmu@0x14680000 {
+		compatible = "samsung,sysmmu-fimdm1";
+		reg = <0x14680000 0x100>;
+	};
+
 	fimd@14400000 {
 		/* sysmmu is not used in U-Boot */
 		samsung,disable-sysmmu;
diff --git a/doc/device-tree-bindings/video/exynos-fb.txt b/doc/device-tree-bindings/video/exynos-fb.txt
index bb7441c..7d9b995 100644
--- a/doc/device-tree-bindings/video/exynos-fb.txt
+++ b/doc/device-tree-bindings/video/exynos-fb.txt
@@ -55,6 +55,8 @@  Board(panel specific):
 	samsung,pclk-name: parent clock identifier: 1(MPLL), 2(EPLL), 3(VPLL)
 	samsung,sclk-div: parent_clock/source_clock ratio
 	samsung,dual-lcd-enabled: 1 if you support two LCD, else 0
+	samsung,disable-sysmmu: present if you want to disable the sysmmu
+			(needed for Exynos5420 and newer versions)
 
 Example:
 SOC specific part:
diff --git a/drivers/video/exynos_fimd.c b/drivers/video/exynos_fimd.c
index cebbba7..5630d0b 100644
--- a/drivers/video/exynos_fimd.c
+++ b/drivers/video/exynos_fimd.c
@@ -251,6 +251,54 @@  void exynos_fimd_window_off(unsigned int win_id)
 	writel(cfg, &fimd_ctrl->winshmap);
 }
 
+#ifdef CONFIG_OF_CONTROL
+void exynos_fimd_disable_sysmmu(void)
+{
+	u32 *sysmmufimd;
+	unsigned int node;
+
+	/*
+	* The reset value for FIMD SYSMMU register MMU_CTRL is 3
+	* on Exynos5420 and newer versions.
+	* This means FIMD SYSMMU is on by default on Exynos5420
+	* and newer versions.
+	* Since in u-boot we don't use SYSMMU, we should disable
+	* those FIMD SYSMMU.
+	* Note that there are 2 SYSMMU for FIMD: m0 and m1.
+	* m0 handles windows 0 and 4, and m1 handles windows 1, 2 and 3.
+	* We disable both of them here.
+	*/
+	node = fdtdec_next_compatible(gd->fdt_blob, 0,
+			COMPAT_SAMSUNG_EXYNOS_FIMD_SYSMMU0);
+	if (node <= 0) {
+		debug("exynos_fb: Can't get device node for fimd dma m0\n");
+		return;
+	}
+
+	sysmmufimd = (u32 *)fdtdec_get_addr(gd->fdt_blob, node, "reg");
+	if (!sysmmufimd) {
+		debug("Can't get base address for sysmmu fimdm0");
+		return;
+	}
+
+	writel(0x0, sysmmufimd);
+
+	node = fdtdec_next_compatible(gd->fdt_blob, 0,
+			COMPAT_SAMSUNG_EXYNOS_FIMD_SYSMMU1);
+	if (node <= 0) {
+		debug("exynos_fb: Can't get device node for fimd dma m1\n");
+		return;
+	}
+
+	sysmmufimd = (u32 *)fdtdec_get_addr(gd->fdt_blob, node, "reg");
+	if (!sysmmufimd) {
+		debug("Can't get base address for sysmmu fimdm0");
+		return;
+	}
+
+	writel(0x0, sysmmufimd);
+}
+#endif
 
 void exynos_fimd_lcd_init(vidinfo_t *vid)
 {
@@ -268,6 +316,10 @@  void exynos_fimd_lcd_init(vidinfo_t *vid)
 								node, "reg");
 	if (fimd_ctrl == NULL)
 		debug("Can't get the FIMD base address\n");
+
+	if (fdtdec_get_bool(gd->fdt_blob, node, "samsung,disable-sysmmu"))
+		exynos_fimd_disable_sysmmu();
+
 #else
 	fimd_ctrl = (struct exynos_fb *)samsung_get_base_fimd();
 #endif
diff --git a/include/fdtdec.h b/include/fdtdec.h
index a7e6ee7..3329623 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -94,6 +94,10 @@  enum fdt_compat_id {
 	COMPAT_SANDBOX_LCD_SDL,		/* Sandbox LCD emulation with SDL */
 	COMPAT_TI_TPS65090,		/* Texas Instrument TPS65090 */
 	COMPAT_NXP_PTN3460,		/* NXP PTN3460 DP/LVDS bridge */
+	/* Exynos Display controller sysmmu0 */
+	COMPAT_SAMSUNG_EXYNOS_FIMD_SYSMMU0,
+	/* Exynos Display controller sysmmu1 */
+	COMPAT_SAMSUNG_EXYNOS_FIMD_SYSMMU1,
 
 	COMPAT_COUNT,
 };
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 13d3d2f..701169e 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -68,6 +68,8 @@  static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(SANDBOX_LCD_SDL, "sandbox,lcd-sdl"),
 	COMPAT(TI_TPS65090, "ti,tps65090"),
 	COMPAT(COMPAT_NXP_PTN3460, "nxp,ptn3460"),
+	COMPAT(SAMSUNG_EXYNOS_FIMD_SYSMMU0, "samsung,sysmmu-fimdm0"),
+	COMPAT(SAMSUNG_EXYNOS_FIMD_SYSMMU1, "samsung,sysmmu-fimdm1"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)