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