Skip to contentSkip to conversation

char: xilinx_hwicap: replace in_be32/out_be32 with ioread32be/iowrite32be

PATCH In review Rosen Penev 2 participants 5 messages Jun 2 – Jun 4

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

PATCH 1/1 char: xilinx_hwicap: replace in_be32/out_be32 with ioread32be/iowrite32be

Mechanical conversion of the ppc4xx-specific accessors to the generic portable helpers.

As a result, COMPILE_TEST is added for extra compile coverage.

Assisted-by opencode:big-pickle
---
 drivers/char/Kconfig                     |  2 +-
 drivers/char/xilinx_hwicap/buffer_icap.c | 16 +++++------
 drivers/char/xilinx_hwicap/fifo_icap.c   | 34 +++++++++++-------------
 3 files changed, 24 insertions(+), 28 deletions(-)
drivers/char/Kconfig +1 -1
index 9865227af167..b892bcf28af4 100644
@@ -201,7 +201,7 @@ source "drivers/char/hw_random/Kconfig"
 
 config XILINX_HWICAP
 	tristate "Xilinx HWICAP Support"
-	depends on MICROBLAZE
+	depends on MICROBLAZE || COMPILE_TEST
 	help
 	  This option enables support for Xilinx Internal Configuration
 	  Access Port (ICAP) driver.  The ICAP is used on Xilinx Virtex
drivers/char/xilinx_hwicap/buffer_icap.c +8 -8
index 35981cae1afa..24e73f1502c2 100644
@@ -87,7 +87,7 @@
  **/
 u32 buffer_icap_get_status(struct hwicap_drvdata *drvdata)
 {
-	return in_be32(drvdata->base_address + XHI_STATUS_REG_OFFSET);
+	return ioread32be(drvdata->base_address + XHI_STATUS_REG_OFFSET);
 }
 
 /**
@@ -101,7 +101,7 @@ u32 buffer_icap_get_status(struct hwicap_drvdata *drvdata)
 static inline u32 buffer_icap_get_bram(void __iomem *base_address,
 		u32 offset)
 {
-	return in_be32(base_address + (offset << 2));
+	return ioread32be(base_address + (offset << 2));
 }
 
 /**
@@ -114,7 +114,7 @@ static inline u32 buffer_icap_get_bram(void __iomem *base_address,
  **/
 static inline bool buffer_icap_busy(void __iomem *base_address)
 {
-	u32 status = in_be32(base_address + XHI_STATUS_REG_OFFSET);
+	u32 status = ioread32be(base_address + XHI_STATUS_REG_OFFSET);
 	return (status & 1) == XHI_NOT_FINISHED;
 }
 
@@ -129,7 +129,7 @@ static inline bool buffer_icap_busy(void __iomem *base_address)
 static inline void buffer_icap_set_size(void __iomem *base_address,
 		u32 data)
 {
-	out_be32(base_address + XHI_SIZE_REG_OFFSET, data);
+	iowrite32be(data, base_address + XHI_SIZE_REG_OFFSET);
 }
 
 /**
@@ -143,7 +143,7 @@ static inline void buffer_icap_set_size(void __iomem *base_address,
 static inline void buffer_icap_set_offset(void __iomem *base_address,
 		u32 data)
 {
-	out_be32(base_address + XHI_BRAM_OFFSET_REG_OFFSET, data);
+	iowrite32be(data, base_address + XHI_BRAM_OFFSET_REG_OFFSET);
 }
 
 /**
@@ -159,7 +159,7 @@ static inline void buffer_icap_set_offset(void __iomem *base_address,
 static inline void buffer_icap_set_rnc(void __iomem *base_address,
 		u32 data)
 {
-	out_be32(base_address + XHI_RNC_REG_OFFSET, data);
+	iowrite32be(data, base_address + XHI_RNC_REG_OFFSET);
 }
 
 /**
@@ -174,7 +174,7 @@ static inline void buffer_icap_set_rnc(void __iomem *base_address,
 static inline void buffer_icap_set_bram(void __iomem *base_address,
 		u32 offset, u32 data)
 {
-	out_be32(base_address + (offset << 2), data);
+	iowrite32be(data, base_address + (offset << 2));
 }
 
 /**
@@ -255,7 +255,7 @@ static int buffer_icap_device_write(struct hwicap_drvdata *drvdata,
  **/
 void buffer_icap_reset(struct hwicap_drvdata *drvdata)
 {
-    out_be32(drvdata->base_address + XHI_STATUS_REG_OFFSET, 0xFEFE);
+    iowrite32be(0xFEFE, drvdata->base_address + XHI_STATUS_REG_OFFSET);
 }
 
 /**
drivers/char/xilinx_hwicap/fifo_icap.c +15 -19
index 7bd786fa1be8..928ee4ca3012 100644
@@ -94,7 +94,7 @@ static inline void fifo_icap_fifo_write(struct hwicap_drvdata *drvdata,
 		u32 data)
 {
 	dev_dbg(drvdata->dev, "fifo_write: %x\n", data);
-	out_be32(drvdata->base_address + XHI_WF_OFFSET, data);
+	iowrite32be(data, drvdata->base_address + XHI_WF_OFFSET);
 }
 
 /**
@@ -107,7 +107,7 @@ static inline void fifo_icap_fifo_write(struct hwicap_drvdata *drvdata,
  **/
 static inline u32 fifo_icap_fifo_read(struct hwicap_drvdata *drvdata)
 {
-	u32 data = in_be32(drvdata->base_address + XHI_RF_OFFSET);
+	u32 data = ioread32be(drvdata->base_address + XHI_RF_OFFSET);
 	dev_dbg(drvdata->dev, "fifo_read: %x\n", data);
 	return data;
 }
@@ -120,7 +120,7 @@ static inline u32 fifo_icap_fifo_read(struct hwicap_drvdata *drvdata)
 static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata,
 		u32 data)
 {
-	out_be32(drvdata->base_address + XHI_SZ_OFFSET, data);
+	iowrite32be(data, drvdata->base_address + XHI_SZ_OFFSET);
 }
 
 /**
@@ -129,7 +129,7 @@ static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata,
  **/
 static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
 {
-	out_be32(drvdata->base_address + XHI_CR_OFFSET, XHI_CR_WRITE_MASK);
+	iowrite32be(XHI_CR_WRITE_MASK, drvdata->base_address + XHI_CR_OFFSET);
 	dev_dbg(drvdata->dev, "configuration started\n");
 }
 
@@ -139,7 +139,7 @@ static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
  **/
 static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
 {
-	out_be32(drvdata->base_address + XHI_CR_OFFSET, XHI_CR_READ_MASK);
+	iowrite32be(XHI_CR_READ_MASK, drvdata->base_address + XHI_CR_OFFSET);
 	dev_dbg(drvdata->dev, "readback started\n");
 }
 
@@ -163,7 +163,7 @@ static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
  **/
 u32 fifo_icap_get_status(struct hwicap_drvdata *drvdata)
 {
-	u32 status = in_be32(drvdata->base_address + XHI_SR_OFFSET);
+	u32 status = ioread32be(drvdata->base_address + XHI_SR_OFFSET);
 	dev_dbg(drvdata->dev, "Getting status = %x\n", status);
 	return status;
 }
@@ -177,7 +177,7 @@ u32 fifo_icap_get_status(struct hwicap_drvdata *drvdata)
  **/
 static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
 {
-	u32 status = in_be32(drvdata->base_address + XHI_SR_OFFSET);
+	u32 status = ioread32be(drvdata->base_address + XHI_SR_OFFSET);
 	return (status & XHI_SR_DONE_MASK) ? 0 : 1;
 }
 
@@ -190,7 +190,7 @@ static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
 static inline u32 fifo_icap_write_fifo_vacancy(
 		struct hwicap_drvdata *drvdata)
 {
-	return in_be32(drvdata->base_address + XHI_WFV_OFFSET);
+	return ioread32be(drvdata->base_address + XHI_WFV_OFFSET);
 }
 
 /**
@@ -202,7 +202,7 @@ static inline u32 fifo_icap_write_fifo_vacancy(
 static inline u32 fifo_icap_read_fifo_occupancy(
 		struct hwicap_drvdata *drvdata)
 {
-	return in_be32(drvdata->base_address + XHI_RFO_OFFSET);
+	return ioread32be(drvdata->base_address + XHI_RFO_OFFSET);
 }
 
 /**
@@ -372,13 +372,11 @@ void fifo_icap_reset(struct hwicap_drvdata *drvdata)
 	 * Reset the device by setting/clearing the RESET bit in the
 	 * Control Register.
 	 */
-	reg_data = in_be32(drvdata->base_address + XHI_CR_OFFSET);
+	reg_data = ioread32be(drvdata->base_address + XHI_CR_OFFSET);
 
-	out_be32(drvdata->base_address + XHI_CR_OFFSET,
-				reg_data | XHI_CR_SW_RESET_MASK);
+	iowrite32be(reg_data | XHI_CR_SW_RESET_MASK, drvdata->base_address + XHI_CR_OFFSET);
 
-	out_be32(drvdata->base_address + XHI_CR_OFFSET,
-				reg_data & (~XHI_CR_SW_RESET_MASK));
+	iowrite32be(reg_data & (~XHI_CR_SW_RESET_MASK), drvdata->base_address + XHI_CR_OFFSET);
 
 }
 
@@ -393,12 +391,10 @@ void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata)
 	 * Flush the FIFO by setting/clearing the FIFO Clear bit in the
 	 * Control Register.
 	 */
-	reg_data = in_be32(drvdata->base_address + XHI_CR_OFFSET);
+	reg_data = ioread32be(drvdata->base_address + XHI_CR_OFFSET);
 
-	out_be32(drvdata->base_address + XHI_CR_OFFSET,
-				reg_data | XHI_CR_FIFO_CLR_MASK);
+	iowrite32be(reg_data | XHI_CR_FIFO_CLR_MASK, drvdata->base_address + XHI_CR_OFFSET);
 
-	out_be32(drvdata->base_address + XHI_CR_OFFSET,
-				reg_data & (~XHI_CR_FIFO_CLR_MASK));
+	iowrite32be(reg_data & (~XHI_CR_FIFO_CLR_MASK), drvdata->base_address + XHI_CR_OFFSET);
 }
 
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 5 lines · Rosen Penev

Mechanical conversion of the ppc4xx-specific accessors to the generic portable helpers.

As a result, COMPILE_TEST is added for extra compile coverage.

Quoted 7 lines
Assisted-by opencode:big-pickle
---
  drivers/char/Kconfig                     |  2 +-
  drivers/char/xilinx_hwicap/buffer_icap.c | 16 +++++------
  drivers/char/xilinx_hwicap/fifo_icap.c   | 34 +++++++++++-------------
  3 files changed, 24 insertions(+), 28 deletions(-)

I don't really mind about this because I think that we can also remove the whole driver.

Thanks,
Michal

#2 lore raw
Quoted 17 lines · Michal Simek
Quoted 5 lines · Rosen Penev

Mechanical conversion of the ppc4xx-specific accessors to the generic portable helpers.

As a result, COMPILE_TEST is added for extra compile coverage.

Quoted 7 lines
Assisted-by opencode:big-pickle
---
  drivers/char/Kconfig                     |  2 +-
  drivers/char/xilinx_hwicap/buffer_icap.c | 16 +++++------
  drivers/char/xilinx_hwicap/fifo_icap.c   | 34 +++++++++++-------------
  3 files changed, 24 insertions(+), 28 deletions(-)
Quoted 2 lines

I don't really mind about this because I think that we can also remove the whole driver.

I looked into this. The problem here is that there are actual users

arch/microblaze/boot/dts/system.dts

and

arch/mips/boot/dts/xilfpga/nexys4ddr.dts

Quoted 2 lines

Thanks,
Michal

maintainer
#3 lore raw
Quoted 20 lines · Rosen Penev
Quoted 17 lines · Michal Simek
Quoted 5 lines · Rosen Penev

Mechanical conversion of the ppc4xx-specific accessors to the generic portable helpers.

As a result, COMPILE_TEST is added for extra compile coverage.

Quoted 7 lines
Assisted-by opencode:big-pickle
---
   drivers/char/Kconfig                     |  2 +-
   drivers/char/xilinx_hwicap/buffer_icap.c | 16 +++++------
   drivers/char/xilinx_hwicap/fifo_icap.c   | 34 +++++++++++-------------
   3 files changed, 24 insertions(+), 28 deletions(-)
Quoted 2 lines

I don't really mind about this because I think that we can also remove the whole driver.

Quoted 7 lines

I looked into this. The problem here is that there are actual users

arch/microblaze/boot/dts/system.dts

and

arch/mips/boot/dts/xilfpga/nexys4ddr.dts

I can't see users of it.

on v7.1-rc1

$ git grep opb-hwicap
Documentation/devicetree/bindings/xilinx.txt:126: "xlnx,opb-hwicap-1.00.b".
drivers/char/xilinx_hwicap/xilinx_hwicap.c:733: { .compatible = "xlnx,opb-hwicap-1.00.b", .data = &buffer_icap_config},
$ git grep xps-hwicap
Documentation/devicetree/bindings/xilinx.txt:125:               - compatible : should contain "xlnx,xps-hwicap-1.00.a" or
drivers/char/xilinx_hwicap/xilinx_hwicap.c:734: { .compatible = "xlnx,xps-hwicap-1.00.a", .data = &fifo_icap_config},

Thanks,
Michal

#4 lore raw
Quoted 25 lines · Michal Simek
Quoted 22 lines · Rosen Penev
Quoted 17 lines · Michal Simek
Quoted 5 lines · Rosen Penev

Mechanical conversion of the ppc4xx-specific accessors to the generic portable helpers.

As a result, COMPILE_TEST is added for extra compile coverage.

Quoted 7 lines
Assisted-by opencode:big-pickle
---
   drivers/char/Kconfig                     |  2 +-
   drivers/char/xilinx_hwicap/buffer_icap.c | 16 +++++------
   drivers/char/xilinx_hwicap/fifo_icap.c   | 34 +++++++++++-------------
   3 files changed, 24 insertions(+), 28 deletions(-)
Quoted 2 lines

I don't really mind about this because I think that we can also remove the whole driver.

I looked into this. The problem here is that there are actual users

Quoted 8 lines
Quoted 5 lines

arch/microblaze/boot/dts/system.dts

and

arch/mips/boot/dts/xilfpga/nexys4ddr.dts

I can't see users of it.

Hrm looks like I just grepped xlns,xps and found system.dts. You're right.

Quoted 15 lines

on v7.1-rc1

$ git grep opb-hwicap
Documentation/devicetree/bindings/xilinx.txt:126:
"xlnx,opb-hwicap-1.00.b".
drivers/char/xilinx_hwicap/xilinx_hwicap.c:733: { .compatible =
"xlnx,opb-hwicap-1.00.b", .data = &buffer_icap_config},
$ git grep xps-hwicap
Documentation/devicetree/bindings/xilinx.txt:125:               - compatible :
should contain "xlnx,xps-hwicap-1.00.a" or
drivers/char/xilinx_hwicap/xilinx_hwicap.c:734: { .compatible =
"xlnx,xps-hwicap-1.00.a", .data = &fifo_icap_config},

Thanks,
Michal