iMX28 SPI max clock rate

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

iMX28 SPI max clock rate

1,633件の閲覧回数
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.

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 返信

1,208件の閲覧回数
GraceH
Senior Contributor II

Hi Matt,

Your change is correct. Thanks for your correction.

Grace

0 件の賞賛
返信