[U-Boot] [PATCH] Add code for spi half duplex operation for enc28j60
Jagan Teki
jagannadh.teki at gmail.com
Fri Oct 4 13:13:51 CEST 2013
Hi
Seems like some issues with checkpatch.pl and use proper commit msg header.
Please fix and use u-boot-spi.git repo with master-probe branch.
Please test the same on your hw and let me know for any issues.
On Tue, Aug 13, 2013 at 8:15 AM, Asok Subramanian <asok at vyassoft.com> wrote:
> Add code for spi half duplex operation for enc28j60
>
> The current code assumes full duplex spi operation. But there are
> processors like imx23 which
> only permit half duplex operation. This fix does half duplex operation based
> on the definition
> of CONFIG_SPI_HALF_DUPLEX
>
> Signed-off-by: Asok Subramanian <asok at vyassoft.com>
> ---
> drivers/net/enc28j60.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
> index ec33764..753fe26 100644
> --- a/drivers/net/enc28j60.c
> +++ b/drivers/net/enc28j60.c
> @@ -157,9 +157,17 @@ static u8 enc_r8(enc_dev_t *enc, const u16 reg)
>
> enc_set_bank(enc, reg);
> dout[0] = CMD_RCR(reg);
> +#ifndef CONFIG_SPI_HALF_DUPLEX
> spi_xfer(enc->slave, nbytes * 8, dout, din,
> SPI_XFER_BEGIN | SPI_XFER_END);
> return din[nbytes-1];
> +#else
> + spi_xfer(enc->slave, (nbytes -1) * 8, dout, NULL,
> + SPI_XFER_BEGIN );
> + spi_xfer(enc->slave, 8, NULL, din,
> + SPI_XFER_END );
> + return din[0];
> +#endif
> }
>
> /*
> @@ -175,6 +183,7 @@ static u16 enc_r16(enc_dev_t *enc, const u16 reg)
>
> enc_set_bank(enc, reg);
> dout[0] = CMD_RCR(reg);
> +#ifndef CONFIG_SPI_HALF_DUPLEX
> spi_xfer(enc->slave, nbytes * 8, dout, din,
> SPI_XFER_BEGIN | SPI_XFER_END);
> result = din[nbytes-1];
> @@ -183,6 +192,20 @@ static u16 enc_r16(enc_dev_t *enc, const u16 reg)
> SPI_XFER_BEGIN | SPI_XFER_END);
> result |= din[nbytes-1] << 8;
> return result;
> +#else
> + spi_xfer(enc->slave, (nbytes -1) * 8, dout, NULL,
> + SPI_XFER_BEGIN );
> + spi_xfer(enc->slave, 8, NULL, din,
> + SPI_XFER_END );
> + result = din[0];
> + dout[0]++; /* next register */
> + spi_xfer(enc->slave, (nbytes -1) * 8, dout, NULL,
> + SPI_XFER_BEGIN );
> + spi_xfer(enc->slave, 8, NULL, din,
> + SPI_XFER_END );
> + result |= din[0] << 8;
> + return result;
> +#endif
> }
>
> /*
> --
> 1.7.9.5
--
Thanks,
Jagan.
--------
Jagannadha Sutradharudu Teki,
E: jagannadh.teki at gmail.com, P: +91-9676773388
Engineer - System Software Hacker
U-boot - SPI Custodian and Zynq APSOC
Ln: http://www.linkedin.com/in/jaganteki
More information about the U-Boot
mailing list