[U-Boot] [PATCH] andes_spi: add andes_spi interface

Mike Frysinger vapier at gentoo.org
Sat Apr 23 19:07:20 CEST 2011


On Sat, Apr 23, 2011 at 12:34 AM, Macpaul Lin wrote:
>> > +       ds->slave.bus = bus;
>> > +       ds->slave.cs = cs;
>> > +       ds->regs = (struct andes_spi_regs *)CONFIG_SYS_SPI_BASE;
>> > +       ds->freq = max_hz;
>>
>> your spi controller has no frequency limit ?  your spi_claim_bus
>> indicates that there is ...
>
> Hey, it really strange but I couldn't help.  ;p
> According to the hardware datasheet, the only thing related to frequence is
> baudrate.
> But, any value I set to baudrate was no affect.
> It seems that something has done between the hardware itselves.
> I've asked the designer and he said the software coder should not care about
> this.

unfortunately your designer is mistaken.  software must be aware of it
considering SPI slaves often have frequency limits, and board designs
sometimes arent that great.

even looking at the baud setup code, there is math there that overflows.

>> > +static int andes_spi_read(struct spi_slave *slave, unsigned int len,
>> > +                           u8 *rxp, unsigned long flags)
>> > +{
>> > ....
>> > +       while (len > 0) {
>> > +               debug(" ");
>> > +               if (len / 4 > 0)
>> > +                       left = 4;
>> > +               else
>> > +                       left = len;
>>
>> seems like you want:
>> left = max(len, 4);
>
> No. Since the hardware is really designed so strange.

so you want:
left = min(len, 4);
-mike


More information about the U-Boot mailing list