tp3780i.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. *
  3. * tp3780i.c -- board driver for 3780i on ThinkPads
  4. *
  5. *
  6. * Written By: Mike Sullivan IBM Corporation
  7. *
  8. * Copyright (C) 1999 IBM Corporation
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * NO WARRANTY
  21. * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  22. * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  23. * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  24. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  25. * solely responsible for determining the appropriateness of using and
  26. * distributing the Program and assumes all risks associated with its
  27. * exercise of rights under this Agreement, including but not limited to
  28. * the risks and costs of program errors, damage to or loss of data,
  29. * programs or equipment, and unavailability or interruption of operations.
  30. *
  31. * DISCLAIMER OF LIABILITY
  32. * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  33. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  35. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  36. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  37. * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  38. * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  39. *
  40. * You should have received a copy of the GNU General Public License
  41. * along with this program; if not, write to the Free Software
  42. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  43. *
  44. *
  45. * 10/23/2000 - Alpha Release
  46. * First release to the public
  47. */
  48. #include <linux/interrupt.h>
  49. #include <linux/kernel.h>
  50. #include <linux/ptrace.h>
  51. #include <linux/ioport.h>
  52. #include <asm/io.h>
  53. #include "smapi.h"
  54. #include "mwavedd.h"
  55. #include "tp3780i.h"
  56. #include "3780i.h"
  57. #include "mwavepub.h"
  58. static unsigned short s_ausThinkpadIrqToField[16] =
  59. { 0xFFFF, 0xFFFF, 0xFFFF, 0x0001, 0x0002, 0x0003, 0xFFFF, 0x0004,
  60. 0xFFFF, 0xFFFF, 0x0005, 0x0006, 0xFFFF, 0xFFFF, 0xFFFF, 0x0007 };
  61. static unsigned short s_ausThinkpadDmaToField[8] =
  62. { 0x0001, 0x0002, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0003, 0x0004 };
  63. static unsigned short s_numIrqs = 16, s_numDmas = 8;
  64. static void EnableSRAM(THINKPAD_BD_DATA * pBDData)
  65. {
  66. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  67. unsigned short usDspBaseIO = pSettings->usDspBaseIO;
  68. DSP_GPIO_OUTPUT_DATA_15_8 rGpioOutputData;
  69. DSP_GPIO_DRIVER_ENABLE_15_8 rGpioDriverEnable;
  70. DSP_GPIO_MODE_15_8 rGpioMode;
  71. PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM, entry\n");
  72. MKWORD(rGpioMode) = ReadMsaCfg(DSP_GpioModeControl_15_8);
  73. rGpioMode.GpioMode10 = 0;
  74. WriteMsaCfg(DSP_GpioModeControl_15_8, MKWORD(rGpioMode));
  75. MKWORD(rGpioDriverEnable) = 0;
  76. rGpioDriverEnable.Enable10 = TRUE;
  77. rGpioDriverEnable.Mask10 = TRUE;
  78. WriteMsaCfg(DSP_GpioDriverEnable_15_8, MKWORD(rGpioDriverEnable));
  79. MKWORD(rGpioOutputData) = 0;
  80. rGpioOutputData.Latch10 = 0;
  81. rGpioOutputData.Mask10 = TRUE;
  82. WriteMsaCfg(DSP_GpioOutputData_15_8, MKWORD(rGpioOutputData));
  83. PRINTK_1(TRACE_TP3780I, "tp3780i::EnableSRAM exit\n");
  84. }
  85. static irqreturn_t UartInterrupt(int irq, void *dev_id)
  86. {
  87. PRINTK_3(TRACE_TP3780I,
  88. "tp3780i::UartInterrupt entry irq %x dev_id %p\n", irq, dev_id);
  89. return IRQ_HANDLED;
  90. }
  91. static irqreturn_t DspInterrupt(int irq, void *dev_id)
  92. {
  93. pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd;
  94. DSP_3780I_CONFIG_SETTINGS *pSettings = &pDrvData->rBDData.rDspSettings;
  95. unsigned short usDspBaseIO = pSettings->usDspBaseIO;
  96. unsigned short usIPCSource = 0, usIsolationMask, usPCNum;
  97. PRINTK_3(TRACE_TP3780I,
  98. "tp3780i::DspInterrupt entry irq %x dev_id %p\n", irq, dev_id);
  99. if (dsp3780I_GetIPCSource(usDspBaseIO, &usIPCSource) == 0) {
  100. PRINTK_2(TRACE_TP3780I,
  101. "tp3780i::DspInterrupt, return from dsp3780i_GetIPCSource, usIPCSource %x\n",
  102. usIPCSource);
  103. usIsolationMask = 1;
  104. for (usPCNum = 1; usPCNum <= 16; usPCNum++) {
  105. if (usIPCSource & usIsolationMask) {
  106. usIPCSource &= ~usIsolationMask;
  107. PRINTK_3(TRACE_TP3780I,
  108. "tp3780i::DspInterrupt usPCNum %x usIPCSource %x\n",
  109. usPCNum, usIPCSource);
  110. if (pDrvData->IPCs[usPCNum - 1].usIntCount == 0) {
  111. pDrvData->IPCs[usPCNum - 1].usIntCount = 1;
  112. }
  113. PRINTK_2(TRACE_TP3780I,
  114. "tp3780i::DspInterrupt usIntCount %x\n",
  115. pDrvData->IPCs[usPCNum - 1].usIntCount);
  116. if (pDrvData->IPCs[usPCNum - 1].bIsEnabled == TRUE) {
  117. PRINTK_2(TRACE_TP3780I,
  118. "tp3780i::DspInterrupt, waking up usPCNum %x\n",
  119. usPCNum - 1);
  120. wake_up_interruptible(&pDrvData->IPCs[usPCNum - 1].ipc_wait_queue);
  121. } else {
  122. PRINTK_2(TRACE_TP3780I,
  123. "tp3780i::DspInterrupt, no one waiting for IPC %x\n",
  124. usPCNum - 1);
  125. }
  126. }
  127. if (usIPCSource == 0)
  128. break;
  129. /* try next IPC */
  130. usIsolationMask = usIsolationMask << 1;
  131. }
  132. } else {
  133. PRINTK_1(TRACE_TP3780I,
  134. "tp3780i::DspInterrupt, return false from dsp3780i_GetIPCSource\n");
  135. }
  136. PRINTK_1(TRACE_TP3780I, "tp3780i::DspInterrupt exit\n");
  137. return IRQ_HANDLED;
  138. }
  139. int tp3780I_InitializeBoardData(THINKPAD_BD_DATA * pBDData)
  140. {
  141. int retval = 0;
  142. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  143. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData entry pBDData %p\n", pBDData);
  144. pBDData->bDSPEnabled = FALSE;
  145. pSettings->bInterruptClaimed = FALSE;
  146. retval = smapi_init();
  147. if (retval) {
  148. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_InitializeBoardData: Error: SMAPI is not available on this machine\n");
  149. } else {
  150. if (mwave_3780i_irq || mwave_3780i_io || mwave_uart_irq || mwave_uart_io) {
  151. retval = smapi_set_DSP_cfg();
  152. }
  153. }
  154. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_InitializeBoardData exit retval %x\n", retval);
  155. return retval;
  156. }
  157. int tp3780I_Cleanup(THINKPAD_BD_DATA * pBDData)
  158. {
  159. int retval = 0;
  160. PRINTK_2(TRACE_TP3780I,
  161. "tp3780i::tp3780I_Cleanup entry and exit pBDData %p\n", pBDData);
  162. return retval;
  163. }
  164. int tp3780I_CalcResources(THINKPAD_BD_DATA * pBDData)
  165. {
  166. SMAPI_DSP_SETTINGS rSmapiInfo;
  167. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  168. PRINTK_2(TRACE_TP3780I,
  169. "tp3780i::tp3780I_CalcResources entry pBDData %p\n", pBDData);
  170. if (smapi_query_DSP_cfg(&rSmapiInfo)) {
  171. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_CalcResources: Error: Could not query DSP config. Aborting.\n");
  172. return -EIO;
  173. }
  174. /* Sanity check */
  175. if (
  176. ( rSmapiInfo.usDspIRQ == 0 )
  177. || ( rSmapiInfo.usDspBaseIO == 0 )
  178. || ( rSmapiInfo.usUartIRQ == 0 )
  179. || ( rSmapiInfo.usUartBaseIO == 0 )
  180. ) {
  181. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_CalcResources: Error: Illegal resource setting. Aborting.\n");
  182. return -EIO;
  183. }
  184. pSettings->bDSPEnabled = (rSmapiInfo.bDSPEnabled && rSmapiInfo.bDSPPresent);
  185. pSettings->bModemEnabled = rSmapiInfo.bModemEnabled;
  186. pSettings->usDspIrq = rSmapiInfo.usDspIRQ;
  187. pSettings->usDspDma = rSmapiInfo.usDspDMA;
  188. pSettings->usDspBaseIO = rSmapiInfo.usDspBaseIO;
  189. pSettings->usUartIrq = rSmapiInfo.usUartIRQ;
  190. pSettings->usUartBaseIO = rSmapiInfo.usUartBaseIO;
  191. pSettings->uDStoreSize = TP_ABILITIES_DATA_SIZE;
  192. pSettings->uIStoreSize = TP_ABILITIES_INST_SIZE;
  193. pSettings->uIps = TP_ABILITIES_INTS_PER_SEC;
  194. if (pSettings->bDSPEnabled && pSettings->bModemEnabled && pSettings->usDspIrq == pSettings->usUartIrq) {
  195. pBDData->bShareDspIrq = pBDData->bShareUartIrq = 1;
  196. } else {
  197. pBDData->bShareDspIrq = pBDData->bShareUartIrq = 0;
  198. }
  199. PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_CalcResources exit\n");
  200. return 0;
  201. }
  202. int tp3780I_ClaimResources(THINKPAD_BD_DATA * pBDData)
  203. {
  204. int retval = 0;
  205. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  206. struct resource *pres;
  207. PRINTK_2(TRACE_TP3780I,
  208. "tp3780i::tp3780I_ClaimResources entry pBDData %p\n", pBDData);
  209. pres = request_region(pSettings->usDspBaseIO, 16, "mwave_3780i");
  210. if ( pres == NULL ) retval = -EIO;
  211. if (retval) {
  212. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_ClaimResources: Error: Could not claim I/O region starting at %x\n", pSettings->usDspBaseIO);
  213. retval = -EIO;
  214. }
  215. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ClaimResources exit retval %x\n", retval);
  216. return retval;
  217. }
  218. int tp3780I_ReleaseResources(THINKPAD_BD_DATA * pBDData)
  219. {
  220. int retval = 0;
  221. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  222. PRINTK_2(TRACE_TP3780I,
  223. "tp3780i::tp3780I_ReleaseResources entry pBDData %p\n", pBDData);
  224. release_region(pSettings->usDspBaseIO & (~3), 16);
  225. if (pSettings->bInterruptClaimed) {
  226. free_irq(pSettings->usDspIrq, NULL);
  227. pSettings->bInterruptClaimed = FALSE;
  228. }
  229. PRINTK_2(TRACE_TP3780I,
  230. "tp3780i::tp3780I_ReleaseResources exit retval %x\n", retval);
  231. return retval;
  232. }
  233. int tp3780I_EnableDSP(THINKPAD_BD_DATA * pBDData)
  234. {
  235. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  236. BOOLEAN bDSPPoweredUp = FALSE, bInterruptAllocated = FALSE;
  237. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP entry pBDData %p\n", pBDData);
  238. if (pBDData->bDSPEnabled) {
  239. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: DSP already enabled!\n");
  240. goto exit_cleanup;
  241. }
  242. if (!pSettings->bDSPEnabled) {
  243. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780::tp3780I_EnableDSP: Error: pSettings->bDSPEnabled not set\n");
  244. goto exit_cleanup;
  245. }
  246. if (
  247. (pSettings->usDspIrq >= s_numIrqs)
  248. || (pSettings->usDspDma >= s_numDmas)
  249. || (s_ausThinkpadIrqToField[pSettings->usDspIrq] == 0xFFFF)
  250. || (s_ausThinkpadDmaToField[pSettings->usDspDma] == 0xFFFF)
  251. ) {
  252. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: invalid irq %x\n", pSettings->usDspIrq);
  253. goto exit_cleanup;
  254. }
  255. if (
  256. ((pSettings->usDspBaseIO & 0xF00F) != 0)
  257. || (pSettings->usDspBaseIO & 0x0FF0) == 0
  258. ) {
  259. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid DSP base I/O address %x\n", pSettings->usDspBaseIO);
  260. goto exit_cleanup;
  261. }
  262. if (pSettings->bModemEnabled) {
  263. if (
  264. pSettings->usUartIrq >= s_numIrqs
  265. || s_ausThinkpadIrqToField[pSettings->usUartIrq] == 0xFFFF
  266. ) {
  267. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Invalid UART IRQ %x\n", pSettings->usUartIrq);
  268. goto exit_cleanup;
  269. }
  270. switch (pSettings->usUartBaseIO) {
  271. case 0x03F8:
  272. case 0x02F8:
  273. case 0x03E8:
  274. case 0x02E8:
  275. break;
  276. default:
  277. PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Invalid UART base I/O address %x\n", pSettings->usUartBaseIO);
  278. goto exit_cleanup;
  279. }
  280. }
  281. pSettings->bDspIrqActiveLow = pSettings->bDspIrqPulse = TRUE;
  282. pSettings->bUartIrqActiveLow = pSettings->bUartIrqPulse = TRUE;
  283. if (pBDData->bShareDspIrq) {
  284. pSettings->bDspIrqActiveLow = FALSE;
  285. }
  286. if (pBDData->bShareUartIrq) {
  287. pSettings->bUartIrqActiveLow = FALSE;
  288. }
  289. pSettings->usNumTransfers = TP_CFG_NumTransfers;
  290. pSettings->usReRequest = TP_CFG_RerequestTimer;
  291. pSettings->bEnableMEMCS16 = TP_CFG_MEMCS16;
  292. pSettings->usIsaMemCmdWidth = TP_CFG_IsaMemCmdWidth;
  293. pSettings->bGateIOCHRDY = TP_CFG_GateIOCHRDY;
  294. pSettings->bEnablePwrMgmt = TP_CFG_EnablePwrMgmt;
  295. pSettings->usHBusTimerLoadValue = TP_CFG_HBusTimerValue;
  296. pSettings->bDisableLBusTimeout = TP_CFG_DisableLBusTimeout;
  297. pSettings->usN_Divisor = TP_CFG_N_Divisor;
  298. pSettings->usM_Multiplier = TP_CFG_M_Multiplier;
  299. pSettings->bPllBypass = TP_CFG_PllBypass;
  300. pSettings->usChipletEnable = TP_CFG_ChipletEnable;
  301. if (request_irq(pSettings->usUartIrq, &UartInterrupt, 0, "mwave_uart", NULL)) {
  302. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: Could not get UART IRQ %x\n", pSettings->usUartIrq);
  303. goto exit_cleanup;
  304. } else { /* no conflict just release */
  305. free_irq(pSettings->usUartIrq, NULL);
  306. }
  307. if (request_irq(pSettings->usDspIrq, &DspInterrupt, 0, "mwave_3780i", NULL)) {
  308. PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: Could not get 3780i IRQ %x\n", pSettings->usDspIrq);
  309. goto exit_cleanup;
  310. } else {
  311. PRINTK_3(TRACE_TP3780I,
  312. "tp3780i::tp3780I_EnableDSP, got interrupt %x bShareDspIrq %x\n",
  313. pSettings->usDspIrq, pBDData->bShareDspIrq);
  314. bInterruptAllocated = TRUE;
  315. pSettings->bInterruptClaimed = TRUE;
  316. }
  317. smapi_set_DSP_power_state(FALSE);
  318. if (smapi_set_DSP_power_state(TRUE)) {
  319. PRINTK_ERROR(KERN_ERR_MWAVE "tp3780i::tp3780I_EnableDSP: Error: smapi_set_DSP_power_state(TRUE) failed\n");
  320. goto exit_cleanup;
  321. } else {
  322. bDSPPoweredUp = TRUE;
  323. }
  324. if (dsp3780I_EnableDSP(pSettings, s_ausThinkpadIrqToField, s_ausThinkpadDmaToField)) {
  325. PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Error: dsp7880I_EnableDSP() failed\n");
  326. goto exit_cleanup;
  327. }
  328. EnableSRAM(pBDData);
  329. pBDData->bDSPEnabled = TRUE;
  330. PRINTK_1(TRACE_TP3780I, "tp3780i::tp3780I_EnableDSP exit\n");
  331. return 0;
  332. exit_cleanup:
  333. PRINTK_ERROR("tp3780i::tp3780I_EnableDSP: Cleaning up\n");
  334. if (bDSPPoweredUp)
  335. smapi_set_DSP_power_state(FALSE);
  336. if (bInterruptAllocated) {
  337. free_irq(pSettings->usDspIrq, NULL);
  338. pSettings->bInterruptClaimed = FALSE;
  339. }
  340. return -EIO;
  341. }
  342. int tp3780I_DisableDSP(THINKPAD_BD_DATA * pBDData)
  343. {
  344. int retval = 0;
  345. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  346. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP entry pBDData %p\n", pBDData);
  347. if (pBDData->bDSPEnabled) {
  348. dsp3780I_DisableDSP(&pBDData->rDspSettings);
  349. if (pSettings->bInterruptClaimed) {
  350. free_irq(pSettings->usDspIrq, NULL);
  351. pSettings->bInterruptClaimed = FALSE;
  352. }
  353. smapi_set_DSP_power_state(FALSE);
  354. pBDData->bDSPEnabled = FALSE;
  355. }
  356. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_DisableDSP exit retval %x\n", retval);
  357. return retval;
  358. }
  359. int tp3780I_ResetDSP(THINKPAD_BD_DATA * pBDData)
  360. {
  361. int retval = 0;
  362. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  363. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP entry pBDData %p\n",
  364. pBDData);
  365. if (dsp3780I_Reset(pSettings) == 0) {
  366. EnableSRAM(pBDData);
  367. } else {
  368. retval = -EIO;
  369. }
  370. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ResetDSP exit retval %x\n", retval);
  371. return retval;
  372. }
  373. int tp3780I_StartDSP(THINKPAD_BD_DATA * pBDData)
  374. {
  375. int retval = 0;
  376. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  377. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP entry pBDData %p\n", pBDData);
  378. if (dsp3780I_Run(pSettings) == 0) {
  379. // @BUG @TBD EnableSRAM(pBDData);
  380. } else {
  381. retval = -EIO;
  382. }
  383. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_StartDSP exit retval %x\n", retval);
  384. return retval;
  385. }
  386. int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities)
  387. {
  388. int retval = 0;
  389. PRINTK_2(TRACE_TP3780I,
  390. "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
  391. /* fill out standard constant fields */
  392. pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
  393. pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
  394. pAbilities->inst_size = pBDData->rDspSettings.uIStoreSize;
  395. pAbilities->bus_dma_bw = pBDData->rDspSettings.uDmaBandwidth;
  396. /* fill out dynamically determined fields */
  397. pAbilities->component_list[0] = 0x00010000 | MW_ADC_MASK;
  398. pAbilities->component_list[1] = 0x00010000 | MW_ACI_MASK;
  399. pAbilities->component_list[2] = 0x00010000 | MW_AIC1_MASK;
  400. pAbilities->component_list[3] = 0x00010000 | MW_AIC2_MASK;
  401. pAbilities->component_list[4] = 0x00010000 | MW_CDDAC_MASK;
  402. pAbilities->component_list[5] = 0x00010000 | MW_MIDI_MASK;
  403. pAbilities->component_list[6] = 0x00010000 | MW_UART_MASK;
  404. pAbilities->component_count = 7;
  405. /* Fill out Mwave OS and BIOS task names */
  406. memcpy(pAbilities->mwave_os_name, TP_ABILITIES_MWAVEOS_NAME,
  407. sizeof(TP_ABILITIES_MWAVEOS_NAME));
  408. memcpy(pAbilities->bios_task_name, TP_ABILITIES_BIOSTASK_NAME,
  409. sizeof(TP_ABILITIES_BIOSTASK_NAME));
  410. PRINTK_1(TRACE_TP3780I,
  411. "tp3780i::tp3780I_QueryAbilities exit retval=SUCCESSFUL\n");
  412. return retval;
  413. }
  414. int tp3780I_ReadWriteDspDStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
  415. void __user *pvBuffer, unsigned int uCount,
  416. unsigned long ulDSPAddr)
  417. {
  418. int retval = 0;
  419. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  420. unsigned short usDspBaseIO = pSettings->usDspBaseIO;
  421. BOOLEAN bRC = 0;
  422. PRINTK_6(TRACE_TP3780I,
  423. "tp3780i::tp3780I_ReadWriteDspDStore entry pBDData %p, uOpcode %x, pvBuffer %p, uCount %x, ulDSPAddr %lx\n",
  424. pBDData, uOpcode, pvBuffer, uCount, ulDSPAddr);
  425. if (pBDData->bDSPEnabled) {
  426. switch (uOpcode) {
  427. case IOCTL_MW_READ_DATA:
  428. bRC = dsp3780I_ReadDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
  429. break;
  430. case IOCTL_MW_READCLEAR_DATA:
  431. bRC = dsp3780I_ReadAndClearDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
  432. break;
  433. case IOCTL_MW_WRITE_DATA:
  434. bRC = dsp3780I_WriteDStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
  435. break;
  436. }
  437. }
  438. retval = (bRC) ? -EIO : 0;
  439. PRINTK_2(TRACE_TP3780I, "tp3780i::tp3780I_ReadWriteDspDStore exit retval %x\n", retval);
  440. return retval;
  441. }
  442. int tp3780I_ReadWriteDspIStore(THINKPAD_BD_DATA * pBDData, unsigned int uOpcode,
  443. void __user *pvBuffer, unsigned int uCount,
  444. unsigned long ulDSPAddr)
  445. {
  446. int retval = 0;
  447. DSP_3780I_CONFIG_SETTINGS *pSettings = &pBDData->rDspSettings;
  448. unsigned short usDspBaseIO = pSettings->usDspBaseIO;
  449. BOOLEAN bRC = 0;
  450. PRINTK_6(TRACE_TP3780I,
  451. "tp3780i::tp3780I_ReadWriteDspIStore entry pBDData %p, uOpcode %x, pvBuffer %p, uCount %x, ulDSPAddr %lx\n",
  452. pBDData, uOpcode, pvBuffer, uCount, ulDSPAddr);
  453. if (pBDData->bDSPEnabled) {
  454. switch (uOpcode) {
  455. case IOCTL_MW_READ_INST:
  456. bRC = dsp3780I_ReadIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
  457. break;
  458. case IOCTL_MW_WRITE_INST:
  459. bRC = dsp3780I_WriteIStore(usDspBaseIO, pvBuffer, uCount, ulDSPAddr);
  460. break;
  461. }
  462. }
  463. retval = (bRC) ? -EIO : 0;
  464. PRINTK_2(TRACE_TP3780I,
  465. "tp3780i::tp3780I_ReadWriteDspIStore exit retval %x\n", retval);
  466. return retval;
  467. }