blob: 37792d43738b1981d78541f05a56a390ec5f726b [file] [log] [blame]
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +01001/*
2 * linux/arch/arm/plat-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>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010028#include <linux/types.h>
29#include <linux/errno.h>
30#include <linux/kernel.h>
31#include <linux/init.h>
32#include <linux/spinlock.h>
33#include <linux/err.h>
Russell Kingf8ce2542006-01-07 16:15:52 +000034#include <linux/clk.h>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010035
36#include <asm/io.h>
Russell King0a5709b2005-11-16 14:51:20 +000037#include <asm/hardware.h>
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010038
39#define OCPI_BASE 0xfffec320
40#define OCPI_FAULT (OCPI_BASE + 0x00)
41#define OCPI_CMD_FAULT (OCPI_BASE + 0x04)
42#define OCPI_SINT0 (OCPI_BASE + 0x08)
43#define OCPI_TABORT (OCPI_BASE + 0x0c)
44#define OCPI_SINT1 (OCPI_BASE + 0x10)
45#define OCPI_PROT (OCPI_BASE + 0x14)
46#define OCPI_SEC (OCPI_BASE + 0x18)
47
48/* USB OHCI OCPI access error registers */
49#define HOSTUEADDR 0xfffba0e0
50#define HOSTUESTATUS 0xfffba0e4
51
52static struct clk *ocpi_ck;
53
54/*
55 * Enables device access to OMAP buses via the OCPI bridge
56 * FIXME: Add locking
57 */
58int ocpi_enable(void)
59{
60 unsigned int val;
61
62 if (!cpu_is_omap16xx())
63 return -ENODEV;
64
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010065 /* Enable access for OHCI in OCPI */
66 val = omap_readl(OCPI_PROT);
67 val &= ~0xff;
68 //val &= (1 << 0); /* Allow access only to EMIFS */
69 omap_writel(val, OCPI_PROT);
70
71 val = omap_readl(OCPI_SEC);
72 val &= ~0xff;
73 omap_writel(val, OCPI_SEC);
74
75 return 0;
76}
77EXPORT_SYMBOL(ocpi_enable);
78
79static int __init omap_ocpi_init(void)
80{
81 if (!cpu_is_omap16xx())
82 return -ENODEV;
83
84 ocpi_ck = clk_get(NULL, "l3_ocpi_ck");
85 if (IS_ERR(ocpi_ck))
86 return PTR_ERR(ocpi_ck);
87
Tony Lindgren30ff7202006-01-17 15:33:51 -080088 clk_enable(ocpi_ck);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +010089 ocpi_enable();
90 printk("OMAP OCPI interconnect driver loaded\n");
91
92 return 0;
93}
94
95static void __exit omap_ocpi_exit(void)
96{
97 /* REVISIT: Disable OCPI */
98
99 if (!cpu_is_omap16xx())
100 return;
101
Tony Lindgren30ff7202006-01-17 15:33:51 -0800102 clk_disable(ocpi_ck);
Tony Lindgren5e1c5ff2005-07-10 19:58:15 +0100103 clk_put(ocpi_ck);
104}
105
106MODULE_AUTHOR("Tony Lindgren <tony@atomide.com>");
107MODULE_DESCRIPTION("OMAP OCPI bus controller module");
108MODULE_LICENSE("GPL");
109module_init(omap_ocpi_init);
110module_exit(omap_ocpi_exit);