dal_axi.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <mach/dal_axi.h>
  13. /* The AXI device ID */
  14. #define DALDEVICEID_AXI 0x02000053
  15. #define DALRPC_PORT_NAME "DAL00"
  16. enum {
  17. DALRPC_AXI_ALLOCATE = DALDEVICE_FIRST_DEVICE_API_IDX + 1,
  18. DALRPC_AXI_FREE = DALDEVICE_FIRST_DEVICE_API_IDX + 2,
  19. DALRPC_AXI_CONFIGURE_BRIDGE = DALDEVICE_FIRST_DEVICE_API_IDX + 11
  20. };
  21. enum {
  22. DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_SYNC_MODE = 14,
  23. DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_ASYNC_MODE,
  24. DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_ISOSYNC_MODE,
  25. DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_DEBUG_EN,
  26. DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_DEBUG_DIS,
  27. DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_SYNC_MODE,
  28. DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_ASYNC_MODE,
  29. DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_ISOSYNC_MODE,
  30. DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_DEBUG_EN,
  31. DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_DEBUG_DIS,
  32. /* 7x27(A) Graphics Subsystem Bridge Configuration */
  33. DAL_AXI_BRIDGE_CFG_GRPSS_XBAR_SYNC_MODE = 58,
  34. DAL_AXI_BRIDGE_CFG_GRPSS_XBAR_ASYNC_MODE = 59,
  35. DAL_AXI_BRIDGE_CFG_GRPSS_XBAR_ISOSYNC_MODE = 60
  36. };
  37. static void *cam_dev_handle;
  38. static int __axi_free(int mode)
  39. {
  40. int rc = 0;
  41. if (!cam_dev_handle)
  42. return rc;
  43. rc = dalrpc_fcn_0(DALRPC_AXI_FREE, cam_dev_handle, mode);
  44. if (rc) {
  45. printk(KERN_ERR "%s: AXI bus device (%d) failed to be configured\n",
  46. __func__, rc);
  47. goto fail_dal_fcn_0;
  48. }
  49. /* close device handle */
  50. rc = daldevice_detach(cam_dev_handle);
  51. if (rc) {
  52. printk(KERN_ERR "%s: failed to detach AXI bus device (%d)\n",
  53. __func__, rc);
  54. goto fail_dal_attach_detach;
  55. }
  56. cam_dev_handle = NULL;
  57. return 0;
  58. fail_dal_fcn_0:
  59. (void)daldevice_detach(cam_dev_handle);
  60. cam_dev_handle = NULL;
  61. fail_dal_attach_detach:
  62. return rc;
  63. }
  64. static int __axi_allocate(int mode)
  65. {
  66. int rc;
  67. /* get device handle */
  68. rc = daldevice_attach(DALDEVICEID_AXI, DALRPC_PORT_NAME,
  69. DALRPC_DEST_MODEM, &cam_dev_handle);
  70. if (rc) {
  71. printk(KERN_ERR "%s: failed to attach AXI bus device (%d)\n",
  72. __func__, rc);
  73. goto fail_dal_attach_detach;
  74. }
  75. rc = dalrpc_fcn_0(DALRPC_AXI_ALLOCATE, cam_dev_handle, mode);
  76. if (rc) {
  77. printk(KERN_ERR "%s: AXI bus device (%d) failed to be configured\n",
  78. __func__, rc);
  79. goto fail_dal_fcn_0;
  80. }
  81. return 0;
  82. fail_dal_fcn_0:
  83. (void)daldevice_detach(cam_dev_handle);
  84. cam_dev_handle = NULL;
  85. fail_dal_attach_detach:
  86. return rc;
  87. }
  88. static int axi_configure_bridge_grfx_sync_mode(int bridge_mode)
  89. {
  90. int rc;
  91. void *dev_handle;
  92. /* get device handle */
  93. rc = daldevice_attach(
  94. DALDEVICEID_AXI, DALRPC_PORT_NAME,
  95. DALRPC_DEST_MODEM, &dev_handle
  96. );
  97. if (rc) {
  98. printk(KERN_ERR "%s: failed to attach AXI bus device (%d)\n",
  99. __func__, rc);
  100. goto fail_dal_attach_detach;
  101. }
  102. /* call ConfigureBridge */
  103. rc = dalrpc_fcn_0(
  104. DALRPC_AXI_CONFIGURE_BRIDGE, dev_handle,
  105. bridge_mode
  106. );
  107. if (rc) {
  108. printk(KERN_ERR "%s: AXI bus device (%d) failed to be configured\n",
  109. __func__, rc);
  110. goto fail_dal_fcn_0;
  111. }
  112. /* close device handle */
  113. rc = daldevice_detach(dev_handle);
  114. if (rc) {
  115. printk(KERN_ERR "%s: failed to detach AXI bus device (%d)\n",
  116. __func__, rc);
  117. goto fail_dal_attach_detach;
  118. }
  119. return 0;
  120. fail_dal_fcn_0:
  121. (void)daldevice_detach(dev_handle);
  122. fail_dal_attach_detach:
  123. return rc;
  124. }
  125. int axi_free(mode)
  126. {
  127. return __axi_free(mode);
  128. }
  129. int axi_allocate(mode)
  130. {
  131. return __axi_allocate(mode);
  132. }
  133. int set_grp2d_async(void)
  134. {
  135. return axi_configure_bridge_grfx_sync_mode(
  136. DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_ASYNC_MODE);
  137. }
  138. int set_grp3d_async(void)
  139. {
  140. return axi_configure_bridge_grfx_sync_mode(
  141. DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_ASYNC_MODE);
  142. }
  143. int set_grp_xbar_async(void)
  144. { return axi_configure_bridge_grfx_sync_mode(
  145. DAL_AXI_BRIDGE_CFG_GRPSS_XBAR_ASYNC_MODE);
  146. }