diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/platform.c | 20 | ||||
-rw-r--r-- | drivers/clocksource/sh_cmt.c | 42 | ||||
-rw-r--r-- | drivers/clocksource/sh_mtu2.c | 34 | ||||
-rw-r--r-- | drivers/clocksource/sh_tmu.c | 38 | ||||
-rw-r--r-- | drivers/dma/shdma.c | 13 | ||||
-rw-r--r-- | drivers/dma/shdma.h | 4 | ||||
-rw-r--r-- | drivers/serial/sh-sci.c | 189 | ||||
-rw-r--r-- | drivers/sh/intc.c | 95 |
8 files changed, 305 insertions, 130 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4b4b565c835f..d10230adeb36 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -1254,6 +1254,26 @@ static int __init early_platform_driver_probe_id(char *class_str, | |||
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | if (match) { | 1256 | if (match) { |
1257 | /* | ||
1258 | * Set up a sensible init_name to enable | ||
1259 | * dev_name() and others to be used before the | ||
1260 | * rest of the driver core is initialized. | ||
1261 | */ | ||
1262 | if (!match->dev.init_name) { | ||
1263 | if (match->id != -1) | ||
1264 | match->dev.init_name = | ||
1265 | kasprintf(GFP_KERNEL, "%s.%d", | ||
1266 | match->name, | ||
1267 | match->id); | ||
1268 | else | ||
1269 | match->dev.init_name = | ||
1270 | kasprintf(GFP_KERNEL, "%s", | ||
1271 | match->name); | ||
1272 | |||
1273 | if (!match->dev.init_name) | ||
1274 | return -ENOMEM; | ||
1275 | } | ||
1276 | |||
1257 | if (epdrv->pdrv->probe(match)) | 1277 | if (epdrv->pdrv->probe(match)) |
1258 | pr_warning("%s: unable to probe %s early.\n", | 1278 | pr_warning("%s: unable to probe %s early.\n", |
1259 | class_str, match->name); | 1279 | class_str, match->name); |
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 578595c4425d..c5f66171a713 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c | |||
@@ -149,13 +149,12 @@ static void sh_cmt_start_stop_ch(struct sh_cmt_priv *p, int start) | |||
149 | 149 | ||
150 | static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate) | 150 | static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate) |
151 | { | 151 | { |
152 | struct sh_timer_config *cfg = p->pdev->dev.platform_data; | ||
153 | int ret; | 152 | int ret; |
154 | 153 | ||
155 | /* enable clock */ | 154 | /* enable clock */ |
156 | ret = clk_enable(p->clk); | 155 | ret = clk_enable(p->clk); |
157 | if (ret) { | 156 | if (ret) { |
158 | pr_err("sh_cmt: cannot enable clock \"%s\"\n", cfg->clk); | 157 | dev_err(&p->pdev->dev, "cannot enable clock\n"); |
159 | return ret; | 158 | return ret; |
160 | } | 159 | } |
161 | 160 | ||
@@ -278,7 +277,7 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, | |||
278 | delay = 1; | 277 | delay = 1; |
279 | 278 | ||
280 | if (!delay) | 279 | if (!delay) |
281 | pr_warning("sh_cmt: too long delay\n"); | 280 | dev_warn(&p->pdev->dev, "too long delay\n"); |
282 | 281 | ||
283 | } while (delay); | 282 | } while (delay); |
284 | } | 283 | } |
@@ -288,7 +287,7 @@ static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta) | |||
288 | unsigned long flags; | 287 | unsigned long flags; |
289 | 288 | ||
290 | if (delta > p->max_match_value) | 289 | if (delta > p->max_match_value) |
291 | pr_warning("sh_cmt: delta out of range\n"); | 290 | dev_warn(&p->pdev->dev, "delta out of range\n"); |
292 | 291 | ||
293 | spin_lock_irqsave(&p->lock, flags); | 292 | spin_lock_irqsave(&p->lock, flags); |
294 | p->next_match_value = delta; | 293 | p->next_match_value = delta; |
@@ -450,7 +449,7 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, | |||
450 | cs->resume = sh_cmt_clocksource_resume; | 449 | cs->resume = sh_cmt_clocksource_resume; |
451 | cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); | 450 | cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); |
452 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; | 451 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; |
453 | pr_info("sh_cmt: %s used as clock source\n", cs->name); | 452 | dev_info(&p->pdev->dev, "used as clock source\n"); |
454 | clocksource_register(cs); | 453 | clocksource_register(cs); |
455 | return 0; | 454 | return 0; |
456 | } | 455 | } |
@@ -496,13 +495,11 @@ static void sh_cmt_clock_event_mode(enum clock_event_mode mode, | |||
496 | 495 | ||
497 | switch (mode) { | 496 | switch (mode) { |
498 | case CLOCK_EVT_MODE_PERIODIC: | 497 | case CLOCK_EVT_MODE_PERIODIC: |
499 | pr_info("sh_cmt: %s used for periodic clock events\n", | 498 | dev_info(&p->pdev->dev, "used for periodic clock events\n"); |
500 | ced->name); | ||
501 | sh_cmt_clock_event_start(p, 1); | 499 | sh_cmt_clock_event_start(p, 1); |
502 | break; | 500 | break; |
503 | case CLOCK_EVT_MODE_ONESHOT: | 501 | case CLOCK_EVT_MODE_ONESHOT: |
504 | pr_info("sh_cmt: %s used for oneshot clock events\n", | 502 | dev_info(&p->pdev->dev, "used for oneshot clock events\n"); |
505 | ced->name); | ||
506 | sh_cmt_clock_event_start(p, 0); | 503 | sh_cmt_clock_event_start(p, 0); |
507 | break; | 504 | break; |
508 | case CLOCK_EVT_MODE_SHUTDOWN: | 505 | case CLOCK_EVT_MODE_SHUTDOWN: |
@@ -543,7 +540,7 @@ static void sh_cmt_register_clockevent(struct sh_cmt_priv *p, | |||
543 | ced->set_next_event = sh_cmt_clock_event_next; | 540 | ced->set_next_event = sh_cmt_clock_event_next; |
544 | ced->set_mode = sh_cmt_clock_event_mode; | 541 | ced->set_mode = sh_cmt_clock_event_mode; |
545 | 542 | ||
546 | pr_info("sh_cmt: %s used for clock events\n", ced->name); | 543 | dev_info(&p->pdev->dev, "used for clock events\n"); |
547 | clockevents_register_device(ced); | 544 | clockevents_register_device(ced); |
548 | } | 545 | } |
549 | 546 | ||
@@ -600,22 +597,26 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) | |||
600 | /* map memory, let mapbase point to our channel */ | 597 | /* map memory, let mapbase point to our channel */ |
601 | p->mapbase = ioremap_nocache(res->start, resource_size(res)); | 598 | p->mapbase = ioremap_nocache(res->start, resource_size(res)); |
602 | if (p->mapbase == NULL) { | 599 | if (p->mapbase == NULL) { |
603 | pr_err("sh_cmt: failed to remap I/O memory\n"); | 600 | dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); |
604 | goto err0; | 601 | goto err0; |
605 | } | 602 | } |
606 | 603 | ||
607 | /* request irq using setup_irq() (too early for request_irq()) */ | 604 | /* request irq using setup_irq() (too early for request_irq()) */ |
608 | p->irqaction.name = cfg->name; | 605 | p->irqaction.name = dev_name(&p->pdev->dev); |
609 | p->irqaction.handler = sh_cmt_interrupt; | 606 | p->irqaction.handler = sh_cmt_interrupt; |
610 | p->irqaction.dev_id = p; | 607 | p->irqaction.dev_id = p; |
611 | p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL; | 608 | p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL; |
612 | 609 | ||
613 | /* get hold of clock */ | 610 | /* get hold of clock */ |
614 | p->clk = clk_get(&p->pdev->dev, cfg->clk); | 611 | p->clk = clk_get(&p->pdev->dev, "cmt_fck"); |
615 | if (IS_ERR(p->clk)) { | 612 | if (IS_ERR(p->clk)) { |
616 | pr_err("sh_cmt: cannot get clock \"%s\"\n", cfg->clk); | 613 | dev_warn(&p->pdev->dev, "using deprecated clock lookup\n"); |
617 | ret = PTR_ERR(p->clk); | 614 | p->clk = clk_get(&p->pdev->dev, cfg->clk); |
618 | goto err1; | 615 | if (IS_ERR(p->clk)) { |
616 | dev_err(&p->pdev->dev, "cannot get clock\n"); | ||
617 | ret = PTR_ERR(p->clk); | ||
618 | goto err1; | ||
619 | } | ||
619 | } | 620 | } |
620 | 621 | ||
621 | if (resource_size(res) == 6) { | 622 | if (resource_size(res) == 6) { |
@@ -628,17 +629,17 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) | |||
628 | p->clear_bits = ~0xc000; | 629 | p->clear_bits = ~0xc000; |
629 | } | 630 | } |
630 | 631 | ||
631 | ret = sh_cmt_register(p, cfg->name, | 632 | ret = sh_cmt_register(p, (char *)dev_name(&p->pdev->dev), |
632 | cfg->clockevent_rating, | 633 | cfg->clockevent_rating, |
633 | cfg->clocksource_rating); | 634 | cfg->clocksource_rating); |
634 | if (ret) { | 635 | if (ret) { |
635 | pr_err("sh_cmt: registration failed\n"); | 636 | dev_err(&p->pdev->dev, "registration failed\n"); |
636 | goto err1; | 637 | goto err1; |
637 | } | 638 | } |
638 | 639 | ||
639 | ret = setup_irq(irq, &p->irqaction); | 640 | ret = setup_irq(irq, &p->irqaction); |
640 | if (ret) { | 641 | if (ret) { |
641 | pr_err("sh_cmt: failed to request irq %d\n", irq); | 642 | dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); |
642 | goto err1; | 643 | goto err1; |
643 | } | 644 | } |
644 | 645 | ||
@@ -653,11 +654,10 @@ err0: | |||
653 | static int __devinit sh_cmt_probe(struct platform_device *pdev) | 654 | static int __devinit sh_cmt_probe(struct platform_device *pdev) |
654 | { | 655 | { |
655 | struct sh_cmt_priv *p = platform_get_drvdata(pdev); | 656 | struct sh_cmt_priv *p = platform_get_drvdata(pdev); |
656 | struct sh_timer_config *cfg = pdev->dev.platform_data; | ||
657 | int ret; | 657 | int ret; |
658 | 658 | ||
659 | if (p) { | 659 | if (p) { |
660 | pr_info("sh_cmt: %s kept as earlytimer\n", cfg->name); | 660 | dev_info(&pdev->dev, "kept as earlytimer\n"); |
661 | return 0; | 661 | return 0; |
662 | } | 662 | } |
663 | 663 | ||
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 4c8a759e60cd..b11882e0f1bd 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c | |||
@@ -118,13 +118,12 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_priv *p, int start) | |||
118 | 118 | ||
119 | static int sh_mtu2_enable(struct sh_mtu2_priv *p) | 119 | static int sh_mtu2_enable(struct sh_mtu2_priv *p) |
120 | { | 120 | { |
121 | struct sh_timer_config *cfg = p->pdev->dev.platform_data; | ||
122 | int ret; | 121 | int ret; |
123 | 122 | ||
124 | /* enable clock */ | 123 | /* enable clock */ |
125 | ret = clk_enable(p->clk); | 124 | ret = clk_enable(p->clk); |
126 | if (ret) { | 125 | if (ret) { |
127 | pr_err("sh_mtu2: cannot enable clock \"%s\"\n", cfg->clk); | 126 | dev_err(&p->pdev->dev, "cannot enable clock\n"); |
128 | return ret; | 127 | return ret; |
129 | } | 128 | } |
130 | 129 | ||
@@ -193,8 +192,7 @@ static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, | |||
193 | 192 | ||
194 | switch (mode) { | 193 | switch (mode) { |
195 | case CLOCK_EVT_MODE_PERIODIC: | 194 | case CLOCK_EVT_MODE_PERIODIC: |
196 | pr_info("sh_mtu2: %s used for periodic clock events\n", | 195 | dev_info(&p->pdev->dev, "used for periodic clock events\n"); |
197 | ced->name); | ||
198 | sh_mtu2_enable(p); | 196 | sh_mtu2_enable(p); |
199 | break; | 197 | break; |
200 | case CLOCK_EVT_MODE_UNUSED: | 198 | case CLOCK_EVT_MODE_UNUSED: |
@@ -221,13 +219,13 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p, | |||
221 | ced->cpumask = cpumask_of(0); | 219 | ced->cpumask = cpumask_of(0); |
222 | ced->set_mode = sh_mtu2_clock_event_mode; | 220 | ced->set_mode = sh_mtu2_clock_event_mode; |
223 | 221 | ||
224 | pr_info("sh_mtu2: %s used for clock events\n", ced->name); | 222 | dev_info(&p->pdev->dev, "used for clock events\n"); |
225 | clockevents_register_device(ced); | 223 | clockevents_register_device(ced); |
226 | 224 | ||
227 | ret = setup_irq(p->irqaction.irq, &p->irqaction); | 225 | ret = setup_irq(p->irqaction.irq, &p->irqaction); |
228 | if (ret) { | 226 | if (ret) { |
229 | pr_err("sh_mtu2: failed to request irq %d\n", | 227 | dev_err(&p->pdev->dev, "failed to request irq %d\n", |
230 | p->irqaction.irq); | 228 | p->irqaction.irq); |
231 | return; | 229 | return; |
232 | } | 230 | } |
233 | } | 231 | } |
@@ -273,26 +271,31 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) | |||
273 | /* map memory, let mapbase point to our channel */ | 271 | /* map memory, let mapbase point to our channel */ |
274 | p->mapbase = ioremap_nocache(res->start, resource_size(res)); | 272 | p->mapbase = ioremap_nocache(res->start, resource_size(res)); |
275 | if (p->mapbase == NULL) { | 273 | if (p->mapbase == NULL) { |
276 | pr_err("sh_mtu2: failed to remap I/O memory\n"); | 274 | dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); |
277 | goto err0; | 275 | goto err0; |
278 | } | 276 | } |
279 | 277 | ||
280 | /* setup data for setup_irq() (too early for request_irq()) */ | 278 | /* setup data for setup_irq() (too early for request_irq()) */ |
281 | p->irqaction.name = cfg->name; | 279 | p->irqaction.name = dev_name(&p->pdev->dev); |
282 | p->irqaction.handler = sh_mtu2_interrupt; | 280 | p->irqaction.handler = sh_mtu2_interrupt; |
283 | p->irqaction.dev_id = p; | 281 | p->irqaction.dev_id = p; |
284 | p->irqaction.irq = irq; | 282 | p->irqaction.irq = irq; |
285 | p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL; | 283 | p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL; |
286 | 284 | ||
287 | /* get hold of clock */ | 285 | /* get hold of clock */ |
288 | p->clk = clk_get(&p->pdev->dev, cfg->clk); | 286 | p->clk = clk_get(&p->pdev->dev, "mtu2_fck"); |
289 | if (IS_ERR(p->clk)) { | 287 | if (IS_ERR(p->clk)) { |
290 | pr_err("sh_mtu2: cannot get clock \"%s\"\n", cfg->clk); | 288 | dev_warn(&p->pdev->dev, "using deprecated clock lookup\n"); |
291 | ret = PTR_ERR(p->clk); | 289 | p->clk = clk_get(&p->pdev->dev, cfg->clk); |
292 | goto err1; | 290 | if (IS_ERR(p->clk)) { |
291 | dev_err(&p->pdev->dev, "cannot get clock\n"); | ||
292 | ret = PTR_ERR(p->clk); | ||
293 | goto err1; | ||
294 | } | ||
293 | } | 295 | } |
294 | 296 | ||
295 | return sh_mtu2_register(p, cfg->name, cfg->clockevent_rating); | 297 | return sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev), |
298 | cfg->clockevent_rating); | ||
296 | err1: | 299 | err1: |
297 | iounmap(p->mapbase); | 300 | iounmap(p->mapbase); |
298 | err0: | 301 | err0: |
@@ -302,11 +305,10 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) | |||
302 | static int __devinit sh_mtu2_probe(struct platform_device *pdev) | 305 | static int __devinit sh_mtu2_probe(struct platform_device *pdev) |
303 | { | 306 | { |
304 | struct sh_mtu2_priv *p = platform_get_drvdata(pdev); | 307 | struct sh_mtu2_priv *p = platform_get_drvdata(pdev); |
305 | struct sh_timer_config *cfg = pdev->dev.platform_data; | ||
306 | int ret; | 308 | int ret; |
307 | 309 | ||
308 | if (p) { | 310 | if (p) { |
309 | pr_info("sh_mtu2: %s kept as earlytimer\n", cfg->name); | 311 | dev_info(&pdev->dev, "kept as earlytimer\n"); |
310 | return 0; | 312 | return 0; |
311 | } | 313 | } |
312 | 314 | ||
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 961f5b5ef6a3..6b62283c1aba 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c | |||
@@ -106,13 +106,12 @@ static void sh_tmu_start_stop_ch(struct sh_tmu_priv *p, int start) | |||
106 | 106 | ||
107 | static int sh_tmu_enable(struct sh_tmu_priv *p) | 107 | static int sh_tmu_enable(struct sh_tmu_priv *p) |
108 | { | 108 | { |
109 | struct sh_timer_config *cfg = p->pdev->dev.platform_data; | ||
110 | int ret; | 109 | int ret; |
111 | 110 | ||
112 | /* enable clock */ | 111 | /* enable clock */ |
113 | ret = clk_enable(p->clk); | 112 | ret = clk_enable(p->clk); |
114 | if (ret) { | 113 | if (ret) { |
115 | pr_err("sh_tmu: cannot enable clock \"%s\"\n", cfg->clk); | 114 | dev_err(&p->pdev->dev, "cannot enable clock\n"); |
116 | return ret; | 115 | return ret; |
117 | } | 116 | } |
118 | 117 | ||
@@ -228,7 +227,7 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p, | |||
228 | cs->disable = sh_tmu_clocksource_disable; | 227 | cs->disable = sh_tmu_clocksource_disable; |
229 | cs->mask = CLOCKSOURCE_MASK(32); | 228 | cs->mask = CLOCKSOURCE_MASK(32); |
230 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; | 229 | cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; |
231 | pr_info("sh_tmu: %s used as clock source\n", cs->name); | 230 | dev_info(&p->pdev->dev, "used as clock source\n"); |
232 | clocksource_register(cs); | 231 | clocksource_register(cs); |
233 | return 0; | 232 | return 0; |
234 | } | 233 | } |
@@ -276,13 +275,11 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode, | |||
276 | 275 | ||
277 | switch (mode) { | 276 | switch (mode) { |
278 | case CLOCK_EVT_MODE_PERIODIC: | 277 | case CLOCK_EVT_MODE_PERIODIC: |
279 | pr_info("sh_tmu: %s used for periodic clock events\n", | 278 | dev_info(&p->pdev->dev, "used for periodic clock events\n"); |
280 | ced->name); | ||
281 | sh_tmu_clock_event_start(p, 1); | 279 | sh_tmu_clock_event_start(p, 1); |
282 | break; | 280 | break; |
283 | case CLOCK_EVT_MODE_ONESHOT: | 281 | case CLOCK_EVT_MODE_ONESHOT: |
284 | pr_info("sh_tmu: %s used for oneshot clock events\n", | 282 | dev_info(&p->pdev->dev, "used for oneshot clock events\n"); |
285 | ced->name); | ||
286 | sh_tmu_clock_event_start(p, 0); | 283 | sh_tmu_clock_event_start(p, 0); |
287 | break; | 284 | break; |
288 | case CLOCK_EVT_MODE_UNUSED: | 285 | case CLOCK_EVT_MODE_UNUSED: |
@@ -323,13 +320,13 @@ static void sh_tmu_register_clockevent(struct sh_tmu_priv *p, | |||
323 | ced->set_next_event = sh_tmu_clock_event_next; | 320 | ced->set_next_event = sh_tmu_clock_event_next; |
324 | ced->set_mode = sh_tmu_clock_event_mode; | 321 | ced->set_mode = sh_tmu_clock_event_mode; |
325 | 322 | ||
326 | pr_info("sh_tmu: %s used for clock events\n", ced->name); | 323 | dev_info(&p->pdev->dev, "used for clock events\n"); |
327 | clockevents_register_device(ced); | 324 | clockevents_register_device(ced); |
328 | 325 | ||
329 | ret = setup_irq(p->irqaction.irq, &p->irqaction); | 326 | ret = setup_irq(p->irqaction.irq, &p->irqaction); |
330 | if (ret) { | 327 | if (ret) { |
331 | pr_err("sh_tmu: failed to request irq %d\n", | 328 | dev_err(&p->pdev->dev, "failed to request irq %d\n", |
332 | p->irqaction.irq); | 329 | p->irqaction.irq); |
333 | return; | 330 | return; |
334 | } | 331 | } |
335 | } | 332 | } |
@@ -378,26 +375,30 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) | |||
378 | /* map memory, let mapbase point to our channel */ | 375 | /* map memory, let mapbase point to our channel */ |
379 | p->mapbase = ioremap_nocache(res->start, resource_size(res)); | 376 | p->mapbase = ioremap_nocache(res->start, resource_size(res)); |
380 | if (p->mapbase == NULL) { | 377 | if (p->mapbase == NULL) { |
381 | pr_err("sh_tmu: failed to remap I/O memory\n"); | 378 | dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); |
382 | goto err0; | 379 | goto err0; |
383 | } | 380 | } |
384 | 381 | ||
385 | /* setup data for setup_irq() (too early for request_irq()) */ | 382 | /* setup data for setup_irq() (too early for request_irq()) */ |
386 | p->irqaction.name = cfg->name; | 383 | p->irqaction.name = dev_name(&p->pdev->dev); |
387 | p->irqaction.handler = sh_tmu_interrupt; | 384 | p->irqaction.handler = sh_tmu_interrupt; |
388 | p->irqaction.dev_id = p; | 385 | p->irqaction.dev_id = p; |
389 | p->irqaction.irq = irq; | 386 | p->irqaction.irq = irq; |
390 | p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL; | 387 | p->irqaction.flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL; |
391 | 388 | ||
392 | /* get hold of clock */ | 389 | /* get hold of clock */ |
393 | p->clk = clk_get(&p->pdev->dev, cfg->clk); | 390 | p->clk = clk_get(&p->pdev->dev, "tmu_fck"); |
394 | if (IS_ERR(p->clk)) { | 391 | if (IS_ERR(p->clk)) { |
395 | pr_err("sh_tmu: cannot get clock \"%s\"\n", cfg->clk); | 392 | dev_warn(&p->pdev->dev, "using deprecated clock lookup\n"); |
396 | ret = PTR_ERR(p->clk); | 393 | p->clk = clk_get(&p->pdev->dev, cfg->clk); |
397 | goto err1; | 394 | if (IS_ERR(p->clk)) { |
395 | dev_err(&p->pdev->dev, "cannot get clock\n"); | ||
396 | ret = PTR_ERR(p->clk); | ||
397 | goto err1; | ||
398 | } | ||
398 | } | 399 | } |
399 | 400 | ||
400 | return sh_tmu_register(p, cfg->name, | 401 | return sh_tmu_register(p, (char *)dev_name(&p->pdev->dev), |
401 | cfg->clockevent_rating, | 402 | cfg->clockevent_rating, |
402 | cfg->clocksource_rating); | 403 | cfg->clocksource_rating); |
403 | err1: | 404 | err1: |
@@ -409,11 +410,10 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) | |||
409 | static int __devinit sh_tmu_probe(struct platform_device *pdev) | 410 | static int __devinit sh_tmu_probe(struct platform_device *pdev) |
410 | { | 411 | { |
411 | struct sh_tmu_priv *p = platform_get_drvdata(pdev); | 412 | struct sh_tmu_priv *p = platform_get_drvdata(pdev); |
412 | struct sh_timer_config *cfg = pdev->dev.platform_data; | ||
413 | int ret; | 413 | int ret; |
414 | 414 | ||
415 | if (p) { | 415 | if (p) { |
416 | pr_info("sh_tmu: %s kept as earlytimer\n", cfg->name); | 416 | dev_info(&pdev->dev, "kept as earlytimer\n"); |
417 | return 0; | 417 | return 0; |
418 | } | 418 | } |
419 | 419 | ||
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c index 5d17e09cb625..7a18b580f626 100644 --- a/drivers/dma/shdma.c +++ b/drivers/dma/shdma.c | |||
@@ -25,8 +25,7 @@ | |||
25 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/pm_runtime.h> | 27 | #include <linux/pm_runtime.h> |
28 | 28 | #include <linux/sh_dma.h> | |
29 | #include <asm/dmaengine.h> | ||
30 | 29 | ||
31 | #include "shdma.h" | 30 | #include "shdma.h" |
32 | 31 | ||
@@ -44,7 +43,7 @@ enum sh_dmae_desc_status { | |||
44 | #define LOG2_DEFAULT_XFER_SIZE 2 | 43 | #define LOG2_DEFAULT_XFER_SIZE 2 |
45 | 44 | ||
46 | /* A bitmask with bits enough for enum sh_dmae_slave_chan_id */ | 45 | /* A bitmask with bits enough for enum sh_dmae_slave_chan_id */ |
47 | static unsigned long sh_dmae_slave_used[BITS_TO_LONGS(SHDMA_SLAVE_NUMBER)]; | 46 | static unsigned long sh_dmae_slave_used[BITS_TO_LONGS(SH_DMA_SLAVE_NUMBER)]; |
48 | 47 | ||
49 | static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan, bool all); | 48 | static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan, bool all); |
50 | 49 | ||
@@ -266,7 +265,7 @@ static struct sh_desc *sh_dmae_get_desc(struct sh_dmae_chan *sh_chan) | |||
266 | } | 265 | } |
267 | 266 | ||
268 | static struct sh_dmae_slave_config *sh_dmae_find_slave( | 267 | static struct sh_dmae_slave_config *sh_dmae_find_slave( |
269 | struct sh_dmae_chan *sh_chan, enum sh_dmae_slave_chan_id slave_id) | 268 | struct sh_dmae_chan *sh_chan, struct sh_dmae_slave *param) |
270 | { | 269 | { |
271 | struct dma_device *dma_dev = sh_chan->common.device; | 270 | struct dma_device *dma_dev = sh_chan->common.device; |
272 | struct sh_dmae_device *shdev = container_of(dma_dev, | 271 | struct sh_dmae_device *shdev = container_of(dma_dev, |
@@ -274,11 +273,11 @@ static struct sh_dmae_slave_config *sh_dmae_find_slave( | |||
274 | struct sh_dmae_pdata *pdata = shdev->pdata; | 273 | struct sh_dmae_pdata *pdata = shdev->pdata; |
275 | int i; | 274 | int i; |
276 | 275 | ||
277 | if ((unsigned)slave_id >= SHDMA_SLAVE_NUMBER) | 276 | if (param->slave_id >= SH_DMA_SLAVE_NUMBER) |
278 | return NULL; | 277 | return NULL; |
279 | 278 | ||
280 | for (i = 0; i < pdata->slave_num; i++) | 279 | for (i = 0; i < pdata->slave_num; i++) |
281 | if (pdata->slave[i].slave_id == slave_id) | 280 | if (pdata->slave[i].slave_id == param->slave_id) |
282 | return pdata->slave + i; | 281 | return pdata->slave + i; |
283 | 282 | ||
284 | return NULL; | 283 | return NULL; |
@@ -299,7 +298,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) | |||
299 | if (param) { | 298 | if (param) { |
300 | struct sh_dmae_slave_config *cfg; | 299 | struct sh_dmae_slave_config *cfg; |
301 | 300 | ||
302 | cfg = sh_dmae_find_slave(sh_chan, param->slave_id); | 301 | cfg = sh_dmae_find_slave(sh_chan, param); |
303 | if (!cfg) | 302 | if (!cfg) |
304 | return -EINVAL; | 303 | return -EINVAL; |
305 | 304 | ||
diff --git a/drivers/dma/shdma.h b/drivers/dma/shdma.h index 153609a1e96c..4021275a0a43 100644 --- a/drivers/dma/shdma.h +++ b/drivers/dma/shdma.h | |||
@@ -17,8 +17,8 @@ | |||
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/list.h> | 18 | #include <linux/list.h> |
19 | 19 | ||
20 | #include <asm/dmaengine.h> | 20 | #define SH_DMAC_MAX_CHANNELS 6 |
21 | 21 | #define SH_DMA_SLAVE_NUMBER 256 | |
22 | #define SH_DMA_TCR_MAX 0x00FFFFFF /* 16MB */ | 22 | #define SH_DMA_TCR_MAX 0x00FFFFFF /* 16MB */ |
23 | 23 | ||
24 | struct device; | 24 | struct device; |
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 309de6be8204..291bc08e2e84 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -82,16 +82,16 @@ struct sci_port { | |||
82 | 82 | ||
83 | /* Interface clock */ | 83 | /* Interface clock */ |
84 | struct clk *iclk; | 84 | struct clk *iclk; |
85 | /* Data clock */ | 85 | /* Function clock */ |
86 | struct clk *dclk; | 86 | struct clk *fclk; |
87 | 87 | ||
88 | struct list_head node; | 88 | struct list_head node; |
89 | struct dma_chan *chan_tx; | 89 | struct dma_chan *chan_tx; |
90 | struct dma_chan *chan_rx; | 90 | struct dma_chan *chan_rx; |
91 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | 91 | #ifdef CONFIG_SERIAL_SH_SCI_DMA |
92 | struct device *dma_dev; | 92 | struct device *dma_dev; |
93 | enum sh_dmae_slave_chan_id slave_tx; | 93 | unsigned int slave_tx; |
94 | enum sh_dmae_slave_chan_id slave_rx; | 94 | unsigned int slave_rx; |
95 | struct dma_async_tx_descriptor *desc_tx; | 95 | struct dma_async_tx_descriptor *desc_tx; |
96 | struct dma_async_tx_descriptor *desc_rx[2]; | 96 | struct dma_async_tx_descriptor *desc_rx[2]; |
97 | dma_cookie_t cookie_tx; | 97 | dma_cookie_t cookie_tx; |
@@ -106,6 +106,7 @@ struct sci_port { | |||
106 | struct work_struct work_tx; | 106 | struct work_struct work_tx; |
107 | struct work_struct work_rx; | 107 | struct work_struct work_rx; |
108 | struct timer_list rx_timer; | 108 | struct timer_list rx_timer; |
109 | unsigned int rx_timeout; | ||
109 | #endif | 110 | #endif |
110 | }; | 111 | }; |
111 | 112 | ||
@@ -673,22 +674,22 @@ static irqreturn_t sci_rx_interrupt(int irq, void *ptr) | |||
673 | struct sci_port *s = to_sci_port(port); | 674 | struct sci_port *s = to_sci_port(port); |
674 | 675 | ||
675 | if (s->chan_rx) { | 676 | if (s->chan_rx) { |
676 | unsigned long tout; | ||
677 | u16 scr = sci_in(port, SCSCR); | 677 | u16 scr = sci_in(port, SCSCR); |
678 | u16 ssr = sci_in(port, SCxSR); | 678 | u16 ssr = sci_in(port, SCxSR); |
679 | 679 | ||
680 | /* Disable future Rx interrupts */ | 680 | /* Disable future Rx interrupts */ |
681 | sci_out(port, SCSCR, scr & ~SCI_CTRL_FLAGS_RIE); | 681 | if (port->type == PORT_SCIFA) { |
682 | disable_irq_nosync(irq); | ||
683 | scr |= 0x4000; | ||
684 | } else { | ||
685 | scr &= ~SCI_CTRL_FLAGS_RIE; | ||
686 | } | ||
687 | sci_out(port, SCSCR, scr); | ||
682 | /* Clear current interrupt */ | 688 | /* Clear current interrupt */ |
683 | sci_out(port, SCxSR, ssr & ~(1 | SCxSR_RDxF(port))); | 689 | sci_out(port, SCxSR, ssr & ~(1 | SCxSR_RDxF(port))); |
684 | /* Calculate delay for 1.5 DMA buffers */ | 690 | dev_dbg(port->dev, "Rx IRQ %lu: setup t-out in %u jiffies\n", |
685 | tout = (port->timeout - HZ / 50) * s->buf_len_rx * 3 / | 691 | jiffies, s->rx_timeout); |
686 | port->fifosize / 2; | 692 | mod_timer(&s->rx_timer, jiffies + s->rx_timeout); |
687 | dev_dbg(port->dev, "Rx IRQ: setup timeout in %lu ms\n", | ||
688 | tout * 1000 / HZ); | ||
689 | if (tout < 2) | ||
690 | tout = 2; | ||
691 | mod_timer(&s->rx_timer, jiffies + tout); | ||
692 | 693 | ||
693 | return IRQ_HANDLED; | 694 | return IRQ_HANDLED; |
694 | } | 695 | } |
@@ -798,7 +799,7 @@ static int sci_notifier(struct notifier_block *self, | |||
798 | (phase == CPUFREQ_RESUMECHANGE)) { | 799 | (phase == CPUFREQ_RESUMECHANGE)) { |
799 | spin_lock_irqsave(&priv->lock, flags); | 800 | spin_lock_irqsave(&priv->lock, flags); |
800 | list_for_each_entry(sci_port, &priv->ports, node) | 801 | list_for_each_entry(sci_port, &priv->ports, node) |
801 | sci_port->port.uartclk = clk_get_rate(sci_port->dclk); | 802 | sci_port->port.uartclk = clk_get_rate(sci_port->iclk); |
802 | spin_unlock_irqrestore(&priv->lock, flags); | 803 | spin_unlock_irqrestore(&priv->lock, flags); |
803 | } | 804 | } |
804 | 805 | ||
@@ -809,21 +810,17 @@ static void sci_clk_enable(struct uart_port *port) | |||
809 | { | 810 | { |
810 | struct sci_port *sci_port = to_sci_port(port); | 811 | struct sci_port *sci_port = to_sci_port(port); |
811 | 812 | ||
812 | clk_enable(sci_port->dclk); | 813 | clk_enable(sci_port->iclk); |
813 | sci_port->port.uartclk = clk_get_rate(sci_port->dclk); | 814 | sci_port->port.uartclk = clk_get_rate(sci_port->iclk); |
814 | 815 | clk_enable(sci_port->fclk); | |
815 | if (sci_port->iclk) | ||
816 | clk_enable(sci_port->iclk); | ||
817 | } | 816 | } |
818 | 817 | ||
819 | static void sci_clk_disable(struct uart_port *port) | 818 | static void sci_clk_disable(struct uart_port *port) |
820 | { | 819 | { |
821 | struct sci_port *sci_port = to_sci_port(port); | 820 | struct sci_port *sci_port = to_sci_port(port); |
822 | 821 | ||
823 | if (sci_port->iclk) | 822 | clk_disable(sci_port->fclk); |
824 | clk_disable(sci_port->iclk); | 823 | clk_disable(sci_port->iclk); |
825 | |||
826 | clk_disable(sci_port->dclk); | ||
827 | } | 824 | } |
828 | 825 | ||
829 | static int sci_request_irq(struct sci_port *port) | 826 | static int sci_request_irq(struct sci_port *port) |
@@ -912,22 +909,26 @@ static void sci_dma_tx_complete(void *arg) | |||
912 | 909 | ||
913 | spin_lock_irqsave(&port->lock, flags); | 910 | spin_lock_irqsave(&port->lock, flags); |
914 | 911 | ||
915 | xmit->tail += s->sg_tx.length; | 912 | xmit->tail += sg_dma_len(&s->sg_tx); |
916 | xmit->tail &= UART_XMIT_SIZE - 1; | 913 | xmit->tail &= UART_XMIT_SIZE - 1; |
917 | 914 | ||
918 | port->icount.tx += s->sg_tx.length; | 915 | port->icount.tx += sg_dma_len(&s->sg_tx); |
919 | 916 | ||
920 | async_tx_ack(s->desc_tx); | 917 | async_tx_ack(s->desc_tx); |
921 | s->cookie_tx = -EINVAL; | 918 | s->cookie_tx = -EINVAL; |
922 | s->desc_tx = NULL; | 919 | s->desc_tx = NULL; |
923 | 920 | ||
924 | spin_unlock_irqrestore(&port->lock, flags); | ||
925 | |||
926 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 921 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
927 | uart_write_wakeup(port); | 922 | uart_write_wakeup(port); |
928 | 923 | ||
929 | if (uart_circ_chars_pending(xmit)) | 924 | if (!uart_circ_empty(xmit)) { |
930 | schedule_work(&s->work_tx); | 925 | schedule_work(&s->work_tx); |
926 | } else if (port->type == PORT_SCIFA) { | ||
927 | u16 ctrl = sci_in(port, SCSCR); | ||
928 | sci_out(port, SCSCR, ctrl & ~SCI_CTRL_FLAGS_TIE); | ||
929 | } | ||
930 | |||
931 | spin_unlock_irqrestore(&port->lock, flags); | ||
931 | } | 932 | } |
932 | 933 | ||
933 | /* Locking: called with port lock held */ | 934 | /* Locking: called with port lock held */ |
@@ -971,13 +972,13 @@ static void sci_dma_rx_complete(void *arg) | |||
971 | unsigned long flags; | 972 | unsigned long flags; |
972 | int count; | 973 | int count; |
973 | 974 | ||
974 | dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); | 975 | dev_dbg(port->dev, "%s(%d) active #%d\n", __func__, port->line, s->active_rx); |
975 | 976 | ||
976 | spin_lock_irqsave(&port->lock, flags); | 977 | spin_lock_irqsave(&port->lock, flags); |
977 | 978 | ||
978 | count = sci_dma_rx_push(s, tty, s->buf_len_rx); | 979 | count = sci_dma_rx_push(s, tty, s->buf_len_rx); |
979 | 980 | ||
980 | mod_timer(&s->rx_timer, jiffies + msecs_to_jiffies(5)); | 981 | mod_timer(&s->rx_timer, jiffies + s->rx_timeout); |
981 | 982 | ||
982 | spin_unlock_irqrestore(&port->lock, flags); | 983 | spin_unlock_irqrestore(&port->lock, flags); |
983 | 984 | ||
@@ -1049,6 +1050,8 @@ static void sci_submit_rx(struct sci_port *s) | |||
1049 | sci_rx_dma_release(s, true); | 1050 | sci_rx_dma_release(s, true); |
1050 | return; | 1051 | return; |
1051 | } | 1052 | } |
1053 | dev_dbg(s->port.dev, "%s(): cookie %d to #%d\n", __func__, | ||
1054 | s->cookie_rx[i], i); | ||
1052 | } | 1055 | } |
1053 | 1056 | ||
1054 | s->active_rx = s->cookie_rx[0]; | 1057 | s->active_rx = s->cookie_rx[0]; |
@@ -1106,10 +1109,10 @@ static void work_fn_rx(struct work_struct *work) | |||
1106 | return; | 1109 | return; |
1107 | } | 1110 | } |
1108 | 1111 | ||
1109 | dev_dbg(port->dev, "%s: cookie %d #%d\n", __func__, | ||
1110 | s->cookie_rx[new], new); | ||
1111 | |||
1112 | s->active_rx = s->cookie_rx[!new]; | 1112 | s->active_rx = s->cookie_rx[!new]; |
1113 | |||
1114 | dev_dbg(port->dev, "%s: cookie %d #%d, new active #%d\n", __func__, | ||
1115 | s->cookie_rx[new], new, s->active_rx); | ||
1113 | } | 1116 | } |
1114 | 1117 | ||
1115 | static void work_fn_tx(struct work_struct *work) | 1118 | static void work_fn_tx(struct work_struct *work) |
@@ -1130,14 +1133,13 @@ static void work_fn_tx(struct work_struct *work) | |||
1130 | */ | 1133 | */ |
1131 | spin_lock_irq(&port->lock); | 1134 | spin_lock_irq(&port->lock); |
1132 | sg->offset = xmit->tail & (UART_XMIT_SIZE - 1); | 1135 | sg->offset = xmit->tail & (UART_XMIT_SIZE - 1); |
1133 | sg->dma_address = (sg_dma_address(sg) & ~(UART_XMIT_SIZE - 1)) + | 1136 | sg_dma_address(sg) = (sg_dma_address(sg) & ~(UART_XMIT_SIZE - 1)) + |
1134 | sg->offset; | 1137 | sg->offset; |
1135 | sg->length = min((int)CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE), | 1138 | sg_dma_len(sg) = min((int)CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE), |
1136 | CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE)); | 1139 | CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE)); |
1137 | sg->dma_length = sg->length; | ||
1138 | spin_unlock_irq(&port->lock); | 1140 | spin_unlock_irq(&port->lock); |
1139 | 1141 | ||
1140 | BUG_ON(!sg->length); | 1142 | BUG_ON(!sg_dma_len(sg)); |
1141 | 1143 | ||
1142 | desc = chan->device->device_prep_slave_sg(chan, | 1144 | desc = chan->device->device_prep_slave_sg(chan, |
1143 | sg, s->sg_len_tx, DMA_TO_DEVICE, | 1145 | sg, s->sg_len_tx, DMA_TO_DEVICE, |
@@ -1172,23 +1174,28 @@ static void work_fn_tx(struct work_struct *work) | |||
1172 | 1174 | ||
1173 | static void sci_start_tx(struct uart_port *port) | 1175 | static void sci_start_tx(struct uart_port *port) |
1174 | { | 1176 | { |
1177 | struct sci_port *s = to_sci_port(port); | ||
1175 | unsigned short ctrl; | 1178 | unsigned short ctrl; |
1176 | 1179 | ||
1177 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | 1180 | #ifdef CONFIG_SERIAL_SH_SCI_DMA |
1178 | struct sci_port *s = to_sci_port(port); | 1181 | if (port->type == PORT_SCIFA) { |
1179 | 1182 | u16 new, scr = sci_in(port, SCSCR); | |
1180 | if (s->chan_tx) { | 1183 | if (s->chan_tx) |
1181 | if (!uart_circ_empty(&s->port.state->xmit) && s->cookie_tx < 0) | 1184 | new = scr | 0x8000; |
1182 | schedule_work(&s->work_tx); | 1185 | else |
1183 | 1186 | new = scr & ~0x8000; | |
1184 | return; | 1187 | if (new != scr) |
1188 | sci_out(port, SCSCR, new); | ||
1185 | } | 1189 | } |
1190 | if (s->chan_tx && !uart_circ_empty(&s->port.state->xmit) && | ||
1191 | s->cookie_tx < 0) | ||
1192 | schedule_work(&s->work_tx); | ||
1186 | #endif | 1193 | #endif |
1187 | 1194 | if (!s->chan_tx || port->type == PORT_SCIFA) { | |
1188 | /* Set TIE (Transmit Interrupt Enable) bit in SCSCR */ | 1195 | /* Set TIE (Transmit Interrupt Enable) bit in SCSCR */ |
1189 | ctrl = sci_in(port, SCSCR); | 1196 | ctrl = sci_in(port, SCSCR); |
1190 | ctrl |= SCI_CTRL_FLAGS_TIE; | 1197 | sci_out(port, SCSCR, ctrl | SCI_CTRL_FLAGS_TIE); |
1191 | sci_out(port, SCSCR, ctrl); | 1198 | } |
1192 | } | 1199 | } |
1193 | 1200 | ||
1194 | static void sci_stop_tx(struct uart_port *port) | 1201 | static void sci_stop_tx(struct uart_port *port) |
@@ -1197,6 +1204,8 @@ static void sci_stop_tx(struct uart_port *port) | |||
1197 | 1204 | ||
1198 | /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */ | 1205 | /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */ |
1199 | ctrl = sci_in(port, SCSCR); | 1206 | ctrl = sci_in(port, SCSCR); |
1207 | if (port->type == PORT_SCIFA) | ||
1208 | ctrl &= ~0x8000; | ||
1200 | ctrl &= ~SCI_CTRL_FLAGS_TIE; | 1209 | ctrl &= ~SCI_CTRL_FLAGS_TIE; |
1201 | sci_out(port, SCSCR, ctrl); | 1210 | sci_out(port, SCSCR, ctrl); |
1202 | } | 1211 | } |
@@ -1207,6 +1216,8 @@ static void sci_start_rx(struct uart_port *port) | |||
1207 | 1216 | ||
1208 | /* Set RIE (Receive Interrupt Enable) bit in SCSCR */ | 1217 | /* Set RIE (Receive Interrupt Enable) bit in SCSCR */ |
1209 | ctrl |= sci_in(port, SCSCR); | 1218 | ctrl |= sci_in(port, SCSCR); |
1219 | if (port->type == PORT_SCIFA) | ||
1220 | ctrl &= ~0x4000; | ||
1210 | sci_out(port, SCSCR, ctrl); | 1221 | sci_out(port, SCSCR, ctrl); |
1211 | } | 1222 | } |
1212 | 1223 | ||
@@ -1216,6 +1227,8 @@ static void sci_stop_rx(struct uart_port *port) | |||
1216 | 1227 | ||
1217 | /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */ | 1228 | /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */ |
1218 | ctrl = sci_in(port, SCSCR); | 1229 | ctrl = sci_in(port, SCSCR); |
1230 | if (port->type == PORT_SCIFA) | ||
1231 | ctrl &= ~0x4000; | ||
1219 | ctrl &= ~(SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE); | 1232 | ctrl &= ~(SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE); |
1220 | sci_out(port, SCSCR, ctrl); | 1233 | sci_out(port, SCSCR, ctrl); |
1221 | } | 1234 | } |
@@ -1250,8 +1263,12 @@ static void rx_timer_fn(unsigned long arg) | |||
1250 | { | 1263 | { |
1251 | struct sci_port *s = (struct sci_port *)arg; | 1264 | struct sci_port *s = (struct sci_port *)arg; |
1252 | struct uart_port *port = &s->port; | 1265 | struct uart_port *port = &s->port; |
1253 | |||
1254 | u16 scr = sci_in(port, SCSCR); | 1266 | u16 scr = sci_in(port, SCSCR); |
1267 | |||
1268 | if (port->type == PORT_SCIFA) { | ||
1269 | scr &= ~0x4000; | ||
1270 | enable_irq(s->irqs[1]); | ||
1271 | } | ||
1255 | sci_out(port, SCSCR, scr | SCI_CTRL_FLAGS_RIE); | 1272 | sci_out(port, SCSCR, scr | SCI_CTRL_FLAGS_RIE); |
1256 | dev_dbg(port->dev, "DMA Rx timed out\n"); | 1273 | dev_dbg(port->dev, "DMA Rx timed out\n"); |
1257 | schedule_work(&s->work_rx); | 1274 | schedule_work(&s->work_rx); |
@@ -1338,8 +1355,7 @@ static void sci_request_dma(struct uart_port *port) | |||
1338 | sg_init_table(sg, 1); | 1355 | sg_init_table(sg, 1); |
1339 | sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx, | 1356 | sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx, |
1340 | (int)buf[i] & ~PAGE_MASK); | 1357 | (int)buf[i] & ~PAGE_MASK); |
1341 | sg->dma_address = dma[i]; | 1358 | sg_dma_address(sg) = dma[i]; |
1342 | sg->dma_length = sg->length; | ||
1343 | } | 1359 | } |
1344 | 1360 | ||
1345 | INIT_WORK(&s->work_rx, work_fn_rx); | 1361 | INIT_WORK(&s->work_rx, work_fn_rx); |
@@ -1402,8 +1418,12 @@ static void sci_shutdown(struct uart_port *port) | |||
1402 | static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | 1418 | static void sci_set_termios(struct uart_port *port, struct ktermios *termios, |
1403 | struct ktermios *old) | 1419 | struct ktermios *old) |
1404 | { | 1420 | { |
1421 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | ||
1422 | struct sci_port *s = to_sci_port(port); | ||
1423 | #endif | ||
1405 | unsigned int status, baud, smr_val, max_baud; | 1424 | unsigned int status, baud, smr_val, max_baud; |
1406 | int t = -1; | 1425 | int t = -1; |
1426 | u16 scfcr = 0; | ||
1407 | 1427 | ||
1408 | /* | 1428 | /* |
1409 | * earlyprintk comes here early on with port->uartclk set to zero. | 1429 | * earlyprintk comes here early on with port->uartclk set to zero. |
@@ -1426,7 +1446,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1426 | sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ | 1446 | sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ |
1427 | 1447 | ||
1428 | if (port->type != PORT_SCI) | 1448 | if (port->type != PORT_SCI) |
1429 | sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); | 1449 | sci_out(port, SCFCR, scfcr | SCFCR_RFRST | SCFCR_TFRST); |
1430 | 1450 | ||
1431 | smr_val = sci_in(port, SCSMR) & 3; | 1451 | smr_val = sci_in(port, SCSMR) & 3; |
1432 | if ((termios->c_cflag & CSIZE) == CS7) | 1452 | if ((termios->c_cflag & CSIZE) == CS7) |
@@ -1457,10 +1477,32 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1457 | } | 1477 | } |
1458 | 1478 | ||
1459 | sci_init_pins(port, termios->c_cflag); | 1479 | sci_init_pins(port, termios->c_cflag); |
1460 | sci_out(port, SCFCR, (termios->c_cflag & CRTSCTS) ? SCFCR_MCE : 0); | 1480 | sci_out(port, SCFCR, scfcr | ((termios->c_cflag & CRTSCTS) ? SCFCR_MCE : 0)); |
1461 | 1481 | ||
1462 | sci_out(port, SCSCR, SCSCR_INIT(port)); | 1482 | sci_out(port, SCSCR, SCSCR_INIT(port)); |
1463 | 1483 | ||
1484 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | ||
1485 | /* | ||
1486 | * Calculate delay for 1.5 DMA buffers: see | ||
1487 | * drivers/serial/serial_core.c::uart_update_timeout(). With 10 bits | ||
1488 | * (CS8), 250Hz, 115200 baud and 64 bytes FIFO, the above function | ||
1489 | * calculates 1 jiffie for the data plus 5 jiffies for the "slop(e)." | ||
1490 | * Then below we calculate 3 jiffies (12ms) for 1.5 DMA buffers (3 FIFO | ||
1491 | * sizes), but it has been found out experimentally, that this is not | ||
1492 | * enough: the driver too often needlessly runs on a DMA timeout. 20ms | ||
1493 | * as a minimum seem to work perfectly. | ||
1494 | */ | ||
1495 | if (s->chan_rx) { | ||
1496 | s->rx_timeout = (port->timeout - HZ / 50) * s->buf_len_rx * 3 / | ||
1497 | port->fifosize / 2; | ||
1498 | dev_dbg(port->dev, | ||
1499 | "DMA Rx t-out %ums, tty t-out %u jiffies\n", | ||
1500 | s->rx_timeout * 1000 / HZ, port->timeout); | ||
1501 | if (s->rx_timeout < msecs_to_jiffies(20)) | ||
1502 | s->rx_timeout = msecs_to_jiffies(20); | ||
1503 | } | ||
1504 | #endif | ||
1505 | |||
1464 | if ((termios->c_cflag & CREAD) != 0) | 1506 | if ((termios->c_cflag & CREAD) != 0) |
1465 | sci_start_rx(port); | 1507 | sci_start_rx(port); |
1466 | } | 1508 | } |
@@ -1552,10 +1594,10 @@ static struct uart_ops sci_uart_ops = { | |||
1552 | #endif | 1594 | #endif |
1553 | }; | 1595 | }; |
1554 | 1596 | ||
1555 | static void __devinit sci_init_single(struct platform_device *dev, | 1597 | static int __devinit sci_init_single(struct platform_device *dev, |
1556 | struct sci_port *sci_port, | 1598 | struct sci_port *sci_port, |
1557 | unsigned int index, | 1599 | unsigned int index, |
1558 | struct plat_sci_port *p) | 1600 | struct plat_sci_port *p) |
1559 | { | 1601 | { |
1560 | struct uart_port *port = &sci_port->port; | 1602 | struct uart_port *port = &sci_port->port; |
1561 | 1603 | ||
@@ -1576,8 +1618,23 @@ static void __devinit sci_init_single(struct platform_device *dev, | |||
1576 | } | 1618 | } |
1577 | 1619 | ||
1578 | if (dev) { | 1620 | if (dev) { |
1579 | sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL; | 1621 | sci_port->iclk = clk_get(&dev->dev, "sci_ick"); |
1580 | sci_port->dclk = clk_get(&dev->dev, "peripheral_clk"); | 1622 | if (IS_ERR(sci_port->iclk)) { |
1623 | sci_port->iclk = clk_get(&dev->dev, "peripheral_clk"); | ||
1624 | if (IS_ERR(sci_port->iclk)) { | ||
1625 | dev_err(&dev->dev, "can't get iclk\n"); | ||
1626 | return PTR_ERR(sci_port->iclk); | ||
1627 | } | ||
1628 | } | ||
1629 | |||
1630 | /* | ||
1631 | * The function clock is optional, ignore it if we can't | ||
1632 | * find it. | ||
1633 | */ | ||
1634 | sci_port->fclk = clk_get(&dev->dev, "sci_fck"); | ||
1635 | if (IS_ERR(sci_port->fclk)) | ||
1636 | sci_port->fclk = NULL; | ||
1637 | |||
1581 | sci_port->enable = sci_clk_enable; | 1638 | sci_port->enable = sci_clk_enable; |
1582 | sci_port->disable = sci_clk_disable; | 1639 | sci_port->disable = sci_clk_disable; |
1583 | port->dev = &dev->dev; | 1640 | port->dev = &dev->dev; |
@@ -1604,6 +1661,7 @@ static void __devinit sci_init_single(struct platform_device *dev, | |||
1604 | #endif | 1661 | #endif |
1605 | 1662 | ||
1606 | memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); | 1663 | memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); |
1664 | return 0; | ||
1607 | } | 1665 | } |
1608 | 1666 | ||
1609 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE | 1667 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE |
@@ -1753,8 +1811,11 @@ static int sci_remove(struct platform_device *dev) | |||
1753 | cpufreq_unregister_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); | 1811 | cpufreq_unregister_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); |
1754 | 1812 | ||
1755 | spin_lock_irqsave(&priv->lock, flags); | 1813 | spin_lock_irqsave(&priv->lock, flags); |
1756 | list_for_each_entry(p, &priv->ports, node) | 1814 | list_for_each_entry(p, &priv->ports, node) { |
1757 | uart_remove_one_port(&sci_uart_driver, &p->port); | 1815 | uart_remove_one_port(&sci_uart_driver, &p->port); |
1816 | clk_put(p->iclk); | ||
1817 | clk_put(p->fclk); | ||
1818 | } | ||
1758 | spin_unlock_irqrestore(&priv->lock, flags); | 1819 | spin_unlock_irqrestore(&priv->lock, flags); |
1759 | 1820 | ||
1760 | kfree(priv); | 1821 | kfree(priv); |
@@ -1780,7 +1841,9 @@ static int __devinit sci_probe_single(struct platform_device *dev, | |||
1780 | return 0; | 1841 | return 0; |
1781 | } | 1842 | } |
1782 | 1843 | ||
1783 | sci_init_single(dev, sciport, index, p); | 1844 | ret = sci_init_single(dev, sciport, index, p); |
1845 | if (ret) | ||
1846 | return ret; | ||
1784 | 1847 | ||
1785 | ret = uart_add_one_port(&sci_uart_driver, &sciport->port); | 1848 | ret = uart_add_one_port(&sci_uart_driver, &sciport->port); |
1786 | if (ret) | 1849 | if (ret) |
diff --git a/drivers/sh/intc.c b/drivers/sh/intc.c index a3d8677af6a5..f43850527645 100644 --- a/drivers/sh/intc.c +++ b/drivers/sh/intc.c | |||
@@ -44,6 +44,12 @@ struct intc_handle_int { | |||
44 | unsigned long handle; | 44 | unsigned long handle; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | struct intc_window { | ||
48 | phys_addr_t phys; | ||
49 | void __iomem *virt; | ||
50 | unsigned long size; | ||
51 | }; | ||
52 | |||
47 | struct intc_desc_int { | 53 | struct intc_desc_int { |
48 | struct list_head list; | 54 | struct list_head list; |
49 | struct sys_device sysdev; | 55 | struct sys_device sysdev; |
@@ -57,6 +63,8 @@ struct intc_desc_int { | |||
57 | unsigned int nr_prio; | 63 | unsigned int nr_prio; |
58 | struct intc_handle_int *sense; | 64 | struct intc_handle_int *sense; |
59 | unsigned int nr_sense; | 65 | unsigned int nr_sense; |
66 | struct intc_window *window; | ||
67 | unsigned int nr_windows; | ||
60 | struct irq_chip chip; | 68 | struct irq_chip chip; |
61 | }; | 69 | }; |
62 | 70 | ||
@@ -446,11 +454,39 @@ static int intc_set_sense(unsigned int irq, unsigned int type) | |||
446 | return 0; | 454 | return 0; |
447 | } | 455 | } |
448 | 456 | ||
457 | static unsigned long intc_phys_to_virt(struct intc_desc_int *d, | ||
458 | unsigned long address) | ||
459 | { | ||
460 | struct intc_window *window; | ||
461 | int k; | ||
462 | |||
463 | /* scan through physical windows and convert address */ | ||
464 | for (k = 0; k < d->nr_windows; k++) { | ||
465 | window = d->window + k; | ||
466 | |||
467 | if (address < window->phys) | ||
468 | continue; | ||
469 | |||
470 | if (address >= (window->phys + window->size)) | ||
471 | continue; | ||
472 | |||
473 | address -= window->phys; | ||
474 | address += (unsigned long)window->virt; | ||
475 | |||
476 | return address; | ||
477 | } | ||
478 | |||
479 | /* no windows defined, register must be 1:1 mapped virt:phys */ | ||
480 | return address; | ||
481 | } | ||
482 | |||
449 | static unsigned int __init intc_get_reg(struct intc_desc_int *d, | 483 | static unsigned int __init intc_get_reg(struct intc_desc_int *d, |
450 | unsigned long address) | 484 | unsigned long address) |
451 | { | 485 | { |
452 | unsigned int k; | 486 | unsigned int k; |
453 | 487 | ||
488 | address = intc_phys_to_virt(d, address); | ||
489 | |||
454 | for (k = 0; k < d->nr_reg; k++) { | 490 | for (k = 0; k < d->nr_reg; k++) { |
455 | if (d->reg[k] == address) | 491 | if (d->reg[k] == address) |
456 | return k; | 492 | return k; |
@@ -800,6 +836,8 @@ static unsigned int __init save_reg(struct intc_desc_int *d, | |||
800 | unsigned int smp) | 836 | unsigned int smp) |
801 | { | 837 | { |
802 | if (value) { | 838 | if (value) { |
839 | value = intc_phys_to_virt(d, value); | ||
840 | |||
803 | d->reg[cnt] = value; | 841 | d->reg[cnt] = value; |
804 | #ifdef CONFIG_SMP | 842 | #ifdef CONFIG_SMP |
805 | d->smp[cnt] = smp; | 843 | d->smp[cnt] = smp; |
@@ -815,25 +853,52 @@ static void intc_redirect_irq(unsigned int irq, struct irq_desc *desc) | |||
815 | generic_handle_irq((unsigned int)get_irq_data(irq)); | 853 | generic_handle_irq((unsigned int)get_irq_data(irq)); |
816 | } | 854 | } |
817 | 855 | ||
818 | void __init register_intc_controller(struct intc_desc *desc) | 856 | int __init register_intc_controller(struct intc_desc *desc) |
819 | { | 857 | { |
820 | unsigned int i, k, smp; | 858 | unsigned int i, k, smp; |
821 | struct intc_hw_desc *hw = &desc->hw; | 859 | struct intc_hw_desc *hw = &desc->hw; |
822 | struct intc_desc_int *d; | 860 | struct intc_desc_int *d; |
861 | struct resource *res; | ||
823 | 862 | ||
824 | d = kzalloc(sizeof(*d), GFP_NOWAIT); | 863 | d = kzalloc(sizeof(*d), GFP_NOWAIT); |
864 | if (!d) | ||
865 | goto err0; | ||
825 | 866 | ||
826 | INIT_LIST_HEAD(&d->list); | 867 | INIT_LIST_HEAD(&d->list); |
827 | list_add(&d->list, &intc_list); | 868 | list_add(&d->list, &intc_list); |
828 | 869 | ||
870 | if (desc->num_resources) { | ||
871 | d->nr_windows = desc->num_resources; | ||
872 | d->window = kzalloc(d->nr_windows * sizeof(*d->window), | ||
873 | GFP_NOWAIT); | ||
874 | if (!d->window) | ||
875 | goto err1; | ||
876 | |||
877 | for (k = 0; k < d->nr_windows; k++) { | ||
878 | res = desc->resource + k; | ||
879 | WARN_ON(resource_type(res) != IORESOURCE_MEM); | ||
880 | d->window[k].phys = res->start; | ||
881 | d->window[k].size = resource_size(res); | ||
882 | d->window[k].virt = ioremap_nocache(res->start, | ||
883 | resource_size(res)); | ||
884 | if (!d->window[k].virt) | ||
885 | goto err2; | ||
886 | } | ||
887 | } | ||
888 | |||
829 | d->nr_reg = hw->mask_regs ? hw->nr_mask_regs * 2 : 0; | 889 | d->nr_reg = hw->mask_regs ? hw->nr_mask_regs * 2 : 0; |
830 | d->nr_reg += hw->prio_regs ? hw->nr_prio_regs * 2 : 0; | 890 | d->nr_reg += hw->prio_regs ? hw->nr_prio_regs * 2 : 0; |
831 | d->nr_reg += hw->sense_regs ? hw->nr_sense_regs : 0; | 891 | d->nr_reg += hw->sense_regs ? hw->nr_sense_regs : 0; |
832 | d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0; | 892 | d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0; |
833 | 893 | ||
834 | d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT); | 894 | d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT); |
895 | if (!d->reg) | ||
896 | goto err2; | ||
897 | |||
835 | #ifdef CONFIG_SMP | 898 | #ifdef CONFIG_SMP |
836 | d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT); | 899 | d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT); |
900 | if (!d->smp) | ||
901 | goto err3; | ||
837 | #endif | 902 | #endif |
838 | k = 0; | 903 | k = 0; |
839 | 904 | ||
@@ -848,6 +913,8 @@ void __init register_intc_controller(struct intc_desc *desc) | |||
848 | if (hw->prio_regs) { | 913 | if (hw->prio_regs) { |
849 | d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio), | 914 | d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio), |
850 | GFP_NOWAIT); | 915 | GFP_NOWAIT); |
916 | if (!d->prio) | ||
917 | goto err4; | ||
851 | 918 | ||
852 | for (i = 0; i < hw->nr_prio_regs; i++) { | 919 | for (i = 0; i < hw->nr_prio_regs; i++) { |
853 | smp = IS_SMP(hw->prio_regs[i]); | 920 | smp = IS_SMP(hw->prio_regs[i]); |
@@ -859,6 +926,8 @@ void __init register_intc_controller(struct intc_desc *desc) | |||
859 | if (hw->sense_regs) { | 926 | if (hw->sense_regs) { |
860 | d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense), | 927 | d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense), |
861 | GFP_NOWAIT); | 928 | GFP_NOWAIT); |
929 | if (!d->sense) | ||
930 | goto err5; | ||
862 | 931 | ||
863 | for (i = 0; i < hw->nr_sense_regs; i++) | 932 | for (i = 0; i < hw->nr_sense_regs; i++) |
864 | k += save_reg(d, k, hw->sense_regs[i].reg, 0); | 933 | k += save_reg(d, k, hw->sense_regs[i].reg, 0); |
@@ -941,6 +1010,28 @@ void __init register_intc_controller(struct intc_desc *desc) | |||
941 | /* enable bits matching force_enable after registering irqs */ | 1010 | /* enable bits matching force_enable after registering irqs */ |
942 | if (desc->force_enable) | 1011 | if (desc->force_enable) |
943 | intc_enable_disable_enum(desc, d, desc->force_enable, 1); | 1012 | intc_enable_disable_enum(desc, d, desc->force_enable, 1); |
1013 | |||
1014 | return 0; | ||
1015 | err5: | ||
1016 | kfree(d->prio); | ||
1017 | err4: | ||
1018 | #ifdef CONFIG_SMP | ||
1019 | kfree(d->smp); | ||
1020 | err3: | ||
1021 | #endif | ||
1022 | kfree(d->reg); | ||
1023 | err2: | ||
1024 | for (k = 0; k < d->nr_windows; k++) | ||
1025 | if (d->window[k].virt) | ||
1026 | iounmap(d->window[k].virt); | ||
1027 | |||
1028 | kfree(d->window); | ||
1029 | err1: | ||
1030 | kfree(d); | ||
1031 | err0: | ||
1032 | pr_err("unable to allocate INTC memory\n"); | ||
1033 | |||
1034 | return -ENOMEM; | ||
944 | } | 1035 | } |
945 | 1036 | ||
946 | static int intc_suspend(struct sys_device *dev, pm_message_t state) | 1037 | static int intc_suspend(struct sys_device *dev, pm_message_t state) |