iMX28 SPI max clock rate

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iMX28 SPI max clock rate

866 Views
Matt_
Contributor II

Hello,

linux-2.6.35.3\drivers\spi\spi_mxs.c tries to set the maximum clock rate using the lines

rate = 1000 * ss->speed_khz / ss->divider / hz;

__raw_writel(BF_SSP_TIMING_CLOCK_DIVIDE(ss->divider) |

             BF_SSP_TIMING_CLOCK_RATE(rate - 1),

             ss->regs + HW_SSP_TIMING);

However this should round up the calculated rate variable otherwise the clock is set beyond the rate requested, e.g.

ss->speed_khz = 24000

ss->divider = 2

hz = 7000000  (requesting max rate of 7MHz)

==> rate = 1  (rounded down from 1.7)

==> SPI clock = 24000000 / (2 * (1+0)) = 12000000, i.e. 12MHz

This can be fixed in many ways.  I did

if ((1000 * ss->speed_khz) > (rate * ss->divider * hz))

        rate++; /* round up */

Matt.

Labels (1)
Tags (1)
0 Kudos
1 Reply

441 Views
GraceH
Senior Contributor II

Hi Matt,

Your change is correct. Thanks for your correction.

Grace

0 Kudos