Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 198414
b: refs/heads/master
c: 0c2a2ae
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Koeller authored and Grant Likely committed May 25, 2010
1 parent 415c476 commit 484ef1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 41c4221ca6b9db8ea63d2c2323c0e7a8865eba6e
refs/heads/master: 0c2a2ae32793e3500a15a449612485f5d17dd431
12 changes: 9 additions & 3 deletions trunk/drivers/spi/davinci_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
struct davinci_spi *davinci_spi;
struct davinci_spi_platform_data *pdata;
u8 bits_per_word = 0;
u32 hz = 0, prescale;
u32 hz = 0, prescale = 0, clkspeed;

davinci_spi = spi_master_get_devdata(spi->master);
pdata = davinci_spi->pdata;
Expand Down Expand Up @@ -338,10 +338,16 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
set_fmt_bits(davinci_spi->base, bits_per_word & 0x1f,
spi->chip_select);

prescale = ((clk_get_rate(davinci_spi->clk) / hz) - 1) & 0xff;
clkspeed = clk_get_rate(davinci_spi->clk);
if (hz > clkspeed / 2)
prescale = 1 << 8;
if (hz < clkspeed / 256)
prescale = 255 << 8;
if (!prescale)
prescale = ((clkspeed / hz - 1) << 8) & 0x0000ff00;

clear_fmt_bits(davinci_spi->base, 0x0000ff00, spi->chip_select);
set_fmt_bits(davinci_spi->base, prescale << 8, spi->chip_select);
set_fmt_bits(davinci_spi->base, prescale, spi->chip_select);

return 0;
}
Expand Down

0 comments on commit 484ef1c

Please sign in to comment.