3780i.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. /*
  2. *
  3. * 3780i.c -- helper routines for the 3780i DSP
  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/kernel.h>
  49. #include <linux/unistd.h>
  50. #include <linux/delay.h>
  51. #include <linux/ioport.h>
  52. #include <linux/init.h>
  53. #include <linux/bitops.h>
  54. #include <linux/sched.h> /* cond_resched() */
  55. #include <asm/io.h>
  56. #include <asm/uaccess.h>
  57. #include <asm/irq.h>
  58. #include "smapi.h"
  59. #include "mwavedd.h"
  60. #include "3780i.h"
  61. static DEFINE_SPINLOCK(dsp_lock);
  62. static void PaceMsaAccess(unsigned short usDspBaseIO)
  63. {
  64. cond_resched();
  65. udelay(100);
  66. cond_resched();
  67. }
  68. unsigned short dsp3780I_ReadMsaCfg(unsigned short usDspBaseIO,
  69. unsigned long ulMsaAddr)
  70. {
  71. unsigned long flags;
  72. unsigned short val;
  73. PRINTK_3(TRACE_3780I,
  74. "3780i::dsp3780I_ReadMsaCfg entry usDspBaseIO %x ulMsaAddr %lx\n",
  75. usDspBaseIO, ulMsaAddr);
  76. spin_lock_irqsave(&dsp_lock, flags);
  77. OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulMsaAddr);
  78. OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulMsaAddr >> 16));
  79. val = InWordDsp(DSP_MsaDataDSISHigh);
  80. spin_unlock_irqrestore(&dsp_lock, flags);
  81. PRINTK_2(TRACE_3780I, "3780i::dsp3780I_ReadMsaCfg exit val %x\n", val);
  82. return val;
  83. }
  84. void dsp3780I_WriteMsaCfg(unsigned short usDspBaseIO,
  85. unsigned long ulMsaAddr, unsigned short usValue)
  86. {
  87. unsigned long flags;
  88. PRINTK_4(TRACE_3780I,
  89. "3780i::dsp3780i_WriteMsaCfg entry usDspBaseIO %x ulMsaAddr %lx usValue %x\n",
  90. usDspBaseIO, ulMsaAddr, usValue);
  91. spin_lock_irqsave(&dsp_lock, flags);
  92. OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulMsaAddr);
  93. OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulMsaAddr >> 16));
  94. OutWordDsp(DSP_MsaDataDSISHigh, usValue);
  95. spin_unlock_irqrestore(&dsp_lock, flags);
  96. }
  97. static void dsp3780I_WriteGenCfg(unsigned short usDspBaseIO, unsigned uIndex,
  98. unsigned char ucValue)
  99. {
  100. DSP_ISA_SLAVE_CONTROL rSlaveControl;
  101. DSP_ISA_SLAVE_CONTROL rSlaveControl_Save;
  102. PRINTK_4(TRACE_3780I,
  103. "3780i::dsp3780i_WriteGenCfg entry usDspBaseIO %x uIndex %x ucValue %x\n",
  104. usDspBaseIO, uIndex, ucValue);
  105. MKBYTE(rSlaveControl) = InByteDsp(DSP_IsaSlaveControl);
  106. PRINTK_2(TRACE_3780I,
  107. "3780i::dsp3780i_WriteGenCfg rSlaveControl %x\n",
  108. MKBYTE(rSlaveControl));
  109. rSlaveControl_Save = rSlaveControl;
  110. rSlaveControl.ConfigMode = TRUE;
  111. PRINTK_2(TRACE_3780I,
  112. "3780i::dsp3780i_WriteGenCfg entry rSlaveControl+ConfigMode %x\n",
  113. MKBYTE(rSlaveControl));
  114. OutByteDsp(DSP_IsaSlaveControl, MKBYTE(rSlaveControl));
  115. OutByteDsp(DSP_ConfigAddress, (unsigned char) uIndex);
  116. OutByteDsp(DSP_ConfigData, ucValue);
  117. OutByteDsp(DSP_IsaSlaveControl, MKBYTE(rSlaveControl_Save));
  118. PRINTK_1(TRACE_3780I, "3780i::dsp3780i_WriteGenCfg exit\n");
  119. }
  120. #if 0
  121. unsigned char dsp3780I_ReadGenCfg(unsigned short usDspBaseIO,
  122. unsigned uIndex)
  123. {
  124. DSP_ISA_SLAVE_CONTROL rSlaveControl;
  125. DSP_ISA_SLAVE_CONTROL rSlaveControl_Save;
  126. unsigned char ucValue;
  127. PRINTK_3(TRACE_3780I,
  128. "3780i::dsp3780i_ReadGenCfg entry usDspBaseIO %x uIndex %x\n",
  129. usDspBaseIO, uIndex);
  130. MKBYTE(rSlaveControl) = InByteDsp(DSP_IsaSlaveControl);
  131. rSlaveControl_Save = rSlaveControl;
  132. rSlaveControl.ConfigMode = TRUE;
  133. OutByteDsp(DSP_IsaSlaveControl, MKBYTE(rSlaveControl));
  134. OutByteDsp(DSP_ConfigAddress, (unsigned char) uIndex);
  135. ucValue = InByteDsp(DSP_ConfigData);
  136. OutByteDsp(DSP_IsaSlaveControl, MKBYTE(rSlaveControl_Save));
  137. PRINTK_2(TRACE_3780I,
  138. "3780i::dsp3780i_ReadGenCfg exit ucValue %x\n", ucValue);
  139. return ucValue;
  140. }
  141. #endif /* 0 */
  142. int dsp3780I_EnableDSP(DSP_3780I_CONFIG_SETTINGS * pSettings,
  143. unsigned short *pIrqMap,
  144. unsigned short *pDmaMap)
  145. {
  146. unsigned long flags;
  147. unsigned short usDspBaseIO = pSettings->usDspBaseIO;
  148. int i;
  149. DSP_UART_CFG_1 rUartCfg1;
  150. DSP_UART_CFG_2 rUartCfg2;
  151. DSP_HBRIDGE_CFG_1 rHBridgeCfg1;
  152. DSP_HBRIDGE_CFG_2 rHBridgeCfg2;
  153. DSP_BUSMASTER_CFG_1 rBusmasterCfg1;
  154. DSP_BUSMASTER_CFG_2 rBusmasterCfg2;
  155. DSP_ISA_PROT_CFG rIsaProtCfg;
  156. DSP_POWER_MGMT_CFG rPowerMgmtCfg;
  157. DSP_HBUS_TIMER_CFG rHBusTimerCfg;
  158. DSP_LBUS_TIMEOUT_DISABLE rLBusTimeoutDisable;
  159. DSP_CHIP_RESET rChipReset;
  160. DSP_CLOCK_CONTROL_1 rClockControl1;
  161. DSP_CLOCK_CONTROL_2 rClockControl2;
  162. DSP_ISA_SLAVE_CONTROL rSlaveControl;
  163. DSP_HBRIDGE_CONTROL rHBridgeControl;
  164. unsigned short ChipID = 0;
  165. unsigned short tval;
  166. PRINTK_2(TRACE_3780I,
  167. "3780i::dsp3780I_EnableDSP entry pSettings->bDSPEnabled %x\n",
  168. pSettings->bDSPEnabled);
  169. if (!pSettings->bDSPEnabled) {
  170. PRINTK_ERROR( KERN_ERR "3780i::dsp3780I_EnableDSP: Error: DSP not enabled. Aborting.\n" );
  171. return -EIO;
  172. }
  173. PRINTK_2(TRACE_3780I,
  174. "3780i::dsp3780i_EnableDSP entry pSettings->bModemEnabled %x\n",
  175. pSettings->bModemEnabled);
  176. if (pSettings->bModemEnabled) {
  177. rUartCfg1.Reserved = rUartCfg2.Reserved = 0;
  178. rUartCfg1.IrqActiveLow = pSettings->bUartIrqActiveLow;
  179. rUartCfg1.IrqPulse = pSettings->bUartIrqPulse;
  180. rUartCfg1.Irq =
  181. (unsigned char) pIrqMap[pSettings->usUartIrq];
  182. switch (pSettings->usUartBaseIO) {
  183. case 0x03F8:
  184. rUartCfg1.BaseIO = 0;
  185. break;
  186. case 0x02F8:
  187. rUartCfg1.BaseIO = 1;
  188. break;
  189. case 0x03E8:
  190. rUartCfg1.BaseIO = 2;
  191. break;
  192. case 0x02E8:
  193. rUartCfg1.BaseIO = 3;
  194. break;
  195. }
  196. rUartCfg2.Enable = TRUE;
  197. }
  198. rHBridgeCfg1.Reserved = rHBridgeCfg2.Reserved = 0;
  199. rHBridgeCfg1.IrqActiveLow = pSettings->bDspIrqActiveLow;
  200. rHBridgeCfg1.IrqPulse = pSettings->bDspIrqPulse;
  201. rHBridgeCfg1.Irq = (unsigned char) pIrqMap[pSettings->usDspIrq];
  202. rHBridgeCfg1.AccessMode = 1;
  203. rHBridgeCfg2.Enable = TRUE;
  204. rBusmasterCfg2.Reserved = 0;
  205. rBusmasterCfg1.Dma = (unsigned char) pDmaMap[pSettings->usDspDma];
  206. rBusmasterCfg1.NumTransfers =
  207. (unsigned char) pSettings->usNumTransfers;
  208. rBusmasterCfg1.ReRequest = (unsigned char) pSettings->usReRequest;
  209. rBusmasterCfg1.MEMCS16 = pSettings->bEnableMEMCS16;
  210. rBusmasterCfg2.IsaMemCmdWidth =
  211. (unsigned char) pSettings->usIsaMemCmdWidth;
  212. rIsaProtCfg.Reserved = 0;
  213. rIsaProtCfg.GateIOCHRDY = pSettings->bGateIOCHRDY;
  214. rPowerMgmtCfg.Reserved = 0;
  215. rPowerMgmtCfg.Enable = pSettings->bEnablePwrMgmt;
  216. rHBusTimerCfg.LoadValue =
  217. (unsigned char) pSettings->usHBusTimerLoadValue;
  218. rLBusTimeoutDisable.Reserved = 0;
  219. rLBusTimeoutDisable.DisableTimeout =
  220. pSettings->bDisableLBusTimeout;
  221. MKWORD(rChipReset) = ~pSettings->usChipletEnable;
  222. rClockControl1.Reserved1 = rClockControl1.Reserved2 = 0;
  223. rClockControl1.N_Divisor = pSettings->usN_Divisor;
  224. rClockControl1.M_Multiplier = pSettings->usM_Multiplier;
  225. rClockControl2.Reserved = 0;
  226. rClockControl2.PllBypass = pSettings->bPllBypass;
  227. /* Issue a soft reset to the chip */
  228. /* Note: Since we may be coming in with 3780i clocks suspended, we must keep
  229. * soft-reset active for 10ms.
  230. */
  231. rSlaveControl.ClockControl = 0;
  232. rSlaveControl.SoftReset = TRUE;
  233. rSlaveControl.ConfigMode = FALSE;
  234. rSlaveControl.Reserved = 0;
  235. PRINTK_4(TRACE_3780I,
  236. "3780i::dsp3780i_EnableDSP usDspBaseIO %x index %x taddr %x\n",
  237. usDspBaseIO, DSP_IsaSlaveControl,
  238. usDspBaseIO + DSP_IsaSlaveControl);
  239. PRINTK_2(TRACE_3780I,
  240. "3780i::dsp3780i_EnableDSP rSlaveContrl %x\n",
  241. MKWORD(rSlaveControl));
  242. spin_lock_irqsave(&dsp_lock, flags);
  243. OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
  244. MKWORD(tval) = InWordDsp(DSP_IsaSlaveControl);
  245. PRINTK_2(TRACE_3780I,
  246. "3780i::dsp3780i_EnableDSP rSlaveControl 2 %x\n", tval);
  247. for (i = 0; i < 11; i++)
  248. udelay(2000);
  249. rSlaveControl.SoftReset = FALSE;
  250. OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
  251. MKWORD(tval) = InWordDsp(DSP_IsaSlaveControl);
  252. PRINTK_2(TRACE_3780I,
  253. "3780i::dsp3780i_EnableDSP rSlaveControl 3 %x\n", tval);
  254. /* Program our general configuration registers */
  255. WriteGenCfg(DSP_HBridgeCfg1Index, MKBYTE(rHBridgeCfg1));
  256. WriteGenCfg(DSP_HBridgeCfg2Index, MKBYTE(rHBridgeCfg2));
  257. WriteGenCfg(DSP_BusMasterCfg1Index, MKBYTE(rBusmasterCfg1));
  258. WriteGenCfg(DSP_BusMasterCfg2Index, MKBYTE(rBusmasterCfg2));
  259. WriteGenCfg(DSP_IsaProtCfgIndex, MKBYTE(rIsaProtCfg));
  260. WriteGenCfg(DSP_PowerMgCfgIndex, MKBYTE(rPowerMgmtCfg));
  261. WriteGenCfg(DSP_HBusTimerCfgIndex, MKBYTE(rHBusTimerCfg));
  262. if (pSettings->bModemEnabled) {
  263. WriteGenCfg(DSP_UartCfg1Index, MKBYTE(rUartCfg1));
  264. WriteGenCfg(DSP_UartCfg2Index, MKBYTE(rUartCfg2));
  265. }
  266. rHBridgeControl.EnableDspInt = FALSE;
  267. rHBridgeControl.MemAutoInc = TRUE;
  268. rHBridgeControl.IoAutoInc = FALSE;
  269. rHBridgeControl.DiagnosticMode = FALSE;
  270. PRINTK_3(TRACE_3780I,
  271. "3780i::dsp3780i_EnableDSP DSP_HBridgeControl %x rHBridgeControl %x\n",
  272. DSP_HBridgeControl, MKWORD(rHBridgeControl));
  273. OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
  274. spin_unlock_irqrestore(&dsp_lock, flags);
  275. WriteMsaCfg(DSP_LBusTimeoutDisable, MKWORD(rLBusTimeoutDisable));
  276. WriteMsaCfg(DSP_ClockControl_1, MKWORD(rClockControl1));
  277. WriteMsaCfg(DSP_ClockControl_2, MKWORD(rClockControl2));
  278. WriteMsaCfg(DSP_ChipReset, MKWORD(rChipReset));
  279. ChipID = ReadMsaCfg(DSP_ChipID);
  280. PRINTK_2(TRACE_3780I,
  281. "3780i::dsp3780I_EnableDSP exiting bRC=TRUE, ChipID %x\n",
  282. ChipID);
  283. return 0;
  284. }
  285. int dsp3780I_DisableDSP(DSP_3780I_CONFIG_SETTINGS * pSettings)
  286. {
  287. unsigned long flags;
  288. unsigned short usDspBaseIO = pSettings->usDspBaseIO;
  289. DSP_ISA_SLAVE_CONTROL rSlaveControl;
  290. PRINTK_1(TRACE_3780I, "3780i::dsp3780i_DisableDSP entry\n");
  291. rSlaveControl.ClockControl = 0;
  292. rSlaveControl.SoftReset = TRUE;
  293. rSlaveControl.ConfigMode = FALSE;
  294. rSlaveControl.Reserved = 0;
  295. spin_lock_irqsave(&dsp_lock, flags);
  296. OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
  297. udelay(5);
  298. rSlaveControl.ClockControl = 1;
  299. OutWordDsp(DSP_IsaSlaveControl, MKWORD(rSlaveControl));
  300. spin_unlock_irqrestore(&dsp_lock, flags);
  301. udelay(5);
  302. PRINTK_1(TRACE_3780I, "3780i::dsp3780i_DisableDSP exit\n");
  303. return 0;
  304. }
  305. int dsp3780I_Reset(DSP_3780I_CONFIG_SETTINGS * pSettings)
  306. {
  307. unsigned long flags;
  308. unsigned short usDspBaseIO = pSettings->usDspBaseIO;
  309. DSP_BOOT_DOMAIN rBootDomain;
  310. DSP_HBRIDGE_CONTROL rHBridgeControl;
  311. PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Reset entry\n");
  312. spin_lock_irqsave(&dsp_lock, flags);
  313. /* Mask DSP to PC interrupt */
  314. MKWORD(rHBridgeControl) = InWordDsp(DSP_HBridgeControl);
  315. PRINTK_2(TRACE_3780I, "3780i::dsp3780i_Reset rHBridgeControl %x\n",
  316. MKWORD(rHBridgeControl));
  317. rHBridgeControl.EnableDspInt = FALSE;
  318. OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
  319. spin_unlock_irqrestore(&dsp_lock, flags);
  320. /* Reset the core via the boot domain register */
  321. rBootDomain.ResetCore = TRUE;
  322. rBootDomain.Halt = TRUE;
  323. rBootDomain.NMI = TRUE;
  324. rBootDomain.Reserved = 0;
  325. PRINTK_2(TRACE_3780I, "3780i::dsp3780i_Reset rBootDomain %x\n",
  326. MKWORD(rBootDomain));
  327. WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
  328. /* Reset all the chiplets and then reactivate them */
  329. WriteMsaCfg(DSP_ChipReset, 0xFFFF);
  330. udelay(5);
  331. WriteMsaCfg(DSP_ChipReset,
  332. (unsigned short) (~pSettings->usChipletEnable));
  333. PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Reset exit bRC=0\n");
  334. return 0;
  335. }
  336. int dsp3780I_Run(DSP_3780I_CONFIG_SETTINGS * pSettings)
  337. {
  338. unsigned long flags;
  339. unsigned short usDspBaseIO = pSettings->usDspBaseIO;
  340. DSP_BOOT_DOMAIN rBootDomain;
  341. DSP_HBRIDGE_CONTROL rHBridgeControl;
  342. PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Run entry\n");
  343. /* Transition the core to a running state */
  344. rBootDomain.ResetCore = TRUE;
  345. rBootDomain.Halt = FALSE;
  346. rBootDomain.NMI = TRUE;
  347. rBootDomain.Reserved = 0;
  348. WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
  349. udelay(5);
  350. rBootDomain.ResetCore = FALSE;
  351. WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
  352. udelay(5);
  353. rBootDomain.NMI = FALSE;
  354. WriteMsaCfg(DSP_MspBootDomain, MKWORD(rBootDomain));
  355. udelay(5);
  356. /* Enable DSP to PC interrupt */
  357. spin_lock_irqsave(&dsp_lock, flags);
  358. MKWORD(rHBridgeControl) = InWordDsp(DSP_HBridgeControl);
  359. rHBridgeControl.EnableDspInt = TRUE;
  360. PRINTK_2(TRACE_3780I, "3780i::dsp3780i_Run rHBridgeControl %x\n",
  361. MKWORD(rHBridgeControl));
  362. OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
  363. spin_unlock_irqrestore(&dsp_lock, flags);
  364. PRINTK_1(TRACE_3780I, "3780i::dsp3780i_Run exit bRC=TRUE\n");
  365. return 0;
  366. }
  367. int dsp3780I_ReadDStore(unsigned short usDspBaseIO, void __user *pvBuffer,
  368. unsigned uCount, unsigned long ulDSPAddr)
  369. {
  370. unsigned long flags;
  371. unsigned short __user *pusBuffer = pvBuffer;
  372. unsigned short val;
  373. PRINTK_5(TRACE_3780I,
  374. "3780i::dsp3780I_ReadDStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
  375. usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
  376. /* Set the initial MSA address. No adjustments need to be made to data store addresses */
  377. spin_lock_irqsave(&dsp_lock, flags);
  378. OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
  379. OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
  380. spin_unlock_irqrestore(&dsp_lock, flags);
  381. /* Transfer the memory block */
  382. while (uCount-- != 0) {
  383. spin_lock_irqsave(&dsp_lock, flags);
  384. val = InWordDsp(DSP_MsaDataDSISHigh);
  385. spin_unlock_irqrestore(&dsp_lock, flags);
  386. if(put_user(val, pusBuffer++))
  387. return -EFAULT;
  388. PRINTK_3(TRACE_3780I,
  389. "3780I::dsp3780I_ReadDStore uCount %x val %x\n",
  390. uCount, val);
  391. PaceMsaAccess(usDspBaseIO);
  392. }
  393. PRINTK_1(TRACE_3780I,
  394. "3780I::dsp3780I_ReadDStore exit bRC=TRUE\n");
  395. return 0;
  396. }
  397. int dsp3780I_ReadAndClearDStore(unsigned short usDspBaseIO,
  398. void __user *pvBuffer, unsigned uCount,
  399. unsigned long ulDSPAddr)
  400. {
  401. unsigned long flags;
  402. unsigned short __user *pusBuffer = pvBuffer;
  403. unsigned short val;
  404. PRINTK_5(TRACE_3780I,
  405. "3780i::dsp3780I_ReadAndDStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
  406. usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
  407. /* Set the initial MSA address. No adjustments need to be made to data store addresses */
  408. spin_lock_irqsave(&dsp_lock, flags);
  409. OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
  410. OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
  411. spin_unlock_irqrestore(&dsp_lock, flags);
  412. /* Transfer the memory block */
  413. while (uCount-- != 0) {
  414. spin_lock_irqsave(&dsp_lock, flags);
  415. val = InWordDsp(DSP_ReadAndClear);
  416. spin_unlock_irqrestore(&dsp_lock, flags);
  417. if(put_user(val, pusBuffer++))
  418. return -EFAULT;
  419. PRINTK_3(TRACE_3780I,
  420. "3780I::dsp3780I_ReadAndCleanDStore uCount %x val %x\n",
  421. uCount, val);
  422. PaceMsaAccess(usDspBaseIO);
  423. }
  424. PRINTK_1(TRACE_3780I,
  425. "3780I::dsp3780I_ReadAndClearDStore exit bRC=TRUE\n");
  426. return 0;
  427. }
  428. int dsp3780I_WriteDStore(unsigned short usDspBaseIO, void __user *pvBuffer,
  429. unsigned uCount, unsigned long ulDSPAddr)
  430. {
  431. unsigned long flags;
  432. unsigned short __user *pusBuffer = pvBuffer;
  433. PRINTK_5(TRACE_3780I,
  434. "3780i::dsp3780D_WriteDStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
  435. usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
  436. /* Set the initial MSA address. No adjustments need to be made to data store addresses */
  437. spin_lock_irqsave(&dsp_lock, flags);
  438. OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
  439. OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
  440. spin_unlock_irqrestore(&dsp_lock, flags);
  441. /* Transfer the memory block */
  442. while (uCount-- != 0) {
  443. unsigned short val;
  444. if(get_user(val, pusBuffer++))
  445. return -EFAULT;
  446. spin_lock_irqsave(&dsp_lock, flags);
  447. OutWordDsp(DSP_MsaDataDSISHigh, val);
  448. spin_unlock_irqrestore(&dsp_lock, flags);
  449. PRINTK_3(TRACE_3780I,
  450. "3780I::dsp3780I_WriteDStore uCount %x val %x\n",
  451. uCount, val);
  452. PaceMsaAccess(usDspBaseIO);
  453. }
  454. PRINTK_1(TRACE_3780I,
  455. "3780I::dsp3780D_WriteDStore exit bRC=TRUE\n");
  456. return 0;
  457. }
  458. int dsp3780I_ReadIStore(unsigned short usDspBaseIO, void __user *pvBuffer,
  459. unsigned uCount, unsigned long ulDSPAddr)
  460. {
  461. unsigned long flags;
  462. unsigned short __user *pusBuffer = pvBuffer;
  463. PRINTK_5(TRACE_3780I,
  464. "3780i::dsp3780I_ReadIStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
  465. usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
  466. /*
  467. * Set the initial MSA address. To convert from an instruction store
  468. * address to an MSA address
  469. * shift the address two bits to the left and set bit 22
  470. */
  471. ulDSPAddr = (ulDSPAddr << 2) | (1 << 22);
  472. spin_lock_irqsave(&dsp_lock, flags);
  473. OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
  474. OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
  475. spin_unlock_irqrestore(&dsp_lock, flags);
  476. /* Transfer the memory block */
  477. while (uCount-- != 0) {
  478. unsigned short val_lo, val_hi;
  479. spin_lock_irqsave(&dsp_lock, flags);
  480. val_lo = InWordDsp(DSP_MsaDataISLow);
  481. val_hi = InWordDsp(DSP_MsaDataDSISHigh);
  482. spin_unlock_irqrestore(&dsp_lock, flags);
  483. if(put_user(val_lo, pusBuffer++))
  484. return -EFAULT;
  485. if(put_user(val_hi, pusBuffer++))
  486. return -EFAULT;
  487. PRINTK_4(TRACE_3780I,
  488. "3780I::dsp3780I_ReadIStore uCount %x val_lo %x val_hi %x\n",
  489. uCount, val_lo, val_hi);
  490. PaceMsaAccess(usDspBaseIO);
  491. }
  492. PRINTK_1(TRACE_3780I,
  493. "3780I::dsp3780I_ReadIStore exit bRC=TRUE\n");
  494. return 0;
  495. }
  496. int dsp3780I_WriteIStore(unsigned short usDspBaseIO, void __user *pvBuffer,
  497. unsigned uCount, unsigned long ulDSPAddr)
  498. {
  499. unsigned long flags;
  500. unsigned short __user *pusBuffer = pvBuffer;
  501. PRINTK_5(TRACE_3780I,
  502. "3780i::dsp3780I_WriteIStore entry usDspBaseIO %x, pusBuffer %p, uCount %x, ulDSPAddr %lx\n",
  503. usDspBaseIO, pusBuffer, uCount, ulDSPAddr);
  504. /*
  505. * Set the initial MSA address. To convert from an instruction store
  506. * address to an MSA address
  507. * shift the address two bits to the left and set bit 22
  508. */
  509. ulDSPAddr = (ulDSPAddr << 2) | (1 << 22);
  510. spin_lock_irqsave(&dsp_lock, flags);
  511. OutWordDsp(DSP_MsaAddrLow, (unsigned short) ulDSPAddr);
  512. OutWordDsp(DSP_MsaAddrHigh, (unsigned short) (ulDSPAddr >> 16));
  513. spin_unlock_irqrestore(&dsp_lock, flags);
  514. /* Transfer the memory block */
  515. while (uCount-- != 0) {
  516. unsigned short val_lo, val_hi;
  517. if(get_user(val_lo, pusBuffer++))
  518. return -EFAULT;
  519. if(get_user(val_hi, pusBuffer++))
  520. return -EFAULT;
  521. spin_lock_irqsave(&dsp_lock, flags);
  522. OutWordDsp(DSP_MsaDataISLow, val_lo);
  523. OutWordDsp(DSP_MsaDataDSISHigh, val_hi);
  524. spin_unlock_irqrestore(&dsp_lock, flags);
  525. PRINTK_4(TRACE_3780I,
  526. "3780I::dsp3780I_WriteIStore uCount %x val_lo %x val_hi %x\n",
  527. uCount, val_lo, val_hi);
  528. PaceMsaAccess(usDspBaseIO);
  529. }
  530. PRINTK_1(TRACE_3780I,
  531. "3780I::dsp3780I_WriteIStore exit bRC=TRUE\n");
  532. return 0;
  533. }
  534. int dsp3780I_GetIPCSource(unsigned short usDspBaseIO,
  535. unsigned short *pusIPCSource)
  536. {
  537. unsigned long flags;
  538. DSP_HBRIDGE_CONTROL rHBridgeControl;
  539. unsigned short temp;
  540. PRINTK_3(TRACE_3780I,
  541. "3780i::dsp3780I_GetIPCSource entry usDspBaseIO %x pusIPCSource %p\n",
  542. usDspBaseIO, pusIPCSource);
  543. /*
  544. * Disable DSP to PC interrupts, read the interrupt register,
  545. * clear the pending IPC bits, and reenable DSP to PC interrupts
  546. */
  547. spin_lock_irqsave(&dsp_lock, flags);
  548. MKWORD(rHBridgeControl) = InWordDsp(DSP_HBridgeControl);
  549. rHBridgeControl.EnableDspInt = FALSE;
  550. OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
  551. *pusIPCSource = InWordDsp(DSP_Interrupt);
  552. temp = (unsigned short) ~(*pusIPCSource);
  553. PRINTK_3(TRACE_3780I,
  554. "3780i::dsp3780I_GetIPCSource, usIPCSource %x ~ %x\n",
  555. *pusIPCSource, temp);
  556. OutWordDsp(DSP_Interrupt, (unsigned short) ~(*pusIPCSource));
  557. rHBridgeControl.EnableDspInt = TRUE;
  558. OutWordDsp(DSP_HBridgeControl, MKWORD(rHBridgeControl));
  559. spin_unlock_irqrestore(&dsp_lock, flags);
  560. PRINTK_2(TRACE_3780I,
  561. "3780i::dsp3780I_GetIPCSource exit usIPCSource %x\n",
  562. *pusIPCSource);
  563. return 0;
  564. }