ARM: S5PV210: Define SPI platform devices
authorJassi Brar <jassi.brar@samsung.com>
Tue, 18 May 2010 07:43:37 +0000 (16:43 +0900)
committerBen Dooks <ben-linux@fluff.org>
Thu, 20 May 2010 10:31:10 +0000 (19:31 +0900)
Define SPI platform devices for the SoC.

Signed-off-by: Jassi Brar <jassi.brar@samsung.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
arch/arm/mach-s5pv210/Makefile
arch/arm/mach-s5pv210/dev-spi.c [new file with mode: 0644]
arch/arm/mach-s5pv210/include/mach/map.h
arch/arm/mach-s5pv210/include/mach/spi-clocks.h [new file with mode: 0644]
arch/arm/plat-samsung/include/plat/devs.h
arch/arm/plat-samsung/include/plat/s3c64xx-spi.h

index 99827813d293afc96b545aac1b6cffcf5f43524b..ba0d7091343b2675cea15d3f4582e3f206c958f7 100644 (file)
@@ -23,3 +23,4 @@ obj-$(CONFIG_MACH_SMDKC110)   += mach-smdkc110.o
 # device support
 
 obj-y                          += dev-audio.o
+obj-$(CONFIG_S3C64XX_DEV_SPI)  += dev-spi.o
diff --git a/arch/arm/mach-s5pv210/dev-spi.c b/arch/arm/mach-s5pv210/dev-spi.c
new file mode 100644 (file)
index 0000000..337a62b
--- /dev/null
@@ -0,0 +1,178 @@
+/* linux/arch/arm/mach-s5pv210/dev-spi.c
+ *
+ * Copyright (C) 2010 Samsung Electronics Co. Ltd.
+ *     Jaswinder Singh <jassi.brar@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+
+#include <mach/dma.h>
+#include <mach/map.h>
+#include <mach/irqs.h>
+#include <mach/gpio.h>
+#include <mach/spi-clocks.h>
+
+#include <plat/s3c64xx-spi.h>
+#include <plat/gpio-cfg.h>
+
+static char *spi_src_clks[] = {
+       [S5PV210_SPI_SRCCLK_PCLK] = "pclk",
+       [S5PV210_SPI_SRCCLK_SCLK] = "sclk_spi",
+};
+
+/* SPI Controller platform_devices */
+
+/* Since we emulate multi-cs capability, we do not touch the CS.
+ * The emulated CS is toggled by board specific mechanism, as it can
+ * be either some immediate GPIO or some signal out of some other
+ * chip in between ... or some yet another way.
+ * We simply do not assume anything about CS.
+ */
+static int s5pv210_spi_cfg_gpio(struct platform_device *pdev)
+{
+       switch (pdev->id) {
+       case 0:
+               s3c_gpio_cfgpin(S5PV210_GPB(0), S3C_GPIO_SFN(2));
+               s3c_gpio_cfgpin(S5PV210_GPB(1), S3C_GPIO_SFN(2));
+               s3c_gpio_cfgpin(S5PV210_GPB(2), S3C_GPIO_SFN(2));
+               s3c_gpio_setpull(S5PV210_GPB(0), S3C_GPIO_PULL_UP);
+               s3c_gpio_setpull(S5PV210_GPB(1), S3C_GPIO_PULL_UP);
+               s3c_gpio_setpull(S5PV210_GPB(2), S3C_GPIO_PULL_UP);
+               break;
+
+       case 1:
+               s3c_gpio_cfgpin(S5PV210_GPB(4), S3C_GPIO_SFN(2));
+               s3c_gpio_cfgpin(S5PV210_GPB(5), S3C_GPIO_SFN(2));
+               s3c_gpio_cfgpin(S5PV210_GPB(6), S3C_GPIO_SFN(2));
+               s3c_gpio_setpull(S5PV210_GPB(4), S3C_GPIO_PULL_UP);
+               s3c_gpio_setpull(S5PV210_GPB(5), S3C_GPIO_PULL_UP);
+               s3c_gpio_setpull(S5PV210_GPB(6), S3C_GPIO_PULL_UP);
+               break;
+
+       default:
+               dev_err(&pdev->dev, "Invalid SPI Controller number!");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static struct resource s5pv210_spi0_resource[] = {
+       [0] = {
+               .start = S5PV210_PA_SPI0,
+               .end   = S5PV210_PA_SPI0 + 0x100 - 1,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = DMACH_SPI0_TX,
+               .end   = DMACH_SPI0_TX,
+               .flags = IORESOURCE_DMA,
+       },
+       [2] = {
+               .start = DMACH_SPI0_RX,
+               .end   = DMACH_SPI0_RX,
+               .flags = IORESOURCE_DMA,
+       },
+       [3] = {
+               .start = IRQ_SPI0,
+               .end   = IRQ_SPI0,
+               .flags = IORESOURCE_IRQ,
+       },
+};
+
+static struct s3c64xx_spi_info s5pv210_spi0_pdata = {
+       .cfg_gpio = s5pv210_spi_cfg_gpio,
+       .fifo_lvl_mask = 0x1ff,
+       .rx_lvl_offset = 15,
+       .high_speed = 1,
+};
+
+static u64 spi_dmamask = DMA_BIT_MASK(32);
+
+struct platform_device s5pv210_device_spi0 = {
+       .name             = "s3c64xx-spi",
+       .id               = 0,
+       .num_resources    = ARRAY_SIZE(s5pv210_spi0_resource),
+       .resource         = s5pv210_spi0_resource,
+       .dev = {
+               .dma_mask               = &spi_dmamask,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
+               .platform_data = &s5pv210_spi0_pdata,
+       },
+};
+
+static struct resource s5pv210_spi1_resource[] = {
+       [0] = {
+               .start = S5PV210_PA_SPI1,
+               .end   = S5PV210_PA_SPI1 + 0x100 - 1,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = DMACH_SPI1_TX,
+               .end   = DMACH_SPI1_TX,
+               .flags = IORESOURCE_DMA,
+       },
+       [2] = {
+               .start = DMACH_SPI1_RX,
+               .end   = DMACH_SPI1_RX,
+               .flags = IORESOURCE_DMA,
+       },
+       [3] = {
+               .start = IRQ_SPI1,
+               .end   = IRQ_SPI1,
+               .flags = IORESOURCE_IRQ,
+       },
+};
+
+static struct s3c64xx_spi_info s5pv210_spi1_pdata = {
+       .cfg_gpio = s5pv210_spi_cfg_gpio,
+       .fifo_lvl_mask = 0x7f,
+       .rx_lvl_offset = 15,
+       .high_speed = 1,
+};
+
+struct platform_device s5pv210_device_spi1 = {
+       .name             = "s3c64xx-spi",
+       .id               = 1,
+       .num_resources    = ARRAY_SIZE(s5pv210_spi1_resource),
+       .resource         = s5pv210_spi1_resource,
+       .dev = {
+               .dma_mask               = &spi_dmamask,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
+               .platform_data = &s5pv210_spi1_pdata,
+       },
+};
+
+void __init s5pv210_spi_set_info(int cntrlr, int src_clk_nr, int num_cs)
+{
+       struct s3c64xx_spi_info *pd;
+
+       /* Reject invalid configuration */
+       if (!num_cs || src_clk_nr < 0
+                       || src_clk_nr > S5PV210_SPI_SRCCLK_SCLK) {
+               printk(KERN_ERR "%s: Invalid SPI configuration\n", __func__);
+               return;
+       }
+
+       switch (cntrlr) {
+       case 0:
+               pd = &s5pv210_spi0_pdata;
+               break;
+       case 1:
+               pd = &s5pv210_spi1_pdata;
+               break;
+       default:
+               printk(KERN_ERR "%s: Invalid SPI controller(%d)\n",
+                                                       __func__, cntrlr);
+               return;
+       }
+
+       pd->num_cs = num_cs;
+       pd->src_clk_nr = src_clk_nr;
+       pd->src_clk_name = spi_src_clks[src_clk_nr];
+}
index 5adcb9f26e449ef76504b10244cbd3570fb710dc..9ab0069d1a7e1a34c4d4c28a886051d48901c325 100644 (file)
 #define S5PV210_PA_GPIO                (0xE0200000)
 #define S5P_PA_GPIO            S5PV210_PA_GPIO
 
+/* SPI */
+#define S5PV210_PA_SPI0                0xE1300000
+#define S5PV210_PA_SPI1                0xE1400000
+
 #define S5PV210_PA_IIC0                (0xE1800000)
 
 #define S5PV210_PA_TIMER       (0xE2500000)
diff --git a/arch/arm/mach-s5pv210/include/mach/spi-clocks.h b/arch/arm/mach-s5pv210/include/mach/spi-clocks.h
new file mode 100644 (file)
index 0000000..02acded
--- /dev/null
@@ -0,0 +1,17 @@
+/* linux/arch/arm/mach-s5pv210/include/mach/spi-clocks.h
+ *
+ * Copyright (C) 2010 Samsung Electronics Co. Ltd.
+ *     Jaswinder Singh <jassi.brar@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __S5PV210_PLAT_SPI_CLKS_H
+#define __S5PV210_PLAT_SPI_CLKS_H __FILE__
+
+#define S5PV210_SPI_SRCCLK_PCLK                0
+#define S5PV210_SPI_SRCCLK_SCLK                1
+
+#endif /* __S5PV210_PLAT_SPI_CLKS_H */
index 1fe83b7b2c35ad76a1e2c358c14a0c297e84e386..350a71b0954dfc97892508a248460d2a8b3ba351 100644 (file)
@@ -60,6 +60,8 @@ extern struct platform_device s3c_device_spi1;
 extern struct platform_device s5pc100_device_spi0;
 extern struct platform_device s5pc100_device_spi1;
 extern struct platform_device s5pc100_device_spi2;
+extern struct platform_device s5pv210_device_spi0;
+extern struct platform_device s5pv210_device_spi1;
 
 extern struct platform_device s3c_device_hwmon;
 
index 49ba71f0f9e5642798ae9c5669dd0e9acf36fa15..fdb40c38282323cba0c69dec621ed81a270a90ed 100644 (file)
@@ -64,5 +64,6 @@ struct s3c64xx_spi_info {
  */
 extern void s3c64xx_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
 extern void s5pc100_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
+extern void s5pv210_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
 
 #endif /* __S3C64XX_PLAT_SPI_H */