# BRCM_VERSION=3
[bcm963xx.git] / kernel / linux / 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 #ifdef CONFIG_ARCH_OMAP1610
63         if (cpu_is_omap1610()) {
64                 val = omap_readl(OMAP1610_ARM_IDLECT3);
65                 val |= EN_OCPI_CK;
66                 val &= ~IDLOCPI_ARM;
67                 omap_writel(val, OMAP1610_ARM_IDLECT3);
68         }
69 #endif
70 #ifdef CONFIG_ARCH_OMAP5912
71         if (cpu_is_omap5912()) {
72                 val = omap_readl(OMAP5912_ARM_IDLECT3);
73                 val |= EN_OCPI_CK;
74                 val &= ~IDLOCPI_ARM;
75                 omap_writel(val, OMAP5912_ARM_IDLECT3);
76         }
77 #endif
78         /* Enable access for OHCI in OCPI */
79         val = omap_readl(OCPI_PROT);
80         val &= ~0xff;
81         //val &= (1 << 0);      /* Allow access only to EMIFS */
82         omap_writel(val, OCPI_PROT);
83
84         val = omap_readl(OCPI_SEC);
85         val &= ~0xff;
86         omap_writel(val, OCPI_SEC);
87
88         return 0;
89 }
90 EXPORT_SYMBOL(ocpi_enable);
91
92 int ocpi_status(void)
93 {
94         printk("OCPI: addr: 0x%08x cmd: 0x%08x\n"
95                "      ohci-addr: 0x%08x ohci-status: 0x%08x\n",
96                omap_readl(OCPI_FAULT), omap_readl(OCPI_CMD_FAULT),
97                omap_readl(HOSTUEADDR), omap_readl(HOSTUESTATUS));
98
99         return 1;
100 }
101 EXPORT_SYMBOL(ocpi_status);
102
103 static int __init omap_ocpi_init(void)
104 {
105         ocpi_enable();
106         printk("OMAP OCPI interconnect driver loaded\n");
107
108         return 0;
109 }
110
111 static void __exit omap_ocpi_exit(void)
112 {
113         /* FIXME: Disable OCPI */
114 }
115
116 MODULE_AUTHOR("Tony Lindgren <tony@atomide.com>");
117 MODULE_DESCRIPTION("OMAP OCPI bus controller module");
118 MODULE_LICENSE("GPL");
119 module_init(omap_ocpi_init);
120 module_exit(omap_ocpi_exit);