Skip to contentSkip to conversation

ARM: imx: add gpu device

PATCH New Richard Zhao 7 participants 17 messages Mar 30, 2011 – Apr 1, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

From: Richard Zhao <[email protected]>

Add mxc_gpu devices for imx35/50/51/53, so external gpu driver module built for the kernel can work.

---
 arch/arm/mach-mx3/Kconfig                       |    1 +
 arch/arm/mach-mx3/devices-imx35.h               |    4 +
 arch/arm/mach-mx3/mach-mx35_3ds.c               |    3 +
 arch/arm/mach-mx5/Kconfig                       |    6 ++
 arch/arm/mach-mx5/board-mx50_rdp.c              |    3 +
 arch/arm/mach-mx5/board-mx51_3ds.c              |    3 +
 arch/arm/mach-mx5/board-mx51_babbage.c          |    3 +
 arch/arm/mach-mx5/board-mx53_loco.c             |    9 ++
 arch/arm/mach-mx5/devices-imx50.h               |    4 +
 arch/arm/mach-mx5/devices-imx51.h               |    4 +
 arch/arm/mach-mx5/devices-imx53.h               |    4 +
 arch/arm/plat-mxc/devices/Kconfig               |    3 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-mxc_gpu.c    |   94 +++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   12 +++
 arch/arm/plat-mxc/include/mach/mx35.h           |    4 +-
 arch/arm/plat-mxc/include/mach/mx51.h           |    9 +-
 arch/arm/plat-mxc/include/mach/mx53.h           |    1 +
 18 files changed, 163 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/plat-mxc/devices/platform-mxc_gpu.c
arch/arm/mach-mx3/Kconfig +1 -0
index 340809a..197ba67 100644
@@ -187,6 +187,7 @@ config MACH_MX35_3DS
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_EHCI
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_MXC_NAND
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	help
arch/arm/mach-mx3/devices-imx35.h +4 -0
index d545d86..e6fb746 100644
@@ -74,3 +74,7 @@ extern const struct imx_spi_imx_data imx35_cspi_data[] __initconst;
 	imx_add_spi_imx(&imx35_cspi_data[id], pdata)
 #define imx35_add_spi_imx0(pdata)	imx35_add_cspi(0, pdata)
 #define imx35_add_spi_imx1(pdata)	imx35_add_cspi(1, pdata)
+
+extern const struct imx_mxc_gpu_data imx35_gpu_data;
+#define imx35_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx35_gpu_data, pdata)
arch/arm/mach-mx3/mach-mx35_3ds.c +3 -0
index ff5fe23..1987311 100644
@@ -175,6 +175,8 @@ static const struct imxi2c_platform_data mx35_3ds_i2c0_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int z160_revision __initdata;
+
 /*
  * Board specific initialization.
  */
@@ -203,6 +205,7 @@ static void __init mx35_3ds_init(void)
 		pr_warn("Init of the debugboard failed, all "
 				"devices on the debugboard are unusable.\n");
 	imx35_add_imx_i2c0(&mx35_3ds_i2c0_data);
+	imx35_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx35pdk_timer_init(void)
arch/arm/mach-mx5/Kconfig +6 -0
index 159340d..a3873ac 100644
@@ -41,6 +41,7 @@ config MACH_MX51_BABBAGE
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	help
@@ -54,6 +55,7 @@ config MACH_MX51_3DS
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	select MXC_DEBUG_BOARD
@@ -142,6 +144,7 @@ config MACH_MX53_EVK
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_IMX_I2C
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	help
@@ -154,6 +157,7 @@ config MACH_MX53_SMD
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	help
 	  Include support for MX53 SMD platform. This includes specific
 	  configurations for the board and its peripherals.
@@ -164,6 +168,7 @@ config MACH_MX53_LOCO
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_GPIO_KEYS
 	help
@@ -176,6 +181,7 @@ config MACH_MX50_RDP
 	select SOC_IMX50
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	select IMX_HAVE_PLATFORM_FEC
arch/arm/mach-mx5/board-mx50_rdp.c +3 -0
index dedf7f2..90742ce 100644
@@ -188,6 +188,8 @@ static const struct imxi2c_platform_data i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int z160_revision __initdata = 1;
+
 /*
  * Board specific initialization.
  */
@@ -203,6 +205,7 @@ static void __init mx50_rdp_board_init(void)
 	imx50_add_imx_i2c(0, &i2c_data);
 	imx50_add_imx_i2c(1, &i2c_data);
 	imx50_add_imx_i2c(2, &i2c_data);
+	imx50_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx50_rdp_timer_init(void)
arch/arm/mach-mx5/board-mx51_3ds.c +3 -0
index 63dfbea..19b91f8 100644
@@ -130,6 +130,8 @@ static struct spi_board_info mx51_3ds_spi_nor_device[] = {
 	 .platform_data = NULL,},
 };
 
+static int z160_revision __initdata;
+
 /*
  * Board specific initialization.
  */
@@ -153,6 +155,7 @@ static void __init mx51_3ds_init(void)
 	imx51_add_sdhci_esdhc_imx(0, NULL);
 	imx51_add_imx_keypad(&mx51_3ds_map_data);
 	imx51_add_imx2_wdt(0, NULL);
+	imx51_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx51_3ds_timer_init(void)
arch/arm/mach-mx5/board-mx51_babbage.c +3 -0
index bea4e41..4d0c00d 100644
@@ -337,6 +337,8 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = {
 	.num_chipselect = ARRAY_SIZE(mx51_babbage_spi_cs),
 };
 
+static int z160_revision __initdata;
+
 /*
  * Board specific initialization.
  */
@@ -387,6 +389,7 @@ static void __init mx51_babbage_init(void)
 		ARRAY_SIZE(mx51_babbage_spi_board_info));
 	imx51_add_ecspi(0, &mx51_babbage_spi_pdata);
 	imx51_add_imx2_wdt(0, NULL);
+	imx51_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx51_babbage_timer_init(void)
arch/arm/mach-mx5/board-mx53_loco.c +9 -0
index 10a1bea..e689643 100644
@@ -227,6 +227,8 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int z160_revision __initdata;
+
 static void __init mx53_loco_board_init(void)
 {
 	mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
@@ -240,6 +242,13 @@ static void __init mx53_loco_board_init(void)
 	imx53_add_sdhci_esdhc_imx(0, NULL);
 	imx53_add_sdhci_esdhc_imx(2, NULL);
 	imx_add_gpio_keys(&loco_button_data);
+
+	/*GPU*/
+	if (mx53_revision() >= IMX_CHIP_REVISION_2_0)
+		z160_revision = 1;
+	else
+		z160_revision = 0;
+	imx53_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx53_loco_timer_init(void)
arch/arm/mach-mx5/devices-imx50.h +4 -0
index c9e4282..6059b2c 100644
@@ -32,3 +32,7 @@ extern const struct imx_fec_data imx50_fec_data __initconst;
 extern const struct imx_imx_i2c_data imx50_imx_i2c_data[] __initconst;
 #define imx50_add_imx_i2c(id, pdata)	\
 	imx_add_imx_i2c(&imx50_imx_i2c_data[id], pdata)
+
+extern const struct imx_mxc_gpu_data imx50_gpu_data;
+#define imx50_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx50_gpu_data, pdata)
arch/arm/mach-mx5/devices-imx51.h +4 -0
index 7fff485..c32adc2 100644
@@ -55,3 +55,7 @@ extern const struct imx_mxc_pwm_data imx51_mxc_pwm_data[] __initconst;
 extern const struct imx_imx_keypad_data imx51_imx_keypad_data __initconst;
 #define imx51_add_imx_keypad(pdata)	\
 	imx_add_imx_keypad(&imx51_imx_keypad_data, pdata)
+
+extern const struct imx_mxc_gpu_data imx51_gpu_data;
+#define imx51_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx51_gpu_data, pdata)
arch/arm/mach-mx5/devices-imx53.h +4 -0
index 9251008..6472215 100644
@@ -33,3 +33,7 @@ extern const struct imx_spi_imx_data imx53_ecspi_data[] __initconst;
 extern const struct imx_imx2_wdt_data imx53_imx2_wdt_data[] __initconst;
 #define imx53_add_imx2_wdt(id, pdata)	\
 	imx_add_imx2_wdt(&imx53_imx2_wdt_data[id])
+
+extern const struct imx_mxc_gpu_data imx53_gpu_data;
+#define imx53_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx53_gpu_data, pdata)
arch/arm/plat-mxc/devices/Kconfig +3 -0
index b9ab1d5..db1bfad 100644
@@ -50,6 +50,9 @@ config IMX_HAVE_PLATFORM_MX2_CAMERA
 config IMX_HAVE_PLATFORM_MXC_EHCI
 	bool
 
+config IMX_HAVE_PLATFORM_MXC_GPU
+	bool
+
 config IMX_HAVE_PLATFORM_MXC_MMC
 	bool
 
arch/arm/plat-mxc/devices/Makefile +1 -0
index 75cd2ec..c2ce086 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MX1_CAMERA) += platform-mx1-camera.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MX2_CAMERA) += platform-mx2-camera.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_EHCI) += platform-mxc-ehci.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_GPU) +=  platform-mxc_gpu.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_MMC) += platform-mxc-mmc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_PWM) += platform-mxc_pwm.o
arch/arm/plat-mxc/devices/platform-mxc_gpu.c new file +94 -0

94 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/devices-common.h +12 -0
index 8658c9c..1c8ed19 100644
@@ -264,3 +264,15 @@ struct imx_spi_imx_data {
 struct platform_device *__init imx_add_spi_imx(
 		const struct imx_spi_imx_data *data,
 		const struct spi_imx_master *pdata);
+
+struct imx_mxc_gpu_data {
+	resource_size_t irq_2d;
+	resource_size_t irq_3d;
+	resource_size_t iobase_2d;
+	resource_size_t iobase_3d;
+	resource_size_t gmem_base;
+	resource_size_t gmem_size;
+};
+struct platform_device *__init imx_add_mxc_gpu(
+		const struct imx_mxc_gpu_data *data,
+		const int *pdata);
arch/arm/plat-mxc/include/mach/mx35.h +3 -1
index d13dbfe..e2954ab 100644
@@ -7,6 +7,8 @@
 #define MX35_IRAM_BASE_ADDR		0x10000000	/* internal ram */
 #define MX35_IRAM_SIZE			SZ_128K
 
+#define MX35_GPU2D_BASE_ADDR		0x20000000
+
 #define MX35_L2CC_BASE_ADDR		0x30000000
 #define MX35_L2CC_SIZE			SZ_1M
 
@@ -133,7 +135,7 @@
 #define MX35_INT_CSPI2		13
 #define MX35_INT_CSPI1		14
 #define MX35_INT_ATA		15
-#define MX35_INT_GPU2D		16
+#define MX35_INT_GPU2_IRQ	16
 #define MX35_INT_ASRC		17
 #define MX35_INT_UART3		18
 #define MX35_INT_IIM		19
arch/arm/plat-mxc/include/mach/mx51.h +5 -4
index dede19a..cab469a 100644
@@ -14,8 +14,9 @@
 #define MX51_IRAM_PARTITIONS		16
 #define MX51_IRAM_SIZE		(MX51_IRAM_PARTITIONS * SZ_8K)	/* 128KB */
 
-#define MX51_GPU_BASE_ADDR		0x20000000
-#define MX51_GPU_CTRL_BASE_ADDR		0x30000000
+#define MX51_GPU_GMEM_BASE_ADDR		0x20000000
+#define MX51_GPU_GMEM_SIZE		SZ_128K
+#define MX51_GPU_BASE_ADDR		0x30000000
 #define MX51_IPU_CTRL_BASE_ADDR		0x40000000
 
 #define MX51_DEBUG_BASE_ADDR		0x60000000
@@ -253,7 +254,7 @@
 #define MX51_MXC_INT_VPU		9
 #define MX51_INT_IPU_ERR		10
 #define MX51_INT_IPU_SYN		11
-#define MX51_MXC_INT_GPU		12
+#define MX51_INT_GPU			12
 #define MX51_MXC_INT_RESV13		13
 #define MX51_MXC_INT_USB_H1		14
 #define MX51_MXC_INT_EMI		15
@@ -325,7 +326,7 @@
 #define MX51_MXC_INT_MCG_ERR		81
 #define MX51_MXC_INT_MCG_TMR		82
 #define MX51_MXC_INT_MCG_FUNC		83
-#define MX51_MXC_INT_GPU2_IRQ		84
+#define MX51_INT_GPU2_IRQ		84
 #define MX51_MXC_INT_GPU2_BUSY		85
 #define MX51_MXC_INT_RESV86		86
 #define MX51_INT_FEC			87
arch/arm/plat-mxc/include/mach/mx53.h +1 -0
index ace1786..01dd210 100644
@@ -35,6 +35,7 @@
 #define MX53_GPU2D_BASE_ADDR		0x20000000
 #define MX53_GPU_BASE_ADDR		0x30000000
 #define MX53_GPU_GMEM_BASE_ADDR	0xF8020000
+#define MX53_GPU_GMEM_SIZE	SZ_256K
 
 #define MX53_DEBUG_BASE_ADDR		0x40000000
 #define MX53_DEBUG_SIZE		SZ_1M
Signature · 1 line
1.7.1
#1 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Quoted 7 lines · Richard Zhao

From: Richard Zhao <[email protected]>

Add mxc_gpu devices for imx35/50/51/53, so external gpu driver module built for the kernel can work.

---

A changed-since-v1 section would be nice here. I assume the only change is that __initconst is skipped for the external declaration? Does someone volunteer to remove these for the other declarations?

Quoted 50 lines
 arch/arm/mach-mx3/Kconfig                       |    1 +
 arch/arm/mach-mx3/devices-imx35.h               |    4 +
 arch/arm/mach-mx3/mach-mx35_3ds.c               |    3 +
 arch/arm/mach-mx5/Kconfig                       |    6 ++
 arch/arm/mach-mx5/board-mx50_rdp.c              |    3 +
 arch/arm/mach-mx5/board-mx51_3ds.c              |    3 +
 arch/arm/mach-mx5/board-mx51_babbage.c          |    3 +
 arch/arm/mach-mx5/board-mx53_loco.c             |    9 ++
 arch/arm/mach-mx5/devices-imx50.h               |    4 +
 arch/arm/mach-mx5/devices-imx51.h               |    4 +
 arch/arm/mach-mx5/devices-imx53.h               |    4 +
 arch/arm/plat-mxc/devices/Kconfig               |    3 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-mxc_gpu.c    |   94 +++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   12 +++
 arch/arm/plat-mxc/include/mach/mx35.h           |    4 +-
 arch/arm/plat-mxc/include/mach/mx51.h           |    9 +-
 arch/arm/plat-mxc/include/mach/mx53.h           |    1 +
 18 files changed, 163 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/plat-mxc/devices/platform-mxc_gpu.c
arch/arm/mach-mx3/Kconfig +1 -0
index 340809a..197ba67 100644
@@ -187,6 +187,7 @@ config MACH_MX35_3DS
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_EHCI
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_MXC_NAND
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	help
arch/arm/mach-mx3/devices-imx35.h +4 -0
index d545d86..e6fb746 100644
@@ -74,3 +74,7 @@ extern const struct imx_spi_imx_data imx35_cspi_data[] __initconst;
 	imx_add_spi_imx(&imx35_cspi_data[id], pdata)
 #define imx35_add_spi_imx0(pdata)	imx35_add_cspi(0, pdata)
 #define imx35_add_spi_imx1(pdata)	imx35_add_cspi(1, pdata)
+
+extern const struct imx_mxc_gpu_data imx35_gpu_data;
+#define imx35_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx35_gpu_data, pdata)
arch/arm/mach-mx3/mach-mx35_3ds.c +0 -0
index ff5fe23..1987311 100644

arch/arm/mach-mx3/mach-mx35_3ds.c static const struct imxi2c_platform_data mx35_3ds_i2c0_data __initconst = { · line 178

Quoted 4 lines
arch/arm/mach-mx3/mach-mx35_3ds.c +1 -0
@@ -175,6 +175,8 @@ static const struct imxi2c_platform_data mx35_3ds_i2c0_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int z160_revision __initdata;

Why is this named z160?

arch/arm/mach-mx3/mach-mx35_3ds.c static void __init mx35_3ds_init(void) · line 208

Quoted 9 lines
arch/arm/mach-mx3/mach-mx35_3ds.c +2 -0
+
 /*
  * Board specific initialization.
  */
@@ -203,6 +205,7 @@ static void __init mx35_3ds_init(void)
 		pr_warn("Init of the debugboard failed, all "
 				"devices on the debugboard are unusable.\n");
 	imx35_add_imx_i2c0(&mx35_3ds_i2c0_data);
+	imx35_add_mxc_gpu(&z160_revision);

Do you really need to pass this by pointer? Wouldn't imx35_add_mxc_gpu(0) be good enough?

Quoted 200 lines
arch/arm/mach-mx3/mach-mx35_3ds.c +0 -0
 }
 
 static void __init mx35pdk_timer_init(void)
arch/arm/mach-mx5/Kconfig +6 -0
index 159340d..a3873ac 100644
@@ -41,6 +41,7 @@ config MACH_MX51_BABBAGE
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	help
@@ -54,6 +55,7 @@ config MACH_MX51_3DS
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	select MXC_DEBUG_BOARD
@@ -142,6 +144,7 @@ config MACH_MX53_EVK
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_IMX_I2C
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	help
@@ -154,6 +157,7 @@ config MACH_MX53_SMD
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	help
 	  Include support for MX53 SMD platform. This includes specific
 	  configurations for the board and its peripherals.
@@ -164,6 +168,7 @@ config MACH_MX53_LOCO
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_GPIO_KEYS
 	help
@@ -176,6 +181,7 @@ config MACH_MX50_RDP
 	select SOC_IMX50
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	select IMX_HAVE_PLATFORM_FEC
arch/arm/mach-mx5/board-mx50_rdp.c +3 -0
index dedf7f2..90742ce 100644
@@ -188,6 +188,8 @@ static const struct imxi2c_platform_data i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int z160_revision __initdata = 1;
+
 /*
  * Board specific initialization.
  */
@@ -203,6 +205,7 @@ static void __init mx50_rdp_board_init(void)
 	imx50_add_imx_i2c(0, &i2c_data);
 	imx50_add_imx_i2c(1, &i2c_data);
 	imx50_add_imx_i2c(2, &i2c_data);
+	imx50_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx50_rdp_timer_init(void)
arch/arm/mach-mx5/board-mx51_3ds.c +3 -0
index 63dfbea..19b91f8 100644
@@ -130,6 +130,8 @@ static struct spi_board_info mx51_3ds_spi_nor_device[] = {
 	 .platform_data = NULL,},
 };
 
+static int z160_revision __initdata;
+
 /*
  * Board specific initialization.
  */
@@ -153,6 +155,7 @@ static void __init mx51_3ds_init(void)
 	imx51_add_sdhci_esdhc_imx(0, NULL);
 	imx51_add_imx_keypad(&mx51_3ds_map_data);
 	imx51_add_imx2_wdt(0, NULL);
+	imx51_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx51_3ds_timer_init(void)
arch/arm/mach-mx5/board-mx51_babbage.c +3 -0
index bea4e41..4d0c00d 100644
@@ -337,6 +337,8 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = {
 	.num_chipselect = ARRAY_SIZE(mx51_babbage_spi_cs),
 };
 
+static int z160_revision __initdata;
+
 /*
  * Board specific initialization.
  */
@@ -387,6 +389,7 @@ static void __init mx51_babbage_init(void)
 		ARRAY_SIZE(mx51_babbage_spi_board_info));
 	imx51_add_ecspi(0, &mx51_babbage_spi_pdata);
 	imx51_add_imx2_wdt(0, NULL);
+	imx51_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx51_babbage_timer_init(void)
arch/arm/mach-mx5/board-mx53_loco.c +9 -0
index 10a1bea..e689643 100644
@@ -227,6 +227,8 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int z160_revision __initdata;
+
 static void __init mx53_loco_board_init(void)
 {
 	mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
@@ -240,6 +242,13 @@ static void __init mx53_loco_board_init(void)
 	imx53_add_sdhci_esdhc_imx(0, NULL);
 	imx53_add_sdhci_esdhc_imx(2, NULL);
 	imx_add_gpio_keys(&loco_button_data);
+
+	/*GPU*/
+	if (mx53_revision() >= IMX_CHIP_REVISION_2_0)
+		z160_revision = 1;
+	else
+		z160_revision = 0;
+	imx53_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx53_loco_timer_init(void)
arch/arm/mach-mx5/devices-imx50.h +4 -0
index c9e4282..6059b2c 100644
@@ -32,3 +32,7 @@ extern const struct imx_fec_data imx50_fec_data __initconst;
 extern const struct imx_imx_i2c_data imx50_imx_i2c_data[] __initconst;
 #define imx50_add_imx_i2c(id, pdata)	\
 	imx_add_imx_i2c(&imx50_imx_i2c_data[id], pdata)
+
+extern const struct imx_mxc_gpu_data imx50_gpu_data;
+#define imx50_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx50_gpu_data, pdata)
arch/arm/mach-mx5/devices-imx51.h +4 -0
index 7fff485..c32adc2 100644
@@ -55,3 +55,7 @@ extern const struct imx_mxc_pwm_data imx51_mxc_pwm_data[] __initconst;
 extern const struct imx_imx_keypad_data imx51_imx_keypad_data __initconst;
 #define imx51_add_imx_keypad(pdata)	\
 	imx_add_imx_keypad(&imx51_imx_keypad_data, pdata)
+
+extern const struct imx_mxc_gpu_data imx51_gpu_data;
+#define imx51_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx51_gpu_data, pdata)
arch/arm/mach-mx5/devices-imx53.h +4 -0
index 9251008..6472215 100644
@@ -33,3 +33,7 @@ extern const struct imx_spi_imx_data imx53_ecspi_data[] __initconst;
 extern const struct imx_imx2_wdt_data imx53_imx2_wdt_data[] __initconst;
 #define imx53_add_imx2_wdt(id, pdata)	\
 	imx_add_imx2_wdt(&imx53_imx2_wdt_data[id])
+
+extern const struct imx_mxc_gpu_data imx53_gpu_data;
+#define imx53_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx53_gpu_data, pdata)
arch/arm/plat-mxc/devices/Kconfig +3 -0
index b9ab1d5..db1bfad 100644
@@ -50,6 +50,9 @@ config IMX_HAVE_PLATFORM_MX2_CAMERA
 config IMX_HAVE_PLATFORM_MXC_EHCI
 	bool
 
+config IMX_HAVE_PLATFORM_MXC_GPU
+	bool
+
 config IMX_HAVE_PLATFORM_MXC_MMC
 	bool
 
arch/arm/plat-mxc/devices/Makefile +0 -0
index 75cd2ec..c2ce086 100644

arch/arm/plat-mxc/devices/Makefile obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o · line 18

Quoted 4 lines
arch/arm/plat-mxc/devices/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MX1_CAMERA) += platform-mx1-camera.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MX2_CAMERA) += platform-mx2-camera.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_EHCI) += platform-mxc-ehci.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_GPU) +=  platform-mxc_gpu.o

s/ / /

Quoted 14 lines
arch/arm/plat-mxc/devices/Makefile +0 -0
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_MMC) += platform-mxc-mmc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_PWM) += platform-mxc_pwm.o
arch/arm/plat-mxc/devices/platform-mxc_gpu.c new file +5 -0
new file mode 100644
index 0000000..550d4c9
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the

arch/arm/plat-mxc/devices/platform-mxc_gpu.c line 15

Quoted 10 lines
arch/arm/plat-mxc/devices/platform-mxc_gpu.c new file +10 -0
+ * Free Software Foundation.
+ */
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+#define imx_mxc_gpu_entry_3d_2d(soc)					\
+	{								\
+		.irq_3d = soc ## _INT_GPU,				\
+		.irq_2d = soc ## _INT_GPU2_IRQ,				\

INT_GPU2_IRQ is duplicated. What is the name specified by the reference manual? If this is the irq associated to GPU2D_BASE_ADDR I'd prefer INT_GPU2D here.

Quoted 89 lines
arch/arm/plat-mxc/devices/platform-mxc_gpu.c new file +79 -0
+		.iobase_3d = soc ## _GPU_BASE_ADDR,			\
+		.iobase_2d = soc ## _GPU2D_BASE_ADDR,			\
+		.gmem_base = soc ## _GPU_GMEM_BASE_ADDR,		\
+		.gmem_size = soc ## _GPU_GMEM_SIZE,			\
+	}
+
+#define imx_mxc_gpu_entry_2d(soc)					\
+	{								\
+		.irq_2d = soc ## _INT_GPU2_IRQ,				\
+		.iobase_2d = soc ## _GPU2D_BASE_ADDR,			\
+	}
+
+#ifdef CONFIG_SOC_IMX35
+const struct imx_mxc_gpu_data imx35_gpu_data __initconst =
+	imx_mxc_gpu_entry_2d(MX35);
+#endif
+
+#ifdef CONFIG_SOC_IMX50
+const struct imx_mxc_gpu_data imx50_gpu_data __initconst =
+	imx_mxc_gpu_entry_2d(MX50);
+#endif
+
+#ifdef CONFIG_SOC_IMX51
+const struct imx_mxc_gpu_data imx51_gpu_data __initconst =
+	imx_mxc_gpu_entry_3d_2d(MX51);
+#endif
+
+#ifdef CONFIG_SOC_IMX53
+const struct imx_mxc_gpu_data imx53_gpu_data __initconst =
+	imx_mxc_gpu_entry_3d_2d(MX53);
+#endif
+
+struct platform_device *__init imx_add_mxc_gpu(
+		const struct imx_mxc_gpu_data *data,
+		const int *pdata)
+{
+	struct resource res[] = {
+		{
+			.start = data->irq_2d,
+			.end = data->irq_2d,
+			.name = "gpu_2d_irq",
+			.flags = IORESOURCE_IRQ,
+		},
+		{
+			.start = data->irq_3d,
+			.end = data->irq_3d,
+			.name = "gpu_3d_irq",
+			.flags = IORESOURCE_IRQ,
+		},
+		{
+			.start = data->iobase_2d,
+			.end = data->iobase_2d + SZ_4K - 1,
+			.name = "gpu_2d_registers",
+			.flags = IORESOURCE_MEM,
+		},
+		{
+			.start = data->iobase_3d,
+			.end = data->iobase_3d + SZ_128K - 1,
+			.name = "gpu_3d_registers",
+			.flags = IORESOURCE_MEM,
+		},
+		{
+			.start = data->gmem_base,
+			.end = data->gmem_base + data->gmem_size - 1,
+			.name = "gpu_graphics_mem",
+			.flags = IORESOURCE_MEM,
+		},
+		{
+			.start = 0,
+			.end = 0,
+			.name = "gpu_reserved_mem",
+			.flags = IORESOURCE_MEM,
+		},
+	};
+
+	return imx_add_platform_device_dmamask("mxc_gpu", 0,
+			res, ARRAY_SIZE(res),
+			pdata, sizeof(*pdata), DMA_BIT_MASK(32));
+}
arch/arm/plat-mxc/include/mach/devices-common.h +2 -0
index 8658c9c..1c8ed19 100644
@@ -264,3 +264,15 @@ struct imx_spi_imx_data {
 struct platform_device *__init imx_add_spi_imx(
 		const struct imx_spi_imx_data *data,
 		const struct spi_imx_master *pdata);
+
+struct imx_mxc_gpu_data {

arch/arm/plat-mxc/include/mach/devices-common.h struct imx_spi_imx_data { · line 278

Quoted 10 lines
arch/arm/plat-mxc/include/mach/devices-common.h +10 -0
+	resource_size_t irq_2d;
+	resource_size_t irq_3d;
+	resource_size_t iobase_2d;
+	resource_size_t iobase_3d;
+	resource_size_t gmem_base;
+	resource_size_t gmem_size;
+};
+struct platform_device *__init imx_add_mxc_gpu(
+		const struct imx_mxc_gpu_data *data,
+		const int *pdata);

This is added out of order. This file should be in the same order as arch/arm/plat-mxc/devices/Makefile.

Quoted 61 lines
arch/arm/plat-mxc/include/mach/mx35.h +3 -1
index d13dbfe..e2954ab 100644
@@ -7,6 +7,8 @@
 #define MX35_IRAM_BASE_ADDR		0x10000000	/* internal ram */
 #define MX35_IRAM_SIZE			SZ_128K
 
+#define MX35_GPU2D_BASE_ADDR		0x20000000
+
 #define MX35_L2CC_BASE_ADDR		0x30000000
 #define MX35_L2CC_SIZE			SZ_1M
 
@@ -133,7 +135,7 @@
 #define MX35_INT_CSPI2		13
 #define MX35_INT_CSPI1		14
 #define MX35_INT_ATA		15
-#define MX35_INT_GPU2D		16
+#define MX35_INT_GPU2_IRQ	16
 #define MX35_INT_ASRC		17
 #define MX35_INT_UART3		18
 #define MX35_INT_IIM		19
arch/arm/plat-mxc/include/mach/mx51.h +5 -4
index dede19a..cab469a 100644
@@ -14,8 +14,9 @@
 #define MX51_IRAM_PARTITIONS		16
 #define MX51_IRAM_SIZE		(MX51_IRAM_PARTITIONS * SZ_8K)	/* 128KB */
 
-#define MX51_GPU_BASE_ADDR		0x20000000
-#define MX51_GPU_CTRL_BASE_ADDR		0x30000000
+#define MX51_GPU_GMEM_BASE_ADDR		0x20000000
+#define MX51_GPU_GMEM_SIZE		SZ_128K
+#define MX51_GPU_BASE_ADDR		0x30000000
 #define MX51_IPU_CTRL_BASE_ADDR		0x40000000
 
 #define MX51_DEBUG_BASE_ADDR		0x60000000
@@ -253,7 +254,7 @@
 #define MX51_MXC_INT_VPU		9
 #define MX51_INT_IPU_ERR		10
 #define MX51_INT_IPU_SYN		11
-#define MX51_MXC_INT_GPU		12
+#define MX51_INT_GPU			12
 #define MX51_MXC_INT_RESV13		13
 #define MX51_MXC_INT_USB_H1		14
 #define MX51_MXC_INT_EMI		15
@@ -325,7 +326,7 @@
 #define MX51_MXC_INT_MCG_ERR		81
 #define MX51_MXC_INT_MCG_TMR		82
 #define MX51_MXC_INT_MCG_FUNC		83
-#define MX51_MXC_INT_GPU2_IRQ		84
+#define MX51_INT_GPU2_IRQ		84
 #define MX51_MXC_INT_GPU2_BUSY		85
 #define MX51_MXC_INT_RESV86		86
 #define MX51_INT_FEC			87
arch/arm/plat-mxc/include/mach/mx53.h +0 -0
index ace1786..01dd210 100644

arch/arm/plat-mxc/include/mach/mx53.h line 41

Quoted 7 lines
arch/arm/plat-mxc/include/mach/mx53.h +1 -0
@@ -35,6 +35,7 @@
 #define MX53_GPU2D_BASE_ADDR		0x20000000
 #define MX53_GPU_BASE_ADDR		0x30000000
 #define MX53_GPU_GMEM_BASE_ADDR	0xF8020000
+#define MX53_GPU_GMEM_SIZE	SZ_256K
 
 #define MX53_DEBUG_BASE_ADDR		0x40000000
 #define MX53_DEBUG_SIZE		SZ_1M

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Hi Uwe,

Quoted 9 lines · Uwe Kleine-K?nig
Quoted 7 lines · Richard Zhao

From: Richard Zhao <[email protected]>

Add mxc_gpu devices for imx35/50/51/53, so external gpu driver module built for the kernel can work.

---

A changed-since-v1 section would be nice here.

Correct

Quoted 2 lines

I assume the only change
is that __initconst is skipped for the external declaration?

also change the copyright to freescale of file arch/arm/plat-mxc/devices/platform-mxc_gpu.c

Quoted 1 line

Does someone volunteer to remove these for the other declarations?

I can clean it up after finish this patch.

Quoted 54 lines
Quoted 54 lines
 arch/arm/mach-mx3/Kconfig                       |    1 +
 arch/arm/mach-mx3/devices-imx35.h               |    4 +
 arch/arm/mach-mx3/mach-mx35_3ds.c               |    3 +
 arch/arm/mach-mx5/Kconfig                       |    6 ++
 arch/arm/mach-mx5/board-mx50_rdp.c              |    3 +
 arch/arm/mach-mx5/board-mx51_3ds.c              |    3 +
 arch/arm/mach-mx5/board-mx51_babbage.c          |    3 +
 arch/arm/mach-mx5/board-mx53_loco.c             |    9 ++
 arch/arm/mach-mx5/devices-imx50.h               |    4 +
 arch/arm/mach-mx5/devices-imx51.h               |    4 +
 arch/arm/mach-mx5/devices-imx53.h               |    4 +
 arch/arm/plat-mxc/devices/Kconfig               |    3 +
 arch/arm/plat-mxc/devices/Makefile              |    1 +
 arch/arm/plat-mxc/devices/platform-mxc_gpu.c    |   94 +++++++++++++++++++++++
 arch/arm/plat-mxc/include/mach/devices-common.h |   12 +++
 arch/arm/plat-mxc/include/mach/mx35.h           |    4 +-
 arch/arm/plat-mxc/include/mach/mx51.h           |    9 +-
 arch/arm/plat-mxc/include/mach/mx53.h           |    1 +
 18 files changed, 163 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/plat-mxc/devices/platform-mxc_gpu.c
arch/arm/mach-mx3/Kconfig +1 -0
index 340809a..197ba67 100644
@@ -187,6 +187,7 @@ config MACH_MX35_3DS
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_EHCI
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_MXC_NAND
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	help
arch/arm/mach-mx3/devices-imx35.h +4 -0
index d545d86..e6fb746 100644
@@ -74,3 +74,7 @@ extern const struct imx_spi_imx_data imx35_cspi_data[] __initconst;
 	imx_add_spi_imx(&imx35_cspi_data[id], pdata)
 #define imx35_add_spi_imx0(pdata)	imx35_add_cspi(0, pdata)
 #define imx35_add_spi_imx1(pdata)	imx35_add_cspi(1, pdata)
+
+extern const struct imx_mxc_gpu_data imx35_gpu_data;
+#define imx35_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx35_gpu_data, pdata)
arch/arm/mach-mx3/mach-mx35_3ds.c +0 -0
index ff5fe23..1987311 100644
@@ -175,6 +175,8 @@ static const struct imxi2c_platform_data mx35_3ds_i2c0_data __initconst = {
 	.bitrate = 100000,
 };
 
Quoted 2 lines

arch/arm/mach-mx3/mach-mx35_3ds.c static const struct imxi2c_platform_data mx35_3ds_i2c0_data __initconst = { · line 178

Quoted 1 line
arch/arm/mach-mx3/mach-mx35_3ds.c +1 -0
+static int z160_revision __initdata;

Why is this named z160?

z160 is the 2d GPU IP name.

Quoted 12 lines

arch/arm/mach-mx3/mach-mx35_3ds.c static void __init mx35_3ds_init(void) · line 208

Quoted 10 lines
arch/arm/mach-mx3/mach-mx35_3ds.c +2 -0
+
 /*
  * Board specific initialization.
  */
@@ -203,6 +205,7 @@ static void __init mx35_3ds_init(void)
 		pr_warn("Init of the debugboard failed, all "
 				"devices on the debugboard are unusable.\n");
 	imx35_add_imx_i2c0(&mx35_3ds_i2c0_data);
+	imx35_add_mxc_gpu(&z160_revision);

Do you really need to pass this by pointer? Wouldn't imx35_add_mxc_gpu(0) be good enough?

It's because sometimes z160_revision has different values with different TO versions and z160_revision will be dup as plat data.

Quoted 196 lines
Quoted 196 lines
arch/arm/mach-mx3/mach-mx35_3ds.c +0 -0
 }
 
 static void __init mx35pdk_timer_init(void)
arch/arm/mach-mx5/Kconfig +6 -0
index 159340d..a3873ac 100644
@@ -41,6 +41,7 @@ config MACH_MX51_BABBAGE
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	help
@@ -54,6 +55,7 @@ config MACH_MX51_3DS
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	select MXC_DEBUG_BOARD
@@ -142,6 +144,7 @@ config MACH_MX53_EVK
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_IMX_I2C
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	help
@@ -154,6 +157,7 @@ config MACH_MX53_SMD
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	help
 	  Include support for MX53 SMD platform. This includes specific
 	  configurations for the board and its peripherals.
@@ -164,6 +168,7 @@ config MACH_MX53_LOCO
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_GPIO_KEYS
 	help
@@ -176,6 +181,7 @@ config MACH_MX50_RDP
 	select SOC_IMX50
 	select IMX_HAVE_PLATFORM_IMX_I2C
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_GPU
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
 	select IMX_HAVE_PLATFORM_SPI_IMX
 	select IMX_HAVE_PLATFORM_FEC
arch/arm/mach-mx5/board-mx50_rdp.c +3 -0
index dedf7f2..90742ce 100644
@@ -188,6 +188,8 @@ static const struct imxi2c_platform_data i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int z160_revision __initdata = 1;
+
 /*
  * Board specific initialization.
  */
@@ -203,6 +205,7 @@ static void __init mx50_rdp_board_init(void)
 	imx50_add_imx_i2c(0, &i2c_data);
 	imx50_add_imx_i2c(1, &i2c_data);
 	imx50_add_imx_i2c(2, &i2c_data);
+	imx50_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx50_rdp_timer_init(void)
arch/arm/mach-mx5/board-mx51_3ds.c +3 -0
index 63dfbea..19b91f8 100644
@@ -130,6 +130,8 @@ static struct spi_board_info mx51_3ds_spi_nor_device[] = {
 	 .platform_data = NULL,},
 };
 
+static int z160_revision __initdata;
+
 /*
  * Board specific initialization.
  */
@@ -153,6 +155,7 @@ static void __init mx51_3ds_init(void)
 	imx51_add_sdhci_esdhc_imx(0, NULL);
 	imx51_add_imx_keypad(&mx51_3ds_map_data);
 	imx51_add_imx2_wdt(0, NULL);
+	imx51_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx51_3ds_timer_init(void)
arch/arm/mach-mx5/board-mx51_babbage.c +3 -0
index bea4e41..4d0c00d 100644
@@ -337,6 +337,8 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = {
 	.num_chipselect = ARRAY_SIZE(mx51_babbage_spi_cs),
 };
 
+static int z160_revision __initdata;
+
 /*
  * Board specific initialization.
  */
@@ -387,6 +389,7 @@ static void __init mx51_babbage_init(void)
 		ARRAY_SIZE(mx51_babbage_spi_board_info));
 	imx51_add_ecspi(0, &mx51_babbage_spi_pdata);
 	imx51_add_imx2_wdt(0, NULL);
+	imx51_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx51_babbage_timer_init(void)
arch/arm/mach-mx5/board-mx53_loco.c +9 -0
index 10a1bea..e689643 100644
@@ -227,6 +227,8 @@ static const struct imxi2c_platform_data mx53_loco_i2c_data __initconst = {
 	.bitrate = 100000,
 };
 
+static int z160_revision __initdata;
+
 static void __init mx53_loco_board_init(void)
 {
 	mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads,
@@ -240,6 +242,13 @@ static void __init mx53_loco_board_init(void)
 	imx53_add_sdhci_esdhc_imx(0, NULL);
 	imx53_add_sdhci_esdhc_imx(2, NULL);
 	imx_add_gpio_keys(&loco_button_data);
+
+	/*GPU*/
+	if (mx53_revision() >= IMX_CHIP_REVISION_2_0)
+		z160_revision = 1;
+	else
+		z160_revision = 0;
+	imx53_add_mxc_gpu(&z160_revision);
 }
 
 static void __init mx53_loco_timer_init(void)
arch/arm/mach-mx5/devices-imx50.h +4 -0
index c9e4282..6059b2c 100644
@@ -32,3 +32,7 @@ extern const struct imx_fec_data imx50_fec_data __initconst;
 extern const struct imx_imx_i2c_data imx50_imx_i2c_data[] __initconst;
 #define imx50_add_imx_i2c(id, pdata)	\
 	imx_add_imx_i2c(&imx50_imx_i2c_data[id], pdata)
+
+extern const struct imx_mxc_gpu_data imx50_gpu_data;
+#define imx50_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx50_gpu_data, pdata)
arch/arm/mach-mx5/devices-imx51.h +4 -0
index 7fff485..c32adc2 100644
@@ -55,3 +55,7 @@ extern const struct imx_mxc_pwm_data imx51_mxc_pwm_data[] __initconst;
 extern const struct imx_imx_keypad_data imx51_imx_keypad_data __initconst;
 #define imx51_add_imx_keypad(pdata)	\
 	imx_add_imx_keypad(&imx51_imx_keypad_data, pdata)
+
+extern const struct imx_mxc_gpu_data imx51_gpu_data;
+#define imx51_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx51_gpu_data, pdata)
arch/arm/mach-mx5/devices-imx53.h +4 -0
index 9251008..6472215 100644
@@ -33,3 +33,7 @@ extern const struct imx_spi_imx_data imx53_ecspi_data[] __initconst;
 extern const struct imx_imx2_wdt_data imx53_imx2_wdt_data[] __initconst;
 #define imx53_add_imx2_wdt(id, pdata)	\
 	imx_add_imx2_wdt(&imx53_imx2_wdt_data[id])
+
+extern const struct imx_mxc_gpu_data imx53_gpu_data;
+#define imx53_add_mxc_gpu(pdata) \
+	imx_add_mxc_gpu(&imx53_gpu_data, pdata)
arch/arm/plat-mxc/devices/Kconfig +3 -0
index b9ab1d5..db1bfad 100644
@@ -50,6 +50,9 @@ config IMX_HAVE_PLATFORM_MX2_CAMERA
 config IMX_HAVE_PLATFORM_MXC_EHCI
 	bool
 
+config IMX_HAVE_PLATFORM_MXC_GPU
+	bool
+
 config IMX_HAVE_PLATFORM_MXC_MMC
 	bool
 
Quoted 10 lines

arch/arm/plat-mxc/devices/Makefile obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o · line 18

Quoted 9 lines
arch/arm/plat-mxc/devices/Makefile +1 -0
index 75cd2ec..c2ce086 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MX1_CAMERA) += platform-mx1-camera.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MX2_CAMERA) += platform-mx2-camera.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_EHCI) += platform-mxc-ehci.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_GPU) +=  platform-mxc_gpu.o

s/ / /

nice catch.

Quoted 20 lines
Quoted 20 lines
arch/arm/plat-mxc/devices/Makefile +0 -0
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_MMC) += platform-mxc-mmc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_PWM) += platform-mxc_pwm.o
arch/arm/plat-mxc/devices/platform-mxc_gpu.c new file +10 -0
new file mode 100644
index 0000000..550d4c9
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <asm/sizes.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
Quoted 8 lines

arch/arm/plat-mxc/devices/platform-mxc_gpu.c line 15

Quoted 5 lines
arch/arm/plat-mxc/devices/platform-mxc_gpu.c new file +5 -0
+
+#define imx_mxc_gpu_entry_3d_2d(soc)					\
+	{								\
+		.irq_3d = soc ## _INT_GPU,				\
+		.irq_2d = soc ## _INT_GPU2_IRQ,				\

INT_GPU2_IRQ is duplicated. What is the name specified by the reference manual? If this is the irq associated to GPU2D_BASE_ADDR I'd prefer INT_GPU2D here.

It's for distinguish between _INT_GPU2_BUSY and _INT_GPU2_IRQ. for example:
MX53_INT_GPU2_IRQ 84
MX53_INT_GPU2_BUSY 85

Quoted 94 lines
Quoted 94 lines
arch/arm/plat-mxc/devices/platform-mxc_gpu.c new file +79 -0
+		.iobase_3d = soc ## _GPU_BASE_ADDR,			\
+		.iobase_2d = soc ## _GPU2D_BASE_ADDR,			\
+		.gmem_base = soc ## _GPU_GMEM_BASE_ADDR,		\
+		.gmem_size = soc ## _GPU_GMEM_SIZE,			\
+	}
+
+#define imx_mxc_gpu_entry_2d(soc)					\
+	{								\
+		.irq_2d = soc ## _INT_GPU2_IRQ,				\
+		.iobase_2d = soc ## _GPU2D_BASE_ADDR,			\
+	}
+
+#ifdef CONFIG_SOC_IMX35
+const struct imx_mxc_gpu_data imx35_gpu_data __initconst =
+	imx_mxc_gpu_entry_2d(MX35);
+#endif
+
+#ifdef CONFIG_SOC_IMX50
+const struct imx_mxc_gpu_data imx50_gpu_data __initconst =
+	imx_mxc_gpu_entry_2d(MX50);
+#endif
+
+#ifdef CONFIG_SOC_IMX51
+const struct imx_mxc_gpu_data imx51_gpu_data __initconst =
+	imx_mxc_gpu_entry_3d_2d(MX51);
+#endif
+
+#ifdef CONFIG_SOC_IMX53
+const struct imx_mxc_gpu_data imx53_gpu_data __initconst =
+	imx_mxc_gpu_entry_3d_2d(MX53);
+#endif
+
+struct platform_device *__init imx_add_mxc_gpu(
+		const struct imx_mxc_gpu_data *data,
+		const int *pdata)
+{
+	struct resource res[] = {
+		{
+			.start = data->irq_2d,
+			.end = data->irq_2d,
+			.name = "gpu_2d_irq",
+			.flags = IORESOURCE_IRQ,
+		},
+		{
+			.start = data->irq_3d,
+			.end = data->irq_3d,
+			.name = "gpu_3d_irq",
+			.flags = IORESOURCE_IRQ,
+		},
+		{
+			.start = data->iobase_2d,
+			.end = data->iobase_2d + SZ_4K - 1,
+			.name = "gpu_2d_registers",
+			.flags = IORESOURCE_MEM,
+		},
+		{
+			.start = data->iobase_3d,
+			.end = data->iobase_3d + SZ_128K - 1,
+			.name = "gpu_3d_registers",
+			.flags = IORESOURCE_MEM,
+		},
+		{
+			.start = data->gmem_base,
+			.end = data->gmem_base + data->gmem_size - 1,
+			.name = "gpu_graphics_mem",
+			.flags = IORESOURCE_MEM,
+		},
+		{
+			.start = 0,
+			.end = 0,
+			.name = "gpu_reserved_mem",
+			.flags = IORESOURCE_MEM,
+		},
+	};
+
+	return imx_add_platform_device_dmamask("mxc_gpu", 0,
+			res, ARRAY_SIZE(res),
+			pdata, sizeof(*pdata), DMA_BIT_MASK(32));
+}
arch/arm/plat-mxc/include/mach/devices-common.h +6 -0
index 8658c9c..1c8ed19 100644
@@ -264,3 +264,15 @@ struct imx_spi_imx_data {
 struct platform_device *__init imx_add_spi_imx(
 		const struct imx_spi_imx_data *data,
 		const struct spi_imx_master *pdata);
+
+struct imx_mxc_gpu_data {
+	resource_size_t irq_2d;
+	resource_size_t irq_3d;
+	resource_size_t iobase_2d;
+	resource_size_t iobase_3d;
Quoted 8 lines

arch/arm/plat-mxc/include/mach/devices-common.h struct imx_spi_imx_data { · line 278

Quoted 6 lines
arch/arm/plat-mxc/include/mach/devices-common.h +6 -0
+	resource_size_t gmem_base;
+	resource_size_t gmem_size;
+};
+struct platform_device *__init imx_add_mxc_gpu(
+		const struct imx_mxc_gpu_data *data,
+		const int *pdata);

This is added out of order. This file should be in the same order as arch/arm/plat-mxc/devices/Makefile.

ok

Quoted 67 lines
Quoted 67 lines
arch/arm/plat-mxc/include/mach/mx35.h +3 -1
index d13dbfe..e2954ab 100644
@@ -7,6 +7,8 @@
 #define MX35_IRAM_BASE_ADDR		0x10000000	/* internal ram */
 #define MX35_IRAM_SIZE			SZ_128K
 
+#define MX35_GPU2D_BASE_ADDR		0x20000000
+
 #define MX35_L2CC_BASE_ADDR		0x30000000
 #define MX35_L2CC_SIZE			SZ_1M
 
@@ -133,7 +135,7 @@
 #define MX35_INT_CSPI2		13
 #define MX35_INT_CSPI1		14
 #define MX35_INT_ATA		15
-#define MX35_INT_GPU2D		16
+#define MX35_INT_GPU2_IRQ	16
 #define MX35_INT_ASRC		17
 #define MX35_INT_UART3		18
 #define MX35_INT_IIM		19
arch/arm/plat-mxc/include/mach/mx51.h +5 -4
index dede19a..cab469a 100644
@@ -14,8 +14,9 @@
 #define MX51_IRAM_PARTITIONS		16
 #define MX51_IRAM_SIZE		(MX51_IRAM_PARTITIONS * SZ_8K)	/* 128KB */
 
-#define MX51_GPU_BASE_ADDR		0x20000000
-#define MX51_GPU_CTRL_BASE_ADDR		0x30000000
+#define MX51_GPU_GMEM_BASE_ADDR		0x20000000
+#define MX51_GPU_GMEM_SIZE		SZ_128K
+#define MX51_GPU_BASE_ADDR		0x30000000
 #define MX51_IPU_CTRL_BASE_ADDR		0x40000000
 
 #define MX51_DEBUG_BASE_ADDR		0x60000000
@@ -253,7 +254,7 @@
 #define MX51_MXC_INT_VPU		9
 #define MX51_INT_IPU_ERR		10
 #define MX51_INT_IPU_SYN		11
-#define MX51_MXC_INT_GPU		12
+#define MX51_INT_GPU			12
 #define MX51_MXC_INT_RESV13		13
 #define MX51_MXC_INT_USB_H1		14
 #define MX51_MXC_INT_EMI		15
@@ -325,7 +326,7 @@
 #define MX51_MXC_INT_MCG_ERR		81
 #define MX51_MXC_INT_MCG_TMR		82
 #define MX51_MXC_INT_MCG_FUNC		83
-#define MX51_MXC_INT_GPU2_IRQ		84
+#define MX51_INT_GPU2_IRQ		84
 #define MX51_MXC_INT_GPU2_BUSY		85
 #define MX51_MXC_INT_RESV86		86
 #define MX51_INT_FEC			87
arch/arm/plat-mxc/include/mach/mx53.h +1 -0
index ace1786..01dd210 100644
@@ -35,6 +35,7 @@
 #define MX53_GPU2D_BASE_ADDR		0x20000000
 #define MX53_GPU_BASE_ADDR		0x30000000
 #define MX53_GPU_GMEM_BASE_ADDR	0xF8020000
+#define MX53_GPU_GMEM_SIZE	SZ_256K
 
Quoted 5 lines

arch/arm/plat-mxc/include/mach/mx53.h line 41

Quoted 2 lines
arch/arm/plat-mxc/include/mach/mx53.h +0 -0
 #define MX53_DEBUG_BASE_ADDR		0x40000000
 #define MX53_DEBUG_SIZE		SZ_1M

Thanks
Uwe

Thanks
Richard

Quoted 5 lines
Signature · 3 lines
-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#3 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
(quoted diff) +0 -0
@@ -203,6 +205,7 @@ static void __init mx35_3ds_init(void)

? ? ? ? ? ? pr_warn("Init of the debugboard failed, all "
? ? ? ? ? ? ? ? ? ? ? ? ? ? "devices on the debugboard are unusable.\n"); ? ? imx35_add_imx_i2c0(&mx35_3ds_i2c0_data);
+ ? imx35_add_mxc_gpu(&z160_revision);

Do you really need to pass this by pointer? Wouldn't imx35_add_mxc_gpu(0) be good enough?

It's because sometimes z160_revision has different values with different TO versions and z160_revision will be dup as plat data.

This is where platform_device_id comes into play, at least by registering device with different names, e.g. 'imx35-gpu' or 'imx51-gpu', and the driver can handle.

Difference between steppings is a bit tricky though, I think a QUIRK_ way, and pass combined QUIRK_* flags will be better in imx35_add_mxc_gpu() function itself.

#4 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Hello,

Quoted 9 lines · Eric Miao
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
(quoted diff) +0 -0
@@ -203,6 +205,7 @@ static void __init mx35_3ds_init(void)

? ? ? ? ? ? pr_warn("Init of the debugboard failed, all "
? ? ? ? ? ? ? ? ? ? ? ? ? ? "devices on the debugboard are unusable.\n"); ? ? imx35_add_imx_i2c0(&mx35_3ds_i2c0_data);
+ ? imx35_add_mxc_gpu(&z160_revision);

Do you really need to pass this by pointer? Wouldn't imx35_add_mxc_gpu(0) be good enough?

It's because sometimes z160_revision has different values with different TO versions and z160_revision will be dup as plat data.

Yeah, I got that. I just meant how imx_add_mxc_gpu works. Just let it take a int (instead of an int *) and pass the address of the local parameter to imx_add_platform_device_dmamask.

Quoted 7 lines

This is where platform_device_id comes into play, at least by registering device with different names, e.g. 'imx35-gpu' or 'imx51-gpu', and the driver can handle.

Difference between steppings is a bit tricky though, I think a QUIRK_ way, and pass combined QUIRK_* flags will be better in imx35_add_mxc_gpu() function itself.

... or that

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#5 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Quoted 4 lines
Quoted 3 lines

Difference between steppings is a bit tricky though, I think a QUIRK_ way, and pass combined QUIRK_* flags will be better in imx35_add_mxc_gpu() function itself.

... or that

No driver, no problem?

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110330/640ba646/attachment-0001.sig>
maintainer
#6 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

In reply to Richard Zhao
Quoted 4 lines · Richard Zhao

From: Richard Zhao <[email protected]>

Add mxc_gpu devices for imx35/50/51/53, so external gpu driver module built for the kernel can work.

Why do we need this? I have never seen a driver for this.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#7 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Sascha Hauer <[email protected]> writes:

Hi,

Quoted 8 lines · Richard Zhao
Quoted 4 lines

From: Richard Zhao <[email protected]>

Add mxc_gpu devices for imx35/50/51/53, so external gpu driver module built for the kernel can work.

Why do we need this? I have never seen a driver for this.

#8 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Quoted 10 lines · Arnaud Patard

Sascha Hauer <[email protected]> writes:

Hi,

Quoted 6 lines · Richard Zhao
Quoted 4 lines

From: Richard Zhao <[email protected]>

Add mxc_gpu devices for imx35/50/51/53, so external gpu driver module built for the kernel can work.

Quoted 8 lines
Quoted 2 lines

Why do we need this? I have never seen a driver for this.

From the subject, I guess it's a patch to declare the device used by the driver for the AMD z160 gpu found on theses imx SoCs. iirc, this driver by itself is GPL but relies on closed-source userspace stuff, that's imho why you didn't see a driver for it. I think you can find it in fsl tree inside drivers/mxc/ directory.

Correct. It's for z430/z160 GPU. The kernel part of the driver is in drivers/mxc/amd-gpu/ of freescale kernel source. It can be built as external kernel module. We don't have plan to upstream it yet.

Thanks
Richard

Quoted 3 lines

Arnaud

maintainer
#9 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

In reply to Arnaud Patard (Rtp)
Quoted 10 lines · Arnaud Patard

Sascha Hauer <[email protected]> writes:

Hi,

Quoted 6 lines · Richard Zhao
Quoted 4 lines

From: Richard Zhao <[email protected]>

Add mxc_gpu devices for imx35/50/51/53, so external gpu driver module built for the kernel can work.

Quoted 8 lines
Quoted 2 lines

Why do we need this? I have never seen a driver for this.

From the subject, I guess it's a patch to declare the device used by the driver for the AMD z160 gpu found on theses imx SoCs. iirc, this driver by itself is GPL but relies on closed-source userspace stuff, that's imho why you didn't see a driver for it. I think you can find it in fsl tree inside drivers/mxc/ directory.

I should have been more specific. My open-source eyes have never seen a driver for this. That's why we shouldn't add support code for this into mainline.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#10 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

In reply to Sascha Hauer

Sascha,

Freescale has a driver. We have a driver since we're under NDA and have the source.

If you want it and want to boot Ubuntu on a Smartbook or Smarttop, we can give you a package that will run on our kernel and load the GPU module if present (we actually ship it as a module built inside the kernel, it's not external and it's dual BSD/GPL licensed). Regardless of where you've not seen it, it does exist. I want this code in there
- on the basis that we have a consumer product that ships and needs it, and this is going to be a dependency for OpenGL, OpenVG, and things on top like Flash which may depend on that.

I dunno if I am in the "path" for this since I have the source code for the driver for the kernel (it's on opensource.freescale.com/git in drivers/mxc/amd-gpu somewhere after the 09.12 BSP ) and for the userspace (it's NDA code) I don't believe there's any hard and fast policy that says the kernel cannot have drivers referenced that are not part of the mainline stack, otherwise no external module using USB or any other pluggable module built externally, which Linus does not disapprove of, would never be allowed to build against the kernel.

What's the harm in allowing a reference for a reserved memory space or IRQ for an SoC module to be instantiated in the kernel? Without reserving the memory space, you can't set up the GPU in any fashion since it in all technically needs to be configured to only be able to talk to this reserved resource to allocate texture memory. You kind of want it to be set up right. The setup is an opensource driver that only didn't get into mainline because the DRM guys (wrongly) expect that any kernel source code linked via ioctl or syscall to userspace makes the userspace a derivative work, and didn't want to go there (Linus has specifically stated very recently this is completely false).

.. so Richard can pick one of these as I heartily approve of this being in there if it goes in.

Of course the real solution is make the driver for the IPU, GPU etc. into a DRM/GEM intead of weird-framebuffer-and-crazy-resource-allocation, but that wouldn't fix the DRM guys whining.

In any case, this is a nice patch, it will help actually us in adding it to a fork of the mainline tree for customers. I don't think it goes far enough though: Richard, why no gpu_resource so GSL can allocate memory, and why not setup the Z430 while you're at it? And the sole nitpick, Uwe noticed that the argument passed as an "soc id" to the imx_mxc_gpu_entry_3d_2d "function".

I have a serious problem with the way the "new" "imx_add_this_and_that" platform devices are done. Why is there so much done in little helper functions and defines?

The "old" way where you had a static definition for one chip, then overwrote the data if cpu_is_mx53() was true, was better and more flexible and doesn't need these hacks. The platform definitions don't change, and if you're going to create a define for it, why not a REAL function that can set up the data instead of it taking an argument? Are we really considering that in the case of initializing the board, inlining it by using #define this_helper_function is far more useful than bool this_helper_function(args) (or void this_helper_function(void))? That somehow doing it in an undebuggable optimized chain of garbage you have to pick apart inside a disassembler, is more fun than just following function calls and having a *real useful* backtrace on an oops instead of "mx51_efikamx_init()" and an offset?

Signature · 2 lines
Matt Sealey <[email protected]>
Product Development Analyst, Genesi USA, Inc.
Quoted 21 lines · Sascha Hauer
Quoted 4 lines · Richard Zhao

From: Richard Zhao <[email protected]>

Add mxc_gpu devices for imx35/50/51/53, so external gpu driver module built for the kernel can work.

Why do we need this? I have never seen a driver for this.

Sascha

--

Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 ? ?|
Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? | Fax: ? +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#11 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Quoted 14 lines · Matt Sealey

Sascha,

Freescale has a driver. We have a driver since we're under NDA and have the source.

If you want it and want to boot Ubuntu on a Smartbook or Smarttop, we can give you a package that will run on our kernel and load the GPU module if present (we actually ship it as a module built inside the kernel, it's not external and it's dual BSD/GPL licensed). Regardless of where you've not seen it, it does exist. I want this code in there
- on the basis that we have a consumer product that ships and needs it, and this is going to be a dependency for OpenGL, OpenVG, and things on top like Flash which may depend on that.

Quoted 8 lines

I dunno if I am in the "path" for this since I have the source code for the driver for the kernel (it's on opensource.freescale.com/git in drivers/mxc/amd-gpu somewhere after the 09.12 BSP ) and for the userspace (it's NDA code) I don't believe there's any hard and fast policy that says the kernel cannot have drivers referenced that are not part of the mainline stack, otherwise no external module using USB or any other pluggable module built externally, which Linus does not disapprove of, would never be allowed to build against the kernel.

yeah, and gpu driver do need the patch to work.

Quoted 13 lines

What's the harm in allowing a reference for a reserved memory space or IRQ for an SoC module to be instantiated in the kernel? Without reserving the memory space, you can't set up the GPU in any fashion since it in all technically needs to be configured to only be able to talk to this reserved resource to allocate texture memory. You kind of want it to be set up right. The setup is an opensource driver that only didn't get into mainline because the DRM guys (wrongly) expect that any kernel source code linked via ioctl or syscall to userspace makes the userspace a derivative work, and didn't want to go there (Linus has specifically stated very recently this is completely false).

Quoted 2 lines

.. so Richard can pick one of these as I heartily approve of this being in there if it goes in.

ok

Quoted 9 lines

Of course the real solution is make the driver for the IPU, GPU etc. into a DRM/GEM intead of weird-framebuffer-and-crazy-resource-allocation, but that wouldn't fix the DRM guys whining.

Quoted 4 lines

In any case, this is a nice patch, it will help actually us in adding it to a fork of the mainline tree for customers. I don't think it goes far enough though: Richard, why no gpu_resource so GSL can allocate memory,

Do you mean the resource gpu_reserved_mem? By default, if gpu_reserved_mem is zero, gpu driver will use dma_alloc_xx to alloc max 16M memory. I have not work out a good way to upstream the reserve memory code yet.

Quoted 1 line

and why not setup the Z430 while you're at it?

z430 does not need any other setup.

Quoted 7 lines

And the sole
nitpick, Uwe noticed that the argument passed as an "soc id" to the imx_mxc_gpu_entry_3d_2d "function".

I have a serious problem with the way the "new" "imx_add_this_and_that" platform devices are done. Why is there so much done in little helper functions and defines?

It's a way to make device create dynamic.

Quoted 18 lines

The "old" way where you had a static definition for one chip, then overwrote the data if cpu_is_mx53() was true, was better and more flexible and doesn't need these hacks. The platform definitions don't change, and if you're going to create a define for it, why not a REAL function that can set up the data instead of it taking an argument? Are we really considering that in the case of initializing the board, inlining it by using #define this_helper_function is far more useful than bool this_helper_function(args) (or void this_helper_function(void))? That somehow doing it in an undebuggable optimized chain of garbage you have to pick apart inside a disassembler, is more fun than just following function calls and having a *real useful* backtrace on an oops instead of "mx51_efikamx_init()" and an offset?

Signature · 2 lines
Matt Sealey <[email protected]>
Product Development Analyst, Genesi USA, Inc.

Thanks
Richard

Quoted 26 lines · Sascha Hauer
Quoted 21 lines · Richard Zhao
Quoted 4 lines

From: Richard Zhao <[email protected]>

Add mxc_gpu devices for imx35/50/51/53, so external gpu driver module built for the kernel can work.

Why do we need this? I have never seen a driver for this.

Sascha

--

Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 ? ?|
Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? | Fax: ? +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#12 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Quoted 6 lines · Richard Zhao
Quoted 5 lines · Matt Sealey

Sascha,

Freescale has a driver. We have a driver since we're under NDA and have the source.

Quoted 8 lines
Quoted 4 lines

In any case, this is a nice patch, it will help actually us in adding it to a fork of the mainline tree for customers. I don't think it goes far enough though: Richard, why no gpu_resource so GSL can allocate memory,

Do you mean the resource gpu_reserved_mem? By default, if gpu_reserved_mem is zero, gpu driver will use dma_alloc_xx to alloc max 16M memory. I have not work out a good way to upstream the reserve memory code yet.

Yeah sorry I did mean like mxc_adjust_mem or whatever it was called in the BSP, that tweaked the value. The code I see in that is fine, and we have an in-house DRM/GEM mapper for a the GPU resource.

As long as the size is set, we don't need start/end except to align it to the GPU MMU boundary which means making sure the address is aligned to.. 32MB windows? I think that was all that was complicated about it. It can be any size.

The reason we fiddled with DRM/GEM is because in the BSP, it allocated 32MB for IPU and 32-64MB for the GPU, but it wasn't effectively sharing the memory between devices (and they are kind of one and the same fundamental unit - GPU is useless without IPU, and it makes no sense to allocate the framebuffer in a place the GPU can be protected from accessing..)

I think that's the problem you'd have to try and solve, right?

Quoted 2 lines
Quoted 1 line

and why not setup the Z430 while you're at it?

z430 does not need any other setup.

Okay, but the GPU memory was conceptually shared here so I might nitpick about the naming: on the BSP it was called gpu2d/gpu3d or just gpu_whatever. This makes more sense.. since it is shared between the GPUs (texture memory and Xorg offscreen for our Xorg C2D driver) and potentially the IPU (framebuffer, Xorg offscreen for FSL's libz160 driver) for all we know we get to some not-yet-planned MX54 which has a Z180 in it (unlikely but who knows :) and then the naming convention is wrong too..

Quoted 4 lines
Quoted 3 lines

I have a serious problem with the way the "new" "imx_add_this_and_that" platform devices are done. Why is there so much done in little helper functions and defines?

It's a way to make device create dynamic.

How was mx53_loco_init_device or mxc_init_device as a *function* less dynamic?

I think the only possible problem is that stuff ends up in an undesirable ELF section in the kernel (.bss instead of .text) and static data hangs around if it's not properly set as __initdata (which 99.9% of this is).

Have you checked our Linux BSP modification? We split subsystem init into seperate functions, IOMUX are done in individual files for individual peripherals. (actually in all technically this should be done as absolutely soon after boot - in the firmware - as possible, but we never got round to it and RMK hates trusting the bootloader so we didn't think it'd mainline to never configure IOMUX peripherals). This was before there was mainline support for MX51 hit in 2.6.35. It works, We get all our RAM for static data back after init, the devices are easier to configure per-board where there are differences, and the MX and SB devices (and any MX51 board, Babbage is barely different) is absolutely common ground.

I admire moving "mxc.h" from the BSPs into seperate per-device files, but then having a single-file board data (board-$name.h with $name.c) defeats the modularization concept at the start - because it is "like every other ARM platform", I think the reasoning was..

BTW while we're talking about this, has anyone solved the problem where make headers_install doesn't populate include/asm-arm/mach properly - plat-mxc and mach-mx5 go together (as does every other mach-mx? cpu directory) but plat-mxc/include/mach stuff is never coped in. This is I think a fundamental kernel flaw, and I think RMK said it may be a distribution foible they should be fixing.. I dunno what the solution is here, but it makes building external modules a complete pain in the backside as you need to extract full Linux source and make prepare before you can build a module. On a system with an 8GB SSD or a development board with only a MicroSD card to boot from it's a bit of a chore to do that.. this is why distributions even on x86 ship linux-headers and use that for dkms etc. rather than linux-source.

Until that's solved the AMD GPU source may as well be built seperately and at least Genesi will just maintain an external patch to enable it (hooray for kernel forks, boo for not upstreaming).

Signature · 2 lines
Matt Sealey <[email protected]>
Product Development Analyst, Genesi USA, Inc.
maintainer
#13 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

In reply to Matt Sealey
Quoted 14 lines · Matt Sealey

Sascha,

Freescale has a driver. We have a driver since we're under NDA and have the source.

If you want it and want to boot Ubuntu on a Smartbook or Smarttop, we can give you a package that will run on our kernel and load the GPU module if present (we actually ship it as a module built inside the kernel, it's not external and it's dual BSD/GPL licensed). Regardless of where you've not seen it, it does exist. I want this code in there
- on the basis that we have a consumer product that ships and needs it, and this is going to be a dependency for OpenGL, OpenVG, and things on top like Flash which may depend on that.

Quoted 8 lines

I dunno if I am in the "path" for this since I have the source code for the driver for the kernel (it's on opensource.freescale.com/git in drivers/mxc/amd-gpu somewhere after the 09.12 BSP ) and for the userspace (it's NDA code) I don't believe there's any hard and fast policy that says the kernel cannot have drivers referenced that are not part of the mainline stack, otherwise no external module using USB or any other pluggable module built externally, which Linus does not disapprove of, would never be allowed to build against the kernel.

With USB there is a clear API defined and exported from the kernel to userspace. This API can be used from source and yes, also from closed source drivers.
The FSL gpu driver is different, its API has been defined for only one closed source driver. There is no way of making use of it without closed source. There is no way for kernel maintainers to test this API without closed source. There is also no way to ever change this API without having the source available.
No, there is no place for this kind of stub drivers in the kernel. Otherwise we would also have nvidia binary driver stubs.

In any way we can delay this until there is some code using it.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#14 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

We have a plan to port it to DRM, We even started for it. But it needs to work first, so we can get our reference on. Ports like this are best done slowly - you make it work, you do it piece by piece. We already did the GEM allocation and unified IPU and GPU memory allocation (after all framebuffer memory *is* texture memory on every other graphics card and the IPU/VPU/GPU need to be able to access each other's memory - they all share an EMI/AXI arbiter anyway). That in itself allows us to lock down the GPU using the AMD MMU which defines a 32MB-aligned window which the GPU can write into (otherwise the GPU can touch system memory). Then we just need to do the command stream stuff and properly port the IPU framebuffer to DRM Connectors and Encoders, so XRandR will magically work, we can stop using fbdevhw evil, and so on.

Since this code is all GPL anyway, there is no contention here.

Of course, what you get out of that is an awesome opensource DRM driver with no userspace at all...

And we'd provide a closed source one, but leave it open for anyone to reverse engineer it: not our problem, after all. We can't do it ourselves though, we are under NDA, and the team of lawyers required to coordinate Qualcomm, AMD, Freescale and whatever other vestiges (nVidia owns one of the companies which contributed to the reference implementation used) is probably going to have to be larger than the development base of Linux kernel itself with all it's subsystems and take 5 years to complete.

What it is, is simply not worth arguing about; all this is going to do is allocate memory for the GPU, so other users (and our porting effort) get easier. We'll add a "user" of the API later. Maybe a simple 2D command stream thing. We gotta get this in first though, I'd rather not delay as it means simply that: a delay.

Signature · 2 lines
Matt Sealey <[email protected]>
Product Development Analyst, Genesi USA, Inc.
Quoted 51 lines · Sascha Hauer
Quoted 14 lines · Matt Sealey

Sascha,

Freescale has a driver. We have a driver since we're under NDA and have the source.

If you want it and want to boot Ubuntu on a Smartbook or Smarttop, we can give you a package that will run on our kernel and load the GPU module if present (we actually ship it as a module built inside the kernel, it's not external and it's dual BSD/GPL licensed). Regardless of where you've not seen it, it does exist. I want this code in there
- on the basis that we have a consumer product that ships and needs it, and this is going to be a dependency for OpenGL, OpenVG, and things on top like Flash which may depend on that.

Quoted 8 lines

I dunno if I am in the "path" for this since I have the source code for the driver for the kernel (it's on opensource.freescale.com/git in drivers/mxc/amd-gpu somewhere after the 09.12 BSP ) and for the userspace (it's NDA code) I don't believe there's any hard and fast policy that says the kernel cannot have drivers referenced that are not part of the mainline stack, otherwise no external module using USB or any other pluggable module built externally, which Linus does not disapprove of, would never be allowed to build against the kernel.

With USB there is a clear API defined and exported from the kernel to userspace. This API can be used from source and yes, also from closed source drivers.
The FSL gpu driver is different, its API has been defined for only one closed source driver. There is no way of making use of it without closed source. There is no way for kernel maintainers to test this API without closed source. There is also no way to ever change this API without having the source available.
No, there is no place for this kind of stub drivers in the kernel. Otherwise we would also have nvidia binary driver stubs.

In any way we can delay this until there is some code using it.

Sascha

--

Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 ? ?|
Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? | Fax: ? +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#15 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

Hi Mat,,

Quoted 5 lines · Matt Sealey

We have a plan to port it to DRM, We even started for it. But it needs to work first, so we can get our reference on. Ports like this are best done slowly - you make it work, you do it piece by piece. We already did the GEM allocation and unified IPU and GPU memory allocation (after all framebuffer memory *is* texture memory on every

Quoted 8 lines

other graphics card and the IPU/VPU/GPU need to be able to access each other's memory - they all share an EMI/AXI arbiter anyway). That in itself allows us to lock down the GPU using the AMD MMU which defines a 32MB-aligned window which the GPU can write into (otherwise the GPU can touch system memory). Then we just need to do the command stream stuff and properly port the IPU framebuffer to DRM Connectors and Encoders, so XRandR will magically work, we can stop using fbdevhw evil, and so on.

That's very good news. I hope you make good progress in this.

Once there is source code available which is useful to anything else but provide a stub for a binary only userspace driver I'm of course open for merging it.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#16 lore raw

PATCH v2 1/1 ARM: imx: add gpu device

In reply to Matt Sealey

Hello Matt,

Quoted 3 lines · Matt Sealey

I have a serious problem with the way the "new" "imx_add_this_and_that" platform devices are done. Why is there so much done in little helper functions and defines?

The reason for that is to get rid of these static struct platform_devices (and some more things) to save memory.

For example look at commit

a5fcfef (ARM: mx5: dynamically allocate imx-keypad devices)

. It get's rid of mxc_kpp_resources[] (= 2 * 28 Byte, .data) and mxc_keypad_device (= 320 Byte, .data).
It only adds imx51_imx_keypad_data (= 12 Byte, .init.rodata). Moreover it allows to move platform data (here: mbimx51_map_data and mx51_3ds_map_data) from .data to .init.rodata. And you need some .init.text memory for the imx_add_this_and_that function.

So if you consider a kernel that supports mx51_3ds, eukrea_cpuimx51 and mx51_babbage. On mx51_3ds and eukrea_cpuimx51 the saving at runtime isn't that big, they only save the platform data of the other machine. But on mx51_babbage you profit from the whole stuff that is 376 Bytes. Up to you to do the same calculation for e.g. imx-uart that has up to 6 instances on i.MX27 with usually only two or three used on a single machine.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |