[U-Boot] dm-spi: spi_chip_select value

Jagan Teki jteki at openedev.com
Tue Jun 30 19:48:44 CEST 2015


Hi Simon,

On 27 June 2015 at 04:32, Simon Glass <sjg at chromium.org> wrote:
> Hi Jagan,
>
> On 26 June 2015 at 13:07, Jagan Teki <jteki at openedev.com> wrote:
>> Hi Simon,
>>
>> On 26 June 2015 at 21:23, Simon Glass <sjg at chromium.org> wrote:
>>> Hi Jagan,
>>>
>>> On 23 June 2015 at 15:03, Jagan Teki <jteki at openedev.com> wrote:
>>>> Hi Simon,
>>>>
>>>> I'm calling spi_chip_select(bus) from set_speed or claim_bus
>>>> to get the cs value from sf probe.
>>>>
>>>> Seems like it returns the maximum number as 254, when I debug
>>>> further seems like slave_platdata returns NULL
>>>>
>>>> int spi_chip_select(struct udevice *dev)
>>>> {
>>>>         struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
>>>>         / * this plat data returns NULL */
>>>>
>>>>         return plat ? plat->cs : -ENOENT;
>>>> }
>>>>
>>>
>>> /**
>>>  * spi_chip_select() - Get the chip select for a slave
>>>  *
>>>  * @return the chip select this slave is attached to
>>>  */
>>> int spi_chip_select(struct udevice *slave);
>>>
>>> This function takes a slave device as a parameter, not a bus. Are you
>>> passing it a bus?
>>
>> So as it's a struct udevice - I have passed it from probe and store my cs.
>> Seems like if you get the cs only if we call it from spi_xfer as it's slave
>> is it right?
>
> Both the bus and the slave device are devices, and thus use struct udevice.
>
> I really don't understand what you are asking/saying. Please can you
> try to be more descriptive?

To finding out the cs number in spi driver, I'm trying to use spi_chip_select
from probe, but I couldn't find the valid cs number .

I got the valid cs number only when I call spi_chip_select from xfer(), is that
something like binding is properly done only when xfer() reaches?

>>>> log:
>>>> zynq-uboot> sf probe 1:0
>>>> zynq_spi_ofdata_to_platdata: regs=e0007000 max-frequency=166666700
>>>> zynq_spi_set_speed: cs 254
>>>> zynq_spi_set_speed: regs=e0007000, mode=1000000
>>>> zynq_spi_set_mode: regs=e0007000, mode=3
>>>> zynq_spi_claim_bus: cs 254
>>>> spi_xfer: bus:1 cs:254 bitlen:8 len:1 flags:1
>>>> spi_xfer: Timeout! TX FIFO not full
>>>> SF: Failed to get idcodes
>>>> Failed to initialize SPI flash at 1:0 (error -1)

thanks!
-- 
Jagan | openedev.


More information about the U-Boot mailing list