Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
[linux-2.6] / arch / avr32 / mach-at32ap / at32ap.c
1 /*
2  * Copyright (C) 2006 Atmel Corporation
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8
9 #include <linux/clk.h>
10 #include <linux/err.h>
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13
14 #include <asm/io.h>
15
16 #include <asm/arch/init.h>
17 #include <asm/arch/sm.h>
18
19 struct at32_sm system_manager;
20
21 static int __init at32_sm_init(void)
22 {
23         struct resource *regs;
24         struct at32_sm *sm = &system_manager;
25         int ret = -ENXIO;
26
27         regs = platform_get_resource(&at32_sm_device, IORESOURCE_MEM, 0);
28         if (!regs)
29                 goto fail;
30
31         spin_lock_init(&sm->lock);
32         sm->pdev = &at32_sm_device;
33
34         ret = -ENOMEM;
35         sm->regs = ioremap(regs->start, regs->end - regs->start + 1);
36         if (!sm->regs)
37                 goto fail;
38
39         return 0;
40
41 fail:
42         printk(KERN_ERR "Failed to initialize System Manager: %d\n", ret);
43         return ret;
44 }
45
46 void __init setup_platform(void)
47 {
48         at32_sm_init();
49         at32_clock_init();
50         at32_portmux_init();
51 }
52
53 static int __init pdc_probe(struct platform_device *pdev)
54 {
55         struct clk *pclk, *hclk;
56
57         pclk = clk_get(&pdev->dev, "pclk");
58         if (IS_ERR(pclk)) {
59                 dev_err(&pdev->dev, "no pclk defined\n");
60                 return PTR_ERR(pclk);
61         }
62         hclk = clk_get(&pdev->dev, "hclk");
63         if (IS_ERR(hclk)) {
64                 dev_err(&pdev->dev, "no hclk defined\n");
65                 clk_put(pclk);
66                 return PTR_ERR(hclk);
67         }
68
69         clk_enable(pclk);
70         clk_enable(hclk);
71
72         dev_info(&pdev->dev, "Atmel Peripheral DMA Controller enabled\n");
73         return 0;
74 }
75
76 static struct platform_driver pdc_driver = {
77         .probe          = pdc_probe,
78         .driver         = {
79                 .name   = "pdc",
80         },
81 };
82
83 static int __init pdc_init(void)
84 {
85         return platform_driver_register(&pdc_driver);
86 }
87 arch_initcall(pdc_init);