3780i.c 21 KB

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