]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - arch/arm/mach-omap/ocpi.c
[SPARC64]: Add syscall auditing support.
[linux-2.6.git] / arch / arm / mach-omap / ocpi.c
1 /*
2  * linux/arch/arm/mach-omap/ocpi.c
3  *
4  * Minimal OCP bus support for omap16xx
5  *
6  * Copyright (C) 2003 - 2005 Nokia Corporation
7  * Written by Tony Lindgren <tony@atomide.com>
8  *
9  * Modified for clock framework by Paul Mundt <paul.mundt@nokia.com>.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  */
25
26 #include <linux/config.h>
27 #include <linux/module.h>
28 #include <linux/version.h>
29 #include <linux/types.h>
30 #include <linux/errno.h>
31 #include <linux/kernel.h>
32 #include <linux/init.h>
33 #include <linux/spinlock.h>
34 #include <linux/err.h>
35
36 #include <asm/io.h>
37 #include <asm/hardware/clock.h>
38 #include <asm/arch/hardware.h>
39
40 #define OCPI_BASE               0xfffec320
41 #define OCPI_FAULT              (OCPI_BASE + 0x00)
42 #define OCPI_CMD_FAULT          (OCPI_BASE + 0x04)
43 #define OCPI_SINT0              (OCPI_BASE + 0x08)
44 #define OCPI_TABORT             (OCPI_BASE + 0x0c)
45 #define OCPI_SINT1              (OCPI_BASE + 0x10)
46 #define OCPI_PROT               (OCPI_BASE + 0x14)
47 #define OCPI_SEC                (OCPI_BASE + 0x18)
48
49 /* USB OHCI OCPI access error registers */
50 #define HOSTUEADDR      0xfffba0e0
51 #define HOSTUESTATUS    0xfffba0e4
52
53 static struct clk *ocpi_ck;
54
55 /*
56  * Enables device access to OMAP buses via the OCPI bridge
57  * FIXME: Add locking
58  */
59 int ocpi_enable(void)
60 {
61         unsigned int val;
62
63         if (!cpu_is_omap16xx())
64                 return -ENODEV;
65
66         /* Make sure there's clock for OCPI */
67         clk_enable(ocpi_ck);
68
69         /* Enable access for OHCI in OCPI */
70         val = omap_readl(OCPI_PROT);
71         val &= ~0xff;
72         //val &= (1 << 0);      /* Allow access only to EMIFS */
73         omap_writel(val, OCPI_PROT);
74
75         val = omap_readl(OCPI_SEC);
76         val &= ~0xff;
77         omap_writel(val, OCPI_SEC);
78
79         return 0;
80 }
81 EXPORT_SYMBOL(ocpi_enable);
82
83 static int __init omap_ocpi_init(void)
84 {
85         if (!cpu_is_omap16xx())
86                 return -ENODEV;
87
88         ocpi_ck = clk_get(NULL, "l3_ocpi_ck");
89         if (IS_ERR(ocpi_ck))
90                 return PTR_ERR(ocpi_ck);
91
92         clk_use(ocpi_ck);
93         ocpi_enable();
94         printk("OMAP OCPI interconnect driver loaded\n");
95
96         return 0;
97 }
98
99 static void __exit omap_ocpi_exit(void)
100 {
101         /* REVISIT: Disable OCPI */
102
103         if (!cpu_is_omap16xx())
104                 return;
105
106         clk_unuse(ocpi_ck);
107         clk_put(ocpi_ck);
108 }
109
110 MODULE_AUTHOR("Tony Lindgren <tony@atomide.com>");
111 MODULE_DESCRIPTION("OMAP OCPI bus controller module");
112 MODULE_LICENSE("GPL");
113 module_init(omap_ocpi_init);
114 module_exit(omap_ocpi_exit);