[U-Boot] Add code for spi half duplex operation for enc28j60

Submitted by Asok Subramanian on Aug. 13, 2013, 2:45 a.m.

Details

Message ID 1376361904.43180.YahooMailNeo@web2805.biz.mail.ne1.yahoo.com
State Rejected
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Asok Subramanian Aug. 13, 2013, 2:45 a.m.
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(+)

Comments

Jagannadha Sutradharudu Teki Oct. 4, 2013, 11:13 a.m.
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@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
Jagannadha Sutradharudu Teki Dec. 20, 2013, 7:10 p.m.
On Fri, Oct 4, 2013 at 4:43 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> 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@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
>>  }
>>
>>  /*
>> --
Ping
Jagannadha Sutradharudu Teki Jan. 8, 2014, 10:36 a.m.
On Sat, Dec 21, 2013 at 12:40 AM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> On Fri, Oct 4, 2013 at 4:43 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
>> 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@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
>>>  }
>>>
>>>  /*
>>> --
> Ping

Ping.!

Patch hide | download patch | download mbox

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
 }
 
 /*