Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 156928
b: refs/heads/master
c: b897878
h: refs/heads/master
v: v3
  • Loading branch information
Ben Dooks authored and Linus Torvalds committed Aug 18, 2009
1 parent 24e2f77 commit 9415237
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 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: b2503a9408e44eb0531adc3436c513ea70f91c42
refs/heads/master: b8978784544e8b4e8fbacb558df8580957d4f8a5
17 changes: 7 additions & 10 deletions trunk/drivers/spi/spi_s3c24xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static int s3c24xx_spi_setupxfer(struct spi_device *spi,
unsigned int bpw;
unsigned int hz;
unsigned int div;
unsigned long clk;

bpw = t ? t->bits_per_word : spi->bits_per_word;
hz = t ? t->speed_hz : spi->max_speed_hz;
Expand All @@ -120,20 +121,16 @@ static int s3c24xx_spi_setupxfer(struct spi_device *spi,
return -EINVAL;
}

div = clk_get_rate(hw->clk) / hz;

/* is clk = pclk / (2 * (pre+1)), or is it
* clk = (pclk * 2) / ( pre + 1) */

div /= 2;

if (div > 0)
div -= 1;
clk = clk_get_rate(hw->clk);
div = DIV_ROUND_UP(clk, hz * 2) - 1;

if (div > 255)
div = 255;

dev_dbg(&spi->dev, "setting pre-scaler to %d (hz %d)\n", div, hz);
dev_dbg(&spi->dev, "setting pre-scaler to %d (wanted %d, got %ld)\n",
div, hz, clk / (2 * (div + 1)));


writeb(div, hw->regs + S3C2410_SPPRE);

spin_lock(&hw->bitbang.lock);
Expand Down

0 comments on commit 9415237

Please sign in to comment.