initial commit with v2.6.9
[linux-2.6.9-moxart.git] / arch / arm / mach-omap / ocpi.c
blob93c7f4aca3bfab0e5f106bef444776f72fd7b143
1 /*
2 * linux/arch/arm/mach-omap/ocpi.c
4 * Minimal OCP bus support for OMAP-1610 and OMAP-5912
6 * Copyright (C) 2003 - 2004 Nokia Corporation
7 * Written by Tony Lindgren <tony@atomide.com>
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.
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.
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
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>
33 #include <asm/io.h>
34 #include <asm/arch/hardware.h>
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)
45 #define EN_OCPI_CK (1 << 0)
46 #define IDLOCPI_ARM (1 << 1)
48 /* USB OHCI OCPI access error registers */
49 #define HOSTUEADDR 0xfffba0e0
50 #define HOSTUESTATUS 0xfffba0e4
53 * Enables device access to OMAP buses via the OCPI bridge
54 * FIXME: Add locking
56 int ocpi_enable(void)
58 unsigned int val;
60 /* Make sure there's clock for OCPI */
62 #if defined(CONFIG_ARCH_OMAP1610) || defined(CONFIG_ARCH_OMAP1710)
63 if (cpu_is_omap1610() || cpu_is_omap1710()) {
64 val = omap_readl(OMAP1610_ARM_IDLECT3);
65 val |= EN_OCPI_CK;
66 val &= ~IDLOCPI_ARM;
67 omap_writel(val, OMAP1610_ARM_IDLECT3);
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);
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);
84 val = omap_readl(OCPI_SEC);
85 val &= ~0xff;
86 omap_writel(val, OCPI_SEC);
88 return 0;
90 EXPORT_SYMBOL(ocpi_enable);
92 int ocpi_status(void)
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));
99 return 1;
101 EXPORT_SYMBOL(ocpi_status);
103 static int __init omap_ocpi_init(void)
105 ocpi_enable();
106 printk("OMAP OCPI interconnect driver loaded\n");
108 return 0;
111 static void __exit omap_ocpi_exit(void)
113 /* FIXME: Disable OCPI */
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);