Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | |
| 13 | #include <mach/dal_axi.h> |
| 14 | |
| 15 | /* The AXI device ID */ |
| 16 | #define DALDEVICEID_AXI 0x02000053 |
| 17 | #define DALRPC_PORT_NAME "DAL00" |
| 18 | |
| 19 | enum { |
Suresh Vankadara | 8047d09 | 2012-08-13 19:14:23 +0530 | [diff] [blame] | 20 | DALRPC_AXI_ALLOCATE = DALDEVICE_FIRST_DEVICE_API_IDX + 1, |
| 21 | DALRPC_AXI_FREE = DALDEVICE_FIRST_DEVICE_API_IDX + 2, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 22 | DALRPC_AXI_CONFIGURE_BRIDGE = DALDEVICE_FIRST_DEVICE_API_IDX + 11 |
| 23 | }; |
| 24 | |
| 25 | enum { |
| 26 | DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_SYNC_MODE = 14, |
| 27 | DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_ASYNC_MODE, |
| 28 | DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_ISOSYNC_MODE, |
| 29 | DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_DEBUG_EN, |
| 30 | DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_DEBUG_DIS, |
| 31 | DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_SYNC_MODE, |
| 32 | DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_ASYNC_MODE, |
| 33 | DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_ISOSYNC_MODE, |
| 34 | DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_DEBUG_EN, |
| 35 | DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_DEBUG_DIS, |
| 36 | /* 7x27(A) Graphics Subsystem Bridge Configuration */ |
| 37 | DAL_AXI_BRIDGE_CFG_GRPSS_XBAR_SYNC_MODE = 58, |
| 38 | DAL_AXI_BRIDGE_CFG_GRPSS_XBAR_ASYNC_MODE = 59, |
| 39 | DAL_AXI_BRIDGE_CFG_GRPSS_XBAR_ISOSYNC_MODE = 60 |
| 40 | |
| 41 | }; |
| 42 | |
Suresh Vankadara | 8047d09 | 2012-08-13 19:14:23 +0530 | [diff] [blame] | 43 | static void *cam_dev_handle; |
| 44 | static int __axi_free(int mode) |
| 45 | { |
| 46 | int rc = 0; |
| 47 | |
| 48 | if (!cam_dev_handle) |
| 49 | return rc; |
| 50 | |
| 51 | rc = dalrpc_fcn_0(DALRPC_AXI_FREE, cam_dev_handle, mode); |
| 52 | if (rc) { |
| 53 | printk(KERN_ERR "%s: AXI bus device (%d) failed to be configured\n", |
| 54 | __func__, rc); |
| 55 | goto fail_dal_fcn_0; |
| 56 | } |
| 57 | |
| 58 | /* close device handle */ |
| 59 | rc = daldevice_detach(cam_dev_handle); |
| 60 | if (rc) { |
| 61 | printk(KERN_ERR "%s: failed to detach AXI bus device (%d)\n", |
| 62 | __func__, rc); |
| 63 | goto fail_dal_attach_detach; |
| 64 | } |
| 65 | cam_dev_handle = NULL; |
| 66 | return 0; |
| 67 | |
| 68 | fail_dal_fcn_0: |
| 69 | (void)daldevice_detach(cam_dev_handle); |
| 70 | cam_dev_handle = NULL; |
| 71 | fail_dal_attach_detach: |
| 72 | return rc; |
| 73 | } |
| 74 | |
| 75 | static int __axi_allocate(int mode) |
| 76 | { |
| 77 | int rc; |
| 78 | |
| 79 | /* get device handle */ |
| 80 | rc = daldevice_attach(DALDEVICEID_AXI, DALRPC_PORT_NAME, |
| 81 | DALRPC_DEST_MODEM, &cam_dev_handle); |
| 82 | if (rc) { |
| 83 | printk(KERN_ERR "%s: failed to attach AXI bus device (%d)\n", |
| 84 | __func__, rc); |
| 85 | goto fail_dal_attach_detach; |
| 86 | } |
| 87 | |
| 88 | rc = dalrpc_fcn_0(DALRPC_AXI_ALLOCATE, cam_dev_handle, mode); |
| 89 | if (rc) { |
| 90 | printk(KERN_ERR "%s: AXI bus device (%d) failed to be configured\n", |
| 91 | __func__, rc); |
| 92 | goto fail_dal_fcn_0; |
| 93 | } |
| 94 | |
| 95 | return 0; |
| 96 | |
| 97 | fail_dal_fcn_0: |
| 98 | (void)daldevice_detach(cam_dev_handle); |
| 99 | cam_dev_handle = NULL; |
| 100 | fail_dal_attach_detach: |
| 101 | return rc; |
| 102 | } |
| 103 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 104 | static int axi_configure_bridge_grfx_sync_mode(int bridge_mode) |
| 105 | { |
| 106 | int rc; |
| 107 | void *dev_handle; |
| 108 | |
| 109 | /* get device handle */ |
| 110 | rc = daldevice_attach( |
| 111 | DALDEVICEID_AXI, DALRPC_PORT_NAME, |
| 112 | DALRPC_DEST_MODEM, &dev_handle |
| 113 | ); |
| 114 | if (rc) { |
| 115 | printk(KERN_ERR "%s: failed to attach AXI bus device (%d)\n", |
| 116 | __func__, rc); |
| 117 | goto fail_dal_attach_detach; |
| 118 | } |
| 119 | |
| 120 | /* call ConfigureBridge */ |
| 121 | rc = dalrpc_fcn_0( |
| 122 | DALRPC_AXI_CONFIGURE_BRIDGE, dev_handle, |
| 123 | bridge_mode |
| 124 | ); |
| 125 | if (rc) { |
| 126 | printk(KERN_ERR "%s: AXI bus device (%d) failed to be configured\n", |
| 127 | __func__, rc); |
| 128 | goto fail_dal_fcn_0; |
| 129 | } |
| 130 | |
| 131 | /* close device handle */ |
| 132 | rc = daldevice_detach(dev_handle); |
| 133 | if (rc) { |
| 134 | printk(KERN_ERR "%s: failed to detach AXI bus device (%d)\n", |
| 135 | __func__, rc); |
| 136 | goto fail_dal_attach_detach; |
| 137 | } |
| 138 | |
| 139 | return 0; |
| 140 | |
| 141 | fail_dal_fcn_0: |
| 142 | (void)daldevice_detach(dev_handle); |
| 143 | fail_dal_attach_detach: |
| 144 | |
| 145 | return rc; |
| 146 | } |
| 147 | |
Suresh Vankadara | 8047d09 | 2012-08-13 19:14:23 +0530 | [diff] [blame] | 148 | int axi_free(mode) |
| 149 | { |
| 150 | return __axi_free(mode); |
| 151 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 152 | |
Suresh Vankadara | 8047d09 | 2012-08-13 19:14:23 +0530 | [diff] [blame] | 153 | int axi_allocate(mode) |
| 154 | { |
| 155 | return __axi_allocate(mode); |
| 156 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 157 | |
| 158 | int set_grp2d_async(void) |
| 159 | { |
| 160 | return axi_configure_bridge_grfx_sync_mode( |
| 161 | DAL_AXI_BRIDGE_CFG_CGR_SS_2DGRP_ASYNC_MODE); |
| 162 | } |
| 163 | |
| 164 | int set_grp3d_async(void) |
| 165 | { |
| 166 | return axi_configure_bridge_grfx_sync_mode( |
| 167 | DAL_AXI_BRIDGE_CFG_CGR_SS_3DGRP_ASYNC_MODE); |
| 168 | } |
| 169 | |
| 170 | int set_grp_xbar_async(void) |
| 171 | { return axi_configure_bridge_grfx_sync_mode( |
| 172 | DAL_AXI_BRIDGE_CFG_GRPSS_XBAR_ASYNC_MODE); |
| 173 | } |