ocpi.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. * 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. #include <linux/module.h>
  26. #include <linux/types.h>
  27. #include <linux/errno.h>
  28. #include <linux/kernel.h>
  29. #include <linux/init.h>
  30. #include <linux/spinlock.h>
  31. #include <linux/err.h>
  32. #include <linux/clk.h>
  33. #include <linux/io.h>
  34. #include <mach/hardware.h>
  35. #define OCPI_BASE 0xfffec320
  36. #define OCPI_FAULT (OCPI_BASE + 0x00)
  37. #define OCPI_CMD_FAULT (OCPI_BASE + 0x04)
  38. #define OCPI_SINT0 (OCPI_BASE + 0x08)
  39. #define OCPI_TABORT (OCPI_BASE + 0x0c)
  40. #define OCPI_SINT1 (OCPI_BASE + 0x10)
  41. #define OCPI_PROT (OCPI_BASE + 0x14)
  42. #define OCPI_SEC (OCPI_BASE + 0x18)
  43. /* USB OHCI OCPI access error registers */
  44. #define HOSTUEADDR 0xfffba0e0
  45. #define HOSTUESTATUS 0xfffba0e4
  46. static struct clk *ocpi_ck;
  47. /*
  48. * Enables device access to OMAP buses via the OCPI bridge
  49. * FIXME: Add locking
  50. */
  51. int ocpi_enable(void)
  52. {
  53. unsigned int val;
  54. if (!cpu_is_omap16xx())
  55. return -ENODEV;
  56. /* Enable access for OHCI in OCPI */
  57. val = omap_readl(OCPI_PROT);
  58. val &= ~0xff;
  59. //val &= (1 << 0); /* Allow access only to EMIFS */
  60. omap_writel(val, OCPI_PROT);
  61. val = omap_readl(OCPI_SEC);
  62. val &= ~0xff;
  63. omap_writel(val, OCPI_SEC);
  64. return 0;
  65. }
  66. EXPORT_SYMBOL(ocpi_enable);
  67. static int __init omap_ocpi_init(void)
  68. {
  69. if (!cpu_is_omap16xx())
  70. return -ENODEV;
  71. ocpi_ck = clk_get(NULL, "l3_ocpi_ck");
  72. if (IS_ERR(ocpi_ck))
  73. return PTR_ERR(ocpi_ck);
  74. clk_enable(ocpi_ck);
  75. ocpi_enable();
  76. printk("OMAP OCPI interconnect driver loaded\n");
  77. return 0;
  78. }
  79. static void __exit omap_ocpi_exit(void)
  80. {
  81. /* REVISIT: Disable OCPI */
  82. if (!cpu_is_omap16xx())
  83. return;
  84. clk_disable(ocpi_ck);
  85. clk_put(ocpi_ck);
  86. }
  87. MODULE_AUTHOR("Tony Lindgren <tony@atomide.com>");
  88. MODULE_DESCRIPTION("OMAP OCPI bus controller module");
  89. MODULE_LICENSE("GPL");
  90. module_init(omap_ocpi_init);
  91. module_exit(omap_ocpi_exit);