diff options
Diffstat (limited to 'arch/arm/plat-samsung')
23 files changed, 636 insertions, 2187 deletions
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig index b3e10659e4b8..74714c155e14 100644 --- a/arch/arm/plat-samsung/Kconfig +++ b/arch/arm/plat-samsung/Kconfig | |||
@@ -79,39 +79,12 @@ config SAMSUNG_GPIOLIB_4BIT | |||
79 | configuration. GPIOlib shall be compiled only for S3C64XX and S5P | 79 | configuration. GPIOlib shall be compiled only for S3C64XX and S5P |
80 | series of processors. | 80 | series of processors. |
81 | 81 | ||
82 | config S3C_GPIO_CFG_S3C24XX | ||
83 | bool | ||
84 | help | ||
85 | Internal configuration to enable S3C24XX style GPIO configuration | ||
86 | functions. | ||
87 | |||
88 | config S3C_GPIO_CFG_S3C64XX | 82 | config S3C_GPIO_CFG_S3C64XX |
89 | bool | 83 | bool |
90 | help | 84 | help |
91 | Internal configuration to enable S3C64XX style GPIO configuration | 85 | Internal configuration to enable S3C64XX style GPIO configuration |
92 | functions. | 86 | functions. |
93 | 87 | ||
94 | config S3C_GPIO_PULL_UPDOWN | ||
95 | bool | ||
96 | help | ||
97 | Internal configuration to enable the correct GPIO pull helper | ||
98 | |||
99 | config S3C_GPIO_PULL_S3C2443 | ||
100 | bool | ||
101 | select S3C_GPIO_PULL_UPDOWN | ||
102 | help | ||
103 | Internal configuration to enable the correct GPIO pull helper for S3C2443-style GPIO | ||
104 | |||
105 | config S3C_GPIO_PULL_DOWN | ||
106 | bool | ||
107 | help | ||
108 | Internal configuration to enable the correct GPIO pull helper | ||
109 | |||
110 | config S3C_GPIO_PULL_UP | ||
111 | bool | ||
112 | help | ||
113 | Internal configuration to enable the correct GPIO pull helper | ||
114 | |||
115 | config S5P_GPIO_DRVSTR | 88 | config S5P_GPIO_DRVSTR |
116 | bool | 89 | bool |
117 | help | 90 | help |
@@ -300,11 +273,14 @@ config S3C_DMA | |||
300 | help | 273 | help |
301 | Internal configuration for S3C DMA core | 274 | Internal configuration for S3C DMA core |
302 | 275 | ||
303 | config S3C_PL330_DMA | 276 | config SAMSUNG_DMADEV |
304 | bool | 277 | bool |
305 | select PL330 | 278 | select DMADEVICES |
279 | select PL330_DMA if (CPU_EXYNOS4210 || CPU_S5PV210 || CPU_S5PC100 || \ | ||
280 | CPU_S5P6450 || CPU_S5P6440) | ||
281 | select ARM_AMBA | ||
306 | help | 282 | help |
307 | S3C DMA API Driver for PL330 DMAC. | 283 | Use DMA device engine for PL330 DMAC. |
308 | 284 | ||
309 | comment "Power management" | 285 | comment "Power management" |
310 | 286 | ||
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile index 3de756da5eaa..5a5435482595 100644 --- a/arch/arm/plat-samsung/Makefile +++ b/arch/arm/plat-samsung/Makefile | |||
@@ -15,8 +15,6 @@ obj-y += init.o cpu.o | |||
15 | obj-$(CONFIG_ARCH_USES_GETTIMEOFFSET) += time.o | 15 | obj-$(CONFIG_ARCH_USES_GETTIMEOFFSET) += time.o |
16 | obj-y += clock.o | 16 | obj-y += clock.o |
17 | obj-y += pwm-clock.o | 17 | obj-y += pwm-clock.o |
18 | obj-y += gpio.o | ||
19 | obj-y += gpio-config.o | ||
20 | obj-y += dev-asocdma.o | 18 | obj-y += dev-asocdma.o |
21 | 19 | ||
22 | obj-$(CONFIG_SAMSUNG_CLKSRC) += clock-clksrc.o | 20 | obj-$(CONFIG_SAMSUNG_CLKSRC) += clock-clksrc.o |
@@ -63,9 +61,9 @@ obj-$(CONFIG_SAMSUNG_DEV_BACKLIGHT) += dev-backlight.o | |||
63 | 61 | ||
64 | # DMA support | 62 | # DMA support |
65 | 63 | ||
66 | obj-$(CONFIG_S3C_DMA) += dma.o | 64 | obj-$(CONFIG_S3C_DMA) += dma.o s3c-dma-ops.o |
67 | 65 | ||
68 | obj-$(CONFIG_S3C_PL330_DMA) += s3c-pl330.o | 66 | obj-$(CONFIG_SAMSUNG_DMADEV) += dma-ops.o |
69 | 67 | ||
70 | # PM support | 68 | # PM support |
71 | 69 | ||
diff --git a/arch/arm/plat-samsung/dma-ops.c b/arch/arm/plat-samsung/dma-ops.c new file mode 100644 index 000000000000..6e3d9abc9e2e --- /dev/null +++ b/arch/arm/plat-samsung/dma-ops.c | |||
@@ -0,0 +1,131 @@ | |||
1 | /* linux/arch/arm/plat-samsung/dma-ops.c | ||
2 | * | ||
3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * Samsung DMA Operations | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/amba/pl330.h> | ||
16 | #include <linux/scatterlist.h> | ||
17 | |||
18 | #include <mach/dma.h> | ||
19 | |||
20 | static inline bool pl330_filter(struct dma_chan *chan, void *param) | ||
21 | { | ||
22 | struct dma_pl330_peri *peri = chan->private; | ||
23 | return peri->peri_id == (unsigned)param; | ||
24 | } | ||
25 | |||
26 | static unsigned samsung_dmadev_request(enum dma_ch dma_ch, | ||
27 | struct samsung_dma_info *info) | ||
28 | { | ||
29 | struct dma_chan *chan; | ||
30 | dma_cap_mask_t mask; | ||
31 | struct dma_slave_config slave_config; | ||
32 | |||
33 | dma_cap_zero(mask); | ||
34 | dma_cap_set(info->cap, mask); | ||
35 | |||
36 | chan = dma_request_channel(mask, pl330_filter, (void *)dma_ch); | ||
37 | |||
38 | if (info->direction == DMA_FROM_DEVICE) { | ||
39 | memset(&slave_config, 0, sizeof(struct dma_slave_config)); | ||
40 | slave_config.direction = info->direction; | ||
41 | slave_config.src_addr = info->fifo; | ||
42 | slave_config.src_addr_width = info->width; | ||
43 | slave_config.src_maxburst = 1; | ||
44 | dmaengine_slave_config(chan, &slave_config); | ||
45 | } else if (info->direction == DMA_TO_DEVICE) { | ||
46 | memset(&slave_config, 0, sizeof(struct dma_slave_config)); | ||
47 | slave_config.direction = info->direction; | ||
48 | slave_config.dst_addr = info->fifo; | ||
49 | slave_config.dst_addr_width = info->width; | ||
50 | slave_config.dst_maxburst = 1; | ||
51 | dmaengine_slave_config(chan, &slave_config); | ||
52 | } | ||
53 | |||
54 | return (unsigned)chan; | ||
55 | } | ||
56 | |||
57 | static int samsung_dmadev_release(unsigned ch, | ||
58 | struct s3c2410_dma_client *client) | ||
59 | { | ||
60 | dma_release_channel((struct dma_chan *)ch); | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static int samsung_dmadev_prepare(unsigned ch, | ||
66 | struct samsung_dma_prep_info *info) | ||
67 | { | ||
68 | struct scatterlist sg; | ||
69 | struct dma_chan *chan = (struct dma_chan *)ch; | ||
70 | struct dma_async_tx_descriptor *desc; | ||
71 | |||
72 | switch (info->cap) { | ||
73 | case DMA_SLAVE: | ||
74 | sg_init_table(&sg, 1); | ||
75 | sg_dma_len(&sg) = info->len; | ||
76 | sg_set_page(&sg, pfn_to_page(PFN_DOWN(info->buf)), | ||
77 | info->len, offset_in_page(info->buf)); | ||
78 | sg_dma_address(&sg) = info->buf; | ||
79 | |||
80 | desc = chan->device->device_prep_slave_sg(chan, | ||
81 | &sg, 1, info->direction, DMA_PREP_INTERRUPT); | ||
82 | break; | ||
83 | case DMA_CYCLIC: | ||
84 | desc = chan->device->device_prep_dma_cyclic(chan, | ||
85 | info->buf, info->len, info->period, info->direction); | ||
86 | break; | ||
87 | default: | ||
88 | dev_err(&chan->dev->device, "unsupported format\n"); | ||
89 | return -EFAULT; | ||
90 | } | ||
91 | |||
92 | if (!desc) { | ||
93 | dev_err(&chan->dev->device, "cannot prepare cyclic dma\n"); | ||
94 | return -EFAULT; | ||
95 | } | ||
96 | |||
97 | desc->callback = info->fp; | ||
98 | desc->callback_param = info->fp_param; | ||
99 | |||
100 | dmaengine_submit((struct dma_async_tx_descriptor *)desc); | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static inline int samsung_dmadev_trigger(unsigned ch) | ||
106 | { | ||
107 | dma_async_issue_pending((struct dma_chan *)ch); | ||
108 | |||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | static inline int samsung_dmadev_flush(unsigned ch) | ||
113 | { | ||
114 | return dmaengine_terminate_all((struct dma_chan *)ch); | ||
115 | } | ||
116 | |||
117 | struct samsung_dma_ops dmadev_ops = { | ||
118 | .request = samsung_dmadev_request, | ||
119 | .release = samsung_dmadev_release, | ||
120 | .prepare = samsung_dmadev_prepare, | ||
121 | .trigger = samsung_dmadev_trigger, | ||
122 | .started = NULL, | ||
123 | .flush = samsung_dmadev_flush, | ||
124 | .stop = samsung_dmadev_flush, | ||
125 | }; | ||
126 | |||
127 | void *samsung_dmadev_get_ops(void) | ||
128 | { | ||
129 | return &dmadev_ops; | ||
130 | } | ||
131 | EXPORT_SYMBOL(samsung_dmadev_get_ops); | ||
diff --git a/arch/arm/plat-samsung/gpio-config.c b/arch/arm/plat-samsung/gpio-config.c deleted file mode 100644 index 1c0b0401594b..000000000000 --- a/arch/arm/plat-samsung/gpio-config.c +++ /dev/null | |||
@@ -1,431 +0,0 @@ | |||
1 | /* linux/arch/arm/plat-s3c/gpio-config.c | ||
2 | * | ||
3 | * Copyright 2008 Openmoko, Inc. | ||
4 | * Copyright 2008-2010 Simtec Electronics | ||
5 | * Ben Dooks <ben@simtec.co.uk> | ||
6 | * http://armlinux.simtec.co.uk/ | ||
7 | * | ||
8 | * S3C series GPIO configuration core | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/gpio.h> | ||
18 | #include <linux/io.h> | ||
19 | |||
20 | #include <plat/gpio-core.h> | ||
21 | #include <plat/gpio-cfg.h> | ||
22 | #include <plat/gpio-cfg-helpers.h> | ||
23 | |||
24 | int s3c_gpio_cfgpin(unsigned int pin, unsigned int config) | ||
25 | { | ||
26 | struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); | ||
27 | unsigned long flags; | ||
28 | int offset; | ||
29 | int ret; | ||
30 | |||
31 | if (!chip) | ||
32 | return -EINVAL; | ||
33 | |||
34 | offset = pin - chip->chip.base; | ||
35 | |||
36 | s3c_gpio_lock(chip, flags); | ||
37 | ret = s3c_gpio_do_setcfg(chip, offset, config); | ||
38 | s3c_gpio_unlock(chip, flags); | ||
39 | |||
40 | return ret; | ||
41 | } | ||
42 | EXPORT_SYMBOL(s3c_gpio_cfgpin); | ||
43 | |||
44 | int s3c_gpio_cfgpin_range(unsigned int start, unsigned int nr, | ||
45 | unsigned int cfg) | ||
46 | { | ||
47 | int ret; | ||
48 | |||
49 | for (; nr > 0; nr--, start++) { | ||
50 | ret = s3c_gpio_cfgpin(start, cfg); | ||
51 | if (ret != 0) | ||
52 | return ret; | ||
53 | } | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | EXPORT_SYMBOL_GPL(s3c_gpio_cfgpin_range); | ||
58 | |||
59 | int s3c_gpio_cfgall_range(unsigned int start, unsigned int nr, | ||
60 | unsigned int cfg, s3c_gpio_pull_t pull) | ||
61 | { | ||
62 | int ret; | ||
63 | |||
64 | for (; nr > 0; nr--, start++) { | ||
65 | s3c_gpio_setpull(start, pull); | ||
66 | ret = s3c_gpio_cfgpin(start, cfg); | ||
67 | if (ret != 0) | ||
68 | return ret; | ||
69 | } | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | EXPORT_SYMBOL_GPL(s3c_gpio_cfgall_range); | ||
74 | |||
75 | unsigned s3c_gpio_getcfg(unsigned int pin) | ||
76 | { | ||
77 | struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); | ||
78 | unsigned long flags; | ||
79 | unsigned ret = 0; | ||
80 | int offset; | ||
81 | |||
82 | if (chip) { | ||
83 | offset = pin - chip->chip.base; | ||
84 | |||
85 | s3c_gpio_lock(chip, flags); | ||
86 | ret = s3c_gpio_do_getcfg(chip, offset); | ||
87 | s3c_gpio_unlock(chip, flags); | ||
88 | } | ||
89 | |||
90 | return ret; | ||
91 | } | ||
92 | EXPORT_SYMBOL(s3c_gpio_getcfg); | ||
93 | |||
94 | |||
95 | int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull) | ||
96 | { | ||
97 | struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); | ||
98 | unsigned long flags; | ||
99 | int offset, ret; | ||
100 | |||
101 | if (!chip) | ||
102 | return -EINVAL; | ||
103 | |||
104 | offset = pin - chip->chip.base; | ||
105 | |||
106 | s3c_gpio_lock(chip, flags); | ||
107 | ret = s3c_gpio_do_setpull(chip, offset, pull); | ||
108 | s3c_gpio_unlock(chip, flags); | ||
109 | |||
110 | return ret; | ||
111 | } | ||
112 | EXPORT_SYMBOL(s3c_gpio_setpull); | ||
113 | |||
114 | s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin) | ||
115 | { | ||
116 | struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); | ||
117 | unsigned long flags; | ||
118 | int offset; | ||
119 | u32 pup = 0; | ||
120 | |||
121 | if (chip) { | ||
122 | offset = pin - chip->chip.base; | ||
123 | |||
124 | s3c_gpio_lock(chip, flags); | ||
125 | pup = s3c_gpio_do_getpull(chip, offset); | ||
126 | s3c_gpio_unlock(chip, flags); | ||
127 | } | ||
128 | |||
129 | return (__force s3c_gpio_pull_t)pup; | ||
130 | } | ||
131 | EXPORT_SYMBOL(s3c_gpio_getpull); | ||
132 | |||
133 | #ifdef CONFIG_S3C_GPIO_CFG_S3C24XX | ||
134 | int s3c_gpio_setcfg_s3c24xx_a(struct s3c_gpio_chip *chip, | ||
135 | unsigned int off, unsigned int cfg) | ||
136 | { | ||
137 | void __iomem *reg = chip->base; | ||
138 | unsigned int shift = off; | ||
139 | u32 con; | ||
140 | |||
141 | if (s3c_gpio_is_cfg_special(cfg)) { | ||
142 | cfg &= 0xf; | ||
143 | |||
144 | /* Map output to 0, and SFN2 to 1 */ | ||
145 | cfg -= 1; | ||
146 | if (cfg > 1) | ||
147 | return -EINVAL; | ||
148 | |||
149 | cfg <<= shift; | ||
150 | } | ||
151 | |||
152 | con = __raw_readl(reg); | ||
153 | con &= ~(0x1 << shift); | ||
154 | con |= cfg; | ||
155 | __raw_writel(con, reg); | ||
156 | |||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | unsigned s3c_gpio_getcfg_s3c24xx_a(struct s3c_gpio_chip *chip, | ||
161 | unsigned int off) | ||
162 | { | ||
163 | u32 con; | ||
164 | |||
165 | con = __raw_readl(chip->base); | ||
166 | con >>= off; | ||
167 | con &= 1; | ||
168 | con++; | ||
169 | |||
170 | return S3C_GPIO_SFN(con); | ||
171 | } | ||
172 | |||
173 | int s3c_gpio_setcfg_s3c24xx(struct s3c_gpio_chip *chip, | ||
174 | unsigned int off, unsigned int cfg) | ||
175 | { | ||
176 | void __iomem *reg = chip->base; | ||
177 | unsigned int shift = off * 2; | ||
178 | u32 con; | ||
179 | |||
180 | if (s3c_gpio_is_cfg_special(cfg)) { | ||
181 | cfg &= 0xf; | ||
182 | if (cfg > 3) | ||
183 | return -EINVAL; | ||
184 | |||
185 | cfg <<= shift; | ||
186 | } | ||
187 | |||
188 | con = __raw_readl(reg); | ||
189 | con &= ~(0x3 << shift); | ||
190 | con |= cfg; | ||
191 | __raw_writel(con, reg); | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | unsigned int s3c_gpio_getcfg_s3c24xx(struct s3c_gpio_chip *chip, | ||
197 | unsigned int off) | ||
198 | { | ||
199 | u32 con; | ||
200 | |||
201 | con = __raw_readl(chip->base); | ||
202 | con >>= off * 2; | ||
203 | con &= 3; | ||
204 | |||
205 | /* this conversion works for IN and OUT as well as special mode */ | ||
206 | return S3C_GPIO_SPECIAL(con); | ||
207 | } | ||
208 | #endif | ||
209 | |||
210 | #ifdef CONFIG_S3C_GPIO_CFG_S3C64XX | ||
211 | int s3c_gpio_setcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip, | ||
212 | unsigned int off, unsigned int cfg) | ||
213 | { | ||
214 | void __iomem *reg = chip->base; | ||
215 | unsigned int shift = (off & 7) * 4; | ||
216 | u32 con; | ||
217 | |||
218 | if (off < 8 && chip->chip.ngpio > 8) | ||
219 | reg -= 4; | ||
220 | |||
221 | if (s3c_gpio_is_cfg_special(cfg)) { | ||
222 | cfg &= 0xf; | ||
223 | cfg <<= shift; | ||
224 | } | ||
225 | |||
226 | con = __raw_readl(reg); | ||
227 | con &= ~(0xf << shift); | ||
228 | con |= cfg; | ||
229 | __raw_writel(con, reg); | ||
230 | |||
231 | return 0; | ||
232 | } | ||
233 | |||
234 | unsigned s3c_gpio_getcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip, | ||
235 | unsigned int off) | ||
236 | { | ||
237 | void __iomem *reg = chip->base; | ||
238 | unsigned int shift = (off & 7) * 4; | ||
239 | u32 con; | ||
240 | |||
241 | if (off < 8 && chip->chip.ngpio > 8) | ||
242 | reg -= 4; | ||
243 | |||
244 | con = __raw_readl(reg); | ||
245 | con >>= shift; | ||
246 | con &= 0xf; | ||
247 | |||
248 | /* this conversion works for IN and OUT as well as special mode */ | ||
249 | return S3C_GPIO_SPECIAL(con); | ||
250 | } | ||
251 | |||
252 | #endif /* CONFIG_S3C_GPIO_CFG_S3C64XX */ | ||
253 | |||
254 | #ifdef CONFIG_S3C_GPIO_PULL_UPDOWN | ||
255 | int s3c_gpio_setpull_updown(struct s3c_gpio_chip *chip, | ||
256 | unsigned int off, s3c_gpio_pull_t pull) | ||
257 | { | ||
258 | void __iomem *reg = chip->base + 0x08; | ||
259 | int shift = off * 2; | ||
260 | u32 pup; | ||
261 | |||
262 | pup = __raw_readl(reg); | ||
263 | pup &= ~(3 << shift); | ||
264 | pup |= pull << shift; | ||
265 | __raw_writel(pup, reg); | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | s3c_gpio_pull_t s3c_gpio_getpull_updown(struct s3c_gpio_chip *chip, | ||
271 | unsigned int off) | ||
272 | { | ||
273 | void __iomem *reg = chip->base + 0x08; | ||
274 | int shift = off * 2; | ||
275 | u32 pup = __raw_readl(reg); | ||
276 | |||
277 | pup >>= shift; | ||
278 | pup &= 0x3; | ||
279 | return (__force s3c_gpio_pull_t)pup; | ||
280 | } | ||
281 | |||
282 | #ifdef CONFIG_S3C_GPIO_PULL_S3C2443 | ||
283 | int s3c_gpio_setpull_s3c2443(struct s3c_gpio_chip *chip, | ||
284 | unsigned int off, s3c_gpio_pull_t pull) | ||
285 | { | ||
286 | switch (pull) { | ||
287 | case S3C_GPIO_PULL_NONE: | ||
288 | pull = 0x01; | ||
289 | break; | ||
290 | case S3C_GPIO_PULL_UP: | ||
291 | pull = 0x00; | ||
292 | break; | ||
293 | case S3C_GPIO_PULL_DOWN: | ||
294 | pull = 0x02; | ||
295 | break; | ||
296 | } | ||
297 | return s3c_gpio_setpull_updown(chip, off, pull); | ||
298 | } | ||
299 | |||
300 | s3c_gpio_pull_t s3c_gpio_getpull_s3c2443(struct s3c_gpio_chip *chip, | ||
301 | unsigned int off) | ||
302 | { | ||
303 | s3c_gpio_pull_t pull; | ||
304 | |||
305 | pull = s3c_gpio_getpull_updown(chip, off); | ||
306 | |||
307 | switch (pull) { | ||
308 | case 0x00: | ||
309 | pull = S3C_GPIO_PULL_UP; | ||
310 | break; | ||
311 | case 0x01: | ||
312 | case 0x03: | ||
313 | pull = S3C_GPIO_PULL_NONE; | ||
314 | break; | ||
315 | case 0x02: | ||
316 | pull = S3C_GPIO_PULL_DOWN; | ||
317 | break; | ||
318 | } | ||
319 | |||
320 | return pull; | ||
321 | } | ||
322 | #endif | ||
323 | #endif | ||
324 | |||
325 | #if defined(CONFIG_S3C_GPIO_PULL_UP) || defined(CONFIG_S3C_GPIO_PULL_DOWN) | ||
326 | static int s3c_gpio_setpull_1(struct s3c_gpio_chip *chip, | ||
327 | unsigned int off, s3c_gpio_pull_t pull, | ||
328 | s3c_gpio_pull_t updown) | ||
329 | { | ||
330 | void __iomem *reg = chip->base + 0x08; | ||
331 | u32 pup = __raw_readl(reg); | ||
332 | |||
333 | if (pull == updown) | ||
334 | pup &= ~(1 << off); | ||
335 | else if (pull == S3C_GPIO_PULL_NONE) | ||
336 | pup |= (1 << off); | ||
337 | else | ||
338 | return -EINVAL; | ||
339 | |||
340 | __raw_writel(pup, reg); | ||
341 | return 0; | ||
342 | } | ||
343 | |||
344 | static s3c_gpio_pull_t s3c_gpio_getpull_1(struct s3c_gpio_chip *chip, | ||
345 | unsigned int off, s3c_gpio_pull_t updown) | ||
346 | { | ||
347 | void __iomem *reg = chip->base + 0x08; | ||
348 | u32 pup = __raw_readl(reg); | ||
349 | |||
350 | pup &= (1 << off); | ||
351 | return pup ? S3C_GPIO_PULL_NONE : updown; | ||
352 | } | ||
353 | #endif /* CONFIG_S3C_GPIO_PULL_UP || CONFIG_S3C_GPIO_PULL_DOWN */ | ||
354 | |||
355 | #ifdef CONFIG_S3C_GPIO_PULL_UP | ||
356 | s3c_gpio_pull_t s3c_gpio_getpull_1up(struct s3c_gpio_chip *chip, | ||
357 | unsigned int off) | ||
358 | { | ||
359 | return s3c_gpio_getpull_1(chip, off, S3C_GPIO_PULL_UP); | ||
360 | } | ||
361 | |||
362 | int s3c_gpio_setpull_1up(struct s3c_gpio_chip *chip, | ||
363 | unsigned int off, s3c_gpio_pull_t pull) | ||
364 | { | ||
365 | return s3c_gpio_setpull_1(chip, off, pull, S3C_GPIO_PULL_UP); | ||
366 | } | ||
367 | #endif /* CONFIG_S3C_GPIO_PULL_UP */ | ||
368 | |||
369 | #ifdef CONFIG_S3C_GPIO_PULL_DOWN | ||
370 | s3c_gpio_pull_t s3c_gpio_getpull_1down(struct s3c_gpio_chip *chip, | ||
371 | unsigned int off) | ||
372 | { | ||
373 | return s3c_gpio_getpull_1(chip, off, S3C_GPIO_PULL_DOWN); | ||
374 | } | ||
375 | |||
376 | int s3c_gpio_setpull_1down(struct s3c_gpio_chip *chip, | ||
377 | unsigned int off, s3c_gpio_pull_t pull) | ||
378 | { | ||
379 | return s3c_gpio_setpull_1(chip, off, pull, S3C_GPIO_PULL_DOWN); | ||
380 | } | ||
381 | #endif /* CONFIG_S3C_GPIO_PULL_DOWN */ | ||
382 | |||
383 | #ifdef CONFIG_S5P_GPIO_DRVSTR | ||
384 | s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin) | ||
385 | { | ||
386 | struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); | ||
387 | unsigned int off; | ||
388 | void __iomem *reg; | ||
389 | int shift; | ||
390 | u32 drvstr; | ||
391 | |||
392 | if (!chip) | ||
393 | return -EINVAL; | ||
394 | |||
395 | off = pin - chip->chip.base; | ||
396 | shift = off * 2; | ||
397 | reg = chip->base + 0x0C; | ||
398 | |||
399 | drvstr = __raw_readl(reg); | ||
400 | drvstr = drvstr >> shift; | ||
401 | drvstr &= 0x3; | ||
402 | |||
403 | return (__force s5p_gpio_drvstr_t)drvstr; | ||
404 | } | ||
405 | EXPORT_SYMBOL(s5p_gpio_get_drvstr); | ||
406 | |||
407 | int s5p_gpio_set_drvstr(unsigned int pin, s5p_gpio_drvstr_t drvstr) | ||
408 | { | ||
409 | struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); | ||
410 | unsigned int off; | ||
411 | void __iomem *reg; | ||
412 | int shift; | ||
413 | u32 tmp; | ||
414 | |||
415 | if (!chip) | ||
416 | return -EINVAL; | ||
417 | |||
418 | off = pin - chip->chip.base; | ||
419 | shift = off * 2; | ||
420 | reg = chip->base + 0x0C; | ||
421 | |||
422 | tmp = __raw_readl(reg); | ||
423 | tmp &= ~(0x3 << shift); | ||
424 | tmp |= drvstr << shift; | ||
425 | |||
426 | __raw_writel(tmp, reg); | ||
427 | |||
428 | return 0; | ||
429 | } | ||
430 | EXPORT_SYMBOL(s5p_gpio_set_drvstr); | ||
431 | #endif /* CONFIG_S5P_GPIO_DRVSTR */ | ||
diff --git a/arch/arm/plat-samsung/gpio.c b/arch/arm/plat-samsung/gpio.c deleted file mode 100644 index 7743c4b8b2fb..000000000000 --- a/arch/arm/plat-samsung/gpio.c +++ /dev/null | |||
@@ -1,167 +0,0 @@ | |||
1 | /* linux/arch/arm/plat-s3c/gpio.c | ||
2 | * | ||
3 | * Copyright 2008 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * http://armlinux.simtec.co.uk/ | ||
6 | * | ||
7 | * S3C series GPIO core | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/gpio.h> | ||
18 | #include <linux/spinlock.h> | ||
19 | |||
20 | #include <plat/gpio-core.h> | ||
21 | |||
22 | #ifdef CONFIG_S3C_GPIO_TRACK | ||
23 | struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END]; | ||
24 | |||
25 | static __init void s3c_gpiolib_track(struct s3c_gpio_chip *chip) | ||
26 | { | ||
27 | unsigned int gpn; | ||
28 | int i; | ||
29 | |||
30 | gpn = chip->chip.base; | ||
31 | for (i = 0; i < chip->chip.ngpio; i++, gpn++) { | ||
32 | BUG_ON(gpn >= ARRAY_SIZE(s3c_gpios)); | ||
33 | s3c_gpios[gpn] = chip; | ||
34 | } | ||
35 | } | ||
36 | #endif /* CONFIG_S3C_GPIO_TRACK */ | ||
37 | |||
38 | /* Default routines for controlling GPIO, based on the original S3C24XX | ||
39 | * GPIO functions which deal with the case where each gpio bank of the | ||
40 | * chip is as following: | ||
41 | * | ||
42 | * base + 0x00: Control register, 2 bits per gpio | ||
43 | * gpio n: 2 bits starting at (2*n) | ||
44 | * 00 = input, 01 = output, others mean special-function | ||
45 | * base + 0x04: Data register, 1 bit per gpio | ||
46 | * bit n: data bit n | ||
47 | */ | ||
48 | |||
49 | static int s3c_gpiolib_input(struct gpio_chip *chip, unsigned offset) | ||
50 | { | ||
51 | struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip); | ||
52 | void __iomem *base = ourchip->base; | ||
53 | unsigned long flags; | ||
54 | unsigned long con; | ||
55 | |||
56 | s3c_gpio_lock(ourchip, flags); | ||
57 | |||
58 | con = __raw_readl(base + 0x00); | ||
59 | con &= ~(3 << (offset * 2)); | ||
60 | |||
61 | __raw_writel(con, base + 0x00); | ||
62 | |||
63 | s3c_gpio_unlock(ourchip, flags); | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | static int s3c_gpiolib_output(struct gpio_chip *chip, | ||
68 | unsigned offset, int value) | ||
69 | { | ||
70 | struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip); | ||
71 | void __iomem *base = ourchip->base; | ||
72 | unsigned long flags; | ||
73 | unsigned long dat; | ||
74 | unsigned long con; | ||
75 | |||
76 | s3c_gpio_lock(ourchip, flags); | ||
77 | |||
78 | dat = __raw_readl(base + 0x04); | ||
79 | dat &= ~(1 << offset); | ||
80 | if (value) | ||
81 | dat |= 1 << offset; | ||
82 | __raw_writel(dat, base + 0x04); | ||
83 | |||
84 | con = __raw_readl(base + 0x00); | ||
85 | con &= ~(3 << (offset * 2)); | ||
86 | con |= 1 << (offset * 2); | ||
87 | |||
88 | __raw_writel(con, base + 0x00); | ||
89 | __raw_writel(dat, base + 0x04); | ||
90 | |||
91 | s3c_gpio_unlock(ourchip, flags); | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | static void s3c_gpiolib_set(struct gpio_chip *chip, | ||
96 | unsigned offset, int value) | ||
97 | { | ||
98 | struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip); | ||
99 | void __iomem *base = ourchip->base; | ||
100 | unsigned long flags; | ||
101 | unsigned long dat; | ||
102 | |||
103 | s3c_gpio_lock(ourchip, flags); | ||
104 | |||
105 | dat = __raw_readl(base + 0x04); | ||
106 | dat &= ~(1 << offset); | ||
107 | if (value) | ||
108 | dat |= 1 << offset; | ||
109 | __raw_writel(dat, base + 0x04); | ||
110 | |||
111 | s3c_gpio_unlock(ourchip, flags); | ||
112 | } | ||
113 | |||
114 | static int s3c_gpiolib_get(struct gpio_chip *chip, unsigned offset) | ||
115 | { | ||
116 | struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip); | ||
117 | unsigned long val; | ||
118 | |||
119 | val = __raw_readl(ourchip->base + 0x04); | ||
120 | val >>= offset; | ||
121 | val &= 1; | ||
122 | |||
123 | return val; | ||
124 | } | ||
125 | |||
126 | __init void s3c_gpiolib_add(struct s3c_gpio_chip *chip) | ||
127 | { | ||
128 | struct gpio_chip *gc = &chip->chip; | ||
129 | int ret; | ||
130 | |||
131 | BUG_ON(!chip->base); | ||
132 | BUG_ON(!gc->label); | ||
133 | BUG_ON(!gc->ngpio); | ||
134 | |||
135 | spin_lock_init(&chip->lock); | ||
136 | |||
137 | if (!gc->direction_input) | ||
138 | gc->direction_input = s3c_gpiolib_input; | ||
139 | if (!gc->direction_output) | ||
140 | gc->direction_output = s3c_gpiolib_output; | ||
141 | if (!gc->set) | ||
142 | gc->set = s3c_gpiolib_set; | ||
143 | if (!gc->get) | ||
144 | gc->get = s3c_gpiolib_get; | ||
145 | |||
146 | #ifdef CONFIG_PM | ||
147 | if (chip->pm != NULL) { | ||
148 | if (!chip->pm->save || !chip->pm->resume) | ||
149 | printk(KERN_ERR "gpio: %s has missing PM functions\n", | ||
150 | gc->label); | ||
151 | } else | ||
152 | printk(KERN_ERR "gpio: %s has no PM function\n", gc->label); | ||
153 | #endif | ||
154 | |||
155 | /* gpiochip_add() prints own failure message on error. */ | ||
156 | ret = gpiochip_add(gc); | ||
157 | if (ret >= 0) | ||
158 | s3c_gpiolib_track(chip); | ||
159 | } | ||
160 | |||
161 | int samsung_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset) | ||
162 | { | ||
163 | struct s3c_gpio_chip *s3c_chip = container_of(chip, | ||
164 | struct s3c_gpio_chip, chip); | ||
165 | |||
166 | return s3c_chip->irq_base + offset; | ||
167 | } | ||
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h index 24ebb1e1de41..ee5014a7cc96 100644 --- a/arch/arm/plat-samsung/include/plat/devs.h +++ b/arch/arm/plat-samsung/include/plat/devs.h | |||
@@ -62,6 +62,7 @@ extern struct platform_device s3c_device_i2c4; | |||
62 | extern struct platform_device s3c_device_i2c5; | 62 | extern struct platform_device s3c_device_i2c5; |
63 | extern struct platform_device s3c_device_i2c6; | 63 | extern struct platform_device s3c_device_i2c6; |
64 | extern struct platform_device s3c_device_i2c7; | 64 | extern struct platform_device s3c_device_i2c7; |
65 | extern struct platform_device s5p_device_i2c_hdmiphy; | ||
65 | extern struct platform_device s3c_device_rtc; | 66 | extern struct platform_device s3c_device_rtc; |
66 | extern struct platform_device s3c_device_adc; | 67 | extern struct platform_device s3c_device_adc; |
67 | extern struct platform_device s3c_device_sdi; | 68 | extern struct platform_device s3c_device_sdi; |
@@ -142,6 +143,11 @@ extern struct platform_device s5p_device_fimc3; | |||
142 | extern struct platform_device s5p_device_mfc; | 143 | extern struct platform_device s5p_device_mfc; |
143 | extern struct platform_device s5p_device_mfc_l; | 144 | extern struct platform_device s5p_device_mfc_l; |
144 | extern struct platform_device s5p_device_mfc_r; | 145 | extern struct platform_device s5p_device_mfc_r; |
146 | |||
147 | extern struct platform_device s5p_device_hdmi; | ||
148 | extern struct platform_device s5p_device_mixer; | ||
149 | extern struct platform_device s5p_device_sdo; | ||
150 | |||
145 | extern struct platform_device s5p_device_mipi_csis0; | 151 | extern struct platform_device s5p_device_mipi_csis0; |
146 | extern struct platform_device s5p_device_mipi_csis1; | 152 | extern struct platform_device s5p_device_mipi_csis1; |
147 | 153 | ||
diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h new file mode 100644 index 000000000000..4c1a363526cf --- /dev/null +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* arch/arm/plat-samsung/include/plat/dma-ops.h | ||
2 | * | ||
3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * Samsung DMA support | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __SAMSUNG_DMA_OPS_H_ | ||
14 | #define __SAMSUNG_DMA_OPS_H_ __FILE__ | ||
15 | |||
16 | #include <linux/dmaengine.h> | ||
17 | |||
18 | struct samsung_dma_prep_info { | ||
19 | enum dma_transaction_type cap; | ||
20 | enum dma_data_direction direction; | ||
21 | dma_addr_t buf; | ||
22 | unsigned long period; | ||
23 | unsigned long len; | ||
24 | void (*fp)(void *data); | ||
25 | void *fp_param; | ||
26 | }; | ||
27 | |||
28 | struct samsung_dma_info { | ||
29 | enum dma_transaction_type cap; | ||
30 | enum dma_data_direction direction; | ||
31 | enum dma_slave_buswidth width; | ||
32 | dma_addr_t fifo; | ||
33 | struct s3c2410_dma_client *client; | ||
34 | }; | ||
35 | |||
36 | struct samsung_dma_ops { | ||
37 | unsigned (*request)(enum dma_ch ch, struct samsung_dma_info *info); | ||
38 | int (*release)(unsigned ch, struct s3c2410_dma_client *client); | ||
39 | int (*prepare)(unsigned ch, struct samsung_dma_prep_info *info); | ||
40 | int (*trigger)(unsigned ch); | ||
41 | int (*started)(unsigned ch); | ||
42 | int (*flush)(unsigned ch); | ||
43 | int (*stop)(unsigned ch); | ||
44 | }; | ||
45 | |||
46 | extern void *samsung_dmadev_get_ops(void); | ||
47 | extern void *s3c_dma_get_ops(void); | ||
48 | |||
49 | static inline void *__samsung_dma_get_ops(void) | ||
50 | { | ||
51 | if (samsung_dma_is_dmadev()) | ||
52 | return samsung_dmadev_get_ops(); | ||
53 | else | ||
54 | return s3c_dma_get_ops(); | ||
55 | } | ||
56 | |||
57 | /* | ||
58 | * samsung_dma_get_ops | ||
59 | * get the set of samsung dma operations | ||
60 | */ | ||
61 | #define samsung_dma_get_ops() __samsung_dma_get_ops() | ||
62 | |||
63 | #endif /* __SAMSUNG_DMA_OPS_H_ */ | ||
diff --git a/arch/arm/plat-samsung/include/plat/s3c-dma-pl330.h b/arch/arm/plat-samsung/include/plat/dma-pl330.h index 810744213120..2e55e5958674 100644 --- a/arch/arm/plat-samsung/include/plat/s3c-dma-pl330.h +++ b/arch/arm/plat-samsung/include/plat/dma-pl330.h | |||
@@ -8,11 +8,8 @@ | |||
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #ifndef __S3C_DMA_PL330_H_ | 11 | #ifndef __DMA_PL330_H_ |
12 | #define __S3C_DMA_PL330_H_ | 12 | #define __DMA_PL330_H_ __FILE__ |
13 | |||
14 | #define S3C2410_DMAF_AUTOSTART (1 << 0) | ||
15 | #define S3C2410_DMAF_CIRCULAR (1 << 1) | ||
16 | 13 | ||
17 | /* | 14 | /* |
18 | * PL330 can assign any channel to communicate with | 15 | * PL330 can assign any channel to communicate with |
@@ -20,7 +17,7 @@ | |||
20 | * For the sake of consistency across client drivers, | 17 | * For the sake of consistency across client drivers, |
21 | * We keep the channel names unchanged and only add | 18 | * We keep the channel names unchanged and only add |
22 | * missing peripherals are added. | 19 | * missing peripherals are added. |
23 | * Order is not important since S3C PL330 API driver | 20 | * Order is not important since DMA PL330 API driver |
24 | * use these just as IDs. | 21 | * use these just as IDs. |
25 | */ | 22 | */ |
26 | enum dma_ch { | 23 | enum dma_ch { |
@@ -88,11 +85,20 @@ enum dma_ch { | |||
88 | DMACH_MAX, | 85 | DMACH_MAX, |
89 | }; | 86 | }; |
90 | 87 | ||
91 | static inline bool s3c_dma_has_circular(void) | 88 | struct s3c2410_dma_client { |
89 | char *name; | ||
90 | }; | ||
91 | |||
92 | static inline bool samsung_dma_has_circular(void) | ||
93 | { | ||
94 | return true; | ||
95 | } | ||
96 | |||
97 | static inline bool samsung_dma_is_dmadev(void) | ||
92 | { | 98 | { |
93 | return true; | 99 | return true; |
94 | } | 100 | } |
95 | 101 | ||
96 | #include <plat/dma.h> | 102 | #include <plat/dma-ops.h> |
97 | 103 | ||
98 | #endif /* __S3C_DMA_PL330_H_ */ | 104 | #endif /* __DMA_PL330_H_ */ |
diff --git a/arch/arm/plat-samsung/include/plat/dma-s3c24xx.h b/arch/arm/plat-samsung/include/plat/dma-s3c24xx.h index ab9bce637cbd..1c1ed5481253 100644 --- a/arch/arm/plat-samsung/include/plat/dma-s3c24xx.h +++ b/arch/arm/plat-samsung/include/plat/dma-s3c24xx.h | |||
@@ -41,7 +41,7 @@ struct s3c24xx_dma_selection { | |||
41 | 41 | ||
42 | void (*direction)(struct s3c2410_dma_chan *chan, | 42 | void (*direction)(struct s3c2410_dma_chan *chan, |
43 | struct s3c24xx_dma_map *map, | 43 | struct s3c24xx_dma_map *map, |
44 | enum s3c2410_dmasrc dir); | 44 | enum dma_data_direction dir); |
45 | }; | 45 | }; |
46 | 46 | ||
47 | extern int s3c24xx_dma_init_map(struct s3c24xx_dma_selection *sel); | 47 | extern int s3c24xx_dma_init_map(struct s3c24xx_dma_selection *sel); |
diff --git a/arch/arm/plat-samsung/include/plat/dma.h b/arch/arm/plat-samsung/include/plat/dma.h index 8c273b7a6f56..b9061128abde 100644 --- a/arch/arm/plat-samsung/include/plat/dma.h +++ b/arch/arm/plat-samsung/include/plat/dma.h | |||
@@ -10,17 +10,14 @@ | |||
10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/dma-mapping.h> | ||
14 | |||
13 | enum s3c2410_dma_buffresult { | 15 | enum s3c2410_dma_buffresult { |
14 | S3C2410_RES_OK, | 16 | S3C2410_RES_OK, |
15 | S3C2410_RES_ERR, | 17 | S3C2410_RES_ERR, |
16 | S3C2410_RES_ABORT | 18 | S3C2410_RES_ABORT |
17 | }; | 19 | }; |
18 | 20 | ||
19 | enum s3c2410_dmasrc { | ||
20 | S3C2410_DMASRC_HW, /* source is memory */ | ||
21 | S3C2410_DMASRC_MEM /* source is hardware */ | ||
22 | }; | ||
23 | |||
24 | /* enum s3c2410_chan_op | 21 | /* enum s3c2410_chan_op |
25 | * | 22 | * |
26 | * operation codes passed to the DMA code by the user, and also used | 23 | * operation codes passed to the DMA code by the user, and also used |
@@ -112,7 +109,7 @@ extern int s3c2410_dma_config(enum dma_ch channel, int xferunit); | |||
112 | */ | 109 | */ |
113 | 110 | ||
114 | extern int s3c2410_dma_devconfig(enum dma_ch channel, | 111 | extern int s3c2410_dma_devconfig(enum dma_ch channel, |
115 | enum s3c2410_dmasrc source, unsigned long devaddr); | 112 | enum dma_data_direction source, unsigned long devaddr); |
116 | 113 | ||
117 | /* s3c2410_dma_getposition | 114 | /* s3c2410_dma_getposition |
118 | * | 115 | * |
@@ -126,3 +123,4 @@ extern int s3c2410_dma_set_opfn(enum dma_ch, s3c2410_dma_opfn_t rtn); | |||
126 | extern int s3c2410_dma_set_buffdone_fn(enum dma_ch, s3c2410_dma_cbfn_t rtn); | 123 | extern int s3c2410_dma_set_buffdone_fn(enum dma_ch, s3c2410_dma_cbfn_t rtn); |
127 | 124 | ||
128 | 125 | ||
126 | #include <plat/dma-ops.h> | ||
diff --git a/arch/arm/plat-samsung/include/plat/fb.h b/arch/arm/plat-samsung/include/plat/fb.h index 01f10e4d00c7..0fedf47fa502 100644 --- a/arch/arm/plat-samsung/include/plat/fb.h +++ b/arch/arm/plat-samsung/include/plat/fb.h | |||
@@ -109,4 +109,11 @@ extern void s5pv210_fb_gpio_setup_24bpp(void); | |||
109 | */ | 109 | */ |
110 | extern void exynos4_fimd0_gpio_setup_24bpp(void); | 110 | extern void exynos4_fimd0_gpio_setup_24bpp(void); |
111 | 111 | ||
112 | /** | ||
113 | * s5p64x0_fb_gpio_setup_24bpp() - S5P6440/S5P6450 setup function for 24bpp LCD | ||
114 | * | ||
115 | * Initialise the GPIO for an 24bpp LCD display on the RGB interface. | ||
116 | */ | ||
117 | extern void s5p64x0_fb_gpio_setup_24bpp(void); | ||
118 | |||
112 | #endif /* __PLAT_S3C_FB_H */ | 119 | #endif /* __PLAT_S3C_FB_H */ |
diff --git a/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h b/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h index 9a4e53d52967..a181d7ce81cf 100644 --- a/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h +++ b/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h | |||
@@ -1,11 +1,11 @@ | |||
1 | /* linux/arch/arm/plat-s3c/include/plat/gpio-cfg-helper.h | 1 | /* linux/arch/arm/plat-samsung/include/plat/gpio-cfg-helper.h |
2 | * | 2 | * |
3 | * Copyright 2008 Openmoko, Inc. | 3 | * Copyright 2008 Openmoko, Inc. |
4 | * Copyright 2008 Simtec Electronics | 4 | * Copyright 2008 Simtec Electronics |
5 | * http://armlinux.simtec.co.uk/ | 5 | * http://armlinux.simtec.co.uk/ |
6 | * Ben Dooks <ben@simtec.co.uk> | 6 | * Ben Dooks <ben@simtec.co.uk> |
7 | * | 7 | * |
8 | * S3C Platform - GPIO pin configuration helper definitions | 8 | * Samsung Platform - GPIO pin configuration helper definitions |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2 as | 11 | * it under the terms of the GNU General Public License version 2 as |
@@ -24,120 +24,30 @@ | |||
24 | * by disabling interrupts. | 24 | * by disabling interrupts. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | static inline int s3c_gpio_do_setcfg(struct s3c_gpio_chip *chip, | 27 | static inline int samsung_gpio_do_setcfg(struct samsung_gpio_chip *chip, |
28 | unsigned int off, unsigned int config) | 28 | unsigned int off, unsigned int config) |
29 | { | 29 | { |
30 | return (chip->config->set_config)(chip, off, config); | 30 | return (chip->config->set_config)(chip, off, config); |
31 | } | 31 | } |
32 | 32 | ||
33 | static inline unsigned s3c_gpio_do_getcfg(struct s3c_gpio_chip *chip, | 33 | static inline unsigned samsung_gpio_do_getcfg(struct samsung_gpio_chip *chip, |
34 | unsigned int off) | 34 | unsigned int off) |
35 | { | 35 | { |
36 | return (chip->config->get_config)(chip, off); | 36 | return (chip->config->get_config)(chip, off); |
37 | } | 37 | } |
38 | 38 | ||
39 | static inline int s3c_gpio_do_setpull(struct s3c_gpio_chip *chip, | 39 | static inline int samsung_gpio_do_setpull(struct samsung_gpio_chip *chip, |
40 | unsigned int off, s3c_gpio_pull_t pull) | 40 | unsigned int off, samsung_gpio_pull_t pull) |
41 | { | 41 | { |
42 | return (chip->config->set_pull)(chip, off, pull); | 42 | return (chip->config->set_pull)(chip, off, pull); |
43 | } | 43 | } |
44 | 44 | ||
45 | static inline s3c_gpio_pull_t s3c_gpio_do_getpull(struct s3c_gpio_chip *chip, | 45 | static inline samsung_gpio_pull_t samsung_gpio_do_getpull(struct samsung_gpio_chip *chip, |
46 | unsigned int off) | 46 | unsigned int off) |
47 | { | 47 | { |
48 | return chip->config->get_pull(chip, off); | 48 | return chip->config->get_pull(chip, off); |
49 | } | 49 | } |
50 | 50 | ||
51 | /** | ||
52 | * s3c_gpio_setcfg_s3c24xx - S3C24XX style GPIO configuration. | ||
53 | * @chip: The gpio chip that is being configured. | ||
54 | * @off: The offset for the GPIO being configured. | ||
55 | * @cfg: The configuration value to set. | ||
56 | * | ||
57 | * This helper deal with the GPIO cases where the control register | ||
58 | * has two bits of configuration per gpio, which have the following | ||
59 | * functions: | ||
60 | * 00 = input | ||
61 | * 01 = output | ||
62 | * 1x = special function | ||
63 | */ | ||
64 | extern int s3c_gpio_setcfg_s3c24xx(struct s3c_gpio_chip *chip, | ||
65 | unsigned int off, unsigned int cfg); | ||
66 | |||
67 | /** | ||
68 | * s3c_gpio_getcfg_s3c24xx - S3C24XX style GPIO configuration read. | ||
69 | * @chip: The gpio chip that is being configured. | ||
70 | * @off: The offset for the GPIO being configured. | ||
71 | * | ||
72 | * The reverse of s3c_gpio_setcfg_s3c24xx(). Will return a value whicg | ||
73 | * could be directly passed back to s3c_gpio_setcfg_s3c24xx(), from the | ||
74 | * S3C_GPIO_SPECIAL() macro. | ||
75 | */ | ||
76 | unsigned int s3c_gpio_getcfg_s3c24xx(struct s3c_gpio_chip *chip, | ||
77 | unsigned int off); | ||
78 | |||
79 | /** | ||
80 | * s3c_gpio_setcfg_s3c24xx_a - S3C24XX style GPIO configuration (Bank A) | ||
81 | * @chip: The gpio chip that is being configured. | ||
82 | * @off: The offset for the GPIO being configured. | ||
83 | * @cfg: The configuration value to set. | ||
84 | * | ||
85 | * This helper deal with the GPIO cases where the control register | ||
86 | * has one bit of configuration for the gpio, where setting the bit | ||
87 | * means the pin is in special function mode and unset means output. | ||
88 | */ | ||
89 | extern int s3c_gpio_setcfg_s3c24xx_a(struct s3c_gpio_chip *chip, | ||
90 | unsigned int off, unsigned int cfg); | ||
91 | |||
92 | |||
93 | /** | ||
94 | * s3c_gpio_getcfg_s3c24xx_a - S3C24XX style GPIO configuration read (Bank A) | ||
95 | * @chip: The gpio chip that is being configured. | ||
96 | * @off: The offset for the GPIO being configured. | ||
97 | * | ||
98 | * The reverse of s3c_gpio_setcfg_s3c24xx_a() turning an GPIO into a usable | ||
99 | * GPIO configuration value. | ||
100 | * | ||
101 | * @sa s3c_gpio_getcfg_s3c24xx | ||
102 | * @sa s3c_gpio_getcfg_s3c64xx_4bit | ||
103 | */ | ||
104 | extern unsigned s3c_gpio_getcfg_s3c24xx_a(struct s3c_gpio_chip *chip, | ||
105 | unsigned int off); | ||
106 | |||
107 | /** | ||
108 | * s3c_gpio_setcfg_s3c64xx_4bit - S3C64XX 4bit single register GPIO config. | ||
109 | * @chip: The gpio chip that is being configured. | ||
110 | * @off: The offset for the GPIO being configured. | ||
111 | * @cfg: The configuration value to set. | ||
112 | * | ||
113 | * This helper deal with the GPIO cases where the control register has 4 bits | ||
114 | * of control per GPIO, generally in the form of: | ||
115 | * 0000 = Input | ||
116 | * 0001 = Output | ||
117 | * others = Special functions (dependent on bank) | ||
118 | * | ||
119 | * Note, since the code to deal with the case where there are two control | ||
120 | * registers instead of one, we do not have a separate set of functions for | ||
121 | * each case. | ||
122 | */ | ||
123 | extern int s3c_gpio_setcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip, | ||
124 | unsigned int off, unsigned int cfg); | ||
125 | |||
126 | |||
127 | /** | ||
128 | * s3c_gpio_getcfg_s3c64xx_4bit - S3C64XX 4bit single register GPIO config read. | ||
129 | * @chip: The gpio chip that is being configured. | ||
130 | * @off: The offset for the GPIO being configured. | ||
131 | * | ||
132 | * The reverse of s3c_gpio_setcfg_s3c64xx_4bit(), turning a gpio configuration | ||
133 | * register setting into a value the software can use, such as could be passed | ||
134 | * to s3c_gpio_setcfg_s3c64xx_4bit(). | ||
135 | * | ||
136 | * @sa s3c_gpio_getcfg_s3c24xx | ||
137 | */ | ||
138 | extern unsigned s3c_gpio_getcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip, | ||
139 | unsigned int off); | ||
140 | |||
141 | /* Pull-{up,down} resistor controls. | 51 | /* Pull-{up,down} resistor controls. |
142 | * | 52 | * |
143 | * S3C2410,S3C2440 = Pull-UP, | 53 | * S3C2410,S3C2440 = Pull-UP, |
@@ -147,7 +57,7 @@ extern unsigned s3c_gpio_getcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip, | |||
147 | */ | 57 | */ |
148 | 58 | ||
149 | /** | 59 | /** |
150 | * s3c_gpio_setpull_1up() - Pull configuration for choice of up or none. | 60 | * s3c24xx_gpio_setpull_1up() - Pull configuration for choice of up or none. |
151 | * @chip: The gpio chip that is being configured. | 61 | * @chip: The gpio chip that is being configured. |
152 | * @off: The offset for the GPIO being configured. | 62 | * @off: The offset for the GPIO being configured. |
153 | * @param: pull: The pull mode being requested. | 63 | * @param: pull: The pull mode being requested. |
@@ -155,11 +65,11 @@ extern unsigned s3c_gpio_getcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip, | |||
155 | * This is a helper function for the case where we have GPIOs with one | 65 | * This is a helper function for the case where we have GPIOs with one |
156 | * bit configuring the presence of a pull-up resistor. | 66 | * bit configuring the presence of a pull-up resistor. |
157 | */ | 67 | */ |
158 | extern int s3c_gpio_setpull_1up(struct s3c_gpio_chip *chip, | 68 | extern int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip *chip, |
159 | unsigned int off, s3c_gpio_pull_t pull); | 69 | unsigned int off, samsung_gpio_pull_t pull); |
160 | 70 | ||
161 | /** | 71 | /** |
162 | * s3c_gpio_setpull_1down() - Pull configuration for choice of down or none | 72 | * s3c24xx_gpio_setpull_1down() - Pull configuration for choice of down or none |
163 | * @chip: The gpio chip that is being configured | 73 | * @chip: The gpio chip that is being configured |
164 | * @off: The offset for the GPIO being configured | 74 | * @off: The offset for the GPIO being configured |
165 | * @param: pull: The pull mode being requested | 75 | * @param: pull: The pull mode being requested |
@@ -167,11 +77,13 @@ extern int s3c_gpio_setpull_1up(struct s3c_gpio_chip *chip, | |||
167 | * This is a helper function for the case where we have GPIOs with one | 77 | * This is a helper function for the case where we have GPIOs with one |
168 | * bit configuring the presence of a pull-down resistor. | 78 | * bit configuring the presence of a pull-down resistor. |
169 | */ | 79 | */ |
170 | extern int s3c_gpio_setpull_1down(struct s3c_gpio_chip *chip, | 80 | extern int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip, |
171 | unsigned int off, s3c_gpio_pull_t pull); | 81 | unsigned int off, samsung_gpio_pull_t pull); |
172 | 82 | ||
173 | /** | 83 | /** |
174 | * s3c_gpio_setpull_upown() - Pull configuration for choice of up, down or none | 84 | * samsung_gpio_setpull_upown() - Pull configuration for choice of up, |
85 | * down or none | ||
86 | * | ||
175 | * @chip: The gpio chip that is being configured. | 87 | * @chip: The gpio chip that is being configured. |
176 | * @off: The offset for the GPIO being configured. | 88 | * @off: The offset for the GPIO being configured. |
177 | * @param: pull: The pull mode being requested. | 89 | * @param: pull: The pull mode being requested. |
@@ -183,45 +95,46 @@ extern int s3c_gpio_setpull_1down(struct s3c_gpio_chip *chip, | |||
183 | * 01 = Pull-up resistor connected | 95 | * 01 = Pull-up resistor connected |
184 | * 10 = Pull-down resistor connected | 96 | * 10 = Pull-down resistor connected |
185 | */ | 97 | */ |
186 | extern int s3c_gpio_setpull_updown(struct s3c_gpio_chip *chip, | 98 | extern int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip, |
187 | unsigned int off, s3c_gpio_pull_t pull); | 99 | unsigned int off, samsung_gpio_pull_t pull); |
188 | |||
189 | 100 | ||
190 | /** | 101 | /** |
191 | * s3c_gpio_getpull_updown() - Get configuration for choice of up, down or none | 102 | * samsung_gpio_getpull_updown() - Get configuration for choice of up, |
103 | * down or none | ||
104 | * | ||
192 | * @chip: The gpio chip that the GPIO pin belongs to | 105 | * @chip: The gpio chip that the GPIO pin belongs to |
193 | * @off: The offset to the pin to get the configuration of. | 106 | * @off: The offset to the pin to get the configuration of. |
194 | * | 107 | * |
195 | * This helper function reads the state of the pull-{up,down} resistor for the | 108 | * This helper function reads the state of the pull-{up,down} resistor |
196 | * given GPIO in the same case as s3c_gpio_setpull_upown. | 109 | * for the given GPIO in the same case as samsung_gpio_setpull_upown. |
197 | */ | 110 | */ |
198 | extern s3c_gpio_pull_t s3c_gpio_getpull_updown(struct s3c_gpio_chip *chip, | 111 | extern samsung_gpio_pull_t samsung_gpio_getpull_updown(struct samsung_gpio_chip *chip, |
199 | unsigned int off); | 112 | unsigned int off); |
200 | 113 | ||
201 | /** | 114 | /** |
202 | * s3c_gpio_getpull_1up() - Get configuration for choice of up or none | 115 | * s3c24xx_gpio_getpull_1up() - Get configuration for choice of up or none |
203 | * @chip: The gpio chip that the GPIO pin belongs to | 116 | * @chip: The gpio chip that the GPIO pin belongs to |
204 | * @off: The offset to the pin to get the configuration of. | 117 | * @off: The offset to the pin to get the configuration of. |
205 | * | 118 | * |
206 | * This helper function reads the state of the pull-up resistor for the | 119 | * This helper function reads the state of the pull-up resistor for the |
207 | * given GPIO in the same case as s3c_gpio_setpull_1up. | 120 | * given GPIO in the same case as s3c24xx_gpio_setpull_1up. |
208 | */ | 121 | */ |
209 | extern s3c_gpio_pull_t s3c_gpio_getpull_1up(struct s3c_gpio_chip *chip, | 122 | extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip *chip, |
210 | unsigned int off); | 123 | unsigned int off); |
211 | 124 | ||
212 | /** | 125 | /** |
213 | * s3c_gpio_getpull_1down() - Get configuration for choice of down or none | 126 | * s3c24xx_gpio_getpull_1down() - Get configuration for choice of down or none |
214 | * @chip: The gpio chip that the GPIO pin belongs to | 127 | * @chip: The gpio chip that the GPIO pin belongs to |
215 | * @off: The offset to the pin to get the configuration of. | 128 | * @off: The offset to the pin to get the configuration of. |
216 | * | 129 | * |
217 | * This helper function reads the state of the pull-down resistor for the | 130 | * This helper function reads the state of the pull-down resistor for the |
218 | * given GPIO in the same case as s3c_gpio_setpull_1down. | 131 | * given GPIO in the same case as s3c24xx_gpio_setpull_1down. |
219 | */ | 132 | */ |
220 | extern s3c_gpio_pull_t s3c_gpio_getpull_1down(struct s3c_gpio_chip *chip, | 133 | extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip *chip, |
221 | unsigned int off); | 134 | unsigned int off); |
222 | 135 | ||
223 | /** | 136 | /** |
224 | * s3c_gpio_setpull_s3c2443() - Pull configuration for s3c2443. | 137 | * s3c2443_gpio_setpull() - Pull configuration for s3c2443. |
225 | * @chip: The gpio chip that is being configured. | 138 | * @chip: The gpio chip that is being configured. |
226 | * @off: The offset for the GPIO being configured. | 139 | * @off: The offset for the GPIO being configured. |
227 | * @param: pull: The pull mode being requested. | 140 | * @param: pull: The pull mode being requested. |
@@ -233,19 +146,18 @@ extern s3c_gpio_pull_t s3c_gpio_getpull_1down(struct s3c_gpio_chip *chip, | |||
233 | * 10 = Pull-down resistor connected | 146 | * 10 = Pull-down resistor connected |
234 | * x1 = No pull up resistor | 147 | * x1 = No pull up resistor |
235 | */ | 148 | */ |
236 | extern int s3c_gpio_setpull_s3c2443(struct s3c_gpio_chip *chip, | 149 | extern int s3c2443_gpio_setpull(struct samsung_gpio_chip *chip, |
237 | unsigned int off, s3c_gpio_pull_t pull); | 150 | unsigned int off, samsung_gpio_pull_t pull); |
238 | 151 | ||
239 | /** | 152 | /** |
240 | * s3c_gpio_getpull_s3c2443() - Get configuration for s3c2443 pull resistors | 153 | * s3c2443_gpio_getpull() - Get configuration for s3c2443 pull resistors |
241 | * @chip: The gpio chip that the GPIO pin belongs to. | 154 | * @chip: The gpio chip that the GPIO pin belongs to. |
242 | * @off: The offset to the pin to get the configuration of. | 155 | * @off: The offset to the pin to get the configuration of. |
243 | * | 156 | * |
244 | * This helper function reads the state of the pull-{up,down} resistor for the | 157 | * This helper function reads the state of the pull-{up,down} resistor for the |
245 | * given GPIO in the same case as s3c_gpio_setpull_upown. | 158 | * given GPIO in the same case as samsung_gpio_setpull_upown. |
246 | */ | 159 | */ |
247 | extern s3c_gpio_pull_t s3c_gpio_getpull_s3c2443(struct s3c_gpio_chip *chip, | 160 | extern samsung_gpio_pull_t s3c2443_gpio_getpull(struct samsung_gpio_chip *chip, |
248 | unsigned int off); | 161 | unsigned int off); |
249 | 162 | ||
250 | #endif /* __PLAT_GPIO_CFG_HELPERS_H */ | 163 | #endif /* __PLAT_GPIO_CFG_HELPERS_H */ |
251 | |||
diff --git a/arch/arm/plat-samsung/include/plat/gpio-cfg.h b/arch/arm/plat-samsung/include/plat/gpio-cfg.h index 1762dcb4cb9e..d48245bb02b3 100644 --- a/arch/arm/plat-samsung/include/plat/gpio-cfg.h +++ b/arch/arm/plat-samsung/include/plat/gpio-cfg.h | |||
@@ -24,14 +24,14 @@ | |||
24 | #ifndef __PLAT_GPIO_CFG_H | 24 | #ifndef __PLAT_GPIO_CFG_H |
25 | #define __PLAT_GPIO_CFG_H __FILE__ | 25 | #define __PLAT_GPIO_CFG_H __FILE__ |
26 | 26 | ||
27 | typedef unsigned int __bitwise__ s3c_gpio_pull_t; | 27 | typedef unsigned int __bitwise__ samsung_gpio_pull_t; |
28 | typedef unsigned int __bitwise__ s5p_gpio_drvstr_t; | 28 | typedef unsigned int __bitwise__ s5p_gpio_drvstr_t; |
29 | 29 | ||
30 | /* forward declaration if gpio-core.h hasn't been included */ | 30 | /* forward declaration if gpio-core.h hasn't been included */ |
31 | struct s3c_gpio_chip; | 31 | struct samsung_gpio_chip; |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * struct s3c_gpio_cfg GPIO configuration | 34 | * struct samsung_gpio_cfg GPIO configuration |
35 | * @cfg_eint: Configuration setting when used for external interrupt source | 35 | * @cfg_eint: Configuration setting when used for external interrupt source |
36 | * @get_pull: Read the current pull configuration for the GPIO | 36 | * @get_pull: Read the current pull configuration for the GPIO |
37 | * @set_pull: Set the current pull configuraiton for the GPIO | 37 | * @set_pull: Set the current pull configuraiton for the GPIO |
@@ -44,20 +44,20 @@ struct s3c_gpio_chip; | |||
44 | * per-bank configuration information that other systems such as the | 44 | * per-bank configuration information that other systems such as the |
45 | * external interrupt code will need. | 45 | * external interrupt code will need. |
46 | * | 46 | * |
47 | * @sa s3c_gpio_cfgpin | 47 | * @sa samsung_gpio_cfgpin |
48 | * @sa s3c_gpio_getcfg | 48 | * @sa s3c_gpio_getcfg |
49 | * @sa s3c_gpio_setpull | 49 | * @sa s3c_gpio_setpull |
50 | * @sa s3c_gpio_getpull | 50 | * @sa s3c_gpio_getpull |
51 | */ | 51 | */ |
52 | struct s3c_gpio_cfg { | 52 | struct samsung_gpio_cfg { |
53 | unsigned int cfg_eint; | 53 | unsigned int cfg_eint; |
54 | 54 | ||
55 | s3c_gpio_pull_t (*get_pull)(struct s3c_gpio_chip *chip, unsigned offs); | 55 | samsung_gpio_pull_t (*get_pull)(struct samsung_gpio_chip *chip, unsigned offs); |
56 | int (*set_pull)(struct s3c_gpio_chip *chip, unsigned offs, | 56 | int (*set_pull)(struct samsung_gpio_chip *chip, unsigned offs, |
57 | s3c_gpio_pull_t pull); | 57 | samsung_gpio_pull_t pull); |
58 | 58 | ||
59 | unsigned (*get_config)(struct s3c_gpio_chip *chip, unsigned offs); | 59 | unsigned (*get_config)(struct samsung_gpio_chip *chip, unsigned offs); |
60 | int (*set_config)(struct s3c_gpio_chip *chip, unsigned offs, | 60 | int (*set_config)(struct samsung_gpio_chip *chip, unsigned offs, |
61 | unsigned config); | 61 | unsigned config); |
62 | }; | 62 | }; |
63 | 63 | ||
@@ -69,7 +69,7 @@ struct s3c_gpio_cfg { | |||
69 | #define S3C_GPIO_OUTPUT (S3C_GPIO_SPECIAL(1)) | 69 | #define S3C_GPIO_OUTPUT (S3C_GPIO_SPECIAL(1)) |
70 | #define S3C_GPIO_SFN(x) (S3C_GPIO_SPECIAL(x)) | 70 | #define S3C_GPIO_SFN(x) (S3C_GPIO_SPECIAL(x)) |
71 | 71 | ||
72 | #define s3c_gpio_is_cfg_special(_cfg) \ | 72 | #define samsung_gpio_is_cfg_special(_cfg) \ |
73 | (((_cfg) & S3C_GPIO_SPECIAL_MARK) == S3C_GPIO_SPECIAL_MARK) | 73 | (((_cfg) & S3C_GPIO_SPECIAL_MARK) == S3C_GPIO_SPECIAL_MARK) |
74 | 74 | ||
75 | /** | 75 | /** |
@@ -128,9 +128,9 @@ extern int s3c_gpio_cfgpin_range(unsigned int start, unsigned int nr, | |||
128 | * up or down settings, and it may be dependent on the chip that is being | 128 | * up or down settings, and it may be dependent on the chip that is being |
129 | * used to whether the particular mode is available. | 129 | * used to whether the particular mode is available. |
130 | */ | 130 | */ |
131 | #define S3C_GPIO_PULL_NONE ((__force s3c_gpio_pull_t)0x00) | 131 | #define S3C_GPIO_PULL_NONE ((__force samsung_gpio_pull_t)0x00) |
132 | #define S3C_GPIO_PULL_DOWN ((__force s3c_gpio_pull_t)0x01) | 132 | #define S3C_GPIO_PULL_DOWN ((__force samsung_gpio_pull_t)0x01) |
133 | #define S3C_GPIO_PULL_UP ((__force s3c_gpio_pull_t)0x02) | 133 | #define S3C_GPIO_PULL_UP ((__force samsung_gpio_pull_t)0x02) |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * s3c_gpio_setpull() - set the state of a gpio pin pull resistor | 136 | * s3c_gpio_setpull() - set the state of a gpio pin pull resistor |
@@ -143,7 +143,7 @@ extern int s3c_gpio_cfgpin_range(unsigned int start, unsigned int nr, | |||
143 | * | 143 | * |
144 | * @pull is one of S3C_GPIO_PULL_NONE, S3C_GPIO_PULL_DOWN or S3C_GPIO_PULL_UP. | 144 | * @pull is one of S3C_GPIO_PULL_NONE, S3C_GPIO_PULL_DOWN or S3C_GPIO_PULL_UP. |
145 | */ | 145 | */ |
146 | extern int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull); | 146 | extern int s3c_gpio_setpull(unsigned int pin, samsung_gpio_pull_t pull); |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * s3c_gpio_getpull() - get the pull resistor state of a gpio pin | 149 | * s3c_gpio_getpull() - get the pull resistor state of a gpio pin |
@@ -151,7 +151,7 @@ extern int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull); | |||
151 | * | 151 | * |
152 | * Read the pull resistor value for the specified pin. | 152 | * Read the pull resistor value for the specified pin. |
153 | */ | 153 | */ |
154 | extern s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin); | 154 | extern samsung_gpio_pull_t s3c_gpio_getpull(unsigned int pin); |
155 | 155 | ||
156 | /* configure `all` aspects of an gpio */ | 156 | /* configure `all` aspects of an gpio */ |
157 | 157 | ||
@@ -170,7 +170,7 @@ extern s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin); | |||
170 | * @sa s3c_gpio_cfgpin_range | 170 | * @sa s3c_gpio_cfgpin_range |
171 | */ | 171 | */ |
172 | extern int s3c_gpio_cfgall_range(unsigned int start, unsigned int nr, | 172 | extern int s3c_gpio_cfgall_range(unsigned int start, unsigned int nr, |
173 | unsigned int cfg, s3c_gpio_pull_t pull); | 173 | unsigned int cfg, samsung_gpio_pull_t pull); |
174 | 174 | ||
175 | static inline int s3c_gpio_cfgrange_nopull(unsigned int pin, unsigned int size, | 175 | static inline int s3c_gpio_cfgrange_nopull(unsigned int pin, unsigned int size, |
176 | unsigned int cfg) | 176 | unsigned int cfg) |
diff --git a/arch/arm/plat-samsung/include/plat/gpio-core.h b/arch/arm/plat-samsung/include/plat/gpio-core.h index 8cad4cf19c3c..1fe6917f6a2a 100644 --- a/arch/arm/plat-samsung/include/plat/gpio-core.h +++ b/arch/arm/plat-samsung/include/plat/gpio-core.h | |||
@@ -25,22 +25,22 @@ | |||
25 | * specific code. | 25 | * specific code. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | struct s3c_gpio_chip; | 28 | struct samsung_gpio_chip; |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * struct s3c_gpio_pm - power management (suspend/resume) information | 31 | * struct samsung_gpio_pm - power management (suspend/resume) information |
32 | * @save: Routine to save the state of the GPIO block | 32 | * @save: Routine to save the state of the GPIO block |
33 | * @resume: Routine to resume the GPIO block. | 33 | * @resume: Routine to resume the GPIO block. |
34 | */ | 34 | */ |
35 | struct s3c_gpio_pm { | 35 | struct samsung_gpio_pm { |
36 | void (*save)(struct s3c_gpio_chip *chip); | 36 | void (*save)(struct samsung_gpio_chip *chip); |
37 | void (*resume)(struct s3c_gpio_chip *chip); | 37 | void (*resume)(struct samsung_gpio_chip *chip); |
38 | }; | 38 | }; |
39 | 39 | ||
40 | struct s3c_gpio_cfg; | 40 | struct samsung_gpio_cfg; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * struct s3c_gpio_chip - wrapper for specific implementation of gpio | 43 | * struct samsung_gpio_chip - wrapper for specific implementation of gpio |
44 | * @chip: The chip structure to be exported via gpiolib. | 44 | * @chip: The chip structure to be exported via gpiolib. |
45 | * @base: The base pointer to the gpio configuration registers. | 45 | * @base: The base pointer to the gpio configuration registers. |
46 | * @group: The group register number for gpio interrupt support. | 46 | * @group: The group register number for gpio interrupt support. |
@@ -60,10 +60,10 @@ struct s3c_gpio_cfg; | |||
60 | * CPU cores trying to get one lock for different GPIO banks, where each | 60 | * CPU cores trying to get one lock for different GPIO banks, where each |
61 | * bank of GPIO has its own register space and configuration registers. | 61 | * bank of GPIO has its own register space and configuration registers. |
62 | */ | 62 | */ |
63 | struct s3c_gpio_chip { | 63 | struct samsung_gpio_chip { |
64 | struct gpio_chip chip; | 64 | struct gpio_chip chip; |
65 | struct s3c_gpio_cfg *config; | 65 | struct samsung_gpio_cfg *config; |
66 | struct s3c_gpio_pm *pm; | 66 | struct samsung_gpio_pm *pm; |
67 | void __iomem *base; | 67 | void __iomem *base; |
68 | int irq_base; | 68 | int irq_base; |
69 | int group; | 69 | int group; |
@@ -73,58 +73,11 @@ struct s3c_gpio_chip { | |||
73 | #endif | 73 | #endif |
74 | }; | 74 | }; |
75 | 75 | ||
76 | static inline struct s3c_gpio_chip *to_s3c_gpio(struct gpio_chip *gpc) | 76 | static inline struct samsung_gpio_chip *to_samsung_gpio(struct gpio_chip *gpc) |
77 | { | 77 | { |
78 | return container_of(gpc, struct s3c_gpio_chip, chip); | 78 | return container_of(gpc, struct samsung_gpio_chip, chip); |
79 | } | 79 | } |
80 | 80 | ||
81 | /** s3c_gpiolib_add() - add the s3c specific version of a gpio_chip. | ||
82 | * @chip: The chip to register | ||
83 | * | ||
84 | * This is a wrapper to gpiochip_add() that takes our specific gpio chip | ||
85 | * information and makes the necessary alterations for the platform and | ||
86 | * notes the information for use with the configuration systems and any | ||
87 | * other parts of the system. | ||
88 | */ | ||
89 | extern void s3c_gpiolib_add(struct s3c_gpio_chip *chip); | ||
90 | |||
91 | /* CONFIG_S3C_GPIO_TRACK enables the tracking of the s3c specific gpios | ||
92 | * for use with the configuration calls, and other parts of the s3c gpiolib | ||
93 | * support code. | ||
94 | * | ||
95 | * Not all s3c support code will need this, as some configurations of cpu | ||
96 | * may only support one or two different configuration options and have an | ||
97 | * easy gpio to s3c_gpio_chip mapping function. If this is the case, then | ||
98 | * the machine support file should provide its own s3c_gpiolib_getchip() | ||
99 | * and any other necessary functions. | ||
100 | */ | ||
101 | |||
102 | /** | ||
103 | * samsung_gpiolib_add_4bit_chips - 4bit single register GPIO config. | ||
104 | * @chip: The gpio chip that is being configured. | ||
105 | * @nr_chips: The no of chips (gpio ports) for the GPIO being configured. | ||
106 | * | ||
107 | * This helper deal with the GPIO cases where the control register has 4 bits | ||
108 | * of control per GPIO, generally in the form of: | ||
109 | * 0000 = Input | ||
110 | * 0001 = Output | ||
111 | * others = Special functions (dependent on bank) | ||
112 | * | ||
113 | * Note, since the code to deal with the case where there are two control | ||
114 | * registers instead of one, we do not have a separate set of function | ||
115 | * (samsung_gpiolib_add_4bit2_chips)for each case. | ||
116 | */ | ||
117 | extern void samsung_gpiolib_add_4bit_chips(struct s3c_gpio_chip *chip, | ||
118 | int nr_chips); | ||
119 | extern void samsung_gpiolib_add_4bit2_chips(struct s3c_gpio_chip *chip, | ||
120 | int nr_chips); | ||
121 | extern void samsung_gpiolib_add_2bit_chips(struct s3c_gpio_chip *chip, | ||
122 | int nr_chips); | ||
123 | |||
124 | extern void samsung_gpiolib_add_4bit(struct s3c_gpio_chip *chip); | ||
125 | extern void samsung_gpiolib_add_4bit2(struct s3c_gpio_chip *chip); | ||
126 | |||
127 | |||
128 | /** | 81 | /** |
129 | * samsung_gpiolib_to_irq - convert gpio pin to irq number | 82 | * samsung_gpiolib_to_irq - convert gpio pin to irq number |
130 | * @chip: The gpio chip that the pin belongs to. | 83 | * @chip: The gpio chip that the pin belongs to. |
@@ -136,36 +89,36 @@ extern void samsung_gpiolib_add_4bit2(struct s3c_gpio_chip *chip); | |||
136 | extern int samsung_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset); | 89 | extern int samsung_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset); |
137 | 90 | ||
138 | /* exported for core SoC support to change */ | 91 | /* exported for core SoC support to change */ |
139 | extern struct s3c_gpio_cfg s3c24xx_gpiocfg_default; | 92 | extern struct samsung_gpio_cfg s3c24xx_gpiocfg_default; |
140 | 93 | ||
141 | #ifdef CONFIG_S3C_GPIO_TRACK | 94 | #ifdef CONFIG_S3C_GPIO_TRACK |
142 | extern struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END]; | 95 | extern struct samsung_gpio_chip *s3c_gpios[S3C_GPIO_END]; |
143 | 96 | ||
144 | static inline struct s3c_gpio_chip *s3c_gpiolib_getchip(unsigned int chip) | 97 | static inline struct samsung_gpio_chip *samsung_gpiolib_getchip(unsigned int chip) |
145 | { | 98 | { |
146 | return (chip < S3C_GPIO_END) ? s3c_gpios[chip] : NULL; | 99 | return (chip < S3C_GPIO_END) ? s3c_gpios[chip] : NULL; |
147 | } | 100 | } |
148 | #else | 101 | #else |
149 | /* machine specific code should provide s3c_gpiolib_getchip */ | 102 | /* machine specific code should provide samsung_gpiolib_getchip */ |
150 | 103 | ||
151 | #include <mach/gpio-track.h> | 104 | #include <mach/gpio-track.h> |
152 | 105 | ||
153 | static inline void s3c_gpiolib_track(struct s3c_gpio_chip *chip) { } | 106 | static inline void s3c_gpiolib_track(struct samsung_gpio_chip *chip) { } |
154 | #endif | 107 | #endif |
155 | 108 | ||
156 | #ifdef CONFIG_PM | 109 | #ifdef CONFIG_PM |
157 | extern struct s3c_gpio_pm s3c_gpio_pm_1bit; | 110 | extern struct samsung_gpio_pm samsung_gpio_pm_1bit; |
158 | extern struct s3c_gpio_pm s3c_gpio_pm_2bit; | 111 | extern struct samsung_gpio_pm samsung_gpio_pm_2bit; |
159 | extern struct s3c_gpio_pm s3c_gpio_pm_4bit; | 112 | extern struct samsung_gpio_pm samsung_gpio_pm_4bit; |
160 | #define __gpio_pm(x) x | 113 | #define __gpio_pm(x) x |
161 | #else | 114 | #else |
162 | #define s3c_gpio_pm_1bit NULL | 115 | #define samsung_gpio_pm_1bit NULL |
163 | #define s3c_gpio_pm_2bit NULL | 116 | #define samsung_gpio_pm_2bit NULL |
164 | #define s3c_gpio_pm_4bit NULL | 117 | #define samsung_gpio_pm_4bit NULL |
165 | #define __gpio_pm(x) NULL | 118 | #define __gpio_pm(x) NULL |
166 | 119 | ||
167 | #endif /* CONFIG_PM */ | 120 | #endif /* CONFIG_PM */ |
168 | 121 | ||
169 | /* locking wrappers to deal with multiple access to the same gpio bank */ | 122 | /* locking wrappers to deal with multiple access to the same gpio bank */ |
170 | #define s3c_gpio_lock(_oc, _fl) spin_lock_irqsave(&(_oc)->lock, _fl) | 123 | #define samsung_gpio_lock(_oc, _fl) spin_lock_irqsave(&(_oc)->lock, _fl) |
171 | #define s3c_gpio_unlock(_oc, _fl) spin_unlock_irqrestore(&(_oc)->lock, _fl) | 124 | #define samsung_gpio_unlock(_oc, _fl) spin_unlock_irqrestore(&(_oc)->lock, _fl) |
diff --git a/arch/arm/plat-samsung/include/plat/gpio-fns.h b/arch/arm/plat-samsung/include/plat/gpio-fns.h new file mode 100644 index 000000000000..bab139201761 --- /dev/null +++ b/arch/arm/plat-samsung/include/plat/gpio-fns.h | |||
@@ -0,0 +1,98 @@ | |||
1 | /* arch/arm/mach-s3c2410/include/mach/gpio-fns.h | ||
2 | * | ||
3 | * Copyright (c) 2003-2009 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * | ||
6 | * S3C2410 - hardware | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __MACH_GPIO_FNS_H | ||
14 | #define __MACH_GPIO_FNS_H __FILE__ | ||
15 | |||
16 | /* These functions are in the to-be-removed category and it is strongly | ||
17 | * encouraged not to use these in new code. They will be marked deprecated | ||
18 | * very soon. | ||
19 | * | ||
20 | * Most of the functionality can be either replaced by the gpiocfg calls | ||
21 | * for the s3c platform or by the generic GPIOlib API. | ||
22 | * | ||
23 | * As of 2.6.35-rc, these will be removed, with the few drivers using them | ||
24 | * either replaced or given a wrapper until the calls can be removed. | ||
25 | */ | ||
26 | |||
27 | #include <plat/gpio-cfg.h> | ||
28 | |||
29 | static inline void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int cfg) | ||
30 | { | ||
31 | /* 1:1 mapping between cfgpin and setcfg calls at the moment */ | ||
32 | s3c_gpio_cfgpin(pin, cfg); | ||
33 | } | ||
34 | |||
35 | /* external functions for GPIO support | ||
36 | * | ||
37 | * These allow various different clients to access the same GPIO | ||
38 | * registers without conflicting. If your driver only owns the entire | ||
39 | * GPIO register, then it is safe to ioremap/__raw_{read|write} to it. | ||
40 | */ | ||
41 | |||
42 | extern unsigned int s3c2410_gpio_getcfg(unsigned int pin); | ||
43 | |||
44 | /* s3c2410_gpio_getirq | ||
45 | * | ||
46 | * turn the given pin number into the corresponding IRQ number | ||
47 | * | ||
48 | * returns: | ||
49 | * < 0 = no interrupt for this pin | ||
50 | * >=0 = interrupt number for the pin | ||
51 | */ | ||
52 | |||
53 | extern int s3c2410_gpio_getirq(unsigned int pin); | ||
54 | |||
55 | /* s3c2410_gpio_irqfilter | ||
56 | * | ||
57 | * set the irq filtering on the given pin | ||
58 | * | ||
59 | * on = 0 => disable filtering | ||
60 | * 1 => enable filtering | ||
61 | * | ||
62 | * config = S3C2410_EINTFLT_PCLK or S3C2410_EINTFLT_EXTCLK orred with | ||
63 | * width of filter (0 through 63) | ||
64 | * | ||
65 | * | ||
66 | */ | ||
67 | |||
68 | extern int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on, | ||
69 | unsigned int config); | ||
70 | |||
71 | /* s3c2410_gpio_pullup | ||
72 | * | ||
73 | * This call should be replaced with s3c_gpio_setpull(). | ||
74 | * | ||
75 | * As a note, there is currently no distinction between pull-up and pull-down | ||
76 | * in the s3c24xx series devices with only an on/off configuration. | ||
77 | */ | ||
78 | |||
79 | /* s3c2410_gpio_pullup | ||
80 | * | ||
81 | * configure the pull-up control on the given pin | ||
82 | * | ||
83 | * to = 1 => disable the pull-up | ||
84 | * 0 => enable the pull-up | ||
85 | * | ||
86 | * eg; | ||
87 | * | ||
88 | * s3c2410_gpio_pullup(S3C2410_GPB(0), 0); | ||
89 | * s3c2410_gpio_pullup(S3C2410_GPE(8), 0); | ||
90 | */ | ||
91 | |||
92 | extern void s3c2410_gpio_pullup(unsigned int pin, unsigned int to); | ||
93 | |||
94 | extern void s3c2410_gpio_setpin(unsigned int pin, unsigned int to); | ||
95 | |||
96 | extern unsigned int s3c2410_gpio_getpin(unsigned int pin); | ||
97 | |||
98 | #endif /* __MACH_GPIO_FNS_H */ | ||
diff --git a/arch/arm/plat-samsung/include/plat/iic.h b/arch/arm/plat-samsung/include/plat/iic.h index 56b0059439e1..51d52e767a19 100644 --- a/arch/arm/plat-samsung/include/plat/iic.h +++ b/arch/arm/plat-samsung/include/plat/iic.h | |||
@@ -60,6 +60,7 @@ extern void s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *i2c); | |||
60 | extern void s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *i2c); | 60 | extern void s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *i2c); |
61 | extern void s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *i2c); | 61 | extern void s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *i2c); |
62 | extern void s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *i2c); | 62 | extern void s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *i2c); |
63 | extern void s5p_i2c_hdmiphy_set_platdata(struct s3c2410_platform_i2c *i2c); | ||
63 | 64 | ||
64 | /* defined by architecture to configure gpio */ | 65 | /* defined by architecture to configure gpio */ |
65 | extern void s3c_i2c0_cfg_gpio(struct platform_device *dev); | 66 | extern void s3c_i2c0_cfg_gpio(struct platform_device *dev); |
diff --git a/arch/arm/plat-samsung/include/plat/pm.h b/arch/arm/plat-samsung/include/plat/pm.h index f6749916d194..dcf68709f9cf 100644 --- a/arch/arm/plat-samsung/include/plat/pm.h +++ b/arch/arm/plat-samsung/include/plat/pm.h | |||
@@ -165,20 +165,20 @@ extern void s3c_pm_check_store(void); | |||
165 | extern void s3c_pm_configure_extint(void); | 165 | extern void s3c_pm_configure_extint(void); |
166 | 166 | ||
167 | /** | 167 | /** |
168 | * s3c_pm_restore_gpios() - restore the state of the gpios after sleep. | 168 | * samsung_pm_restore_gpios() - restore the state of the gpios after sleep. |
169 | * | 169 | * |
170 | * Restore the state of the GPIO pins after sleep, which may involve ensuring | 170 | * Restore the state of the GPIO pins after sleep, which may involve ensuring |
171 | * that we do not glitch the state of the pins from that the bootloader's | 171 | * that we do not glitch the state of the pins from that the bootloader's |
172 | * resume code has done. | 172 | * resume code has done. |
173 | */ | 173 | */ |
174 | extern void s3c_pm_restore_gpios(void); | 174 | extern void samsung_pm_restore_gpios(void); |
175 | 175 | ||
176 | /** | 176 | /** |
177 | * s3c_pm_save_gpios() - save the state of the GPIOs for restoring after sleep. | 177 | * samsung_pm_save_gpios() - save the state of the GPIOs for restoring after sleep. |
178 | * | 178 | * |
179 | * Save the GPIO states for resotration on resume. See s3c_pm_restore_gpios(). | 179 | * Save the GPIO states for resotration on resume. See samsung_pm_restore_gpios(). |
180 | */ | 180 | */ |
181 | extern void s3c_pm_save_gpios(void); | 181 | extern void samsung_pm_save_gpios(void); |
182 | 182 | ||
183 | extern void s3c_pm_save_core(void); | 183 | extern void s3c_pm_save_core(void); |
184 | extern void s3c_pm_restore_core(void); | 184 | extern void s3c_pm_restore_core(void); |
diff --git a/arch/arm/plat-samsung/include/plat/s3c-pl330-pdata.h b/arch/arm/plat-samsung/include/plat/s3c-pl330-pdata.h deleted file mode 100644 index bf5e2a9d408d..000000000000 --- a/arch/arm/plat-samsung/include/plat/s3c-pl330-pdata.h +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | /* linux/arch/arm/plat-samsung/include/plat/s3c-pl330-pdata.h | ||
2 | * | ||
3 | * Copyright (C) 2010 Samsung Electronics Co. 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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifndef __S3C_PL330_PDATA_H | ||
13 | #define __S3C_PL330_PDATA_H | ||
14 | |||
15 | #include <plat/s3c-dma-pl330.h> | ||
16 | |||
17 | /* | ||
18 | * Every PL330 DMAC has max 32 peripheral interfaces, | ||
19 | * of which some may be not be really used in your | ||
20 | * DMAC's configuration. | ||
21 | * Populate this array of 32 peri i/fs with relevant | ||
22 | * channel IDs for used peri i/f and DMACH_MAX for | ||
23 | * those unused. | ||
24 | * | ||
25 | * The platforms just need to provide this info | ||
26 | * to the S3C DMA API driver for PL330. | ||
27 | */ | ||
28 | struct s3c_pl330_platdata { | ||
29 | enum dma_ch peri[32]; | ||
30 | }; | ||
31 | |||
32 | #endif /* __S3C_PL330_PDATA_H */ | ||
diff --git a/arch/arm/plat-samsung/include/plat/tv-core.h b/arch/arm/plat-samsung/include/plat/tv-core.h new file mode 100644 index 000000000000..3bc34f3ce28f --- /dev/null +++ b/arch/arm/plat-samsung/include/plat/tv-core.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-samsung/include/plat/tv.h | ||
3 | * | ||
4 | * Copyright 2011 Samsung Electronics Co., Ltd. | ||
5 | * Tomasz Stanislawski <t.stanislaws@samsung.com> | ||
6 | * | ||
7 | * Samsung TV driver core functions | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #ifndef __SAMSUNG_PLAT_TV_H | ||
15 | #define __SAMSUNG_PLAT_TV_H __FILE__ | ||
16 | |||
17 | /* | ||
18 | * These functions are only for use with the core support code, such as | ||
19 | * the CPU-specific initialization code. | ||
20 | */ | ||
21 | |||
22 | /* Re-define device name to differentiate the subsystem in various SoCs. */ | ||
23 | static inline void s5p_hdmi_setname(char *name) | ||
24 | { | ||
25 | #ifdef CONFIG_S5P_DEV_TV | ||
26 | s5p_device_hdmi.name = name; | ||
27 | #endif | ||
28 | } | ||
29 | |||
30 | static inline void s5p_mixer_setname(char *name) | ||
31 | { | ||
32 | #ifdef CONFIG_S5P_DEV_TV | ||
33 | s5p_device_mixer.name = name; | ||
34 | #endif | ||
35 | } | ||
36 | |||
37 | static inline void s5p_sdo_setname(char *name) | ||
38 | { | ||
39 | #ifdef CONFIG_S5P_DEV_TV | ||
40 | s5p_device_sdo.name = name; | ||
41 | #endif | ||
42 | } | ||
43 | |||
44 | #endif /* __SAMSUNG_PLAT_TV_H */ | ||
diff --git a/arch/arm/plat-samsung/pm-gpio.c b/arch/arm/plat-samsung/pm-gpio.c index 96528200eb79..4be016eaa6db 100644 --- a/arch/arm/plat-samsung/pm-gpio.c +++ b/arch/arm/plat-samsung/pm-gpio.c | |||
@@ -28,13 +28,13 @@ | |||
28 | #define OFFS_DAT (0x04) | 28 | #define OFFS_DAT (0x04) |
29 | #define OFFS_UP (0x08) | 29 | #define OFFS_UP (0x08) |
30 | 30 | ||
31 | static void s3c_gpio_pm_1bit_save(struct s3c_gpio_chip *chip) | 31 | static void samsung_gpio_pm_1bit_save(struct samsung_gpio_chip *chip) |
32 | { | 32 | { |
33 | chip->pm_save[0] = __raw_readl(chip->base + OFFS_CON); | 33 | chip->pm_save[0] = __raw_readl(chip->base + OFFS_CON); |
34 | chip->pm_save[1] = __raw_readl(chip->base + OFFS_DAT); | 34 | chip->pm_save[1] = __raw_readl(chip->base + OFFS_DAT); |
35 | } | 35 | } |
36 | 36 | ||
37 | static void s3c_gpio_pm_1bit_resume(struct s3c_gpio_chip *chip) | 37 | static void samsung_gpio_pm_1bit_resume(struct samsung_gpio_chip *chip) |
38 | { | 38 | { |
39 | void __iomem *base = chip->base; | 39 | void __iomem *base = chip->base; |
40 | u32 old_gpcon = __raw_readl(base + OFFS_CON); | 40 | u32 old_gpcon = __raw_readl(base + OFFS_CON); |
@@ -60,12 +60,12 @@ static void s3c_gpio_pm_1bit_resume(struct s3c_gpio_chip *chip) | |||
60 | chip->chip.label, old_gpcon, gps_gpcon, old_gpdat, gps_gpdat); | 60 | chip->chip.label, old_gpcon, gps_gpcon, old_gpdat, gps_gpdat); |
61 | } | 61 | } |
62 | 62 | ||
63 | struct s3c_gpio_pm s3c_gpio_pm_1bit = { | 63 | struct samsung_gpio_pm samsung_gpio_pm_1bit = { |
64 | .save = s3c_gpio_pm_1bit_save, | 64 | .save = samsung_gpio_pm_1bit_save, |
65 | .resume = s3c_gpio_pm_1bit_resume, | 65 | .resume = samsung_gpio_pm_1bit_resume, |
66 | }; | 66 | }; |
67 | 67 | ||
68 | static void s3c_gpio_pm_2bit_save(struct s3c_gpio_chip *chip) | 68 | static void samsung_gpio_pm_2bit_save(struct samsung_gpio_chip *chip) |
69 | { | 69 | { |
70 | chip->pm_save[0] = __raw_readl(chip->base + OFFS_CON); | 70 | chip->pm_save[0] = __raw_readl(chip->base + OFFS_CON); |
71 | chip->pm_save[1] = __raw_readl(chip->base + OFFS_DAT); | 71 | chip->pm_save[1] = __raw_readl(chip->base + OFFS_DAT); |
@@ -95,7 +95,7 @@ static inline int is_out(unsigned long con) | |||
95 | } | 95 | } |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * s3c_gpio_pm_2bit_resume() - restore the given GPIO bank | 98 | * samsung_gpio_pm_2bit_resume() - restore the given GPIO bank |
99 | * @chip: The chip information to resume. | 99 | * @chip: The chip information to resume. |
100 | * | 100 | * |
101 | * Restore one of the GPIO banks that was saved during suspend. This is | 101 | * Restore one of the GPIO banks that was saved during suspend. This is |
@@ -121,7 +121,7 @@ static inline int is_out(unsigned long con) | |||
121 | * [1] this assumes that writing to a pin DAT whilst in SFN will set the | 121 | * [1] this assumes that writing to a pin DAT whilst in SFN will set the |
122 | * state for when it is next output. | 122 | * state for when it is next output. |
123 | */ | 123 | */ |
124 | static void s3c_gpio_pm_2bit_resume(struct s3c_gpio_chip *chip) | 124 | static void samsung_gpio_pm_2bit_resume(struct samsung_gpio_chip *chip) |
125 | { | 125 | { |
126 | void __iomem *base = chip->base; | 126 | void __iomem *base = chip->base; |
127 | u32 old_gpcon = __raw_readl(base + OFFS_CON); | 127 | u32 old_gpcon = __raw_readl(base + OFFS_CON); |
@@ -187,13 +187,13 @@ static void s3c_gpio_pm_2bit_resume(struct s3c_gpio_chip *chip) | |||
187 | chip->chip.label, old_gpcon, gps_gpcon, old_gpdat, gps_gpdat); | 187 | chip->chip.label, old_gpcon, gps_gpcon, old_gpdat, gps_gpdat); |
188 | } | 188 | } |
189 | 189 | ||
190 | struct s3c_gpio_pm s3c_gpio_pm_2bit = { | 190 | struct samsung_gpio_pm samsung_gpio_pm_2bit = { |
191 | .save = s3c_gpio_pm_2bit_save, | 191 | .save = samsung_gpio_pm_2bit_save, |
192 | .resume = s3c_gpio_pm_2bit_resume, | 192 | .resume = samsung_gpio_pm_2bit_resume, |
193 | }; | 193 | }; |
194 | 194 | ||
195 | #if defined(CONFIG_ARCH_S3C64XX) || defined(CONFIG_PLAT_S5P) | 195 | #if defined(CONFIG_ARCH_S3C64XX) || defined(CONFIG_PLAT_S5P) |
196 | static void s3c_gpio_pm_4bit_save(struct s3c_gpio_chip *chip) | 196 | static void samsung_gpio_pm_4bit_save(struct samsung_gpio_chip *chip) |
197 | { | 197 | { |
198 | chip->pm_save[1] = __raw_readl(chip->base + OFFS_CON); | 198 | chip->pm_save[1] = __raw_readl(chip->base + OFFS_CON); |
199 | chip->pm_save[2] = __raw_readl(chip->base + OFFS_DAT); | 199 | chip->pm_save[2] = __raw_readl(chip->base + OFFS_DAT); |
@@ -203,7 +203,7 @@ static void s3c_gpio_pm_4bit_save(struct s3c_gpio_chip *chip) | |||
203 | chip->pm_save[0] = __raw_readl(chip->base - 4); | 203 | chip->pm_save[0] = __raw_readl(chip->base - 4); |
204 | } | 204 | } |
205 | 205 | ||
206 | static u32 s3c_gpio_pm_4bit_mask(u32 old_gpcon, u32 gps_gpcon) | 206 | static u32 samsung_gpio_pm_4bit_mask(u32 old_gpcon, u32 gps_gpcon) |
207 | { | 207 | { |
208 | u32 old, new, mask; | 208 | u32 old, new, mask; |
209 | u32 change_mask = 0x0; | 209 | u32 change_mask = 0x0; |
@@ -242,14 +242,14 @@ static u32 s3c_gpio_pm_4bit_mask(u32 old_gpcon, u32 gps_gpcon) | |||
242 | return change_mask; | 242 | return change_mask; |
243 | } | 243 | } |
244 | 244 | ||
245 | static void s3c_gpio_pm_4bit_con(struct s3c_gpio_chip *chip, int index) | 245 | static void samsung_gpio_pm_4bit_con(struct samsung_gpio_chip *chip, int index) |
246 | { | 246 | { |
247 | void __iomem *con = chip->base + (index * 4); | 247 | void __iomem *con = chip->base + (index * 4); |
248 | u32 old_gpcon = __raw_readl(con); | 248 | u32 old_gpcon = __raw_readl(con); |
249 | u32 gps_gpcon = chip->pm_save[index + 1]; | 249 | u32 gps_gpcon = chip->pm_save[index + 1]; |
250 | u32 gpcon, mask; | 250 | u32 gpcon, mask; |
251 | 251 | ||
252 | mask = s3c_gpio_pm_4bit_mask(old_gpcon, gps_gpcon); | 252 | mask = samsung_gpio_pm_4bit_mask(old_gpcon, gps_gpcon); |
253 | 253 | ||
254 | gpcon = old_gpcon & ~mask; | 254 | gpcon = old_gpcon & ~mask; |
255 | gpcon |= gps_gpcon & mask; | 255 | gpcon |= gps_gpcon & mask; |
@@ -257,7 +257,7 @@ static void s3c_gpio_pm_4bit_con(struct s3c_gpio_chip *chip, int index) | |||
257 | __raw_writel(gpcon, con); | 257 | __raw_writel(gpcon, con); |
258 | } | 258 | } |
259 | 259 | ||
260 | static void s3c_gpio_pm_4bit_resume(struct s3c_gpio_chip *chip) | 260 | static void samsung_gpio_pm_4bit_resume(struct samsung_gpio_chip *chip) |
261 | { | 261 | { |
262 | void __iomem *base = chip->base; | 262 | void __iomem *base = chip->base; |
263 | u32 old_gpcon[2]; | 263 | u32 old_gpcon[2]; |
@@ -269,10 +269,10 @@ static void s3c_gpio_pm_4bit_resume(struct s3c_gpio_chip *chip) | |||
269 | old_gpcon[0] = 0; | 269 | old_gpcon[0] = 0; |
270 | old_gpcon[1] = __raw_readl(base + OFFS_CON); | 270 | old_gpcon[1] = __raw_readl(base + OFFS_CON); |
271 | 271 | ||
272 | s3c_gpio_pm_4bit_con(chip, 0); | 272 | samsung_gpio_pm_4bit_con(chip, 0); |
273 | if (chip->chip.ngpio > 8) { | 273 | if (chip->chip.ngpio > 8) { |
274 | old_gpcon[0] = __raw_readl(base - 4); | 274 | old_gpcon[0] = __raw_readl(base - 4); |
275 | s3c_gpio_pm_4bit_con(chip, -1); | 275 | samsung_gpio_pm_4bit_con(chip, -1); |
276 | } | 276 | } |
277 | 277 | ||
278 | /* Now change the configurations that require DAT,CON */ | 278 | /* Now change the configurations that require DAT,CON */ |
@@ -298,19 +298,19 @@ static void s3c_gpio_pm_4bit_resume(struct s3c_gpio_chip *chip) | |||
298 | old_gpdat, gps_gpdat); | 298 | old_gpdat, gps_gpdat); |
299 | } | 299 | } |
300 | 300 | ||
301 | struct s3c_gpio_pm s3c_gpio_pm_4bit = { | 301 | struct samsung_gpio_pm samsung_gpio_pm_4bit = { |
302 | .save = s3c_gpio_pm_4bit_save, | 302 | .save = samsung_gpio_pm_4bit_save, |
303 | .resume = s3c_gpio_pm_4bit_resume, | 303 | .resume = samsung_gpio_pm_4bit_resume, |
304 | }; | 304 | }; |
305 | #endif /* CONFIG_ARCH_S3C64XX || CONFIG_PLAT_S5P */ | 305 | #endif /* CONFIG_ARCH_S3C64XX || CONFIG_PLAT_S5P */ |
306 | 306 | ||
307 | /** | 307 | /** |
308 | * s3c_pm_save_gpio() - save gpio chip data for suspend | 308 | * samsung_pm_save_gpio() - save gpio chip data for suspend |
309 | * @ourchip: The chip for suspend. | 309 | * @ourchip: The chip for suspend. |
310 | */ | 310 | */ |
311 | static void s3c_pm_save_gpio(struct s3c_gpio_chip *ourchip) | 311 | static void samsung_pm_save_gpio(struct samsung_gpio_chip *ourchip) |
312 | { | 312 | { |
313 | struct s3c_gpio_pm *pm = ourchip->pm; | 313 | struct samsung_gpio_pm *pm = ourchip->pm; |
314 | 314 | ||
315 | if (pm == NULL || pm->save == NULL) | 315 | if (pm == NULL || pm->save == NULL) |
316 | S3C_PMDBG("%s: no pm for %s\n", __func__, ourchip->chip.label); | 316 | S3C_PMDBG("%s: no pm for %s\n", __func__, ourchip->chip.label); |
@@ -319,24 +319,24 @@ static void s3c_pm_save_gpio(struct s3c_gpio_chip *ourchip) | |||
319 | } | 319 | } |
320 | 320 | ||
321 | /** | 321 | /** |
322 | * s3c_pm_save_gpios() - Save the state of the GPIO banks. | 322 | * samsung_pm_save_gpios() - Save the state of the GPIO banks. |
323 | * | 323 | * |
324 | * For all the GPIO banks, save the state of each one ready for going | 324 | * For all the GPIO banks, save the state of each one ready for going |
325 | * into a suspend mode. | 325 | * into a suspend mode. |
326 | */ | 326 | */ |
327 | void s3c_pm_save_gpios(void) | 327 | void samsung_pm_save_gpios(void) |
328 | { | 328 | { |
329 | struct s3c_gpio_chip *ourchip; | 329 | struct samsung_gpio_chip *ourchip; |
330 | unsigned int gpio_nr; | 330 | unsigned int gpio_nr; |
331 | 331 | ||
332 | for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) { | 332 | for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) { |
333 | ourchip = s3c_gpiolib_getchip(gpio_nr); | 333 | ourchip = samsung_gpiolib_getchip(gpio_nr); |
334 | if (!ourchip) { | 334 | if (!ourchip) { |
335 | gpio_nr++; | 335 | gpio_nr++; |
336 | continue; | 336 | continue; |
337 | } | 337 | } |
338 | 338 | ||
339 | s3c_pm_save_gpio(ourchip); | 339 | samsung_pm_save_gpio(ourchip); |
340 | 340 | ||
341 | S3C_PMDBG("%s: save %08x,%08x,%08x,%08x\n", | 341 | S3C_PMDBG("%s: save %08x,%08x,%08x,%08x\n", |
342 | ourchip->chip.label, | 342 | ourchip->chip.label, |
@@ -351,12 +351,12 @@ void s3c_pm_save_gpios(void) | |||
351 | } | 351 | } |
352 | 352 | ||
353 | /** | 353 | /** |
354 | * s3c_pm_resume_gpio() - restore gpio chip data after suspend | 354 | * samsung_pm_resume_gpio() - restore gpio chip data after suspend |
355 | * @ourchip: The suspended chip. | 355 | * @ourchip: The suspended chip. |
356 | */ | 356 | */ |
357 | static void s3c_pm_resume_gpio(struct s3c_gpio_chip *ourchip) | 357 | static void samsung_pm_resume_gpio(struct samsung_gpio_chip *ourchip) |
358 | { | 358 | { |
359 | struct s3c_gpio_pm *pm = ourchip->pm; | 359 | struct samsung_gpio_pm *pm = ourchip->pm; |
360 | 360 | ||
361 | if (pm == NULL || pm->resume == NULL) | 361 | if (pm == NULL || pm->resume == NULL) |
362 | S3C_PMDBG("%s: no pm for %s\n", __func__, ourchip->chip.label); | 362 | S3C_PMDBG("%s: no pm for %s\n", __func__, ourchip->chip.label); |
@@ -364,19 +364,19 @@ static void s3c_pm_resume_gpio(struct s3c_gpio_chip *ourchip) | |||
364 | pm->resume(ourchip); | 364 | pm->resume(ourchip); |
365 | } | 365 | } |
366 | 366 | ||
367 | void s3c_pm_restore_gpios(void) | 367 | void samsung_pm_restore_gpios(void) |
368 | { | 368 | { |
369 | struct s3c_gpio_chip *ourchip; | 369 | struct samsung_gpio_chip *ourchip; |
370 | unsigned int gpio_nr; | 370 | unsigned int gpio_nr; |
371 | 371 | ||
372 | for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) { | 372 | for (gpio_nr = 0; gpio_nr < S3C_GPIO_END;) { |
373 | ourchip = s3c_gpiolib_getchip(gpio_nr); | 373 | ourchip = samsung_gpiolib_getchip(gpio_nr); |
374 | if (!ourchip) { | 374 | if (!ourchip) { |
375 | gpio_nr++; | 375 | gpio_nr++; |
376 | continue; | 376 | continue; |
377 | } | 377 | } |
378 | 378 | ||
379 | s3c_pm_resume_gpio(ourchip); | 379 | samsung_pm_resume_gpio(ourchip); |
380 | 380 | ||
381 | gpio_nr += ourchip->chip.ngpio; | 381 | gpio_nr += ourchip->chip.ngpio; |
382 | gpio_nr += CONFIG_S3C_GPIO_SPACE; | 382 | gpio_nr += CONFIG_S3C_GPIO_SPACE; |
diff --git a/arch/arm/plat-samsung/pm.c b/arch/arm/plat-samsung/pm.c index ae6f99834cdd..64ab65f0fdbc 100644 --- a/arch/arm/plat-samsung/pm.c +++ b/arch/arm/plat-samsung/pm.c | |||
@@ -268,8 +268,8 @@ static int s3c_pm_enter(suspend_state_t state) | |||
268 | 268 | ||
269 | /* save all necessary core registers not covered by the drivers */ | 269 | /* save all necessary core registers not covered by the drivers */ |
270 | 270 | ||
271 | s3c_pm_save_gpios(); | 271 | samsung_pm_save_gpios(); |
272 | s3c_pm_saved_gpios(); | 272 | samsung_pm_saved_gpios(); |
273 | s3c_pm_save_uarts(); | 273 | s3c_pm_save_uarts(); |
274 | s3c_pm_save_core(); | 274 | s3c_pm_save_core(); |
275 | 275 | ||
@@ -306,7 +306,7 @@ static int s3c_pm_enter(suspend_state_t state) | |||
306 | 306 | ||
307 | s3c_pm_restore_core(); | 307 | s3c_pm_restore_core(); |
308 | s3c_pm_restore_uarts(); | 308 | s3c_pm_restore_uarts(); |
309 | s3c_pm_restore_gpios(); | 309 | samsung_pm_restore_gpios(); |
310 | s3c_pm_restored_gpios(); | 310 | s3c_pm_restored_gpios(); |
311 | 311 | ||
312 | s3c_pm_debug_init(); | 312 | s3c_pm_debug_init(); |
diff --git a/arch/arm/plat-samsung/s3c-dma-ops.c b/arch/arm/plat-samsung/s3c-dma-ops.c new file mode 100644 index 000000000000..582333c70585 --- /dev/null +++ b/arch/arm/plat-samsung/s3c-dma-ops.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /* linux/arch/arm/plat-samsung/s3c-dma-ops.c | ||
2 | * | ||
3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * Samsung S3C-DMA Operations | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/slab.h> | ||
16 | #include <linux/types.h> | ||
17 | |||
18 | #include <mach/dma.h> | ||
19 | |||
20 | struct cb_data { | ||
21 | void (*fp) (void *); | ||
22 | void *fp_param; | ||
23 | unsigned ch; | ||
24 | struct list_head node; | ||
25 | }; | ||
26 | |||
27 | static LIST_HEAD(dma_list); | ||
28 | |||
29 | static void s3c_dma_cb(struct s3c2410_dma_chan *channel, void *param, | ||
30 | int size, enum s3c2410_dma_buffresult res) | ||
31 | { | ||
32 | struct cb_data *data = param; | ||
33 | |||
34 | data->fp(data->fp_param); | ||
35 | } | ||
36 | |||
37 | static unsigned s3c_dma_request(enum dma_ch dma_ch, | ||
38 | struct samsung_dma_info *info) | ||
39 | { | ||
40 | struct cb_data *data; | ||
41 | |||
42 | if (s3c2410_dma_request(dma_ch, info->client, NULL) < 0) { | ||
43 | s3c2410_dma_free(dma_ch, info->client); | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | data = kzalloc(sizeof(struct cb_data), GFP_KERNEL); | ||
48 | data->ch = dma_ch; | ||
49 | list_add_tail(&data->node, &dma_list); | ||
50 | |||
51 | s3c2410_dma_devconfig(dma_ch, info->direction, info->fifo); | ||
52 | |||
53 | if (info->cap == DMA_CYCLIC) | ||
54 | s3c2410_dma_setflags(dma_ch, S3C2410_DMAF_CIRCULAR); | ||
55 | |||
56 | s3c2410_dma_config(dma_ch, info->width); | ||
57 | |||
58 | return (unsigned)dma_ch; | ||
59 | } | ||
60 | |||
61 | static int s3c_dma_release(unsigned ch, struct s3c2410_dma_client *client) | ||
62 | { | ||
63 | struct cb_data *data; | ||
64 | |||
65 | list_for_each_entry(data, &dma_list, node) | ||
66 | if (data->ch == ch) | ||
67 | break; | ||
68 | list_del(&data->node); | ||
69 | |||
70 | s3c2410_dma_free(ch, client); | ||
71 | kfree(data); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static int s3c_dma_prepare(unsigned ch, struct samsung_dma_prep_info *info) | ||
77 | { | ||
78 | struct cb_data *data; | ||
79 | int len = (info->cap == DMA_CYCLIC) ? info->period : info->len; | ||
80 | |||
81 | list_for_each_entry(data, &dma_list, node) | ||
82 | if (data->ch == ch) | ||
83 | break; | ||
84 | |||
85 | if (!data->fp) { | ||
86 | s3c2410_dma_set_buffdone_fn(ch, s3c_dma_cb); | ||
87 | data->fp = info->fp; | ||
88 | data->fp_param = info->fp_param; | ||
89 | } | ||
90 | |||
91 | s3c2410_dma_enqueue(ch, (void *)data, info->buf, len); | ||
92 | |||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static inline int s3c_dma_trigger(unsigned ch) | ||
97 | { | ||
98 | return s3c2410_dma_ctrl(ch, S3C2410_DMAOP_START); | ||
99 | } | ||
100 | |||
101 | static inline int s3c_dma_started(unsigned ch) | ||
102 | { | ||
103 | return s3c2410_dma_ctrl(ch, S3C2410_DMAOP_STARTED); | ||
104 | } | ||
105 | |||
106 | static inline int s3c_dma_flush(unsigned ch) | ||
107 | { | ||
108 | return s3c2410_dma_ctrl(ch, S3C2410_DMAOP_FLUSH); | ||
109 | } | ||
110 | |||
111 | static inline int s3c_dma_stop(unsigned ch) | ||
112 | { | ||
113 | return s3c2410_dma_ctrl(ch, S3C2410_DMAOP_STOP); | ||
114 | } | ||
115 | |||
116 | static struct samsung_dma_ops s3c_dma_ops = { | ||
117 | .request = s3c_dma_request, | ||
118 | .release = s3c_dma_release, | ||
119 | .prepare = s3c_dma_prepare, | ||
120 | .trigger = s3c_dma_trigger, | ||
121 | .started = s3c_dma_started, | ||
122 | .flush = s3c_dma_flush, | ||
123 | .stop = s3c_dma_stop, | ||
124 | }; | ||
125 | |||
126 | void *s3c_dma_get_ops(void) | ||
127 | { | ||
128 | return &s3c_dma_ops; | ||
129 | } | ||
130 | EXPORT_SYMBOL(s3c_dma_get_ops); | ||
diff --git a/arch/arm/plat-samsung/s3c-pl330.c b/arch/arm/plat-samsung/s3c-pl330.c deleted file mode 100644 index f85638c6f5ae..000000000000 --- a/arch/arm/plat-samsung/s3c-pl330.c +++ /dev/null | |||
@@ -1,1244 +0,0 @@ | |||
1 | /* linux/arch/arm/plat-samsung/s3c-pl330.c | ||
2 | * | ||
3 | * Copyright (C) 2010 Samsung Electronics Co. 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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/init.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/clk.h> | ||
19 | #include <linux/err.h> | ||
20 | |||
21 | #include <asm/hardware/pl330.h> | ||
22 | |||
23 | #include <plat/s3c-pl330-pdata.h> | ||
24 | |||
25 | /** | ||
26 | * struct s3c_pl330_dmac - Logical representation of a PL330 DMAC. | ||
27 | * @busy_chan: Number of channels currently busy. | ||
28 | * @peri: List of IDs of peripherals this DMAC can work with. | ||
29 | * @node: To attach to the global list of DMACs. | ||
30 | * @pi: PL330 configuration info for the DMAC. | ||
31 | * @kmcache: Pool to quickly allocate xfers for all channels in the dmac. | ||
32 | * @clk: Pointer of DMAC operation clock. | ||
33 | */ | ||
34 | struct s3c_pl330_dmac { | ||
35 | unsigned busy_chan; | ||
36 | enum dma_ch *peri; | ||
37 | struct list_head node; | ||
38 | struct pl330_info *pi; | ||
39 | struct kmem_cache *kmcache; | ||
40 | struct clk *clk; | ||
41 | }; | ||
42 | |||
43 | /** | ||
44 | * struct s3c_pl330_xfer - A request submitted by S3C DMA clients. | ||
45 | * @token: Xfer ID provided by the client. | ||
46 | * @node: To attach to the list of xfers on a channel. | ||
47 | * @px: Xfer for PL330 core. | ||
48 | * @chan: Owner channel of this xfer. | ||
49 | */ | ||
50 | struct s3c_pl330_xfer { | ||
51 | void *token; | ||
52 | struct list_head node; | ||
53 | struct pl330_xfer px; | ||
54 | struct s3c_pl330_chan *chan; | ||
55 | }; | ||
56 | |||
57 | /** | ||
58 | * struct s3c_pl330_chan - Logical channel to communicate with | ||
59 | * a Physical peripheral. | ||
60 | * @pl330_chan_id: Token of a hardware channel thread of PL330 DMAC. | ||
61 | * NULL if the channel is available to be acquired. | ||
62 | * @id: ID of the peripheral that this channel can communicate with. | ||
63 | * @options: Options specified by the client. | ||
64 | * @sdaddr: Address provided via s3c2410_dma_devconfig. | ||
65 | * @node: To attach to the global list of channels. | ||
66 | * @lrq: Pointer to the last submitted pl330_req to PL330 core. | ||
67 | * @xfer_list: To manage list of xfers enqueued. | ||
68 | * @req: Two requests to communicate with the PL330 engine. | ||
69 | * @callback_fn: Callback function to the client. | ||
70 | * @rqcfg: Channel configuration for the xfers. | ||
71 | * @xfer_head: Pointer to the xfer to be next executed. | ||
72 | * @dmac: Pointer to the DMAC that manages this channel, NULL if the | ||
73 | * channel is available to be acquired. | ||
74 | * @client: Client of this channel. NULL if the | ||
75 | * channel is available to be acquired. | ||
76 | */ | ||
77 | struct s3c_pl330_chan { | ||
78 | void *pl330_chan_id; | ||
79 | enum dma_ch id; | ||
80 | unsigned int options; | ||
81 | unsigned long sdaddr; | ||
82 | struct list_head node; | ||
83 | struct pl330_req *lrq; | ||
84 | struct list_head xfer_list; | ||
85 | struct pl330_req req[2]; | ||
86 | s3c2410_dma_cbfn_t callback_fn; | ||
87 | struct pl330_reqcfg rqcfg; | ||
88 | struct s3c_pl330_xfer *xfer_head; | ||
89 | struct s3c_pl330_dmac *dmac; | ||
90 | struct s3c2410_dma_client *client; | ||
91 | }; | ||
92 | |||
93 | /* All DMACs in the platform */ | ||
94 | static LIST_HEAD(dmac_list); | ||
95 | |||
96 | /* All channels to peripherals in the platform */ | ||
97 | static LIST_HEAD(chan_list); | ||
98 | |||
99 | /* | ||
100 | * Since we add resources(DMACs and Channels) to the global pool, | ||
101 | * we need to guard access to the resources using a global lock | ||
102 | */ | ||
103 | static DEFINE_SPINLOCK(res_lock); | ||
104 | |||
105 | /* Returns the channel with ID 'id' in the chan_list */ | ||
106 | static struct s3c_pl330_chan *id_to_chan(const enum dma_ch id) | ||
107 | { | ||
108 | struct s3c_pl330_chan *ch; | ||
109 | |||
110 | list_for_each_entry(ch, &chan_list, node) | ||
111 | if (ch->id == id) | ||
112 | return ch; | ||
113 | |||
114 | return NULL; | ||
115 | } | ||
116 | |||
117 | /* Allocate a new channel with ID 'id' and add to chan_list */ | ||
118 | static void chan_add(const enum dma_ch id) | ||
119 | { | ||
120 | struct s3c_pl330_chan *ch = id_to_chan(id); | ||
121 | |||
122 | /* Return if the channel already exists */ | ||
123 | if (ch) | ||
124 | return; | ||
125 | |||
126 | ch = kmalloc(sizeof(*ch), GFP_KERNEL); | ||
127 | /* Return silently to work with other channels */ | ||
128 | if (!ch) | ||
129 | return; | ||
130 | |||
131 | ch->id = id; | ||
132 | ch->dmac = NULL; | ||
133 | |||
134 | list_add_tail(&ch->node, &chan_list); | ||
135 | } | ||
136 | |||
137 | /* If the channel is not yet acquired by any client */ | ||
138 | static bool chan_free(struct s3c_pl330_chan *ch) | ||
139 | { | ||
140 | if (!ch) | ||
141 | return false; | ||
142 | |||
143 | /* Channel points to some DMAC only when it's acquired */ | ||
144 | return ch->dmac ? false : true; | ||
145 | } | ||
146 | |||
147 | /* | ||
148 | * Returns 0 is peripheral i/f is invalid or not present on the dmac. | ||
149 | * Index + 1, otherwise. | ||
150 | */ | ||
151 | static unsigned iface_of_dmac(struct s3c_pl330_dmac *dmac, enum dma_ch ch_id) | ||
152 | { | ||
153 | enum dma_ch *id = dmac->peri; | ||
154 | int i; | ||
155 | |||
156 | /* Discount invalid markers */ | ||
157 | if (ch_id == DMACH_MAX) | ||
158 | return 0; | ||
159 | |||
160 | for (i = 0; i < PL330_MAX_PERI; i++) | ||
161 | if (id[i] == ch_id) | ||
162 | return i + 1; | ||
163 | |||
164 | return 0; | ||
165 | } | ||
166 | |||
167 | /* If all channel threads of the DMAC are busy */ | ||
168 | static inline bool dmac_busy(struct s3c_pl330_dmac *dmac) | ||
169 | { | ||
170 | struct pl330_info *pi = dmac->pi; | ||
171 | |||
172 | return (dmac->busy_chan < pi->pcfg.num_chan) ? false : true; | ||
173 | } | ||
174 | |||
175 | /* | ||
176 | * Returns the number of free channels that | ||
177 | * can be handled by this dmac only. | ||
178 | */ | ||
179 | static unsigned ch_onlyby_dmac(struct s3c_pl330_dmac *dmac) | ||
180 | { | ||
181 | enum dma_ch *id = dmac->peri; | ||
182 | struct s3c_pl330_dmac *d; | ||
183 | struct s3c_pl330_chan *ch; | ||
184 | unsigned found, count = 0; | ||
185 | enum dma_ch p; | ||
186 | int i; | ||
187 | |||
188 | for (i = 0; i < PL330_MAX_PERI; i++) { | ||
189 | p = id[i]; | ||
190 | ch = id_to_chan(p); | ||
191 | |||
192 | if (p == DMACH_MAX || !chan_free(ch)) | ||
193 | continue; | ||
194 | |||
195 | found = 0; | ||
196 | list_for_each_entry(d, &dmac_list, node) { | ||
197 | if (d != dmac && iface_of_dmac(d, ch->id)) { | ||
198 | found = 1; | ||
199 | break; | ||
200 | } | ||
201 | } | ||
202 | if (!found) | ||
203 | count++; | ||
204 | } | ||
205 | |||
206 | return count; | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * Measure of suitability of 'dmac' handling 'ch' | ||
211 | * | ||
212 | * 0 indicates 'dmac' can not handle 'ch' either | ||
213 | * because it is not supported by the hardware or | ||
214 | * because all dmac channels are currently busy. | ||
215 | * | ||
216 | * >0 vlaue indicates 'dmac' has the capability. | ||
217 | * The bigger the value the more suitable the dmac. | ||
218 | */ | ||
219 | #define MAX_SUIT UINT_MAX | ||
220 | #define MIN_SUIT 0 | ||
221 | |||
222 | static unsigned suitablility(struct s3c_pl330_dmac *dmac, | ||
223 | struct s3c_pl330_chan *ch) | ||
224 | { | ||
225 | struct pl330_info *pi = dmac->pi; | ||
226 | enum dma_ch *id = dmac->peri; | ||
227 | struct s3c_pl330_dmac *d; | ||
228 | unsigned s; | ||
229 | int i; | ||
230 | |||
231 | s = MIN_SUIT; | ||
232 | /* If all the DMAC channel threads are busy */ | ||
233 | if (dmac_busy(dmac)) | ||
234 | return s; | ||
235 | |||
236 | for (i = 0; i < PL330_MAX_PERI; i++) | ||
237 | if (id[i] == ch->id) | ||
238 | break; | ||
239 | |||
240 | /* If the 'dmac' can't talk to 'ch' */ | ||
241 | if (i == PL330_MAX_PERI) | ||
242 | return s; | ||
243 | |||
244 | s = MAX_SUIT; | ||
245 | list_for_each_entry(d, &dmac_list, node) { | ||
246 | /* | ||
247 | * If some other dmac can talk to this | ||
248 | * peri and has some channel free. | ||
249 | */ | ||
250 | if (d != dmac && iface_of_dmac(d, ch->id) && !dmac_busy(d)) { | ||
251 | s = 0; | ||
252 | break; | ||
253 | } | ||
254 | } | ||
255 | if (s) | ||
256 | return s; | ||
257 | |||
258 | s = 100; | ||
259 | |||
260 | /* Good if free chans are more, bad otherwise */ | ||
261 | s += (pi->pcfg.num_chan - dmac->busy_chan) - ch_onlyby_dmac(dmac); | ||
262 | |||
263 | return s; | ||
264 | } | ||
265 | |||
266 | /* More than one DMAC may have capability to transfer data with the | ||
267 | * peripheral. This function assigns most suitable DMAC to manage the | ||
268 | * channel and hence communicate with the peripheral. | ||
269 | */ | ||
270 | static struct s3c_pl330_dmac *map_chan_to_dmac(struct s3c_pl330_chan *ch) | ||
271 | { | ||
272 | struct s3c_pl330_dmac *d, *dmac = NULL; | ||
273 | unsigned sn, sl = MIN_SUIT; | ||
274 | |||
275 | list_for_each_entry(d, &dmac_list, node) { | ||
276 | sn = suitablility(d, ch); | ||
277 | |||
278 | if (sn == MAX_SUIT) | ||
279 | return d; | ||
280 | |||
281 | if (sn > sl) | ||
282 | dmac = d; | ||
283 | } | ||
284 | |||
285 | return dmac; | ||
286 | } | ||
287 | |||
288 | /* Acquire the channel for peripheral 'id' */ | ||
289 | static struct s3c_pl330_chan *chan_acquire(const enum dma_ch id) | ||
290 | { | ||
291 | struct s3c_pl330_chan *ch = id_to_chan(id); | ||
292 | struct s3c_pl330_dmac *dmac; | ||
293 | |||
294 | /* If the channel doesn't exist or is already acquired */ | ||
295 | if (!ch || !chan_free(ch)) { | ||
296 | ch = NULL; | ||
297 | goto acq_exit; | ||
298 | } | ||
299 | |||
300 | dmac = map_chan_to_dmac(ch); | ||
301 | /* If couldn't map */ | ||
302 | if (!dmac) { | ||
303 | ch = NULL; | ||
304 | goto acq_exit; | ||
305 | } | ||
306 | |||
307 | dmac->busy_chan++; | ||
308 | ch->dmac = dmac; | ||
309 | |||
310 | acq_exit: | ||
311 | return ch; | ||
312 | } | ||
313 | |||
314 | /* Delete xfer from the queue */ | ||
315 | static inline void del_from_queue(struct s3c_pl330_xfer *xfer) | ||
316 | { | ||
317 | struct s3c_pl330_xfer *t; | ||
318 | struct s3c_pl330_chan *ch; | ||
319 | int found; | ||
320 | |||
321 | if (!xfer) | ||
322 | return; | ||
323 | |||
324 | ch = xfer->chan; | ||
325 | |||
326 | /* Make sure xfer is in the queue */ | ||
327 | found = 0; | ||
328 | list_for_each_entry(t, &ch->xfer_list, node) | ||
329 | if (t == xfer) { | ||
330 | found = 1; | ||
331 | break; | ||
332 | } | ||
333 | |||
334 | if (!found) | ||
335 | return; | ||
336 | |||
337 | /* If xfer is last entry in the queue */ | ||
338 | if (xfer->node.next == &ch->xfer_list) | ||
339 | t = list_entry(ch->xfer_list.next, | ||
340 | struct s3c_pl330_xfer, node); | ||
341 | else | ||
342 | t = list_entry(xfer->node.next, | ||
343 | struct s3c_pl330_xfer, node); | ||
344 | |||
345 | /* If there was only one node left */ | ||
346 | if (t == xfer) | ||
347 | ch->xfer_head = NULL; | ||
348 | else if (ch->xfer_head == xfer) | ||
349 | ch->xfer_head = t; | ||
350 | |||
351 | list_del(&xfer->node); | ||
352 | } | ||
353 | |||
354 | /* Provides pointer to the next xfer in the queue. | ||
355 | * If CIRCULAR option is set, the list is left intact, | ||
356 | * otherwise the xfer is removed from the list. | ||
357 | * Forced delete 'pluck' can be set to override the CIRCULAR option. | ||
358 | */ | ||
359 | static struct s3c_pl330_xfer *get_from_queue(struct s3c_pl330_chan *ch, | ||
360 | int pluck) | ||
361 | { | ||
362 | struct s3c_pl330_xfer *xfer = ch->xfer_head; | ||
363 | |||
364 | if (!xfer) | ||
365 | return NULL; | ||
366 | |||
367 | /* If xfer is last entry in the queue */ | ||
368 | if (xfer->node.next == &ch->xfer_list) | ||
369 | ch->xfer_head = list_entry(ch->xfer_list.next, | ||
370 | struct s3c_pl330_xfer, node); | ||
371 | else | ||
372 | ch->xfer_head = list_entry(xfer->node.next, | ||
373 | struct s3c_pl330_xfer, node); | ||
374 | |||
375 | if (pluck || !(ch->options & S3C2410_DMAF_CIRCULAR)) | ||
376 | del_from_queue(xfer); | ||
377 | |||
378 | return xfer; | ||
379 | } | ||
380 | |||
381 | static inline void add_to_queue(struct s3c_pl330_chan *ch, | ||
382 | struct s3c_pl330_xfer *xfer, int front) | ||
383 | { | ||
384 | struct pl330_xfer *xt; | ||
385 | |||
386 | /* If queue empty */ | ||
387 | if (ch->xfer_head == NULL) | ||
388 | ch->xfer_head = xfer; | ||
389 | |||
390 | xt = &ch->xfer_head->px; | ||
391 | /* If the head already submitted (CIRCULAR head) */ | ||
392 | if (ch->options & S3C2410_DMAF_CIRCULAR && | ||
393 | (xt == ch->req[0].x || xt == ch->req[1].x)) | ||
394 | ch->xfer_head = xfer; | ||
395 | |||
396 | /* If this is a resubmission, it should go at the head */ | ||
397 | if (front) { | ||
398 | ch->xfer_head = xfer; | ||
399 | list_add(&xfer->node, &ch->xfer_list); | ||
400 | } else { | ||
401 | list_add_tail(&xfer->node, &ch->xfer_list); | ||
402 | } | ||
403 | } | ||
404 | |||
405 | static inline void _finish_off(struct s3c_pl330_xfer *xfer, | ||
406 | enum s3c2410_dma_buffresult res, int ffree) | ||
407 | { | ||
408 | struct s3c_pl330_chan *ch; | ||
409 | |||
410 | if (!xfer) | ||
411 | return; | ||
412 | |||
413 | ch = xfer->chan; | ||
414 | |||
415 | /* Do callback */ | ||
416 | if (ch->callback_fn) | ||
417 | ch->callback_fn(NULL, xfer->token, xfer->px.bytes, res); | ||
418 | |||
419 | /* Force Free or if buffer is not needed anymore */ | ||
420 | if (ffree || !(ch->options & S3C2410_DMAF_CIRCULAR)) | ||
421 | kmem_cache_free(ch->dmac->kmcache, xfer); | ||
422 | } | ||
423 | |||
424 | static inline int s3c_pl330_submit(struct s3c_pl330_chan *ch, | ||
425 | struct pl330_req *r) | ||
426 | { | ||
427 | struct s3c_pl330_xfer *xfer; | ||
428 | int ret = 0; | ||
429 | |||
430 | /* If already submitted */ | ||
431 | if (r->x) | ||
432 | return 0; | ||
433 | |||
434 | xfer = get_from_queue(ch, 0); | ||
435 | if (xfer) { | ||
436 | r->x = &xfer->px; | ||
437 | |||
438 | /* Use max bandwidth for M<->M xfers */ | ||
439 | if (r->rqtype == MEMTOMEM) { | ||
440 | struct pl330_info *pi = xfer->chan->dmac->pi; | ||
441 | int burst = 1 << ch->rqcfg.brst_size; | ||
442 | u32 bytes = r->x->bytes; | ||
443 | int bl; | ||
444 | |||
445 | bl = pi->pcfg.data_bus_width / 8; | ||
446 | bl *= pi->pcfg.data_buf_dep; | ||
447 | bl /= burst; | ||
448 | |||
449 | /* src/dst_burst_len can't be more than 16 */ | ||
450 | if (bl > 16) | ||
451 | bl = 16; | ||
452 | |||
453 | while (bl > 1) { | ||
454 | if (!(bytes % (bl * burst))) | ||
455 | break; | ||
456 | bl--; | ||
457 | } | ||
458 | |||
459 | ch->rqcfg.brst_len = bl; | ||
460 | } else { | ||
461 | ch->rqcfg.brst_len = 1; | ||
462 | } | ||
463 | |||
464 | ret = pl330_submit_req(ch->pl330_chan_id, r); | ||
465 | |||
466 | /* If submission was successful */ | ||
467 | if (!ret) { | ||
468 | ch->lrq = r; /* latest submitted req */ | ||
469 | return 0; | ||
470 | } | ||
471 | |||
472 | r->x = NULL; | ||
473 | |||
474 | /* If both of the PL330 ping-pong buffers filled */ | ||
475 | if (ret == -EAGAIN) { | ||
476 | dev_err(ch->dmac->pi->dev, "%s:%d!\n", | ||
477 | __func__, __LINE__); | ||
478 | /* Queue back again */ | ||
479 | add_to_queue(ch, xfer, 1); | ||
480 | ret = 0; | ||
481 | } else { | ||
482 | dev_err(ch->dmac->pi->dev, "%s:%d!\n", | ||
483 | __func__, __LINE__); | ||
484 | _finish_off(xfer, S3C2410_RES_ERR, 0); | ||
485 | } | ||
486 | } | ||
487 | |||
488 | return ret; | ||
489 | } | ||
490 | |||
491 | static void s3c_pl330_rq(struct s3c_pl330_chan *ch, | ||
492 | struct pl330_req *r, enum pl330_op_err err) | ||
493 | { | ||
494 | unsigned long flags; | ||
495 | struct s3c_pl330_xfer *xfer; | ||
496 | struct pl330_xfer *xl = r->x; | ||
497 | enum s3c2410_dma_buffresult res; | ||
498 | |||
499 | spin_lock_irqsave(&res_lock, flags); | ||
500 | |||
501 | r->x = NULL; | ||
502 | |||
503 | s3c_pl330_submit(ch, r); | ||
504 | |||
505 | spin_unlock_irqrestore(&res_lock, flags); | ||
506 | |||
507 | /* Map result to S3C DMA API */ | ||
508 | if (err == PL330_ERR_NONE) | ||
509 | res = S3C2410_RES_OK; | ||
510 | else if (err == PL330_ERR_ABORT) | ||
511 | res = S3C2410_RES_ABORT; | ||
512 | else | ||
513 | res = S3C2410_RES_ERR; | ||
514 | |||
515 | /* If last request had some xfer */ | ||
516 | if (xl) { | ||
517 | xfer = container_of(xl, struct s3c_pl330_xfer, px); | ||
518 | _finish_off(xfer, res, 0); | ||
519 | } else { | ||
520 | dev_info(ch->dmac->pi->dev, "%s:%d No Xfer?!\n", | ||
521 | __func__, __LINE__); | ||
522 | } | ||
523 | } | ||
524 | |||
525 | static void s3c_pl330_rq0(void *token, enum pl330_op_err err) | ||
526 | { | ||
527 | struct pl330_req *r = token; | ||
528 | struct s3c_pl330_chan *ch = container_of(r, | ||
529 | struct s3c_pl330_chan, req[0]); | ||
530 | s3c_pl330_rq(ch, r, err); | ||
531 | } | ||
532 | |||
533 | static void s3c_pl330_rq1(void *token, enum pl330_op_err err) | ||
534 | { | ||
535 | struct pl330_req *r = token; | ||
536 | struct s3c_pl330_chan *ch = container_of(r, | ||
537 | struct s3c_pl330_chan, req[1]); | ||
538 | s3c_pl330_rq(ch, r, err); | ||
539 | } | ||
540 | |||
541 | /* Release an acquired channel */ | ||
542 | static void chan_release(struct s3c_pl330_chan *ch) | ||
543 | { | ||
544 | struct s3c_pl330_dmac *dmac; | ||
545 | |||
546 | if (chan_free(ch)) | ||
547 | return; | ||
548 | |||
549 | dmac = ch->dmac; | ||
550 | ch->dmac = NULL; | ||
551 | dmac->busy_chan--; | ||
552 | } | ||
553 | |||
554 | int s3c2410_dma_ctrl(enum dma_ch id, enum s3c2410_chan_op op) | ||
555 | { | ||
556 | struct s3c_pl330_xfer *xfer; | ||
557 | enum pl330_chan_op pl330op; | ||
558 | struct s3c_pl330_chan *ch; | ||
559 | unsigned long flags; | ||
560 | int idx, ret; | ||
561 | |||
562 | spin_lock_irqsave(&res_lock, flags); | ||
563 | |||
564 | ch = id_to_chan(id); | ||
565 | |||
566 | if (!ch || chan_free(ch)) { | ||
567 | ret = -EINVAL; | ||
568 | goto ctrl_exit; | ||
569 | } | ||
570 | |||
571 | switch (op) { | ||
572 | case S3C2410_DMAOP_START: | ||
573 | /* Make sure both reqs are enqueued */ | ||
574 | idx = (ch->lrq == &ch->req[0]) ? 1 : 0; | ||
575 | s3c_pl330_submit(ch, &ch->req[idx]); | ||
576 | s3c_pl330_submit(ch, &ch->req[1 - idx]); | ||
577 | pl330op = PL330_OP_START; | ||
578 | break; | ||
579 | |||
580 | case S3C2410_DMAOP_STOP: | ||
581 | pl330op = PL330_OP_ABORT; | ||
582 | break; | ||
583 | |||
584 | case S3C2410_DMAOP_FLUSH: | ||
585 | pl330op = PL330_OP_FLUSH; | ||
586 | break; | ||
587 | |||
588 | case S3C2410_DMAOP_PAUSE: | ||
589 | case S3C2410_DMAOP_RESUME: | ||
590 | case S3C2410_DMAOP_TIMEOUT: | ||
591 | case S3C2410_DMAOP_STARTED: | ||
592 | spin_unlock_irqrestore(&res_lock, flags); | ||
593 | return 0; | ||
594 | |||
595 | default: | ||
596 | spin_unlock_irqrestore(&res_lock, flags); | ||
597 | return -EINVAL; | ||
598 | } | ||
599 | |||
600 | ret = pl330_chan_ctrl(ch->pl330_chan_id, pl330op); | ||
601 | |||
602 | if (pl330op == PL330_OP_START) { | ||
603 | spin_unlock_irqrestore(&res_lock, flags); | ||
604 | return ret; | ||
605 | } | ||
606 | |||
607 | idx = (ch->lrq == &ch->req[0]) ? 1 : 0; | ||
608 | |||
609 | /* Abort the current xfer */ | ||
610 | if (ch->req[idx].x) { | ||
611 | xfer = container_of(ch->req[idx].x, | ||
612 | struct s3c_pl330_xfer, px); | ||
613 | |||
614 | /* Drop xfer during FLUSH */ | ||
615 | if (pl330op == PL330_OP_FLUSH) | ||
616 | del_from_queue(xfer); | ||
617 | |||
618 | ch->req[idx].x = NULL; | ||
619 | |||
620 | spin_unlock_irqrestore(&res_lock, flags); | ||
621 | _finish_off(xfer, S3C2410_RES_ABORT, | ||
622 | pl330op == PL330_OP_FLUSH ? 1 : 0); | ||
623 | spin_lock_irqsave(&res_lock, flags); | ||
624 | } | ||
625 | |||
626 | /* Flush the whole queue */ | ||
627 | if (pl330op == PL330_OP_FLUSH) { | ||
628 | |||
629 | if (ch->req[1 - idx].x) { | ||
630 | xfer = container_of(ch->req[1 - idx].x, | ||
631 | struct s3c_pl330_xfer, px); | ||
632 | |||
633 | del_from_queue(xfer); | ||
634 | |||
635 | ch->req[1 - idx].x = NULL; | ||
636 | |||
637 | spin_unlock_irqrestore(&res_lock, flags); | ||
638 | _finish_off(xfer, S3C2410_RES_ABORT, 1); | ||
639 | spin_lock_irqsave(&res_lock, flags); | ||
640 | } | ||
641 | |||
642 | /* Finish off the remaining in the queue */ | ||
643 | xfer = ch->xfer_head; | ||
644 | while (xfer) { | ||
645 | |||
646 | del_from_queue(xfer); | ||
647 | |||
648 | spin_unlock_irqrestore(&res_lock, flags); | ||
649 | _finish_off(xfer, S3C2410_RES_ABORT, 1); | ||
650 | spin_lock_irqsave(&res_lock, flags); | ||
651 | |||
652 | xfer = ch->xfer_head; | ||
653 | } | ||
654 | } | ||
655 | |||
656 | ctrl_exit: | ||
657 | spin_unlock_irqrestore(&res_lock, flags); | ||
658 | |||
659 | return ret; | ||
660 | } | ||
661 | EXPORT_SYMBOL(s3c2410_dma_ctrl); | ||
662 | |||
663 | int s3c2410_dma_enqueue(enum dma_ch id, void *token, | ||
664 | dma_addr_t addr, int size) | ||
665 | { | ||
666 | struct s3c_pl330_chan *ch; | ||
667 | struct s3c_pl330_xfer *xfer; | ||
668 | unsigned long flags; | ||
669 | int idx, ret = 0; | ||
670 | |||
671 | spin_lock_irqsave(&res_lock, flags); | ||
672 | |||
673 | ch = id_to_chan(id); | ||
674 | |||
675 | /* Error if invalid or free channel */ | ||
676 | if (!ch || chan_free(ch)) { | ||
677 | ret = -EINVAL; | ||
678 | goto enq_exit; | ||
679 | } | ||
680 | |||
681 | /* Error if size is unaligned */ | ||
682 | if (ch->rqcfg.brst_size && size % (1 << ch->rqcfg.brst_size)) { | ||
683 | ret = -EINVAL; | ||
684 | goto enq_exit; | ||
685 | } | ||
686 | |||
687 | xfer = kmem_cache_alloc(ch->dmac->kmcache, GFP_ATOMIC); | ||
688 | if (!xfer) { | ||
689 | ret = -ENOMEM; | ||
690 | goto enq_exit; | ||
691 | } | ||
692 | |||
693 | xfer->token = token; | ||
694 | xfer->chan = ch; | ||
695 | xfer->px.bytes = size; | ||
696 | xfer->px.next = NULL; /* Single request */ | ||
697 | |||
698 | /* For S3C DMA API, direction is always fixed for all xfers */ | ||
699 | if (ch->req[0].rqtype == MEMTODEV) { | ||
700 | xfer->px.src_addr = addr; | ||
701 | xfer->px.dst_addr = ch->sdaddr; | ||
702 | } else { | ||
703 | xfer->px.src_addr = ch->sdaddr; | ||
704 | xfer->px.dst_addr = addr; | ||
705 | } | ||
706 | |||
707 | add_to_queue(ch, xfer, 0); | ||
708 | |||
709 | /* Try submitting on either request */ | ||
710 | idx = (ch->lrq == &ch->req[0]) ? 1 : 0; | ||
711 | |||
712 | if (!ch->req[idx].x) | ||
713 | s3c_pl330_submit(ch, &ch->req[idx]); | ||
714 | else | ||
715 | s3c_pl330_submit(ch, &ch->req[1 - idx]); | ||
716 | |||
717 | spin_unlock_irqrestore(&res_lock, flags); | ||
718 | |||
719 | if (ch->options & S3C2410_DMAF_AUTOSTART) | ||
720 | s3c2410_dma_ctrl(id, S3C2410_DMAOP_START); | ||
721 | |||
722 | return 0; | ||
723 | |||
724 | enq_exit: | ||
725 | spin_unlock_irqrestore(&res_lock, flags); | ||
726 | |||
727 | return ret; | ||
728 | } | ||
729 | EXPORT_SYMBOL(s3c2410_dma_enqueue); | ||
730 | |||
731 | int s3c2410_dma_request(enum dma_ch id, | ||
732 | struct s3c2410_dma_client *client, | ||
733 | void *dev) | ||
734 | { | ||
735 | struct s3c_pl330_dmac *dmac; | ||
736 | struct s3c_pl330_chan *ch; | ||
737 | unsigned long flags; | ||
738 | int ret = 0; | ||
739 | |||
740 | spin_lock_irqsave(&res_lock, flags); | ||
741 | |||
742 | ch = chan_acquire(id); | ||
743 | if (!ch) { | ||
744 | ret = -EBUSY; | ||
745 | goto req_exit; | ||
746 | } | ||
747 | |||
748 | dmac = ch->dmac; | ||
749 | |||
750 | ch->pl330_chan_id = pl330_request_channel(dmac->pi); | ||
751 | if (!ch->pl330_chan_id) { | ||
752 | chan_release(ch); | ||
753 | ret = -EBUSY; | ||
754 | goto req_exit; | ||
755 | } | ||
756 | |||
757 | ch->client = client; | ||
758 | ch->options = 0; /* Clear any option */ | ||
759 | ch->callback_fn = NULL; /* Clear any callback */ | ||
760 | ch->lrq = NULL; | ||
761 | |||
762 | ch->rqcfg.brst_size = 2; /* Default word size */ | ||
763 | ch->rqcfg.swap = SWAP_NO; | ||
764 | ch->rqcfg.scctl = SCCTRL0; /* Noncacheable and nonbufferable */ | ||
765 | ch->rqcfg.dcctl = DCCTRL0; /* Noncacheable and nonbufferable */ | ||
766 | ch->rqcfg.privileged = 0; | ||
767 | ch->rqcfg.insnaccess = 0; | ||
768 | |||
769 | /* Set invalid direction */ | ||
770 | ch->req[0].rqtype = DEVTODEV; | ||
771 | ch->req[1].rqtype = ch->req[0].rqtype; | ||
772 | |||
773 | ch->req[0].cfg = &ch->rqcfg; | ||
774 | ch->req[1].cfg = ch->req[0].cfg; | ||
775 | |||
776 | ch->req[0].peri = iface_of_dmac(dmac, id) - 1; /* Original index */ | ||
777 | ch->req[1].peri = ch->req[0].peri; | ||
778 | |||
779 | ch->req[0].token = &ch->req[0]; | ||
780 | ch->req[0].xfer_cb = s3c_pl330_rq0; | ||
781 | ch->req[1].token = &ch->req[1]; | ||
782 | ch->req[1].xfer_cb = s3c_pl330_rq1; | ||
783 | |||
784 | ch->req[0].x = NULL; | ||
785 | ch->req[1].x = NULL; | ||
786 | |||
787 | /* Reset xfer list */ | ||
788 | INIT_LIST_HEAD(&ch->xfer_list); | ||
789 | ch->xfer_head = NULL; | ||
790 | |||
791 | req_exit: | ||
792 | spin_unlock_irqrestore(&res_lock, flags); | ||
793 | |||
794 | return ret; | ||
795 | } | ||
796 | EXPORT_SYMBOL(s3c2410_dma_request); | ||
797 | |||
798 | int s3c2410_dma_free(enum dma_ch id, struct s3c2410_dma_client *client) | ||
799 | { | ||
800 | struct s3c_pl330_chan *ch; | ||
801 | struct s3c_pl330_xfer *xfer; | ||
802 | unsigned long flags; | ||
803 | int ret = 0; | ||
804 | unsigned idx; | ||
805 | |||
806 | spin_lock_irqsave(&res_lock, flags); | ||
807 | |||
808 | ch = id_to_chan(id); | ||
809 | |||
810 | if (!ch || chan_free(ch)) | ||
811 | goto free_exit; | ||
812 | |||
813 | /* Refuse if someone else wanted to free the channel */ | ||
814 | if (ch->client != client) { | ||
815 | ret = -EBUSY; | ||
816 | goto free_exit; | ||
817 | } | ||
818 | |||
819 | /* Stop any active xfer, Flushe the queue and do callbacks */ | ||
820 | pl330_chan_ctrl(ch->pl330_chan_id, PL330_OP_FLUSH); | ||
821 | |||
822 | /* Abort the submitted requests */ | ||
823 | idx = (ch->lrq == &ch->req[0]) ? 1 : 0; | ||
824 | |||
825 | if (ch->req[idx].x) { | ||
826 | xfer = container_of(ch->req[idx].x, | ||
827 | struct s3c_pl330_xfer, px); | ||
828 | |||
829 | ch->req[idx].x = NULL; | ||
830 | del_from_queue(xfer); | ||
831 | |||
832 | spin_unlock_irqrestore(&res_lock, flags); | ||
833 | _finish_off(xfer, S3C2410_RES_ABORT, 1); | ||
834 | spin_lock_irqsave(&res_lock, flags); | ||
835 | } | ||
836 | |||
837 | if (ch->req[1 - idx].x) { | ||
838 | xfer = container_of(ch->req[1 - idx].x, | ||
839 | struct s3c_pl330_xfer, px); | ||
840 | |||
841 | ch->req[1 - idx].x = NULL; | ||
842 | del_from_queue(xfer); | ||
843 | |||
844 | spin_unlock_irqrestore(&res_lock, flags); | ||
845 | _finish_off(xfer, S3C2410_RES_ABORT, 1); | ||
846 | spin_lock_irqsave(&res_lock, flags); | ||
847 | } | ||
848 | |||
849 | /* Pluck and Abort the queued requests in order */ | ||
850 | do { | ||
851 | xfer = get_from_queue(ch, 1); | ||
852 | |||
853 | spin_unlock_irqrestore(&res_lock, flags); | ||
854 | _finish_off(xfer, S3C2410_RES_ABORT, 1); | ||
855 | spin_lock_irqsave(&res_lock, flags); | ||
856 | } while (xfer); | ||
857 | |||
858 | ch->client = NULL; | ||
859 | |||
860 | pl330_release_channel(ch->pl330_chan_id); | ||
861 | |||
862 | ch->pl330_chan_id = NULL; | ||
863 | |||
864 | chan_release(ch); | ||
865 | |||
866 | free_exit: | ||
867 | spin_unlock_irqrestore(&res_lock, flags); | ||
868 | |||
869 | return ret; | ||
870 | } | ||
871 | EXPORT_SYMBOL(s3c2410_dma_free); | ||
872 | |||
873 | int s3c2410_dma_config(enum dma_ch id, int xferunit) | ||
874 | { | ||
875 | struct s3c_pl330_chan *ch; | ||
876 | struct pl330_info *pi; | ||
877 | unsigned long flags; | ||
878 | int i, dbwidth, ret = 0; | ||
879 | |||
880 | spin_lock_irqsave(&res_lock, flags); | ||
881 | |||
882 | ch = id_to_chan(id); | ||
883 | |||
884 | if (!ch || chan_free(ch)) { | ||
885 | ret = -EINVAL; | ||
886 | goto cfg_exit; | ||
887 | } | ||
888 | |||
889 | pi = ch->dmac->pi; | ||
890 | dbwidth = pi->pcfg.data_bus_width / 8; | ||
891 | |||
892 | /* Max size of xfer can be pcfg.data_bus_width */ | ||
893 | if (xferunit > dbwidth) { | ||
894 | ret = -EINVAL; | ||
895 | goto cfg_exit; | ||
896 | } | ||
897 | |||
898 | i = 0; | ||
899 | while (xferunit != (1 << i)) | ||
900 | i++; | ||
901 | |||
902 | /* If valid value */ | ||
903 | if (xferunit == (1 << i)) | ||
904 | ch->rqcfg.brst_size = i; | ||
905 | else | ||
906 | ret = -EINVAL; | ||
907 | |||
908 | cfg_exit: | ||
909 | spin_unlock_irqrestore(&res_lock, flags); | ||
910 | |||
911 | return ret; | ||
912 | } | ||
913 | EXPORT_SYMBOL(s3c2410_dma_config); | ||
914 | |||
915 | /* Options that are supported by this driver */ | ||
916 | #define S3C_PL330_FLAGS (S3C2410_DMAF_CIRCULAR | S3C2410_DMAF_AUTOSTART) | ||
917 | |||
918 | int s3c2410_dma_setflags(enum dma_ch id, unsigned int options) | ||
919 | { | ||
920 | struct s3c_pl330_chan *ch; | ||
921 | unsigned long flags; | ||
922 | int ret = 0; | ||
923 | |||
924 | spin_lock_irqsave(&res_lock, flags); | ||
925 | |||
926 | ch = id_to_chan(id); | ||
927 | |||
928 | if (!ch || chan_free(ch) || options & ~(S3C_PL330_FLAGS)) | ||
929 | ret = -EINVAL; | ||
930 | else | ||
931 | ch->options = options; | ||
932 | |||
933 | spin_unlock_irqrestore(&res_lock, flags); | ||
934 | |||
935 | return 0; | ||
936 | } | ||
937 | EXPORT_SYMBOL(s3c2410_dma_setflags); | ||
938 | |||
939 | int s3c2410_dma_set_buffdone_fn(enum dma_ch id, s3c2410_dma_cbfn_t rtn) | ||
940 | { | ||
941 | struct s3c_pl330_chan *ch; | ||
942 | unsigned long flags; | ||
943 | int ret = 0; | ||
944 | |||
945 | spin_lock_irqsave(&res_lock, flags); | ||
946 | |||
947 | ch = id_to_chan(id); | ||
948 | |||
949 | if (!ch || chan_free(ch)) | ||
950 | ret = -EINVAL; | ||
951 | else | ||
952 | ch->callback_fn = rtn; | ||
953 | |||
954 | spin_unlock_irqrestore(&res_lock, flags); | ||
955 | |||
956 | return ret; | ||
957 | } | ||
958 | EXPORT_SYMBOL(s3c2410_dma_set_buffdone_fn); | ||
959 | |||
960 | int s3c2410_dma_devconfig(enum dma_ch id, enum s3c2410_dmasrc source, | ||
961 | unsigned long address) | ||
962 | { | ||
963 | struct s3c_pl330_chan *ch; | ||
964 | unsigned long flags; | ||
965 | int ret = 0; | ||
966 | |||
967 | spin_lock_irqsave(&res_lock, flags); | ||
968 | |||
969 | ch = id_to_chan(id); | ||
970 | |||
971 | if (!ch || chan_free(ch)) { | ||
972 | ret = -EINVAL; | ||
973 | goto devcfg_exit; | ||
974 | } | ||
975 | |||
976 | switch (source) { | ||
977 | case S3C2410_DMASRC_HW: /* P->M */ | ||
978 | ch->req[0].rqtype = DEVTOMEM; | ||
979 | ch->req[1].rqtype = DEVTOMEM; | ||
980 | ch->rqcfg.src_inc = 0; | ||
981 | ch->rqcfg.dst_inc = 1; | ||
982 | break; | ||
983 | case S3C2410_DMASRC_MEM: /* M->P */ | ||
984 | ch->req[0].rqtype = MEMTODEV; | ||
985 | ch->req[1].rqtype = MEMTODEV; | ||
986 | ch->rqcfg.src_inc = 1; | ||
987 | ch->rqcfg.dst_inc = 0; | ||
988 | break; | ||
989 | default: | ||
990 | ret = -EINVAL; | ||
991 | goto devcfg_exit; | ||
992 | } | ||
993 | |||
994 | ch->sdaddr = address; | ||
995 | |||
996 | devcfg_exit: | ||
997 | spin_unlock_irqrestore(&res_lock, flags); | ||
998 | |||
999 | return ret; | ||
1000 | } | ||
1001 | EXPORT_SYMBOL(s3c2410_dma_devconfig); | ||
1002 | |||
1003 | int s3c2410_dma_getposition(enum dma_ch id, dma_addr_t *src, dma_addr_t *dst) | ||
1004 | { | ||
1005 | struct s3c_pl330_chan *ch = id_to_chan(id); | ||
1006 | struct pl330_chanstatus status; | ||
1007 | int ret; | ||
1008 | |||
1009 | if (!ch || chan_free(ch)) | ||
1010 | return -EINVAL; | ||
1011 | |||
1012 | ret = pl330_chan_status(ch->pl330_chan_id, &status); | ||
1013 | if (ret < 0) | ||
1014 | return ret; | ||
1015 | |||
1016 | *src = status.src_addr; | ||
1017 | *dst = status.dst_addr; | ||
1018 | |||
1019 | return 0; | ||
1020 | } | ||
1021 | EXPORT_SYMBOL(s3c2410_dma_getposition); | ||
1022 | |||
1023 | static irqreturn_t pl330_irq_handler(int irq, void *data) | ||
1024 | { | ||
1025 | if (pl330_update(data)) | ||
1026 | return IRQ_HANDLED; | ||
1027 | else | ||
1028 | return IRQ_NONE; | ||
1029 | } | ||
1030 | |||
1031 | static int pl330_probe(struct platform_device *pdev) | ||
1032 | { | ||
1033 | struct s3c_pl330_dmac *s3c_pl330_dmac; | ||
1034 | struct s3c_pl330_platdata *pl330pd; | ||
1035 | struct pl330_info *pl330_info; | ||
1036 | struct resource *res; | ||
1037 | int i, ret, irq; | ||
1038 | |||
1039 | pl330pd = pdev->dev.platform_data; | ||
1040 | |||
1041 | /* Can't do without the list of _32_ peripherals */ | ||
1042 | if (!pl330pd || !pl330pd->peri) { | ||
1043 | dev_err(&pdev->dev, "platform data missing!\n"); | ||
1044 | return -ENODEV; | ||
1045 | } | ||
1046 | |||
1047 | pl330_info = kzalloc(sizeof(*pl330_info), GFP_KERNEL); | ||
1048 | if (!pl330_info) | ||
1049 | return -ENOMEM; | ||
1050 | |||
1051 | pl330_info->pl330_data = NULL; | ||
1052 | pl330_info->dev = &pdev->dev; | ||
1053 | |||
1054 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1055 | if (!res) { | ||
1056 | ret = -ENODEV; | ||
1057 | goto probe_err1; | ||
1058 | } | ||
1059 | |||
1060 | request_mem_region(res->start, resource_size(res), pdev->name); | ||
1061 | |||
1062 | pl330_info->base = ioremap(res->start, resource_size(res)); | ||
1063 | if (!pl330_info->base) { | ||
1064 | ret = -ENXIO; | ||
1065 | goto probe_err2; | ||
1066 | } | ||
1067 | |||
1068 | irq = platform_get_irq(pdev, 0); | ||
1069 | if (irq < 0) { | ||
1070 | ret = irq; | ||
1071 | goto probe_err3; | ||
1072 | } | ||
1073 | |||
1074 | ret = request_irq(irq, pl330_irq_handler, 0, | ||
1075 | dev_name(&pdev->dev), pl330_info); | ||
1076 | if (ret) | ||
1077 | goto probe_err4; | ||
1078 | |||
1079 | /* Allocate a new DMAC */ | ||
1080 | s3c_pl330_dmac = kmalloc(sizeof(*s3c_pl330_dmac), GFP_KERNEL); | ||
1081 | if (!s3c_pl330_dmac) { | ||
1082 | ret = -ENOMEM; | ||
1083 | goto probe_err5; | ||
1084 | } | ||
1085 | |||
1086 | /* Get operation clock and enable it */ | ||
1087 | s3c_pl330_dmac->clk = clk_get(&pdev->dev, "pdma"); | ||
1088 | if (IS_ERR(s3c_pl330_dmac->clk)) { | ||
1089 | dev_err(&pdev->dev, "Cannot get operation clock.\n"); | ||
1090 | ret = -EINVAL; | ||
1091 | goto probe_err6; | ||
1092 | } | ||
1093 | clk_enable(s3c_pl330_dmac->clk); | ||
1094 | |||
1095 | ret = pl330_add(pl330_info); | ||
1096 | if (ret) | ||
1097 | goto probe_err7; | ||
1098 | |||
1099 | /* Hook the info */ | ||
1100 | s3c_pl330_dmac->pi = pl330_info; | ||
1101 | |||
1102 | /* No busy channels */ | ||
1103 | s3c_pl330_dmac->busy_chan = 0; | ||
1104 | |||
1105 | s3c_pl330_dmac->kmcache = kmem_cache_create(dev_name(&pdev->dev), | ||
1106 | sizeof(struct s3c_pl330_xfer), 0, 0, NULL); | ||
1107 | |||
1108 | if (!s3c_pl330_dmac->kmcache) { | ||
1109 | ret = -ENOMEM; | ||
1110 | goto probe_err8; | ||
1111 | } | ||
1112 | |||
1113 | /* Get the list of peripherals */ | ||
1114 | s3c_pl330_dmac->peri = pl330pd->peri; | ||
1115 | |||
1116 | /* Attach to the list of DMACs */ | ||
1117 | list_add_tail(&s3c_pl330_dmac->node, &dmac_list); | ||
1118 | |||
1119 | /* Create a channel for each peripheral in the DMAC | ||
1120 | * that is, if it doesn't already exist | ||
1121 | */ | ||
1122 | for (i = 0; i < PL330_MAX_PERI; i++) | ||
1123 | if (s3c_pl330_dmac->peri[i] != DMACH_MAX) | ||
1124 | chan_add(s3c_pl330_dmac->peri[i]); | ||
1125 | |||
1126 | printk(KERN_INFO | ||
1127 | "Loaded driver for PL330 DMAC-%d %s\n", pdev->id, pdev->name); | ||
1128 | printk(KERN_INFO | ||
1129 | "\tDBUFF-%ux%ubytes Num_Chans-%u Num_Peri-%u Num_Events-%u\n", | ||
1130 | pl330_info->pcfg.data_buf_dep, | ||
1131 | pl330_info->pcfg.data_bus_width / 8, pl330_info->pcfg.num_chan, | ||
1132 | pl330_info->pcfg.num_peri, pl330_info->pcfg.num_events); | ||
1133 | |||
1134 | return 0; | ||
1135 | |||
1136 | probe_err8: | ||
1137 | pl330_del(pl330_info); | ||
1138 | probe_err7: | ||
1139 | clk_disable(s3c_pl330_dmac->clk); | ||
1140 | clk_put(s3c_pl330_dmac->clk); | ||
1141 | probe_err6: | ||
1142 | kfree(s3c_pl330_dmac); | ||
1143 | probe_err5: | ||
1144 | free_irq(irq, pl330_info); | ||
1145 | probe_err4: | ||
1146 | probe_err3: | ||
1147 | iounmap(pl330_info->base); | ||
1148 | probe_err2: | ||
1149 | release_mem_region(res->start, resource_size(res)); | ||
1150 | probe_err1: | ||
1151 | kfree(pl330_info); | ||
1152 | |||
1153 | return ret; | ||
1154 | } | ||
1155 | |||
1156 | static int pl330_remove(struct platform_device *pdev) | ||
1157 | { | ||
1158 | struct s3c_pl330_dmac *dmac, *d; | ||
1159 | struct s3c_pl330_chan *ch; | ||
1160 | unsigned long flags; | ||
1161 | int del, found; | ||
1162 | |||
1163 | if (!pdev->dev.platform_data) | ||
1164 | return -EINVAL; | ||
1165 | |||
1166 | spin_lock_irqsave(&res_lock, flags); | ||
1167 | |||
1168 | found = 0; | ||
1169 | list_for_each_entry(d, &dmac_list, node) | ||
1170 | if (d->pi->dev == &pdev->dev) { | ||
1171 | found = 1; | ||
1172 | break; | ||
1173 | } | ||
1174 | |||
1175 | if (!found) { | ||
1176 | spin_unlock_irqrestore(&res_lock, flags); | ||
1177 | return 0; | ||
1178 | } | ||
1179 | |||
1180 | dmac = d; | ||
1181 | |||
1182 | /* Remove all Channels that are managed only by this DMAC */ | ||
1183 | list_for_each_entry(ch, &chan_list, node) { | ||
1184 | |||
1185 | /* Only channels that are handled by this DMAC */ | ||
1186 | if (iface_of_dmac(dmac, ch->id)) | ||
1187 | del = 1; | ||
1188 | else | ||
1189 | continue; | ||
1190 | |||
1191 | /* Don't remove if some other DMAC has it too */ | ||
1192 | list_for_each_entry(d, &dmac_list, node) | ||
1193 | if (d != dmac && iface_of_dmac(d, ch->id)) { | ||
1194 | del = 0; | ||
1195 | break; | ||
1196 | } | ||
1197 | |||
1198 | if (del) { | ||
1199 | spin_unlock_irqrestore(&res_lock, flags); | ||
1200 | s3c2410_dma_free(ch->id, ch->client); | ||
1201 | spin_lock_irqsave(&res_lock, flags); | ||
1202 | list_del(&ch->node); | ||
1203 | kfree(ch); | ||
1204 | } | ||
1205 | } | ||
1206 | |||
1207 | /* Disable operation clock */ | ||
1208 | clk_disable(dmac->clk); | ||
1209 | clk_put(dmac->clk); | ||
1210 | |||
1211 | /* Remove the DMAC */ | ||
1212 | list_del(&dmac->node); | ||
1213 | kfree(dmac); | ||
1214 | |||
1215 | spin_unlock_irqrestore(&res_lock, flags); | ||
1216 | |||
1217 | return 0; | ||
1218 | } | ||
1219 | |||
1220 | static struct platform_driver pl330_driver = { | ||
1221 | .driver = { | ||
1222 | .owner = THIS_MODULE, | ||
1223 | .name = "s3c-pl330", | ||
1224 | }, | ||
1225 | .probe = pl330_probe, | ||
1226 | .remove = pl330_remove, | ||
1227 | }; | ||
1228 | |||
1229 | static int __init pl330_init(void) | ||
1230 | { | ||
1231 | return platform_driver_register(&pl330_driver); | ||
1232 | } | ||
1233 | module_init(pl330_init); | ||
1234 | |||
1235 | static void __exit pl330_exit(void) | ||
1236 | { | ||
1237 | platform_driver_unregister(&pl330_driver); | ||
1238 | return; | ||
1239 | } | ||
1240 | module_exit(pl330_exit); | ||
1241 | |||
1242 | MODULE_AUTHOR("Jaswinder Singh <jassi.brar@samsung.com>"); | ||
1243 | MODULE_DESCRIPTION("Driver for PL330 DMA Controller"); | ||
1244 | MODULE_LICENSE("GPL"); | ||