ocpi.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  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. * Copyright (C) 2012 Texas Instruments, Inc.
  8. * Written by Tony Lindgren <tony@atomide.com>
  9. *
  10. * Modified for clock framework by Paul Mundt <paul.mundt@nokia.com>.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. */
  26. #include <linux/module.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. #include <linux/err.h>
  33. #include <linux/clk.h>
  34. #include <linux/io.h>
  35. #include <mach/hardware.h>
  36. #include "common.h"
  37. #define OCPI_BASE 0xfffec320
  38. #define OCPI_FAULT (OCPI_BASE + 0x00)
  39. #define OCPI_CMD_FAULT (OCPI_BASE + 0x04)
  40. #define OCPI_SINT0 (OCPI_BASE + 0x08)
  41. #define OCPI_TABORT (OCPI_BASE + 0x0c)
  42. #define OCPI_SINT1 (OCPI_BASE + 0x10)
  43. #define OCPI_PROT (OCPI_BASE + 0x14)
  44. #define OCPI_SEC (OCPI_BASE + 0x18)
  45. /* USB OHCI OCPI access error registers */
  46. #define HOSTUEADDR 0xfffba0e0
  47. #define HOSTUESTATUS 0xfffba0e4
  48. static struct clk *ocpi_ck;
  49. /*
  50. * Enables device access to OMAP buses via the OCPI bridge
  51. */
  52. int ocpi_enable(void)
  53. {
  54. unsigned int val;
  55. if (!cpu_is_omap16xx())
  56. return -ENODEV;
  57. /* Enable access for OHCI in OCPI */
  58. val = omap_readl(OCPI_PROT);
  59. val &= ~0xff;
  60. /* val &= (1 << 0); Allow access only to EMIFS */
  61. omap_writel(val, OCPI_PROT);
  62. val = omap_readl(OCPI_SEC);
  63. val &= ~0xff;
  64. omap_writel(val, OCPI_SEC);
  65. return 0;
  66. }
  67. EXPORT_SYMBOL(ocpi_enable);
  68. static int __init omap_ocpi_init(void)
  69. {
  70. if (!cpu_is_omap16xx())
  71. return -ENODEV;
  72. ocpi_ck = clk_get(NULL, "l3_ocpi_ck");
  73. if (IS_ERR(ocpi_ck))
  74. return PTR_ERR(ocpi_ck);
  75. clk_enable(ocpi_ck);
  76. ocpi_enable();
  77. pr_info("OMAP OCPI interconnect driver loaded\n");
  78. return 0;
  79. }
  80. static void __exit omap_ocpi_exit(void)
  81. {
  82. /* REVISIT: Disable OCPI */
  83. if (!cpu_is_omap16xx())
  84. return;
  85. clk_disable(ocpi_ck);
  86. clk_put(ocpi_ck);
  87. }
  88. MODULE_AUTHOR("Tony Lindgren <tony@atomide.com>");
  89. MODULE_DESCRIPTION("OMAP OCPI bus controller module");
  90. MODULE_LICENSE("GPL");
  91. module_init(omap_ocpi_init);
  92. module_exit(omap_ocpi_exit);