Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 180882
b: refs/heads/master
c: b0d5d6e
h: refs/heads/master
v: v3
  • Loading branch information
Jassi Brar authored and Grant Likely committed Jan 20, 2010
1 parent 2fbc6c1 commit 59b7fca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 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: ee64a37732c23ab2bcef5fe7785fd237a7e38951
refs/heads/master: b0d5d6e55340348b0de75eb691b93d7e60dba879
36 changes: 17 additions & 19 deletions trunk/drivers/spi/spi_s3c64xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
/**
* struct s3c64xx_spi_driver_data - Runtime info holder for SPI driver.
* @clk: Pointer to the spi clock.
* @src_clk: Pointer to the clock used to generate SPI signals.
* @master: Pointer to the SPI Protocol master.
* @workqueue: Work queue for the SPI xfer requests.
* @cntrlr_info: Platform specific data for the controller this driver manages.
Expand All @@ -157,6 +158,7 @@
struct s3c64xx_spi_driver_data {
void __iomem *regs;
struct clk *clk;
struct clk *src_clk;
struct platform_device *pdev;
struct spi_master *master;
struct workqueue_struct *workqueue;
Expand Down Expand Up @@ -389,7 +391,6 @@ static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd,

static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
{
struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
void __iomem *regs = sdd->regs;
u32 val;

Expand Down Expand Up @@ -435,7 +436,7 @@ static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
/* Configure Clock */
val = readl(regs + S3C64XX_SPI_CLK_CFG);
val &= ~S3C64XX_SPI_PSR_MASK;
val |= ((clk_get_rate(sci->src_clk) / sdd->cur_speed / 2 - 1)
val |= ((clk_get_rate(sdd->src_clk) / sdd->cur_speed / 2 - 1)
& S3C64XX_SPI_PSR_MASK);
writel(val, regs + S3C64XX_SPI_CLK_CFG);

Expand Down Expand Up @@ -831,17 +832,17 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
}

/* Check if we can provide the requested rate */
speed = clk_get_rate(sci->src_clk) / 2 / (0 + 1); /* Max possible */
speed = clk_get_rate(sdd->src_clk) / 2 / (0 + 1); /* Max possible */

if (spi->max_speed_hz > speed)
spi->max_speed_hz = speed;

psr = clk_get_rate(sci->src_clk) / 2 / spi->max_speed_hz - 1;
psr = clk_get_rate(sdd->src_clk) / 2 / spi->max_speed_hz - 1;
psr &= S3C64XX_SPI_PSR_MASK;
if (psr == S3C64XX_SPI_PSR_MASK)
psr--;

speed = clk_get_rate(sci->src_clk) / 2 / (psr + 1);
speed = clk_get_rate(sdd->src_clk) / 2 / (psr + 1);
if (spi->max_speed_hz < speed) {
if (psr+1 < S3C64XX_SPI_PSR_MASK) {
psr++;
Expand All @@ -851,7 +852,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
}
}

speed = clk_get_rate(sci->src_clk) / 2 / (psr + 1);
speed = clk_get_rate(sdd->src_clk) / 2 / (psr + 1);
if (spi->max_speed_hz >= speed)
spi->max_speed_hz = speed;
else
Expand Down Expand Up @@ -1000,15 +1001,15 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
goto err4;
}

sci->src_clk = clk_get(&pdev->dev, sci->src_clk_name);
if (IS_ERR(sci->src_clk)) {
sdd->src_clk = clk_get(&pdev->dev, sci->src_clk_name);
if (IS_ERR(sdd->src_clk)) {
dev_err(&pdev->dev,
"Unable to acquire clock '%s'\n", sci->src_clk_name);
ret = PTR_ERR(sci->src_clk);
ret = PTR_ERR(sdd->src_clk);
goto err5;
}

if (clk_enable(sci->src_clk)) {
if (clk_enable(sdd->src_clk)) {
dev_err(&pdev->dev, "Couldn't enable clock '%s'\n",
sci->src_clk_name);
ret = -EBUSY;
Expand Down Expand Up @@ -1050,9 +1051,9 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
err8:
destroy_workqueue(sdd->workqueue);
err7:
clk_disable(sci->src_clk);
clk_disable(sdd->src_clk);
err6:
clk_put(sci->src_clk);
clk_put(sdd->src_clk);
err5:
clk_disable(sdd->clk);
err4:
Expand All @@ -1073,7 +1074,6 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
{
struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
struct resource *mem_res;
unsigned long flags;

Expand All @@ -1088,8 +1088,8 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)

destroy_workqueue(sdd->workqueue);

clk_disable(sci->src_clk);
clk_put(sci->src_clk);
clk_disable(sdd->src_clk);
clk_put(sdd->src_clk);

clk_disable(sdd->clk);
clk_put(sdd->clk);
Expand All @@ -1110,8 +1110,6 @@ static int s3c64xx_spi_suspend(struct platform_device *pdev, pm_message_t state)
{
struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
struct s3c64xx_spi_csinfo *cs;
unsigned long flags;

spin_lock_irqsave(&sdd->lock, flags);
Expand All @@ -1122,7 +1120,7 @@ static int s3c64xx_spi_suspend(struct platform_device *pdev, pm_message_t state)
msleep(10);

/* Disable the clock */
clk_disable(sci->src_clk);
clk_disable(sdd->src_clk);
clk_disable(sdd->clk);

sdd->cur_speed = 0; /* Output Clock is stopped */
Expand All @@ -1140,7 +1138,7 @@ static int s3c64xx_spi_resume(struct platform_device *pdev)
sci->cfg_gpio(pdev);

/* Enable the clock */
clk_enable(sci->src_clk);
clk_enable(sdd->src_clk);
clk_enable(sdd->clk);

s3c64xx_spi_hwinit(sdd, pdev->id);
Expand Down

0 comments on commit 59b7fca

Please sign in to comment.