Skip to contentSkip to conversation

CS89x0 : add CS89x0 platform device to the iMX21ADS board

PATCH Superseded Jaccon Bastiaansen 2 participants 6 messages Jan 19, 2012 – Jan 25, 2012

Subsystems (5)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 2/4 CS89x0 : add CS89x0 platform device to the iMX21ADS board

Add CS89x0 networking support to the iMX21ADS board by using the platform driver support in the CS89x0 driver.

---
 arch/arm/configs/imx_v4_v5_defconfig |    2 ++
 arch/arm/mach-imx/mach-mx21ads.c     |   31 ++++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)
arch/arm/configs/imx_v4_v5_defconfig +2 -0
index 11a4192..fc0106f 100644
@@ -81,6 +81,8 @@ CONFIG_NET_ETHERNET=y
 CONFIG_SMC91X=y
 CONFIG_DM9000=y
 CONFIG_SMC911X=y
+CONFIG_CS89x0=y
+CONFIG_CS89x0_PLATFORM=y
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
 # CONFIG_INPUT_MOUSEDEV is not set
arch/arm/mach-imx/mach-mx21ads.c +28 -3
index 25f8402..4fd37fc 100644
@@ -37,8 +37,8 @@
 #define MX21ADS_REG_ADDR(offset)    (void __force __iomem *) \
 		(MX21ADS_MMIO_BASE_ADDR + (offset))
 
+#define MX21ADS_CS8900A_MMIO_SIZE   0x200000
 #define MX21ADS_CS8900A_IRQ         IRQ_GPIOE(11)
-#define MX21ADS_CS8900A_IOBASE_REG  MX21ADS_REG_ADDR(0x000000)
 #define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000)
 #define MX21ADS_VERSION_REG         MX21ADS_REG_ADDR(0x400000)
 #define MX21ADS_IO_REG              MX21ADS_REG_ADDR(0x800000)
@@ -159,6 +159,26 @@ static struct platform_device mx21ads_nor_mtd_device = {
 	.resource = &mx21ads_flash_resource,
 };
 
+static const struct resource mx21ads_cs8900_resources[] __initconst = {
+	{
+		.start = MX21_CS1_BASE_ADDR,
+		.end = MX21_CS1_BASE_ADDR +  MX21ADS_CS8900A_MMIO_SIZE - 1,
+		.flags = IORESOURCE_MEM,
+	},
+	{
+		.start = MX21ADS_CS8900A_IRQ,
+		.end = MX21ADS_CS8900A_IRQ,
+		.flags = IORESOURCE_IRQ,
+	}
+};
+
+static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
+	.name = "cs89x0",
+	.id = 0,
+	.res = mx21ads_cs8900_resources,
+	.num_res = ARRAY_SIZE(mx21ads_cs8900_resources),
+};
+
 static const struct imxuart_platform_data uart_pdata_rts __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
@@ -254,14 +274,17 @@ mx21ads_nand_board_info __initconst = {
 static struct map_desc mx21ads_io_desc[] __initdata = {
 	/*
 	 * Memory-mapped I/O on MX21ADS Base board:
-	 *   - CS8900A Ethernet controller
 	 *   - ST16C2552CJ UART
 	 *   - CPU and Base board version
 	 *   - Base board I/O register
+	 *
+	 * Note that the CS8900 uses the first MX21ADS_CS8900A_MMIO_SIZE
+	 * bytes of the CS1 memory range.
 	 */
 	{
 		.virtual = MX21ADS_MMIO_BASE_ADDR,
-		.pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR),
+		.pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR +
+					MX21ADS_CS8900A_MMIO_SIZE),
 		.length = MX21ADS_MMIO_SIZE,
 		.type = MT_DEVICE,
 	},
@@ -292,6 +315,8 @@ static void __init mx21ads_board_init(void)
 	imx21_add_mxc_nand(&mx21ads_nand_board_info);
 
 	platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
+	platform_device_register_full(
+			(struct platform_device_info *)&mx21ads_cs8900_devinfo);
 }
 
 static void __init mx21ads_timer_init(void)
Signature · 1 line
1.7.1
maintainer
#1 lore raw
Quoted 70 lines · Jaccon Bastiaansen

Add CS89x0 networking support to the iMX21ADS board by using the platform driver support in the CS89x0 driver.

---
 arch/arm/configs/imx_v4_v5_defconfig |    2 ++
 arch/arm/mach-imx/mach-mx21ads.c     |   31 ++++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)
arch/arm/configs/imx_v4_v5_defconfig +2 -0
index 11a4192..fc0106f 100644
@@ -81,6 +81,8 @@ CONFIG_NET_ETHERNET=y
 CONFIG_SMC91X=y
 CONFIG_DM9000=y
 CONFIG_SMC911X=y
+CONFIG_CS89x0=y
+CONFIG_CS89x0_PLATFORM=y
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
 # CONFIG_INPUT_MOUSEDEV is not set
arch/arm/mach-imx/mach-mx21ads.c +21 -2
index 25f8402..4fd37fc 100644
@@ -37,8 +37,8 @@
 #define MX21ADS_REG_ADDR(offset)    (void __force __iomem *) \
 		(MX21ADS_MMIO_BASE_ADDR + (offset))
 
+#define MX21ADS_CS8900A_MMIO_SIZE   0x200000
 #define MX21ADS_CS8900A_IRQ         IRQ_GPIOE(11)
-#define MX21ADS_CS8900A_IOBASE_REG  MX21ADS_REG_ADDR(0x000000)
 #define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000)
 #define MX21ADS_VERSION_REG         MX21ADS_REG_ADDR(0x400000)
 #define MX21ADS_IO_REG              MX21ADS_REG_ADDR(0x800000)
@@ -159,6 +159,26 @@ static struct platform_device mx21ads_nor_mtd_device = {
 	.resource = &mx21ads_flash_resource,
 };
 
+static const struct resource mx21ads_cs8900_resources[] __initconst = {
+	{
+		.start = MX21_CS1_BASE_ADDR,
+		.end = MX21_CS1_BASE_ADDR +  MX21ADS_CS8900A_MMIO_SIZE - 1,
+		.flags = IORESOURCE_MEM,
+	},
+	{
+		.start = MX21ADS_CS8900A_IRQ,
+		.end = MX21ADS_CS8900A_IRQ,
+		.flags = IORESOURCE_IRQ,
+	}
+};
+
+static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
+	.name = "cs89x0",
+	.id = 0,
+	.res = mx21ads_cs8900_resources,
+	.num_res = ARRAY_SIZE(mx21ads_cs8900_resources),
+};
+
 static const struct imxuart_platform_data uart_pdata_rts __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
 };
@@ -254,14 +274,17 @@ mx21ads_nand_board_info __initconst = {
 static struct map_desc mx21ads_io_desc[] __initdata = {
 	/*
 	 * Memory-mapped I/O on MX21ADS Base board:
-	 *   - CS8900A Ethernet controller
 	 *   - ST16C2552CJ UART
 	 *   - CPU and Base board version

arch/arm/mach-imx/mach-mx21ads.c mx21ads_nand_board_info __initconst = { · line 287

Quoted 10 lines
arch/arm/mach-imx/mach-mx21ads.c +5 -1
 	 *   - Base board I/O register
+	 *
+	 * Note that the CS8900 uses the first MX21ADS_CS8900A_MMIO_SIZE
+	 * bytes of the CS1 memory range.
 	 */
 	{
 		.virtual = MX21ADS_MMIO_BASE_ADDR,
-		.pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR),
+		.pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR +
+					MX21ADS_CS8900A_MMIO_SIZE),

Since you now use ioremap the cs89x0 driver this mapping is not used for the cs89x0 anymore, so it's strange to have references to it here.
You still need the mapping though, but only for MX21ADS_IO_REG.

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 |
#2 lore raw

Hello Sascha,

2012/1/23 Sascha Hauer <[email protected]>:

Quoted 78 lines · Jaccon Bastiaansen
Quoted 77 lines

Add CS89x0 networking support to the iMX21ADS board by using the platform driver support in the CS89x0 driver.

---
?arch/arm/configs/imx_v4_v5_defconfig | ? ?2 ++ ?arch/arm/mach-imx/mach-mx21ads.c ? ? | ? 31 ++++++++++++++++++++++++++++--- ?2 files changed, 30 insertions(+), 3 deletions(-)

arch/arm/configs/imx_v4_v5_defconfig +0 -0
index 11a4192..fc0106f 100644
@@ -81,6 +81,8 @@ CONFIG_NET_ETHERNET=y

?CONFIG_SMC91X=y
?CONFIG_DM9000=y
?CONFIG_SMC911X=y

arch/arm/configs/imx_v4_v5_defconfig +2 -0
+CONFIG_CS89x0=y
+CONFIG_CS89x0_PLATFORM=y

?# CONFIG_NETDEV_1000 is not set
?# CONFIG_NETDEV_10000 is not set
?# CONFIG_INPUT_MOUSEDEV is not set

arch/arm/mach-imx/mach-mx21ads.c +21 -1
index 25f8402..4fd37fc 100644
@@ -37,8 +37,8 @@
 ?#define MX21ADS_REG_ADDR(offset) ? ?(void __force __iomem *) \
 ? ? ? ? ? ? ? (MX21ADS_MMIO_BASE_ADDR + (offset))
 
+#define MX21ADS_CS8900A_MMIO_SIZE ? 0x200000
 ?#define MX21ADS_CS8900A_IRQ ? ? ? ? IRQ_GPIOE(11)
-#define MX21ADS_CS8900A_IOBASE_REG ?MX21ADS_REG_ADDR(0x000000)
 ?#define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000)
 ?#define MX21ADS_VERSION_REG ? ? ? ? MX21ADS_REG_ADDR(0x400000)
 ?#define MX21ADS_IO_REG ? ? ? ? ? ? ?MX21ADS_REG_ADDR(0x800000)
@@ -159,6 +159,26 @@ static struct platform_device mx21ads_nor_mtd_device = {
 ? ? ? .resource = &mx21ads_flash_resource,
 ?};
 
+static const struct resource mx21ads_cs8900_resources[] __initconst = {
+ ? ? {
+ ? ? ? ? ? ? .start = MX21_CS1_BASE_ADDR,
+ ? ? ? ? ? ? .end = MX21_CS1_BASE_ADDR + ?MX21ADS_CS8900A_MMIO_SIZE - 1,
+ ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? },
+ ? ? {
+ ? ? ? ? ? ? .start = MX21ADS_CS8900A_IRQ,
+ ? ? ? ? ? ? .end = MX21ADS_CS8900A_IRQ,
+ ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? }
+};
+
+static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
+ ? ? .name = "cs89x0",
+ ? ? .id = 0,
+ ? ? .res = mx21ads_cs8900_resources,
+ ? ? .num_res = ARRAY_SIZE(mx21ads_cs8900_resources),
+};
+
 ?static const struct imxuart_platform_data uart_pdata_rts __initconst = {
 ? ? ? .flags = IMXUART_HAVE_RTSCTS,
 ?};
@@ -254,14 +274,17 @@ mx21ads_nand_board_info __initconst = {
 ?static struct map_desc mx21ads_io_desc[] __initdata = {

? ? ? /*
? ? ? ?* Memory-mapped I/O on MX21ADS Base board:
- ? ? ?* ? - CS8900A Ethernet controller
? ? ? ?* ? - ST16C2552CJ UART
? ? ? ?* ? - CPU and Base board version
? ? ? ?* ? - Base board I/O register
+ ? ? ?*
+ ? ? ?* Note that the CS8900 uses the first MX21ADS_CS8900A_MMIO_SIZE
+ ? ? ?* bytes of the CS1 memory range.
? ? ? ?*/
? ? ? {
? ? ? ? ? ? ? .virtual = MX21ADS_MMIO_BASE_ADDR,

Quoted 9 lines
Quoted 3 lines

- ? ? ? ? ? ? .pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR),
+ ? ? ? ? ? ? .pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR +
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MX21ADS_CS8900A_MMIO_SIZE),

Since you now use ioremap the cs89x0 driver this mapping is not used for the cs89x0 anymore, so it's strange to have references to it here.
You still need the mapping though, but only for MX21ADS_IO_REG.

The ST16C255 UART is the first peripheral in the CS1 memory range for which this fixed mapping is now required. I could create another constant (for example: MX21ADS_ST16C255_OFFSET) to indicate the offset in the CS1 memory range where the mapping should start. But since that would create another constant with the same value as MX21ADS_CS8900A_MMIO_SIZE, I decided to use MX21ADS_CS8900A_MMIO_SIZE.

Do you prefer to a constant with another name here?

Quoted 7 lines

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 |

Regards,
Jaccon

maintainer
#3 lore raw
Quoted 91 lines · Jaccon Bastiaansen

Hello Sascha,

2012/1/23 Sascha Hauer <[email protected]>:

Quoted 78 lines · Jaccon Bastiaansen
Quoted 77 lines

Add CS89x0 networking support to the iMX21ADS board by using the platform driver support in the CS89x0 driver.

---
?arch/arm/configs/imx_v4_v5_defconfig | ? ?2 ++ ?arch/arm/mach-imx/mach-mx21ads.c ? ? | ? 31 ++++++++++++++++++++++++++++--- ?2 files changed, 30 insertions(+), 3 deletions(-)

arch/arm/configs/imx_v4_v5_defconfig +0 -0
index 11a4192..fc0106f 100644
@@ -81,6 +81,8 @@ CONFIG_NET_ETHERNET=y

?CONFIG_SMC91X=y
?CONFIG_DM9000=y
?CONFIG_SMC911X=y

arch/arm/configs/imx_v4_v5_defconfig +2 -0
+CONFIG_CS89x0=y
+CONFIG_CS89x0_PLATFORM=y

?# CONFIG_NETDEV_1000 is not set
?# CONFIG_NETDEV_10000 is not set
?# CONFIG_INPUT_MOUSEDEV is not set

arch/arm/mach-imx/mach-mx21ads.c +21 -1
index 25f8402..4fd37fc 100644
@@ -37,8 +37,8 @@
 ?#define MX21ADS_REG_ADDR(offset) ? ?(void __force __iomem *) \
 ? ? ? ? ? ? ? (MX21ADS_MMIO_BASE_ADDR + (offset))
 
+#define MX21ADS_CS8900A_MMIO_SIZE ? 0x200000
 ?#define MX21ADS_CS8900A_IRQ ? ? ? ? IRQ_GPIOE(11)
-#define MX21ADS_CS8900A_IOBASE_REG ?MX21ADS_REG_ADDR(0x000000)
 ?#define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000)
 ?#define MX21ADS_VERSION_REG ? ? ? ? MX21ADS_REG_ADDR(0x400000)
 ?#define MX21ADS_IO_REG ? ? ? ? ? ? ?MX21ADS_REG_ADDR(0x800000)
@@ -159,6 +159,26 @@ static struct platform_device mx21ads_nor_mtd_device = {
 ? ? ? .resource = &mx21ads_flash_resource,
 ?};
 
+static const struct resource mx21ads_cs8900_resources[] __initconst = {
+ ? ? {
+ ? ? ? ? ? ? .start = MX21_CS1_BASE_ADDR,
+ ? ? ? ? ? ? .end = MX21_CS1_BASE_ADDR + ?MX21ADS_CS8900A_MMIO_SIZE - 1,
+ ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? },
+ ? ? {
+ ? ? ? ? ? ? .start = MX21ADS_CS8900A_IRQ,
+ ? ? ? ? ? ? .end = MX21ADS_CS8900A_IRQ,
+ ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? }
+};
+
+static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
+ ? ? .name = "cs89x0",
+ ? ? .id = 0,
+ ? ? .res = mx21ads_cs8900_resources,
+ ? ? .num_res = ARRAY_SIZE(mx21ads_cs8900_resources),
+};
+
 ?static const struct imxuart_platform_data uart_pdata_rts __initconst = {
 ? ? ? .flags = IMXUART_HAVE_RTSCTS,
 ?};
@@ -254,14 +274,17 @@ mx21ads_nand_board_info __initconst = {
 ?static struct map_desc mx21ads_io_desc[] __initdata = {

? ? ? /*
? ? ? ?* Memory-mapped I/O on MX21ADS Base board:
- ? ? ?* ? - CS8900A Ethernet controller
? ? ? ?* ? - ST16C2552CJ UART
? ? ? ?* ? - CPU and Base board version
? ? ? ?* ? - Base board I/O register
+ ? ? ?*
+ ? ? ?* Note that the CS8900 uses the first MX21ADS_CS8900A_MMIO_SIZE
+ ? ? ?* bytes of the CS1 memory range.
? ? ? ?*/
? ? ? {
? ? ? ? ? ? ? .virtual = MX21ADS_MMIO_BASE_ADDR,

Quoted 9 lines
Quoted 3 lines

- ? ? ? ? ? ? .pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR),
+ ? ? ? ? ? ? .pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR +
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MX21ADS_CS8900A_MMIO_SIZE),

Since you now use ioremap the cs89x0 driver this mapping is not used for the cs89x0 anymore, so it's strange to have references to it here.
You still need the mapping though, but only for MX21ADS_IO_REG.

Quoted 8 lines

The ST16C255 UART is the first peripheral in the CS1 memory range for which this fixed mapping is now required. I could create another constant (for example: MX21ADS_ST16C255_OFFSET) to indicate the offset in the CS1 memory range where the mapping should start. But since that would create another constant with the same value as MX21ADS_CS8900A_MMIO_SIZE, I decided to use MX21ADS_CS8900A_MMIO_SIZE.

Do you prefer to a constant with another name here?

Ok, looking again at it I understand what you are doing here and it seems wrong. Instead of mapping MX21_CS1_BASE_ADDR you now map MX21_CS1_BASE_ADDR + MX21ADS_CS8900A_MMIO_SIZE. This means that the offset to MX21ADS_IO_REG is no longer 0x800000 but 0x800000 - MX21ADS_CS8900A_MMIO_SIZE.
Please just keep the mapping like it was before, it won't hurt. BTW the 8250 serial driver also ioremaps the memory if you add UPF_IOREMAP to the platform data.

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 |
#4 lore raw

2012/1/24 Sascha Hauer <[email protected]>:

Quoted 110 lines · Jaccon Bastiaansen
Quoted 91 lines

Hello Sascha,

2012/1/23 Sascha Hauer <[email protected]>:

Quoted 78 lines · Jaccon Bastiaansen
Quoted 77 lines

Add CS89x0 networking support to the iMX21ADS board by using the platform driver support in the CS89x0 driver.

---
?arch/arm/configs/imx_v4_v5_defconfig | ? ?2 ++ ?arch/arm/mach-imx/mach-mx21ads.c ? ? | ? 31 ++++++++++++++++++++++++++++--- ?2 files changed, 30 insertions(+), 3 deletions(-)

arch/arm/configs/imx_v4_v5_defconfig +0 -0
index 11a4192..fc0106f 100644
@@ -81,6 +81,8 @@ CONFIG_NET_ETHERNET=y

?CONFIG_SMC91X=y
?CONFIG_DM9000=y
?CONFIG_SMC911X=y

arch/arm/configs/imx_v4_v5_defconfig +2 -0
+CONFIG_CS89x0=y
+CONFIG_CS89x0_PLATFORM=y

?# CONFIG_NETDEV_1000 is not set
?# CONFIG_NETDEV_10000 is not set
?# CONFIG_INPUT_MOUSEDEV is not set

arch/arm/mach-imx/mach-mx21ads.c +21 -1
index 25f8402..4fd37fc 100644
@@ -37,8 +37,8 @@
 ?#define MX21ADS_REG_ADDR(offset) ? ?(void __force __iomem *) \
 ? ? ? ? ? ? ? (MX21ADS_MMIO_BASE_ADDR + (offset))
 
+#define MX21ADS_CS8900A_MMIO_SIZE ? 0x200000
 ?#define MX21ADS_CS8900A_IRQ ? ? ? ? IRQ_GPIOE(11)
-#define MX21ADS_CS8900A_IOBASE_REG ?MX21ADS_REG_ADDR(0x000000)
 ?#define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000)
 ?#define MX21ADS_VERSION_REG ? ? ? ? MX21ADS_REG_ADDR(0x400000)
 ?#define MX21ADS_IO_REG ? ? ? ? ? ? ?MX21ADS_REG_ADDR(0x800000)
@@ -159,6 +159,26 @@ static struct platform_device mx21ads_nor_mtd_device = {
 ? ? ? .resource = &mx21ads_flash_resource,
 ?};
 
+static const struct resource mx21ads_cs8900_resources[] __initconst = {
+ ? ? {
+ ? ? ? ? ? ? .start = MX21_CS1_BASE_ADDR,
+ ? ? ? ? ? ? .end = MX21_CS1_BASE_ADDR + ?MX21ADS_CS8900A_MMIO_SIZE - 1,
+ ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? },
+ ? ? {
+ ? ? ? ? ? ? .start = MX21ADS_CS8900A_IRQ,
+ ? ? ? ? ? ? .end = MX21ADS_CS8900A_IRQ,
+ ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? }
+};
+
+static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
+ ? ? .name = "cs89x0",
+ ? ? .id = 0,
+ ? ? .res = mx21ads_cs8900_resources,
+ ? ? .num_res = ARRAY_SIZE(mx21ads_cs8900_resources),
+};
+
 ?static const struct imxuart_platform_data uart_pdata_rts __initconst = {
 ? ? ? .flags = IMXUART_HAVE_RTSCTS,
 ?};
@@ -254,14 +274,17 @@ mx21ads_nand_board_info __initconst = {
 ?static struct map_desc mx21ads_io_desc[] __initdata = {

? ? ? /*
? ? ? ?* Memory-mapped I/O on MX21ADS Base board:
- ? ? ?* ? - CS8900A Ethernet controller
? ? ? ?* ? - ST16C2552CJ UART
? ? ? ?* ? - CPU and Base board version
? ? ? ?* ? - Base board I/O register
+ ? ? ?*
+ ? ? ?* Note that the CS8900 uses the first MX21ADS_CS8900A_MMIO_SIZE
+ ? ? ?* bytes of the CS1 memory range.
? ? ? ?*/
? ? ? {
? ? ? ? ? ? ? .virtual = MX21ADS_MMIO_BASE_ADDR,

Quoted 9 lines
Quoted 3 lines

- ? ? ? ? ? ? .pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR),
+ ? ? ? ? ? ? .pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR +
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MX21ADS_CS8900A_MMIO_SIZE),

Since you now use ioremap the cs89x0 driver this mapping is not used for the cs89x0 anymore, so it's strange to have references to it here.
You still need the mapping though, but only for MX21ADS_IO_REG.

Quoted 8 lines

The ST16C255 UART is the first peripheral in the CS1 memory range for which this fixed mapping is now required. I could create another constant (for example: MX21ADS_ST16C255_OFFSET) to indicate the offset in the CS1 memory range where the mapping should start. But since that would create another constant with the same value as MX21ADS_CS8900A_MMIO_SIZE, I decided to use MX21ADS_CS8900A_MMIO_SIZE.

Do you prefer to a constant with another name here?

Ok, looking again at it I understand what you are doing here and it seems wrong. Instead of mapping MX21_CS1_BASE_ADDR you now map MX21_CS1_BASE_ADDR + MX21ADS_CS8900A_MMIO_SIZE. This means that the offset to MX21ADS_IO_REG is no longer 0x800000 but 0x800000 - MX21ADS_CS8900A_MMIO_SIZE.
Please just keep the mapping like it was before, it won't hurt. BTW the 8250 serial driver also ioremaps the memory if you add UPF_IOREMAP to the platform data.

Quoted 2 lines

Sascha

You are right, this mapping is now wrong.

The reason I didn't keep the mapping as is, is because then the physical pages from MX21_CS1_BASE_ADDR up to MX21_CS1_BASE_ADDR + MX21ADS_CS8900A_MMIO_SIZE would be mapped twice to different virtual addresses (once by this static mapping and once by the ioremap in the cs89x0 driver).

Another approach could be to subtract 0x200000 from the offsets in the definitions of MX21ADS_ST16C255_IOBASE_REG, MX21ADS_VERSION_REG and MX21ADS_IO_REG. So the definition of MX21ADS_IO_REG would become MX21ADS_REG_ADDR(0x600000). What do you think of this?

Regards,
Jaccon

Quoted 5 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 |
maintainer Tested-by Stephen Warren Tested-by Kevin Hilman Tested-by Jamie Iles
#5 lore raw
Quoted 28 lines · Jaccon Bastiaansen
Quoted 25 lines
Quoted 7 lines
Quoted 6 lines

Since you now use ioremap the cs89x0 driver this mapping is not used for the cs89x0 anymore, so it's strange to have references to it here.
You still need the mapping though, but only for MX21ADS_IO_REG.

Quoted 8 lines

The ST16C255 UART is the first peripheral in the CS1 memory range for which this fixed mapping is now required. I could create another constant (for example: MX21ADS_ST16C255_OFFSET) to indicate the offset in the CS1 memory range where the mapping should start. But since that would create another constant with the same value as MX21ADS_CS8900A_MMIO_SIZE, I decided to use MX21ADS_CS8900A_MMIO_SIZE.

Do you prefer to a constant with another name here?

Ok, looking again at it I understand what you are doing here and it seems wrong. Instead of mapping MX21_CS1_BASE_ADDR you now map MX21_CS1_BASE_ADDR + MX21ADS_CS8900A_MMIO_SIZE. This means that the offset to MX21ADS_IO_REG is no longer 0x800000 but 0x800000 - MX21ADS_CS8900A_MMIO_SIZE.
Please just keep the mapping like it was before, it won't hurt. BTW the 8250 serial driver also ioremaps the memory if you add UPF_IOREMAP to the platform data.

Quoted 2 lines

Sascha

Quoted 7 lines

You are right, this mapping is now wrong.

The reason I didn't keep the mapping as is, is because then the physical pages from MX21_CS1_BASE_ADDR up to MX21_CS1_BASE_ADDR + MX21ADS_CS8900A_MMIO_SIZE would be mapped twice to different virtual addresses (once by this static mapping and once by the ioremap in the cs89x0 driver).

This won't hurt, you will even get the same virtual address you have in the static mapping returned from ioremap since this commit:

commit 576d2f2525612ecb5af029a76f21f22a3b82563d

Author: Nicolas Pitre <[email protected]>
Date:   Fri Sep 16 01:14:23 2011 -0400

ARM: add generic ioremap optimization by reusing static mappings

Now that we have all the static mappings from iotable_init() located in the vmalloc area, it is trivial to optimize ioremap by reusing those static mappings when the requested physical area fits in one ofi them, and so in a generic way for all platforms.

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 |