Quantcast
Viewing all articles
Browse latest Browse all 18089

Re: Sources for /dev/spidev5.1 and what it calls

I may be barking up some wrong trees, but my guess is after my bitbake, the main code associated with SPI is in the directory:

/home/kurt/edison-src/build/tmp/work/edison-poky-linux/linux-yocto/3.10.17+gitAUTOINC+6ad20f049a_c03195ed6e-r0/linux/drivers/spi)

 

There are a couple of driver files I think are involved:

spidev.c - which is what is handling our calls.

intel_mod_ssp_spi.c - Which I think spidev is calling off to for at least some stuff.

if ((sspc->quirks & QUIRKS_SPI_SLAVE_CLOCK_MODE) == 0) {

  

clk_div = ssp_get_clk_div(sspc, spi->max_speed_hz);

  

chip->cr0 |= (clk_div & 0xFFF) << 8;

  

spi->max_speed_hz = ssp_get_speed(sspc, clk_div);

  

chip->speed_hz = spi->max_speed_hz;

  

dev_dbg(&spi->dev, "spi->max_speed_hz:%d clk_div:%x cr0:%x",

  

spi->max_speed_hz, clk_div, chip->cr0);

    }

 

 

 

And if you look at the two functions:

static unsigned int ssp_get_clk_div(struct ssp_drv_context *sspc, int speed)

{

    /* The clock divider shall stay between 3 and 4095 as specified in TRM. */

    if (sspc->quirks & QUIRKS_PLATFORM_MRFL)

        return clamp(25000000 / speed - 1, 3, 4095);

    else

        return clamp(100000000 / speed - 1, 3, 4095);

}

 

 

static int ssp_get_speed(struct ssp_drv_context *sspc, int clk_div)

{

    if (sspc->quirks & QUIRKS_PLATFORM_MRFL)

        return 25000000 / (clk_div + 1);

    else

        return 100000000 / (clk_div + 1);

}

 

Sorry about formating above, need to figure out how to properly paste code in...

But looking at these two functions: if I pass in 8000000 for speed, the first function, will divide 25000000/8000000 -1 = 2, but then clamp it up to a 3.  Then it calls off to the second function with the 3 which sets the max speed to 25000000/4 = 6.25mhz which is what we are seeing...


Viewing all articles
Browse latest Browse all 18089

Trending Articles