diff options
author | Ben Dooks <ben-linux@fluff.org> | 2010-01-19 04:36:04 -0500 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2010-01-19 04:36:04 -0500 |
commit | 9e157144afe81052f5abe122c2469e33a30d20a5 (patch) | |
tree | 167ea8d57d6a8d97edac64f8af744f38a8407a3e | |
parent | 44d6cef805c1b17218723279a2767484e43d6fac (diff) | |
parent | 6a2b4111643127a28944d673995810a82582c5a1 (diff) |
ARM: Merge next-jassi-spi
Merge branch 'next-jassi-spi' into next-samsung-try7
-rw-r--r-- | arch/arm/mach-s3c6400/include/mach/map.h | 2 | ||||
-rw-r--r-- | arch/arm/plat-s3c/include/plat/devs.h | 3 | ||||
-rw-r--r-- | arch/arm/plat-s3c64xx/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/plat-s3c64xx/clock.c | 12 | ||||
-rw-r--r-- | arch/arm/plat-s3c64xx/dev-spi.c | 180 | ||||
-rw-r--r-- | arch/arm/plat-s3c64xx/include/plat/spi-clocks.h | 18 | ||||
-rw-r--r-- | arch/arm/plat-samsung/include/plat/s3c64xx-spi.h | 67 |
7 files changed, 283 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c6400/include/mach/map.h b/arch/arm/mach-s3c6400/include/mach/map.h index 3e17adf3a89b..801c1c0f3a95 100644 --- a/arch/arm/mach-s3c6400/include/mach/map.h +++ b/arch/arm/mach-s3c6400/include/mach/map.h | |||
@@ -64,6 +64,8 @@ | |||
64 | #define S3C64XX_PA_IIS1 (0x7F003000) | 64 | #define S3C64XX_PA_IIS1 (0x7F003000) |
65 | #define S3C64XX_PA_TIMER (0x7F006000) | 65 | #define S3C64XX_PA_TIMER (0x7F006000) |
66 | #define S3C64XX_PA_IIC0 (0x7F004000) | 66 | #define S3C64XX_PA_IIC0 (0x7F004000) |
67 | #define S3C64XX_PA_SPI0 (0x7F00B000) | ||
68 | #define S3C64XX_PA_SPI1 (0x7F00C000) | ||
67 | #define S3C64XX_PA_PCM0 (0x7F009000) | 69 | #define S3C64XX_PA_PCM0 (0x7F009000) |
68 | #define S3C64XX_PA_PCM1 (0x7F00A000) | 70 | #define S3C64XX_PA_PCM1 (0x7F00A000) |
69 | #define S3C64XX_PA_IISV4 (0x7F00D000) | 71 | #define S3C64XX_PA_IISV4 (0x7F00D000) |
diff --git a/arch/arm/plat-s3c/include/plat/devs.h b/arch/arm/plat-s3c/include/plat/devs.h index 8a4153b49f40..f4a7e57bab2b 100644 --- a/arch/arm/plat-s3c/include/plat/devs.h +++ b/arch/arm/plat-s3c/include/plat/devs.h | |||
@@ -29,6 +29,9 @@ extern struct platform_device s3c64xx_device_iis0; | |||
29 | extern struct platform_device s3c64xx_device_iis1; | 29 | extern struct platform_device s3c64xx_device_iis1; |
30 | extern struct platform_device s3c64xx_device_iisv4; | 30 | extern struct platform_device s3c64xx_device_iisv4; |
31 | 31 | ||
32 | extern struct platform_device s3c64xx_device_spi0; | ||
33 | extern struct platform_device s3c64xx_device_spi1; | ||
34 | |||
32 | extern struct platform_device s3c64xx_device_pcm0; | 35 | extern struct platform_device s3c64xx_device_pcm0; |
33 | extern struct platform_device s3c64xx_device_pcm1; | 36 | extern struct platform_device s3c64xx_device_pcm1; |
34 | 37 | ||
diff --git a/arch/arm/plat-s3c64xx/Makefile b/arch/arm/plat-s3c64xx/Makefile index b241f3695560..80255a5e1789 100644 --- a/arch/arm/plat-s3c64xx/Makefile +++ b/arch/arm/plat-s3c64xx/Makefile | |||
@@ -47,3 +47,4 @@ obj-$(CONFIG_S3C64XX_SETUP_I2C1) += setup-i2c1.o | |||
47 | obj-$(CONFIG_S3C64XX_SETUP_FB_24BPP) += setup-fb-24bpp.o | 47 | obj-$(CONFIG_S3C64XX_SETUP_FB_24BPP) += setup-fb-24bpp.o |
48 | obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o | 48 | obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o |
49 | obj-$(CONFIG_SND_S3C24XX_SOC) += dev-audio.o | 49 | obj-$(CONFIG_SND_S3C24XX_SOC) += dev-audio.o |
50 | obj-$(CONFIG_SPI_S3C64XX) += dev-spi.o | ||
diff --git a/arch/arm/plat-s3c64xx/clock.c b/arch/arm/plat-s3c64xx/clock.c index ae5883c00e7a..2989c3a2e94d 100644 --- a/arch/arm/plat-s3c64xx/clock.c +++ b/arch/arm/plat-s3c64xx/clock.c | |||
@@ -141,6 +141,18 @@ static struct clk init_clocks_disable[] = { | |||
141 | .enable = s3c64xx_pclk_ctrl, | 141 | .enable = s3c64xx_pclk_ctrl, |
142 | .ctrlbit = S3C_CLKCON_PCLK_SPI1, | 142 | .ctrlbit = S3C_CLKCON_PCLK_SPI1, |
143 | }, { | 143 | }, { |
144 | .name = "spi_48m", | ||
145 | .id = 0, | ||
146 | .parent = &clk_48m, | ||
147 | .enable = s3c64xx_sclk_ctrl, | ||
148 | .ctrlbit = S3C_CLKCON_SCLK_SPI0_48, | ||
149 | }, { | ||
150 | .name = "spi_48m", | ||
151 | .id = 1, | ||
152 | .parent = &clk_48m, | ||
153 | .enable = s3c64xx_sclk_ctrl, | ||
154 | .ctrlbit = S3C_CLKCON_SCLK_SPI1_48, | ||
155 | }, { | ||
144 | .name = "48m", | 156 | .name = "48m", |
145 | .id = 0, | 157 | .id = 0, |
146 | .parent = &clk_48m, | 158 | .parent = &clk_48m, |
diff --git a/arch/arm/plat-s3c64xx/dev-spi.c b/arch/arm/plat-s3c64xx/dev-spi.c new file mode 100644 index 000000000000..6b6d7af06624 --- /dev/null +++ b/arch/arm/plat-s3c64xx/dev-spi.c | |||
@@ -0,0 +1,180 @@ | |||
1 | /* linux/arch/arm/plat-s3c64xx/dev-spi.c | ||
2 | * | ||
3 | * Copyright (C) 2009 Samsung Electronics Ltd. | ||
4 | * Jaswinder Singh <jassi.brar@samsung.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/string.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/dma-mapping.h> | ||
15 | |||
16 | #include <mach/dma.h> | ||
17 | #include <mach/map.h> | ||
18 | #include <mach/gpio.h> | ||
19 | |||
20 | #include <plat/spi-clocks.h> | ||
21 | #include <plat/s3c64xx-spi.h> | ||
22 | #include <plat/gpio-bank-c.h> | ||
23 | #include <plat/gpio-cfg.h> | ||
24 | #include <plat/irqs.h> | ||
25 | |||
26 | static char *spi_src_clks[] = { | ||
27 | [S3C64XX_SPI_SRCCLK_PCLK] = "pclk", | ||
28 | [S3C64XX_SPI_SRCCLK_SPIBUS] = "spi-bus", | ||
29 | [S3C64XX_SPI_SRCCLK_48M] = "spi_48m", | ||
30 | }; | ||
31 | |||
32 | /* SPI Controller platform_devices */ | ||
33 | |||
34 | /* Since we emulate multi-cs capability, we do not touch the GPC-3,7. | ||
35 | * The emulated CS is toggled by board specific mechanism, as it can | ||
36 | * be either some immediate GPIO or some signal out of some other | ||
37 | * chip in between ... or some yet another way. | ||
38 | * We simply do not assume anything about CS. | ||
39 | */ | ||
40 | static int s3c64xx_spi_cfg_gpio(struct platform_device *pdev) | ||
41 | { | ||
42 | switch (pdev->id) { | ||
43 | case 0: | ||
44 | s3c_gpio_cfgpin(S3C64XX_GPC(0), S3C64XX_GPC0_SPI_MISO0); | ||
45 | s3c_gpio_cfgpin(S3C64XX_GPC(1), S3C64XX_GPC1_SPI_CLKO); | ||
46 | s3c_gpio_cfgpin(S3C64XX_GPC(2), S3C64XX_GPC2_SPI_MOSIO); | ||
47 | s3c_gpio_setpull(S3C64XX_GPC(0), S3C_GPIO_PULL_UP); | ||
48 | s3c_gpio_setpull(S3C64XX_GPC(1), S3C_GPIO_PULL_UP); | ||
49 | s3c_gpio_setpull(S3C64XX_GPC(2), S3C_GPIO_PULL_UP); | ||
50 | break; | ||
51 | |||
52 | case 1: | ||
53 | s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C64XX_GPC4_SPI_MISO1); | ||
54 | s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C64XX_GPC5_SPI_CLK1); | ||
55 | s3c_gpio_cfgpin(S3C64XX_GPC(6), S3C64XX_GPC6_SPI_MOSI1); | ||
56 | s3c_gpio_setpull(S3C64XX_GPC(4), S3C_GPIO_PULL_UP); | ||
57 | s3c_gpio_setpull(S3C64XX_GPC(5), S3C_GPIO_PULL_UP); | ||
58 | s3c_gpio_setpull(S3C64XX_GPC(6), S3C_GPIO_PULL_UP); | ||
59 | break; | ||
60 | |||
61 | default: | ||
62 | dev_err(&pdev->dev, "Invalid SPI Controller number!"); | ||
63 | return -EINVAL; | ||
64 | } | ||
65 | |||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | static struct resource s3c64xx_spi0_resource[] = { | ||
70 | [0] = { | ||
71 | .start = S3C64XX_PA_SPI0, | ||
72 | .end = S3C64XX_PA_SPI0 + 0x100 - 1, | ||
73 | .flags = IORESOURCE_MEM, | ||
74 | }, | ||
75 | [1] = { | ||
76 | .start = DMACH_SPI0_TX, | ||
77 | .end = DMACH_SPI0_TX, | ||
78 | .flags = IORESOURCE_DMA, | ||
79 | }, | ||
80 | [2] = { | ||
81 | .start = DMACH_SPI0_RX, | ||
82 | .end = DMACH_SPI0_RX, | ||
83 | .flags = IORESOURCE_DMA, | ||
84 | }, | ||
85 | [3] = { | ||
86 | .start = IRQ_SPI0, | ||
87 | .end = IRQ_SPI0, | ||
88 | .flags = IORESOURCE_IRQ, | ||
89 | }, | ||
90 | }; | ||
91 | |||
92 | static struct s3c64xx_spi_info s3c64xx_spi0_pdata = { | ||
93 | .cfg_gpio = s3c64xx_spi_cfg_gpio, | ||
94 | .fifo_lvl_mask = 0x7f, | ||
95 | .rx_lvl_offset = 13, | ||
96 | }; | ||
97 | |||
98 | static u64 spi_dmamask = DMA_BIT_MASK(32); | ||
99 | |||
100 | struct platform_device s3c64xx_device_spi0 = { | ||
101 | .name = "s3c64xx-spi", | ||
102 | .id = 0, | ||
103 | .num_resources = ARRAY_SIZE(s3c64xx_spi0_resource), | ||
104 | .resource = s3c64xx_spi0_resource, | ||
105 | .dev = { | ||
106 | .dma_mask = &spi_dmamask, | ||
107 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
108 | .platform_data = &s3c64xx_spi0_pdata, | ||
109 | }, | ||
110 | }; | ||
111 | EXPORT_SYMBOL(s3c64xx_device_spi0); | ||
112 | |||
113 | static struct resource s3c64xx_spi1_resource[] = { | ||
114 | [0] = { | ||
115 | .start = S3C64XX_PA_SPI1, | ||
116 | .end = S3C64XX_PA_SPI1 + 0x100 - 1, | ||
117 | .flags = IORESOURCE_MEM, | ||
118 | }, | ||
119 | [1] = { | ||
120 | .start = DMACH_SPI1_TX, | ||
121 | .end = DMACH_SPI1_TX, | ||
122 | .flags = IORESOURCE_DMA, | ||
123 | }, | ||
124 | [2] = { | ||
125 | .start = DMACH_SPI1_RX, | ||
126 | .end = DMACH_SPI1_RX, | ||
127 | .flags = IORESOURCE_DMA, | ||
128 | }, | ||
129 | [3] = { | ||
130 | .start = IRQ_SPI1, | ||
131 | .end = IRQ_SPI1, | ||
132 | .flags = IORESOURCE_IRQ, | ||
133 | }, | ||
134 | }; | ||
135 | |||
136 | static struct s3c64xx_spi_info s3c64xx_spi1_pdata = { | ||
137 | .cfg_gpio = s3c64xx_spi_cfg_gpio, | ||
138 | .fifo_lvl_mask = 0x7f, | ||
139 | .rx_lvl_offset = 13, | ||
140 | }; | ||
141 | |||
142 | struct platform_device s3c64xx_device_spi1 = { | ||
143 | .name = "s3c64xx-spi", | ||
144 | .id = 1, | ||
145 | .num_resources = ARRAY_SIZE(s3c64xx_spi1_resource), | ||
146 | .resource = s3c64xx_spi1_resource, | ||
147 | .dev = { | ||
148 | .dma_mask = &spi_dmamask, | ||
149 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
150 | .platform_data = &s3c64xx_spi1_pdata, | ||
151 | }, | ||
152 | }; | ||
153 | EXPORT_SYMBOL(s3c64xx_device_spi1); | ||
154 | |||
155 | void __init s3c64xx_spi_set_info(int cntrlr, int src_clk_nr, int num_cs) | ||
156 | { | ||
157 | /* Reject invalid configuration */ | ||
158 | if (!num_cs || src_clk_nr < 0 | ||
159 | || src_clk_nr > S3C64XX_SPI_SRCCLK_48M) { | ||
160 | printk(KERN_ERR "%s: Invalid SPI configuration\n", __func__); | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | switch (cntrlr) { | ||
165 | case 0: | ||
166 | s3c64xx_spi0_pdata.num_cs = num_cs; | ||
167 | s3c64xx_spi0_pdata.src_clk_nr = src_clk_nr; | ||
168 | s3c64xx_spi0_pdata.src_clk_name = spi_src_clks[src_clk_nr]; | ||
169 | break; | ||
170 | case 1: | ||
171 | s3c64xx_spi1_pdata.num_cs = num_cs; | ||
172 | s3c64xx_spi1_pdata.src_clk_nr = src_clk_nr; | ||
173 | s3c64xx_spi1_pdata.src_clk_name = spi_src_clks[src_clk_nr]; | ||
174 | break; | ||
175 | default: | ||
176 | printk(KERN_ERR "%s: Invalid SPI controller(%d)\n", | ||
177 | __func__, cntrlr); | ||
178 | return; | ||
179 | } | ||
180 | } | ||
diff --git a/arch/arm/plat-s3c64xx/include/plat/spi-clocks.h b/arch/arm/plat-s3c64xx/include/plat/spi-clocks.h new file mode 100644 index 000000000000..524bdae3f625 --- /dev/null +++ b/arch/arm/plat-s3c64xx/include/plat/spi-clocks.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* linux/arch/arm/plat-s3c64xx/include/plat/spi-clocks.h | ||
2 | * | ||
3 | * Copyright (C) 2009 Samsung Electronics Ltd. | ||
4 | * Jaswinder Singh <jassi.brar@samsung.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #ifndef __S3C64XX_PLAT_SPI_CLKS_H | ||
12 | #define __S3C64XX_PLAT_SPI_CLKS_H __FILE__ | ||
13 | |||
14 | #define S3C64XX_SPI_SRCCLK_PCLK 0 | ||
15 | #define S3C64XX_SPI_SRCCLK_SPIBUS 1 | ||
16 | #define S3C64XX_SPI_SRCCLK_48M 2 | ||
17 | |||
18 | #endif /* __S3C64XX_PLAT_SPI_CLKS_H */ | ||
diff --git a/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h new file mode 100644 index 000000000000..d17724149315 --- /dev/null +++ b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* linux/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h | ||
2 | * | ||
3 | * Copyright (C) 2009 Samsung Electronics Ltd. | ||
4 | * Jaswinder Singh <jassi.brar@samsung.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #ifndef __S3C64XX_PLAT_SPI_H | ||
12 | #define __S3C64XX_PLAT_SPI_H | ||
13 | |||
14 | /** | ||
15 | * struct s3c64xx_spi_csinfo - ChipSelect description | ||
16 | * @fb_delay: Slave specific feedback delay. | ||
17 | * Refer to FB_CLK_SEL register definition in SPI chapter. | ||
18 | * @line: Custom 'identity' of the CS line. | ||
19 | * @set_level: CS line control. | ||
20 | * | ||
21 | * This is per SPI-Slave Chipselect information. | ||
22 | * Allocate and initialize one in machine init code and make the | ||
23 | * spi_board_info.controller_data point to it. | ||
24 | */ | ||
25 | struct s3c64xx_spi_csinfo { | ||
26 | u8 fb_delay; | ||
27 | unsigned line; | ||
28 | void (*set_level)(unsigned line_id, int lvl); | ||
29 | }; | ||
30 | |||
31 | /** | ||
32 | * struct s3c64xx_spi_info - SPI Controller defining structure | ||
33 | * @src_clk_nr: Clock source index for the CLK_CFG[SPI_CLKSEL] field. | ||
34 | * @src_clk_name: Platform name of the corresponding clock. | ||
35 | * @num_cs: Number of CS this controller emulates. | ||
36 | * @cfg_gpio: Configure pins for this SPI controller. | ||
37 | * @fifo_lvl_mask: All tx fifo_lvl fields start at offset-6 | ||
38 | * @rx_lvl_offset: Depends on tx fifo_lvl field and bus number | ||
39 | * @high_speed: If the controller supports HIGH_SPEED_EN bit | ||
40 | */ | ||
41 | struct s3c64xx_spi_info { | ||
42 | int src_clk_nr; | ||
43 | char *src_clk_name; | ||
44 | |||
45 | int num_cs; | ||
46 | |||
47 | int (*cfg_gpio)(struct platform_device *pdev); | ||
48 | |||
49 | /* Following two fields are for future compatibility */ | ||
50 | int fifo_lvl_mask; | ||
51 | int rx_lvl_offset; | ||
52 | int high_speed; | ||
53 | }; | ||
54 | |||
55 | /** | ||
56 | * s3c64xx_spi_set_info - SPI Controller configure callback by the board | ||
57 | * initialization code. | ||
58 | * @cntrlr: SPI controller number the configuration is for. | ||
59 | * @src_clk_nr: Clock the SPI controller is to use to generate SPI clocks. | ||
60 | * @num_cs: Number of elements in the 'cs' array. | ||
61 | * | ||
62 | * Call this from machine init code for each SPI Controller that | ||
63 | * has some chips attached to it. | ||
64 | */ | ||
65 | extern void s3c64xx_spi_set_info(int cntrlr, int src_clk_nr, int num_cs); | ||
66 | |||
67 | #endif /* __S3C64XX_PLAT_SPI_H */ | ||