ocpi.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * linux/arch/arm/plat-omap/ocpi.c
  4. *
  5. * Minimal OCP bus support for omap16xx
  6. *
  7. * Copyright (C) 2003 - 2005 Nokia Corporation
  8. * Copyright (C) 2012 Texas Instruments, Inc.
  9. * Written by Tony Lindgren <[email protected]>
  10. *
  11. * Modified for clock framework by Paul Mundt <[email protected]>.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/types.h>
  15. #include <linux/errno.h>
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/spinlock.h>
  19. #include <linux/err.h>
  20. #include <linux/clk.h>
  21. #include <linux/io.h>
  22. #include <linux/soc/ti/omap1-io.h>
  23. #include "hardware.h"
  24. #include "common.h"
  25. #define OCPI_BASE 0xfffec320
  26. #define OCPI_FAULT (OCPI_BASE + 0x00)
  27. #define OCPI_CMD_FAULT (OCPI_BASE + 0x04)
  28. #define OCPI_SINT0 (OCPI_BASE + 0x08)
  29. #define OCPI_TABORT (OCPI_BASE + 0x0c)
  30. #define OCPI_SINT1 (OCPI_BASE + 0x10)
  31. #define OCPI_PROT (OCPI_BASE + 0x14)
  32. #define OCPI_SEC (OCPI_BASE + 0x18)
  33. /* USB OHCI OCPI access error registers */
  34. #define HOSTUEADDR 0xfffba0e0
  35. #define HOSTUESTATUS 0xfffba0e4
  36. static struct clk *ocpi_ck;
  37. /*
  38. * Enables device access to OMAP buses via the OCPI bridge
  39. */
  40. int ocpi_enable(void)
  41. {
  42. unsigned int val;
  43. if (!cpu_is_omap16xx())
  44. return -ENODEV;
  45. /* Enable access for OHCI in OCPI */
  46. val = omap_readl(OCPI_PROT);
  47. val &= ~0xff;
  48. /* val &= (1 << 0); Allow access only to EMIFS */
  49. omap_writel(val, OCPI_PROT);
  50. val = omap_readl(OCPI_SEC);
  51. val &= ~0xff;
  52. omap_writel(val, OCPI_SEC);
  53. return 0;
  54. }
  55. EXPORT_SYMBOL(ocpi_enable);
  56. static int __init omap_ocpi_init(void)
  57. {
  58. if (!cpu_is_omap16xx())
  59. return -ENODEV;
  60. ocpi_ck = clk_get(NULL, "l3_ocpi_ck");
  61. if (IS_ERR(ocpi_ck))
  62. return PTR_ERR(ocpi_ck);
  63. clk_prepare_enable(ocpi_ck);
  64. ocpi_enable();
  65. pr_info("OMAP OCPI interconnect driver loaded\n");
  66. return 0;
  67. }
  68. static void __exit omap_ocpi_exit(void)
  69. {
  70. /* REVISIT: Disable OCPI */
  71. if (!cpu_is_omap16xx())
  72. return;
  73. clk_disable_unprepare(ocpi_ck);
  74. clk_put(ocpi_ck);
  75. }
  76. MODULE_AUTHOR("Tony Lindgren <[email protected]>");
  77. MODULE_DESCRIPTION("OMAP OCPI bus controller module");
  78. MODULE_LICENSE("GPL");
  79. module_init(omap_ocpi_init);
  80. module_exit(omap_ocpi_exit);