Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * linux/arch/arm/plat-omap/ocpi.c
0004  *
0005  * Minimal OCP bus support for omap16xx
0006  *
0007  * Copyright (C) 2003 - 2005 Nokia Corporation
0008  * Copyright (C) 2012 Texas Instruments, Inc.
0009  * Written by Tony Lindgren <tony@atomide.com>
0010  *
0011  * Modified for clock framework by Paul Mundt <paul.mundt@nokia.com>.
0012  */
0013 
0014 #include <linux/module.h>
0015 #include <linux/types.h>
0016 #include <linux/errno.h>
0017 #include <linux/kernel.h>
0018 #include <linux/init.h>
0019 #include <linux/spinlock.h>
0020 #include <linux/err.h>
0021 #include <linux/clk.h>
0022 #include <linux/io.h>
0023 #include <linux/soc/ti/omap1-io.h>
0024 
0025 #include "hardware.h"
0026 #include "common.h"
0027 
0028 #define OCPI_BASE       0xfffec320
0029 #define OCPI_FAULT      (OCPI_BASE + 0x00)
0030 #define OCPI_CMD_FAULT      (OCPI_BASE + 0x04)
0031 #define OCPI_SINT0      (OCPI_BASE + 0x08)
0032 #define OCPI_TABORT     (OCPI_BASE + 0x0c)
0033 #define OCPI_SINT1      (OCPI_BASE + 0x10)
0034 #define OCPI_PROT       (OCPI_BASE + 0x14)
0035 #define OCPI_SEC        (OCPI_BASE + 0x18)
0036 
0037 /* USB OHCI OCPI access error registers */
0038 #define HOSTUEADDR  0xfffba0e0
0039 #define HOSTUESTATUS    0xfffba0e4
0040 
0041 static struct clk *ocpi_ck;
0042 
0043 /*
0044  * Enables device access to OMAP buses via the OCPI bridge
0045  */
0046 int ocpi_enable(void)
0047 {
0048     unsigned int val;
0049 
0050     if (!cpu_is_omap16xx())
0051         return -ENODEV;
0052 
0053     /* Enable access for OHCI in OCPI */
0054     val = omap_readl(OCPI_PROT);
0055     val &= ~0xff;
0056     /* val &= (1 << 0);  Allow access only to EMIFS */
0057     omap_writel(val, OCPI_PROT);
0058 
0059     val = omap_readl(OCPI_SEC);
0060     val &= ~0xff;
0061     omap_writel(val, OCPI_SEC);
0062 
0063     return 0;
0064 }
0065 EXPORT_SYMBOL(ocpi_enable);
0066 
0067 static int __init omap_ocpi_init(void)
0068 {
0069     if (!cpu_is_omap16xx())
0070         return -ENODEV;
0071 
0072     ocpi_ck = clk_get(NULL, "l3_ocpi_ck");
0073     if (IS_ERR(ocpi_ck))
0074         return PTR_ERR(ocpi_ck);
0075 
0076     clk_prepare_enable(ocpi_ck);
0077     ocpi_enable();
0078     pr_info("OMAP OCPI interconnect driver loaded\n");
0079 
0080     return 0;
0081 }
0082 
0083 static void __exit omap_ocpi_exit(void)
0084 {
0085     /* REVISIT: Disable OCPI */
0086 
0087     if (!cpu_is_omap16xx())
0088         return;
0089 
0090     clk_disable_unprepare(ocpi_ck);
0091     clk_put(ocpi_ck);
0092 }
0093 
0094 MODULE_AUTHOR("Tony Lindgren <tony@atomide.com>");
0095 MODULE_DESCRIPTION("OMAP OCPI bus controller module");
0096 MODULE_LICENSE("GPL");
0097 module_init(omap_ocpi_init);
0098 module_exit(omap_ocpi_exit);