Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fixes
[pandora-kernel.git] / drivers / spi / spi_s3c24xx.c
index 34bfb7d..89da39f 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <asm/io.h>
 #include <asm/dma.h>
-#include <asm/hardware.h>
+#include <asm/arch/hardware.h>
 
 #include <asm/arch/regs-gpio.h>
 #include <asm/plat-s3c24xx/regs-spi.h>
@@ -125,10 +125,10 @@ static int s3c24xx_spi_setupxfer(struct spi_device *spi,
        /* is clk = pclk / (2 * (pre+1)), or is it
         *    clk = (pclk * 2) / ( pre + 1) */
 
-       div = (div / 2) - 1;
+       div /= 2;
 
-       if (div < 0)
-               div = 1;
+       if (div > 0)
+               div -= 1;
 
        if (div > 255)
                div = 255;
@@ -236,6 +236,19 @@ static irqreturn_t s3c24xx_spi_irq(int irq, void *dev)
        return IRQ_HANDLED;
 }
 
+static void s3c24xx_spi_initialsetup(struct s3c24xx_spi *hw)
+{
+       /* for the moment, permanently enable the clock */
+
+       clk_enable(hw->clk);
+
+       /* program defaults into the registers */
+
+       writeb(0xff, hw->regs + S3C2410_SPPRE);
+       writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN);
+       writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON);
+}
+
 static int __init s3c24xx_spi_probe(struct platform_device *pdev)
 {
        struct s3c2410_spi_info *pdata;
@@ -270,6 +283,7 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
        /* setup the master state. */
 
        master->num_chipselect = hw->pdata->num_cs;
+       master->bus_num = pdata->bus_num;
 
        /* setup the state for the bitbang driver */
 
@@ -326,15 +340,7 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
                goto err_no_clk;
        }
 
-       /* for the moment, permanently enable the clock */
-
-       clk_enable(hw->clk);
-
-       /* program defaults into the registers */
-
-       writeb(0xff, hw->regs + S3C2410_SPPRE);
-       writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN);
-       writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON);
+       s3c24xx_spi_initialsetup(hw);
 
        /* setup any gpio we can */
 
@@ -414,7 +420,7 @@ static int s3c24xx_spi_resume(struct platform_device *pdev)
 {
        struct s3c24xx_spi *hw = platform_get_drvdata(pdev);
 
-       clk_enable(hw->clk);
+       s3c24xx_spi_initialsetup(hw);
        return 0;
 }