diff options
Diffstat (limited to 'drivers')
76 files changed, 1827 insertions, 857 deletions
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index c8abce3d2d9c..ed0fade46aed 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -270,15 +270,10 @@ static int hci_uart_send_frame(struct sk_buff *skb) | |||
270 | */ | 270 | */ |
271 | static int hci_uart_tty_open(struct tty_struct *tty) | 271 | static int hci_uart_tty_open(struct tty_struct *tty) |
272 | { | 272 | { |
273 | struct hci_uart *hu = (void *) tty->disc_data; | 273 | struct hci_uart *hu; |
274 | 274 | ||
275 | BT_DBG("tty %p", tty); | 275 | BT_DBG("tty %p", tty); |
276 | 276 | ||
277 | /* FIXME: This btw is bogus, nothing requires the old ldisc to clear | ||
278 | the pointer */ | ||
279 | if (hu) | ||
280 | return -EEXIST; | ||
281 | |||
282 | /* Error if the tty has no write op instead of leaving an exploitable | 277 | /* Error if the tty has no write op instead of leaving an exploitable |
283 | hole */ | 278 | hole */ |
284 | if (tty->ops->write == NULL) | 279 | if (tty->ops->write == NULL) |
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c index a5effd813abd..45e467dcc8c8 100644 --- a/drivers/char/hw_random/omap-rng.c +++ b/drivers/char/hw_random/omap-rng.c | |||
@@ -27,8 +27,6 @@ | |||
27 | 27 | ||
28 | #include <asm/io.h> | 28 | #include <asm/io.h> |
29 | 29 | ||
30 | #include <plat/cpu.h> | ||
31 | |||
32 | #define RNG_OUT_REG 0x00 /* Output register */ | 30 | #define RNG_OUT_REG 0x00 /* Output register */ |
33 | #define RNG_STAT_REG 0x04 /* Status register | 31 | #define RNG_STAT_REG 0x04 /* Status register |
34 | [0] = STAT_BUSY */ | 32 | [0] = STAT_BUSY */ |
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 71a25b91de00..d35a34c58369 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile | |||
@@ -19,6 +19,7 @@ endif | |||
19 | obj-$(CONFIG_MACH_LOONGSON1) += clk-ls1x.o | 19 | obj-$(CONFIG_MACH_LOONGSON1) += clk-ls1x.o |
20 | obj-$(CONFIG_ARCH_U8500) += ux500/ | 20 | obj-$(CONFIG_ARCH_U8500) += ux500/ |
21 | obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o | 21 | obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o |
22 | obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o | ||
22 | 23 | ||
23 | # Chip specific | 24 | # Chip specific |
24 | obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o | 25 | obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o |
diff --git a/drivers/clk/clk-zynq.c b/drivers/clk/clk-zynq.c new file mode 100644 index 000000000000..37a30514fd66 --- /dev/null +++ b/drivers/clk/clk-zynq.c | |||
@@ -0,0 +1,383 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2012 National Instruments | ||
3 | * | ||
4 | * Josh Cartwright <josh.cartwright@ni.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along with | ||
16 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | #include <linux/io.h> | ||
19 | #include <linux/of.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/clk-provider.h> | ||
23 | |||
24 | static void __iomem *slcr_base; | ||
25 | |||
26 | struct zynq_pll_clk { | ||
27 | struct clk_hw hw; | ||
28 | void __iomem *pll_ctrl; | ||
29 | void __iomem *pll_cfg; | ||
30 | }; | ||
31 | |||
32 | #define to_zynq_pll_clk(hw) container_of(hw, struct zynq_pll_clk, hw) | ||
33 | |||
34 | #define CTRL_PLL_FDIV(x) ((x) >> 12) | ||
35 | |||
36 | static unsigned long zynq_pll_recalc_rate(struct clk_hw *hw, | ||
37 | unsigned long parent_rate) | ||
38 | { | ||
39 | struct zynq_pll_clk *pll = to_zynq_pll_clk(hw); | ||
40 | return parent_rate * CTRL_PLL_FDIV(ioread32(pll->pll_ctrl)); | ||
41 | } | ||
42 | |||
43 | static const struct clk_ops zynq_pll_clk_ops = { | ||
44 | .recalc_rate = zynq_pll_recalc_rate, | ||
45 | }; | ||
46 | |||
47 | static void __init zynq_pll_clk_setup(struct device_node *np) | ||
48 | { | ||
49 | struct clk_init_data init; | ||
50 | struct zynq_pll_clk *pll; | ||
51 | const char *parent_name; | ||
52 | struct clk *clk; | ||
53 | u32 regs[2]; | ||
54 | int ret; | ||
55 | |||
56 | ret = of_property_read_u32_array(np, "reg", regs, ARRAY_SIZE(regs)); | ||
57 | if (WARN_ON(ret)) | ||
58 | return; | ||
59 | |||
60 | pll = kzalloc(sizeof(*pll), GFP_KERNEL); | ||
61 | if (WARN_ON(!pll)) | ||
62 | return; | ||
63 | |||
64 | pll->pll_ctrl = slcr_base + regs[0]; | ||
65 | pll->pll_cfg = slcr_base + regs[1]; | ||
66 | |||
67 | of_property_read_string(np, "clock-output-names", &init.name); | ||
68 | |||
69 | init.ops = &zynq_pll_clk_ops; | ||
70 | parent_name = of_clk_get_parent_name(np, 0); | ||
71 | init.parent_names = &parent_name; | ||
72 | init.num_parents = 1; | ||
73 | |||
74 | pll->hw.init = &init; | ||
75 | |||
76 | clk = clk_register(NULL, &pll->hw); | ||
77 | if (WARN_ON(IS_ERR(clk))) | ||
78 | return; | ||
79 | |||
80 | ret = of_clk_add_provider(np, of_clk_src_simple_get, clk); | ||
81 | if (WARN_ON(ret)) | ||
82 | return; | ||
83 | } | ||
84 | |||
85 | struct zynq_periph_clk { | ||
86 | struct clk_hw hw; | ||
87 | struct clk_onecell_data onecell_data; | ||
88 | struct clk *gates[2]; | ||
89 | void __iomem *clk_ctrl; | ||
90 | spinlock_t clkact_lock; | ||
91 | }; | ||
92 | |||
93 | #define to_zynq_periph_clk(hw) container_of(hw, struct zynq_periph_clk, hw) | ||
94 | |||
95 | static const u8 periph_clk_parent_map[] = { | ||
96 | 0, 0, 1, 2 | ||
97 | }; | ||
98 | #define PERIPH_CLK_CTRL_SRC(x) (periph_clk_parent_map[((x) & 0x30) >> 4]) | ||
99 | #define PERIPH_CLK_CTRL_DIV(x) (((x) & 0x3F00) >> 8) | ||
100 | |||
101 | static unsigned long zynq_periph_recalc_rate(struct clk_hw *hw, | ||
102 | unsigned long parent_rate) | ||
103 | { | ||
104 | struct zynq_periph_clk *periph = to_zynq_periph_clk(hw); | ||
105 | return parent_rate / PERIPH_CLK_CTRL_DIV(ioread32(periph->clk_ctrl)); | ||
106 | } | ||
107 | |||
108 | static u8 zynq_periph_get_parent(struct clk_hw *hw) | ||
109 | { | ||
110 | struct zynq_periph_clk *periph = to_zynq_periph_clk(hw); | ||
111 | return PERIPH_CLK_CTRL_SRC(ioread32(periph->clk_ctrl)); | ||
112 | } | ||
113 | |||
114 | static const struct clk_ops zynq_periph_clk_ops = { | ||
115 | .recalc_rate = zynq_periph_recalc_rate, | ||
116 | .get_parent = zynq_periph_get_parent, | ||
117 | }; | ||
118 | |||
119 | static void __init zynq_periph_clk_setup(struct device_node *np) | ||
120 | { | ||
121 | struct zynq_periph_clk *periph; | ||
122 | const char *parent_names[3]; | ||
123 | struct clk_init_data init; | ||
124 | int clk_num = 0, err; | ||
125 | const char *name; | ||
126 | struct clk *clk; | ||
127 | u32 reg; | ||
128 | int i; | ||
129 | |||
130 | err = of_property_read_u32(np, "reg", ®); | ||
131 | if (WARN_ON(err)) | ||
132 | return; | ||
133 | |||
134 | periph = kzalloc(sizeof(*periph), GFP_KERNEL); | ||
135 | if (WARN_ON(!periph)) | ||
136 | return; | ||
137 | |||
138 | periph->clk_ctrl = slcr_base + reg; | ||
139 | spin_lock_init(&periph->clkact_lock); | ||
140 | |||
141 | init.name = np->name; | ||
142 | init.ops = &zynq_periph_clk_ops; | ||
143 | for (i = 0; i < ARRAY_SIZE(parent_names); i++) | ||
144 | parent_names[i] = of_clk_get_parent_name(np, i); | ||
145 | init.parent_names = parent_names; | ||
146 | init.num_parents = ARRAY_SIZE(parent_names); | ||
147 | |||
148 | periph->hw.init = &init; | ||
149 | |||
150 | clk = clk_register(NULL, &periph->hw); | ||
151 | if (WARN_ON(IS_ERR(clk))) | ||
152 | return; | ||
153 | |||
154 | err = of_clk_add_provider(np, of_clk_src_simple_get, clk); | ||
155 | if (WARN_ON(err)) | ||
156 | return; | ||
157 | |||
158 | err = of_property_read_string_index(np, "clock-output-names", 0, | ||
159 | &name); | ||
160 | if (WARN_ON(err)) | ||
161 | return; | ||
162 | |||
163 | periph->gates[0] = clk_register_gate(NULL, name, np->name, 0, | ||
164 | periph->clk_ctrl, 0, 0, | ||
165 | &periph->clkact_lock); | ||
166 | if (WARN_ON(IS_ERR(periph->gates[0]))) | ||
167 | return; | ||
168 | clk_num++; | ||
169 | |||
170 | /* some periph clks have 2 downstream gates */ | ||
171 | err = of_property_read_string_index(np, "clock-output-names", 1, | ||
172 | &name); | ||
173 | if (err != -ENODATA) { | ||
174 | periph->gates[1] = clk_register_gate(NULL, name, np->name, 0, | ||
175 | periph->clk_ctrl, 1, 0, | ||
176 | &periph->clkact_lock); | ||
177 | if (WARN_ON(IS_ERR(periph->gates[1]))) | ||
178 | return; | ||
179 | clk_num++; | ||
180 | } | ||
181 | |||
182 | periph->onecell_data.clks = periph->gates; | ||
183 | periph->onecell_data.clk_num = clk_num; | ||
184 | |||
185 | err = of_clk_add_provider(np, of_clk_src_onecell_get, | ||
186 | &periph->onecell_data); | ||
187 | if (WARN_ON(err)) | ||
188 | return; | ||
189 | } | ||
190 | |||
191 | /* CPU Clock domain is modelled as a mux with 4 children subclks, whose | ||
192 | * derivative rates depend on CLK_621_TRUE | ||
193 | */ | ||
194 | |||
195 | struct zynq_cpu_clk { | ||
196 | struct clk_hw hw; | ||
197 | struct clk_onecell_data onecell_data; | ||
198 | struct clk *subclks[4]; | ||
199 | void __iomem *clk_ctrl; | ||
200 | spinlock_t clkact_lock; | ||
201 | }; | ||
202 | |||
203 | #define to_zynq_cpu_clk(hw) container_of(hw, struct zynq_cpu_clk, hw) | ||
204 | |||
205 | static const u8 zynq_cpu_clk_parent_map[] = { | ||
206 | 1, 1, 2, 0 | ||
207 | }; | ||
208 | #define CPU_CLK_SRCSEL(x) (zynq_cpu_clk_parent_map[(((x) & 0x30) >> 4)]) | ||
209 | #define CPU_CLK_CTRL_DIV(x) (((x) & 0x3F00) >> 8) | ||
210 | |||
211 | static u8 zynq_cpu_clk_get_parent(struct clk_hw *hw) | ||
212 | { | ||
213 | struct zynq_cpu_clk *cpuclk = to_zynq_cpu_clk(hw); | ||
214 | return CPU_CLK_SRCSEL(ioread32(cpuclk->clk_ctrl)); | ||
215 | } | ||
216 | |||
217 | static unsigned long zynq_cpu_clk_recalc_rate(struct clk_hw *hw, | ||
218 | unsigned long parent_rate) | ||
219 | { | ||
220 | struct zynq_cpu_clk *cpuclk = to_zynq_cpu_clk(hw); | ||
221 | return parent_rate / CPU_CLK_CTRL_DIV(ioread32(cpuclk->clk_ctrl)); | ||
222 | } | ||
223 | |||
224 | static const struct clk_ops zynq_cpu_clk_ops = { | ||
225 | .get_parent = zynq_cpu_clk_get_parent, | ||
226 | .recalc_rate = zynq_cpu_clk_recalc_rate, | ||
227 | }; | ||
228 | |||
229 | struct zynq_cpu_subclk { | ||
230 | struct clk_hw hw; | ||
231 | void __iomem *clk_621; | ||
232 | enum { | ||
233 | CPU_SUBCLK_6X4X, | ||
234 | CPU_SUBCLK_3X2X, | ||
235 | CPU_SUBCLK_2X, | ||
236 | CPU_SUBCLK_1X, | ||
237 | } which; | ||
238 | }; | ||
239 | |||
240 | #define CLK_621_TRUE(x) ((x) & 1) | ||
241 | |||
242 | #define to_zynq_cpu_subclk(hw) container_of(hw, struct zynq_cpu_subclk, hw); | ||
243 | |||
244 | static unsigned long zynq_cpu_subclk_recalc_rate(struct clk_hw *hw, | ||
245 | unsigned long parent_rate) | ||
246 | { | ||
247 | unsigned long uninitialized_var(rate); | ||
248 | struct zynq_cpu_subclk *subclk; | ||
249 | bool is_621; | ||
250 | |||
251 | subclk = to_zynq_cpu_subclk(hw) | ||
252 | is_621 = CLK_621_TRUE(ioread32(subclk->clk_621)); | ||
253 | |||
254 | switch (subclk->which) { | ||
255 | case CPU_SUBCLK_6X4X: | ||
256 | rate = parent_rate; | ||
257 | break; | ||
258 | case CPU_SUBCLK_3X2X: | ||
259 | rate = parent_rate / 2; | ||
260 | break; | ||
261 | case CPU_SUBCLK_2X: | ||
262 | rate = parent_rate / (is_621 ? 3 : 2); | ||
263 | break; | ||
264 | case CPU_SUBCLK_1X: | ||
265 | rate = parent_rate / (is_621 ? 6 : 4); | ||
266 | break; | ||
267 | }; | ||
268 | |||
269 | return rate; | ||
270 | } | ||
271 | |||
272 | static const struct clk_ops zynq_cpu_subclk_ops = { | ||
273 | .recalc_rate = zynq_cpu_subclk_recalc_rate, | ||
274 | }; | ||
275 | |||
276 | static struct clk *zynq_cpu_subclk_setup(struct device_node *np, u8 which, | ||
277 | void __iomem *clk_621) | ||
278 | { | ||
279 | struct zynq_cpu_subclk *subclk; | ||
280 | struct clk_init_data init; | ||
281 | struct clk *clk; | ||
282 | int err; | ||
283 | |||
284 | err = of_property_read_string_index(np, "clock-output-names", | ||
285 | which, &init.name); | ||
286 | if (WARN_ON(err)) | ||
287 | goto err_read_output_name; | ||
288 | |||
289 | subclk = kzalloc(sizeof(*subclk), GFP_KERNEL); | ||
290 | if (!subclk) | ||
291 | goto err_subclk_alloc; | ||
292 | |||
293 | subclk->clk_621 = clk_621; | ||
294 | subclk->which = which; | ||
295 | |||
296 | init.ops = &zynq_cpu_subclk_ops; | ||
297 | init.parent_names = &np->name; | ||
298 | init.num_parents = 1; | ||
299 | |||
300 | subclk->hw.init = &init; | ||
301 | |||
302 | clk = clk_register(NULL, &subclk->hw); | ||
303 | if (WARN_ON(IS_ERR(clk))) | ||
304 | goto err_clk_register; | ||
305 | |||
306 | return clk; | ||
307 | |||
308 | err_clk_register: | ||
309 | kfree(subclk); | ||
310 | err_subclk_alloc: | ||
311 | err_read_output_name: | ||
312 | return ERR_PTR(-EINVAL); | ||
313 | } | ||
314 | |||
315 | static void __init zynq_cpu_clk_setup(struct device_node *np) | ||
316 | { | ||
317 | struct zynq_cpu_clk *cpuclk; | ||
318 | const char *parent_names[3]; | ||
319 | struct clk_init_data init; | ||
320 | void __iomem *clk_621; | ||
321 | struct clk *clk; | ||
322 | u32 reg[2]; | ||
323 | int err; | ||
324 | int i; | ||
325 | |||
326 | err = of_property_read_u32_array(np, "reg", reg, ARRAY_SIZE(reg)); | ||
327 | if (WARN_ON(err)) | ||
328 | return; | ||
329 | |||
330 | cpuclk = kzalloc(sizeof(*cpuclk), GFP_KERNEL); | ||
331 | if (WARN_ON(!cpuclk)) | ||
332 | return; | ||
333 | |||
334 | cpuclk->clk_ctrl = slcr_base + reg[0]; | ||
335 | clk_621 = slcr_base + reg[1]; | ||
336 | spin_lock_init(&cpuclk->clkact_lock); | ||
337 | |||
338 | init.name = np->name; | ||
339 | init.ops = &zynq_cpu_clk_ops; | ||
340 | for (i = 0; i < ARRAY_SIZE(parent_names); i++) | ||
341 | parent_names[i] = of_clk_get_parent_name(np, i); | ||
342 | init.parent_names = parent_names; | ||
343 | init.num_parents = ARRAY_SIZE(parent_names); | ||
344 | |||
345 | cpuclk->hw.init = &init; | ||
346 | |||
347 | clk = clk_register(NULL, &cpuclk->hw); | ||
348 | if (WARN_ON(IS_ERR(clk))) | ||
349 | return; | ||
350 | |||
351 | err = of_clk_add_provider(np, of_clk_src_simple_get, clk); | ||
352 | if (WARN_ON(err)) | ||
353 | return; | ||
354 | |||
355 | for (i = 0; i < 4; i++) { | ||
356 | cpuclk->subclks[i] = zynq_cpu_subclk_setup(np, i, clk_621); | ||
357 | if (WARN_ON(IS_ERR(cpuclk->subclks[i]))) | ||
358 | return; | ||
359 | } | ||
360 | |||
361 | cpuclk->onecell_data.clks = cpuclk->subclks; | ||
362 | cpuclk->onecell_data.clk_num = i; | ||
363 | |||
364 | err = of_clk_add_provider(np, of_clk_src_onecell_get, | ||
365 | &cpuclk->onecell_data); | ||
366 | if (WARN_ON(err)) | ||
367 | return; | ||
368 | } | ||
369 | |||
370 | static const __initconst struct of_device_id zynq_clk_match[] = { | ||
371 | { .compatible = "fixed-clock", .data = of_fixed_clk_setup, }, | ||
372 | { .compatible = "xlnx,zynq-pll", .data = zynq_pll_clk_setup, }, | ||
373 | { .compatible = "xlnx,zynq-periph-clock", | ||
374 | .data = zynq_periph_clk_setup, }, | ||
375 | { .compatible = "xlnx,zynq-cpu-clock", .data = zynq_cpu_clk_setup, }, | ||
376 | {} | ||
377 | }; | ||
378 | |||
379 | void __init xilinx_zynq_clocks_init(void __iomem *slcr) | ||
380 | { | ||
381 | slcr_base = slcr; | ||
382 | of_clk_init(zynq_clk_match); | ||
383 | } | ||
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index 093a8af59cbe..649a146e1382 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c | |||
@@ -29,8 +29,7 @@ | |||
29 | #include <crypto/scatterwalk.h> | 29 | #include <crypto/scatterwalk.h> |
30 | #include <crypto/aes.h> | 30 | #include <crypto/aes.h> |
31 | 31 | ||
32 | #include <plat/cpu.h> | 32 | #include <plat-omap/dma-omap.h> |
33 | #include <plat/dma.h> | ||
34 | 33 | ||
35 | /* OMAP TRM gives bitfields as start:end, where start is the higher bit | 34 | /* OMAP TRM gives bitfields as start:end, where start is the higher bit |
36 | number. For example 7:0 */ | 35 | number. For example 7:0 */ |
@@ -941,11 +940,6 @@ static int __init omap_aes_mod_init(void) | |||
941 | { | 940 | { |
942 | pr_info("loading %s driver\n", "omap-aes"); | 941 | pr_info("loading %s driver\n", "omap-aes"); |
943 | 942 | ||
944 | if (!cpu_class_is_omap2() || omap_type() != OMAP2_DEVICE_TYPE_SEC) { | ||
945 | pr_err("Unsupported cpu\n"); | ||
946 | return -ENODEV; | ||
947 | } | ||
948 | |||
949 | return platform_driver_register(&omap_aes_driver); | 943 | return platform_driver_register(&omap_aes_driver); |
950 | } | 944 | } |
951 | 945 | ||
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c index a3fd6fc504b1..d76fe06b9417 100644 --- a/drivers/crypto/omap-sham.c +++ b/drivers/crypto/omap-sham.c | |||
@@ -37,8 +37,7 @@ | |||
37 | #include <crypto/hash.h> | 37 | #include <crypto/hash.h> |
38 | #include <crypto/internal/hash.h> | 38 | #include <crypto/internal/hash.h> |
39 | 39 | ||
40 | #include <plat/cpu.h> | 40 | #include <plat-omap/dma-omap.h> |
41 | #include <plat/dma.h> | ||
42 | #include <mach/irqs.h> | 41 | #include <mach/irqs.h> |
43 | 42 | ||
44 | #define SHA_REG_DIGEST(x) (0x00 + ((x) * 0x04)) | 43 | #define SHA_REG_DIGEST(x) (0x00 + ((x) * 0x04)) |
@@ -1289,13 +1288,6 @@ static int __init omap_sham_mod_init(void) | |||
1289 | { | 1288 | { |
1290 | pr_info("loading %s driver\n", "omap-sham"); | 1289 | pr_info("loading %s driver\n", "omap-sham"); |
1291 | 1290 | ||
1292 | if (!cpu_class_is_omap2() || | ||
1293 | (omap_type() != OMAP2_DEVICE_TYPE_SEC && | ||
1294 | omap_type() != OMAP2_DEVICE_TYPE_EMU)) { | ||
1295 | pr_err("Unsupported cpu\n"); | ||
1296 | return -ENODEV; | ||
1297 | } | ||
1298 | |||
1299 | return platform_driver_register(&omap_sham_driver); | 1291 | return platform_driver_register(&omap_sham_driver); |
1300 | } | 1292 | } |
1301 | 1293 | ||
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c index 7d9554cc4976..dbf0e6f8de8a 100644 --- a/drivers/dma/imx-dma.c +++ b/drivers/dma/imx-dma.c | |||
@@ -29,7 +29,6 @@ | |||
29 | 29 | ||
30 | #include <asm/irq.h> | 30 | #include <asm/irq.h> |
31 | #include <linux/platform_data/dma-imx.h> | 31 | #include <linux/platform_data/dma-imx.h> |
32 | #include <mach/hardware.h> | ||
33 | 32 | ||
34 | #include "dmaengine.h" | 33 | #include "dmaengine.h" |
35 | #define IMXDMA_MAX_CHAN_DESCRIPTORS 16 | 34 | #define IMXDMA_MAX_CHAN_DESCRIPTORS 16 |
@@ -167,6 +166,12 @@ struct imxdma_channel { | |||
167 | int slot_2d; | 166 | int slot_2d; |
168 | }; | 167 | }; |
169 | 168 | ||
169 | enum imx_dma_type { | ||
170 | IMX1_DMA, | ||
171 | IMX21_DMA, | ||
172 | IMX27_DMA, | ||
173 | }; | ||
174 | |||
170 | struct imxdma_engine { | 175 | struct imxdma_engine { |
171 | struct device *dev; | 176 | struct device *dev; |
172 | struct device_dma_parameters dma_parms; | 177 | struct device_dma_parameters dma_parms; |
@@ -177,7 +182,39 @@ struct imxdma_engine { | |||
177 | spinlock_t lock; | 182 | spinlock_t lock; |
178 | struct imx_dma_2d_config slots_2d[IMX_DMA_2D_SLOTS]; | 183 | struct imx_dma_2d_config slots_2d[IMX_DMA_2D_SLOTS]; |
179 | struct imxdma_channel channel[IMX_DMA_CHANNELS]; | 184 | struct imxdma_channel channel[IMX_DMA_CHANNELS]; |
185 | enum imx_dma_type devtype; | ||
186 | }; | ||
187 | |||
188 | static struct platform_device_id imx_dma_devtype[] = { | ||
189 | { | ||
190 | .name = "imx1-dma", | ||
191 | .driver_data = IMX1_DMA, | ||
192 | }, { | ||
193 | .name = "imx21-dma", | ||
194 | .driver_data = IMX21_DMA, | ||
195 | }, { | ||
196 | .name = "imx27-dma", | ||
197 | .driver_data = IMX27_DMA, | ||
198 | }, { | ||
199 | /* sentinel */ | ||
200 | } | ||
180 | }; | 201 | }; |
202 | MODULE_DEVICE_TABLE(platform, imx_dma_devtype); | ||
203 | |||
204 | static inline int is_imx1_dma(struct imxdma_engine *imxdma) | ||
205 | { | ||
206 | return imxdma->devtype == IMX1_DMA; | ||
207 | } | ||
208 | |||
209 | static inline int is_imx21_dma(struct imxdma_engine *imxdma) | ||
210 | { | ||
211 | return imxdma->devtype == IMX21_DMA; | ||
212 | } | ||
213 | |||
214 | static inline int is_imx27_dma(struct imxdma_engine *imxdma) | ||
215 | { | ||
216 | return imxdma->devtype == IMX27_DMA; | ||
217 | } | ||
181 | 218 | ||
182 | static struct imxdma_channel *to_imxdma_chan(struct dma_chan *chan) | 219 | static struct imxdma_channel *to_imxdma_chan(struct dma_chan *chan) |
183 | { | 220 | { |
@@ -212,7 +249,9 @@ static unsigned imx_dmav1_readl(struct imxdma_engine *imxdma, unsigned offset) | |||
212 | 249 | ||
213 | static int imxdma_hw_chain(struct imxdma_channel *imxdmac) | 250 | static int imxdma_hw_chain(struct imxdma_channel *imxdmac) |
214 | { | 251 | { |
215 | if (cpu_is_mx27()) | 252 | struct imxdma_engine *imxdma = imxdmac->imxdma; |
253 | |||
254 | if (is_imx27_dma(imxdma)) | ||
216 | return imxdmac->hw_chaining; | 255 | return imxdmac->hw_chaining; |
217 | else | 256 | else |
218 | return 0; | 257 | return 0; |
@@ -267,7 +306,7 @@ static void imxdma_enable_hw(struct imxdma_desc *d) | |||
267 | imx_dmav1_writel(imxdma, imx_dmav1_readl(imxdma, DMA_CCR(channel)) | | 306 | imx_dmav1_writel(imxdma, imx_dmav1_readl(imxdma, DMA_CCR(channel)) | |
268 | CCR_CEN | CCR_ACRPT, DMA_CCR(channel)); | 307 | CCR_CEN | CCR_ACRPT, DMA_CCR(channel)); |
269 | 308 | ||
270 | if ((cpu_is_mx21() || cpu_is_mx27()) && | 309 | if (!is_imx1_dma(imxdma) && |
271 | d->sg && imxdma_hw_chain(imxdmac)) { | 310 | d->sg && imxdma_hw_chain(imxdmac)) { |
272 | d->sg = sg_next(d->sg); | 311 | d->sg = sg_next(d->sg); |
273 | if (d->sg) { | 312 | if (d->sg) { |
@@ -436,7 +475,7 @@ static irqreturn_t dma_irq_handler(int irq, void *dev_id) | |||
436 | struct imxdma_engine *imxdma = dev_id; | 475 | struct imxdma_engine *imxdma = dev_id; |
437 | int i, disr; | 476 | int i, disr; |
438 | 477 | ||
439 | if (cpu_is_mx21() || cpu_is_mx27()) | 478 | if (!is_imx1_dma(imxdma)) |
440 | imxdma_err_handler(irq, dev_id); | 479 | imxdma_err_handler(irq, dev_id); |
441 | 480 | ||
442 | disr = imx_dmav1_readl(imxdma, DMA_DISR); | 481 | disr = imx_dmav1_readl(imxdma, DMA_DISR); |
@@ -961,35 +1000,32 @@ static void imxdma_issue_pending(struct dma_chan *chan) | |||
961 | static int __init imxdma_probe(struct platform_device *pdev) | 1000 | static int __init imxdma_probe(struct platform_device *pdev) |
962 | { | 1001 | { |
963 | struct imxdma_engine *imxdma; | 1002 | struct imxdma_engine *imxdma; |
1003 | struct resource *res; | ||
964 | int ret, i; | 1004 | int ret, i; |
1005 | int irq, irq_err; | ||
965 | 1006 | ||
966 | 1007 | imxdma = devm_kzalloc(&pdev->dev, sizeof(*imxdma), GFP_KERNEL); | |
967 | imxdma = kzalloc(sizeof(*imxdma), GFP_KERNEL); | ||
968 | if (!imxdma) | 1008 | if (!imxdma) |
969 | return -ENOMEM; | 1009 | return -ENOMEM; |
970 | 1010 | ||
971 | if (cpu_is_mx1()) { | 1011 | imxdma->devtype = pdev->id_entry->driver_data; |
972 | imxdma->base = MX1_IO_ADDRESS(MX1_DMA_BASE_ADDR); | 1012 | |
973 | } else if (cpu_is_mx21()) { | 1013 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
974 | imxdma->base = MX21_IO_ADDRESS(MX21_DMA_BASE_ADDR); | 1014 | imxdma->base = devm_request_and_ioremap(&pdev->dev, res); |
975 | } else if (cpu_is_mx27()) { | 1015 | if (!imxdma->base) |
976 | imxdma->base = MX27_IO_ADDRESS(MX27_DMA_BASE_ADDR); | 1016 | return -EADDRNOTAVAIL; |
977 | } else { | 1017 | |
978 | kfree(imxdma); | 1018 | irq = platform_get_irq(pdev, 0); |
979 | return 0; | 1019 | if (irq < 0) |
980 | } | 1020 | return irq; |
981 | 1021 | ||
982 | imxdma->dma_ipg = devm_clk_get(&pdev->dev, "ipg"); | 1022 | imxdma->dma_ipg = devm_clk_get(&pdev->dev, "ipg"); |
983 | if (IS_ERR(imxdma->dma_ipg)) { | 1023 | if (IS_ERR(imxdma->dma_ipg)) |
984 | ret = PTR_ERR(imxdma->dma_ipg); | 1024 | return PTR_ERR(imxdma->dma_ipg); |
985 | goto err_clk; | ||
986 | } | ||
987 | 1025 | ||
988 | imxdma->dma_ahb = devm_clk_get(&pdev->dev, "ahb"); | 1026 | imxdma->dma_ahb = devm_clk_get(&pdev->dev, "ahb"); |
989 | if (IS_ERR(imxdma->dma_ahb)) { | 1027 | if (IS_ERR(imxdma->dma_ahb)) |
990 | ret = PTR_ERR(imxdma->dma_ahb); | 1028 | return PTR_ERR(imxdma->dma_ahb); |
991 | goto err_clk; | ||
992 | } | ||
993 | 1029 | ||
994 | clk_prepare_enable(imxdma->dma_ipg); | 1030 | clk_prepare_enable(imxdma->dma_ipg); |
995 | clk_prepare_enable(imxdma->dma_ahb); | 1031 | clk_prepare_enable(imxdma->dma_ahb); |
@@ -997,18 +1033,25 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
997 | /* reset DMA module */ | 1033 | /* reset DMA module */ |
998 | imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR); | 1034 | imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR); |
999 | 1035 | ||
1000 | if (cpu_is_mx1()) { | 1036 | if (is_imx1_dma(imxdma)) { |
1001 | ret = request_irq(MX1_DMA_INT, dma_irq_handler, 0, "DMA", imxdma); | 1037 | ret = devm_request_irq(&pdev->dev, irq, |
1038 | dma_irq_handler, 0, "DMA", imxdma); | ||
1002 | if (ret) { | 1039 | if (ret) { |
1003 | dev_warn(imxdma->dev, "Can't register IRQ for DMA\n"); | 1040 | dev_warn(imxdma->dev, "Can't register IRQ for DMA\n"); |
1004 | goto err_enable; | 1041 | goto err; |
1042 | } | ||
1043 | |||
1044 | irq_err = platform_get_irq(pdev, 1); | ||
1045 | if (irq_err < 0) { | ||
1046 | ret = irq_err; | ||
1047 | goto err; | ||
1005 | } | 1048 | } |
1006 | 1049 | ||
1007 | ret = request_irq(MX1_DMA_ERR, imxdma_err_handler, 0, "DMA", imxdma); | 1050 | ret = devm_request_irq(&pdev->dev, irq_err, |
1051 | imxdma_err_handler, 0, "DMA", imxdma); | ||
1008 | if (ret) { | 1052 | if (ret) { |
1009 | dev_warn(imxdma->dev, "Can't register ERRIRQ for DMA\n"); | 1053 | dev_warn(imxdma->dev, "Can't register ERRIRQ for DMA\n"); |
1010 | free_irq(MX1_DMA_INT, NULL); | 1054 | goto err; |
1011 | goto err_enable; | ||
1012 | } | 1055 | } |
1013 | } | 1056 | } |
1014 | 1057 | ||
@@ -1038,14 +1081,14 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
1038 | for (i = 0; i < IMX_DMA_CHANNELS; i++) { | 1081 | for (i = 0; i < IMX_DMA_CHANNELS; i++) { |
1039 | struct imxdma_channel *imxdmac = &imxdma->channel[i]; | 1082 | struct imxdma_channel *imxdmac = &imxdma->channel[i]; |
1040 | 1083 | ||
1041 | if (cpu_is_mx21() || cpu_is_mx27()) { | 1084 | if (!is_imx1_dma(imxdma)) { |
1042 | ret = request_irq(MX2x_INT_DMACH0 + i, | 1085 | ret = devm_request_irq(&pdev->dev, irq + i, |
1043 | dma_irq_handler, 0, "DMA", imxdma); | 1086 | dma_irq_handler, 0, "DMA", imxdma); |
1044 | if (ret) { | 1087 | if (ret) { |
1045 | dev_warn(imxdma->dev, "Can't register IRQ %d " | 1088 | dev_warn(imxdma->dev, "Can't register IRQ %d " |
1046 | "for DMA channel %d\n", | 1089 | "for DMA channel %d\n", |
1047 | MX2x_INT_DMACH0 + i, i); | 1090 | irq + i, i); |
1048 | goto err_init; | 1091 | goto err; |
1049 | } | 1092 | } |
1050 | init_timer(&imxdmac->watchdog); | 1093 | init_timer(&imxdmac->watchdog); |
1051 | imxdmac->watchdog.function = &imxdma_watchdog; | 1094 | imxdmac->watchdog.function = &imxdma_watchdog; |
@@ -1091,46 +1134,25 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
1091 | ret = dma_async_device_register(&imxdma->dma_device); | 1134 | ret = dma_async_device_register(&imxdma->dma_device); |
1092 | if (ret) { | 1135 | if (ret) { |
1093 | dev_err(&pdev->dev, "unable to register\n"); | 1136 | dev_err(&pdev->dev, "unable to register\n"); |
1094 | goto err_init; | 1137 | goto err; |
1095 | } | 1138 | } |
1096 | 1139 | ||
1097 | return 0; | 1140 | return 0; |
1098 | 1141 | ||
1099 | err_init: | 1142 | err: |
1100 | |||
1101 | if (cpu_is_mx21() || cpu_is_mx27()) { | ||
1102 | while (--i >= 0) | ||
1103 | free_irq(MX2x_INT_DMACH0 + i, NULL); | ||
1104 | } else if cpu_is_mx1() { | ||
1105 | free_irq(MX1_DMA_INT, NULL); | ||
1106 | free_irq(MX1_DMA_ERR, NULL); | ||
1107 | } | ||
1108 | err_enable: | ||
1109 | clk_disable_unprepare(imxdma->dma_ipg); | 1143 | clk_disable_unprepare(imxdma->dma_ipg); |
1110 | clk_disable_unprepare(imxdma->dma_ahb); | 1144 | clk_disable_unprepare(imxdma->dma_ahb); |
1111 | err_clk: | ||
1112 | kfree(imxdma); | ||
1113 | return ret; | 1145 | return ret; |
1114 | } | 1146 | } |
1115 | 1147 | ||
1116 | static int __exit imxdma_remove(struct platform_device *pdev) | 1148 | static int __exit imxdma_remove(struct platform_device *pdev) |
1117 | { | 1149 | { |
1118 | struct imxdma_engine *imxdma = platform_get_drvdata(pdev); | 1150 | struct imxdma_engine *imxdma = platform_get_drvdata(pdev); |
1119 | int i; | ||
1120 | 1151 | ||
1121 | dma_async_device_unregister(&imxdma->dma_device); | 1152 | dma_async_device_unregister(&imxdma->dma_device); |
1122 | 1153 | ||
1123 | if (cpu_is_mx21() || cpu_is_mx27()) { | ||
1124 | for (i = 0; i < IMX_DMA_CHANNELS; i++) | ||
1125 | free_irq(MX2x_INT_DMACH0 + i, NULL); | ||
1126 | } else if cpu_is_mx1() { | ||
1127 | free_irq(MX1_DMA_INT, NULL); | ||
1128 | free_irq(MX1_DMA_ERR, NULL); | ||
1129 | } | ||
1130 | |||
1131 | clk_disable_unprepare(imxdma->dma_ipg); | 1154 | clk_disable_unprepare(imxdma->dma_ipg); |
1132 | clk_disable_unprepare(imxdma->dma_ahb); | 1155 | clk_disable_unprepare(imxdma->dma_ahb); |
1133 | kfree(imxdma); | ||
1134 | 1156 | ||
1135 | return 0; | 1157 | return 0; |
1136 | } | 1158 | } |
@@ -1139,6 +1161,7 @@ static struct platform_driver imxdma_driver = { | |||
1139 | .driver = { | 1161 | .driver = { |
1140 | .name = "imx-dma", | 1162 | .name = "imx-dma", |
1141 | }, | 1163 | }, |
1164 | .id_table = imx_dma_devtype, | ||
1142 | .remove = __exit_p(imxdma_remove), | 1165 | .remove = __exit_p(imxdma_remove), |
1143 | }; | 1166 | }; |
1144 | 1167 | ||
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index c099ca0846f4..f082aa3a918c 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <asm/irq.h> | 40 | #include <asm/irq.h> |
41 | #include <linux/platform_data/dma-imx-sdma.h> | 41 | #include <linux/platform_data/dma-imx-sdma.h> |
42 | #include <linux/platform_data/dma-imx.h> | 42 | #include <linux/platform_data/dma-imx.h> |
43 | #include <mach/hardware.h> | ||
44 | 43 | ||
45 | #include "dmaengine.h" | 44 | #include "dmaengine.h" |
46 | 45 | ||
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c index c7573e50aa14..65855373cee6 100644 --- a/drivers/dma/ipu/ipu_idmac.c +++ b/drivers/dma/ipu/ipu_idmac.c | |||
@@ -22,8 +22,7 @@ | |||
22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | 25 | #include <linux/dma/ipu-dma.h> | |
26 | #include <mach/ipu.h> | ||
27 | 26 | ||
28 | #include "../dmaengine.h" | 27 | #include "../dmaengine.h" |
29 | #include "ipu_intern.h" | 28 | #include "ipu_intern.h" |
diff --git a/drivers/dma/ipu/ipu_irq.c b/drivers/dma/ipu/ipu_irq.c index fa95bcc3de1f..a5ee37d5320f 100644 --- a/drivers/dma/ipu/ipu_irq.c +++ b/drivers/dma/ipu/ipu_irq.c | |||
@@ -15,8 +15,7 @@ | |||
15 | #include <linux/irq.h> | 15 | #include <linux/irq.h> |
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | 18 | #include <linux/dma/ipu-dma.h> | |
19 | #include <mach/ipu.h> | ||
20 | 19 | ||
21 | #include "ipu_intern.h" | 20 | #include "ipu_intern.h" |
22 | 21 | ||
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c index bb2d8e7029eb..7d35c237fbf1 100644 --- a/drivers/dma/omap-dma.c +++ b/drivers/dma/omap-dma.c | |||
@@ -19,8 +19,7 @@ | |||
19 | 19 | ||
20 | #include "virt-dma.h" | 20 | #include "virt-dma.h" |
21 | 21 | ||
22 | #include <plat/cpu.h> | 22 | #include <plat-omap/dma-omap.h> |
23 | #include <plat/dma.h> | ||
24 | 23 | ||
25 | struct omap_dmadev { | 24 | struct omap_dmadev { |
26 | struct dma_device ddev; | 25 | struct dma_device ddev; |
@@ -438,7 +437,7 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic( | |||
438 | omap_disable_dma_irq(c->dma_ch, OMAP_DMA_BLOCK_IRQ); | 437 | omap_disable_dma_irq(c->dma_ch, OMAP_DMA_BLOCK_IRQ); |
439 | } | 438 | } |
440 | 439 | ||
441 | if (!cpu_class_is_omap1()) { | 440 | if (dma_omap2plus()) { |
442 | omap_set_dma_src_burst_mode(c->dma_ch, OMAP_DMA_DATA_BURST_16); | 441 | omap_set_dma_src_burst_mode(c->dma_ch, OMAP_DMA_DATA_BURST_16); |
443 | omap_set_dma_dest_burst_mode(c->dma_ch, OMAP_DMA_DATA_BURST_16); | 442 | omap_set_dma_dest_burst_mode(c->dma_ch, OMAP_DMA_DATA_BURST_16); |
444 | } | 443 | } |
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 2ef162d148cb..b9734747d610 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c | |||
@@ -52,8 +52,6 @@ | |||
52 | #include <linux/of_device.h> | 52 | #include <linux/of_device.h> |
53 | #include <linux/of_i2c.h> | 53 | #include <linux/of_i2c.h> |
54 | #include <linux/pinctrl/consumer.h> | 54 | #include <linux/pinctrl/consumer.h> |
55 | |||
56 | #include <mach/hardware.h> | ||
57 | #include <linux/platform_data/i2c-imx.h> | 55 | #include <linux/platform_data/i2c-imx.h> |
58 | 56 | ||
59 | /** Defines ******************************************************************** | 57 | /** Defines ******************************************************************** |
@@ -115,6 +113,11 @@ static u16 __initdata i2c_clk_div[50][2] = { | |||
115 | { 3072, 0x1E }, { 3840, 0x1F } | 113 | { 3072, 0x1E }, { 3840, 0x1F } |
116 | }; | 114 | }; |
117 | 115 | ||
116 | enum imx_i2c_type { | ||
117 | IMX1_I2C, | ||
118 | IMX21_I2C, | ||
119 | }; | ||
120 | |||
118 | struct imx_i2c_struct { | 121 | struct imx_i2c_struct { |
119 | struct i2c_adapter adapter; | 122 | struct i2c_adapter adapter; |
120 | struct clk *clk; | 123 | struct clk *clk; |
@@ -124,13 +127,33 @@ struct imx_i2c_struct { | |||
124 | unsigned int disable_delay; | 127 | unsigned int disable_delay; |
125 | int stopped; | 128 | int stopped; |
126 | unsigned int ifdr; /* IMX_I2C_IFDR */ | 129 | unsigned int ifdr; /* IMX_I2C_IFDR */ |
130 | enum imx_i2c_type devtype; | ||
131 | }; | ||
132 | |||
133 | static struct platform_device_id imx_i2c_devtype[] = { | ||
134 | { | ||
135 | .name = "imx1-i2c", | ||
136 | .driver_data = IMX1_I2C, | ||
137 | }, { | ||
138 | .name = "imx21-i2c", | ||
139 | .driver_data = IMX21_I2C, | ||
140 | }, { | ||
141 | /* sentinel */ | ||
142 | } | ||
127 | }; | 143 | }; |
144 | MODULE_DEVICE_TABLE(platform, imx_i2c_devtype); | ||
128 | 145 | ||
129 | static const struct of_device_id i2c_imx_dt_ids[] = { | 146 | static const struct of_device_id i2c_imx_dt_ids[] = { |
130 | { .compatible = "fsl,imx1-i2c", }, | 147 | { .compatible = "fsl,imx1-i2c", .data = &imx_i2c_devtype[IMX1_I2C], }, |
148 | { .compatible = "fsl,imx21-i2c", .data = &imx_i2c_devtype[IMX21_I2C], }, | ||
131 | { /* sentinel */ } | 149 | { /* sentinel */ } |
132 | }; | 150 | }; |
133 | 151 | ||
152 | static inline int is_imx1_i2c(struct imx_i2c_struct *i2c_imx) | ||
153 | { | ||
154 | return i2c_imx->devtype == IMX1_I2C; | ||
155 | } | ||
156 | |||
134 | /** Functions for IMX I2C adapter driver *************************************** | 157 | /** Functions for IMX I2C adapter driver *************************************** |
135 | *******************************************************************************/ | 158 | *******************************************************************************/ |
136 | 159 | ||
@@ -223,7 +246,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx) | |||
223 | temp &= ~(I2CR_MSTA | I2CR_MTX); | 246 | temp &= ~(I2CR_MSTA | I2CR_MTX); |
224 | writeb(temp, i2c_imx->base + IMX_I2C_I2CR); | 247 | writeb(temp, i2c_imx->base + IMX_I2C_I2CR); |
225 | } | 248 | } |
226 | if (cpu_is_mx1()) { | 249 | if (is_imx1_i2c(i2c_imx)) { |
227 | /* | 250 | /* |
228 | * This delay caused by an i.MXL hardware bug. | 251 | * This delay caused by an i.MXL hardware bug. |
229 | * If no (or too short) delay, no "STOP" bit will be generated. | 252 | * If no (or too short) delay, no "STOP" bit will be generated. |
@@ -465,6 +488,8 @@ static struct i2c_algorithm i2c_imx_algo = { | |||
465 | 488 | ||
466 | static int __init i2c_imx_probe(struct platform_device *pdev) | 489 | static int __init i2c_imx_probe(struct platform_device *pdev) |
467 | { | 490 | { |
491 | const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids, | ||
492 | &pdev->dev); | ||
468 | struct imx_i2c_struct *i2c_imx; | 493 | struct imx_i2c_struct *i2c_imx; |
469 | struct resource *res; | 494 | struct resource *res; |
470 | struct imxi2c_platform_data *pdata = pdev->dev.platform_data; | 495 | struct imxi2c_platform_data *pdata = pdev->dev.platform_data; |
@@ -497,6 +522,10 @@ static int __init i2c_imx_probe(struct platform_device *pdev) | |||
497 | return -ENOMEM; | 522 | return -ENOMEM; |
498 | } | 523 | } |
499 | 524 | ||
525 | if (of_id) | ||
526 | pdev->id_entry = of_id->data; | ||
527 | i2c_imx->devtype = pdev->id_entry->driver_data; | ||
528 | |||
500 | /* Setup i2c_imx driver structure */ | 529 | /* Setup i2c_imx driver structure */ |
501 | strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name)); | 530 | strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name)); |
502 | i2c_imx->adapter.owner = THIS_MODULE; | 531 | i2c_imx->adapter.owner = THIS_MODULE; |
@@ -593,7 +622,8 @@ static struct platform_driver i2c_imx_driver = { | |||
593 | .name = DRIVER_NAME, | 622 | .name = DRIVER_NAME, |
594 | .owner = THIS_MODULE, | 623 | .owner = THIS_MODULE, |
595 | .of_match_table = i2c_imx_dt_ids, | 624 | .of_match_table = i2c_imx_dt_ids, |
596 | } | 625 | }, |
626 | .id_table = imx_i2c_devtype, | ||
597 | }; | 627 | }; |
598 | 628 | ||
599 | static int __init i2c_adap_imx_init(void) | 629 | static int __init i2c_adap_imx_init(void) |
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c index a3b1a34c896d..4b1becc86e54 100644 --- a/drivers/media/platform/omap/omap_vout.c +++ b/drivers/media/platform/omap/omap_vout.c | |||
@@ -45,8 +45,8 @@ | |||
45 | #include <media/v4l2-ioctl.h> | 45 | #include <media/v4l2-ioctl.h> |
46 | 46 | ||
47 | #include <plat/cpu.h> | 47 | #include <plat/cpu.h> |
48 | #include <plat/dma.h> | 48 | #include <plat-omap/dma-omap.h> |
49 | #include <plat/vrfb.h> | 49 | #include <video/omapvrfb.h> |
50 | #include <video/omapdss.h> | 50 | #include <video/omapdss.h> |
51 | 51 | ||
52 | #include "omap_voutlib.h" | 52 | #include "omap_voutlib.h" |
diff --git a/drivers/media/platform/omap/omap_vout_vrfb.c b/drivers/media/platform/omap/omap_vout_vrfb.c index 4be26abf6cea..8340445a0ee5 100644 --- a/drivers/media/platform/omap/omap_vout_vrfb.c +++ b/drivers/media/platform/omap/omap_vout_vrfb.c | |||
@@ -16,12 +16,14 @@ | |||
16 | #include <media/videobuf-dma-contig.h> | 16 | #include <media/videobuf-dma-contig.h> |
17 | #include <media/v4l2-device.h> | 17 | #include <media/v4l2-device.h> |
18 | 18 | ||
19 | #include <plat/dma.h> | 19 | #include <plat-omap/dma-omap.h> |
20 | #include <plat/vrfb.h> | 20 | #include <video/omapvrfb.h> |
21 | 21 | ||
22 | #include "omap_voutdef.h" | 22 | #include "omap_voutdef.h" |
23 | #include "omap_voutlib.h" | 23 | #include "omap_voutlib.h" |
24 | 24 | ||
25 | #define OMAP_DMA_NO_DEVICE 0 | ||
26 | |||
25 | /* | 27 | /* |
26 | * Function for allocating video buffers | 28 | * Function for allocating video buffers |
27 | */ | 29 | */ |
diff --git a/drivers/media/platform/omap/omap_voutdef.h b/drivers/media/platform/omap/omap_voutdef.h index 27a95d23b913..9ccfe1f475a4 100644 --- a/drivers/media/platform/omap/omap_voutdef.h +++ b/drivers/media/platform/omap/omap_voutdef.h | |||
@@ -12,7 +12,7 @@ | |||
12 | #define OMAP_VOUTDEF_H | 12 | #define OMAP_VOUTDEF_H |
13 | 13 | ||
14 | #include <video/omapdss.h> | 14 | #include <video/omapdss.h> |
15 | #include <plat/vrfb.h> | 15 | #include <video/omapvrfb.h> |
16 | 16 | ||
17 | #define YUYV_BPP 2 | 17 | #define YUYV_BPP 2 |
18 | #define RGB565_BPP 2 | 18 | #define RGB565_BPP 2 |
diff --git a/drivers/media/platform/omap3isp/isphist.c b/drivers/media/platform/omap3isp/isphist.c index d1a8dee5e1ca..e7f9c4292cc6 100644 --- a/drivers/media/platform/omap3isp/isphist.c +++ b/drivers/media/platform/omap3isp/isphist.c | |||
@@ -34,6 +34,8 @@ | |||
34 | #include "ispreg.h" | 34 | #include "ispreg.h" |
35 | #include "isphist.h" | 35 | #include "isphist.h" |
36 | 36 | ||
37 | #define OMAP24XX_DMA_NO_DEVICE 0 | ||
38 | |||
37 | #define HIST_CONFIG_DMA 1 | 39 | #define HIST_CONFIG_DMA 1 |
38 | 40 | ||
39 | #define HIST_USING_DMA(hist) ((hist)->dma_ch >= 0) | 41 | #define HIST_USING_DMA(hist) ((hist)->dma_ch >= 0) |
diff --git a/drivers/media/platform/omap3isp/ispstat.h b/drivers/media/platform/omap3isp/ispstat.h index a6fe653eb237..40f87cdd7994 100644 --- a/drivers/media/platform/omap3isp/ispstat.h +++ b/drivers/media/platform/omap3isp/ispstat.h | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/omap3isp.h> | 32 | #include <linux/omap3isp.h> |
33 | #include <plat/dma.h> | 33 | #include <plat-omap/dma-omap.h> |
34 | #include <media/v4l2-event.h> | 34 | #include <media/v4l2-event.h> |
35 | 35 | ||
36 | #include "isp.h" | 36 | #include "isp.h" |
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index a0b737fecf13..5bd40e6870cc 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <media/v4l2-ioctl.h> | 36 | #include <media/v4l2-ioctl.h> |
37 | #include <plat/iommu.h> | 37 | #include <plat/iommu.h> |
38 | #include <plat/iovmm.h> | 38 | #include <plat/iovmm.h> |
39 | #include <plat/omap-pm.h> | ||
40 | 39 | ||
41 | #include "ispvideo.h" | 40 | #include "ispvideo.h" |
42 | #include "isp.h" | 41 | #include "isp.h" |
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c index 9fd9d1c5b218..e575ae82771d 100644 --- a/drivers/media/platform/soc_camera/mx2_camera.c +++ b/drivers/media/platform/soc_camera/mx2_camera.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <linux/videodev2.h> | 41 | #include <linux/videodev2.h> |
42 | 42 | ||
43 | #include <linux/platform_data/camera-mx2.h> | 43 | #include <linux/platform_data/camera-mx2.h> |
44 | #include <mach/hardware.h> | ||
45 | 44 | ||
46 | #include <asm/dma.h> | 45 | #include <asm/dma.h> |
47 | 46 | ||
@@ -121,11 +120,13 @@ | |||
121 | 120 | ||
122 | #define CSICR1 0x00 | 121 | #define CSICR1 0x00 |
123 | #define CSICR2 0x04 | 122 | #define CSICR2 0x04 |
124 | #define CSISR (cpu_is_mx27() ? 0x08 : 0x18) | 123 | #define CSISR_IMX25 0x18 |
124 | #define CSISR_IMX27 0x08 | ||
125 | #define CSISTATFIFO 0x0c | 125 | #define CSISTATFIFO 0x0c |
126 | #define CSIRFIFO 0x10 | 126 | #define CSIRFIFO 0x10 |
127 | #define CSIRXCNT 0x14 | 127 | #define CSIRXCNT 0x14 |
128 | #define CSICR3 (cpu_is_mx27() ? 0x1C : 0x08) | 128 | #define CSICR3_IMX25 0x08 |
129 | #define CSICR3_IMX27 0x1c | ||
129 | #define CSIDMASA_STATFIFO 0x20 | 130 | #define CSIDMASA_STATFIFO 0x20 |
130 | #define CSIDMATA_STATFIFO 0x24 | 131 | #define CSIDMATA_STATFIFO 0x24 |
131 | #define CSIDMASA_FB1 0x28 | 132 | #define CSIDMASA_FB1 0x28 |
@@ -268,6 +269,11 @@ struct mx2_buffer { | |||
268 | struct mx2_buf_internal internal; | 269 | struct mx2_buf_internal internal; |
269 | }; | 270 | }; |
270 | 271 | ||
272 | enum mx2_camera_type { | ||
273 | IMX25_CAMERA, | ||
274 | IMX27_CAMERA, | ||
275 | }; | ||
276 | |||
271 | struct mx2_camera_dev { | 277 | struct mx2_camera_dev { |
272 | struct device *dev; | 278 | struct device *dev; |
273 | struct soc_camera_host soc_host; | 279 | struct soc_camera_host soc_host; |
@@ -291,6 +297,9 @@ struct mx2_camera_dev { | |||
291 | struct mx2_buffer *fb2_active; | 297 | struct mx2_buffer *fb2_active; |
292 | 298 | ||
293 | u32 csicr1; | 299 | u32 csicr1; |
300 | u32 reg_csisr; | ||
301 | u32 reg_csicr3; | ||
302 | enum mx2_camera_type devtype; | ||
294 | 303 | ||
295 | struct mx2_buf_internal buf_discard[2]; | 304 | struct mx2_buf_internal buf_discard[2]; |
296 | void *discard_buffer; | 305 | void *discard_buffer; |
@@ -303,6 +312,29 @@ struct mx2_camera_dev { | |||
303 | struct vb2_alloc_ctx *alloc_ctx; | 312 | struct vb2_alloc_ctx *alloc_ctx; |
304 | }; | 313 | }; |
305 | 314 | ||
315 | static struct platform_device_id mx2_camera_devtype[] = { | ||
316 | { | ||
317 | .name = "imx25-camera", | ||
318 | .driver_data = IMX25_CAMERA, | ||
319 | }, { | ||
320 | .name = "imx27-camera", | ||
321 | .driver_data = IMX27_CAMERA, | ||
322 | }, { | ||
323 | /* sentinel */ | ||
324 | } | ||
325 | }; | ||
326 | MODULE_DEVICE_TABLE(platform, mx2_camera_devtype); | ||
327 | |||
328 | static inline int is_imx25_camera(struct mx2_camera_dev *pcdev) | ||
329 | { | ||
330 | return pcdev->devtype == IMX25_CAMERA; | ||
331 | } | ||
332 | |||
333 | static inline int is_imx27_camera(struct mx2_camera_dev *pcdev) | ||
334 | { | ||
335 | return pcdev->devtype == IMX27_CAMERA; | ||
336 | } | ||
337 | |||
306 | static struct mx2_buffer *mx2_ibuf_to_buf(struct mx2_buf_internal *int_buf) | 338 | static struct mx2_buffer *mx2_ibuf_to_buf(struct mx2_buf_internal *int_buf) |
307 | { | 339 | { |
308 | return container_of(int_buf, struct mx2_buffer, internal); | 340 | return container_of(int_buf, struct mx2_buffer, internal); |
@@ -434,9 +466,9 @@ static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev) | |||
434 | 466 | ||
435 | clk_disable_unprepare(pcdev->clk_csi); | 467 | clk_disable_unprepare(pcdev->clk_csi); |
436 | writel(0, pcdev->base_csi + CSICR1); | 468 | writel(0, pcdev->base_csi + CSICR1); |
437 | if (cpu_is_mx27()) { | 469 | if (is_imx27_camera(pcdev)) { |
438 | writel(0, pcdev->base_emma + PRP_CNTL); | 470 | writel(0, pcdev->base_emma + PRP_CNTL); |
439 | } else if (cpu_is_mx25()) { | 471 | } else if (is_imx25_camera(pcdev)) { |
440 | spin_lock_irqsave(&pcdev->lock, flags); | 472 | spin_lock_irqsave(&pcdev->lock, flags); |
441 | pcdev->fb1_active = NULL; | 473 | pcdev->fb1_active = NULL; |
442 | pcdev->fb2_active = NULL; | 474 | pcdev->fb2_active = NULL; |
@@ -466,7 +498,7 @@ static int mx2_camera_add_device(struct soc_camera_device *icd) | |||
466 | 498 | ||
467 | csicr1 = CSICR1_MCLKEN; | 499 | csicr1 = CSICR1_MCLKEN; |
468 | 500 | ||
469 | if (cpu_is_mx27()) | 501 | if (is_imx27_camera(pcdev)) |
470 | csicr1 |= CSICR1_PRP_IF_EN | CSICR1_FCC | | 502 | csicr1 |= CSICR1_PRP_IF_EN | CSICR1_FCC | |
471 | CSICR1_RXFF_LEVEL(0); | 503 | CSICR1_RXFF_LEVEL(0); |
472 | 504 | ||
@@ -542,7 +574,7 @@ out: | |||
542 | static irqreturn_t mx25_camera_irq(int irq_csi, void *data) | 574 | static irqreturn_t mx25_camera_irq(int irq_csi, void *data) |
543 | { | 575 | { |
544 | struct mx2_camera_dev *pcdev = data; | 576 | struct mx2_camera_dev *pcdev = data; |
545 | u32 status = readl(pcdev->base_csi + CSISR); | 577 | u32 status = readl(pcdev->base_csi + pcdev->reg_csisr); |
546 | 578 | ||
547 | if (status & CSISR_DMA_TSF_FB1_INT) | 579 | if (status & CSISR_DMA_TSF_FB1_INT) |
548 | mx25_camera_frame_done(pcdev, 1, MX2_STATE_DONE); | 580 | mx25_camera_frame_done(pcdev, 1, MX2_STATE_DONE); |
@@ -551,7 +583,7 @@ static irqreturn_t mx25_camera_irq(int irq_csi, void *data) | |||
551 | 583 | ||
552 | /* FIXME: handle CSISR_RFF_OR_INT */ | 584 | /* FIXME: handle CSISR_RFF_OR_INT */ |
553 | 585 | ||
554 | writel(status, pcdev->base_csi + CSISR); | 586 | writel(status, pcdev->base_csi + pcdev->reg_csisr); |
555 | 587 | ||
556 | return IRQ_HANDLED; | 588 | return IRQ_HANDLED; |
557 | } | 589 | } |
@@ -636,7 +668,7 @@ static void mx2_videobuf_queue(struct vb2_buffer *vb) | |||
636 | buf->state = MX2_STATE_QUEUED; | 668 | buf->state = MX2_STATE_QUEUED; |
637 | list_add_tail(&buf->internal.queue, &pcdev->capture); | 669 | list_add_tail(&buf->internal.queue, &pcdev->capture); |
638 | 670 | ||
639 | if (cpu_is_mx25()) { | 671 | if (is_imx25_camera(pcdev)) { |
640 | u32 csicr3, dma_inten = 0; | 672 | u32 csicr3, dma_inten = 0; |
641 | 673 | ||
642 | if (pcdev->fb1_active == NULL) { | 674 | if (pcdev->fb1_active == NULL) { |
@@ -655,20 +687,20 @@ static void mx2_videobuf_queue(struct vb2_buffer *vb) | |||
655 | list_del(&buf->internal.queue); | 687 | list_del(&buf->internal.queue); |
656 | buf->state = MX2_STATE_ACTIVE; | 688 | buf->state = MX2_STATE_ACTIVE; |
657 | 689 | ||
658 | csicr3 = readl(pcdev->base_csi + CSICR3); | 690 | csicr3 = readl(pcdev->base_csi + pcdev->reg_csicr3); |
659 | 691 | ||
660 | /* Reflash DMA */ | 692 | /* Reflash DMA */ |
661 | writel(csicr3 | CSICR3_DMA_REFLASH_RFF, | 693 | writel(csicr3 | CSICR3_DMA_REFLASH_RFF, |
662 | pcdev->base_csi + CSICR3); | 694 | pcdev->base_csi + pcdev->reg_csicr3); |
663 | 695 | ||
664 | /* clear & enable interrupts */ | 696 | /* clear & enable interrupts */ |
665 | writel(dma_inten, pcdev->base_csi + CSISR); | 697 | writel(dma_inten, pcdev->base_csi + pcdev->reg_csisr); |
666 | pcdev->csicr1 |= dma_inten; | 698 | pcdev->csicr1 |= dma_inten; |
667 | writel(pcdev->csicr1, pcdev->base_csi + CSICR1); | 699 | writel(pcdev->csicr1, pcdev->base_csi + CSICR1); |
668 | 700 | ||
669 | /* enable DMA */ | 701 | /* enable DMA */ |
670 | csicr3 |= CSICR3_DMA_REQ_EN_RFF | CSICR3_RXFF_LEVEL(1); | 702 | csicr3 |= CSICR3_DMA_REQ_EN_RFF | CSICR3_RXFF_LEVEL(1); |
671 | writel(csicr3, pcdev->base_csi + CSICR3); | 703 | writel(csicr3, pcdev->base_csi + pcdev->reg_csicr3); |
672 | } | 704 | } |
673 | } | 705 | } |
674 | 706 | ||
@@ -712,7 +744,7 @@ static void mx2_videobuf_release(struct vb2_buffer *vb) | |||
712 | */ | 744 | */ |
713 | 745 | ||
714 | spin_lock_irqsave(&pcdev->lock, flags); | 746 | spin_lock_irqsave(&pcdev->lock, flags); |
715 | if (cpu_is_mx25() && buf->state == MX2_STATE_ACTIVE) { | 747 | if (is_imx25_camera(pcdev) && buf->state == MX2_STATE_ACTIVE) { |
716 | if (pcdev->fb1_active == buf) { | 748 | if (pcdev->fb1_active == buf) { |
717 | pcdev->csicr1 &= ~CSICR1_FB1_DMA_INTEN; | 749 | pcdev->csicr1 &= ~CSICR1_FB1_DMA_INTEN; |
718 | writel(0, pcdev->base_csi + CSIDMASA_FB1); | 750 | writel(0, pcdev->base_csi + CSIDMASA_FB1); |
@@ -835,7 +867,7 @@ static int mx2_start_streaming(struct vb2_queue *q, unsigned int count) | |||
835 | unsigned long phys; | 867 | unsigned long phys; |
836 | int bytesperline; | 868 | int bytesperline; |
837 | 869 | ||
838 | if (cpu_is_mx27()) { | 870 | if (is_imx27_camera(pcdev)) { |
839 | unsigned long flags; | 871 | unsigned long flags; |
840 | if (count < 2) | 872 | if (count < 2) |
841 | return -EINVAL; | 873 | return -EINVAL; |
@@ -930,7 +962,7 @@ static int mx2_stop_streaming(struct vb2_queue *q) | |||
930 | void *b; | 962 | void *b; |
931 | u32 cntl; | 963 | u32 cntl; |
932 | 964 | ||
933 | if (cpu_is_mx27()) { | 965 | if (is_imx27_camera(pcdev)) { |
934 | spin_lock_irqsave(&pcdev->lock, flags); | 966 | spin_lock_irqsave(&pcdev->lock, flags); |
935 | 967 | ||
936 | cntl = readl(pcdev->base_emma + PRP_CNTL); | 968 | cntl = readl(pcdev->base_emma + PRP_CNTL); |
@@ -1082,11 +1114,11 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd) | |||
1082 | if (bytesperline < 0) | 1114 | if (bytesperline < 0) |
1083 | return bytesperline; | 1115 | return bytesperline; |
1084 | 1116 | ||
1085 | if (cpu_is_mx27()) { | 1117 | if (is_imx27_camera(pcdev)) { |
1086 | ret = mx27_camera_emma_prp_reset(pcdev); | 1118 | ret = mx27_camera_emma_prp_reset(pcdev); |
1087 | if (ret) | 1119 | if (ret) |
1088 | return ret; | 1120 | return ret; |
1089 | } else if (cpu_is_mx25()) { | 1121 | } else if (is_imx25_camera(pcdev)) { |
1090 | writel((bytesperline * icd->user_height) >> 2, | 1122 | writel((bytesperline * icd->user_height) >> 2, |
1091 | pcdev->base_csi + CSIRXCNT); | 1123 | pcdev->base_csi + CSIRXCNT); |
1092 | writel((bytesperline << 16) | icd->user_height, | 1124 | writel((bytesperline << 16) | icd->user_height, |
@@ -1392,7 +1424,7 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd, | |||
1392 | /* FIXME: implement MX27 limits */ | 1424 | /* FIXME: implement MX27 limits */ |
1393 | 1425 | ||
1394 | /* limit to MX25 hardware capabilities */ | 1426 | /* limit to MX25 hardware capabilities */ |
1395 | if (cpu_is_mx25()) { | 1427 | if (is_imx25_camera(pcdev)) { |
1396 | if (xlate->host_fmt->bits_per_sample <= 8) | 1428 | if (xlate->host_fmt->bits_per_sample <= 8) |
1397 | width_limit = 0xffff * 4; | 1429 | width_limit = 0xffff * 4; |
1398 | else | 1430 | else |
@@ -1726,6 +1758,20 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) | |||
1726 | goto exit; | 1758 | goto exit; |
1727 | } | 1759 | } |
1728 | 1760 | ||
1761 | pcdev->devtype = pdev->id_entry->driver_data; | ||
1762 | switch (pcdev->devtype) { | ||
1763 | case IMX25_CAMERA: | ||
1764 | pcdev->reg_csisr = CSISR_IMX25; | ||
1765 | pcdev->reg_csicr3 = CSICR3_IMX25; | ||
1766 | break; | ||
1767 | case IMX27_CAMERA: | ||
1768 | pcdev->reg_csisr = CSISR_IMX27; | ||
1769 | pcdev->reg_csicr3 = CSICR3_IMX27; | ||
1770 | break; | ||
1771 | default: | ||
1772 | break; | ||
1773 | } | ||
1774 | |||
1729 | pcdev->clk_csi = devm_clk_get(&pdev->dev, "ahb"); | 1775 | pcdev->clk_csi = devm_clk_get(&pdev->dev, "ahb"); |
1730 | if (IS_ERR(pcdev->clk_csi)) { | 1776 | if (IS_ERR(pcdev->clk_csi)) { |
1731 | dev_err(&pdev->dev, "Could not get csi clock\n"); | 1777 | dev_err(&pdev->dev, "Could not get csi clock\n"); |
@@ -1763,7 +1809,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) | |||
1763 | pcdev->dev = &pdev->dev; | 1809 | pcdev->dev = &pdev->dev; |
1764 | platform_set_drvdata(pdev, pcdev); | 1810 | platform_set_drvdata(pdev, pcdev); |
1765 | 1811 | ||
1766 | if (cpu_is_mx25()) { | 1812 | if (is_imx25_camera(pcdev)) { |
1767 | err = devm_request_irq(&pdev->dev, irq_csi, mx25_camera_irq, 0, | 1813 | err = devm_request_irq(&pdev->dev, irq_csi, mx25_camera_irq, 0, |
1768 | MX2_CAM_DRV_NAME, pcdev); | 1814 | MX2_CAM_DRV_NAME, pcdev); |
1769 | if (err) { | 1815 | if (err) { |
@@ -1772,7 +1818,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) | |||
1772 | } | 1818 | } |
1773 | } | 1819 | } |
1774 | 1820 | ||
1775 | if (cpu_is_mx27()) { | 1821 | if (is_imx27_camera(pcdev)) { |
1776 | err = mx27_camera_emma_init(pdev); | 1822 | err = mx27_camera_emma_init(pdev); |
1777 | if (err) | 1823 | if (err) |
1778 | goto exit; | 1824 | goto exit; |
@@ -1789,7 +1835,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) | |||
1789 | pcdev->soc_host.priv = pcdev; | 1835 | pcdev->soc_host.priv = pcdev; |
1790 | pcdev->soc_host.v4l2_dev.dev = &pdev->dev; | 1836 | pcdev->soc_host.v4l2_dev.dev = &pdev->dev; |
1791 | pcdev->soc_host.nr = pdev->id; | 1837 | pcdev->soc_host.nr = pdev->id; |
1792 | if (cpu_is_mx25()) | 1838 | if (is_imx25_camera(pcdev)) |
1793 | pcdev->soc_host.capabilities = SOCAM_HOST_CAP_STRIDE; | 1839 | pcdev->soc_host.capabilities = SOCAM_HOST_CAP_STRIDE; |
1794 | 1840 | ||
1795 | pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); | 1841 | pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); |
@@ -1809,7 +1855,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) | |||
1809 | exit_free_emma: | 1855 | exit_free_emma: |
1810 | vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); | 1856 | vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); |
1811 | eallocctx: | 1857 | eallocctx: |
1812 | if (cpu_is_mx27()) { | 1858 | if (is_imx27_camera(pcdev)) { |
1813 | clk_disable_unprepare(pcdev->clk_emma_ipg); | 1859 | clk_disable_unprepare(pcdev->clk_emma_ipg); |
1814 | clk_disable_unprepare(pcdev->clk_emma_ahb); | 1860 | clk_disable_unprepare(pcdev->clk_emma_ahb); |
1815 | } | 1861 | } |
@@ -1827,7 +1873,7 @@ static int __devexit mx2_camera_remove(struct platform_device *pdev) | |||
1827 | 1873 | ||
1828 | vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); | 1874 | vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); |
1829 | 1875 | ||
1830 | if (cpu_is_mx27()) { | 1876 | if (is_imx27_camera(pcdev)) { |
1831 | clk_disable_unprepare(pcdev->clk_emma_ipg); | 1877 | clk_disable_unprepare(pcdev->clk_emma_ipg); |
1832 | clk_disable_unprepare(pcdev->clk_emma_ahb); | 1878 | clk_disable_unprepare(pcdev->clk_emma_ahb); |
1833 | } | 1879 | } |
@@ -1841,6 +1887,7 @@ static struct platform_driver mx2_camera_driver = { | |||
1841 | .driver = { | 1887 | .driver = { |
1842 | .name = MX2_CAM_DRV_NAME, | 1888 | .name = MX2_CAM_DRV_NAME, |
1843 | }, | 1889 | }, |
1890 | .id_table = mx2_camera_devtype, | ||
1844 | .remove = __devexit_p(mx2_camera_remove), | 1891 | .remove = __devexit_p(mx2_camera_remove), |
1845 | }; | 1892 | }; |
1846 | 1893 | ||
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c index 3557ac97e430..64d39b1b5582 100644 --- a/drivers/media/platform/soc_camera/mx3_camera.c +++ b/drivers/media/platform/soc_camera/mx3_camera.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/vmalloc.h> | 17 | #include <linux/vmalloc.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
20 | #include <linux/dma/ipu-dma.h> | ||
20 | 21 | ||
21 | #include <media/v4l2-common.h> | 22 | #include <media/v4l2-common.h> |
22 | #include <media/v4l2-dev.h> | 23 | #include <media/v4l2-dev.h> |
@@ -24,7 +25,6 @@ | |||
24 | #include <media/soc_camera.h> | 25 | #include <media/soc_camera.h> |
25 | #include <media/soc_mediabus.h> | 26 | #include <media/soc_mediabus.h> |
26 | 27 | ||
27 | #include <mach/ipu.h> | ||
28 | #include <linux/platform_data/camera-mx3.h> | 28 | #include <linux/platform_data/camera-mx3.h> |
29 | #include <linux/platform_data/dma-imx.h> | 29 | #include <linux/platform_data/dma-imx.h> |
30 | 30 | ||
diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/media/platform/soc_camera/omap1_camera.c index fa08c7695ccb..cae9ce6275e9 100644 --- a/drivers/media/platform/soc_camera/omap1_camera.c +++ b/drivers/media/platform/soc_camera/omap1_camera.c | |||
@@ -34,12 +34,13 @@ | |||
34 | #include <media/videobuf-dma-contig.h> | 34 | #include <media/videobuf-dma-contig.h> |
35 | #include <media/videobuf-dma-sg.h> | 35 | #include <media/videobuf-dma-sg.h> |
36 | 36 | ||
37 | #include <plat/dma.h> | 37 | #include <plat-omap/dma-omap.h> |
38 | 38 | ||
39 | 39 | ||
40 | #define DRIVER_NAME "omap1-camera" | 40 | #define DRIVER_NAME "omap1-camera" |
41 | #define DRIVER_VERSION "0.0.2" | 41 | #define DRIVER_VERSION "0.0.2" |
42 | 42 | ||
43 | #define OMAP_DMA_CAMERA_IF_RX 20 | ||
43 | 44 | ||
44 | /* | 45 | /* |
45 | * --------------------------------------------------------------------------- | 46 | * --------------------------------------------------------------------------- |
diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c index 546199e9ccc7..82e6c1e282d5 100644 --- a/drivers/media/rc/ir-rx51.c +++ b/drivers/media/rc/ir-rx51.c | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | #include <plat/dmtimer.h> | 29 | #include <plat/dmtimer.h> |
30 | #include <plat/clock.h> | 30 | #include <plat/clock.h> |
31 | #include <plat/omap-pm.h> | ||
32 | 31 | ||
33 | #include <media/lirc.h> | 32 | #include <media/lirc.h> |
34 | #include <media/lirc_dev.h> | 33 | #include <media/lirc_dev.h> |
diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c index 55d589981412..998ce8cb3065 100644 --- a/drivers/mfd/menelaus.c +++ b/drivers/mfd/menelaus.c | |||
@@ -41,11 +41,11 @@ | |||
41 | #include <linux/rtc.h> | 41 | #include <linux/rtc.h> |
42 | #include <linux/bcd.h> | 42 | #include <linux/bcd.h> |
43 | #include <linux/slab.h> | 43 | #include <linux/slab.h> |
44 | #include <linux/mfd/menelaus.h> | ||
44 | 45 | ||
45 | #include <asm/mach/irq.h> | 46 | #include <asm/mach/irq.h> |
46 | 47 | ||
47 | #include <asm/gpio.h> | 48 | #include <asm/gpio.h> |
48 | #include <plat/menelaus.h> | ||
49 | 49 | ||
50 | #define DRIVER_NAME "menelaus" | 50 | #define DRIVER_NAME "menelaus" |
51 | 51 | ||
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 23cec57c02ba..cebfe0a68aa7 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c | |||
@@ -26,9 +26,12 @@ | |||
26 | #include <linux/spinlock.h> | 26 | #include <linux/spinlock.h> |
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <plat/cpu.h> | 28 | #include <plat/cpu.h> |
29 | #include <plat/usb.h> | 29 | #include <linux/platform_device.h> |
30 | #include <linux/platform_data/usb-omap.h> | ||
30 | #include <linux/pm_runtime.h> | 31 | #include <linux/pm_runtime.h> |
31 | 32 | ||
33 | #include "omap-usb.h" | ||
34 | |||
32 | #define USBHS_DRIVER_NAME "usbhs_omap" | 35 | #define USBHS_DRIVER_NAME "usbhs_omap" |
33 | #define OMAP_EHCI_DEVICE "ehci-omap" | 36 | #define OMAP_EHCI_DEVICE "ehci-omap" |
34 | #define OMAP_OHCI_DEVICE "ohci-omap3" | 37 | #define OMAP_OHCI_DEVICE "ohci-omap3" |
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c index 4b7757b84301..0db0dfa3d08c 100644 --- a/drivers/mfd/omap-usb-tll.c +++ b/drivers/mfd/omap-usb-tll.c | |||
@@ -25,8 +25,8 @@ | |||
25 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
26 | #include <linux/io.h> | 26 | #include <linux/io.h> |
27 | #include <linux/err.h> | 27 | #include <linux/err.h> |
28 | #include <plat/usb.h> | ||
29 | #include <linux/pm_runtime.h> | 28 | #include <linux/pm_runtime.h> |
29 | #include <linux/platform_data/usb-omap.h> | ||
30 | 30 | ||
31 | #define USBTLL_DRIVER_NAME "usbhs_tll" | 31 | #define USBTLL_DRIVER_NAME "usbhs_tll" |
32 | 32 | ||
diff --git a/drivers/mfd/omap-usb.h b/drivers/mfd/omap-usb.h new file mode 100644 index 000000000000..972aa961b064 --- /dev/null +++ b/drivers/mfd/omap-usb.h | |||
@@ -0,0 +1,2 @@ | |||
1 | extern int omap_tll_enable(void); | ||
2 | extern int omap_tll_disable(void); | ||
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index 6290b7f1ccfe..477f63bad521 100644 --- a/drivers/mmc/host/mxcmmc.c +++ b/drivers/mmc/host/mxcmmc.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <linux/platform_data/mmc-mxcmmc.h> | 41 | #include <linux/platform_data/mmc-mxcmmc.h> |
42 | 42 | ||
43 | #include <linux/platform_data/dma-imx.h> | 43 | #include <linux/platform_data/dma-imx.h> |
44 | #include <mach/hardware.h> | ||
45 | 44 | ||
46 | #define DRIVER_NAME "mxc-mmc" | 45 | #define DRIVER_NAME "mxc-mmc" |
47 | #define MXCMCI_TIMEOUT_MS 10000 | 46 | #define MXCMCI_TIMEOUT_MS 10000 |
@@ -113,6 +112,11 @@ | |||
113 | #define INT_WRITE_OP_DONE_EN (1 << 1) | 112 | #define INT_WRITE_OP_DONE_EN (1 << 1) |
114 | #define INT_READ_OP_EN (1 << 0) | 113 | #define INT_READ_OP_EN (1 << 0) |
115 | 114 | ||
115 | enum mxcmci_type { | ||
116 | IMX21_MMC, | ||
117 | IMX31_MMC, | ||
118 | }; | ||
119 | |||
116 | struct mxcmci_host { | 120 | struct mxcmci_host { |
117 | struct mmc_host *mmc; | 121 | struct mmc_host *mmc; |
118 | struct resource *res; | 122 | struct resource *res; |
@@ -153,7 +157,26 @@ struct mxcmci_host { | |||
153 | struct imx_dma_data dma_data; | 157 | struct imx_dma_data dma_data; |
154 | 158 | ||
155 | struct timer_list watchdog; | 159 | struct timer_list watchdog; |
160 | enum mxcmci_type devtype; | ||
161 | }; | ||
162 | |||
163 | static struct platform_device_id mxcmci_devtype[] = { | ||
164 | { | ||
165 | .name = "imx21-mmc", | ||
166 | .driver_data = IMX21_MMC, | ||
167 | }, { | ||
168 | .name = "imx31-mmc", | ||
169 | .driver_data = IMX31_MMC, | ||
170 | }, { | ||
171 | /* sentinel */ | ||
172 | } | ||
156 | }; | 173 | }; |
174 | MODULE_DEVICE_TABLE(platform, mxcmci_devtype); | ||
175 | |||
176 | static inline int is_imx31_mmc(struct mxcmci_host *host) | ||
177 | { | ||
178 | return host->devtype == IMX31_MMC; | ||
179 | } | ||
157 | 180 | ||
158 | static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios); | 181 | static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios); |
159 | 182 | ||
@@ -843,6 +866,8 @@ static void mxcmci_enable_sdio_irq(struct mmc_host *mmc, int enable) | |||
843 | 866 | ||
844 | static void mxcmci_init_card(struct mmc_host *host, struct mmc_card *card) | 867 | static void mxcmci_init_card(struct mmc_host *host, struct mmc_card *card) |
845 | { | 868 | { |
869 | struct mxcmci_host *mxcmci = mmc_priv(host); | ||
870 | |||
846 | /* | 871 | /* |
847 | * MX3 SoCs have a silicon bug which corrupts CRC calculation of | 872 | * MX3 SoCs have a silicon bug which corrupts CRC calculation of |
848 | * multi-block transfers when connected SDIO peripheral doesn't | 873 | * multi-block transfers when connected SDIO peripheral doesn't |
@@ -850,7 +875,7 @@ static void mxcmci_init_card(struct mmc_host *host, struct mmc_card *card) | |||
850 | * One way to prevent this is to only allow 1-bit transfers. | 875 | * One way to prevent this is to only allow 1-bit transfers. |
851 | */ | 876 | */ |
852 | 877 | ||
853 | if (cpu_is_mx3() && card->type == MMC_TYPE_SDIO) | 878 | if (is_imx31_mmc(mxcmci) && card->type == MMC_TYPE_SDIO) |
854 | host->caps &= ~MMC_CAP_4_BIT_DATA; | 879 | host->caps &= ~MMC_CAP_4_BIT_DATA; |
855 | else | 880 | else |
856 | host->caps |= MMC_CAP_4_BIT_DATA; | 881 | host->caps |= MMC_CAP_4_BIT_DATA; |
@@ -948,6 +973,7 @@ static int mxcmci_probe(struct platform_device *pdev) | |||
948 | 973 | ||
949 | host->mmc = mmc; | 974 | host->mmc = mmc; |
950 | host->pdata = pdev->dev.platform_data; | 975 | host->pdata = pdev->dev.platform_data; |
976 | host->devtype = pdev->id_entry->driver_data; | ||
951 | spin_lock_init(&host->lock); | 977 | spin_lock_init(&host->lock); |
952 | 978 | ||
953 | mxcmci_init_ocr(host); | 979 | mxcmci_init_ocr(host); |
@@ -1120,6 +1146,7 @@ static const struct dev_pm_ops mxcmci_pm_ops = { | |||
1120 | static struct platform_driver mxcmci_driver = { | 1146 | static struct platform_driver mxcmci_driver = { |
1121 | .probe = mxcmci_probe, | 1147 | .probe = mxcmci_probe, |
1122 | .remove = mxcmci_remove, | 1148 | .remove = mxcmci_remove, |
1149 | .id_table = mxcmci_devtype, | ||
1123 | .driver = { | 1150 | .driver = { |
1124 | .name = DRIVER_NAME, | 1151 | .name = DRIVER_NAME, |
1125 | .owner = THIS_MODULE, | 1152 | .owner = THIS_MODULE, |
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 48ad361613ef..ae115c01283b 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c | |||
@@ -28,9 +28,8 @@ | |||
28 | #include <linux/clk.h> | 28 | #include <linux/clk.h> |
29 | #include <linux/scatterlist.h> | 29 | #include <linux/scatterlist.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/platform_data/mmc-omap.h> | ||
31 | 32 | ||
32 | #include <plat/mmc.h> | ||
33 | #include <plat/dma.h> | ||
34 | 33 | ||
35 | #define OMAP_MMC_REG_CMD 0x00 | 34 | #define OMAP_MMC_REG_CMD 0x00 |
36 | #define OMAP_MMC_REG_ARGL 0x01 | 35 | #define OMAP_MMC_REG_ARGL 0x01 |
@@ -72,6 +71,13 @@ | |||
72 | #define OMAP_MMC_STAT_CARD_BUSY (1 << 2) | 71 | #define OMAP_MMC_STAT_CARD_BUSY (1 << 2) |
73 | #define OMAP_MMC_STAT_END_OF_CMD (1 << 0) | 72 | #define OMAP_MMC_STAT_END_OF_CMD (1 << 0) |
74 | 73 | ||
74 | #define mmc_omap7xx() (host->features & MMC_OMAP7XX) | ||
75 | #define mmc_omap15xx() (host->features & MMC_OMAP15XX) | ||
76 | #define mmc_omap16xx() (host->features & MMC_OMAP16XX) | ||
77 | #define MMC_OMAP1_MASK (MMC_OMAP7XX | MMC_OMAP15XX | MMC_OMAP16XX) | ||
78 | #define mmc_omap1() (host->features & MMC_OMAP1_MASK) | ||
79 | #define mmc_omap2() (!mmc_omap1()) | ||
80 | |||
75 | #define OMAP_MMC_REG(host, reg) (OMAP_MMC_REG_##reg << (host)->reg_shift) | 81 | #define OMAP_MMC_REG(host, reg) (OMAP_MMC_REG_##reg << (host)->reg_shift) |
76 | #define OMAP_MMC_READ(host, reg) __raw_readw((host)->virt_base + OMAP_MMC_REG(host, reg)) | 82 | #define OMAP_MMC_READ(host, reg) __raw_readw((host)->virt_base + OMAP_MMC_REG(host, reg)) |
77 | #define OMAP_MMC_WRITE(host, reg, val) __raw_writew((val), (host)->virt_base + OMAP_MMC_REG(host, reg)) | 83 | #define OMAP_MMC_WRITE(host, reg, val) __raw_writew((val), (host)->virt_base + OMAP_MMC_REG(host, reg)) |
@@ -84,6 +90,16 @@ | |||
84 | #define OMAP_MMC_CMDTYPE_AC 2 | 90 | #define OMAP_MMC_CMDTYPE_AC 2 |
85 | #define OMAP_MMC_CMDTYPE_ADTC 3 | 91 | #define OMAP_MMC_CMDTYPE_ADTC 3 |
86 | 92 | ||
93 | #define OMAP_DMA_MMC_TX 21 | ||
94 | #define OMAP_DMA_MMC_RX 22 | ||
95 | #define OMAP_DMA_MMC2_TX 54 | ||
96 | #define OMAP_DMA_MMC2_RX 55 | ||
97 | |||
98 | #define OMAP24XX_DMA_MMC2_TX 47 | ||
99 | #define OMAP24XX_DMA_MMC2_RX 48 | ||
100 | #define OMAP24XX_DMA_MMC1_TX 61 | ||
101 | #define OMAP24XX_DMA_MMC1_RX 62 | ||
102 | |||
87 | 103 | ||
88 | #define DRIVER_NAME "mmci-omap" | 104 | #define DRIVER_NAME "mmci-omap" |
89 | 105 | ||
@@ -147,6 +163,7 @@ struct mmc_omap_host { | |||
147 | u32 buffer_bytes_left; | 163 | u32 buffer_bytes_left; |
148 | u32 total_bytes_left; | 164 | u32 total_bytes_left; |
149 | 165 | ||
166 | unsigned features; | ||
150 | unsigned use_dma:1; | 167 | unsigned use_dma:1; |
151 | unsigned brs_received:1, dma_done:1; | 168 | unsigned brs_received:1, dma_done:1; |
152 | unsigned dma_in_use:1; | 169 | unsigned dma_in_use:1; |
@@ -988,7 +1005,7 @@ mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req) | |||
988 | * blocksize is at least that large. Blocksize is | 1005 | * blocksize is at least that large. Blocksize is |
989 | * usually 512 bytes; but not for some SD reads. | 1006 | * usually 512 bytes; but not for some SD reads. |
990 | */ | 1007 | */ |
991 | burst = cpu_is_omap15xx() ? 32 : 64; | 1008 | burst = mmc_omap15xx() ? 32 : 64; |
992 | if (burst > data->blksz) | 1009 | if (burst > data->blksz) |
993 | burst = data->blksz; | 1010 | burst = data->blksz; |
994 | 1011 | ||
@@ -1104,8 +1121,7 @@ static void mmc_omap_set_power(struct mmc_omap_slot *slot, int power_on, | |||
1104 | if (slot->pdata->set_power != NULL) | 1121 | if (slot->pdata->set_power != NULL) |
1105 | slot->pdata->set_power(mmc_dev(slot->mmc), slot->id, power_on, | 1122 | slot->pdata->set_power(mmc_dev(slot->mmc), slot->id, power_on, |
1106 | vdd); | 1123 | vdd); |
1107 | 1124 | if (mmc_omap2()) { | |
1108 | if (cpu_is_omap24xx()) { | ||
1109 | u16 w; | 1125 | u16 w; |
1110 | 1126 | ||
1111 | if (power_on) { | 1127 | if (power_on) { |
@@ -1239,7 +1255,7 @@ static int __devinit mmc_omap_new_slot(struct mmc_omap_host *host, int id) | |||
1239 | mmc->ops = &mmc_omap_ops; | 1255 | mmc->ops = &mmc_omap_ops; |
1240 | mmc->f_min = 400000; | 1256 | mmc->f_min = 400000; |
1241 | 1257 | ||
1242 | if (cpu_class_is_omap2()) | 1258 | if (mmc_omap2()) |
1243 | mmc->f_max = 48000000; | 1259 | mmc->f_max = 48000000; |
1244 | else | 1260 | else |
1245 | mmc->f_max = 24000000; | 1261 | mmc->f_max = 24000000; |
@@ -1359,6 +1375,7 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev) | |||
1359 | init_waitqueue_head(&host->slot_wq); | 1375 | init_waitqueue_head(&host->slot_wq); |
1360 | 1376 | ||
1361 | host->pdata = pdata; | 1377 | host->pdata = pdata; |
1378 | host->features = host->pdata->slots[0].features; | ||
1362 | host->dev = &pdev->dev; | 1379 | host->dev = &pdev->dev; |
1363 | platform_set_drvdata(pdev, host); | 1380 | platform_set_drvdata(pdev, host); |
1364 | 1381 | ||
@@ -1391,7 +1408,7 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev) | |||
1391 | host->dma_tx_burst = -1; | 1408 | host->dma_tx_burst = -1; |
1392 | host->dma_rx_burst = -1; | 1409 | host->dma_rx_burst = -1; |
1393 | 1410 | ||
1394 | if (cpu_is_omap24xx()) | 1411 | if (mmc_omap2()) |
1395 | sig = host->id == 0 ? OMAP24XX_DMA_MMC1_TX : OMAP24XX_DMA_MMC2_TX; | 1412 | sig = host->id == 0 ? OMAP24XX_DMA_MMC1_TX : OMAP24XX_DMA_MMC2_TX; |
1396 | else | 1413 | else |
1397 | sig = host->id == 0 ? OMAP_DMA_MMC_TX : OMAP_DMA_MMC2_TX; | 1414 | sig = host->id == 0 ? OMAP_DMA_MMC_TX : OMAP_DMA_MMC2_TX; |
@@ -1407,7 +1424,7 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev) | |||
1407 | dev_warn(host->dev, "unable to obtain TX DMA engine channel %u\n", | 1424 | dev_warn(host->dev, "unable to obtain TX DMA engine channel %u\n", |
1408 | sig); | 1425 | sig); |
1409 | #endif | 1426 | #endif |
1410 | if (cpu_is_omap24xx()) | 1427 | if (mmc_omap2()) |
1411 | sig = host->id == 0 ? OMAP24XX_DMA_MMC1_RX : OMAP24XX_DMA_MMC2_RX; | 1428 | sig = host->id == 0 ? OMAP24XX_DMA_MMC1_RX : OMAP24XX_DMA_MMC2_RX; |
1412 | else | 1429 | else |
1413 | sig = host->id == 0 ? OMAP_DMA_MMC_RX : OMAP_DMA_MMC2_RX; | 1430 | sig = host->id == 0 ? OMAP_DMA_MMC_RX : OMAP_DMA_MMC2_RX; |
@@ -1435,7 +1452,7 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev) | |||
1435 | } | 1452 | } |
1436 | 1453 | ||
1437 | host->nr_slots = pdata->nr_slots; | 1454 | host->nr_slots = pdata->nr_slots; |
1438 | host->reg_shift = (cpu_is_omap7xx() ? 1 : 2); | 1455 | host->reg_shift = (mmc_omap7xx() ? 1 : 2); |
1439 | 1456 | ||
1440 | host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0); | 1457 | host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0); |
1441 | if (!host->mmc_omap_wq) | 1458 | if (!host->mmc_omap_wq) |
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index fedd258cc4ea..e7c185233b18 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
@@ -38,9 +38,7 @@ | |||
38 | #include <linux/gpio.h> | 38 | #include <linux/gpio.h> |
39 | #include <linux/regulator/consumer.h> | 39 | #include <linux/regulator/consumer.h> |
40 | #include <linux/pm_runtime.h> | 40 | #include <linux/pm_runtime.h> |
41 | #include <mach/hardware.h> | 41 | #include <linux/platform_data/mmc-omap.h> |
42 | #include <plat/mmc.h> | ||
43 | #include <plat/cpu.h> | ||
44 | 42 | ||
45 | /* OMAP HSMMC Host Controller Registers */ | 43 | /* OMAP HSMMC Host Controller Registers */ |
46 | #define OMAP_HSMMC_SYSSTATUS 0x0014 | 44 | #define OMAP_HSMMC_SYSSTATUS 0x0014 |
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 72e31d86030d..022dcdc256fb 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -37,15 +37,9 @@ | |||
37 | 37 | ||
38 | #include <asm/mach/flash.h> | 38 | #include <asm/mach/flash.h> |
39 | #include <linux/platform_data/mtd-mxc_nand.h> | 39 | #include <linux/platform_data/mtd-mxc_nand.h> |
40 | #include <mach/hardware.h> | ||
41 | 40 | ||
42 | #define DRIVER_NAME "mxc_nand" | 41 | #define DRIVER_NAME "mxc_nand" |
43 | 42 | ||
44 | #define nfc_is_v21() (cpu_is_mx25() || cpu_is_mx35()) | ||
45 | #define nfc_is_v1() (cpu_is_mx31() || cpu_is_mx27() || cpu_is_mx21()) | ||
46 | #define nfc_is_v3_2a() cpu_is_mx51() | ||
47 | #define nfc_is_v3_2b() cpu_is_mx53() | ||
48 | |||
49 | /* Addresses for NFC registers */ | 43 | /* Addresses for NFC registers */ |
50 | #define NFC_V1_V2_BUF_SIZE (host->regs + 0x00) | 44 | #define NFC_V1_V2_BUF_SIZE (host->regs + 0x00) |
51 | #define NFC_V1_V2_BUF_ADDR (host->regs + 0x04) | 45 | #define NFC_V1_V2_BUF_ADDR (host->regs + 0x04) |
@@ -1283,6 +1277,53 @@ static const struct mxc_nand_devtype_data imx53_nand_devtype_data = { | |||
1283 | .ppb_shift = 8, | 1277 | .ppb_shift = 8, |
1284 | }; | 1278 | }; |
1285 | 1279 | ||
1280 | static inline int is_imx21_nfc(struct mxc_nand_host *host) | ||
1281 | { | ||
1282 | return host->devtype_data == &imx21_nand_devtype_data; | ||
1283 | } | ||
1284 | |||
1285 | static inline int is_imx27_nfc(struct mxc_nand_host *host) | ||
1286 | { | ||
1287 | return host->devtype_data == &imx27_nand_devtype_data; | ||
1288 | } | ||
1289 | |||
1290 | static inline int is_imx25_nfc(struct mxc_nand_host *host) | ||
1291 | { | ||
1292 | return host->devtype_data == &imx25_nand_devtype_data; | ||
1293 | } | ||
1294 | |||
1295 | static inline int is_imx51_nfc(struct mxc_nand_host *host) | ||
1296 | { | ||
1297 | return host->devtype_data == &imx51_nand_devtype_data; | ||
1298 | } | ||
1299 | |||
1300 | static inline int is_imx53_nfc(struct mxc_nand_host *host) | ||
1301 | { | ||
1302 | return host->devtype_data == &imx53_nand_devtype_data; | ||
1303 | } | ||
1304 | |||
1305 | static struct platform_device_id mxcnd_devtype[] = { | ||
1306 | { | ||
1307 | .name = "imx21-nand", | ||
1308 | .driver_data = (kernel_ulong_t) &imx21_nand_devtype_data, | ||
1309 | }, { | ||
1310 | .name = "imx27-nand", | ||
1311 | .driver_data = (kernel_ulong_t) &imx27_nand_devtype_data, | ||
1312 | }, { | ||
1313 | .name = "imx25-nand", | ||
1314 | .driver_data = (kernel_ulong_t) &imx25_nand_devtype_data, | ||
1315 | }, { | ||
1316 | .name = "imx51-nand", | ||
1317 | .driver_data = (kernel_ulong_t) &imx51_nand_devtype_data, | ||
1318 | }, { | ||
1319 | .name = "imx53-nand", | ||
1320 | .driver_data = (kernel_ulong_t) &imx53_nand_devtype_data, | ||
1321 | }, { | ||
1322 | /* sentinel */ | ||
1323 | } | ||
1324 | }; | ||
1325 | MODULE_DEVICE_TABLE(platform, mxcnd_devtype); | ||
1326 | |||
1286 | #ifdef CONFIG_OF_MTD | 1327 | #ifdef CONFIG_OF_MTD |
1287 | static const struct of_device_id mxcnd_dt_ids[] = { | 1328 | static const struct of_device_id mxcnd_dt_ids[] = { |
1288 | { | 1329 | { |
@@ -1337,32 +1378,6 @@ static int __init mxcnd_probe_dt(struct mxc_nand_host *host) | |||
1337 | } | 1378 | } |
1338 | #endif | 1379 | #endif |
1339 | 1380 | ||
1340 | static int __init mxcnd_probe_pdata(struct mxc_nand_host *host) | ||
1341 | { | ||
1342 | struct mxc_nand_platform_data *pdata = host->dev->platform_data; | ||
1343 | |||
1344 | if (!pdata) | ||
1345 | return -ENODEV; | ||
1346 | |||
1347 | host->pdata = *pdata; | ||
1348 | |||
1349 | if (nfc_is_v1()) { | ||
1350 | if (cpu_is_mx21()) | ||
1351 | host->devtype_data = &imx21_nand_devtype_data; | ||
1352 | else | ||
1353 | host->devtype_data = &imx27_nand_devtype_data; | ||
1354 | } else if (nfc_is_v21()) { | ||
1355 | host->devtype_data = &imx25_nand_devtype_data; | ||
1356 | } else if (nfc_is_v3_2a()) { | ||
1357 | host->devtype_data = &imx51_nand_devtype_data; | ||
1358 | } else if (nfc_is_v3_2b()) { | ||
1359 | host->devtype_data = &imx53_nand_devtype_data; | ||
1360 | } else | ||
1361 | BUG(); | ||
1362 | |||
1363 | return 0; | ||
1364 | } | ||
1365 | |||
1366 | static int __devinit mxcnd_probe(struct platform_device *pdev) | 1381 | static int __devinit mxcnd_probe(struct platform_device *pdev) |
1367 | { | 1382 | { |
1368 | struct nand_chip *this; | 1383 | struct nand_chip *this; |
@@ -1404,8 +1419,16 @@ static int __devinit mxcnd_probe(struct platform_device *pdev) | |||
1404 | return PTR_ERR(host->clk); | 1419 | return PTR_ERR(host->clk); |
1405 | 1420 | ||
1406 | err = mxcnd_probe_dt(host); | 1421 | err = mxcnd_probe_dt(host); |
1407 | if (err > 0) | 1422 | if (err > 0) { |
1408 | err = mxcnd_probe_pdata(host); | 1423 | struct mxc_nand_platform_data *pdata = pdev->dev.platform_data; |
1424 | if (pdata) { | ||
1425 | host->pdata = *pdata; | ||
1426 | host->devtype_data = (struct mxc_nand_devtype_data *) | ||
1427 | pdev->id_entry->driver_data; | ||
1428 | } else { | ||
1429 | err = -ENODEV; | ||
1430 | } | ||
1431 | } | ||
1409 | if (err < 0) | 1432 | if (err < 0) |
1410 | return err; | 1433 | return err; |
1411 | 1434 | ||
@@ -1494,7 +1517,7 @@ static int __devinit mxcnd_probe(struct platform_device *pdev) | |||
1494 | } | 1517 | } |
1495 | 1518 | ||
1496 | /* first scan to find the device and get the page size */ | 1519 | /* first scan to find the device and get the page size */ |
1497 | if (nand_scan_ident(mtd, nfc_is_v21() ? 4 : 1, NULL)) { | 1520 | if (nand_scan_ident(mtd, is_imx25_nfc(host) ? 4 : 1, NULL)) { |
1498 | err = -ENXIO; | 1521 | err = -ENXIO; |
1499 | goto escan; | 1522 | goto escan; |
1500 | } | 1523 | } |
@@ -1508,7 +1531,7 @@ static int __devinit mxcnd_probe(struct platform_device *pdev) | |||
1508 | this->ecc.layout = host->devtype_data->ecclayout_4k; | 1531 | this->ecc.layout = host->devtype_data->ecclayout_4k; |
1509 | 1532 | ||
1510 | if (this->ecc.mode == NAND_ECC_HW) { | 1533 | if (this->ecc.mode == NAND_ECC_HW) { |
1511 | if (nfc_is_v1()) | 1534 | if (is_imx21_nfc(host) || is_imx27_nfc(host)) |
1512 | this->ecc.strength = 1; | 1535 | this->ecc.strength = 1; |
1513 | else | 1536 | else |
1514 | this->ecc.strength = (host->eccsize == 4) ? 4 : 8; | 1537 | this->ecc.strength = (host->eccsize == 4) ? 4 : 8; |
@@ -1555,6 +1578,7 @@ static struct platform_driver mxcnd_driver = { | |||
1555 | .owner = THIS_MODULE, | 1578 | .owner = THIS_MODULE, |
1556 | .of_match_table = of_match_ptr(mxcnd_dt_ids), | 1579 | .of_match_table = of_match_ptr(mxcnd_dt_ids), |
1557 | }, | 1580 | }, |
1581 | .id_table = mxcnd_devtype, | ||
1558 | .probe = mxcnd_probe, | 1582 | .probe = mxcnd_probe, |
1559 | .remove = __devexit_p(mxcnd_remove), | 1583 | .remove = __devexit_p(mxcnd_remove), |
1560 | }; | 1584 | }; |
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 5b3138620646..5c8978e90240 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c | |||
@@ -27,8 +27,7 @@ | |||
27 | #include <linux/bch.h> | 27 | #include <linux/bch.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <plat/dma.h> | 30 | #include <plat-omap/dma-omap.h> |
31 | #include <plat/gpmc.h> | ||
32 | #include <linux/platform_data/mtd-nand-omap2.h> | 31 | #include <linux/platform_data/mtd-nand-omap2.h> |
33 | 32 | ||
34 | #define DRIVER_NAME "omap2-nand" | 33 | #define DRIVER_NAME "omap2-nand" |
@@ -106,10 +105,18 @@ | |||
106 | #define CS_MASK 0x7 | 105 | #define CS_MASK 0x7 |
107 | #define ENABLE_PREFETCH (0x1 << 7) | 106 | #define ENABLE_PREFETCH (0x1 << 7) |
108 | #define DMA_MPU_MODE_SHIFT 2 | 107 | #define DMA_MPU_MODE_SHIFT 2 |
108 | #define ECCSIZE0_SHIFT 12 | ||
109 | #define ECCSIZE1_SHIFT 22 | 109 | #define ECCSIZE1_SHIFT 22 |
110 | #define ECC1RESULTSIZE 0x1 | 110 | #define ECC1RESULTSIZE 0x1 |
111 | #define ECCCLEAR 0x100 | 111 | #define ECCCLEAR 0x100 |
112 | #define ECC1 0x1 | 112 | #define ECC1 0x1 |
113 | #define PREFETCH_FIFOTHRESHOLD_MAX 0x40 | ||
114 | #define PREFETCH_FIFOTHRESHOLD(val) ((val) << 8) | ||
115 | #define PREFETCH_STATUS_COUNT(val) (val & 0x00003fff) | ||
116 | #define PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F) | ||
117 | #define STATUS_BUFF_EMPTY 0x00000001 | ||
118 | |||
119 | #define OMAP24XX_DMA_GPMC 4 | ||
113 | 120 | ||
114 | /* oob info generated runtime depending on ecc algorithm and layout selected */ | 121 | /* oob info generated runtime depending on ecc algorithm and layout selected */ |
115 | static struct nand_ecclayout omap_oobinfo; | 122 | static struct nand_ecclayout omap_oobinfo; |
@@ -269,7 +276,7 @@ static void omap_write_buf8(struct mtd_info *mtd, const u_char *buf, int len) | |||
269 | /* wait until buffer is available for write */ | 276 | /* wait until buffer is available for write */ |
270 | do { | 277 | do { |
271 | status = readl(info->reg.gpmc_status) & | 278 | status = readl(info->reg.gpmc_status) & |
272 | GPMC_STATUS_BUFF_EMPTY; | 279 | STATUS_BUFF_EMPTY; |
273 | } while (!status); | 280 | } while (!status); |
274 | } | 281 | } |
275 | } | 282 | } |
@@ -307,7 +314,7 @@ static void omap_write_buf16(struct mtd_info *mtd, const u_char * buf, int len) | |||
307 | /* wait until buffer is available for write */ | 314 | /* wait until buffer is available for write */ |
308 | do { | 315 | do { |
309 | status = readl(info->reg.gpmc_status) & | 316 | status = readl(info->reg.gpmc_status) & |
310 | GPMC_STATUS_BUFF_EMPTY; | 317 | STATUS_BUFF_EMPTY; |
311 | } while (!status); | 318 | } while (!status); |
312 | } | 319 | } |
313 | } | 320 | } |
@@ -348,7 +355,7 @@ static void omap_read_buf_pref(struct mtd_info *mtd, u_char *buf, int len) | |||
348 | } else { | 355 | } else { |
349 | do { | 356 | do { |
350 | r_count = readl(info->reg.gpmc_prefetch_status); | 357 | r_count = readl(info->reg.gpmc_prefetch_status); |
351 | r_count = GPMC_PREFETCH_STATUS_FIFO_CNT(r_count); | 358 | r_count = PREFETCH_STATUS_FIFO_CNT(r_count); |
352 | r_count = r_count >> 2; | 359 | r_count = r_count >> 2; |
353 | ioread32_rep(info->nand.IO_ADDR_R, p, r_count); | 360 | ioread32_rep(info->nand.IO_ADDR_R, p, r_count); |
354 | p += r_count; | 361 | p += r_count; |
@@ -395,7 +402,7 @@ static void omap_write_buf_pref(struct mtd_info *mtd, | |||
395 | } else { | 402 | } else { |
396 | while (len) { | 403 | while (len) { |
397 | w_count = readl(info->reg.gpmc_prefetch_status); | 404 | w_count = readl(info->reg.gpmc_prefetch_status); |
398 | w_count = GPMC_PREFETCH_STATUS_FIFO_CNT(w_count); | 405 | w_count = PREFETCH_STATUS_FIFO_CNT(w_count); |
399 | w_count = w_count >> 1; | 406 | w_count = w_count >> 1; |
400 | for (i = 0; (i < w_count) && len; i++, len -= 2) | 407 | for (i = 0; (i < w_count) && len; i++, len -= 2) |
401 | iowrite16(*p++, info->nand.IO_ADDR_W); | 408 | iowrite16(*p++, info->nand.IO_ADDR_W); |
@@ -407,7 +414,7 @@ static void omap_write_buf_pref(struct mtd_info *mtd, | |||
407 | do { | 414 | do { |
408 | cpu_relax(); | 415 | cpu_relax(); |
409 | val = readl(info->reg.gpmc_prefetch_status); | 416 | val = readl(info->reg.gpmc_prefetch_status); |
410 | val = GPMC_PREFETCH_STATUS_COUNT(val); | 417 | val = PREFETCH_STATUS_COUNT(val); |
411 | } while (val && (tim++ < limit)); | 418 | } while (val && (tim++ < limit)); |
412 | 419 | ||
413 | /* disable and stop the PFPW engine */ | 420 | /* disable and stop the PFPW engine */ |
@@ -493,7 +500,7 @@ static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr, | |||
493 | do { | 500 | do { |
494 | cpu_relax(); | 501 | cpu_relax(); |
495 | val = readl(info->reg.gpmc_prefetch_status); | 502 | val = readl(info->reg.gpmc_prefetch_status); |
496 | val = GPMC_PREFETCH_STATUS_COUNT(val); | 503 | val = PREFETCH_STATUS_COUNT(val); |
497 | } while (val && (tim++ < limit)); | 504 | } while (val && (tim++ < limit)); |
498 | 505 | ||
499 | /* disable and stop the PFPW engine */ | 506 | /* disable and stop the PFPW engine */ |
@@ -556,7 +563,7 @@ static irqreturn_t omap_nand_irq(int this_irq, void *dev) | |||
556 | u32 bytes; | 563 | u32 bytes; |
557 | 564 | ||
558 | bytes = readl(info->reg.gpmc_prefetch_status); | 565 | bytes = readl(info->reg.gpmc_prefetch_status); |
559 | bytes = GPMC_PREFETCH_STATUS_FIFO_CNT(bytes); | 566 | bytes = PREFETCH_STATUS_FIFO_CNT(bytes); |
560 | bytes = bytes & 0xFFFC; /* io in multiple of 4 bytes */ | 567 | bytes = bytes & 0xFFFC; /* io in multiple of 4 bytes */ |
561 | if (info->iomode == OMAP_NAND_IO_WRITE) { /* checks for write io */ | 568 | if (info->iomode == OMAP_NAND_IO_WRITE) { /* checks for write io */ |
562 | if (this_irq == info->gpmc_irq_count) | 569 | if (this_irq == info->gpmc_irq_count) |
@@ -682,7 +689,7 @@ static void omap_write_buf_irq_pref(struct mtd_info *mtd, | |||
682 | limit = (loops_per_jiffy * msecs_to_jiffies(OMAP_NAND_TIMEOUT_MS)); | 689 | limit = (loops_per_jiffy * msecs_to_jiffies(OMAP_NAND_TIMEOUT_MS)); |
683 | do { | 690 | do { |
684 | val = readl(info->reg.gpmc_prefetch_status); | 691 | val = readl(info->reg.gpmc_prefetch_status); |
685 | val = GPMC_PREFETCH_STATUS_COUNT(val); | 692 | val = PREFETCH_STATUS_COUNT(val); |
686 | cpu_relax(); | 693 | cpu_relax(); |
687 | } while (val && (tim++ < limit)); | 694 | } while (val && (tim++ < limit)); |
688 | 695 | ||
@@ -996,7 +1003,7 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) | |||
996 | cond_resched(); | 1003 | cond_resched(); |
997 | } | 1004 | } |
998 | 1005 | ||
999 | status = gpmc_nand_read(info->gpmc_cs, GPMC_NAND_DATA); | 1006 | status = readb(info->reg.gpmc_nand_data); |
1000 | return status; | 1007 | return status; |
1001 | } | 1008 | } |
1002 | 1009 | ||
@@ -1029,19 +1036,45 @@ static int omap_dev_ready(struct mtd_info *mtd) | |||
1029 | static void omap3_enable_hwecc_bch(struct mtd_info *mtd, int mode) | 1036 | static void omap3_enable_hwecc_bch(struct mtd_info *mtd, int mode) |
1030 | { | 1037 | { |
1031 | int nerrors; | 1038 | int nerrors; |
1032 | unsigned int dev_width; | 1039 | unsigned int dev_width, nsectors; |
1033 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, | 1040 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, |
1034 | mtd); | 1041 | mtd); |
1035 | struct nand_chip *chip = mtd->priv; | 1042 | struct nand_chip *chip = mtd->priv; |
1043 | u32 val; | ||
1036 | 1044 | ||
1037 | nerrors = (info->nand.ecc.bytes == 13) ? 8 : 4; | 1045 | nerrors = (info->nand.ecc.bytes == 13) ? 8 : 4; |
1038 | dev_width = (chip->options & NAND_BUSWIDTH_16) ? 1 : 0; | 1046 | dev_width = (chip->options & NAND_BUSWIDTH_16) ? 1 : 0; |
1047 | nsectors = 1; | ||
1039 | /* | 1048 | /* |
1040 | * Program GPMC to perform correction on one 512-byte sector at a time. | 1049 | * Program GPMC to perform correction on one 512-byte sector at a time. |
1041 | * Using 4 sectors at a time (i.e. ecc.size = 2048) is also possible and | 1050 | * Using 4 sectors at a time (i.e. ecc.size = 2048) is also possible and |
1042 | * gives a slight (5%) performance gain (but requires additional code). | 1051 | * gives a slight (5%) performance gain (but requires additional code). |
1043 | */ | 1052 | */ |
1044 | (void)gpmc_enable_hwecc_bch(info->gpmc_cs, mode, dev_width, 1, nerrors); | 1053 | |
1054 | writel(ECC1, info->reg.gpmc_ecc_control); | ||
1055 | |||
1056 | /* | ||
1057 | * When using BCH, sector size is hardcoded to 512 bytes. | ||
1058 | * Here we are using wrapping mode 6 both for reading and writing, with: | ||
1059 | * size0 = 0 (no additional protected byte in spare area) | ||
1060 | * size1 = 32 (skip 32 nibbles = 16 bytes per sector in spare area) | ||
1061 | */ | ||
1062 | val = (32 << ECCSIZE1_SHIFT) | (0 << ECCSIZE0_SHIFT); | ||
1063 | writel(val, info->reg.gpmc_ecc_size_config); | ||
1064 | |||
1065 | /* BCH configuration */ | ||
1066 | val = ((1 << 16) | /* enable BCH */ | ||
1067 | (((nerrors == 8) ? 1 : 0) << 12) | /* 8 or 4 bits */ | ||
1068 | (0x06 << 8) | /* wrap mode = 6 */ | ||
1069 | (dev_width << 7) | /* bus width */ | ||
1070 | (((nsectors-1) & 0x7) << 4) | /* number of sectors */ | ||
1071 | (info->gpmc_cs << 1) | /* ECC CS */ | ||
1072 | (0x1)); /* enable ECC */ | ||
1073 | |||
1074 | writel(val, info->reg.gpmc_ecc_config); | ||
1075 | |||
1076 | /* clear ecc and enable bits */ | ||
1077 | writel(ECCCLEAR | ECC1, info->reg.gpmc_ecc_control); | ||
1045 | } | 1078 | } |
1046 | 1079 | ||
1047 | /** | 1080 | /** |
@@ -1055,7 +1088,32 @@ static int omap3_calculate_ecc_bch4(struct mtd_info *mtd, const u_char *dat, | |||
1055 | { | 1088 | { |
1056 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, | 1089 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, |
1057 | mtd); | 1090 | mtd); |
1058 | return gpmc_calculate_ecc_bch4(info->gpmc_cs, dat, ecc_code); | 1091 | unsigned long nsectors, val1, val2; |
1092 | int i; | ||
1093 | |||
1094 | nsectors = ((readl(info->reg.gpmc_ecc_config) >> 4) & 0x7) + 1; | ||
1095 | |||
1096 | for (i = 0; i < nsectors; i++) { | ||
1097 | |||
1098 | /* Read hw-computed remainder */ | ||
1099 | val1 = readl(info->reg.gpmc_bch_result0[i]); | ||
1100 | val2 = readl(info->reg.gpmc_bch_result1[i]); | ||
1101 | |||
1102 | /* | ||
1103 | * Add constant polynomial to remainder, in order to get an ecc | ||
1104 | * sequence of 0xFFs for a buffer filled with 0xFFs; and | ||
1105 | * left-justify the resulting polynomial. | ||
1106 | */ | ||
1107 | *ecc_code++ = 0x28 ^ ((val2 >> 12) & 0xFF); | ||
1108 | *ecc_code++ = 0x13 ^ ((val2 >> 4) & 0xFF); | ||
1109 | *ecc_code++ = 0xcc ^ (((val2 & 0xF) << 4)|((val1 >> 28) & 0xF)); | ||
1110 | *ecc_code++ = 0x39 ^ ((val1 >> 20) & 0xFF); | ||
1111 | *ecc_code++ = 0x96 ^ ((val1 >> 12) & 0xFF); | ||
1112 | *ecc_code++ = 0xac ^ ((val1 >> 4) & 0xFF); | ||
1113 | *ecc_code++ = 0x7f ^ ((val1 & 0xF) << 4); | ||
1114 | } | ||
1115 | |||
1116 | return 0; | ||
1059 | } | 1117 | } |
1060 | 1118 | ||
1061 | /** | 1119 | /** |
@@ -1069,7 +1127,39 @@ static int omap3_calculate_ecc_bch8(struct mtd_info *mtd, const u_char *dat, | |||
1069 | { | 1127 | { |
1070 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, | 1128 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, |
1071 | mtd); | 1129 | mtd); |
1072 | return gpmc_calculate_ecc_bch8(info->gpmc_cs, dat, ecc_code); | 1130 | unsigned long nsectors, val1, val2, val3, val4; |
1131 | int i; | ||
1132 | |||
1133 | nsectors = ((readl(info->reg.gpmc_ecc_config) >> 4) & 0x7) + 1; | ||
1134 | |||
1135 | for (i = 0; i < nsectors; i++) { | ||
1136 | |||
1137 | /* Read hw-computed remainder */ | ||
1138 | val1 = readl(info->reg.gpmc_bch_result0[i]); | ||
1139 | val2 = readl(info->reg.gpmc_bch_result1[i]); | ||
1140 | val3 = readl(info->reg.gpmc_bch_result2[i]); | ||
1141 | val4 = readl(info->reg.gpmc_bch_result3[i]); | ||
1142 | |||
1143 | /* | ||
1144 | * Add constant polynomial to remainder, in order to get an ecc | ||
1145 | * sequence of 0xFFs for a buffer filled with 0xFFs. | ||
1146 | */ | ||
1147 | *ecc_code++ = 0xef ^ (val4 & 0xFF); | ||
1148 | *ecc_code++ = 0x51 ^ ((val3 >> 24) & 0xFF); | ||
1149 | *ecc_code++ = 0x2e ^ ((val3 >> 16) & 0xFF); | ||
1150 | *ecc_code++ = 0x09 ^ ((val3 >> 8) & 0xFF); | ||
1151 | *ecc_code++ = 0xed ^ (val3 & 0xFF); | ||
1152 | *ecc_code++ = 0x93 ^ ((val2 >> 24) & 0xFF); | ||
1153 | *ecc_code++ = 0x9a ^ ((val2 >> 16) & 0xFF); | ||
1154 | *ecc_code++ = 0xc2 ^ ((val2 >> 8) & 0xFF); | ||
1155 | *ecc_code++ = 0x97 ^ (val2 & 0xFF); | ||
1156 | *ecc_code++ = 0x79 ^ ((val1 >> 24) & 0xFF); | ||
1157 | *ecc_code++ = 0xe5 ^ ((val1 >> 16) & 0xFF); | ||
1158 | *ecc_code++ = 0x24 ^ ((val1 >> 8) & 0xFF); | ||
1159 | *ecc_code++ = 0xb5 ^ (val1 & 0xFF); | ||
1160 | } | ||
1161 | |||
1162 | return 0; | ||
1073 | } | 1163 | } |
1074 | 1164 | ||
1075 | /** | 1165 | /** |
@@ -1125,7 +1215,7 @@ static void omap3_free_bch(struct mtd_info *mtd) | |||
1125 | */ | 1215 | */ |
1126 | static int omap3_init_bch(struct mtd_info *mtd, int ecc_opt) | 1216 | static int omap3_init_bch(struct mtd_info *mtd, int ecc_opt) |
1127 | { | 1217 | { |
1128 | int ret, max_errors; | 1218 | int max_errors; |
1129 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, | 1219 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, |
1130 | mtd); | 1220 | mtd); |
1131 | #ifdef CONFIG_MTD_NAND_OMAP_BCH8 | 1221 | #ifdef CONFIG_MTD_NAND_OMAP_BCH8 |
@@ -1142,11 +1232,6 @@ static int omap3_init_bch(struct mtd_info *mtd, int ecc_opt) | |||
1142 | goto fail; | 1232 | goto fail; |
1143 | } | 1233 | } |
1144 | 1234 | ||
1145 | /* initialize GPMC BCH engine */ | ||
1146 | ret = gpmc_init_hwecc_bch(info->gpmc_cs, 1, max_errors); | ||
1147 | if (ret) | ||
1148 | goto fail; | ||
1149 | |||
1150 | /* software bch library is only used to detect and locate errors */ | 1235 | /* software bch library is only used to detect and locate errors */ |
1151 | info->bch = init_bch(13, max_errors, 0x201b /* hw polynomial */); | 1236 | info->bch = init_bch(13, max_errors, 0x201b /* hw polynomial */); |
1152 | if (!info->bch) | 1237 | if (!info->bch) |
@@ -1513,7 +1598,7 @@ static int omap_nand_remove(struct platform_device *pdev) | |||
1513 | /* Release NAND device, its internal structures and partitions */ | 1598 | /* Release NAND device, its internal structures and partitions */ |
1514 | nand_release(&info->mtd); | 1599 | nand_release(&info->mtd); |
1515 | iounmap(info->nand.IO_ADDR_R); | 1600 | iounmap(info->nand.IO_ADDR_R); |
1516 | release_mem_region(info->phys_base, NAND_IO_SIZE); | 1601 | release_mem_region(info->phys_base, info->mem_size); |
1517 | kfree(info); | 1602 | kfree(info); |
1518 | return 0; | 1603 | return 0; |
1519 | } | 1604 | } |
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c index 1961be985171..99f96e19ebea 100644 --- a/drivers/mtd/onenand/omap2.c +++ b/drivers/mtd/onenand/omap2.c | |||
@@ -38,12 +38,10 @@ | |||
38 | #include <linux/regulator/consumer.h> | 38 | #include <linux/regulator/consumer.h> |
39 | 39 | ||
40 | #include <asm/mach/flash.h> | 40 | #include <asm/mach/flash.h> |
41 | #include <plat/gpmc.h> | ||
42 | #include <linux/platform_data/mtd-onenand-omap2.h> | 41 | #include <linux/platform_data/mtd-onenand-omap2.h> |
43 | #include <asm/gpio.h> | 42 | #include <asm/gpio.h> |
44 | 43 | ||
45 | #include <plat/dma.h> | 44 | #include <plat-omap/dma-omap.h> |
46 | #include <plat/cpu.h> | ||
47 | 45 | ||
48 | #define DRIVER_NAME "omap2-onenand" | 46 | #define DRIVER_NAME "omap2-onenand" |
49 | 47 | ||
@@ -63,6 +61,7 @@ struct omap2_onenand { | |||
63 | int freq; | 61 | int freq; |
64 | int (*setup)(void __iomem *base, int *freq_ptr); | 62 | int (*setup)(void __iomem *base, int *freq_ptr); |
65 | struct regulator *regulator; | 63 | struct regulator *regulator; |
64 | u8 flags; | ||
66 | }; | 65 | }; |
67 | 66 | ||
68 | static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data) | 67 | static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data) |
@@ -155,7 +154,7 @@ static int omap2_onenand_wait(struct mtd_info *mtd, int state) | |||
155 | if (!(syscfg & ONENAND_SYS_CFG1_IOBE)) { | 154 | if (!(syscfg & ONENAND_SYS_CFG1_IOBE)) { |
156 | syscfg |= ONENAND_SYS_CFG1_IOBE; | 155 | syscfg |= ONENAND_SYS_CFG1_IOBE; |
157 | write_reg(c, syscfg, ONENAND_REG_SYS_CFG1); | 156 | write_reg(c, syscfg, ONENAND_REG_SYS_CFG1); |
158 | if (cpu_is_omap34xx()) | 157 | if (c->flags & ONENAND_IN_OMAP34XX) |
159 | /* Add a delay to let GPIO settle */ | 158 | /* Add a delay to let GPIO settle */ |
160 | syscfg = read_reg(c, ONENAND_REG_SYS_CFG1); | 159 | syscfg = read_reg(c, ONENAND_REG_SYS_CFG1); |
161 | } | 160 | } |
@@ -446,13 +445,19 @@ out_copy: | |||
446 | 445 | ||
447 | #else | 446 | #else |
448 | 447 | ||
449 | int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area, | 448 | static int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area, |
450 | unsigned char *buffer, int offset, | 449 | unsigned char *buffer, int offset, |
451 | size_t count); | 450 | size_t count) |
451 | { | ||
452 | return -ENOSYS; | ||
453 | } | ||
452 | 454 | ||
453 | int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area, | 455 | static int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area, |
454 | const unsigned char *buffer, | 456 | const unsigned char *buffer, |
455 | int offset, size_t count); | 457 | int offset, size_t count) |
458 | { | ||
459 | return -ENOSYS; | ||
460 | } | ||
456 | 461 | ||
457 | #endif | 462 | #endif |
458 | 463 | ||
@@ -550,13 +555,19 @@ static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area, | |||
550 | 555 | ||
551 | #else | 556 | #else |
552 | 557 | ||
553 | int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area, | 558 | static int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area, |
554 | unsigned char *buffer, int offset, | 559 | unsigned char *buffer, int offset, |
555 | size_t count); | 560 | size_t count) |
561 | { | ||
562 | return -ENOSYS; | ||
563 | } | ||
556 | 564 | ||
557 | int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area, | 565 | static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area, |
558 | const unsigned char *buffer, | 566 | const unsigned char *buffer, |
559 | int offset, size_t count); | 567 | int offset, size_t count) |
568 | { | ||
569 | return -ENOSYS; | ||
570 | } | ||
560 | 571 | ||
561 | #endif | 572 | #endif |
562 | 573 | ||
@@ -639,6 +650,7 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev) | |||
639 | 650 | ||
640 | init_completion(&c->irq_done); | 651 | init_completion(&c->irq_done); |
641 | init_completion(&c->dma_done); | 652 | init_completion(&c->dma_done); |
653 | c->flags = pdata->flags; | ||
642 | c->gpmc_cs = pdata->cs; | 654 | c->gpmc_cs = pdata->cs; |
643 | c->gpio_irq = pdata->gpio_irq; | 655 | c->gpio_irq = pdata->gpio_irq; |
644 | c->dma_channel = pdata->dma_channel; | 656 | c->dma_channel = pdata->dma_channel; |
@@ -729,7 +741,7 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev) | |||
729 | this = &c->onenand; | 741 | this = &c->onenand; |
730 | if (c->dma_channel >= 0) { | 742 | if (c->dma_channel >= 0) { |
731 | this->wait = omap2_onenand_wait; | 743 | this->wait = omap2_onenand_wait; |
732 | if (cpu_is_omap34xx()) { | 744 | if (c->flags & ONENAND_IN_OMAP34XX) { |
733 | this->read_bufferram = omap3_onenand_read_bufferram; | 745 | this->read_bufferram = omap3_onenand_read_bufferram; |
734 | this->write_bufferram = omap3_onenand_write_bufferram; | 746 | this->write_bufferram = omap3_onenand_write_bufferram; |
735 | } else { | 747 | } else { |
@@ -803,7 +815,6 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev) | |||
803 | } | 815 | } |
804 | iounmap(c->onenand.base); | 816 | iounmap(c->onenand.base); |
805 | release_mem_region(c->phys_base, c->mem_size); | 817 | release_mem_region(c->phys_base, c->mem_size); |
806 | gpmc_cs_free(c->gpmc_cs); | ||
807 | kfree(c); | 818 | kfree(c); |
808 | 819 | ||
809 | return 0; | 820 | return 0; |
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c index fa74efe82206..25c4b1993b3d 100644 --- a/drivers/pcmcia/omap_cf.c +++ b/drivers/pcmcia/omap_cf.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <asm/sizes.h> | 25 | #include <asm/sizes.h> |
26 | 26 | ||
27 | #include <mach/mux.h> | 27 | #include <mach/mux.h> |
28 | #include <plat/tc.h> | 28 | #include <mach/tc.h> |
29 | 29 | ||
30 | 30 | ||
31 | /* NOTE: don't expect this to support many I/O cards. The 16xx chips have | 31 | /* NOTE: don't expect this to support many I/O cards. The 16xx chips have |
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index cd0106293a49..7304139934aa 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
@@ -17,8 +17,6 @@ | |||
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
19 | 19 | ||
20 | #include <mach/hardware.h> | ||
21 | |||
22 | #define RTC_INPUT_CLK_32768HZ (0x00 << 5) | 20 | #define RTC_INPUT_CLK_32768HZ (0x00 << 5) |
23 | #define RTC_INPUT_CLK_32000HZ (0x01 << 5) | 21 | #define RTC_INPUT_CLK_32000HZ (0x01 << 5) |
24 | #define RTC_INPUT_CLK_38400HZ (0x02 << 5) | 22 | #define RTC_INPUT_CLK_38400HZ (0x02 << 5) |
@@ -72,14 +70,38 @@ static const u32 PIE_BIT_DEF[MAX_PIE_NUM][2] = { | |||
72 | #define RTC_TEST2 0x2C /* 32bit rtc test reg 2 */ | 70 | #define RTC_TEST2 0x2C /* 32bit rtc test reg 2 */ |
73 | #define RTC_TEST3 0x30 /* 32bit rtc test reg 3 */ | 71 | #define RTC_TEST3 0x30 /* 32bit rtc test reg 3 */ |
74 | 72 | ||
73 | enum imx_rtc_type { | ||
74 | IMX1_RTC, | ||
75 | IMX21_RTC, | ||
76 | }; | ||
77 | |||
75 | struct rtc_plat_data { | 78 | struct rtc_plat_data { |
76 | struct rtc_device *rtc; | 79 | struct rtc_device *rtc; |
77 | void __iomem *ioaddr; | 80 | void __iomem *ioaddr; |
78 | int irq; | 81 | int irq; |
79 | struct clk *clk; | 82 | struct clk *clk; |
80 | struct rtc_time g_rtc_alarm; | 83 | struct rtc_time g_rtc_alarm; |
84 | enum imx_rtc_type devtype; | ||
81 | }; | 85 | }; |
82 | 86 | ||
87 | static struct platform_device_id imx_rtc_devtype[] = { | ||
88 | { | ||
89 | .name = "imx1-rtc", | ||
90 | .driver_data = IMX1_RTC, | ||
91 | }, { | ||
92 | .name = "imx21-rtc", | ||
93 | .driver_data = IMX21_RTC, | ||
94 | }, { | ||
95 | /* sentinel */ | ||
96 | } | ||
97 | }; | ||
98 | MODULE_DEVICE_TABLE(platform, imx_rtc_devtype); | ||
99 | |||
100 | static inline int is_imx1_rtc(struct rtc_plat_data *data) | ||
101 | { | ||
102 | return data->devtype == IMX1_RTC; | ||
103 | } | ||
104 | |||
83 | /* | 105 | /* |
84 | * This function is used to obtain the RTC time or the alarm value in | 106 | * This function is used to obtain the RTC time or the alarm value in |
85 | * second. | 107 | * second. |
@@ -278,10 +300,13 @@ static int mxc_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
278 | */ | 300 | */ |
279 | static int mxc_rtc_set_mmss(struct device *dev, unsigned long time) | 301 | static int mxc_rtc_set_mmss(struct device *dev, unsigned long time) |
280 | { | 302 | { |
303 | struct platform_device *pdev = to_platform_device(dev); | ||
304 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | ||
305 | |||
281 | /* | 306 | /* |
282 | * TTC_DAYR register is 9-bit in MX1 SoC, save time and day of year only | 307 | * TTC_DAYR register is 9-bit in MX1 SoC, save time and day of year only |
283 | */ | 308 | */ |
284 | if (cpu_is_mx1()) { | 309 | if (is_imx1_rtc(pdata)) { |
285 | struct rtc_time tm; | 310 | struct rtc_time tm; |
286 | 311 | ||
287 | rtc_time_to_tm(time, &tm); | 312 | rtc_time_to_tm(time, &tm); |
@@ -360,6 +385,8 @@ static int __devinit mxc_rtc_probe(struct platform_device *pdev) | |||
360 | if (!pdata) | 385 | if (!pdata) |
361 | return -ENOMEM; | 386 | return -ENOMEM; |
362 | 387 | ||
388 | pdata->devtype = pdev->id_entry->driver_data; | ||
389 | |||
363 | if (!devm_request_mem_region(&pdev->dev, res->start, | 390 | if (!devm_request_mem_region(&pdev->dev, res->start, |
364 | resource_size(res), pdev->name)) | 391 | resource_size(res), pdev->name)) |
365 | return -EBUSY; | 392 | return -EBUSY; |
@@ -480,6 +507,7 @@ static struct platform_driver mxc_rtc_driver = { | |||
480 | #endif | 507 | #endif |
481 | .owner = THIS_MODULE, | 508 | .owner = THIS_MODULE, |
482 | }, | 509 | }, |
510 | .id_table = imx_rtc_devtype, | ||
483 | .probe = mxc_rtc_probe, | 511 | .probe = mxc_rtc_probe, |
484 | .remove = __devexit_p(mxc_rtc_remove), | 512 | .remove = __devexit_p(mxc_rtc_remove), |
485 | }; | 513 | }; |
diff --git a/drivers/staging/tidspbridge/include/dspbridge/host_os.h b/drivers/staging/tidspbridge/include/dspbridge/host_os.h index 5e2f4d82d925..7f3a1db31619 100644 --- a/drivers/staging/tidspbridge/include/dspbridge/host_os.h +++ b/drivers/staging/tidspbridge/include/dspbridge/host_os.h | |||
@@ -40,7 +40,6 @@ | |||
40 | #include <linux/vmalloc.h> | 40 | #include <linux/vmalloc.h> |
41 | #include <linux/ioport.h> | 41 | #include <linux/ioport.h> |
42 | #include <linux/platform_device.h> | 42 | #include <linux/platform_device.h> |
43 | #include <plat/clock.h> | ||
44 | #include <linux/clk.h> | 43 | #include <linux/clk.h> |
45 | #include <plat/mailbox.h> | 44 | #include <plat/mailbox.h> |
46 | #include <linux/pagemap.h> | 45 | #include <linux/pagemap.h> |
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 8c0b7b42319c..60b076cc4e20 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
@@ -73,10 +73,42 @@ | |||
73 | #define ECHO_OP_SET_CANON_COL 0x81 | 73 | #define ECHO_OP_SET_CANON_COL 0x81 |
74 | #define ECHO_OP_ERASE_TAB 0x82 | 74 | #define ECHO_OP_ERASE_TAB 0x82 |
75 | 75 | ||
76 | struct n_tty_data { | ||
77 | unsigned int column; | ||
78 | unsigned long overrun_time; | ||
79 | int num_overrun; | ||
80 | |||
81 | unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; | ||
82 | unsigned char echo_overrun:1; | ||
83 | |||
84 | DECLARE_BITMAP(process_char_map, 256); | ||
85 | DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE); | ||
86 | |||
87 | char *read_buf; | ||
88 | int read_head; | ||
89 | int read_tail; | ||
90 | int read_cnt; | ||
91 | |||
92 | unsigned char *echo_buf; | ||
93 | unsigned int echo_pos; | ||
94 | unsigned int echo_cnt; | ||
95 | |||
96 | int canon_data; | ||
97 | unsigned long canon_head; | ||
98 | unsigned int canon_column; | ||
99 | |||
100 | struct mutex atomic_read_lock; | ||
101 | struct mutex output_lock; | ||
102 | struct mutex echo_lock; | ||
103 | spinlock_t read_lock; | ||
104 | }; | ||
105 | |||
76 | static inline int tty_put_user(struct tty_struct *tty, unsigned char x, | 106 | static inline int tty_put_user(struct tty_struct *tty, unsigned char x, |
77 | unsigned char __user *ptr) | 107 | unsigned char __user *ptr) |
78 | { | 108 | { |
79 | tty_audit_add_data(tty, &x, 1); | 109 | struct n_tty_data *ldata = tty->disc_data; |
110 | |||
111 | tty_audit_add_data(tty, &x, 1, ldata->icanon); | ||
80 | return put_user(x, ptr); | 112 | return put_user(x, ptr); |
81 | } | 113 | } |
82 | 114 | ||
@@ -92,17 +124,18 @@ static inline int tty_put_user(struct tty_struct *tty, unsigned char x, | |||
92 | 124 | ||
93 | static void n_tty_set_room(struct tty_struct *tty) | 125 | static void n_tty_set_room(struct tty_struct *tty) |
94 | { | 126 | { |
127 | struct n_tty_data *ldata = tty->disc_data; | ||
95 | int left; | 128 | int left; |
96 | int old_left; | 129 | int old_left; |
97 | 130 | ||
98 | /* tty->read_cnt is not read locked ? */ | 131 | /* ldata->read_cnt is not read locked ? */ |
99 | if (I_PARMRK(tty)) { | 132 | if (I_PARMRK(tty)) { |
100 | /* Multiply read_cnt by 3, since each byte might take up to | 133 | /* Multiply read_cnt by 3, since each byte might take up to |
101 | * three times as many spaces when PARMRK is set (depending on | 134 | * three times as many spaces when PARMRK is set (depending on |
102 | * its flags, e.g. parity error). */ | 135 | * its flags, e.g. parity error). */ |
103 | left = N_TTY_BUF_SIZE - tty->read_cnt * 3 - 1; | 136 | left = N_TTY_BUF_SIZE - ldata->read_cnt * 3 - 1; |
104 | } else | 137 | } else |
105 | left = N_TTY_BUF_SIZE - tty->read_cnt - 1; | 138 | left = N_TTY_BUF_SIZE - ldata->read_cnt - 1; |
106 | 139 | ||
107 | /* | 140 | /* |
108 | * If we are doing input canonicalization, and there are no | 141 | * If we are doing input canonicalization, and there are no |
@@ -111,44 +144,47 @@ static void n_tty_set_room(struct tty_struct *tty) | |||
111 | * characters will be beeped. | 144 | * characters will be beeped. |
112 | */ | 145 | */ |
113 | if (left <= 0) | 146 | if (left <= 0) |
114 | left = tty->icanon && !tty->canon_data; | 147 | left = ldata->icanon && !ldata->canon_data; |
115 | old_left = tty->receive_room; | 148 | old_left = tty->receive_room; |
116 | tty->receive_room = left; | 149 | tty->receive_room = left; |
117 | 150 | ||
118 | /* Did this open up the receive buffer? We may need to flip */ | 151 | /* Did this open up the receive buffer? We may need to flip */ |
119 | if (left && !old_left) | 152 | if (left && !old_left) { |
120 | schedule_work(&tty->buf.work); | 153 | WARN_RATELIMIT(tty->port->itty == NULL, |
154 | "scheduling with invalid itty"); | ||
155 | schedule_work(&tty->port->buf.work); | ||
156 | } | ||
121 | } | 157 | } |
122 | 158 | ||
123 | static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty) | 159 | static void put_tty_queue_nolock(unsigned char c, struct n_tty_data *ldata) |
124 | { | 160 | { |
125 | if (tty->read_cnt < N_TTY_BUF_SIZE) { | 161 | if (ldata->read_cnt < N_TTY_BUF_SIZE) { |
126 | tty->read_buf[tty->read_head] = c; | 162 | ldata->read_buf[ldata->read_head] = c; |
127 | tty->read_head = (tty->read_head + 1) & (N_TTY_BUF_SIZE-1); | 163 | ldata->read_head = (ldata->read_head + 1) & (N_TTY_BUF_SIZE-1); |
128 | tty->read_cnt++; | 164 | ldata->read_cnt++; |
129 | } | 165 | } |
130 | } | 166 | } |
131 | 167 | ||
132 | /** | 168 | /** |
133 | * put_tty_queue - add character to tty | 169 | * put_tty_queue - add character to tty |
134 | * @c: character | 170 | * @c: character |
135 | * @tty: tty device | 171 | * @ldata: n_tty data |
136 | * | 172 | * |
137 | * Add a character to the tty read_buf queue. This is done under the | 173 | * Add a character to the tty read_buf queue. This is done under the |
138 | * read_lock to serialize character addition and also to protect us | 174 | * read_lock to serialize character addition and also to protect us |
139 | * against parallel reads or flushes | 175 | * against parallel reads or flushes |
140 | */ | 176 | */ |
141 | 177 | ||
142 | static void put_tty_queue(unsigned char c, struct tty_struct *tty) | 178 | static void put_tty_queue(unsigned char c, struct n_tty_data *ldata) |
143 | { | 179 | { |
144 | unsigned long flags; | 180 | unsigned long flags; |
145 | /* | 181 | /* |
146 | * The problem of stomping on the buffers ends here. | 182 | * The problem of stomping on the buffers ends here. |
147 | * Why didn't anyone see this one coming? --AJK | 183 | * Why didn't anyone see this one coming? --AJK |
148 | */ | 184 | */ |
149 | spin_lock_irqsave(&tty->read_lock, flags); | 185 | spin_lock_irqsave(&ldata->read_lock, flags); |
150 | put_tty_queue_nolock(c, tty); | 186 | put_tty_queue_nolock(c, ldata); |
151 | spin_unlock_irqrestore(&tty->read_lock, flags); | 187 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
152 | } | 188 | } |
153 | 189 | ||
154 | /** | 190 | /** |
@@ -179,18 +215,19 @@ static void check_unthrottle(struct tty_struct *tty) | |||
179 | 215 | ||
180 | static void reset_buffer_flags(struct tty_struct *tty) | 216 | static void reset_buffer_flags(struct tty_struct *tty) |
181 | { | 217 | { |
218 | struct n_tty_data *ldata = tty->disc_data; | ||
182 | unsigned long flags; | 219 | unsigned long flags; |
183 | 220 | ||
184 | spin_lock_irqsave(&tty->read_lock, flags); | 221 | spin_lock_irqsave(&ldata->read_lock, flags); |
185 | tty->read_head = tty->read_tail = tty->read_cnt = 0; | 222 | ldata->read_head = ldata->read_tail = ldata->read_cnt = 0; |
186 | spin_unlock_irqrestore(&tty->read_lock, flags); | 223 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
187 | 224 | ||
188 | mutex_lock(&tty->echo_lock); | 225 | mutex_lock(&ldata->echo_lock); |
189 | tty->echo_pos = tty->echo_cnt = tty->echo_overrun = 0; | 226 | ldata->echo_pos = ldata->echo_cnt = ldata->echo_overrun = 0; |
190 | mutex_unlock(&tty->echo_lock); | 227 | mutex_unlock(&ldata->echo_lock); |
191 | 228 | ||
192 | tty->canon_head = tty->canon_data = tty->erasing = 0; | 229 | ldata->canon_head = ldata->canon_data = ldata->erasing = 0; |
193 | memset(&tty->read_flags, 0, sizeof tty->read_flags); | 230 | bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE); |
194 | n_tty_set_room(tty); | 231 | n_tty_set_room(tty); |
195 | } | 232 | } |
196 | 233 | ||
@@ -235,18 +272,19 @@ static void n_tty_flush_buffer(struct tty_struct *tty) | |||
235 | 272 | ||
236 | static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) | 273 | static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) |
237 | { | 274 | { |
275 | struct n_tty_data *ldata = tty->disc_data; | ||
238 | unsigned long flags; | 276 | unsigned long flags; |
239 | ssize_t n = 0; | 277 | ssize_t n = 0; |
240 | 278 | ||
241 | spin_lock_irqsave(&tty->read_lock, flags); | 279 | spin_lock_irqsave(&ldata->read_lock, flags); |
242 | if (!tty->icanon) { | 280 | if (!ldata->icanon) { |
243 | n = tty->read_cnt; | 281 | n = ldata->read_cnt; |
244 | } else if (tty->canon_data) { | 282 | } else if (ldata->canon_data) { |
245 | n = (tty->canon_head > tty->read_tail) ? | 283 | n = (ldata->canon_head > ldata->read_tail) ? |
246 | tty->canon_head - tty->read_tail : | 284 | ldata->canon_head - ldata->read_tail : |
247 | tty->canon_head + (N_TTY_BUF_SIZE - tty->read_tail); | 285 | ldata->canon_head + (N_TTY_BUF_SIZE - ldata->read_tail); |
248 | } | 286 | } |
249 | spin_unlock_irqrestore(&tty->read_lock, flags); | 287 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
250 | return n; | 288 | return n; |
251 | } | 289 | } |
252 | 290 | ||
@@ -301,6 +339,7 @@ static inline int is_continuation(unsigned char c, struct tty_struct *tty) | |||
301 | 339 | ||
302 | static int do_output_char(unsigned char c, struct tty_struct *tty, int space) | 340 | static int do_output_char(unsigned char c, struct tty_struct *tty, int space) |
303 | { | 341 | { |
342 | struct n_tty_data *ldata = tty->disc_data; | ||
304 | int spaces; | 343 | int spaces; |
305 | 344 | ||
306 | if (!space) | 345 | if (!space) |
@@ -309,48 +348,48 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space) | |||
309 | switch (c) { | 348 | switch (c) { |
310 | case '\n': | 349 | case '\n': |
311 | if (O_ONLRET(tty)) | 350 | if (O_ONLRET(tty)) |
312 | tty->column = 0; | 351 | ldata->column = 0; |
313 | if (O_ONLCR(tty)) { | 352 | if (O_ONLCR(tty)) { |
314 | if (space < 2) | 353 | if (space < 2) |
315 | return -1; | 354 | return -1; |
316 | tty->canon_column = tty->column = 0; | 355 | ldata->canon_column = ldata->column = 0; |
317 | tty->ops->write(tty, "\r\n", 2); | 356 | tty->ops->write(tty, "\r\n", 2); |
318 | return 2; | 357 | return 2; |
319 | } | 358 | } |
320 | tty->canon_column = tty->column; | 359 | ldata->canon_column = ldata->column; |
321 | break; | 360 | break; |
322 | case '\r': | 361 | case '\r': |
323 | if (O_ONOCR(tty) && tty->column == 0) | 362 | if (O_ONOCR(tty) && ldata->column == 0) |
324 | return 0; | 363 | return 0; |
325 | if (O_OCRNL(tty)) { | 364 | if (O_OCRNL(tty)) { |
326 | c = '\n'; | 365 | c = '\n'; |
327 | if (O_ONLRET(tty)) | 366 | if (O_ONLRET(tty)) |
328 | tty->canon_column = tty->column = 0; | 367 | ldata->canon_column = ldata->column = 0; |
329 | break; | 368 | break; |
330 | } | 369 | } |
331 | tty->canon_column = tty->column = 0; | 370 | ldata->canon_column = ldata->column = 0; |
332 | break; | 371 | break; |
333 | case '\t': | 372 | case '\t': |
334 | spaces = 8 - (tty->column & 7); | 373 | spaces = 8 - (ldata->column & 7); |
335 | if (O_TABDLY(tty) == XTABS) { | 374 | if (O_TABDLY(tty) == XTABS) { |
336 | if (space < spaces) | 375 | if (space < spaces) |
337 | return -1; | 376 | return -1; |
338 | tty->column += spaces; | 377 | ldata->column += spaces; |
339 | tty->ops->write(tty, " ", spaces); | 378 | tty->ops->write(tty, " ", spaces); |
340 | return spaces; | 379 | return spaces; |
341 | } | 380 | } |
342 | tty->column += spaces; | 381 | ldata->column += spaces; |
343 | break; | 382 | break; |
344 | case '\b': | 383 | case '\b': |
345 | if (tty->column > 0) | 384 | if (ldata->column > 0) |
346 | tty->column--; | 385 | ldata->column--; |
347 | break; | 386 | break; |
348 | default: | 387 | default: |
349 | if (!iscntrl(c)) { | 388 | if (!iscntrl(c)) { |
350 | if (O_OLCUC(tty)) | 389 | if (O_OLCUC(tty)) |
351 | c = toupper(c); | 390 | c = toupper(c); |
352 | if (!is_continuation(c, tty)) | 391 | if (!is_continuation(c, tty)) |
353 | tty->column++; | 392 | ldata->column++; |
354 | } | 393 | } |
355 | break; | 394 | break; |
356 | } | 395 | } |
@@ -375,14 +414,15 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space) | |||
375 | 414 | ||
376 | static int process_output(unsigned char c, struct tty_struct *tty) | 415 | static int process_output(unsigned char c, struct tty_struct *tty) |
377 | { | 416 | { |
417 | struct n_tty_data *ldata = tty->disc_data; | ||
378 | int space, retval; | 418 | int space, retval; |
379 | 419 | ||
380 | mutex_lock(&tty->output_lock); | 420 | mutex_lock(&ldata->output_lock); |
381 | 421 | ||
382 | space = tty_write_room(tty); | 422 | space = tty_write_room(tty); |
383 | retval = do_output_char(c, tty, space); | 423 | retval = do_output_char(c, tty, space); |
384 | 424 | ||
385 | mutex_unlock(&tty->output_lock); | 425 | mutex_unlock(&ldata->output_lock); |
386 | if (retval < 0) | 426 | if (retval < 0) |
387 | return -1; | 427 | return -1; |
388 | else | 428 | else |
@@ -411,15 +451,16 @@ static int process_output(unsigned char c, struct tty_struct *tty) | |||
411 | static ssize_t process_output_block(struct tty_struct *tty, | 451 | static ssize_t process_output_block(struct tty_struct *tty, |
412 | const unsigned char *buf, unsigned int nr) | 452 | const unsigned char *buf, unsigned int nr) |
413 | { | 453 | { |
454 | struct n_tty_data *ldata = tty->disc_data; | ||
414 | int space; | 455 | int space; |
415 | int i; | 456 | int i; |
416 | const unsigned char *cp; | 457 | const unsigned char *cp; |
417 | 458 | ||
418 | mutex_lock(&tty->output_lock); | 459 | mutex_lock(&ldata->output_lock); |
419 | 460 | ||
420 | space = tty_write_room(tty); | 461 | space = tty_write_room(tty); |
421 | if (!space) { | 462 | if (!space) { |
422 | mutex_unlock(&tty->output_lock); | 463 | mutex_unlock(&ldata->output_lock); |
423 | return 0; | 464 | return 0; |
424 | } | 465 | } |
425 | if (nr > space) | 466 | if (nr > space) |
@@ -431,30 +472,30 @@ static ssize_t process_output_block(struct tty_struct *tty, | |||
431 | switch (c) { | 472 | switch (c) { |
432 | case '\n': | 473 | case '\n': |
433 | if (O_ONLRET(tty)) | 474 | if (O_ONLRET(tty)) |
434 | tty->column = 0; | 475 | ldata->column = 0; |
435 | if (O_ONLCR(tty)) | 476 | if (O_ONLCR(tty)) |
436 | goto break_out; | 477 | goto break_out; |
437 | tty->canon_column = tty->column; | 478 | ldata->canon_column = ldata->column; |
438 | break; | 479 | break; |
439 | case '\r': | 480 | case '\r': |
440 | if (O_ONOCR(tty) && tty->column == 0) | 481 | if (O_ONOCR(tty) && ldata->column == 0) |
441 | goto break_out; | 482 | goto break_out; |
442 | if (O_OCRNL(tty)) | 483 | if (O_OCRNL(tty)) |
443 | goto break_out; | 484 | goto break_out; |
444 | tty->canon_column = tty->column = 0; | 485 | ldata->canon_column = ldata->column = 0; |
445 | break; | 486 | break; |
446 | case '\t': | 487 | case '\t': |
447 | goto break_out; | 488 | goto break_out; |
448 | case '\b': | 489 | case '\b': |
449 | if (tty->column > 0) | 490 | if (ldata->column > 0) |
450 | tty->column--; | 491 | ldata->column--; |
451 | break; | 492 | break; |
452 | default: | 493 | default: |
453 | if (!iscntrl(c)) { | 494 | if (!iscntrl(c)) { |
454 | if (O_OLCUC(tty)) | 495 | if (O_OLCUC(tty)) |
455 | goto break_out; | 496 | goto break_out; |
456 | if (!is_continuation(c, tty)) | 497 | if (!is_continuation(c, tty)) |
457 | tty->column++; | 498 | ldata->column++; |
458 | } | 499 | } |
459 | break; | 500 | break; |
460 | } | 501 | } |
@@ -462,7 +503,7 @@ static ssize_t process_output_block(struct tty_struct *tty, | |||
462 | break_out: | 503 | break_out: |
463 | i = tty->ops->write(tty, buf, i); | 504 | i = tty->ops->write(tty, buf, i); |
464 | 505 | ||
465 | mutex_unlock(&tty->output_lock); | 506 | mutex_unlock(&ldata->output_lock); |
466 | return i; | 507 | return i; |
467 | } | 508 | } |
468 | 509 | ||
@@ -494,21 +535,22 @@ break_out: | |||
494 | 535 | ||
495 | static void process_echoes(struct tty_struct *tty) | 536 | static void process_echoes(struct tty_struct *tty) |
496 | { | 537 | { |
538 | struct n_tty_data *ldata = tty->disc_data; | ||
497 | int space, nr; | 539 | int space, nr; |
498 | unsigned char c; | 540 | unsigned char c; |
499 | unsigned char *cp, *buf_end; | 541 | unsigned char *cp, *buf_end; |
500 | 542 | ||
501 | if (!tty->echo_cnt) | 543 | if (!ldata->echo_cnt) |
502 | return; | 544 | return; |
503 | 545 | ||
504 | mutex_lock(&tty->output_lock); | 546 | mutex_lock(&ldata->output_lock); |
505 | mutex_lock(&tty->echo_lock); | 547 | mutex_lock(&ldata->echo_lock); |
506 | 548 | ||
507 | space = tty_write_room(tty); | 549 | space = tty_write_room(tty); |
508 | 550 | ||
509 | buf_end = tty->echo_buf + N_TTY_BUF_SIZE; | 551 | buf_end = ldata->echo_buf + N_TTY_BUF_SIZE; |
510 | cp = tty->echo_buf + tty->echo_pos; | 552 | cp = ldata->echo_buf + ldata->echo_pos; |
511 | nr = tty->echo_cnt; | 553 | nr = ldata->echo_cnt; |
512 | while (nr > 0) { | 554 | while (nr > 0) { |
513 | c = *cp; | 555 | c = *cp; |
514 | if (c == ECHO_OP_START) { | 556 | if (c == ECHO_OP_START) { |
@@ -545,7 +587,7 @@ static void process_echoes(struct tty_struct *tty) | |||
545 | * Otherwise, tab spacing is normal. | 587 | * Otherwise, tab spacing is normal. |
546 | */ | 588 | */ |
547 | if (!(num_chars & 0x80)) | 589 | if (!(num_chars & 0x80)) |
548 | num_chars += tty->canon_column; | 590 | num_chars += ldata->canon_column; |
549 | num_bs = 8 - (num_chars & 7); | 591 | num_bs = 8 - (num_chars & 7); |
550 | 592 | ||
551 | if (num_bs > space) { | 593 | if (num_bs > space) { |
@@ -555,22 +597,22 @@ static void process_echoes(struct tty_struct *tty) | |||
555 | space -= num_bs; | 597 | space -= num_bs; |
556 | while (num_bs--) { | 598 | while (num_bs--) { |
557 | tty_put_char(tty, '\b'); | 599 | tty_put_char(tty, '\b'); |
558 | if (tty->column > 0) | 600 | if (ldata->column > 0) |
559 | tty->column--; | 601 | ldata->column--; |
560 | } | 602 | } |
561 | cp += 3; | 603 | cp += 3; |
562 | nr -= 3; | 604 | nr -= 3; |
563 | break; | 605 | break; |
564 | 606 | ||
565 | case ECHO_OP_SET_CANON_COL: | 607 | case ECHO_OP_SET_CANON_COL: |
566 | tty->canon_column = tty->column; | 608 | ldata->canon_column = ldata->column; |
567 | cp += 2; | 609 | cp += 2; |
568 | nr -= 2; | 610 | nr -= 2; |
569 | break; | 611 | break; |
570 | 612 | ||
571 | case ECHO_OP_MOVE_BACK_COL: | 613 | case ECHO_OP_MOVE_BACK_COL: |
572 | if (tty->column > 0) | 614 | if (ldata->column > 0) |
573 | tty->column--; | 615 | ldata->column--; |
574 | cp += 2; | 616 | cp += 2; |
575 | nr -= 2; | 617 | nr -= 2; |
576 | break; | 618 | break; |
@@ -582,7 +624,7 @@ static void process_echoes(struct tty_struct *tty) | |||
582 | break; | 624 | break; |
583 | } | 625 | } |
584 | tty_put_char(tty, ECHO_OP_START); | 626 | tty_put_char(tty, ECHO_OP_START); |
585 | tty->column++; | 627 | ldata->column++; |
586 | space--; | 628 | space--; |
587 | cp += 2; | 629 | cp += 2; |
588 | nr -= 2; | 630 | nr -= 2; |
@@ -604,7 +646,7 @@ static void process_echoes(struct tty_struct *tty) | |||
604 | } | 646 | } |
605 | tty_put_char(tty, '^'); | 647 | tty_put_char(tty, '^'); |
606 | tty_put_char(tty, op ^ 0100); | 648 | tty_put_char(tty, op ^ 0100); |
607 | tty->column += 2; | 649 | ldata->column += 2; |
608 | space -= 2; | 650 | space -= 2; |
609 | cp += 2; | 651 | cp += 2; |
610 | nr -= 2; | 652 | nr -= 2; |
@@ -635,20 +677,20 @@ static void process_echoes(struct tty_struct *tty) | |||
635 | } | 677 | } |
636 | 678 | ||
637 | if (nr == 0) { | 679 | if (nr == 0) { |
638 | tty->echo_pos = 0; | 680 | ldata->echo_pos = 0; |
639 | tty->echo_cnt = 0; | 681 | ldata->echo_cnt = 0; |
640 | tty->echo_overrun = 0; | 682 | ldata->echo_overrun = 0; |
641 | } else { | 683 | } else { |
642 | int num_processed = tty->echo_cnt - nr; | 684 | int num_processed = ldata->echo_cnt - nr; |
643 | tty->echo_pos += num_processed; | 685 | ldata->echo_pos += num_processed; |
644 | tty->echo_pos &= N_TTY_BUF_SIZE - 1; | 686 | ldata->echo_pos &= N_TTY_BUF_SIZE - 1; |
645 | tty->echo_cnt = nr; | 687 | ldata->echo_cnt = nr; |
646 | if (num_processed > 0) | 688 | if (num_processed > 0) |
647 | tty->echo_overrun = 0; | 689 | ldata->echo_overrun = 0; |
648 | } | 690 | } |
649 | 691 | ||
650 | mutex_unlock(&tty->echo_lock); | 692 | mutex_unlock(&ldata->echo_lock); |
651 | mutex_unlock(&tty->output_lock); | 693 | mutex_unlock(&ldata->output_lock); |
652 | 694 | ||
653 | if (tty->ops->flush_chars) | 695 | if (tty->ops->flush_chars) |
654 | tty->ops->flush_chars(tty); | 696 | tty->ops->flush_chars(tty); |
@@ -657,72 +699,70 @@ static void process_echoes(struct tty_struct *tty) | |||
657 | /** | 699 | /** |
658 | * add_echo_byte - add a byte to the echo buffer | 700 | * add_echo_byte - add a byte to the echo buffer |
659 | * @c: unicode byte to echo | 701 | * @c: unicode byte to echo |
660 | * @tty: terminal device | 702 | * @ldata: n_tty data |
661 | * | 703 | * |
662 | * Add a character or operation byte to the echo buffer. | 704 | * Add a character or operation byte to the echo buffer. |
663 | * | 705 | * |
664 | * Should be called under the echo lock to protect the echo buffer. | 706 | * Should be called under the echo lock to protect the echo buffer. |
665 | */ | 707 | */ |
666 | 708 | ||
667 | static void add_echo_byte(unsigned char c, struct tty_struct *tty) | 709 | static void add_echo_byte(unsigned char c, struct n_tty_data *ldata) |
668 | { | 710 | { |
669 | int new_byte_pos; | 711 | int new_byte_pos; |
670 | 712 | ||
671 | if (tty->echo_cnt == N_TTY_BUF_SIZE) { | 713 | if (ldata->echo_cnt == N_TTY_BUF_SIZE) { |
672 | /* Circular buffer is already at capacity */ | 714 | /* Circular buffer is already at capacity */ |
673 | new_byte_pos = tty->echo_pos; | 715 | new_byte_pos = ldata->echo_pos; |
674 | 716 | ||
675 | /* | 717 | /* |
676 | * Since the buffer start position needs to be advanced, | 718 | * Since the buffer start position needs to be advanced, |
677 | * be sure to step by a whole operation byte group. | 719 | * be sure to step by a whole operation byte group. |
678 | */ | 720 | */ |
679 | if (tty->echo_buf[tty->echo_pos] == ECHO_OP_START) { | 721 | if (ldata->echo_buf[ldata->echo_pos] == ECHO_OP_START) { |
680 | if (tty->echo_buf[(tty->echo_pos + 1) & | 722 | if (ldata->echo_buf[(ldata->echo_pos + 1) & |
681 | (N_TTY_BUF_SIZE - 1)] == | 723 | (N_TTY_BUF_SIZE - 1)] == |
682 | ECHO_OP_ERASE_TAB) { | 724 | ECHO_OP_ERASE_TAB) { |
683 | tty->echo_pos += 3; | 725 | ldata->echo_pos += 3; |
684 | tty->echo_cnt -= 2; | 726 | ldata->echo_cnt -= 2; |
685 | } else { | 727 | } else { |
686 | tty->echo_pos += 2; | 728 | ldata->echo_pos += 2; |
687 | tty->echo_cnt -= 1; | 729 | ldata->echo_cnt -= 1; |
688 | } | 730 | } |
689 | } else { | 731 | } else { |
690 | tty->echo_pos++; | 732 | ldata->echo_pos++; |
691 | } | 733 | } |
692 | tty->echo_pos &= N_TTY_BUF_SIZE - 1; | 734 | ldata->echo_pos &= N_TTY_BUF_SIZE - 1; |
693 | 735 | ||
694 | tty->echo_overrun = 1; | 736 | ldata->echo_overrun = 1; |
695 | } else { | 737 | } else { |
696 | new_byte_pos = tty->echo_pos + tty->echo_cnt; | 738 | new_byte_pos = ldata->echo_pos + ldata->echo_cnt; |
697 | new_byte_pos &= N_TTY_BUF_SIZE - 1; | 739 | new_byte_pos &= N_TTY_BUF_SIZE - 1; |
698 | tty->echo_cnt++; | 740 | ldata->echo_cnt++; |
699 | } | 741 | } |
700 | 742 | ||
701 | tty->echo_buf[new_byte_pos] = c; | 743 | ldata->echo_buf[new_byte_pos] = c; |
702 | } | 744 | } |
703 | 745 | ||
704 | /** | 746 | /** |
705 | * echo_move_back_col - add operation to move back a column | 747 | * echo_move_back_col - add operation to move back a column |
706 | * @tty: terminal device | 748 | * @ldata: n_tty data |
707 | * | 749 | * |
708 | * Add an operation to the echo buffer to move back one column. | 750 | * Add an operation to the echo buffer to move back one column. |
709 | * | 751 | * |
710 | * Locking: echo_lock to protect the echo buffer | 752 | * Locking: echo_lock to protect the echo buffer |
711 | */ | 753 | */ |
712 | 754 | ||
713 | static void echo_move_back_col(struct tty_struct *tty) | 755 | static void echo_move_back_col(struct n_tty_data *ldata) |
714 | { | 756 | { |
715 | mutex_lock(&tty->echo_lock); | 757 | mutex_lock(&ldata->echo_lock); |
716 | 758 | add_echo_byte(ECHO_OP_START, ldata); | |
717 | add_echo_byte(ECHO_OP_START, tty); | 759 | add_echo_byte(ECHO_OP_MOVE_BACK_COL, ldata); |
718 | add_echo_byte(ECHO_OP_MOVE_BACK_COL, tty); | 760 | mutex_unlock(&ldata->echo_lock); |
719 | |||
720 | mutex_unlock(&tty->echo_lock); | ||
721 | } | 761 | } |
722 | 762 | ||
723 | /** | 763 | /** |
724 | * echo_set_canon_col - add operation to set the canon column | 764 | * echo_set_canon_col - add operation to set the canon column |
725 | * @tty: terminal device | 765 | * @ldata: n_tty data |
726 | * | 766 | * |
727 | * Add an operation to the echo buffer to set the canon column | 767 | * Add an operation to the echo buffer to set the canon column |
728 | * to the current column. | 768 | * to the current column. |
@@ -730,21 +770,19 @@ static void echo_move_back_col(struct tty_struct *tty) | |||
730 | * Locking: echo_lock to protect the echo buffer | 770 | * Locking: echo_lock to protect the echo buffer |
731 | */ | 771 | */ |
732 | 772 | ||
733 | static void echo_set_canon_col(struct tty_struct *tty) | 773 | static void echo_set_canon_col(struct n_tty_data *ldata) |
734 | { | 774 | { |
735 | mutex_lock(&tty->echo_lock); | 775 | mutex_lock(&ldata->echo_lock); |
736 | 776 | add_echo_byte(ECHO_OP_START, ldata); | |
737 | add_echo_byte(ECHO_OP_START, tty); | 777 | add_echo_byte(ECHO_OP_SET_CANON_COL, ldata); |
738 | add_echo_byte(ECHO_OP_SET_CANON_COL, tty); | 778 | mutex_unlock(&ldata->echo_lock); |
739 | |||
740 | mutex_unlock(&tty->echo_lock); | ||
741 | } | 779 | } |
742 | 780 | ||
743 | /** | 781 | /** |
744 | * echo_erase_tab - add operation to erase a tab | 782 | * echo_erase_tab - add operation to erase a tab |
745 | * @num_chars: number of character columns already used | 783 | * @num_chars: number of character columns already used |
746 | * @after_tab: true if num_chars starts after a previous tab | 784 | * @after_tab: true if num_chars starts after a previous tab |
747 | * @tty: terminal device | 785 | * @ldata: n_tty data |
748 | * | 786 | * |
749 | * Add an operation to the echo buffer to erase a tab. | 787 | * Add an operation to the echo buffer to erase a tab. |
750 | * | 788 | * |
@@ -758,12 +796,12 @@ static void echo_set_canon_col(struct tty_struct *tty) | |||
758 | */ | 796 | */ |
759 | 797 | ||
760 | static void echo_erase_tab(unsigned int num_chars, int after_tab, | 798 | static void echo_erase_tab(unsigned int num_chars, int after_tab, |
761 | struct tty_struct *tty) | 799 | struct n_tty_data *ldata) |
762 | { | 800 | { |
763 | mutex_lock(&tty->echo_lock); | 801 | mutex_lock(&ldata->echo_lock); |
764 | 802 | ||
765 | add_echo_byte(ECHO_OP_START, tty); | 803 | add_echo_byte(ECHO_OP_START, ldata); |
766 | add_echo_byte(ECHO_OP_ERASE_TAB, tty); | 804 | add_echo_byte(ECHO_OP_ERASE_TAB, ldata); |
767 | 805 | ||
768 | /* We only need to know this modulo 8 (tab spacing) */ | 806 | /* We only need to know this modulo 8 (tab spacing) */ |
769 | num_chars &= 7; | 807 | num_chars &= 7; |
@@ -772,9 +810,9 @@ static void echo_erase_tab(unsigned int num_chars, int after_tab, | |||
772 | if (after_tab) | 810 | if (after_tab) |
773 | num_chars |= 0x80; | 811 | num_chars |= 0x80; |
774 | 812 | ||
775 | add_echo_byte(num_chars, tty); | 813 | add_echo_byte(num_chars, ldata); |
776 | 814 | ||
777 | mutex_unlock(&tty->echo_lock); | 815 | mutex_unlock(&ldata->echo_lock); |
778 | } | 816 | } |
779 | 817 | ||
780 | /** | 818 | /** |
@@ -790,18 +828,16 @@ static void echo_erase_tab(unsigned int num_chars, int after_tab, | |||
790 | * Locking: echo_lock to protect the echo buffer | 828 | * Locking: echo_lock to protect the echo buffer |
791 | */ | 829 | */ |
792 | 830 | ||
793 | static void echo_char_raw(unsigned char c, struct tty_struct *tty) | 831 | static void echo_char_raw(unsigned char c, struct n_tty_data *ldata) |
794 | { | 832 | { |
795 | mutex_lock(&tty->echo_lock); | 833 | mutex_lock(&ldata->echo_lock); |
796 | |||
797 | if (c == ECHO_OP_START) { | 834 | if (c == ECHO_OP_START) { |
798 | add_echo_byte(ECHO_OP_START, tty); | 835 | add_echo_byte(ECHO_OP_START, ldata); |
799 | add_echo_byte(ECHO_OP_START, tty); | 836 | add_echo_byte(ECHO_OP_START, ldata); |
800 | } else { | 837 | } else { |
801 | add_echo_byte(c, tty); | 838 | add_echo_byte(c, ldata); |
802 | } | 839 | } |
803 | 840 | mutex_unlock(&ldata->echo_lock); | |
804 | mutex_unlock(&tty->echo_lock); | ||
805 | } | 841 | } |
806 | 842 | ||
807 | /** | 843 | /** |
@@ -820,30 +856,32 @@ static void echo_char_raw(unsigned char c, struct tty_struct *tty) | |||
820 | 856 | ||
821 | static void echo_char(unsigned char c, struct tty_struct *tty) | 857 | static void echo_char(unsigned char c, struct tty_struct *tty) |
822 | { | 858 | { |
823 | mutex_lock(&tty->echo_lock); | 859 | struct n_tty_data *ldata = tty->disc_data; |
860 | |||
861 | mutex_lock(&ldata->echo_lock); | ||
824 | 862 | ||
825 | if (c == ECHO_OP_START) { | 863 | if (c == ECHO_OP_START) { |
826 | add_echo_byte(ECHO_OP_START, tty); | 864 | add_echo_byte(ECHO_OP_START, ldata); |
827 | add_echo_byte(ECHO_OP_START, tty); | 865 | add_echo_byte(ECHO_OP_START, ldata); |
828 | } else { | 866 | } else { |
829 | if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') | 867 | if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') |
830 | add_echo_byte(ECHO_OP_START, tty); | 868 | add_echo_byte(ECHO_OP_START, ldata); |
831 | add_echo_byte(c, tty); | 869 | add_echo_byte(c, ldata); |
832 | } | 870 | } |
833 | 871 | ||
834 | mutex_unlock(&tty->echo_lock); | 872 | mutex_unlock(&ldata->echo_lock); |
835 | } | 873 | } |
836 | 874 | ||
837 | /** | 875 | /** |
838 | * finish_erasing - complete erase | 876 | * finish_erasing - complete erase |
839 | * @tty: tty doing the erase | 877 | * @ldata: n_tty data |
840 | */ | 878 | */ |
841 | 879 | ||
842 | static inline void finish_erasing(struct tty_struct *tty) | 880 | static inline void finish_erasing(struct n_tty_data *ldata) |
843 | { | 881 | { |
844 | if (tty->erasing) { | 882 | if (ldata->erasing) { |
845 | echo_char_raw('/', tty); | 883 | echo_char_raw('/', ldata); |
846 | tty->erasing = 0; | 884 | ldata->erasing = 0; |
847 | } | 885 | } |
848 | } | 886 | } |
849 | 887 | ||
@@ -861,12 +899,13 @@ static inline void finish_erasing(struct tty_struct *tty) | |||
861 | 899 | ||
862 | static void eraser(unsigned char c, struct tty_struct *tty) | 900 | static void eraser(unsigned char c, struct tty_struct *tty) |
863 | { | 901 | { |
902 | struct n_tty_data *ldata = tty->disc_data; | ||
864 | enum { ERASE, WERASE, KILL } kill_type; | 903 | enum { ERASE, WERASE, KILL } kill_type; |
865 | int head, seen_alnums, cnt; | 904 | int head, seen_alnums, cnt; |
866 | unsigned long flags; | 905 | unsigned long flags; |
867 | 906 | ||
868 | /* FIXME: locking needed ? */ | 907 | /* FIXME: locking needed ? */ |
869 | if (tty->read_head == tty->canon_head) { | 908 | if (ldata->read_head == ldata->canon_head) { |
870 | /* process_output('\a', tty); */ /* what do you think? */ | 909 | /* process_output('\a', tty); */ /* what do you think? */ |
871 | return; | 910 | return; |
872 | } | 911 | } |
@@ -876,24 +915,24 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
876 | kill_type = WERASE; | 915 | kill_type = WERASE; |
877 | else { | 916 | else { |
878 | if (!L_ECHO(tty)) { | 917 | if (!L_ECHO(tty)) { |
879 | spin_lock_irqsave(&tty->read_lock, flags); | 918 | spin_lock_irqsave(&ldata->read_lock, flags); |
880 | tty->read_cnt -= ((tty->read_head - tty->canon_head) & | 919 | ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) & |
881 | (N_TTY_BUF_SIZE - 1)); | 920 | (N_TTY_BUF_SIZE - 1)); |
882 | tty->read_head = tty->canon_head; | 921 | ldata->read_head = ldata->canon_head; |
883 | spin_unlock_irqrestore(&tty->read_lock, flags); | 922 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
884 | return; | 923 | return; |
885 | } | 924 | } |
886 | if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) { | 925 | if (!L_ECHOK(tty) || !L_ECHOKE(tty) || !L_ECHOE(tty)) { |
887 | spin_lock_irqsave(&tty->read_lock, flags); | 926 | spin_lock_irqsave(&ldata->read_lock, flags); |
888 | tty->read_cnt -= ((tty->read_head - tty->canon_head) & | 927 | ldata->read_cnt -= ((ldata->read_head - ldata->canon_head) & |
889 | (N_TTY_BUF_SIZE - 1)); | 928 | (N_TTY_BUF_SIZE - 1)); |
890 | tty->read_head = tty->canon_head; | 929 | ldata->read_head = ldata->canon_head; |
891 | spin_unlock_irqrestore(&tty->read_lock, flags); | 930 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
892 | finish_erasing(tty); | 931 | finish_erasing(ldata); |
893 | echo_char(KILL_CHAR(tty), tty); | 932 | echo_char(KILL_CHAR(tty), tty); |
894 | /* Add a newline if ECHOK is on and ECHOKE is off. */ | 933 | /* Add a newline if ECHOK is on and ECHOKE is off. */ |
895 | if (L_ECHOK(tty)) | 934 | if (L_ECHOK(tty)) |
896 | echo_char_raw('\n', tty); | 935 | echo_char_raw('\n', ldata); |
897 | return; | 936 | return; |
898 | } | 937 | } |
899 | kill_type = KILL; | 938 | kill_type = KILL; |
@@ -901,14 +940,14 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
901 | 940 | ||
902 | seen_alnums = 0; | 941 | seen_alnums = 0; |
903 | /* FIXME: Locking ?? */ | 942 | /* FIXME: Locking ?? */ |
904 | while (tty->read_head != tty->canon_head) { | 943 | while (ldata->read_head != ldata->canon_head) { |
905 | head = tty->read_head; | 944 | head = ldata->read_head; |
906 | 945 | ||
907 | /* erase a single possibly multibyte character */ | 946 | /* erase a single possibly multibyte character */ |
908 | do { | 947 | do { |
909 | head = (head - 1) & (N_TTY_BUF_SIZE-1); | 948 | head = (head - 1) & (N_TTY_BUF_SIZE-1); |
910 | c = tty->read_buf[head]; | 949 | c = ldata->read_buf[head]; |
911 | } while (is_continuation(c, tty) && head != tty->canon_head); | 950 | } while (is_continuation(c, tty) && head != ldata->canon_head); |
912 | 951 | ||
913 | /* do not partially erase */ | 952 | /* do not partially erase */ |
914 | if (is_continuation(c, tty)) | 953 | if (is_continuation(c, tty)) |
@@ -921,30 +960,31 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
921 | else if (seen_alnums) | 960 | else if (seen_alnums) |
922 | break; | 961 | break; |
923 | } | 962 | } |
924 | cnt = (tty->read_head - head) & (N_TTY_BUF_SIZE-1); | 963 | cnt = (ldata->read_head - head) & (N_TTY_BUF_SIZE-1); |
925 | spin_lock_irqsave(&tty->read_lock, flags); | 964 | spin_lock_irqsave(&ldata->read_lock, flags); |
926 | tty->read_head = head; | 965 | ldata->read_head = head; |
927 | tty->read_cnt -= cnt; | 966 | ldata->read_cnt -= cnt; |
928 | spin_unlock_irqrestore(&tty->read_lock, flags); | 967 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
929 | if (L_ECHO(tty)) { | 968 | if (L_ECHO(tty)) { |
930 | if (L_ECHOPRT(tty)) { | 969 | if (L_ECHOPRT(tty)) { |
931 | if (!tty->erasing) { | 970 | if (!ldata->erasing) { |
932 | echo_char_raw('\\', tty); | 971 | echo_char_raw('\\', ldata); |
933 | tty->erasing = 1; | 972 | ldata->erasing = 1; |
934 | } | 973 | } |
935 | /* if cnt > 1, output a multi-byte character */ | 974 | /* if cnt > 1, output a multi-byte character */ |
936 | echo_char(c, tty); | 975 | echo_char(c, tty); |
937 | while (--cnt > 0) { | 976 | while (--cnt > 0) { |
938 | head = (head+1) & (N_TTY_BUF_SIZE-1); | 977 | head = (head+1) & (N_TTY_BUF_SIZE-1); |
939 | echo_char_raw(tty->read_buf[head], tty); | 978 | echo_char_raw(ldata->read_buf[head], |
940 | echo_move_back_col(tty); | 979 | ldata); |
980 | echo_move_back_col(ldata); | ||
941 | } | 981 | } |
942 | } else if (kill_type == ERASE && !L_ECHOE(tty)) { | 982 | } else if (kill_type == ERASE && !L_ECHOE(tty)) { |
943 | echo_char(ERASE_CHAR(tty), tty); | 983 | echo_char(ERASE_CHAR(tty), tty); |
944 | } else if (c == '\t') { | 984 | } else if (c == '\t') { |
945 | unsigned int num_chars = 0; | 985 | unsigned int num_chars = 0; |
946 | int after_tab = 0; | 986 | int after_tab = 0; |
947 | unsigned long tail = tty->read_head; | 987 | unsigned long tail = ldata->read_head; |
948 | 988 | ||
949 | /* | 989 | /* |
950 | * Count the columns used for characters | 990 | * Count the columns used for characters |
@@ -953,9 +993,9 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
953 | * This info is used to go back the correct | 993 | * This info is used to go back the correct |
954 | * number of columns. | 994 | * number of columns. |
955 | */ | 995 | */ |
956 | while (tail != tty->canon_head) { | 996 | while (tail != ldata->canon_head) { |
957 | tail = (tail-1) & (N_TTY_BUF_SIZE-1); | 997 | tail = (tail-1) & (N_TTY_BUF_SIZE-1); |
958 | c = tty->read_buf[tail]; | 998 | c = ldata->read_buf[tail]; |
959 | if (c == '\t') { | 999 | if (c == '\t') { |
960 | after_tab = 1; | 1000 | after_tab = 1; |
961 | break; | 1001 | break; |
@@ -966,25 +1006,25 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
966 | num_chars++; | 1006 | num_chars++; |
967 | } | 1007 | } |
968 | } | 1008 | } |
969 | echo_erase_tab(num_chars, after_tab, tty); | 1009 | echo_erase_tab(num_chars, after_tab, ldata); |
970 | } else { | 1010 | } else { |
971 | if (iscntrl(c) && L_ECHOCTL(tty)) { | 1011 | if (iscntrl(c) && L_ECHOCTL(tty)) { |
972 | echo_char_raw('\b', tty); | 1012 | echo_char_raw('\b', ldata); |
973 | echo_char_raw(' ', tty); | 1013 | echo_char_raw(' ', ldata); |
974 | echo_char_raw('\b', tty); | 1014 | echo_char_raw('\b', ldata); |
975 | } | 1015 | } |
976 | if (!iscntrl(c) || L_ECHOCTL(tty)) { | 1016 | if (!iscntrl(c) || L_ECHOCTL(tty)) { |
977 | echo_char_raw('\b', tty); | 1017 | echo_char_raw('\b', ldata); |
978 | echo_char_raw(' ', tty); | 1018 | echo_char_raw(' ', ldata); |
979 | echo_char_raw('\b', tty); | 1019 | echo_char_raw('\b', ldata); |
980 | } | 1020 | } |
981 | } | 1021 | } |
982 | } | 1022 | } |
983 | if (kill_type == ERASE) | 1023 | if (kill_type == ERASE) |
984 | break; | 1024 | break; |
985 | } | 1025 | } |
986 | if (tty->read_head == tty->canon_head && L_ECHO(tty)) | 1026 | if (ldata->read_head == ldata->canon_head && L_ECHO(tty)) |
987 | finish_erasing(tty); | 1027 | finish_erasing(ldata); |
988 | } | 1028 | } |
989 | 1029 | ||
990 | /** | 1030 | /** |
@@ -1023,6 +1063,8 @@ static inline void isig(int sig, struct tty_struct *tty, int flush) | |||
1023 | 1063 | ||
1024 | static inline void n_tty_receive_break(struct tty_struct *tty) | 1064 | static inline void n_tty_receive_break(struct tty_struct *tty) |
1025 | { | 1065 | { |
1066 | struct n_tty_data *ldata = tty->disc_data; | ||
1067 | |||
1026 | if (I_IGNBRK(tty)) | 1068 | if (I_IGNBRK(tty)) |
1027 | return; | 1069 | return; |
1028 | if (I_BRKINT(tty)) { | 1070 | if (I_BRKINT(tty)) { |
@@ -1030,10 +1072,10 @@ static inline void n_tty_receive_break(struct tty_struct *tty) | |||
1030 | return; | 1072 | return; |
1031 | } | 1073 | } |
1032 | if (I_PARMRK(tty)) { | 1074 | if (I_PARMRK(tty)) { |
1033 | put_tty_queue('\377', tty); | 1075 | put_tty_queue('\377', ldata); |
1034 | put_tty_queue('\0', tty); | 1076 | put_tty_queue('\0', ldata); |
1035 | } | 1077 | } |
1036 | put_tty_queue('\0', tty); | 1078 | put_tty_queue('\0', ldata); |
1037 | wake_up_interruptible(&tty->read_wait); | 1079 | wake_up_interruptible(&tty->read_wait); |
1038 | } | 1080 | } |
1039 | 1081 | ||
@@ -1052,16 +1094,17 @@ static inline void n_tty_receive_break(struct tty_struct *tty) | |||
1052 | 1094 | ||
1053 | static inline void n_tty_receive_overrun(struct tty_struct *tty) | 1095 | static inline void n_tty_receive_overrun(struct tty_struct *tty) |
1054 | { | 1096 | { |
1097 | struct n_tty_data *ldata = tty->disc_data; | ||
1055 | char buf[64]; | 1098 | char buf[64]; |
1056 | 1099 | ||
1057 | tty->num_overrun++; | 1100 | ldata->num_overrun++; |
1058 | if (time_before(tty->overrun_time, jiffies - HZ) || | 1101 | if (time_after(jiffies, ldata->overrun_time + HZ) || |
1059 | time_after(tty->overrun_time, jiffies)) { | 1102 | time_after(ldata->overrun_time, jiffies)) { |
1060 | printk(KERN_WARNING "%s: %d input overrun(s)\n", | 1103 | printk(KERN_WARNING "%s: %d input overrun(s)\n", |
1061 | tty_name(tty, buf), | 1104 | tty_name(tty, buf), |
1062 | tty->num_overrun); | 1105 | ldata->num_overrun); |
1063 | tty->overrun_time = jiffies; | 1106 | ldata->overrun_time = jiffies; |
1064 | tty->num_overrun = 0; | 1107 | ldata->num_overrun = 0; |
1065 | } | 1108 | } |
1066 | } | 1109 | } |
1067 | 1110 | ||
@@ -1076,16 +1119,18 @@ static inline void n_tty_receive_overrun(struct tty_struct *tty) | |||
1076 | static inline void n_tty_receive_parity_error(struct tty_struct *tty, | 1119 | static inline void n_tty_receive_parity_error(struct tty_struct *tty, |
1077 | unsigned char c) | 1120 | unsigned char c) |
1078 | { | 1121 | { |
1122 | struct n_tty_data *ldata = tty->disc_data; | ||
1123 | |||
1079 | if (I_IGNPAR(tty)) | 1124 | if (I_IGNPAR(tty)) |
1080 | return; | 1125 | return; |
1081 | if (I_PARMRK(tty)) { | 1126 | if (I_PARMRK(tty)) { |
1082 | put_tty_queue('\377', tty); | 1127 | put_tty_queue('\377', ldata); |
1083 | put_tty_queue('\0', tty); | 1128 | put_tty_queue('\0', ldata); |
1084 | put_tty_queue(c, tty); | 1129 | put_tty_queue(c, ldata); |
1085 | } else if (I_INPCK(tty)) | 1130 | } else if (I_INPCK(tty)) |
1086 | put_tty_queue('\0', tty); | 1131 | put_tty_queue('\0', ldata); |
1087 | else | 1132 | else |
1088 | put_tty_queue(c, tty); | 1133 | put_tty_queue(c, ldata); |
1089 | wake_up_interruptible(&tty->read_wait); | 1134 | wake_up_interruptible(&tty->read_wait); |
1090 | } | 1135 | } |
1091 | 1136 | ||
@@ -1101,11 +1146,12 @@ static inline void n_tty_receive_parity_error(struct tty_struct *tty, | |||
1101 | 1146 | ||
1102 | static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | 1147 | static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) |
1103 | { | 1148 | { |
1149 | struct n_tty_data *ldata = tty->disc_data; | ||
1104 | unsigned long flags; | 1150 | unsigned long flags; |
1105 | int parmrk; | 1151 | int parmrk; |
1106 | 1152 | ||
1107 | if (tty->raw) { | 1153 | if (ldata->raw) { |
1108 | put_tty_queue(c, tty); | 1154 | put_tty_queue(c, ldata); |
1109 | return; | 1155 | return; |
1110 | } | 1156 | } |
1111 | 1157 | ||
@@ -1115,7 +1161,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
1115 | c = tolower(c); | 1161 | c = tolower(c); |
1116 | 1162 | ||
1117 | if (L_EXTPROC(tty)) { | 1163 | if (L_EXTPROC(tty)) { |
1118 | put_tty_queue(c, tty); | 1164 | put_tty_queue(c, ldata); |
1119 | return; | 1165 | return; |
1120 | } | 1166 | } |
1121 | 1167 | ||
@@ -1143,26 +1189,26 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
1143 | * handle specially, do shortcut processing to speed things | 1189 | * handle specially, do shortcut processing to speed things |
1144 | * up. | 1190 | * up. |
1145 | */ | 1191 | */ |
1146 | if (!test_bit(c, tty->process_char_map) || tty->lnext) { | 1192 | if (!test_bit(c, ldata->process_char_map) || ldata->lnext) { |
1147 | tty->lnext = 0; | 1193 | ldata->lnext = 0; |
1148 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; | 1194 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; |
1149 | if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { | 1195 | if (ldata->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { |
1150 | /* beep if no space */ | 1196 | /* beep if no space */ |
1151 | if (L_ECHO(tty)) | 1197 | if (L_ECHO(tty)) |
1152 | process_output('\a', tty); | 1198 | process_output('\a', tty); |
1153 | return; | 1199 | return; |
1154 | } | 1200 | } |
1155 | if (L_ECHO(tty)) { | 1201 | if (L_ECHO(tty)) { |
1156 | finish_erasing(tty); | 1202 | finish_erasing(ldata); |
1157 | /* Record the column of first canon char. */ | 1203 | /* Record the column of first canon char. */ |
1158 | if (tty->canon_head == tty->read_head) | 1204 | if (ldata->canon_head == ldata->read_head) |
1159 | echo_set_canon_col(tty); | 1205 | echo_set_canon_col(ldata); |
1160 | echo_char(c, tty); | 1206 | echo_char(c, tty); |
1161 | process_echoes(tty); | 1207 | process_echoes(tty); |
1162 | } | 1208 | } |
1163 | if (parmrk) | 1209 | if (parmrk) |
1164 | put_tty_queue(c, tty); | 1210 | put_tty_queue(c, ldata); |
1165 | put_tty_queue(c, tty); | 1211 | put_tty_queue(c, ldata); |
1166 | return; | 1212 | return; |
1167 | } | 1213 | } |
1168 | 1214 | ||
@@ -1218,7 +1264,7 @@ send_signal: | |||
1218 | } else if (c == '\n' && I_INLCR(tty)) | 1264 | } else if (c == '\n' && I_INLCR(tty)) |
1219 | c = '\r'; | 1265 | c = '\r'; |
1220 | 1266 | ||
1221 | if (tty->icanon) { | 1267 | if (ldata->icanon) { |
1222 | if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || | 1268 | if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || |
1223 | (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { | 1269 | (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { |
1224 | eraser(c, tty); | 1270 | eraser(c, tty); |
@@ -1226,12 +1272,12 @@ send_signal: | |||
1226 | return; | 1272 | return; |
1227 | } | 1273 | } |
1228 | if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { | 1274 | if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { |
1229 | tty->lnext = 1; | 1275 | ldata->lnext = 1; |
1230 | if (L_ECHO(tty)) { | 1276 | if (L_ECHO(tty)) { |
1231 | finish_erasing(tty); | 1277 | finish_erasing(ldata); |
1232 | if (L_ECHOCTL(tty)) { | 1278 | if (L_ECHOCTL(tty)) { |
1233 | echo_char_raw('^', tty); | 1279 | echo_char_raw('^', ldata); |
1234 | echo_char_raw('\b', tty); | 1280 | echo_char_raw('\b', ldata); |
1235 | process_echoes(tty); | 1281 | process_echoes(tty); |
1236 | } | 1282 | } |
1237 | } | 1283 | } |
@@ -1239,34 +1285,34 @@ send_signal: | |||
1239 | } | 1285 | } |
1240 | if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && | 1286 | if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && |
1241 | L_IEXTEN(tty)) { | 1287 | L_IEXTEN(tty)) { |
1242 | unsigned long tail = tty->canon_head; | 1288 | unsigned long tail = ldata->canon_head; |
1243 | 1289 | ||
1244 | finish_erasing(tty); | 1290 | finish_erasing(ldata); |
1245 | echo_char(c, tty); | 1291 | echo_char(c, tty); |
1246 | echo_char_raw('\n', tty); | 1292 | echo_char_raw('\n', ldata); |
1247 | while (tail != tty->read_head) { | 1293 | while (tail != ldata->read_head) { |
1248 | echo_char(tty->read_buf[tail], tty); | 1294 | echo_char(ldata->read_buf[tail], tty); |
1249 | tail = (tail+1) & (N_TTY_BUF_SIZE-1); | 1295 | tail = (tail+1) & (N_TTY_BUF_SIZE-1); |
1250 | } | 1296 | } |
1251 | process_echoes(tty); | 1297 | process_echoes(tty); |
1252 | return; | 1298 | return; |
1253 | } | 1299 | } |
1254 | if (c == '\n') { | 1300 | if (c == '\n') { |
1255 | if (tty->read_cnt >= N_TTY_BUF_SIZE) { | 1301 | if (ldata->read_cnt >= N_TTY_BUF_SIZE) { |
1256 | if (L_ECHO(tty)) | 1302 | if (L_ECHO(tty)) |
1257 | process_output('\a', tty); | 1303 | process_output('\a', tty); |
1258 | return; | 1304 | return; |
1259 | } | 1305 | } |
1260 | if (L_ECHO(tty) || L_ECHONL(tty)) { | 1306 | if (L_ECHO(tty) || L_ECHONL(tty)) { |
1261 | echo_char_raw('\n', tty); | 1307 | echo_char_raw('\n', ldata); |
1262 | process_echoes(tty); | 1308 | process_echoes(tty); |
1263 | } | 1309 | } |
1264 | goto handle_newline; | 1310 | goto handle_newline; |
1265 | } | 1311 | } |
1266 | if (c == EOF_CHAR(tty)) { | 1312 | if (c == EOF_CHAR(tty)) { |
1267 | if (tty->read_cnt >= N_TTY_BUF_SIZE) | 1313 | if (ldata->read_cnt >= N_TTY_BUF_SIZE) |
1268 | return; | 1314 | return; |
1269 | if (tty->canon_head != tty->read_head) | 1315 | if (ldata->canon_head != ldata->read_head) |
1270 | set_bit(TTY_PUSH, &tty->flags); | 1316 | set_bit(TTY_PUSH, &tty->flags); |
1271 | c = __DISABLED_CHAR; | 1317 | c = __DISABLED_CHAR; |
1272 | goto handle_newline; | 1318 | goto handle_newline; |
@@ -1275,7 +1321,7 @@ send_signal: | |||
1275 | (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { | 1321 | (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { |
1276 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) | 1322 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) |
1277 | ? 1 : 0; | 1323 | ? 1 : 0; |
1278 | if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk)) { | 1324 | if (ldata->read_cnt >= (N_TTY_BUF_SIZE - parmrk)) { |
1279 | if (L_ECHO(tty)) | 1325 | if (L_ECHO(tty)) |
1280 | process_output('\a', tty); | 1326 | process_output('\a', tty); |
1281 | return; | 1327 | return; |
@@ -1285,8 +1331,8 @@ send_signal: | |||
1285 | */ | 1331 | */ |
1286 | if (L_ECHO(tty)) { | 1332 | if (L_ECHO(tty)) { |
1287 | /* Record the column of first canon char. */ | 1333 | /* Record the column of first canon char. */ |
1288 | if (tty->canon_head == tty->read_head) | 1334 | if (ldata->canon_head == ldata->read_head) |
1289 | echo_set_canon_col(tty); | 1335 | echo_set_canon_col(ldata); |
1290 | echo_char(c, tty); | 1336 | echo_char(c, tty); |
1291 | process_echoes(tty); | 1337 | process_echoes(tty); |
1292 | } | 1338 | } |
@@ -1295,15 +1341,15 @@ send_signal: | |||
1295 | * EOL_CHAR and EOL2_CHAR? | 1341 | * EOL_CHAR and EOL2_CHAR? |
1296 | */ | 1342 | */ |
1297 | if (parmrk) | 1343 | if (parmrk) |
1298 | put_tty_queue(c, tty); | 1344 | put_tty_queue(c, ldata); |
1299 | 1345 | ||
1300 | handle_newline: | 1346 | handle_newline: |
1301 | spin_lock_irqsave(&tty->read_lock, flags); | 1347 | spin_lock_irqsave(&ldata->read_lock, flags); |
1302 | set_bit(tty->read_head, tty->read_flags); | 1348 | set_bit(ldata->read_head, ldata->read_flags); |
1303 | put_tty_queue_nolock(c, tty); | 1349 | put_tty_queue_nolock(c, ldata); |
1304 | tty->canon_head = tty->read_head; | 1350 | ldata->canon_head = ldata->read_head; |
1305 | tty->canon_data++; | 1351 | ldata->canon_data++; |
1306 | spin_unlock_irqrestore(&tty->read_lock, flags); | 1352 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
1307 | kill_fasync(&tty->fasync, SIGIO, POLL_IN); | 1353 | kill_fasync(&tty->fasync, SIGIO, POLL_IN); |
1308 | if (waitqueue_active(&tty->read_wait)) | 1354 | if (waitqueue_active(&tty->read_wait)) |
1309 | wake_up_interruptible(&tty->read_wait); | 1355 | wake_up_interruptible(&tty->read_wait); |
@@ -1312,29 +1358,29 @@ handle_newline: | |||
1312 | } | 1358 | } |
1313 | 1359 | ||
1314 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; | 1360 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; |
1315 | if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { | 1361 | if (ldata->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { |
1316 | /* beep if no space */ | 1362 | /* beep if no space */ |
1317 | if (L_ECHO(tty)) | 1363 | if (L_ECHO(tty)) |
1318 | process_output('\a', tty); | 1364 | process_output('\a', tty); |
1319 | return; | 1365 | return; |
1320 | } | 1366 | } |
1321 | if (L_ECHO(tty)) { | 1367 | if (L_ECHO(tty)) { |
1322 | finish_erasing(tty); | 1368 | finish_erasing(ldata); |
1323 | if (c == '\n') | 1369 | if (c == '\n') |
1324 | echo_char_raw('\n', tty); | 1370 | echo_char_raw('\n', ldata); |
1325 | else { | 1371 | else { |
1326 | /* Record the column of first canon char. */ | 1372 | /* Record the column of first canon char. */ |
1327 | if (tty->canon_head == tty->read_head) | 1373 | if (ldata->canon_head == ldata->read_head) |
1328 | echo_set_canon_col(tty); | 1374 | echo_set_canon_col(ldata); |
1329 | echo_char(c, tty); | 1375 | echo_char(c, tty); |
1330 | } | 1376 | } |
1331 | process_echoes(tty); | 1377 | process_echoes(tty); |
1332 | } | 1378 | } |
1333 | 1379 | ||
1334 | if (parmrk) | 1380 | if (parmrk) |
1335 | put_tty_queue(c, tty); | 1381 | put_tty_queue(c, ldata); |
1336 | 1382 | ||
1337 | put_tty_queue(c, tty); | 1383 | put_tty_queue(c, ldata); |
1338 | } | 1384 | } |
1339 | 1385 | ||
1340 | 1386 | ||
@@ -1369,33 +1415,31 @@ static void n_tty_write_wakeup(struct tty_struct *tty) | |||
1369 | static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, | 1415 | static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, |
1370 | char *fp, int count) | 1416 | char *fp, int count) |
1371 | { | 1417 | { |
1418 | struct n_tty_data *ldata = tty->disc_data; | ||
1372 | const unsigned char *p; | 1419 | const unsigned char *p; |
1373 | char *f, flags = TTY_NORMAL; | 1420 | char *f, flags = TTY_NORMAL; |
1374 | int i; | 1421 | int i; |
1375 | char buf[64]; | 1422 | char buf[64]; |
1376 | unsigned long cpuflags; | 1423 | unsigned long cpuflags; |
1377 | 1424 | ||
1378 | if (!tty->read_buf) | 1425 | if (ldata->real_raw) { |
1379 | return; | 1426 | spin_lock_irqsave(&ldata->read_lock, cpuflags); |
1380 | 1427 | i = min(N_TTY_BUF_SIZE - ldata->read_cnt, | |
1381 | if (tty->real_raw) { | 1428 | N_TTY_BUF_SIZE - ldata->read_head); |
1382 | spin_lock_irqsave(&tty->read_lock, cpuflags); | ||
1383 | i = min(N_TTY_BUF_SIZE - tty->read_cnt, | ||
1384 | N_TTY_BUF_SIZE - tty->read_head); | ||
1385 | i = min(count, i); | 1429 | i = min(count, i); |
1386 | memcpy(tty->read_buf + tty->read_head, cp, i); | 1430 | memcpy(ldata->read_buf + ldata->read_head, cp, i); |
1387 | tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); | 1431 | ldata->read_head = (ldata->read_head + i) & (N_TTY_BUF_SIZE-1); |
1388 | tty->read_cnt += i; | 1432 | ldata->read_cnt += i; |
1389 | cp += i; | 1433 | cp += i; |
1390 | count -= i; | 1434 | count -= i; |
1391 | 1435 | ||
1392 | i = min(N_TTY_BUF_SIZE - tty->read_cnt, | 1436 | i = min(N_TTY_BUF_SIZE - ldata->read_cnt, |
1393 | N_TTY_BUF_SIZE - tty->read_head); | 1437 | N_TTY_BUF_SIZE - ldata->read_head); |
1394 | i = min(count, i); | 1438 | i = min(count, i); |
1395 | memcpy(tty->read_buf + tty->read_head, cp, i); | 1439 | memcpy(ldata->read_buf + ldata->read_head, cp, i); |
1396 | tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); | 1440 | ldata->read_head = (ldata->read_head + i) & (N_TTY_BUF_SIZE-1); |
1397 | tty->read_cnt += i; | 1441 | ldata->read_cnt += i; |
1398 | spin_unlock_irqrestore(&tty->read_lock, cpuflags); | 1442 | spin_unlock_irqrestore(&ldata->read_lock, cpuflags); |
1399 | } else { | 1443 | } else { |
1400 | for (i = count, p = cp, f = fp; i; i--, p++) { | 1444 | for (i = count, p = cp, f = fp; i; i--, p++) { |
1401 | if (f) | 1445 | if (f) |
@@ -1426,7 +1470,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
1426 | 1470 | ||
1427 | n_tty_set_room(tty); | 1471 | n_tty_set_room(tty); |
1428 | 1472 | ||
1429 | if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) || | 1473 | if ((!ldata->icanon && (ldata->read_cnt >= tty->minimum_to_wake)) || |
1430 | L_EXTPROC(tty)) { | 1474 | L_EXTPROC(tty)) { |
1431 | kill_fasync(&tty->fasync, SIGIO, POLL_IN); | 1475 | kill_fasync(&tty->fasync, SIGIO, POLL_IN); |
1432 | if (waitqueue_active(&tty->read_wait)) | 1476 | if (waitqueue_active(&tty->read_wait)) |
@@ -1470,25 +1514,25 @@ int is_ignored(int sig) | |||
1470 | 1514 | ||
1471 | static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) | 1515 | static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) |
1472 | { | 1516 | { |
1517 | struct n_tty_data *ldata = tty->disc_data; | ||
1473 | int canon_change = 1; | 1518 | int canon_change = 1; |
1474 | BUG_ON(!tty); | ||
1475 | 1519 | ||
1476 | if (old) | 1520 | if (old) |
1477 | canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON; | 1521 | canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON; |
1478 | if (canon_change) { | 1522 | if (canon_change) { |
1479 | memset(&tty->read_flags, 0, sizeof tty->read_flags); | 1523 | bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE); |
1480 | tty->canon_head = tty->read_tail; | 1524 | ldata->canon_head = ldata->read_tail; |
1481 | tty->canon_data = 0; | 1525 | ldata->canon_data = 0; |
1482 | tty->erasing = 0; | 1526 | ldata->erasing = 0; |
1483 | } | 1527 | } |
1484 | 1528 | ||
1485 | if (canon_change && !L_ICANON(tty) && tty->read_cnt) | 1529 | if (canon_change && !L_ICANON(tty) && ldata->read_cnt) |
1486 | wake_up_interruptible(&tty->read_wait); | 1530 | wake_up_interruptible(&tty->read_wait); |
1487 | 1531 | ||
1488 | tty->icanon = (L_ICANON(tty) != 0); | 1532 | ldata->icanon = (L_ICANON(tty) != 0); |
1489 | if (test_bit(TTY_HW_COOK_IN, &tty->flags)) { | 1533 | if (test_bit(TTY_HW_COOK_IN, &tty->flags)) { |
1490 | tty->raw = 1; | 1534 | ldata->raw = 1; |
1491 | tty->real_raw = 1; | 1535 | ldata->real_raw = 1; |
1492 | n_tty_set_room(tty); | 1536 | n_tty_set_room(tty); |
1493 | return; | 1537 | return; |
1494 | } | 1538 | } |
@@ -1496,51 +1540,51 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
1496 | I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) || | 1540 | I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) || |
1497 | I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) || | 1541 | I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) || |
1498 | I_PARMRK(tty)) { | 1542 | I_PARMRK(tty)) { |
1499 | memset(tty->process_char_map, 0, 256/8); | 1543 | bitmap_zero(ldata->process_char_map, 256); |
1500 | 1544 | ||
1501 | if (I_IGNCR(tty) || I_ICRNL(tty)) | 1545 | if (I_IGNCR(tty) || I_ICRNL(tty)) |
1502 | set_bit('\r', tty->process_char_map); | 1546 | set_bit('\r', ldata->process_char_map); |
1503 | if (I_INLCR(tty)) | 1547 | if (I_INLCR(tty)) |
1504 | set_bit('\n', tty->process_char_map); | 1548 | set_bit('\n', ldata->process_char_map); |
1505 | 1549 | ||
1506 | if (L_ICANON(tty)) { | 1550 | if (L_ICANON(tty)) { |
1507 | set_bit(ERASE_CHAR(tty), tty->process_char_map); | 1551 | set_bit(ERASE_CHAR(tty), ldata->process_char_map); |
1508 | set_bit(KILL_CHAR(tty), tty->process_char_map); | 1552 | set_bit(KILL_CHAR(tty), ldata->process_char_map); |
1509 | set_bit(EOF_CHAR(tty), tty->process_char_map); | 1553 | set_bit(EOF_CHAR(tty), ldata->process_char_map); |
1510 | set_bit('\n', tty->process_char_map); | 1554 | set_bit('\n', ldata->process_char_map); |
1511 | set_bit(EOL_CHAR(tty), tty->process_char_map); | 1555 | set_bit(EOL_CHAR(tty), ldata->process_char_map); |
1512 | if (L_IEXTEN(tty)) { | 1556 | if (L_IEXTEN(tty)) { |
1513 | set_bit(WERASE_CHAR(tty), | 1557 | set_bit(WERASE_CHAR(tty), |
1514 | tty->process_char_map); | 1558 | ldata->process_char_map); |
1515 | set_bit(LNEXT_CHAR(tty), | 1559 | set_bit(LNEXT_CHAR(tty), |
1516 | tty->process_char_map); | 1560 | ldata->process_char_map); |
1517 | set_bit(EOL2_CHAR(tty), | 1561 | set_bit(EOL2_CHAR(tty), |
1518 | tty->process_char_map); | 1562 | ldata->process_char_map); |
1519 | if (L_ECHO(tty)) | 1563 | if (L_ECHO(tty)) |
1520 | set_bit(REPRINT_CHAR(tty), | 1564 | set_bit(REPRINT_CHAR(tty), |
1521 | tty->process_char_map); | 1565 | ldata->process_char_map); |
1522 | } | 1566 | } |
1523 | } | 1567 | } |
1524 | if (I_IXON(tty)) { | 1568 | if (I_IXON(tty)) { |
1525 | set_bit(START_CHAR(tty), tty->process_char_map); | 1569 | set_bit(START_CHAR(tty), ldata->process_char_map); |
1526 | set_bit(STOP_CHAR(tty), tty->process_char_map); | 1570 | set_bit(STOP_CHAR(tty), ldata->process_char_map); |
1527 | } | 1571 | } |
1528 | if (L_ISIG(tty)) { | 1572 | if (L_ISIG(tty)) { |
1529 | set_bit(INTR_CHAR(tty), tty->process_char_map); | 1573 | set_bit(INTR_CHAR(tty), ldata->process_char_map); |
1530 | set_bit(QUIT_CHAR(tty), tty->process_char_map); | 1574 | set_bit(QUIT_CHAR(tty), ldata->process_char_map); |
1531 | set_bit(SUSP_CHAR(tty), tty->process_char_map); | 1575 | set_bit(SUSP_CHAR(tty), ldata->process_char_map); |
1532 | } | 1576 | } |
1533 | clear_bit(__DISABLED_CHAR, tty->process_char_map); | 1577 | clear_bit(__DISABLED_CHAR, ldata->process_char_map); |
1534 | tty->raw = 0; | 1578 | ldata->raw = 0; |
1535 | tty->real_raw = 0; | 1579 | ldata->real_raw = 0; |
1536 | } else { | 1580 | } else { |
1537 | tty->raw = 1; | 1581 | ldata->raw = 1; |
1538 | if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) && | 1582 | if ((I_IGNBRK(tty) || (!I_BRKINT(tty) && !I_PARMRK(tty))) && |
1539 | (I_IGNPAR(tty) || !I_INPCK(tty)) && | 1583 | (I_IGNPAR(tty) || !I_INPCK(tty)) && |
1540 | (tty->driver->flags & TTY_DRIVER_REAL_RAW)) | 1584 | (tty->driver->flags & TTY_DRIVER_REAL_RAW)) |
1541 | tty->real_raw = 1; | 1585 | ldata->real_raw = 1; |
1542 | else | 1586 | else |
1543 | tty->real_raw = 0; | 1587 | ldata->real_raw = 0; |
1544 | } | 1588 | } |
1545 | n_tty_set_room(tty); | 1589 | n_tty_set_room(tty); |
1546 | /* The termios change make the tty ready for I/O */ | 1590 | /* The termios change make the tty ready for I/O */ |
@@ -1560,15 +1604,13 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
1560 | 1604 | ||
1561 | static void n_tty_close(struct tty_struct *tty) | 1605 | static void n_tty_close(struct tty_struct *tty) |
1562 | { | 1606 | { |
1607 | struct n_tty_data *ldata = tty->disc_data; | ||
1608 | |||
1563 | n_tty_flush_buffer(tty); | 1609 | n_tty_flush_buffer(tty); |
1564 | if (tty->read_buf) { | 1610 | kfree(ldata->read_buf); |
1565 | kfree(tty->read_buf); | 1611 | kfree(ldata->echo_buf); |
1566 | tty->read_buf = NULL; | 1612 | kfree(ldata); |
1567 | } | 1613 | tty->disc_data = NULL; |
1568 | if (tty->echo_buf) { | ||
1569 | kfree(tty->echo_buf); | ||
1570 | tty->echo_buf = NULL; | ||
1571 | } | ||
1572 | } | 1614 | } |
1573 | 1615 | ||
1574 | /** | 1616 | /** |
@@ -1583,37 +1625,50 @@ static void n_tty_close(struct tty_struct *tty) | |||
1583 | 1625 | ||
1584 | static int n_tty_open(struct tty_struct *tty) | 1626 | static int n_tty_open(struct tty_struct *tty) |
1585 | { | 1627 | { |
1586 | if (!tty) | 1628 | struct n_tty_data *ldata; |
1587 | return -EINVAL; | 1629 | |
1630 | ldata = kzalloc(sizeof(*ldata), GFP_KERNEL); | ||
1631 | if (!ldata) | ||
1632 | goto err; | ||
1633 | |||
1634 | ldata->overrun_time = jiffies; | ||
1635 | mutex_init(&ldata->atomic_read_lock); | ||
1636 | mutex_init(&ldata->output_lock); | ||
1637 | mutex_init(&ldata->echo_lock); | ||
1638 | spin_lock_init(&ldata->read_lock); | ||
1588 | 1639 | ||
1589 | /* These are ugly. Currently a malloc failure here can panic */ | 1640 | /* These are ugly. Currently a malloc failure here can panic */ |
1590 | if (!tty->read_buf) { | 1641 | ldata->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); |
1591 | tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); | 1642 | ldata->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); |
1592 | if (!tty->read_buf) | 1643 | if (!ldata->read_buf || !ldata->echo_buf) |
1593 | return -ENOMEM; | 1644 | goto err_free_bufs; |
1594 | } | ||
1595 | if (!tty->echo_buf) { | ||
1596 | tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL); | ||
1597 | 1645 | ||
1598 | if (!tty->echo_buf) | 1646 | tty->disc_data = ldata; |
1599 | return -ENOMEM; | ||
1600 | } | ||
1601 | reset_buffer_flags(tty); | 1647 | reset_buffer_flags(tty); |
1602 | tty_unthrottle(tty); | 1648 | tty_unthrottle(tty); |
1603 | tty->column = 0; | 1649 | ldata->column = 0; |
1604 | n_tty_set_termios(tty, NULL); | 1650 | n_tty_set_termios(tty, NULL); |
1605 | tty->minimum_to_wake = 1; | 1651 | tty->minimum_to_wake = 1; |
1606 | tty->closing = 0; | 1652 | tty->closing = 0; |
1653 | |||
1607 | return 0; | 1654 | return 0; |
1655 | err_free_bufs: | ||
1656 | kfree(ldata->read_buf); | ||
1657 | kfree(ldata->echo_buf); | ||
1658 | kfree(ldata); | ||
1659 | err: | ||
1660 | return -ENOMEM; | ||
1608 | } | 1661 | } |
1609 | 1662 | ||
1610 | static inline int input_available_p(struct tty_struct *tty, int amt) | 1663 | static inline int input_available_p(struct tty_struct *tty, int amt) |
1611 | { | 1664 | { |
1665 | struct n_tty_data *ldata = tty->disc_data; | ||
1666 | |||
1612 | tty_flush_to_ldisc(tty); | 1667 | tty_flush_to_ldisc(tty); |
1613 | if (tty->icanon && !L_EXTPROC(tty)) { | 1668 | if (ldata->icanon && !L_EXTPROC(tty)) { |
1614 | if (tty->canon_data) | 1669 | if (ldata->canon_data) |
1615 | return 1; | 1670 | return 1; |
1616 | } else if (tty->read_cnt >= (amt ? amt : 1)) | 1671 | } else if (ldata->read_cnt >= (amt ? amt : 1)) |
1617 | return 1; | 1672 | return 1; |
1618 | 1673 | ||
1619 | return 0; | 1674 | return 0; |
@@ -1632,7 +1687,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt) | |||
1632 | * buffer, and once to drain the space from the (physical) beginning of | 1687 | * buffer, and once to drain the space from the (physical) beginning of |
1633 | * the buffer to head pointer. | 1688 | * the buffer to head pointer. |
1634 | * | 1689 | * |
1635 | * Called under the tty->atomic_read_lock sem | 1690 | * Called under the ldata->atomic_read_lock sem |
1636 | * | 1691 | * |
1637 | */ | 1692 | */ |
1638 | 1693 | ||
@@ -1641,29 +1696,31 @@ static int copy_from_read_buf(struct tty_struct *tty, | |||
1641 | size_t *nr) | 1696 | size_t *nr) |
1642 | 1697 | ||
1643 | { | 1698 | { |
1699 | struct n_tty_data *ldata = tty->disc_data; | ||
1644 | int retval; | 1700 | int retval; |
1645 | size_t n; | 1701 | size_t n; |
1646 | unsigned long flags; | 1702 | unsigned long flags; |
1647 | bool is_eof; | 1703 | bool is_eof; |
1648 | 1704 | ||
1649 | retval = 0; | 1705 | retval = 0; |
1650 | spin_lock_irqsave(&tty->read_lock, flags); | 1706 | spin_lock_irqsave(&ldata->read_lock, flags); |
1651 | n = min(tty->read_cnt, N_TTY_BUF_SIZE - tty->read_tail); | 1707 | n = min(ldata->read_cnt, N_TTY_BUF_SIZE - ldata->read_tail); |
1652 | n = min(*nr, n); | 1708 | n = min(*nr, n); |
1653 | spin_unlock_irqrestore(&tty->read_lock, flags); | 1709 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
1654 | if (n) { | 1710 | if (n) { |
1655 | retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n); | 1711 | retval = copy_to_user(*b, &ldata->read_buf[ldata->read_tail], n); |
1656 | n -= retval; | 1712 | n -= retval; |
1657 | is_eof = n == 1 && | 1713 | is_eof = n == 1 && |
1658 | tty->read_buf[tty->read_tail] == EOF_CHAR(tty); | 1714 | ldata->read_buf[ldata->read_tail] == EOF_CHAR(tty); |
1659 | tty_audit_add_data(tty, &tty->read_buf[tty->read_tail], n); | 1715 | tty_audit_add_data(tty, &ldata->read_buf[ldata->read_tail], n, |
1660 | spin_lock_irqsave(&tty->read_lock, flags); | 1716 | ldata->icanon); |
1661 | tty->read_tail = (tty->read_tail + n) & (N_TTY_BUF_SIZE-1); | 1717 | spin_lock_irqsave(&ldata->read_lock, flags); |
1662 | tty->read_cnt -= n; | 1718 | ldata->read_tail = (ldata->read_tail + n) & (N_TTY_BUF_SIZE-1); |
1719 | ldata->read_cnt -= n; | ||
1663 | /* Turn single EOF into zero-length read */ | 1720 | /* Turn single EOF into zero-length read */ |
1664 | if (L_EXTPROC(tty) && tty->icanon && is_eof && !tty->read_cnt) | 1721 | if (L_EXTPROC(tty) && ldata->icanon && is_eof && !ldata->read_cnt) |
1665 | n = 0; | 1722 | n = 0; |
1666 | spin_unlock_irqrestore(&tty->read_lock, flags); | 1723 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
1667 | *b += n; | 1724 | *b += n; |
1668 | *nr -= n; | 1725 | *nr -= n; |
1669 | } | 1726 | } |
@@ -1730,6 +1787,7 @@ static int job_control(struct tty_struct *tty, struct file *file) | |||
1730 | static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, | 1787 | static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, |
1731 | unsigned char __user *buf, size_t nr) | 1788 | unsigned char __user *buf, size_t nr) |
1732 | { | 1789 | { |
1790 | struct n_tty_data *ldata = tty->disc_data; | ||
1733 | unsigned char __user *b = buf; | 1791 | unsigned char __user *b = buf; |
1734 | DECLARE_WAITQUEUE(wait, current); | 1792 | DECLARE_WAITQUEUE(wait, current); |
1735 | int c; | 1793 | int c; |
@@ -1741,17 +1799,13 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, | |||
1741 | int packet; | 1799 | int packet; |
1742 | 1800 | ||
1743 | do_it_again: | 1801 | do_it_again: |
1744 | |||
1745 | if (WARN_ON(!tty->read_buf)) | ||
1746 | return -EAGAIN; | ||
1747 | |||
1748 | c = job_control(tty, file); | 1802 | c = job_control(tty, file); |
1749 | if (c < 0) | 1803 | if (c < 0) |
1750 | return c; | 1804 | return c; |
1751 | 1805 | ||
1752 | minimum = time = 0; | 1806 | minimum = time = 0; |
1753 | timeout = MAX_SCHEDULE_TIMEOUT; | 1807 | timeout = MAX_SCHEDULE_TIMEOUT; |
1754 | if (!tty->icanon) { | 1808 | if (!ldata->icanon) { |
1755 | time = (HZ / 10) * TIME_CHAR(tty); | 1809 | time = (HZ / 10) * TIME_CHAR(tty); |
1756 | minimum = MIN_CHAR(tty); | 1810 | minimum = MIN_CHAR(tty); |
1757 | if (minimum) { | 1811 | if (minimum) { |
@@ -1774,10 +1828,10 @@ do_it_again: | |||
1774 | * Internal serialization of reads. | 1828 | * Internal serialization of reads. |
1775 | */ | 1829 | */ |
1776 | if (file->f_flags & O_NONBLOCK) { | 1830 | if (file->f_flags & O_NONBLOCK) { |
1777 | if (!mutex_trylock(&tty->atomic_read_lock)) | 1831 | if (!mutex_trylock(&ldata->atomic_read_lock)) |
1778 | return -EAGAIN; | 1832 | return -EAGAIN; |
1779 | } else { | 1833 | } else { |
1780 | if (mutex_lock_interruptible(&tty->atomic_read_lock)) | 1834 | if (mutex_lock_interruptible(&ldata->atomic_read_lock)) |
1781 | return -ERESTARTSYS; | 1835 | return -ERESTARTSYS; |
1782 | } | 1836 | } |
1783 | packet = tty->packet; | 1837 | packet = tty->packet; |
@@ -1830,7 +1884,6 @@ do_it_again: | |||
1830 | /* FIXME: does n_tty_set_room need locking ? */ | 1884 | /* FIXME: does n_tty_set_room need locking ? */ |
1831 | n_tty_set_room(tty); | 1885 | n_tty_set_room(tty); |
1832 | timeout = schedule_timeout(timeout); | 1886 | timeout = schedule_timeout(timeout); |
1833 | BUG_ON(!tty->read_buf); | ||
1834 | continue; | 1887 | continue; |
1835 | } | 1888 | } |
1836 | __set_current_state(TASK_RUNNING); | 1889 | __set_current_state(TASK_RUNNING); |
@@ -1845,45 +1898,45 @@ do_it_again: | |||
1845 | nr--; | 1898 | nr--; |
1846 | } | 1899 | } |
1847 | 1900 | ||
1848 | if (tty->icanon && !L_EXTPROC(tty)) { | 1901 | if (ldata->icanon && !L_EXTPROC(tty)) { |
1849 | /* N.B. avoid overrun if nr == 0 */ | 1902 | /* N.B. avoid overrun if nr == 0 */ |
1850 | spin_lock_irqsave(&tty->read_lock, flags); | 1903 | spin_lock_irqsave(&ldata->read_lock, flags); |
1851 | while (nr && tty->read_cnt) { | 1904 | while (nr && ldata->read_cnt) { |
1852 | int eol; | 1905 | int eol; |
1853 | 1906 | ||
1854 | eol = test_and_clear_bit(tty->read_tail, | 1907 | eol = test_and_clear_bit(ldata->read_tail, |
1855 | tty->read_flags); | 1908 | ldata->read_flags); |
1856 | c = tty->read_buf[tty->read_tail]; | 1909 | c = ldata->read_buf[ldata->read_tail]; |
1857 | tty->read_tail = ((tty->read_tail+1) & | 1910 | ldata->read_tail = ((ldata->read_tail+1) & |
1858 | (N_TTY_BUF_SIZE-1)); | 1911 | (N_TTY_BUF_SIZE-1)); |
1859 | tty->read_cnt--; | 1912 | ldata->read_cnt--; |
1860 | if (eol) { | 1913 | if (eol) { |
1861 | /* this test should be redundant: | 1914 | /* this test should be redundant: |
1862 | * we shouldn't be reading data if | 1915 | * we shouldn't be reading data if |
1863 | * canon_data is 0 | 1916 | * canon_data is 0 |
1864 | */ | 1917 | */ |
1865 | if (--tty->canon_data < 0) | 1918 | if (--ldata->canon_data < 0) |
1866 | tty->canon_data = 0; | 1919 | ldata->canon_data = 0; |
1867 | } | 1920 | } |
1868 | spin_unlock_irqrestore(&tty->read_lock, flags); | 1921 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
1869 | 1922 | ||
1870 | if (!eol || (c != __DISABLED_CHAR)) { | 1923 | if (!eol || (c != __DISABLED_CHAR)) { |
1871 | if (tty_put_user(tty, c, b++)) { | 1924 | if (tty_put_user(tty, c, b++)) { |
1872 | retval = -EFAULT; | 1925 | retval = -EFAULT; |
1873 | b--; | 1926 | b--; |
1874 | spin_lock_irqsave(&tty->read_lock, flags); | 1927 | spin_lock_irqsave(&ldata->read_lock, flags); |
1875 | break; | 1928 | break; |
1876 | } | 1929 | } |
1877 | nr--; | 1930 | nr--; |
1878 | } | 1931 | } |
1879 | if (eol) { | 1932 | if (eol) { |
1880 | tty_audit_push(tty); | 1933 | tty_audit_push(tty); |
1881 | spin_lock_irqsave(&tty->read_lock, flags); | 1934 | spin_lock_irqsave(&ldata->read_lock, flags); |
1882 | break; | 1935 | break; |
1883 | } | 1936 | } |
1884 | spin_lock_irqsave(&tty->read_lock, flags); | 1937 | spin_lock_irqsave(&ldata->read_lock, flags); |
1885 | } | 1938 | } |
1886 | spin_unlock_irqrestore(&tty->read_lock, flags); | 1939 | spin_unlock_irqrestore(&ldata->read_lock, flags); |
1887 | if (retval) | 1940 | if (retval) |
1888 | break; | 1941 | break; |
1889 | } else { | 1942 | } else { |
@@ -1915,7 +1968,7 @@ do_it_again: | |||
1915 | if (time) | 1968 | if (time) |
1916 | timeout = time; | 1969 | timeout = time; |
1917 | } | 1970 | } |
1918 | mutex_unlock(&tty->atomic_read_lock); | 1971 | mutex_unlock(&ldata->atomic_read_lock); |
1919 | remove_wait_queue(&tty->read_wait, &wait); | 1972 | remove_wait_queue(&tty->read_wait, &wait); |
1920 | 1973 | ||
1921 | if (!waitqueue_active(&tty->read_wait)) | 1974 | if (!waitqueue_active(&tty->read_wait)) |
@@ -2076,19 +2129,19 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file, | |||
2076 | return mask; | 2129 | return mask; |
2077 | } | 2130 | } |
2078 | 2131 | ||
2079 | static unsigned long inq_canon(struct tty_struct *tty) | 2132 | static unsigned long inq_canon(struct n_tty_data *ldata) |
2080 | { | 2133 | { |
2081 | int nr, head, tail; | 2134 | int nr, head, tail; |
2082 | 2135 | ||
2083 | if (!tty->canon_data) | 2136 | if (!ldata->canon_data) |
2084 | return 0; | 2137 | return 0; |
2085 | head = tty->canon_head; | 2138 | head = ldata->canon_head; |
2086 | tail = tty->read_tail; | 2139 | tail = ldata->read_tail; |
2087 | nr = (head - tail) & (N_TTY_BUF_SIZE-1); | 2140 | nr = (head - tail) & (N_TTY_BUF_SIZE-1); |
2088 | /* Skip EOF-chars.. */ | 2141 | /* Skip EOF-chars.. */ |
2089 | while (head != tail) { | 2142 | while (head != tail) { |
2090 | if (test_bit(tail, tty->read_flags) && | 2143 | if (test_bit(tail, ldata->read_flags) && |
2091 | tty->read_buf[tail] == __DISABLED_CHAR) | 2144 | ldata->read_buf[tail] == __DISABLED_CHAR) |
2092 | nr--; | 2145 | nr--; |
2093 | tail = (tail+1) & (N_TTY_BUF_SIZE-1); | 2146 | tail = (tail+1) & (N_TTY_BUF_SIZE-1); |
2094 | } | 2147 | } |
@@ -2098,6 +2151,7 @@ static unsigned long inq_canon(struct tty_struct *tty) | |||
2098 | static int n_tty_ioctl(struct tty_struct *tty, struct file *file, | 2151 | static int n_tty_ioctl(struct tty_struct *tty, struct file *file, |
2099 | unsigned int cmd, unsigned long arg) | 2152 | unsigned int cmd, unsigned long arg) |
2100 | { | 2153 | { |
2154 | struct n_tty_data *ldata = tty->disc_data; | ||
2101 | int retval; | 2155 | int retval; |
2102 | 2156 | ||
2103 | switch (cmd) { | 2157 | switch (cmd) { |
@@ -2105,9 +2159,9 @@ static int n_tty_ioctl(struct tty_struct *tty, struct file *file, | |||
2105 | return put_user(tty_chars_in_buffer(tty), (int __user *) arg); | 2159 | return put_user(tty_chars_in_buffer(tty), (int __user *) arg); |
2106 | case TIOCINQ: | 2160 | case TIOCINQ: |
2107 | /* FIXME: Locking */ | 2161 | /* FIXME: Locking */ |
2108 | retval = tty->read_cnt; | 2162 | retval = ldata->read_cnt; |
2109 | if (L_ICANON(tty)) | 2163 | if (L_ICANON(tty)) |
2110 | retval = inq_canon(tty); | 2164 | retval = inq_canon(ldata); |
2111 | return put_user(retval, (unsigned int __user *) arg); | 2165 | return put_user(retval, (unsigned int __user *) arg); |
2112 | default: | 2166 | default: |
2113 | return n_tty_ioctl_helper(tty, file, cmd, arg); | 2167 | return n_tty_ioctl_helper(tty, file, cmd, arg); |
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index a82b39939a9c..4219f040adb8 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -4,9 +4,6 @@ | |||
4 | * Added support for a Unix98-style ptmx device. | 4 | * Added support for a Unix98-style ptmx device. |
5 | * -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-1998 | 5 | * -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-1998 |
6 | * | 6 | * |
7 | * When reading this code see also fs/devpts. In particular note that the | ||
8 | * driver_data field is used by the devpts side as a binding to the devpts | ||
9 | * inode. | ||
10 | */ | 7 | */ |
11 | 8 | ||
12 | #include <linux/module.h> | 9 | #include <linux/module.h> |
@@ -59,7 +56,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp) | |||
59 | #ifdef CONFIG_UNIX98_PTYS | 56 | #ifdef CONFIG_UNIX98_PTYS |
60 | if (tty->driver == ptm_driver) { | 57 | if (tty->driver == ptm_driver) { |
61 | mutex_lock(&devpts_mutex); | 58 | mutex_lock(&devpts_mutex); |
62 | devpts_pty_kill(tty->link); | 59 | devpts_pty_kill(tty->link->driver_data); |
63 | mutex_unlock(&devpts_mutex); | 60 | mutex_unlock(&devpts_mutex); |
64 | } | 61 | } |
65 | #endif | 62 | #endif |
@@ -96,7 +93,7 @@ static void pty_unthrottle(struct tty_struct *tty) | |||
96 | 93 | ||
97 | static int pty_space(struct tty_struct *to) | 94 | static int pty_space(struct tty_struct *to) |
98 | { | 95 | { |
99 | int n = 8192 - to->buf.memory_used; | 96 | int n = 8192 - to->port->buf.memory_used; |
100 | if (n < 0) | 97 | if (n < 0) |
101 | return 0; | 98 | return 0; |
102 | return n; | 99 | return n; |
@@ -348,6 +345,7 @@ static int pty_common_install(struct tty_driver *driver, struct tty_struct *tty, | |||
348 | tty_port_init(ports[1]); | 345 | tty_port_init(ports[1]); |
349 | o_tty->port = ports[0]; | 346 | o_tty->port = ports[0]; |
350 | tty->port = ports[1]; | 347 | tty->port = ports[1]; |
348 | o_tty->port->itty = o_tty; | ||
351 | 349 | ||
352 | tty_driver_kref_get(driver); | 350 | tty_driver_kref_get(driver); |
353 | tty->count++; | 351 | tty->count++; |
@@ -366,8 +364,15 @@ err: | |||
366 | return retval; | 364 | return retval; |
367 | } | 365 | } |
368 | 366 | ||
367 | /* this is called once with whichever end is closed last */ | ||
368 | static void pty_unix98_shutdown(struct tty_struct *tty) | ||
369 | { | ||
370 | devpts_kill_index(tty->driver_data, tty->index); | ||
371 | } | ||
372 | |||
369 | static void pty_cleanup(struct tty_struct *tty) | 373 | static void pty_cleanup(struct tty_struct *tty) |
370 | { | 374 | { |
375 | tty->port->itty = NULL; | ||
371 | kfree(tty->port); | 376 | kfree(tty->port); |
372 | } | 377 | } |
373 | 378 | ||
@@ -547,7 +552,7 @@ static struct tty_struct *pts_unix98_lookup(struct tty_driver *driver, | |||
547 | struct tty_struct *tty; | 552 | struct tty_struct *tty; |
548 | 553 | ||
549 | mutex_lock(&devpts_mutex); | 554 | mutex_lock(&devpts_mutex); |
550 | tty = devpts_get_tty(pts_inode, idx); | 555 | tty = devpts_get_priv(pts_inode); |
551 | mutex_unlock(&devpts_mutex); | 556 | mutex_unlock(&devpts_mutex); |
552 | /* Master must be open before slave */ | 557 | /* Master must be open before slave */ |
553 | if (!tty) | 558 | if (!tty) |
@@ -581,6 +586,7 @@ static const struct tty_operations ptm_unix98_ops = { | |||
581 | .set_termios = pty_set_termios, | 586 | .set_termios = pty_set_termios, |
582 | .ioctl = pty_unix98_ioctl, | 587 | .ioctl = pty_unix98_ioctl, |
583 | .resize = pty_resize, | 588 | .resize = pty_resize, |
589 | .shutdown = pty_unix98_shutdown, | ||
584 | .cleanup = pty_cleanup | 590 | .cleanup = pty_cleanup |
585 | }; | 591 | }; |
586 | 592 | ||
@@ -596,6 +602,7 @@ static const struct tty_operations pty_unix98_ops = { | |||
596 | .chars_in_buffer = pty_chars_in_buffer, | 602 | .chars_in_buffer = pty_chars_in_buffer, |
597 | .unthrottle = pty_unthrottle, | 603 | .unthrottle = pty_unthrottle, |
598 | .set_termios = pty_set_termios, | 604 | .set_termios = pty_set_termios, |
605 | .shutdown = pty_unix98_shutdown, | ||
599 | .cleanup = pty_cleanup, | 606 | .cleanup = pty_cleanup, |
600 | }; | 607 | }; |
601 | 608 | ||
@@ -614,6 +621,7 @@ static const struct tty_operations pty_unix98_ops = { | |||
614 | static int ptmx_open(struct inode *inode, struct file *filp) | 621 | static int ptmx_open(struct inode *inode, struct file *filp) |
615 | { | 622 | { |
616 | struct tty_struct *tty; | 623 | struct tty_struct *tty; |
624 | struct inode *slave_inode; | ||
617 | int retval; | 625 | int retval; |
618 | int index; | 626 | int index; |
619 | 627 | ||
@@ -650,15 +658,21 @@ static int ptmx_open(struct inode *inode, struct file *filp) | |||
650 | 658 | ||
651 | tty_add_file(tty, filp); | 659 | tty_add_file(tty, filp); |
652 | 660 | ||
653 | retval = devpts_pty_new(inode, tty->link); | 661 | slave_inode = devpts_pty_new(inode, |
654 | if (retval) | 662 | MKDEV(UNIX98_PTY_SLAVE_MAJOR, index), index, |
663 | tty->link); | ||
664 | if (IS_ERR(slave_inode)) { | ||
665 | retval = PTR_ERR(slave_inode); | ||
655 | goto err_release; | 666 | goto err_release; |
667 | } | ||
656 | 668 | ||
657 | retval = ptm_driver->ops->open(tty, filp); | 669 | retval = ptm_driver->ops->open(tty, filp); |
658 | if (retval) | 670 | if (retval) |
659 | goto err_release; | 671 | goto err_release; |
660 | 672 | ||
661 | tty_unlock(tty); | 673 | tty_unlock(tty); |
674 | tty->driver_data = inode; | ||
675 | tty->link->driver_data = slave_inode; | ||
662 | return 0; | 676 | return 0; |
663 | err_release: | 677 | err_release: |
664 | tty_unlock(tty); | 678 | tty_unlock(tty); |
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c index 3ba4234592bc..5ccbd90540cf 100644 --- a/drivers/tty/serial/8250/8250.c +++ b/drivers/tty/serial/8250/8250.c | |||
@@ -2349,16 +2349,14 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, | |||
2349 | serial_port_out(port, UART_EFR, efr); | 2349 | serial_port_out(port, UART_EFR, efr); |
2350 | } | 2350 | } |
2351 | 2351 | ||
2352 | #ifdef CONFIG_ARCH_OMAP1 | ||
2353 | /* Workaround to enable 115200 baud on OMAP1510 internal ports */ | 2352 | /* Workaround to enable 115200 baud on OMAP1510 internal ports */ |
2354 | if (cpu_is_omap1510() && is_omap_port(up)) { | 2353 | if (is_omap1510_8250(up)) { |
2355 | if (baud == 115200) { | 2354 | if (baud == 115200) { |
2356 | quot = 1; | 2355 | quot = 1; |
2357 | serial_port_out(port, UART_OMAP_OSC_12M_SEL, 1); | 2356 | serial_port_out(port, UART_OMAP_OSC_12M_SEL, 1); |
2358 | } else | 2357 | } else |
2359 | serial_port_out(port, UART_OMAP_OSC_12M_SEL, 0); | 2358 | serial_port_out(port, UART_OMAP_OSC_12M_SEL, 0); |
2360 | } | 2359 | } |
2361 | #endif | ||
2362 | 2360 | ||
2363 | /* | 2361 | /* |
2364 | * For NatSemi, switch to bank 2 not bank 1, to avoid resetting EXCR2, | 2362 | * For NatSemi, switch to bank 2 not bank 1, to avoid resetting EXCR2, |
@@ -2439,10 +2437,9 @@ static unsigned int serial8250_port_size(struct uart_8250_port *pt) | |||
2439 | { | 2437 | { |
2440 | if (pt->port.iotype == UPIO_AU) | 2438 | if (pt->port.iotype == UPIO_AU) |
2441 | return 0x1000; | 2439 | return 0x1000; |
2442 | #ifdef CONFIG_ARCH_OMAP1 | 2440 | if (is_omap1_8250(pt)) |
2443 | if (is_omap_port(pt)) | ||
2444 | return 0x16 << pt->port.regshift; | 2441 | return 0x16 << pt->port.regshift; |
2445 | #endif | 2442 | |
2446 | return 8 << pt->port.regshift; | 2443 | return 8 << pt->port.regshift; |
2447 | } | 2444 | } |
2448 | 2445 | ||
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 5a76f9c8d36b..3b4ea84898c2 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h | |||
@@ -106,3 +106,39 @@ static inline int serial8250_pnp_init(void) { return 0; } | |||
106 | static inline void serial8250_pnp_exit(void) { } | 106 | static inline void serial8250_pnp_exit(void) { } |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | #ifdef CONFIG_ARCH_OMAP1 | ||
110 | static inline int is_omap1_8250(struct uart_8250_port *pt) | ||
111 | { | ||
112 | int res; | ||
113 | |||
114 | switch (pt->port.mapbase) { | ||
115 | case OMAP1_UART1_BASE: | ||
116 | case OMAP1_UART2_BASE: | ||
117 | case OMAP1_UART3_BASE: | ||
118 | res = 1; | ||
119 | break; | ||
120 | default: | ||
121 | res = 0; | ||
122 | break; | ||
123 | } | ||
124 | |||
125 | return res; | ||
126 | } | ||
127 | |||
128 | static inline int is_omap1510_8250(struct uart_8250_port *pt) | ||
129 | { | ||
130 | if (!cpu_is_omap1510()) | ||
131 | return 0; | ||
132 | |||
133 | return is_omap1_8250(pt); | ||
134 | } | ||
135 | #else | ||
136 | static inline int is_omap1_8250(struct uart_8250_port *pt) | ||
137 | { | ||
138 | return 0; | ||
139 | } | ||
140 | static inline int is_omap1510_8250(struct uart_8250_port *pt) | ||
141 | { | ||
142 | return 0; | ||
143 | } | ||
144 | #endif | ||
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index eaafb98debed..843a150ba105 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c | |||
@@ -140,7 +140,7 @@ static void __init init_port(struct early_serial8250_device *device) | |||
140 | serial_out(port, UART_FCR, 0); /* no fifo */ | 140 | serial_out(port, UART_FCR, 0); /* no fifo */ |
141 | serial_out(port, UART_MCR, 0x3); /* DTR + RTS */ | 141 | serial_out(port, UART_MCR, 0x3); /* DTR + RTS */ |
142 | 142 | ||
143 | divisor = port->uartclk / (16 * device->baud); | 143 | divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud); |
144 | c = serial_in(port, UART_LCR); | 144 | c = serial_in(port, UART_LCR); |
145 | serial_out(port, UART_LCR, c | UART_LCR_DLAB); | 145 | serial_out(port, UART_LCR, c | UART_LCR_DLAB); |
146 | serial_out(port, UART_DLL, divisor & 0xff); | 146 | serial_out(port, UART_DLL, divisor & 0xff); |
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 7f04717176aa..740458ca62cc 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c | |||
@@ -530,16 +530,16 @@ static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level, | |||
530 | switch (level) { | 530 | switch (level) { |
531 | case 3: | 531 | case 3: |
532 | if (!IS_ERR(ourport->baudclk)) | 532 | if (!IS_ERR(ourport->baudclk)) |
533 | clk_disable(ourport->baudclk); | 533 | clk_disable_unprepare(ourport->baudclk); |
534 | 534 | ||
535 | clk_disable(ourport->clk); | 535 | clk_disable_unprepare(ourport->clk); |
536 | break; | 536 | break; |
537 | 537 | ||
538 | case 0: | 538 | case 0: |
539 | clk_enable(ourport->clk); | 539 | clk_prepare_enable(ourport->clk); |
540 | 540 | ||
541 | if (!IS_ERR(ourport->baudclk)) | 541 | if (!IS_ERR(ourport->baudclk)) |
542 | clk_enable(ourport->baudclk); | 542 | clk_prepare_enable(ourport->baudclk); |
543 | 543 | ||
544 | break; | 544 | break; |
545 | default: | 545 | default: |
@@ -713,11 +713,11 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, | |||
713 | s3c24xx_serial_setsource(port, clk_sel); | 713 | s3c24xx_serial_setsource(port, clk_sel); |
714 | 714 | ||
715 | if (!IS_ERR(ourport->baudclk)) { | 715 | if (!IS_ERR(ourport->baudclk)) { |
716 | clk_disable(ourport->baudclk); | 716 | clk_disable_unprepare(ourport->baudclk); |
717 | ourport->baudclk = ERR_PTR(-EINVAL); | 717 | ourport->baudclk = ERR_PTR(-EINVAL); |
718 | } | 718 | } |
719 | 719 | ||
720 | clk_enable(clk); | 720 | clk_prepare_enable(clk); |
721 | 721 | ||
722 | ourport->baudclk = clk; | 722 | ourport->baudclk = clk; |
723 | ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0; | 723 | ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0; |
@@ -1287,9 +1287,9 @@ static int s3c24xx_serial_resume(struct device *dev) | |||
1287 | struct s3c24xx_uart_port *ourport = to_ourport(port); | 1287 | struct s3c24xx_uart_port *ourport = to_ourport(port); |
1288 | 1288 | ||
1289 | if (port) { | 1289 | if (port) { |
1290 | clk_enable(ourport->clk); | 1290 | clk_prepare_enable(ourport->clk); |
1291 | s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port)); | 1291 | s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port)); |
1292 | clk_disable(ourport->clk); | 1292 | clk_disable_unprepare(ourport->clk); |
1293 | 1293 | ||
1294 | uart_resume_port(&s3c24xx_uart_drv, port); | 1294 | uart_resume_port(&s3c24xx_uart_drv, port); |
1295 | } | 1295 | } |
diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c index b0b39b823ccf..6953dc82850c 100644 --- a/drivers/tty/tty_audit.c +++ b/drivers/tty/tty_audit.c | |||
@@ -23,7 +23,7 @@ struct tty_audit_buf { | |||
23 | }; | 23 | }; |
24 | 24 | ||
25 | static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor, | 25 | static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor, |
26 | int icanon) | 26 | unsigned icanon) |
27 | { | 27 | { |
28 | struct tty_audit_buf *buf; | 28 | struct tty_audit_buf *buf; |
29 | 29 | ||
@@ -239,7 +239,8 @@ int tty_audit_push_task(struct task_struct *tsk, kuid_t loginuid, u32 sessionid) | |||
239 | * if TTY auditing is disabled or out of memory. Otherwise, return a new | 239 | * if TTY auditing is disabled or out of memory. Otherwise, return a new |
240 | * reference to the buffer. | 240 | * reference to the buffer. |
241 | */ | 241 | */ |
242 | static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty) | 242 | static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty, |
243 | unsigned icanon) | ||
243 | { | 244 | { |
244 | struct tty_audit_buf *buf, *buf2; | 245 | struct tty_audit_buf *buf, *buf2; |
245 | 246 | ||
@@ -257,7 +258,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty) | |||
257 | 258 | ||
258 | buf2 = tty_audit_buf_alloc(tty->driver->major, | 259 | buf2 = tty_audit_buf_alloc(tty->driver->major, |
259 | tty->driver->minor_start + tty->index, | 260 | tty->driver->minor_start + tty->index, |
260 | tty->icanon); | 261 | icanon); |
261 | if (buf2 == NULL) { | 262 | if (buf2 == NULL) { |
262 | audit_log_lost("out of memory in TTY auditing"); | 263 | audit_log_lost("out of memory in TTY auditing"); |
263 | return NULL; | 264 | return NULL; |
@@ -287,7 +288,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty) | |||
287 | * Audit @data of @size from @tty, if necessary. | 288 | * Audit @data of @size from @tty, if necessary. |
288 | */ | 289 | */ |
289 | void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, | 290 | void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, |
290 | size_t size) | 291 | size_t size, unsigned icanon) |
291 | { | 292 | { |
292 | struct tty_audit_buf *buf; | 293 | struct tty_audit_buf *buf; |
293 | int major, minor; | 294 | int major, minor; |
@@ -299,7 +300,7 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, | |||
299 | && tty->driver->subtype == PTY_TYPE_MASTER) | 300 | && tty->driver->subtype == PTY_TYPE_MASTER) |
300 | return; | 301 | return; |
301 | 302 | ||
302 | buf = tty_audit_buf_get(tty); | 303 | buf = tty_audit_buf_get(tty, icanon); |
303 | if (!buf) | 304 | if (!buf) |
304 | return; | 305 | return; |
305 | 306 | ||
@@ -307,11 +308,11 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, | |||
307 | major = tty->driver->major; | 308 | major = tty->driver->major; |
308 | minor = tty->driver->minor_start + tty->index; | 309 | minor = tty->driver->minor_start + tty->index; |
309 | if (buf->major != major || buf->minor != minor | 310 | if (buf->major != major || buf->minor != minor |
310 | || buf->icanon != tty->icanon) { | 311 | || buf->icanon != icanon) { |
311 | tty_audit_buf_push_current(buf); | 312 | tty_audit_buf_push_current(buf); |
312 | buf->major = major; | 313 | buf->major = major; |
313 | buf->minor = minor; | 314 | buf->minor = minor; |
314 | buf->icanon = tty->icanon; | 315 | buf->icanon = icanon; |
315 | } | 316 | } |
316 | do { | 317 | do { |
317 | size_t run; | 318 | size_t run; |
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 91e326ffe7db..6cf87d7afb7e 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c | |||
@@ -27,19 +27,21 @@ | |||
27 | * Locking: none | 27 | * Locking: none |
28 | */ | 28 | */ |
29 | 29 | ||
30 | void tty_buffer_free_all(struct tty_struct *tty) | 30 | void tty_buffer_free_all(struct tty_port *port) |
31 | { | 31 | { |
32 | struct tty_bufhead *buf = &port->buf; | ||
32 | struct tty_buffer *thead; | 33 | struct tty_buffer *thead; |
33 | while ((thead = tty->buf.head) != NULL) { | 34 | |
34 | tty->buf.head = thead->next; | 35 | while ((thead = buf->head) != NULL) { |
36 | buf->head = thead->next; | ||
35 | kfree(thead); | 37 | kfree(thead); |
36 | } | 38 | } |
37 | while ((thead = tty->buf.free) != NULL) { | 39 | while ((thead = buf->free) != NULL) { |
38 | tty->buf.free = thead->next; | 40 | buf->free = thead->next; |
39 | kfree(thead); | 41 | kfree(thead); |
40 | } | 42 | } |
41 | tty->buf.tail = NULL; | 43 | buf->tail = NULL; |
42 | tty->buf.memory_used = 0; | 44 | buf->memory_used = 0; |
43 | } | 45 | } |
44 | 46 | ||
45 | /** | 47 | /** |
@@ -54,11 +56,11 @@ void tty_buffer_free_all(struct tty_struct *tty) | |||
54 | * Locking: Caller must hold tty->buf.lock | 56 | * Locking: Caller must hold tty->buf.lock |
55 | */ | 57 | */ |
56 | 58 | ||
57 | static struct tty_buffer *tty_buffer_alloc(struct tty_struct *tty, size_t size) | 59 | static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size) |
58 | { | 60 | { |
59 | struct tty_buffer *p; | 61 | struct tty_buffer *p; |
60 | 62 | ||
61 | if (tty->buf.memory_used + size > 65536) | 63 | if (port->buf.memory_used + size > 65536) |
62 | return NULL; | 64 | return NULL; |
63 | p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC); | 65 | p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC); |
64 | if (p == NULL) | 66 | if (p == NULL) |
@@ -70,7 +72,7 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_struct *tty, size_t size) | |||
70 | p->read = 0; | 72 | p->read = 0; |
71 | p->char_buf_ptr = (char *)(p->data); | 73 | p->char_buf_ptr = (char *)(p->data); |
72 | p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size; | 74 | p->flag_buf_ptr = (unsigned char *)p->char_buf_ptr + size; |
73 | tty->buf.memory_used += size; | 75 | port->buf.memory_used += size; |
74 | return p; | 76 | return p; |
75 | } | 77 | } |
76 | 78 | ||
@@ -85,17 +87,19 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_struct *tty, size_t size) | |||
85 | * Locking: Caller must hold tty->buf.lock | 87 | * Locking: Caller must hold tty->buf.lock |
86 | */ | 88 | */ |
87 | 89 | ||
88 | static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b) | 90 | static void tty_buffer_free(struct tty_port *port, struct tty_buffer *b) |
89 | { | 91 | { |
92 | struct tty_bufhead *buf = &port->buf; | ||
93 | |||
90 | /* Dumb strategy for now - should keep some stats */ | 94 | /* Dumb strategy for now - should keep some stats */ |
91 | tty->buf.memory_used -= b->size; | 95 | buf->memory_used -= b->size; |
92 | WARN_ON(tty->buf.memory_used < 0); | 96 | WARN_ON(buf->memory_used < 0); |
93 | 97 | ||
94 | if (b->size >= 512) | 98 | if (b->size >= 512) |
95 | kfree(b); | 99 | kfree(b); |
96 | else { | 100 | else { |
97 | b->next = tty->buf.free; | 101 | b->next = buf->free; |
98 | tty->buf.free = b; | 102 | buf->free = b; |
99 | } | 103 | } |
100 | } | 104 | } |
101 | 105 | ||
@@ -110,15 +114,16 @@ static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b) | |||
110 | * Locking: Caller must hold tty->buf.lock | 114 | * Locking: Caller must hold tty->buf.lock |
111 | */ | 115 | */ |
112 | 116 | ||
113 | static void __tty_buffer_flush(struct tty_struct *tty) | 117 | static void __tty_buffer_flush(struct tty_port *port) |
114 | { | 118 | { |
119 | struct tty_bufhead *buf = &port->buf; | ||
115 | struct tty_buffer *thead; | 120 | struct tty_buffer *thead; |
116 | 121 | ||
117 | while ((thead = tty->buf.head) != NULL) { | 122 | while ((thead = buf->head) != NULL) { |
118 | tty->buf.head = thead->next; | 123 | buf->head = thead->next; |
119 | tty_buffer_free(tty, thead); | 124 | tty_buffer_free(port, thead); |
120 | } | 125 | } |
121 | tty->buf.tail = NULL; | 126 | buf->tail = NULL; |
122 | } | 127 | } |
123 | 128 | ||
124 | /** | 129 | /** |
@@ -134,21 +139,24 @@ static void __tty_buffer_flush(struct tty_struct *tty) | |||
134 | 139 | ||
135 | void tty_buffer_flush(struct tty_struct *tty) | 140 | void tty_buffer_flush(struct tty_struct *tty) |
136 | { | 141 | { |
142 | struct tty_port *port = tty->port; | ||
143 | struct tty_bufhead *buf = &port->buf; | ||
137 | unsigned long flags; | 144 | unsigned long flags; |
138 | spin_lock_irqsave(&tty->buf.lock, flags); | 145 | |
146 | spin_lock_irqsave(&buf->lock, flags); | ||
139 | 147 | ||
140 | /* If the data is being pushed to the tty layer then we can't | 148 | /* If the data is being pushed to the tty layer then we can't |
141 | process it here. Instead set a flag and the flush_to_ldisc | 149 | process it here. Instead set a flag and the flush_to_ldisc |
142 | path will process the flush request before it exits */ | 150 | path will process the flush request before it exits */ |
143 | if (test_bit(TTY_FLUSHING, &tty->flags)) { | 151 | if (test_bit(TTYP_FLUSHING, &port->iflags)) { |
144 | set_bit(TTY_FLUSHPENDING, &tty->flags); | 152 | set_bit(TTYP_FLUSHPENDING, &port->iflags); |
145 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 153 | spin_unlock_irqrestore(&buf->lock, flags); |
146 | wait_event(tty->read_wait, | 154 | wait_event(tty->read_wait, |
147 | test_bit(TTY_FLUSHPENDING, &tty->flags) == 0); | 155 | test_bit(TTYP_FLUSHPENDING, &port->iflags) == 0); |
148 | return; | 156 | return; |
149 | } else | 157 | } else |
150 | __tty_buffer_flush(tty); | 158 | __tty_buffer_flush(port); |
151 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 159 | spin_unlock_irqrestore(&buf->lock, flags); |
152 | } | 160 | } |
153 | 161 | ||
154 | /** | 162 | /** |
@@ -163,9 +171,9 @@ void tty_buffer_flush(struct tty_struct *tty) | |||
163 | * Locking: Caller must hold tty->buf.lock | 171 | * Locking: Caller must hold tty->buf.lock |
164 | */ | 172 | */ |
165 | 173 | ||
166 | static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size) | 174 | static struct tty_buffer *tty_buffer_find(struct tty_port *port, size_t size) |
167 | { | 175 | { |
168 | struct tty_buffer **tbh = &tty->buf.free; | 176 | struct tty_buffer **tbh = &port->buf.free; |
169 | while ((*tbh) != NULL) { | 177 | while ((*tbh) != NULL) { |
170 | struct tty_buffer *t = *tbh; | 178 | struct tty_buffer *t = *tbh; |
171 | if (t->size >= size) { | 179 | if (t->size >= size) { |
@@ -174,14 +182,14 @@ static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size) | |||
174 | t->used = 0; | 182 | t->used = 0; |
175 | t->commit = 0; | 183 | t->commit = 0; |
176 | t->read = 0; | 184 | t->read = 0; |
177 | tty->buf.memory_used += t->size; | 185 | port->buf.memory_used += t->size; |
178 | return t; | 186 | return t; |
179 | } | 187 | } |
180 | tbh = &((*tbh)->next); | 188 | tbh = &((*tbh)->next); |
181 | } | 189 | } |
182 | /* Round the buffer size out */ | 190 | /* Round the buffer size out */ |
183 | size = (size + 0xFF) & ~0xFF; | 191 | size = (size + 0xFF) & ~0xFF; |
184 | return tty_buffer_alloc(tty, size); | 192 | return tty_buffer_alloc(port, size); |
185 | /* Should possibly check if this fails for the largest buffer we | 193 | /* Should possibly check if this fails for the largest buffer we |
186 | have queued and recycle that ? */ | 194 | have queued and recycle that ? */ |
187 | } | 195 | } |
@@ -192,29 +200,31 @@ static struct tty_buffer *tty_buffer_find(struct tty_struct *tty, size_t size) | |||
192 | * | 200 | * |
193 | * Make at least size bytes of linear space available for the tty | 201 | * Make at least size bytes of linear space available for the tty |
194 | * buffer. If we fail return the size we managed to find. | 202 | * buffer. If we fail return the size we managed to find. |
195 | * Locking: Caller must hold tty->buf.lock | 203 | * Locking: Caller must hold port->buf.lock |
196 | */ | 204 | */ |
197 | static int __tty_buffer_request_room(struct tty_struct *tty, size_t size) | 205 | static int __tty_buffer_request_room(struct tty_port *port, size_t size) |
198 | { | 206 | { |
207 | struct tty_bufhead *buf = &port->buf; | ||
199 | struct tty_buffer *b, *n; | 208 | struct tty_buffer *b, *n; |
200 | int left; | 209 | int left; |
201 | /* OPTIMISATION: We could keep a per tty "zero" sized buffer to | 210 | /* OPTIMISATION: We could keep a per tty "zero" sized buffer to |
202 | remove this conditional if its worth it. This would be invisible | 211 | remove this conditional if its worth it. This would be invisible |
203 | to the callers */ | 212 | to the callers */ |
204 | if ((b = tty->buf.tail) != NULL) | 213 | b = buf->tail; |
214 | if (b != NULL) | ||
205 | left = b->size - b->used; | 215 | left = b->size - b->used; |
206 | else | 216 | else |
207 | left = 0; | 217 | left = 0; |
208 | 218 | ||
209 | if (left < size) { | 219 | if (left < size) { |
210 | /* This is the slow path - looking for new buffers to use */ | 220 | /* This is the slow path - looking for new buffers to use */ |
211 | if ((n = tty_buffer_find(tty, size)) != NULL) { | 221 | if ((n = tty_buffer_find(port, size)) != NULL) { |
212 | if (b != NULL) { | 222 | if (b != NULL) { |
213 | b->next = n; | 223 | b->next = n; |
214 | b->commit = b->used; | 224 | b->commit = b->used; |
215 | } else | 225 | } else |
216 | tty->buf.head = n; | 226 | buf->head = n; |
217 | tty->buf.tail = n; | 227 | buf->tail = n; |
218 | } else | 228 | } else |
219 | size = left; | 229 | size = left; |
220 | } | 230 | } |
@@ -231,16 +241,17 @@ static int __tty_buffer_request_room(struct tty_struct *tty, size_t size) | |||
231 | * Make at least size bytes of linear space available for the tty | 241 | * Make at least size bytes of linear space available for the tty |
232 | * buffer. If we fail return the size we managed to find. | 242 | * buffer. If we fail return the size we managed to find. |
233 | * | 243 | * |
234 | * Locking: Takes tty->buf.lock | 244 | * Locking: Takes port->buf.lock |
235 | */ | 245 | */ |
236 | int tty_buffer_request_room(struct tty_struct *tty, size_t size) | 246 | int tty_buffer_request_room(struct tty_struct *tty, size_t size) |
237 | { | 247 | { |
248 | struct tty_port *port = tty->port; | ||
238 | unsigned long flags; | 249 | unsigned long flags; |
239 | int length; | 250 | int length; |
240 | 251 | ||
241 | spin_lock_irqsave(&tty->buf.lock, flags); | 252 | spin_lock_irqsave(&port->buf.lock, flags); |
242 | length = __tty_buffer_request_room(tty, size); | 253 | length = __tty_buffer_request_room(port, size); |
243 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 254 | spin_unlock_irqrestore(&port->buf.lock, flags); |
244 | return length; | 255 | return length; |
245 | } | 256 | } |
246 | EXPORT_SYMBOL_GPL(tty_buffer_request_room); | 257 | EXPORT_SYMBOL_GPL(tty_buffer_request_room); |
@@ -255,12 +266,13 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room); | |||
255 | * Queue a series of bytes to the tty buffering. All the characters | 266 | * Queue a series of bytes to the tty buffering. All the characters |
256 | * passed are marked with the supplied flag. Returns the number added. | 267 | * passed are marked with the supplied flag. Returns the number added. |
257 | * | 268 | * |
258 | * Locking: Called functions may take tty->buf.lock | 269 | * Locking: Called functions may take port->buf.lock |
259 | */ | 270 | */ |
260 | 271 | ||
261 | int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, | 272 | int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, |
262 | const unsigned char *chars, char flag, size_t size) | 273 | const unsigned char *chars, char flag, size_t size) |
263 | { | 274 | { |
275 | struct tty_bufhead *buf = &tty->port->buf; | ||
264 | int copied = 0; | 276 | int copied = 0; |
265 | do { | 277 | do { |
266 | int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); | 278 | int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); |
@@ -268,18 +280,18 @@ int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, | |||
268 | unsigned long flags; | 280 | unsigned long flags; |
269 | struct tty_buffer *tb; | 281 | struct tty_buffer *tb; |
270 | 282 | ||
271 | spin_lock_irqsave(&tty->buf.lock, flags); | 283 | spin_lock_irqsave(&buf->lock, flags); |
272 | space = __tty_buffer_request_room(tty, goal); | 284 | space = __tty_buffer_request_room(tty->port, goal); |
273 | tb = tty->buf.tail; | 285 | tb = buf->tail; |
274 | /* If there is no space then tb may be NULL */ | 286 | /* If there is no space then tb may be NULL */ |
275 | if (unlikely(space == 0)) { | 287 | if (unlikely(space == 0)) { |
276 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 288 | spin_unlock_irqrestore(&buf->lock, flags); |
277 | break; | 289 | break; |
278 | } | 290 | } |
279 | memcpy(tb->char_buf_ptr + tb->used, chars, space); | 291 | memcpy(tb->char_buf_ptr + tb->used, chars, space); |
280 | memset(tb->flag_buf_ptr + tb->used, flag, space); | 292 | memset(tb->flag_buf_ptr + tb->used, flag, space); |
281 | tb->used += space; | 293 | tb->used += space; |
282 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 294 | spin_unlock_irqrestore(&buf->lock, flags); |
283 | copied += space; | 295 | copied += space; |
284 | chars += space; | 296 | chars += space; |
285 | /* There is a small chance that we need to split the data over | 297 | /* There is a small chance that we need to split the data over |
@@ -300,12 +312,13 @@ EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag); | |||
300 | * the flags array indicates the status of the character. Returns the | 312 | * the flags array indicates the status of the character. Returns the |
301 | * number added. | 313 | * number added. |
302 | * | 314 | * |
303 | * Locking: Called functions may take tty->buf.lock | 315 | * Locking: Called functions may take port->buf.lock |
304 | */ | 316 | */ |
305 | 317 | ||
306 | int tty_insert_flip_string_flags(struct tty_struct *tty, | 318 | int tty_insert_flip_string_flags(struct tty_struct *tty, |
307 | const unsigned char *chars, const char *flags, size_t size) | 319 | const unsigned char *chars, const char *flags, size_t size) |
308 | { | 320 | { |
321 | struct tty_bufhead *buf = &tty->port->buf; | ||
309 | int copied = 0; | 322 | int copied = 0; |
310 | do { | 323 | do { |
311 | int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); | 324 | int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); |
@@ -313,18 +326,18 @@ int tty_insert_flip_string_flags(struct tty_struct *tty, | |||
313 | unsigned long __flags; | 326 | unsigned long __flags; |
314 | struct tty_buffer *tb; | 327 | struct tty_buffer *tb; |
315 | 328 | ||
316 | spin_lock_irqsave(&tty->buf.lock, __flags); | 329 | spin_lock_irqsave(&buf->lock, __flags); |
317 | space = __tty_buffer_request_room(tty, goal); | 330 | space = __tty_buffer_request_room(tty->port, goal); |
318 | tb = tty->buf.tail; | 331 | tb = buf->tail; |
319 | /* If there is no space then tb may be NULL */ | 332 | /* If there is no space then tb may be NULL */ |
320 | if (unlikely(space == 0)) { | 333 | if (unlikely(space == 0)) { |
321 | spin_unlock_irqrestore(&tty->buf.lock, __flags); | 334 | spin_unlock_irqrestore(&buf->lock, __flags); |
322 | break; | 335 | break; |
323 | } | 336 | } |
324 | memcpy(tb->char_buf_ptr + tb->used, chars, space); | 337 | memcpy(tb->char_buf_ptr + tb->used, chars, space); |
325 | memcpy(tb->flag_buf_ptr + tb->used, flags, space); | 338 | memcpy(tb->flag_buf_ptr + tb->used, flags, space); |
326 | tb->used += space; | 339 | tb->used += space; |
327 | spin_unlock_irqrestore(&tty->buf.lock, __flags); | 340 | spin_unlock_irqrestore(&buf->lock, __flags); |
328 | copied += space; | 341 | copied += space; |
329 | chars += space; | 342 | chars += space; |
330 | flags += space; | 343 | flags += space; |
@@ -342,18 +355,23 @@ EXPORT_SYMBOL(tty_insert_flip_string_flags); | |||
342 | * Takes any pending buffers and transfers their ownership to the | 355 | * Takes any pending buffers and transfers their ownership to the |
343 | * ldisc side of the queue. It then schedules those characters for | 356 | * ldisc side of the queue. It then schedules those characters for |
344 | * processing by the line discipline. | 357 | * processing by the line discipline. |
358 | * Note that this function can only be used when the low_latency flag | ||
359 | * is unset. Otherwise the workqueue won't be flushed. | ||
345 | * | 360 | * |
346 | * Locking: Takes tty->buf.lock | 361 | * Locking: Takes port->buf.lock |
347 | */ | 362 | */ |
348 | 363 | ||
349 | void tty_schedule_flip(struct tty_struct *tty) | 364 | void tty_schedule_flip(struct tty_struct *tty) |
350 | { | 365 | { |
366 | struct tty_bufhead *buf = &tty->port->buf; | ||
351 | unsigned long flags; | 367 | unsigned long flags; |
352 | spin_lock_irqsave(&tty->buf.lock, flags); | 368 | WARN_ON(tty->low_latency); |
353 | if (tty->buf.tail != NULL) | 369 | |
354 | tty->buf.tail->commit = tty->buf.tail->used; | 370 | spin_lock_irqsave(&buf->lock, flags); |
355 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 371 | if (buf->tail != NULL) |
356 | schedule_work(&tty->buf.work); | 372 | buf->tail->commit = buf->tail->used; |
373 | spin_unlock_irqrestore(&buf->lock, flags); | ||
374 | schedule_work(&buf->work); | ||
357 | } | 375 | } |
358 | EXPORT_SYMBOL(tty_schedule_flip); | 376 | EXPORT_SYMBOL(tty_schedule_flip); |
359 | 377 | ||
@@ -369,26 +387,27 @@ EXPORT_SYMBOL(tty_schedule_flip); | |||
369 | * that need their own block copy routines into the buffer. There is no | 387 | * that need their own block copy routines into the buffer. There is no |
370 | * guarantee the buffer is a DMA target! | 388 | * guarantee the buffer is a DMA target! |
371 | * | 389 | * |
372 | * Locking: May call functions taking tty->buf.lock | 390 | * Locking: May call functions taking port->buf.lock |
373 | */ | 391 | */ |
374 | 392 | ||
375 | int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, | 393 | int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, |
376 | size_t size) | 394 | size_t size) |
377 | { | 395 | { |
396 | struct tty_bufhead *buf = &tty->port->buf; | ||
378 | int space; | 397 | int space; |
379 | unsigned long flags; | 398 | unsigned long flags; |
380 | struct tty_buffer *tb; | 399 | struct tty_buffer *tb; |
381 | 400 | ||
382 | spin_lock_irqsave(&tty->buf.lock, flags); | 401 | spin_lock_irqsave(&buf->lock, flags); |
383 | space = __tty_buffer_request_room(tty, size); | 402 | space = __tty_buffer_request_room(tty->port, size); |
384 | 403 | ||
385 | tb = tty->buf.tail; | 404 | tb = buf->tail; |
386 | if (likely(space)) { | 405 | if (likely(space)) { |
387 | *chars = tb->char_buf_ptr + tb->used; | 406 | *chars = tb->char_buf_ptr + tb->used; |
388 | memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); | 407 | memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); |
389 | tb->used += space; | 408 | tb->used += space; |
390 | } | 409 | } |
391 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 410 | spin_unlock_irqrestore(&buf->lock, flags); |
392 | return space; | 411 | return space; |
393 | } | 412 | } |
394 | EXPORT_SYMBOL_GPL(tty_prepare_flip_string); | 413 | EXPORT_SYMBOL_GPL(tty_prepare_flip_string); |
@@ -406,26 +425,27 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string); | |||
406 | * that need their own block copy routines into the buffer. There is no | 425 | * that need their own block copy routines into the buffer. There is no |
407 | * guarantee the buffer is a DMA target! | 426 | * guarantee the buffer is a DMA target! |
408 | * | 427 | * |
409 | * Locking: May call functions taking tty->buf.lock | 428 | * Locking: May call functions taking port->buf.lock |
410 | */ | 429 | */ |
411 | 430 | ||
412 | int tty_prepare_flip_string_flags(struct tty_struct *tty, | 431 | int tty_prepare_flip_string_flags(struct tty_struct *tty, |
413 | unsigned char **chars, char **flags, size_t size) | 432 | unsigned char **chars, char **flags, size_t size) |
414 | { | 433 | { |
434 | struct tty_bufhead *buf = &tty->port->buf; | ||
415 | int space; | 435 | int space; |
416 | unsigned long __flags; | 436 | unsigned long __flags; |
417 | struct tty_buffer *tb; | 437 | struct tty_buffer *tb; |
418 | 438 | ||
419 | spin_lock_irqsave(&tty->buf.lock, __flags); | 439 | spin_lock_irqsave(&buf->lock, __flags); |
420 | space = __tty_buffer_request_room(tty, size); | 440 | space = __tty_buffer_request_room(tty->port, size); |
421 | 441 | ||
422 | tb = tty->buf.tail; | 442 | tb = buf->tail; |
423 | if (likely(space)) { | 443 | if (likely(space)) { |
424 | *chars = tb->char_buf_ptr + tb->used; | 444 | *chars = tb->char_buf_ptr + tb->used; |
425 | *flags = tb->flag_buf_ptr + tb->used; | 445 | *flags = tb->flag_buf_ptr + tb->used; |
426 | tb->used += space; | 446 | tb->used += space; |
427 | } | 447 | } |
428 | spin_unlock_irqrestore(&tty->buf.lock, __flags); | 448 | spin_unlock_irqrestore(&buf->lock, __flags); |
429 | return space; | 449 | return space; |
430 | } | 450 | } |
431 | EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags); | 451 | EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags); |
@@ -446,20 +466,25 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags); | |||
446 | 466 | ||
447 | static void flush_to_ldisc(struct work_struct *work) | 467 | static void flush_to_ldisc(struct work_struct *work) |
448 | { | 468 | { |
449 | struct tty_struct *tty = | 469 | struct tty_port *port = container_of(work, struct tty_port, buf.work); |
450 | container_of(work, struct tty_struct, buf.work); | 470 | struct tty_bufhead *buf = &port->buf; |
471 | struct tty_struct *tty; | ||
451 | unsigned long flags; | 472 | unsigned long flags; |
452 | struct tty_ldisc *disc; | 473 | struct tty_ldisc *disc; |
453 | 474 | ||
475 | tty = port->itty; | ||
476 | if (WARN_RATELIMIT(tty == NULL, "tty is NULL")) | ||
477 | return; | ||
478 | |||
454 | disc = tty_ldisc_ref(tty); | 479 | disc = tty_ldisc_ref(tty); |
455 | if (disc == NULL) /* !TTY_LDISC */ | 480 | if (disc == NULL) /* !TTY_LDISC */ |
456 | return; | 481 | return; |
457 | 482 | ||
458 | spin_lock_irqsave(&tty->buf.lock, flags); | 483 | spin_lock_irqsave(&buf->lock, flags); |
459 | 484 | ||
460 | if (!test_and_set_bit(TTY_FLUSHING, &tty->flags)) { | 485 | if (!test_and_set_bit(TTYP_FLUSHING, &port->iflags)) { |
461 | struct tty_buffer *head; | 486 | struct tty_buffer *head; |
462 | while ((head = tty->buf.head) != NULL) { | 487 | while ((head = buf->head) != NULL) { |
463 | int count; | 488 | int count; |
464 | char *char_buf; | 489 | char *char_buf; |
465 | unsigned char *flag_buf; | 490 | unsigned char *flag_buf; |
@@ -468,14 +493,14 @@ static void flush_to_ldisc(struct work_struct *work) | |||
468 | if (!count) { | 493 | if (!count) { |
469 | if (head->next == NULL) | 494 | if (head->next == NULL) |
470 | break; | 495 | break; |
471 | tty->buf.head = head->next; | 496 | buf->head = head->next; |
472 | tty_buffer_free(tty, head); | 497 | tty_buffer_free(port, head); |
473 | continue; | 498 | continue; |
474 | } | 499 | } |
475 | /* Ldisc or user is trying to flush the buffers | 500 | /* Ldisc or user is trying to flush the buffers |
476 | we are feeding to the ldisc, stop feeding the | 501 | we are feeding to the ldisc, stop feeding the |
477 | line discipline as we want to empty the queue */ | 502 | line discipline as we want to empty the queue */ |
478 | if (test_bit(TTY_FLUSHPENDING, &tty->flags)) | 503 | if (test_bit(TTYP_FLUSHPENDING, &port->iflags)) |
479 | break; | 504 | break; |
480 | if (!tty->receive_room) | 505 | if (!tty->receive_room) |
481 | break; | 506 | break; |
@@ -484,22 +509,22 @@ static void flush_to_ldisc(struct work_struct *work) | |||
484 | char_buf = head->char_buf_ptr + head->read; | 509 | char_buf = head->char_buf_ptr + head->read; |
485 | flag_buf = head->flag_buf_ptr + head->read; | 510 | flag_buf = head->flag_buf_ptr + head->read; |
486 | head->read += count; | 511 | head->read += count; |
487 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 512 | spin_unlock_irqrestore(&buf->lock, flags); |
488 | disc->ops->receive_buf(tty, char_buf, | 513 | disc->ops->receive_buf(tty, char_buf, |
489 | flag_buf, count); | 514 | flag_buf, count); |
490 | spin_lock_irqsave(&tty->buf.lock, flags); | 515 | spin_lock_irqsave(&buf->lock, flags); |
491 | } | 516 | } |
492 | clear_bit(TTY_FLUSHING, &tty->flags); | 517 | clear_bit(TTYP_FLUSHING, &port->iflags); |
493 | } | 518 | } |
494 | 519 | ||
495 | /* We may have a deferred request to flush the input buffer, | 520 | /* We may have a deferred request to flush the input buffer, |
496 | if so pull the chain under the lock and empty the queue */ | 521 | if so pull the chain under the lock and empty the queue */ |
497 | if (test_bit(TTY_FLUSHPENDING, &tty->flags)) { | 522 | if (test_bit(TTYP_FLUSHPENDING, &port->iflags)) { |
498 | __tty_buffer_flush(tty); | 523 | __tty_buffer_flush(port); |
499 | clear_bit(TTY_FLUSHPENDING, &tty->flags); | 524 | clear_bit(TTYP_FLUSHPENDING, &port->iflags); |
500 | wake_up(&tty->read_wait); | 525 | wake_up(&tty->read_wait); |
501 | } | 526 | } |
502 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 527 | spin_unlock_irqrestore(&buf->lock, flags); |
503 | 528 | ||
504 | tty_ldisc_deref(disc); | 529 | tty_ldisc_deref(disc); |
505 | } | 530 | } |
@@ -514,7 +539,8 @@ static void flush_to_ldisc(struct work_struct *work) | |||
514 | */ | 539 | */ |
515 | void tty_flush_to_ldisc(struct tty_struct *tty) | 540 | void tty_flush_to_ldisc(struct tty_struct *tty) |
516 | { | 541 | { |
517 | flush_work(&tty->buf.work); | 542 | if (!tty->low_latency) |
543 | flush_work(&tty->port->buf.work); | ||
518 | } | 544 | } |
519 | 545 | ||
520 | /** | 546 | /** |
@@ -532,16 +558,18 @@ void tty_flush_to_ldisc(struct tty_struct *tty) | |||
532 | 558 | ||
533 | void tty_flip_buffer_push(struct tty_struct *tty) | 559 | void tty_flip_buffer_push(struct tty_struct *tty) |
534 | { | 560 | { |
561 | struct tty_bufhead *buf = &tty->port->buf; | ||
535 | unsigned long flags; | 562 | unsigned long flags; |
536 | spin_lock_irqsave(&tty->buf.lock, flags); | 563 | |
537 | if (tty->buf.tail != NULL) | 564 | spin_lock_irqsave(&buf->lock, flags); |
538 | tty->buf.tail->commit = tty->buf.tail->used; | 565 | if (buf->tail != NULL) |
539 | spin_unlock_irqrestore(&tty->buf.lock, flags); | 566 | buf->tail->commit = buf->tail->used; |
567 | spin_unlock_irqrestore(&buf->lock, flags); | ||
540 | 568 | ||
541 | if (tty->low_latency) | 569 | if (tty->low_latency) |
542 | flush_to_ldisc(&tty->buf.work); | 570 | flush_to_ldisc(&buf->work); |
543 | else | 571 | else |
544 | schedule_work(&tty->buf.work); | 572 | schedule_work(&buf->work); |
545 | } | 573 | } |
546 | EXPORT_SYMBOL(tty_flip_buffer_push); | 574 | EXPORT_SYMBOL(tty_flip_buffer_push); |
547 | 575 | ||
@@ -555,13 +583,15 @@ EXPORT_SYMBOL(tty_flip_buffer_push); | |||
555 | * Locking: none | 583 | * Locking: none |
556 | */ | 584 | */ |
557 | 585 | ||
558 | void tty_buffer_init(struct tty_struct *tty) | 586 | void tty_buffer_init(struct tty_port *port) |
559 | { | 587 | { |
560 | spin_lock_init(&tty->buf.lock); | 588 | struct tty_bufhead *buf = &port->buf; |
561 | tty->buf.head = NULL; | 589 | |
562 | tty->buf.tail = NULL; | 590 | spin_lock_init(&buf->lock); |
563 | tty->buf.free = NULL; | 591 | buf->head = NULL; |
564 | tty->buf.memory_used = 0; | 592 | buf->tail = NULL; |
565 | INIT_WORK(&tty->buf.work, flush_to_ldisc); | 593 | buf->free = NULL; |
594 | buf->memory_used = 0; | ||
595 | INIT_WORK(&buf->work, flush_to_ldisc); | ||
566 | } | 596 | } |
567 | 597 | ||
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 2ea176b2280e..a3eba7f359ed 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -186,7 +186,6 @@ void free_tty_struct(struct tty_struct *tty) | |||
186 | if (tty->dev) | 186 | if (tty->dev) |
187 | put_device(tty->dev); | 187 | put_device(tty->dev); |
188 | kfree(tty->write_buf); | 188 | kfree(tty->write_buf); |
189 | tty_buffer_free_all(tty); | ||
190 | tty->magic = 0xDEADDEAD; | 189 | tty->magic = 0xDEADDEAD; |
191 | kfree(tty); | 190 | kfree(tty); |
192 | } | 191 | } |
@@ -1417,6 +1416,8 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx) | |||
1417 | "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n", | 1416 | "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n", |
1418 | __func__, tty->driver->name); | 1417 | __func__, tty->driver->name); |
1419 | 1418 | ||
1419 | tty->port->itty = tty; | ||
1420 | |||
1420 | /* | 1421 | /* |
1421 | * Structures all installed ... call the ldisc open routines. | 1422 | * Structures all installed ... call the ldisc open routines. |
1422 | * If we fail here just call release_tty to clean up. No need | 1423 | * If we fail here just call release_tty to clean up. No need |
@@ -1552,6 +1553,7 @@ static void release_tty(struct tty_struct *tty, int idx) | |||
1552 | tty->ops->shutdown(tty); | 1553 | tty->ops->shutdown(tty); |
1553 | tty_free_termios(tty); | 1554 | tty_free_termios(tty); |
1554 | tty_driver_remove_tty(tty->driver, tty); | 1555 | tty_driver_remove_tty(tty->driver, tty); |
1556 | tty->port->itty = NULL; | ||
1555 | 1557 | ||
1556 | if (tty->link) | 1558 | if (tty->link) |
1557 | tty_kref_put(tty->link); | 1559 | tty_kref_put(tty->link); |
@@ -1625,7 +1627,6 @@ int tty_release(struct inode *inode, struct file *filp) | |||
1625 | struct tty_struct *tty = file_tty(filp); | 1627 | struct tty_struct *tty = file_tty(filp); |
1626 | struct tty_struct *o_tty; | 1628 | struct tty_struct *o_tty; |
1627 | int pty_master, tty_closing, o_tty_closing, do_sleep; | 1629 | int pty_master, tty_closing, o_tty_closing, do_sleep; |
1628 | int devpts; | ||
1629 | int idx; | 1630 | int idx; |
1630 | char buf[64]; | 1631 | char buf[64]; |
1631 | 1632 | ||
@@ -1640,7 +1641,6 @@ int tty_release(struct inode *inode, struct file *filp) | |||
1640 | idx = tty->index; | 1641 | idx = tty->index; |
1641 | pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY && | 1642 | pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY && |
1642 | tty->driver->subtype == PTY_TYPE_MASTER); | 1643 | tty->driver->subtype == PTY_TYPE_MASTER); |
1643 | devpts = (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) != 0; | ||
1644 | /* Review: parallel close */ | 1644 | /* Review: parallel close */ |
1645 | o_tty = tty->link; | 1645 | o_tty = tty->link; |
1646 | 1646 | ||
@@ -1799,9 +1799,6 @@ int tty_release(struct inode *inode, struct file *filp) | |||
1799 | release_tty(tty, idx); | 1799 | release_tty(tty, idx); |
1800 | mutex_unlock(&tty_mutex); | 1800 | mutex_unlock(&tty_mutex); |
1801 | 1801 | ||
1802 | /* Make this pty number available for reallocation */ | ||
1803 | if (devpts) | ||
1804 | devpts_kill_index(inode, idx); | ||
1805 | return 0; | 1802 | return 0; |
1806 | } | 1803 | } |
1807 | 1804 | ||
@@ -2937,19 +2934,13 @@ void initialize_tty_struct(struct tty_struct *tty, | |||
2937 | tty_ldisc_init(tty); | 2934 | tty_ldisc_init(tty); |
2938 | tty->session = NULL; | 2935 | tty->session = NULL; |
2939 | tty->pgrp = NULL; | 2936 | tty->pgrp = NULL; |
2940 | tty->overrun_time = jiffies; | ||
2941 | tty_buffer_init(tty); | ||
2942 | mutex_init(&tty->legacy_mutex); | 2937 | mutex_init(&tty->legacy_mutex); |
2943 | mutex_init(&tty->termios_mutex); | 2938 | mutex_init(&tty->termios_mutex); |
2944 | mutex_init(&tty->ldisc_mutex); | 2939 | mutex_init(&tty->ldisc_mutex); |
2945 | init_waitqueue_head(&tty->write_wait); | 2940 | init_waitqueue_head(&tty->write_wait); |
2946 | init_waitqueue_head(&tty->read_wait); | 2941 | init_waitqueue_head(&tty->read_wait); |
2947 | INIT_WORK(&tty->hangup_work, do_tty_hangup); | 2942 | INIT_WORK(&tty->hangup_work, do_tty_hangup); |
2948 | mutex_init(&tty->atomic_read_lock); | ||
2949 | mutex_init(&tty->atomic_write_lock); | 2943 | mutex_init(&tty->atomic_write_lock); |
2950 | mutex_init(&tty->output_lock); | ||
2951 | mutex_init(&tty->echo_lock); | ||
2952 | spin_lock_init(&tty->read_lock); | ||
2953 | spin_lock_init(&tty->ctrl_lock); | 2944 | spin_lock_init(&tty->ctrl_lock); |
2954 | INIT_LIST_HEAD(&tty->tty_files); | 2945 | INIT_LIST_HEAD(&tty->tty_files); |
2955 | INIT_WORK(&tty->SAK_work, do_SAK_work); | 2946 | INIT_WORK(&tty->SAK_work, do_SAK_work); |
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index 0f2a2c5e704c..f4e6754525dc 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c | |||
@@ -512,7 +512,7 @@ static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) | |||
512 | static int tty_ldisc_halt(struct tty_struct *tty) | 512 | static int tty_ldisc_halt(struct tty_struct *tty) |
513 | { | 513 | { |
514 | clear_bit(TTY_LDISC, &tty->flags); | 514 | clear_bit(TTY_LDISC, &tty->flags); |
515 | return cancel_work_sync(&tty->buf.work); | 515 | return cancel_work_sync(&tty->port->buf.work); |
516 | } | 516 | } |
517 | 517 | ||
518 | /** | 518 | /** |
@@ -525,7 +525,7 @@ static void tty_ldisc_flush_works(struct tty_struct *tty) | |||
525 | { | 525 | { |
526 | flush_work(&tty->hangup_work); | 526 | flush_work(&tty->hangup_work); |
527 | flush_work(&tty->SAK_work); | 527 | flush_work(&tty->SAK_work); |
528 | flush_work(&tty->buf.work); | 528 | flush_work(&tty->port->buf.work); |
529 | } | 529 | } |
530 | 530 | ||
531 | /** | 531 | /** |
@@ -704,9 +704,9 @@ enable: | |||
704 | /* Restart the work queue in case no characters kick it off. Safe if | 704 | /* Restart the work queue in case no characters kick it off. Safe if |
705 | already running */ | 705 | already running */ |
706 | if (work) | 706 | if (work) |
707 | schedule_work(&tty->buf.work); | 707 | schedule_work(&tty->port->buf.work); |
708 | if (o_work) | 708 | if (o_work) |
709 | schedule_work(&o_tty->buf.work); | 709 | schedule_work(&o_tty->port->buf.work); |
710 | mutex_unlock(&tty->ldisc_mutex); | 710 | mutex_unlock(&tty->ldisc_mutex); |
711 | tty_unlock(tty); | 711 | tty_unlock(tty); |
712 | return retval; | 712 | return retval; |
@@ -817,7 +817,7 @@ void tty_ldisc_hangup(struct tty_struct *tty) | |||
817 | */ | 817 | */ |
818 | clear_bit(TTY_LDISC, &tty->flags); | 818 | clear_bit(TTY_LDISC, &tty->flags); |
819 | tty_unlock(tty); | 819 | tty_unlock(tty); |
820 | cancel_work_sync(&tty->buf.work); | 820 | cancel_work_sync(&tty->port->buf.work); |
821 | mutex_unlock(&tty->ldisc_mutex); | 821 | mutex_unlock(&tty->ldisc_mutex); |
822 | retry: | 822 | retry: |
823 | tty_lock(tty); | 823 | tty_lock(tty); |
@@ -897,6 +897,11 @@ int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty) | |||
897 | 897 | ||
898 | static void tty_ldisc_kill(struct tty_struct *tty) | 898 | static void tty_ldisc_kill(struct tty_struct *tty) |
899 | { | 899 | { |
900 | /* There cannot be users from userspace now. But there still might be | ||
901 | * drivers holding a reference via tty_ldisc_ref. Do not steal them the | ||
902 | * ldisc until they are done. */ | ||
903 | tty_ldisc_wait_idle(tty, MAX_SCHEDULE_TIMEOUT); | ||
904 | |||
900 | mutex_lock(&tty->ldisc_mutex); | 905 | mutex_lock(&tty->ldisc_mutex); |
901 | /* | 906 | /* |
902 | * Now kill off the ldisc | 907 | * Now kill off the ldisc |
diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index d7bdd8d0c23f..416b42f7c346 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c | |||
@@ -21,6 +21,7 @@ | |||
21 | void tty_port_init(struct tty_port *port) | 21 | void tty_port_init(struct tty_port *port) |
22 | { | 22 | { |
23 | memset(port, 0, sizeof(*port)); | 23 | memset(port, 0, sizeof(*port)); |
24 | tty_buffer_init(port); | ||
24 | init_waitqueue_head(&port->open_wait); | 25 | init_waitqueue_head(&port->open_wait); |
25 | init_waitqueue_head(&port->close_wait); | 26 | init_waitqueue_head(&port->close_wait); |
26 | init_waitqueue_head(&port->delta_msr_wait); | 27 | init_waitqueue_head(&port->delta_msr_wait); |
@@ -126,6 +127,7 @@ static void tty_port_destructor(struct kref *kref) | |||
126 | struct tty_port *port = container_of(kref, struct tty_port, kref); | 127 | struct tty_port *port = container_of(kref, struct tty_port, kref); |
127 | if (port->xmit_buf) | 128 | if (port->xmit_buf) |
128 | free_page((unsigned long)port->xmit_buf); | 129 | free_page((unsigned long)port->xmit_buf); |
130 | tty_buffer_free_all(port); | ||
129 | if (port->ops->destruct) | 131 | if (port->ops->destruct) |
130 | port->ops->destruct(port); | 132 | port->ops->destruct(port); |
131 | else | 133 | else |
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c index 8e9b4be97a2d..60b7b6926059 100644 --- a/drivers/tty/vt/selection.c +++ b/drivers/tty/vt/selection.c | |||
@@ -341,15 +341,11 @@ int paste_selection(struct tty_struct *tty) | |||
341 | struct tty_ldisc *ld; | 341 | struct tty_ldisc *ld; |
342 | DECLARE_WAITQUEUE(wait, current); | 342 | DECLARE_WAITQUEUE(wait, current); |
343 | 343 | ||
344 | |||
345 | console_lock(); | 344 | console_lock(); |
346 | poke_blanked_console(); | 345 | poke_blanked_console(); |
347 | console_unlock(); | 346 | console_unlock(); |
348 | 347 | ||
349 | /* FIXME: wtf is this supposed to achieve ? */ | 348 | ld = tty_ldisc_ref_wait(tty); |
350 | ld = tty_ldisc_ref(tty); | ||
351 | if (!ld) | ||
352 | ld = tty_ldisc_ref_wait(tty); | ||
353 | 349 | ||
354 | /* FIXME: this is completely unsafe */ | 350 | /* FIXME: this is completely unsafe */ |
355 | add_wait_queue(&vc->paste_wait, &wait); | 351 | add_wait_queue(&vc->paste_wait, &wait); |
@@ -361,8 +357,7 @@ int paste_selection(struct tty_struct *tty) | |||
361 | } | 357 | } |
362 | count = sel_buffer_lth - pasted; | 358 | count = sel_buffer_lth - pasted; |
363 | count = min(count, tty->receive_room); | 359 | count = min(count, tty->receive_room); |
364 | tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted, | 360 | ld->ops->receive_buf(tty, sel_buffer + pasted, NULL, count); |
365 | NULL, count); | ||
366 | pasted += count; | 361 | pasted += count; |
367 | } | 362 | } |
368 | remove_wait_queue(&vc->paste_wait, &wait); | 363 | remove_wait_queue(&vc->paste_wait, &wait); |
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig index 6f3ea9bbc818..c48b93813fc1 100644 --- a/drivers/uio/Kconfig +++ b/drivers/uio/Kconfig | |||
@@ -97,6 +97,7 @@ config UIO_NETX | |||
97 | config UIO_PRUSS | 97 | config UIO_PRUSS |
98 | tristate "Texas Instruments PRUSS driver" | 98 | tristate "Texas Instruments PRUSS driver" |
99 | depends on ARCH_DAVINCI_DA850 | 99 | depends on ARCH_DAVINCI_DA850 |
100 | select GENERIC_ALLOCATOR | ||
100 | help | 101 | help |
101 | PRUSS driver for OMAPL138/DA850/AM18XX devices | 102 | PRUSS driver for OMAPL138/DA850/AM18XX devices |
102 | PRUSS driver requires user space components, examples and user space | 103 | PRUSS driver requires user space components, examples and user space |
diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c index 33a7a273b453..f8738de342be 100644 --- a/drivers/uio/uio_pruss.c +++ b/drivers/uio/uio_pruss.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
26 | #include <linux/dma-mapping.h> | 26 | #include <linux/dma-mapping.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <mach/sram.h> | 28 | #include <linux/genalloc.h> |
29 | 29 | ||
30 | #define DRV_NAME "pruss_uio" | 30 | #define DRV_NAME "pruss_uio" |
31 | #define DRV_VERSION "1.0" | 31 | #define DRV_VERSION "1.0" |
@@ -65,10 +65,11 @@ struct uio_pruss_dev { | |||
65 | dma_addr_t sram_paddr; | 65 | dma_addr_t sram_paddr; |
66 | dma_addr_t ddr_paddr; | 66 | dma_addr_t ddr_paddr; |
67 | void __iomem *prussio_vaddr; | 67 | void __iomem *prussio_vaddr; |
68 | void *sram_vaddr; | 68 | unsigned long sram_vaddr; |
69 | void *ddr_vaddr; | 69 | void *ddr_vaddr; |
70 | unsigned int hostirq_start; | 70 | unsigned int hostirq_start; |
71 | unsigned int pintc_base; | 71 | unsigned int pintc_base; |
72 | struct gen_pool *sram_pool; | ||
72 | }; | 73 | }; |
73 | 74 | ||
74 | static irqreturn_t pruss_handler(int irq, struct uio_info *info) | 75 | static irqreturn_t pruss_handler(int irq, struct uio_info *info) |
@@ -106,7 +107,9 @@ static void pruss_cleanup(struct platform_device *dev, | |||
106 | gdev->ddr_paddr); | 107 | gdev->ddr_paddr); |
107 | } | 108 | } |
108 | if (gdev->sram_vaddr) | 109 | if (gdev->sram_vaddr) |
109 | sram_free(gdev->sram_vaddr, sram_pool_sz); | 110 | gen_pool_free(gdev->sram_pool, |
111 | gdev->sram_vaddr, | ||
112 | sram_pool_sz); | ||
110 | kfree(gdev->info); | 113 | kfree(gdev->info); |
111 | clk_put(gdev->pruss_clk); | 114 | clk_put(gdev->pruss_clk); |
112 | kfree(gdev); | 115 | kfree(gdev); |
@@ -152,10 +155,17 @@ static int __devinit pruss_probe(struct platform_device *dev) | |||
152 | goto out_free; | 155 | goto out_free; |
153 | } | 156 | } |
154 | 157 | ||
155 | gdev->sram_vaddr = sram_alloc(sram_pool_sz, &(gdev->sram_paddr)); | 158 | if (pdata->sram_pool) { |
156 | if (!gdev->sram_vaddr) { | 159 | gdev->sram_pool = pdata->sram_pool; |
157 | dev_err(&dev->dev, "Could not allocate SRAM pool\n"); | 160 | gdev->sram_vaddr = |
158 | goto out_free; | 161 | gen_pool_alloc(gdev->sram_pool, sram_pool_sz); |
162 | if (!gdev->sram_vaddr) { | ||
163 | dev_err(&dev->dev, "Could not allocate SRAM pool\n"); | ||
164 | goto out_free; | ||
165 | } | ||
166 | gdev->sram_paddr = | ||
167 | gen_pool_virt_to_phys(gdev->sram_pool, | ||
168 | gdev->sram_vaddr); | ||
159 | } | 169 | } |
160 | 170 | ||
161 | gdev->ddr_vaddr = dma_alloc_coherent(&dev->dev, extram_pool_sz, | 171 | gdev->ddr_vaddr = dma_alloc_coherent(&dev->dev, extram_pool_sz, |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 2a4749c3eb3f..23afa06b65a4 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <asm/unaligned.h> | 44 | #include <asm/unaligned.h> |
45 | #include <asm/mach-types.h> | 45 | #include <asm/mach-types.h> |
46 | 46 | ||
47 | #include <plat/dma.h> | 47 | #include <plat-omap/dma-omap.h> |
48 | 48 | ||
49 | #include <mach/usb.h> | 49 | #include <mach/usb.h> |
50 | 50 | ||
@@ -61,6 +61,8 @@ | |||
61 | #define DRIVER_DESC "OMAP UDC driver" | 61 | #define DRIVER_DESC "OMAP UDC driver" |
62 | #define DRIVER_VERSION "4 October 2004" | 62 | #define DRIVER_VERSION "4 October 2004" |
63 | 63 | ||
64 | #define OMAP_DMA_USB_W2FC_TX0 29 | ||
65 | |||
64 | /* | 66 | /* |
65 | * The OMAP UDC needs _very_ early endpoint setup: before enabling the | 67 | * The OMAP UDC needs _very_ early endpoint setup: before enabling the |
66 | * D+ pullup to allow enumeration. That's too early for the gadget | 68 | * D+ pullup to allow enumeration. That's too early for the gadget |
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c index 4a08fc0b27c9..8e58a5fa1994 100644 --- a/drivers/usb/host/ehci-mxc.c +++ b/drivers/usb/host/ehci-mxc.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/usb/ulpi.h> | 24 | #include <linux/usb/ulpi.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | 26 | ||
27 | #include <mach/hardware.h> | ||
28 | #include <linux/platform_data/usb-ehci-mxc.h> | 27 | #include <linux/platform_data/usb-ehci-mxc.h> |
29 | 28 | ||
30 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index d7fe287d0678..0d5ac36fdf47 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c | |||
@@ -39,12 +39,13 @@ | |||
39 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/usb/ulpi.h> | 41 | #include <linux/usb/ulpi.h> |
42 | #include <plat/usb.h> | ||
43 | #include <linux/regulator/consumer.h> | 42 | #include <linux/regulator/consumer.h> |
44 | #include <linux/pm_runtime.h> | 43 | #include <linux/pm_runtime.h> |
45 | #include <linux/gpio.h> | 44 | #include <linux/gpio.h> |
46 | #include <linux/clk.h> | 45 | #include <linux/clk.h> |
47 | 46 | ||
47 | #include <linux/platform_data/usb-omap.h> | ||
48 | |||
48 | /* EHCI Register Set */ | 49 | /* EHCI Register Set */ |
49 | #define EHCI_INSNREG04 (0xA0) | 50 | #define EHCI_INSNREG04 (0xA0) |
50 | #define EHCI_INSNREG04_DISABLE_UNSUSPEND (1 << 5) | 51 | #define EHCI_INSNREG04_DISABLE_UNSUSPEND (1 << 5) |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 4531d03503c3..439e6e4f2d6b 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <asm/mach-types.h> | 25 | #include <asm/mach-types.h> |
26 | 26 | ||
27 | #include <mach/mux.h> | 27 | #include <mach/mux.h> |
28 | #include <plat/fpga.h> | ||
29 | 28 | ||
30 | #include <mach/hardware.h> | 29 | #include <mach/hardware.h> |
31 | #include <mach/irqs.h> | 30 | #include <mach/irqs.h> |
@@ -93,14 +92,14 @@ static int omap_ohci_transceiver_power(int on) | |||
93 | { | 92 | { |
94 | if (on) { | 93 | if (on) { |
95 | if (machine_is_omap_innovator() && cpu_is_omap1510()) | 94 | if (machine_is_omap_innovator() && cpu_is_omap1510()) |
96 | fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) | 95 | __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL) |
97 | | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), | 96 | | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), |
98 | INNOVATOR_FPGA_CAM_USB_CONTROL); | 97 | INNOVATOR_FPGA_CAM_USB_CONTROL); |
99 | else if (machine_is_omap_osk()) | 98 | else if (machine_is_omap_osk()) |
100 | tps65010_set_gpio_out_value(GPIO1, LOW); | 99 | tps65010_set_gpio_out_value(GPIO1, LOW); |
101 | } else { | 100 | } else { |
102 | if (machine_is_omap_innovator() && cpu_is_omap1510()) | 101 | if (machine_is_omap_innovator() && cpu_is_omap1510()) |
103 | fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) | 102 | __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL) |
104 | & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), | 103 | & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), |
105 | INNOVATOR_FPGA_CAM_USB_CONTROL); | 104 | INNOVATOR_FPGA_CAM_USB_CONTROL); |
106 | else if (machine_is_omap_osk()) | 105 | else if (machine_is_omap_osk()) |
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c index 1b8133b6e451..bd7803dce9be 100644 --- a/drivers/usb/host/ohci-omap3.c +++ b/drivers/usb/host/ohci-omap3.c | |||
@@ -30,7 +30,6 @@ | |||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
33 | #include <plat/usb.h> | ||
34 | #include <linux/pm_runtime.h> | 33 | #include <linux/pm_runtime.h> |
35 | 34 | ||
36 | /*-------------------------------------------------------------------------*/ | 35 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index c964d6af178b..a87cdd2387cf 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -34,8 +34,7 @@ | |||
34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
36 | #include <linux/usb/nop-usb-xceiv.h> | 36 | #include <linux/usb/nop-usb-xceiv.h> |
37 | 37 | #include <linux/platform_data/usb-omap.h> | |
38 | #include <plat/usb.h> | ||
39 | 38 | ||
40 | #include "musb_core.h" | 39 | #include "musb_core.h" |
41 | 40 | ||
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index ff5f112053d2..aa34f22181c1 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c | |||
@@ -38,13 +38,12 @@ | |||
38 | #include <linux/pm_runtime.h> | 38 | #include <linux/pm_runtime.h> |
39 | #include <linux/module.h> | 39 | #include <linux/module.h> |
40 | #include <linux/usb/nop-usb-xceiv.h> | 40 | #include <linux/usb/nop-usb-xceiv.h> |
41 | #include <linux/platform_data/usb-omap.h> | ||
41 | 42 | ||
42 | #include <linux/of.h> | 43 | #include <linux/of.h> |
43 | #include <linux/of_device.h> | 44 | #include <linux/of_device.h> |
44 | #include <linux/of_address.h> | 45 | #include <linux/of_address.h> |
45 | 46 | ||
46 | #include <plat/usb.h> | ||
47 | |||
48 | #include "musb_core.h" | 47 | #include "musb_core.h" |
49 | 48 | ||
50 | #ifdef CONFIG_OF | 49 | #ifdef CONFIG_OF |
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h index b85f3973e78c..8ef656659fcb 100644 --- a/drivers/usb/musb/omap2430.h +++ b/drivers/usb/musb/omap2430.h | |||
@@ -10,7 +10,7 @@ | |||
10 | #ifndef __MUSB_OMAP243X_H__ | 10 | #ifndef __MUSB_OMAP243X_H__ |
11 | #define __MUSB_OMAP243X_H__ | 11 | #define __MUSB_OMAP243X_H__ |
12 | 12 | ||
13 | #include <plat/usb.h> | 13 | #include <linux/platform_data/usb-omap.h> |
14 | 14 | ||
15 | /* | 15 | /* |
16 | * OMAP2430-specific definitions | 16 | * OMAP2430-specific definitions |
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c index 7a62b95dac24..bfca114f7c56 100644 --- a/drivers/usb/musb/tusb6010_omap.c +++ b/drivers/usb/musb/tusb6010_omap.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <plat/dma.h> | 19 | #include <plat-omap/dma-omap.h> |
20 | 20 | ||
21 | #include "musb_core.h" | 21 | #include "musb_core.h" |
22 | #include "tusb6010.h" | 22 | #include "tusb6010.h" |
@@ -25,6 +25,13 @@ | |||
25 | 25 | ||
26 | #define MAX_DMAREQ 5 /* REVISIT: Really 6, but req5 not OK */ | 26 | #define MAX_DMAREQ 5 /* REVISIT: Really 6, but req5 not OK */ |
27 | 27 | ||
28 | #define OMAP24XX_DMA_EXT_DMAREQ0 2 | ||
29 | #define OMAP24XX_DMA_EXT_DMAREQ1 3 | ||
30 | #define OMAP242X_DMA_EXT_DMAREQ2 14 | ||
31 | #define OMAP242X_DMA_EXT_DMAREQ3 15 | ||
32 | #define OMAP242X_DMA_EXT_DMAREQ4 16 | ||
33 | #define OMAP242X_DMA_EXT_DMAREQ5 64 | ||
34 | |||
28 | struct tusb_omap_dma_ch { | 35 | struct tusb_omap_dma_ch { |
29 | struct musb *musb; | 36 | struct musb *musb; |
30 | void __iomem *tbase; | 37 | void __iomem *tbase; |
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index cf2688de0832..e501dbc966b3 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/math64.h> | 33 | #include <linux/math64.h> |
34 | 34 | ||
35 | #include <linux/platform_data/video-imxfb.h> | 35 | #include <linux/platform_data/video-imxfb.h> |
36 | #include <mach/hardware.h> | ||
37 | 36 | ||
38 | /* | 37 | /* |
39 | * Complain if VAR is out of range. | 38 | * Complain if VAR is out of range. |
@@ -53,8 +52,8 @@ | |||
53 | #define LCDC_SIZE 0x04 | 52 | #define LCDC_SIZE 0x04 |
54 | #define SIZE_XMAX(x) ((((x) >> 4) & 0x3f) << 20) | 53 | #define SIZE_XMAX(x) ((((x) >> 4) & 0x3f) << 20) |
55 | 54 | ||
56 | #define YMAX_MASK (cpu_is_mx1() ? 0x1ff : 0x3ff) | 55 | #define YMAX_MASK_IMX1 0x1ff |
57 | #define SIZE_YMAX(y) ((y) & YMAX_MASK) | 56 | #define YMAX_MASK_IMX21 0x3ff |
58 | 57 | ||
59 | #define LCDC_VPW 0x08 | 58 | #define LCDC_VPW 0x08 |
60 | #define VPW_VPW(x) ((x) & 0x3ff) | 59 | #define VPW_VPW(x) ((x) & 0x3ff) |
@@ -128,12 +127,18 @@ struct imxfb_rgb { | |||
128 | struct fb_bitfield transp; | 127 | struct fb_bitfield transp; |
129 | }; | 128 | }; |
130 | 129 | ||
130 | enum imxfb_type { | ||
131 | IMX1_FB, | ||
132 | IMX21_FB, | ||
133 | }; | ||
134 | |||
131 | struct imxfb_info { | 135 | struct imxfb_info { |
132 | struct platform_device *pdev; | 136 | struct platform_device *pdev; |
133 | void __iomem *regs; | 137 | void __iomem *regs; |
134 | struct clk *clk_ipg; | 138 | struct clk *clk_ipg; |
135 | struct clk *clk_ahb; | 139 | struct clk *clk_ahb; |
136 | struct clk *clk_per; | 140 | struct clk *clk_per; |
141 | enum imxfb_type devtype; | ||
137 | 142 | ||
138 | /* | 143 | /* |
139 | * These are the addresses we mapped | 144 | * These are the addresses we mapped |
@@ -168,6 +173,24 @@ struct imxfb_info { | |||
168 | void (*backlight_power)(int); | 173 | void (*backlight_power)(int); |
169 | }; | 174 | }; |
170 | 175 | ||
176 | static struct platform_device_id imxfb_devtype[] = { | ||
177 | { | ||
178 | .name = "imx1-fb", | ||
179 | .driver_data = IMX1_FB, | ||
180 | }, { | ||
181 | .name = "imx21-fb", | ||
182 | .driver_data = IMX21_FB, | ||
183 | }, { | ||
184 | /* sentinel */ | ||
185 | } | ||
186 | }; | ||
187 | MODULE_DEVICE_TABLE(platform, imxfb_devtype); | ||
188 | |||
189 | static inline int is_imx1_fb(struct imxfb_info *fbi) | ||
190 | { | ||
191 | return fbi->devtype == IMX1_FB; | ||
192 | } | ||
193 | |||
171 | #define IMX_NAME "IMX" | 194 | #define IMX_NAME "IMX" |
172 | 195 | ||
173 | /* | 196 | /* |
@@ -366,7 +389,7 @@ static int imxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | |||
366 | break; | 389 | break; |
367 | case 16: | 390 | case 16: |
368 | default: | 391 | default: |
369 | if (cpu_is_mx1()) | 392 | if (is_imx1_fb(fbi)) |
370 | pcr |= PCR_BPIX_12; | 393 | pcr |= PCR_BPIX_12; |
371 | else | 394 | else |
372 | pcr |= PCR_BPIX_16; | 395 | pcr |= PCR_BPIX_16; |
@@ -596,6 +619,7 @@ static struct fb_ops imxfb_ops = { | |||
596 | static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info) | 619 | static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info) |
597 | { | 620 | { |
598 | struct imxfb_info *fbi = info->par; | 621 | struct imxfb_info *fbi = info->par; |
622 | u32 ymax_mask = is_imx1_fb(fbi) ? YMAX_MASK_IMX1 : YMAX_MASK_IMX21; | ||
599 | 623 | ||
600 | pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n", | 624 | pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n", |
601 | var->xres, var->hsync_len, | 625 | var->xres, var->hsync_len, |
@@ -617,7 +641,7 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf | |||
617 | if (var->right_margin > 255) | 641 | if (var->right_margin > 255) |
618 | printk(KERN_ERR "%s: invalid right_margin %d\n", | 642 | printk(KERN_ERR "%s: invalid right_margin %d\n", |
619 | info->fix.id, var->right_margin); | 643 | info->fix.id, var->right_margin); |
620 | if (var->yres < 1 || var->yres > YMAX_MASK) | 644 | if (var->yres < 1 || var->yres > ymax_mask) |
621 | printk(KERN_ERR "%s: invalid yres %d\n", | 645 | printk(KERN_ERR "%s: invalid yres %d\n", |
622 | info->fix.id, var->yres); | 646 | info->fix.id, var->yres); |
623 | if (var->vsync_len > 100) | 647 | if (var->vsync_len > 100) |
@@ -645,7 +669,7 @@ static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *inf | |||
645 | VCR_V_WAIT_2(var->upper_margin), | 669 | VCR_V_WAIT_2(var->upper_margin), |
646 | fbi->regs + LCDC_VCR); | 670 | fbi->regs + LCDC_VCR); |
647 | 671 | ||
648 | writel(SIZE_XMAX(var->xres) | SIZE_YMAX(var->yres), | 672 | writel(SIZE_XMAX(var->xres) | (var->yres & ymax_mask), |
649 | fbi->regs + LCDC_SIZE); | 673 | fbi->regs + LCDC_SIZE); |
650 | 674 | ||
651 | writel(fbi->pcr, fbi->regs + LCDC_PCR); | 675 | writel(fbi->pcr, fbi->regs + LCDC_PCR); |
@@ -765,6 +789,7 @@ static int __init imxfb_probe(struct platform_device *pdev) | |||
765 | return -ENOMEM; | 789 | return -ENOMEM; |
766 | 790 | ||
767 | fbi = info->par; | 791 | fbi = info->par; |
792 | fbi->devtype = pdev->id_entry->driver_data; | ||
768 | 793 | ||
769 | if (!fb_mode) | 794 | if (!fb_mode) |
770 | fb_mode = pdata->mode[0].mode.name; | 795 | fb_mode = pdata->mode[0].mode.name; |
@@ -939,6 +964,7 @@ static struct platform_driver imxfb_driver = { | |||
939 | .driver = { | 964 | .driver = { |
940 | .name = DRIVER_NAME, | 965 | .name = DRIVER_NAME, |
941 | }, | 966 | }, |
967 | .id_table = imxfb_devtype, | ||
942 | }; | 968 | }; |
943 | 969 | ||
944 | static int imxfb_setup(void) | 970 | static int imxfb_setup(void) |
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c index ce1d452464ed..736887208574 100644 --- a/drivers/video/mx3fb.c +++ b/drivers/video/mx3fb.c | |||
@@ -26,10 +26,9 @@ | |||
26 | #include <linux/console.h> | 26 | #include <linux/console.h> |
27 | #include <linux/clk.h> | 27 | #include <linux/clk.h> |
28 | #include <linux/mutex.h> | 28 | #include <linux/mutex.h> |
29 | #include <linux/dma/ipu-dma.h> | ||
29 | 30 | ||
30 | #include <linux/platform_data/dma-imx.h> | 31 | #include <linux/platform_data/dma-imx.h> |
31 | #include <mach/hardware.h> | ||
32 | #include <mach/ipu.h> | ||
33 | #include <linux/platform_data/video-mx3fb.h> | 32 | #include <linux/platform_data/video-mx3fb.h> |
34 | 33 | ||
35 | #include <asm/io.h> | 34 | #include <asm/io.h> |
diff --git a/drivers/video/omap/lcd_inn1510.c b/drivers/video/omap/lcd_inn1510.c index b38b1dd15ce3..2ee423279e35 100644 --- a/drivers/video/omap/lcd_inn1510.c +++ b/drivers/video/omap/lcd_inn1510.c | |||
@@ -23,7 +23,8 @@ | |||
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | 25 | ||
26 | #include <plat/fpga.h> | 26 | #include <mach/hardware.h> |
27 | |||
27 | #include "omapfb.h" | 28 | #include "omapfb.h" |
28 | 29 | ||
29 | static int innovator1510_panel_init(struct lcd_panel *panel, | 30 | static int innovator1510_panel_init(struct lcd_panel *panel, |
@@ -38,13 +39,13 @@ static void innovator1510_panel_cleanup(struct lcd_panel *panel) | |||
38 | 39 | ||
39 | static int innovator1510_panel_enable(struct lcd_panel *panel) | 40 | static int innovator1510_panel_enable(struct lcd_panel *panel) |
40 | { | 41 | { |
41 | fpga_write(0x7, OMAP1510_FPGA_LCD_PANEL_CONTROL); | 42 | __raw_writeb(0x7, OMAP1510_FPGA_LCD_PANEL_CONTROL); |
42 | return 0; | 43 | return 0; |
43 | } | 44 | } |
44 | 45 | ||
45 | static void innovator1510_panel_disable(struct lcd_panel *panel) | 46 | static void innovator1510_panel_disable(struct lcd_panel *panel) |
46 | { | 47 | { |
47 | fpga_write(0x0, OMAP1510_FPGA_LCD_PANEL_CONTROL); | 48 | __raw_writeb(0x0, OMAP1510_FPGA_LCD_PANEL_CONTROL); |
48 | } | 49 | } |
49 | 50 | ||
50 | static unsigned long innovator1510_panel_get_caps(struct lcd_panel *panel) | 51 | static unsigned long innovator1510_panel_get_caps(struct lcd_panel *panel) |
diff --git a/drivers/video/omap/lcdc.c b/drivers/video/omap/lcdc.c index 7767338f8b14..c39d6e46f8c5 100644 --- a/drivers/video/omap/lcdc.c +++ b/drivers/video/omap/lcdc.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/gfp.h> | 31 | #include <linux/gfp.h> |
32 | 32 | ||
33 | #include <mach/lcdc.h> | 33 | #include <mach/lcdc.h> |
34 | #include <plat/dma.h> | 34 | #include <plat-omap/dma-omap.h> |
35 | 35 | ||
36 | #include <asm/mach-types.h> | 36 | #include <asm/mach-types.h> |
37 | 37 | ||
diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c index 4351c438b76f..1b5ee8ec192a 100644 --- a/drivers/video/omap/omapfb_main.c +++ b/drivers/video/omap/omapfb_main.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/uaccess.h> | 30 | #include <linux/uaccess.h> |
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | 32 | ||
33 | #include <plat/dma.h> | 33 | #include <plat-omap/dma-omap.h> |
34 | 34 | ||
35 | #include "omapfb.h" | 35 | #include "omapfb.h" |
36 | #include "lcdc.h" | 36 | #include "lcdc.h" |
diff --git a/drivers/video/omap/sossi.c b/drivers/video/omap/sossi.c index f79c137753d7..c510a4457398 100644 --- a/drivers/video/omap/sossi.c +++ b/drivers/video/omap/sossi.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
27 | 27 | ||
28 | #include <plat/dma.h> | 28 | #include <plat-omap/dma-omap.h> |
29 | 29 | ||
30 | #include "omapfb.h" | 30 | #include "omapfb.h" |
31 | #include "lcdc.h" | 31 | #include "lcdc.h" |
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c index b2af72dc20bd..d94ef9e31a35 100644 --- a/drivers/video/omap2/dss/core.c +++ b/drivers/video/omap2/dss/core.c | |||
@@ -237,7 +237,7 @@ static int __init omap_dss_probe(struct platform_device *pdev) | |||
237 | 237 | ||
238 | core.pdev = pdev; | 238 | core.pdev = pdev; |
239 | 239 | ||
240 | dss_features_init(); | 240 | dss_features_init(pdata->version); |
241 | 241 | ||
242 | dss_apply_init(); | 242 | dss_apply_init(); |
243 | 243 | ||
diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c index b43477a5fae8..a5ab354f267a 100644 --- a/drivers/video/omap2/dss/dispc.c +++ b/drivers/video/omap2/dss/dispc.c | |||
@@ -37,8 +37,6 @@ | |||
37 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
38 | #include <linux/pm_runtime.h> | 38 | #include <linux/pm_runtime.h> |
39 | 39 | ||
40 | #include <plat/cpu.h> | ||
41 | |||
42 | #include <video/omapdss.h> | 40 | #include <video/omapdss.h> |
43 | 41 | ||
44 | #include "dss.h" | 42 | #include "dss.h" |
@@ -4042,29 +4040,44 @@ static const struct dispc_features omap44xx_dispc_feats __initconst = { | |||
4042 | .gfx_fifo_workaround = true, | 4040 | .gfx_fifo_workaround = true, |
4043 | }; | 4041 | }; |
4044 | 4042 | ||
4045 | static int __init dispc_init_features(struct device *dev) | 4043 | static int __init dispc_init_features(struct platform_device *pdev) |
4046 | { | 4044 | { |
4045 | struct omap_dss_board_info *pdata = pdev->dev.platform_data; | ||
4047 | const struct dispc_features *src; | 4046 | const struct dispc_features *src; |
4048 | struct dispc_features *dst; | 4047 | struct dispc_features *dst; |
4049 | 4048 | ||
4050 | dst = devm_kzalloc(dev, sizeof(*dst), GFP_KERNEL); | 4049 | dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); |
4051 | if (!dst) { | 4050 | if (!dst) { |
4052 | dev_err(dev, "Failed to allocate DISPC Features\n"); | 4051 | dev_err(&pdev->dev, "Failed to allocate DISPC Features\n"); |
4053 | return -ENOMEM; | 4052 | return -ENOMEM; |
4054 | } | 4053 | } |
4055 | 4054 | ||
4056 | if (cpu_is_omap24xx()) { | 4055 | switch (pdata->version) { |
4056 | case OMAPDSS_VER_OMAP24xx: | ||
4057 | src = &omap24xx_dispc_feats; | 4057 | src = &omap24xx_dispc_feats; |
4058 | } else if (cpu_is_omap34xx()) { | 4058 | break; |
4059 | if (omap_rev() < OMAP3430_REV_ES3_0) | 4059 | |
4060 | src = &omap34xx_rev1_0_dispc_feats; | 4060 | case OMAPDSS_VER_OMAP34xx_ES1: |
4061 | else | 4061 | src = &omap34xx_rev1_0_dispc_feats; |
4062 | src = &omap34xx_rev3_0_dispc_feats; | 4062 | break; |
4063 | } else if (cpu_is_omap44xx()) { | 4063 | |
4064 | case OMAPDSS_VER_OMAP34xx_ES3: | ||
4065 | case OMAPDSS_VER_OMAP3630: | ||
4066 | case OMAPDSS_VER_AM35xx: | ||
4067 | src = &omap34xx_rev3_0_dispc_feats; | ||
4068 | break; | ||
4069 | |||
4070 | case OMAPDSS_VER_OMAP4430_ES1: | ||
4071 | case OMAPDSS_VER_OMAP4430_ES2: | ||
4072 | case OMAPDSS_VER_OMAP4: | ||
4064 | src = &omap44xx_dispc_feats; | 4073 | src = &omap44xx_dispc_feats; |
4065 | } else if (soc_is_omap54xx()) { | 4074 | break; |
4075 | |||
4076 | case OMAPDSS_VER_OMAP5: | ||
4066 | src = &omap44xx_dispc_feats; | 4077 | src = &omap44xx_dispc_feats; |
4067 | } else { | 4078 | break; |
4079 | |||
4080 | default: | ||
4068 | return -ENODEV; | 4081 | return -ENODEV; |
4069 | } | 4082 | } |
4070 | 4083 | ||
@@ -4084,7 +4097,7 @@ static int __init omap_dispchw_probe(struct platform_device *pdev) | |||
4084 | 4097 | ||
4085 | dispc.pdev = pdev; | 4098 | dispc.pdev = pdev; |
4086 | 4099 | ||
4087 | r = dispc_init_features(&dispc.pdev->dev); | 4100 | r = dispc_init_features(dispc.pdev); |
4088 | if (r) | 4101 | if (r) |
4089 | return r; | 4102 | return r; |
4090 | 4103 | ||
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c index 2ab1c3e96553..363852a0f764 100644 --- a/drivers/video/omap2/dss/dss.c +++ b/drivers/video/omap2/dss/dss.c | |||
@@ -35,8 +35,6 @@ | |||
35 | 35 | ||
36 | #include <video/omapdss.h> | 36 | #include <video/omapdss.h> |
37 | 37 | ||
38 | #include <plat/cpu.h> | ||
39 | |||
40 | #include "dss.h" | 38 | #include "dss.h" |
41 | #include "dss_features.h" | 39 | #include "dss_features.h" |
42 | 40 | ||
@@ -792,29 +790,46 @@ static const struct dss_features omap54xx_dss_feats __initconst = { | |||
792 | .dpi_select_source = &dss_dpi_select_source_omap5, | 790 | .dpi_select_source = &dss_dpi_select_source_omap5, |
793 | }; | 791 | }; |
794 | 792 | ||
795 | static int __init dss_init_features(struct device *dev) | 793 | static int __init dss_init_features(struct platform_device *pdev) |
796 | { | 794 | { |
795 | struct omap_dss_board_info *pdata = pdev->dev.platform_data; | ||
797 | const struct dss_features *src; | 796 | const struct dss_features *src; |
798 | struct dss_features *dst; | 797 | struct dss_features *dst; |
799 | 798 | ||
800 | dst = devm_kzalloc(dev, sizeof(*dst), GFP_KERNEL); | 799 | dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); |
801 | if (!dst) { | 800 | if (!dst) { |
802 | dev_err(dev, "Failed to allocate local DSS Features\n"); | 801 | dev_err(&pdev->dev, "Failed to allocate local DSS Features\n"); |
803 | return -ENOMEM; | 802 | return -ENOMEM; |
804 | } | 803 | } |
805 | 804 | ||
806 | if (cpu_is_omap24xx()) | 805 | switch (pdata->version) { |
806 | case OMAPDSS_VER_OMAP24xx: | ||
807 | src = &omap24xx_dss_feats; | 807 | src = &omap24xx_dss_feats; |
808 | else if (cpu_is_omap34xx()) | 808 | break; |
809 | |||
810 | case OMAPDSS_VER_OMAP34xx_ES1: | ||
811 | case OMAPDSS_VER_OMAP34xx_ES3: | ||
812 | case OMAPDSS_VER_AM35xx: | ||
809 | src = &omap34xx_dss_feats; | 813 | src = &omap34xx_dss_feats; |
810 | else if (cpu_is_omap3630()) | 814 | break; |
815 | |||
816 | case OMAPDSS_VER_OMAP3630: | ||
811 | src = &omap3630_dss_feats; | 817 | src = &omap3630_dss_feats; |
812 | else if (cpu_is_omap44xx()) | 818 | break; |
819 | |||
820 | case OMAPDSS_VER_OMAP4430_ES1: | ||
821 | case OMAPDSS_VER_OMAP4430_ES2: | ||
822 | case OMAPDSS_VER_OMAP4: | ||
813 | src = &omap44xx_dss_feats; | 823 | src = &omap44xx_dss_feats; |
814 | else if (soc_is_omap54xx()) | 824 | break; |
825 | |||
826 | case OMAPDSS_VER_OMAP5: | ||
815 | src = &omap54xx_dss_feats; | 827 | src = &omap54xx_dss_feats; |
816 | else | 828 | break; |
829 | |||
830 | default: | ||
817 | return -ENODEV; | 831 | return -ENODEV; |
832 | } | ||
818 | 833 | ||
819 | memcpy(dst, src, sizeof(*dst)); | 834 | memcpy(dst, src, sizeof(*dst)); |
820 | dss.feat = dst; | 835 | dss.feat = dst; |
@@ -831,7 +846,7 @@ static int __init omap_dsshw_probe(struct platform_device *pdev) | |||
831 | 846 | ||
832 | dss.pdev = pdev; | 847 | dss.pdev = pdev; |
833 | 848 | ||
834 | r = dss_init_features(&dss.pdev->dev); | 849 | r = dss_init_features(dss.pdev); |
835 | if (r) | 850 | if (r) |
836 | return r; | 851 | return r; |
837 | 852 | ||
diff --git a/drivers/video/omap2/dss/dss_features.c b/drivers/video/omap2/dss/dss_features.c index acbc1e1efba3..3e8287c8709d 100644 --- a/drivers/video/omap2/dss/dss_features.c +++ b/drivers/video/omap2/dss/dss_features.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | 24 | ||
25 | #include <video/omapdss.h> | 25 | #include <video/omapdss.h> |
26 | #include <plat/cpu.h> | ||
27 | 26 | ||
28 | #include "dss.h" | 27 | #include "dss.h" |
29 | #include "dss_features.h" | 28 | #include "dss_features.h" |
@@ -825,10 +824,20 @@ static const struct ti_hdmi_ip_ops omap4_hdmi_functions = { | |||
825 | 824 | ||
826 | }; | 825 | }; |
827 | 826 | ||
828 | void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data) | 827 | void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data, |
828 | enum omapdss_version version) | ||
829 | { | 829 | { |
830 | if (cpu_is_omap44xx()) | 830 | switch (version) { |
831 | case OMAPDSS_VER_OMAP4430_ES1: | ||
832 | case OMAPDSS_VER_OMAP4430_ES2: | ||
833 | case OMAPDSS_VER_OMAP4: | ||
831 | ip_data->ops = &omap4_hdmi_functions; | 834 | ip_data->ops = &omap4_hdmi_functions; |
835 | break; | ||
836 | default: | ||
837 | ip_data->ops = NULL; | ||
838 | } | ||
839 | |||
840 | WARN_ON(ip_data->ops == NULL); | ||
832 | } | 841 | } |
833 | #endif | 842 | #endif |
834 | 843 | ||
@@ -929,29 +938,44 @@ bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type) | |||
929 | return omap_current_dss_features->supported_rotation_types & rot_type; | 938 | return omap_current_dss_features->supported_rotation_types & rot_type; |
930 | } | 939 | } |
931 | 940 | ||
932 | void dss_features_init(void) | 941 | void dss_features_init(enum omapdss_version version) |
933 | { | 942 | { |
934 | if (cpu_is_omap24xx()) | 943 | switch (version) { |
944 | case OMAPDSS_VER_OMAP24xx: | ||
935 | omap_current_dss_features = &omap2_dss_features; | 945 | omap_current_dss_features = &omap2_dss_features; |
936 | else if (cpu_is_omap3630()) | 946 | break; |
947 | |||
948 | case OMAPDSS_VER_OMAP34xx_ES1: | ||
949 | case OMAPDSS_VER_OMAP34xx_ES3: | ||
950 | omap_current_dss_features = &omap3430_dss_features; | ||
951 | break; | ||
952 | |||
953 | case OMAPDSS_VER_OMAP3630: | ||
937 | omap_current_dss_features = &omap3630_dss_features; | 954 | omap_current_dss_features = &omap3630_dss_features; |
938 | else if (cpu_is_omap34xx()) { | 955 | break; |
939 | if (soc_is_am35xx()) { | 956 | |
940 | omap_current_dss_features = &am35xx_dss_features; | 957 | case OMAPDSS_VER_OMAP4430_ES1: |
941 | } else { | ||
942 | omap_current_dss_features = &omap3430_dss_features; | ||
943 | } | ||
944 | } | ||
945 | else if (omap_rev() == OMAP4430_REV_ES1_0) | ||
946 | omap_current_dss_features = &omap4430_es1_0_dss_features; | 958 | omap_current_dss_features = &omap4430_es1_0_dss_features; |
947 | else if (omap_rev() == OMAP4430_REV_ES2_0 || | 959 | break; |
948 | omap_rev() == OMAP4430_REV_ES2_1 || | 960 | |
949 | omap_rev() == OMAP4430_REV_ES2_2) | 961 | case OMAPDSS_VER_OMAP4430_ES2: |
950 | omap_current_dss_features = &omap4430_es2_0_1_2_dss_features; | 962 | omap_current_dss_features = &omap4430_es2_0_1_2_dss_features; |
951 | else if (cpu_is_omap44xx()) | 963 | break; |
964 | |||
965 | case OMAPDSS_VER_OMAP4: | ||
952 | omap_current_dss_features = &omap4_dss_features; | 966 | omap_current_dss_features = &omap4_dss_features; |
953 | else if (soc_is_omap54xx()) | 967 | break; |
968 | |||
969 | case OMAPDSS_VER_OMAP5: | ||
954 | omap_current_dss_features = &omap5_dss_features; | 970 | omap_current_dss_features = &omap5_dss_features; |
955 | else | 971 | break; |
972 | |||
973 | case OMAPDSS_VER_AM35xx: | ||
974 | omap_current_dss_features = &am35xx_dss_features; | ||
975 | break; | ||
976 | |||
977 | default: | ||
956 | DSSWARN("Unsupported OMAP version"); | 978 | DSSWARN("Unsupported OMAP version"); |
979 | break; | ||
980 | } | ||
957 | } | 981 | } |
diff --git a/drivers/video/omap2/dss/dss_features.h b/drivers/video/omap2/dss/dss_features.h index 9218113b5e88..fc492ef72a51 100644 --- a/drivers/video/omap2/dss/dss_features.h +++ b/drivers/video/omap2/dss/dss_features.h | |||
@@ -123,8 +123,9 @@ bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type); | |||
123 | 123 | ||
124 | bool dss_has_feature(enum dss_feat_id id); | 124 | bool dss_has_feature(enum dss_feat_id id); |
125 | void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end); | 125 | void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end); |
126 | void dss_features_init(void); | 126 | void dss_features_init(enum omapdss_version version); |
127 | #if defined(CONFIG_OMAP4_DSS_HDMI) | 127 | #if defined(CONFIG_OMAP4_DSS_HDMI) |
128 | void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data); | 128 | void dss_init_hdmi_ip_ops(struct hdmi_ip_data *ip_data, |
129 | enum omapdss_version version); | ||
129 | #endif | 130 | #endif |
130 | #endif | 131 | #endif |
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c index a48a7dd75b33..adcc906d12f8 100644 --- a/drivers/video/omap2/dss/hdmi.c +++ b/drivers/video/omap2/dss/hdmi.c | |||
@@ -323,6 +323,7 @@ static void hdmi_runtime_put(void) | |||
323 | 323 | ||
324 | static int __init hdmi_init_display(struct omap_dss_device *dssdev) | 324 | static int __init hdmi_init_display(struct omap_dss_device *dssdev) |
325 | { | 325 | { |
326 | struct omap_dss_board_info *pdata = hdmi.pdev->dev.platform_data; | ||
326 | int r; | 327 | int r; |
327 | 328 | ||
328 | struct gpio gpios[] = { | 329 | struct gpio gpios[] = { |
@@ -333,7 +334,7 @@ static int __init hdmi_init_display(struct omap_dss_device *dssdev) | |||
333 | 334 | ||
334 | DSSDBG("init_display\n"); | 335 | DSSDBG("init_display\n"); |
335 | 336 | ||
336 | dss_init_hdmi_ip_ops(&hdmi.ip_data); | 337 | dss_init_hdmi_ip_ops(&hdmi.ip_data, pdata->version); |
337 | 338 | ||
338 | if (hdmi.vdda_hdmi_dac_reg == NULL) { | 339 | if (hdmi.vdda_hdmi_dac_reg == NULL) { |
339 | struct regulator *reg; | 340 | struct regulator *reg; |
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c index 606b89f12351..55a39be694a5 100644 --- a/drivers/video/omap2/omapfb/omapfb-ioctl.c +++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/export.h> | 30 | #include <linux/export.h> |
31 | 31 | ||
32 | #include <video/omapdss.h> | 32 | #include <video/omapdss.h> |
33 | #include <plat/vrfb.h> | 33 | #include <video/omapvrfb.h> |
34 | #include <plat/vram.h> | 34 | #include <plat/vram.h> |
35 | 35 | ||
36 | #include "omapfb.h" | 36 | #include "omapfb.h" |
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c index 16db1589bd91..bc225e46fdd2 100644 --- a/drivers/video/omap2/omapfb/omapfb-main.c +++ b/drivers/video/omap2/omapfb/omapfb-main.c | |||
@@ -31,9 +31,8 @@ | |||
31 | #include <linux/omapfb.h> | 31 | #include <linux/omapfb.h> |
32 | 32 | ||
33 | #include <video/omapdss.h> | 33 | #include <video/omapdss.h> |
34 | #include <plat/cpu.h> | ||
35 | #include <plat/vram.h> | 34 | #include <plat/vram.h> |
36 | #include <plat/vrfb.h> | 35 | #include <video/omapvrfb.h> |
37 | 36 | ||
38 | #include "omapfb.h" | 37 | #include "omapfb.h" |
39 | 38 | ||
@@ -2396,10 +2395,7 @@ static int __init omapfb_probe(struct platform_device *pdev) | |||
2396 | goto err0; | 2395 | goto err0; |
2397 | } | 2396 | } |
2398 | 2397 | ||
2399 | /* TODO : Replace cpu check with omap_has_vrfb once HAS_FEATURE | 2398 | if (def_vrfb && !omap_vrfb_supported()) { |
2400 | * available for OMAP2 and OMAP3 | ||
2401 | */ | ||
2402 | if (def_vrfb && !cpu_is_omap24xx() && !cpu_is_omap34xx()) { | ||
2403 | def_vrfb = 0; | 2399 | def_vrfb = 0; |
2404 | dev_warn(&pdev->dev, "VRFB is not supported on this hardware, " | 2400 | dev_warn(&pdev->dev, "VRFB is not supported on this hardware, " |
2405 | "ignoring the module parameter vrfb=y\n"); | 2401 | "ignoring the module parameter vrfb=y\n"); |
diff --git a/drivers/video/omap2/omapfb/omapfb-sysfs.c b/drivers/video/omap2/omapfb/omapfb-sysfs.c index e8d8cc76a435..17aa174e187c 100644 --- a/drivers/video/omap2/omapfb/omapfb-sysfs.c +++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/omapfb.h> | 30 | #include <linux/omapfb.h> |
31 | 31 | ||
32 | #include <video/omapdss.h> | 32 | #include <video/omapdss.h> |
33 | #include <plat/vrfb.h> | 33 | #include <video/omapvrfb.h> |
34 | 34 | ||
35 | #include "omapfb.h" | 35 | #include "omapfb.h" |
36 | 36 | ||
diff --git a/drivers/video/omap2/vrfb.c b/drivers/video/omap2/vrfb.c index 7e990220ad2a..5d8fdac3b800 100644 --- a/drivers/video/omap2/vrfb.c +++ b/drivers/video/omap2/vrfb.c | |||
@@ -26,9 +26,9 @@ | |||
26 | #include <linux/io.h> | 26 | #include <linux/io.h> |
27 | #include <linux/bitops.h> | 27 | #include <linux/bitops.h> |
28 | #include <linux/mutex.h> | 28 | #include <linux/mutex.h> |
29 | #include <linux/platform_device.h> | ||
29 | 30 | ||
30 | #include <plat/vrfb.h> | 31 | #include <video/omapvrfb.h> |
31 | #include <plat/sdrc.h> | ||
32 | 32 | ||
33 | #ifdef DEBUG | 33 | #ifdef DEBUG |
34 | #define DBG(format, ...) pr_debug("VRFB: " format, ## __VA_ARGS__) | 34 | #define DBG(format, ...) pr_debug("VRFB: " format, ## __VA_ARGS__) |
@@ -36,10 +36,10 @@ | |||
36 | #define DBG(format, ...) | 36 | #define DBG(format, ...) |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #define SMS_ROT_VIRT_BASE(context, rot) \ | 39 | #define SMS_ROT_CONTROL(context) (0x0 + 0x10 * context) |
40 | (((context >= 4) ? 0xD0000000 : 0x70000000) \ | 40 | #define SMS_ROT_SIZE(context) (0x4 + 0x10 * context) |
41 | + (0x4000000 * (context)) \ | 41 | #define SMS_ROT_PHYSICAL_BA(context) (0x8 + 0x10 * context) |
42 | + (0x1000000 * (rot))) | 42 | #define SMS_ROT_VIRT_BASE(rot) (0x1000000 * (rot)) |
43 | 43 | ||
44 | #define OMAP_VRFB_SIZE (2048 * 2048 * 4) | 44 | #define OMAP_VRFB_SIZE (2048 * 2048 * 4) |
45 | 45 | ||
@@ -53,10 +53,16 @@ | |||
53 | #define SMS_PW_OFFSET 4 | 53 | #define SMS_PW_OFFSET 4 |
54 | #define SMS_PS_OFFSET 0 | 54 | #define SMS_PS_OFFSET 0 |
55 | 55 | ||
56 | #define VRFB_NUM_CTXS 12 | ||
57 | /* bitmap of reserved contexts */ | 56 | /* bitmap of reserved contexts */ |
58 | static unsigned long ctx_map; | 57 | static unsigned long ctx_map; |
59 | 58 | ||
59 | struct vrfb_ctx { | ||
60 | u32 base; | ||
61 | u32 physical_ba; | ||
62 | u32 control; | ||
63 | u32 size; | ||
64 | }; | ||
65 | |||
60 | static DEFINE_MUTEX(ctx_lock); | 66 | static DEFINE_MUTEX(ctx_lock); |
61 | 67 | ||
62 | /* | 68 | /* |
@@ -65,17 +71,34 @@ static DEFINE_MUTEX(ctx_lock); | |||
65 | * we don't need locking, since no drivers will run until after the wake-up | 71 | * we don't need locking, since no drivers will run until after the wake-up |
66 | * has finished. | 72 | * has finished. |
67 | */ | 73 | */ |
68 | static struct { | 74 | |
69 | u32 physical_ba; | 75 | static void __iomem *vrfb_base; |
70 | u32 control; | 76 | |
71 | u32 size; | 77 | static int num_ctxs; |
72 | } vrfb_hw_context[VRFB_NUM_CTXS]; | 78 | static struct vrfb_ctx *ctxs; |
79 | |||
80 | static bool vrfb_loaded; | ||
81 | |||
82 | static void omap2_sms_write_rot_control(u32 val, unsigned ctx) | ||
83 | { | ||
84 | __raw_writel(val, vrfb_base + SMS_ROT_CONTROL(ctx)); | ||
85 | } | ||
86 | |||
87 | static void omap2_sms_write_rot_size(u32 val, unsigned ctx) | ||
88 | { | ||
89 | __raw_writel(val, vrfb_base + SMS_ROT_SIZE(ctx)); | ||
90 | } | ||
91 | |||
92 | static void omap2_sms_write_rot_physical_ba(u32 val, unsigned ctx) | ||
93 | { | ||
94 | __raw_writel(val, vrfb_base + SMS_ROT_PHYSICAL_BA(ctx)); | ||
95 | } | ||
73 | 96 | ||
74 | static inline void restore_hw_context(int ctx) | 97 | static inline void restore_hw_context(int ctx) |
75 | { | 98 | { |
76 | omap2_sms_write_rot_control(vrfb_hw_context[ctx].control, ctx); | 99 | omap2_sms_write_rot_control(ctxs[ctx].control, ctx); |
77 | omap2_sms_write_rot_size(vrfb_hw_context[ctx].size, ctx); | 100 | omap2_sms_write_rot_size(ctxs[ctx].size, ctx); |
78 | omap2_sms_write_rot_physical_ba(vrfb_hw_context[ctx].physical_ba, ctx); | 101 | omap2_sms_write_rot_physical_ba(ctxs[ctx].physical_ba, ctx); |
79 | } | 102 | } |
80 | 103 | ||
81 | static u32 get_image_width_roundup(u16 width, u8 bytespp) | 104 | static u32 get_image_width_roundup(u16 width, u8 bytespp) |
@@ -196,9 +219,9 @@ void omap_vrfb_setup(struct vrfb *vrfb, unsigned long paddr, | |||
196 | control |= VRFB_PAGE_WIDTH_EXP << SMS_PW_OFFSET; | 219 | control |= VRFB_PAGE_WIDTH_EXP << SMS_PW_OFFSET; |
197 | control |= VRFB_PAGE_HEIGHT_EXP << SMS_PH_OFFSET; | 220 | control |= VRFB_PAGE_HEIGHT_EXP << SMS_PH_OFFSET; |
198 | 221 | ||
199 | vrfb_hw_context[ctx].physical_ba = paddr; | 222 | ctxs[ctx].physical_ba = paddr; |
200 | vrfb_hw_context[ctx].size = size; | 223 | ctxs[ctx].size = size; |
201 | vrfb_hw_context[ctx].control = control; | 224 | ctxs[ctx].control = control; |
202 | 225 | ||
203 | omap2_sms_write_rot_physical_ba(paddr, ctx); | 226 | omap2_sms_write_rot_physical_ba(paddr, ctx); |
204 | omap2_sms_write_rot_size(size, ctx); | 227 | omap2_sms_write_rot_size(size, ctx); |
@@ -274,11 +297,11 @@ int omap_vrfb_request_ctx(struct vrfb *vrfb) | |||
274 | 297 | ||
275 | mutex_lock(&ctx_lock); | 298 | mutex_lock(&ctx_lock); |
276 | 299 | ||
277 | for (ctx = 0; ctx < VRFB_NUM_CTXS; ++ctx) | 300 | for (ctx = 0; ctx < num_ctxs; ++ctx) |
278 | if ((ctx_map & (1 << ctx)) == 0) | 301 | if ((ctx_map & (1 << ctx)) == 0) |
279 | break; | 302 | break; |
280 | 303 | ||
281 | if (ctx == VRFB_NUM_CTXS) { | 304 | if (ctx == num_ctxs) { |
282 | pr_err("vrfb: no free contexts\n"); | 305 | pr_err("vrfb: no free contexts\n"); |
283 | r = -EBUSY; | 306 | r = -EBUSY; |
284 | goto out; | 307 | goto out; |
@@ -293,7 +316,7 @@ int omap_vrfb_request_ctx(struct vrfb *vrfb) | |||
293 | vrfb->context = ctx; | 316 | vrfb->context = ctx; |
294 | 317 | ||
295 | for (rot = 0; rot < 4; ++rot) { | 318 | for (rot = 0; rot < 4; ++rot) { |
296 | paddr = SMS_ROT_VIRT_BASE(ctx, rot); | 319 | paddr = ctxs[ctx].base + SMS_ROT_VIRT_BASE(rot); |
297 | if (!request_mem_region(paddr, OMAP_VRFB_SIZE, "vrfb")) { | 320 | if (!request_mem_region(paddr, OMAP_VRFB_SIZE, "vrfb")) { |
298 | pr_err("vrfb: failed to reserve VRFB " | 321 | pr_err("vrfb: failed to reserve VRFB " |
299 | "area for ctx %d, rotation %d\n", | 322 | "area for ctx %d, rotation %d\n", |
@@ -314,3 +337,80 @@ out: | |||
314 | return r; | 337 | return r; |
315 | } | 338 | } |
316 | EXPORT_SYMBOL(omap_vrfb_request_ctx); | 339 | EXPORT_SYMBOL(omap_vrfb_request_ctx); |
340 | |||
341 | bool omap_vrfb_supported(void) | ||
342 | { | ||
343 | return vrfb_loaded; | ||
344 | } | ||
345 | EXPORT_SYMBOL(omap_vrfb_supported); | ||
346 | |||
347 | static int __init vrfb_probe(struct platform_device *pdev) | ||
348 | { | ||
349 | struct resource *mem; | ||
350 | int i; | ||
351 | |||
352 | /* first resource is the register res, the rest are vrfb contexts */ | ||
353 | |||
354 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
355 | if (!mem) { | ||
356 | dev_err(&pdev->dev, "can't get vrfb base address\n"); | ||
357 | return -EINVAL; | ||
358 | } | ||
359 | |||
360 | vrfb_base = devm_request_and_ioremap(&pdev->dev, mem); | ||
361 | if (!vrfb_base) { | ||
362 | dev_err(&pdev->dev, "can't ioremap vrfb memory\n"); | ||
363 | return -ENOMEM; | ||
364 | } | ||
365 | |||
366 | num_ctxs = pdev->num_resources - 1; | ||
367 | |||
368 | ctxs = devm_kzalloc(&pdev->dev, | ||
369 | sizeof(struct vrfb_ctx) * num_ctxs, | ||
370 | GFP_KERNEL); | ||
371 | |||
372 | if (!ctxs) | ||
373 | return -ENOMEM; | ||
374 | |||
375 | for (i = 0; i < num_ctxs; ++i) { | ||
376 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 1 + i); | ||
377 | if (!mem) { | ||
378 | dev_err(&pdev->dev, "can't get vrfb ctx %d address\n", | ||
379 | i); | ||
380 | return -EINVAL; | ||
381 | } | ||
382 | |||
383 | ctxs[i].base = mem->start; | ||
384 | } | ||
385 | |||
386 | vrfb_loaded = true; | ||
387 | |||
388 | return 0; | ||
389 | } | ||
390 | |||
391 | static void __exit vrfb_remove(struct platform_device *pdev) | ||
392 | { | ||
393 | vrfb_loaded = false; | ||
394 | } | ||
395 | |||
396 | static struct platform_driver vrfb_driver = { | ||
397 | .driver.name = "omapvrfb", | ||
398 | .remove = __exit_p(vrfb_remove), | ||
399 | }; | ||
400 | |||
401 | static int __init vrfb_init(void) | ||
402 | { | ||
403 | return platform_driver_probe(&vrfb_driver, &vrfb_probe); | ||
404 | } | ||
405 | |||
406 | static void __exit vrfb_exit(void) | ||
407 | { | ||
408 | platform_driver_unregister(&vrfb_driver); | ||
409 | } | ||
410 | |||
411 | module_init(vrfb_init); | ||
412 | module_exit(vrfb_exit); | ||
413 | |||
414 | MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>"); | ||
415 | MODULE_DESCRIPTION("OMAP VRFB"); | ||
416 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index bcfab2b00ad2..9a45d0294cf4 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/uaccess.h> | 33 | #include <linux/uaccess.h> |
34 | #include <linux/timer.h> | 34 | #include <linux/timer.h> |
35 | #include <linux/jiffies.h> | 35 | #include <linux/jiffies.h> |
36 | #include <mach/hardware.h> | ||
37 | 36 | ||
38 | #define DRIVER_NAME "imx2-wdt" | 37 | #define DRIVER_NAME "imx2-wdt" |
39 | 38 | ||
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index f5db18dbc0f9..477a1d47a64c 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c | |||
@@ -46,8 +46,8 @@ | |||
46 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
47 | #include <linux/pm_runtime.h> | 47 | #include <linux/pm_runtime.h> |
48 | #include <mach/hardware.h> | 48 | #include <mach/hardware.h> |
49 | #include <plat/cpu.h> | 49 | |
50 | #include <plat/prcm.h> | 50 | #include <linux/platform_data/omap-wd-timer.h> |
51 | 51 | ||
52 | #include "omap_wdt.h" | 52 | #include "omap_wdt.h" |
53 | 53 | ||
@@ -202,8 +202,10 @@ static ssize_t omap_wdt_write(struct file *file, const char __user *data, | |||
202 | static long omap_wdt_ioctl(struct file *file, unsigned int cmd, | 202 | static long omap_wdt_ioctl(struct file *file, unsigned int cmd, |
203 | unsigned long arg) | 203 | unsigned long arg) |
204 | { | 204 | { |
205 | struct omap_wd_timer_platform_data *pdata; | ||
205 | struct omap_wdt_dev *wdev; | 206 | struct omap_wdt_dev *wdev; |
206 | int new_margin; | 207 | u32 rs; |
208 | int new_margin, bs; | ||
207 | static const struct watchdog_info ident = { | 209 | static const struct watchdog_info ident = { |
208 | .identity = "OMAP Watchdog", | 210 | .identity = "OMAP Watchdog", |
209 | .options = WDIOF_SETTIMEOUT, | 211 | .options = WDIOF_SETTIMEOUT, |
@@ -211,6 +213,7 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd, | |||
211 | }; | 213 | }; |
212 | 214 | ||
213 | wdev = file->private_data; | 215 | wdev = file->private_data; |
216 | pdata = wdev->dev->platform_data; | ||
214 | 217 | ||
215 | switch (cmd) { | 218 | switch (cmd) { |
216 | case WDIOC_GETSUPPORT: | 219 | case WDIOC_GETSUPPORT: |
@@ -219,17 +222,12 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd, | |||
219 | case WDIOC_GETSTATUS: | 222 | case WDIOC_GETSTATUS: |
220 | return put_user(0, (int __user *)arg); | 223 | return put_user(0, (int __user *)arg); |
221 | case WDIOC_GETBOOTSTATUS: | 224 | case WDIOC_GETBOOTSTATUS: |
222 | #ifdef CONFIG_ARCH_OMAP1 | 225 | if (!pdata || !pdata->read_reset_sources) |
223 | if (cpu_is_omap16xx()) | 226 | return put_user(0, (int __user *)arg); |
224 | return put_user(__raw_readw(ARM_SYSST), | 227 | rs = pdata->read_reset_sources(); |
225 | (int __user *)arg); | 228 | bs = (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT)) ? |
226 | #endif | 229 | WDIOF_CARDRESET : 0; |
227 | #ifdef CONFIG_ARCH_OMAP2PLUS | 230 | return put_user(bs, (int __user *)arg); |
228 | if (cpu_is_omap24xx()) | ||
229 | return put_user(omap_prcm_get_reset_sources(), | ||
230 | (int __user *)arg); | ||
231 | #endif | ||
232 | return put_user(0, (int __user *)arg); | ||
233 | case WDIOC_KEEPALIVE: | 231 | case WDIOC_KEEPALIVE: |
234 | spin_lock(&wdt_lock); | 232 | spin_lock(&wdt_lock); |
235 | omap_wdt_ping(wdev); | 233 | omap_wdt_ping(wdev); |