[U-Boot,05/10] spi: sun4i: Support fifo_depth via drvdata

Message ID 20190209131500.29954-6-jagan@amarulasolutions.com
State Changes Requested
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series
  • spi: Add Allwinner A31 SPI driver
Related show

Commit Message

Jagan Teki Feb. 9, 2019, 1:14 p.m.
Support fifo_depth via drvdata instead of macro definition, this would
eventually reduce another macro definition for new SPI controller fifo
depth support addition.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/spi/sun4i_spi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

André Przywara Feb. 13, 2019, 1:16 a.m. | #1
On 09/02/2019 13:14, Jagan Teki wrote:
> Support fifo_depth via drvdata instead of macro definition, this would
> eventually reduce another macro definition for new SPI controller fifo
> depth support addition.
> 
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> ---
>  drivers/spi/sun4i_spi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/sun4i_spi.c b/drivers/spi/sun4i_spi.c
> index c06028890b..d3cf25db6f 100644
> --- a/drivers/spi/sun4i_spi.c
> +++ b/drivers/spi/sun4i_spi.c
> @@ -33,8 +33,6 @@
>  
>  #include <linux/iopoll.h>
>  
> -#define SUN4I_FIFO_DEPTH	64
> -
>  #define SUN4I_RXDATA_REG	0x00
>  
>  #define SUN4I_TXDATA_REG	0x04
> @@ -124,6 +122,7 @@ enum sun4i_spi_bits {
>  
>  struct sun4i_spi_variant {
>  	const unsigned long *regs, *bits;
> +	u32 fifo_depth;
>  };
>  
>  struct sun4i_spi_platdata {
> @@ -363,7 +362,7 @@ static int sun4i_spi_xfer(struct udevice *dev, unsigned int bitlen,
>  
>  	while (len) {
>  		/* Setup the transfer now... */
> -		nbytes = min(len, (u32)(SUN4I_FIFO_DEPTH - 1));
> +		nbytes = min(len, (priv->variant->fifo_depth - 1));
>  
>  		/* Setup the counters */
>  		writel(SUN4I_BURST_CNT(nbytes),
> @@ -511,6 +510,7 @@ static const unsigned long sun4i_spi_bits[] = {
>  static const struct sun4i_spi_variant sun4i_a10_spi_variant = {
>  	.regs			= sun4i_spi_regs,
>  	.bits			= sun4i_spi_bits,
> +	.fifo_depth		= 64,
>  };
>  
>  static const struct udevice_id sun4i_spi_ids[] = {
>

Patch

diff --git a/drivers/spi/sun4i_spi.c b/drivers/spi/sun4i_spi.c
index c06028890b..d3cf25db6f 100644
--- a/drivers/spi/sun4i_spi.c
+++ b/drivers/spi/sun4i_spi.c
@@ -33,8 +33,6 @@ 
 
 #include <linux/iopoll.h>
 
-#define SUN4I_FIFO_DEPTH	64
-
 #define SUN4I_RXDATA_REG	0x00
 
 #define SUN4I_TXDATA_REG	0x04
@@ -124,6 +122,7 @@  enum sun4i_spi_bits {
 
 struct sun4i_spi_variant {
 	const unsigned long *regs, *bits;
+	u32 fifo_depth;
 };
 
 struct sun4i_spi_platdata {
@@ -363,7 +362,7 @@  static int sun4i_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 	while (len) {
 		/* Setup the transfer now... */
-		nbytes = min(len, (u32)(SUN4I_FIFO_DEPTH - 1));
+		nbytes = min(len, (priv->variant->fifo_depth - 1));
 
 		/* Setup the counters */
 		writel(SUN4I_BURST_CNT(nbytes),
@@ -511,6 +510,7 @@  static const unsigned long sun4i_spi_bits[] = {
 static const struct sun4i_spi_variant sun4i_a10_spi_variant = {
 	.regs			= sun4i_spi_regs,
 	.bits			= sun4i_spi_bits,
+	.fifo_depth		= 64,
 };
 
 static const struct udevice_id sun4i_spi_ids[] = {