2012-11-22 23:05:39

by Fabio Estevam

[permalink] [raw]
Subject: [PATCH v4 1/3] ARM: imx27_visstrim_m10: Do not reserve DMA pools on board file

Do not reserve DMA pools on board file as this can be done via CMA.

The motivation for doing this is to allow to register the VPU driver via a common
SoC file instead of per board.

Signed-off-by: Fabio Estevam <[email protected]>
---
This applies against 20121115 linux-next.

Changes since v3:
- Remove all the DMA pools
Changes since v2:
- No changes. Newly introduced on this series
arch/arm/mach-imx/mach-imx27_visstrim_m10.c | 66 ++-------------------------
1 file changed, 3 insertions(+), 63 deletions(-)

diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
index b744226..914b2f8 100644
--- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
+++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
@@ -30,7 +30,6 @@
#include <linux/input.h>
#include <linux/gpio.h>
#include <linux/delay.h>
-#include <linux/dma-mapping.h>
#include <linux/leds.h>
#include <linux/platform_data/asoc-mx27vis.h>
#include <media/soc_camera.h>
@@ -39,7 +38,6 @@
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
#include <asm/system_info.h>
-#include <asm/memblock.h>

#include "common.h"
#include "devices-imx27.h"
@@ -234,14 +232,8 @@ static struct mx2_camera_platform_data visstrim_camera = {
.clk = 100000,
};

-static phys_addr_t mx2_camera_base __initdata;
-#define MX2_CAMERA_BUF_SIZE SZ_8M
-
static void __init visstrim_camera_init(void)
{
- struct platform_device *pdev;
- int dma;
-
gpio_set_value(TVP5150_PWDN, 1);
ndelay(1);
gpio_set_value(TVP5150_RSTN, 0);
@@ -249,23 +241,7 @@ static void __init visstrim_camera_init(void)
gpio_set_value(TVP5150_RSTN, 1);
ndelay(200000);

- pdev = imx27_add_mx2_camera(&visstrim_camera);
- if (IS_ERR(pdev))
- return;
-
- dma = dma_declare_coherent_memory(&pdev->dev,
- mx2_camera_base, mx2_camera_base,
- MX2_CAMERA_BUF_SIZE,
- DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
- if (!(dma & DMA_MEMORY_MAP))
- return;
-}
-
-static void __init visstrim_reserve(void)
-{
- /* reserve 4 MiB for mx2-camera */
- mx2_camera_base = arm_memblock_steal(3 * MX2_CAMERA_BUF_SIZE,
- MX2_CAMERA_BUF_SIZE);
+ imx27_add_mx2_camera(&visstrim_camera);
}

/* GPIOs used as events for applications */
@@ -434,47 +410,12 @@ static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = {
.flags = IMX_SSI_DMA | IMX_SSI_SYN,
};

-/* coda */
-
-static void __init visstrim_coda_init(void)
-{
- struct platform_device *pdev;
- int dma;
-
- pdev = imx27_add_coda();
- dma = dma_declare_coherent_memory(&pdev->dev,
- mx2_camera_base + MX2_CAMERA_BUF_SIZE,
- mx2_camera_base + MX2_CAMERA_BUF_SIZE,
- MX2_CAMERA_BUF_SIZE,
- DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
- if (!(dma & DMA_MEMORY_MAP))
- return;
-}
-
/* DMA deinterlace */
static struct platform_device visstrim_deinterlace = {
.name = "m2m-deinterlace",
.id = 0,
};

-static void __init visstrim_deinterlace_init(void)
-{
- int ret = -ENOMEM;
- struct platform_device *pdev = &visstrim_deinterlace;
- int dma;
-
- ret = platform_device_register(pdev);
-
- dma = dma_declare_coherent_memory(&pdev->dev,
- mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE,
- mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE,
- MX2_CAMERA_BUF_SIZE,
- DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
- if (!(dma & DMA_MEMORY_MAP))
- return;
-}
-
-
/* Audio */
static const struct snd_mx27vis_platform_data snd_mx27vis_pdata __initconst = {
.amp_gain0_gpio = AMP_GAIN_0,
@@ -546,9 +487,9 @@ static void __init visstrim_m10_board_init(void)
platform_device_register_resndata(NULL, "soc-camera-pdrv", 0, NULL, 0,
&iclink_tvp5150, sizeof(iclink_tvp5150));
gpio_led_register_device(0, &visstrim_m10_led_data);
- visstrim_deinterlace_init();
+ platform_device_register(&visstrim_deinterlace);
visstrim_camera_init();
- visstrim_coda_init();
+ imx27_add_coda();
}

static void __init visstrim_m10_timer_init(void)
@@ -562,7 +503,6 @@ static struct sys_timer visstrim_m10_timer = {

MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
.atag_offset = 0x100,
- .reserve = visstrim_reserve,
.map_io = mx27_map_io,
.init_early = imx27_init_early,
.init_irq = mx27_init_irq,
--
1.7.9.5


2012-11-22 18:28:43

by Fabio Estevam

[permalink] [raw]
Subject: [PATCH v4 3/3] ARM: mx27: Add VPU support

mx27 has a VPU (Video Processing Unit) block that allows doing H264/MPEG4
decoding and encoding in hardware.

Add support for it in a common SoC file instead of per board file.

Also make sure to not register the VPU driver for the MX27Lite version as this
one does not contain the VPU controller.

Signed-off-by: Fabio Estevam <[email protected]>
---
Changes since v3:
- Use a shorter name for VPU disabled fuse bit.
Changes since v2:
- Do not register VPU for mx27lite version
Changes since v1:
- Call imx27_add_coda() on a common mx27 location instead of per board
arch/arm/mach-imx/iim.h | 2 ++
arch/arm/mach-imx/mach-imx27_visstrim_m10.c | 1 -
arch/arm/mach-imx/mm-imx27.c | 21 ++++++++++++++++++++-
3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/iim.h b/arch/arm/mach-imx/iim.h
index d1d6f35..4ac1de9 100644
--- a/arch/arm/mach-imx/iim.h
+++ b/arch/arm/mach-imx/iim.h
@@ -74,4 +74,6 @@
#define MXC_IIMHWV2_BP_SDMA (0x1 << 6)
#define MXC_IIMHWV2_SCM_DCM (0x1 << 5)

+#define MX27_VPU_DISABLE (0x1 << 7)
+
#endif /* __ASM_ARCH_MXC_IIM_H__ */
diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
index 914b2f8..d228d09 100644
--- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
+++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
@@ -489,7 +489,6 @@ static void __init visstrim_m10_board_init(void)
gpio_led_register_device(0, &visstrim_m10_led_data);
platform_device_register(&visstrim_deinterlace);
visstrim_camera_init();
- imx27_add_coda();
}

static void __init visstrim_m10_timer_init(void)
diff --git a/arch/arm/mach-imx/mm-imx27.c b/arch/arm/mach-imx/mm-imx27.c
index 4f1be65..cf65792 100644
--- a/arch/arm/mach-imx/mm-imx27.c
+++ b/arch/arm/mach-imx/mm-imx27.c
@@ -25,9 +25,10 @@
#include <asm/mach/map.h>

#include "common.h"
-#include "devices/devices-common.h"
+#include "devices-imx27.h"
#include "hardware.h"
#include "iomux-v1.h"
+#include "iim.h"

/* MX27 memory map definition */
static struct map_desc imx27_io_desc[] __initdata = {
@@ -80,6 +81,20 @@ static const struct resource imx27_audmux_res[] __initconst = {
DEFINE_RES_MEM(MX27_AUDMUX_BASE_ADDR, SZ_4K),
};

+static int cpu_is_mx27l(void)
+{
+ int fuse;
+ fuse = __raw_readl(MX27_IO_ADDRESS(MX27_IIM_BASE_ADDR +
+ MXC_IIMWORD3_BANK0));
+
+ fuse &= MX27_VPU_DISABLE;
+
+ if (fuse)
+ return 1;
+ else
+ return 0;
+}
+
void __init imx27_soc_init(void)
{
mxc_device_init();
@@ -98,4 +113,8 @@ void __init imx27_soc_init(void)
/* imx27 has the imx21 type audmux */
platform_device_register_simple("imx21-audmux", 0, imx27_audmux_res,
ARRAY_SIZE(imx27_audmux_res));
+
+ /* MX27L variant does not have VPU, so do not register VPU for it */
+ if (!cpu_is_mx27l())
+ imx27_add_coda();
}
--
1.7.9.5

2012-11-22 18:28:42

by Fabio Estevam

[permalink] [raw]
Subject: [PATCH v4 2/3] ARM: mx27: Align IIM registers with MX27 Reference Manual

Align IIM registers with the MX27 Reference Manual.

Signed-off-by: Fabio Estevam <[email protected]>
---
Changes since v3:
- No changes
Changes since v2:
- No changes. Newly introduced on this series
arch/arm/mach-imx/iim.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-imx/iim.h b/arch/arm/mach-imx/iim.h
index 315bffa..d1d6f35 100644
--- a/arch/arm/mach-imx/iim.h
+++ b/arch/arm/mach-imx/iim.h
@@ -36,11 +36,11 @@
#define MXC_IIMSCS1 0x0030
#define MXC_IIMSCS2 0x0034
#define MXC_IIMSCS3 0x0038
-#define MXC_IIMFBAC0 0x0800
-#define MXC_IIMJAC 0x0804
-#define MXC_IIMHWV1 0x0808
-#define MXC_IIMHWV2 0x080C
-#define MXC_IIMHAB0 0x0810
+#define MXC_IIMFBAC0 0x003C
+#define MXC_IIMWORD1_BANK0 0x0804
+#define MXC_IIMWORD2_BANK0 0x0808
+#define MXC_IIMWORD3_BANK0 0x080C
+#define MXC_IIMWORD4_BANK0 0x0810
#define MXC_IIMHAB1 0x0814
/* Definitions for i.MX27 TO2 */
#define MXC_IIMMAC 0x0814
--
1.7.9.5

2012-11-23 11:28:32

by javier Martin

[permalink] [raw]
Subject: Re: [PATCH v4 1/3] ARM: imx27_visstrim_m10: Do not reserve DMA pools on board file

Hi Fabio,
have you actually tested CMA with mx2_camera and coda drivers in i.MX27?


On 22 November 2012 17:12, Fabio Estevam <[email protected]> wrote:
> Do not reserve DMA pools on board file as this can be done via CMA.
>
> The motivation for doing this is to allow to register the VPU driver via a common
> SoC file instead of per board.
>
> Signed-off-by: Fabio Estevam <[email protected]>
> ---
> This applies against 20121115 linux-next.
>
> Changes since v3:
> - Remove all the DMA pools
> Changes since v2:
> - No changes. Newly introduced on this series
> arch/arm/mach-imx/mach-imx27_visstrim_m10.c | 66 ++-------------------------
> 1 file changed, 3 insertions(+), 63 deletions(-)
>
> diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
> index b744226..914b2f8 100644
> --- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
> +++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
> @@ -30,7 +30,6 @@
> #include <linux/input.h>
> #include <linux/gpio.h>
> #include <linux/delay.h>
> -#include <linux/dma-mapping.h>
> #include <linux/leds.h>
> #include <linux/platform_data/asoc-mx27vis.h>
> #include <media/soc_camera.h>
> @@ -39,7 +38,6 @@
> #include <asm/mach/arch.h>
> #include <asm/mach/time.h>
> #include <asm/system_info.h>
> -#include <asm/memblock.h>
>
> #include "common.h"
> #include "devices-imx27.h"
> @@ -234,14 +232,8 @@ static struct mx2_camera_platform_data visstrim_camera = {
> .clk = 100000,
> };
>
> -static phys_addr_t mx2_camera_base __initdata;
> -#define MX2_CAMERA_BUF_SIZE SZ_8M
> -
> static void __init visstrim_camera_init(void)
> {
> - struct platform_device *pdev;
> - int dma;
> -
> gpio_set_value(TVP5150_PWDN, 1);
> ndelay(1);
> gpio_set_value(TVP5150_RSTN, 0);
> @@ -249,23 +241,7 @@ static void __init visstrim_camera_init(void)
> gpio_set_value(TVP5150_RSTN, 1);
> ndelay(200000);
>
> - pdev = imx27_add_mx2_camera(&visstrim_camera);
> - if (IS_ERR(pdev))
> - return;
> -
> - dma = dma_declare_coherent_memory(&pdev->dev,
> - mx2_camera_base, mx2_camera_base,
> - MX2_CAMERA_BUF_SIZE,
> - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
> - if (!(dma & DMA_MEMORY_MAP))
> - return;
> -}
> -
> -static void __init visstrim_reserve(void)
> -{
> - /* reserve 4 MiB for mx2-camera */
> - mx2_camera_base = arm_memblock_steal(3 * MX2_CAMERA_BUF_SIZE,
> - MX2_CAMERA_BUF_SIZE);
> + imx27_add_mx2_camera(&visstrim_camera);
> }
>
> /* GPIOs used as events for applications */
> @@ -434,47 +410,12 @@ static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = {
> .flags = IMX_SSI_DMA | IMX_SSI_SYN,
> };
>
> -/* coda */
> -
> -static void __init visstrim_coda_init(void)
> -{
> - struct platform_device *pdev;
> - int dma;
> -
> - pdev = imx27_add_coda();
> - dma = dma_declare_coherent_memory(&pdev->dev,
> - mx2_camera_base + MX2_CAMERA_BUF_SIZE,
> - mx2_camera_base + MX2_CAMERA_BUF_SIZE,
> - MX2_CAMERA_BUF_SIZE,
> - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
> - if (!(dma & DMA_MEMORY_MAP))
> - return;
> -}
> -
> /* DMA deinterlace */
> static struct platform_device visstrim_deinterlace = {
> .name = "m2m-deinterlace",
> .id = 0,
> };
>
> -static void __init visstrim_deinterlace_init(void)
> -{
> - int ret = -ENOMEM;
> - struct platform_device *pdev = &visstrim_deinterlace;
> - int dma;
> -
> - ret = platform_device_register(pdev);
> -
> - dma = dma_declare_coherent_memory(&pdev->dev,
> - mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE,
> - mx2_camera_base + 2 * MX2_CAMERA_BUF_SIZE,
> - MX2_CAMERA_BUF_SIZE,
> - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
> - if (!(dma & DMA_MEMORY_MAP))
> - return;
> -}
> -
> -
> /* Audio */
> static const struct snd_mx27vis_platform_data snd_mx27vis_pdata __initconst = {
> .amp_gain0_gpio = AMP_GAIN_0,
> @@ -546,9 +487,9 @@ static void __init visstrim_m10_board_init(void)
> platform_device_register_resndata(NULL, "soc-camera-pdrv", 0, NULL, 0,
> &iclink_tvp5150, sizeof(iclink_tvp5150));
> gpio_led_register_device(0, &visstrim_m10_led_data);
> - visstrim_deinterlace_init();
> + platform_device_register(&visstrim_deinterlace);
> visstrim_camera_init();
> - visstrim_coda_init();
> + imx27_add_coda();
> }
>
> static void __init visstrim_m10_timer_init(void)
> @@ -562,7 +503,6 @@ static struct sys_timer visstrim_m10_timer = {
>
> MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
> .atag_offset = 0x100,
> - .reserve = visstrim_reserve,
> .map_io = mx27_map_io,
> .init_early = imx27_init_early,
> .init_irq = mx27_init_irq,
> --
> 1.7.9.5
>
>



--
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
http://www.vista-silicon.com

2012-11-23 12:27:21

by Fabio Estevam

[permalink] [raw]
Subject: Re: [PATCH v4 1/3] ARM: imx27_visstrim_m10: Do not reserve DMA pools on board file

Hi Javier,

javier Martin wrote:
> Hi Fabio,
> have you actually tested CMA with mx2_camera and coda drivers in i.MX27?

Only probe tested it. Please ket me know if you have issues.

Thanks,

Fabio Estevam