dma_lib.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * Copyright (C) 2006-2007 PA Semi, Inc
  3. *
  4. * Common functions for DMA access on PA Semi PWRficient
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/export.h>
  21. #include <linux/pci.h>
  22. #include <linux/slab.h>
  23. #include <linux/of.h>
  24. #include <linux/sched.h>
  25. #include <asm/pasemi_dma.h>
  26. #define MAX_TXCH 64
  27. #define MAX_RXCH 64
  28. #define MAX_FLAGS 64
  29. #define MAX_FUN 8
  30. static struct pasdma_status *dma_status;
  31. static void __iomem *iob_regs;
  32. static void __iomem *mac_regs[6];
  33. static void __iomem *dma_regs;
  34. static int base_hw_irq;
  35. static int num_txch, num_rxch;
  36. static struct pci_dev *dma_pdev;
  37. /* Bitmaps to handle allocation of channels */
  38. static DECLARE_BITMAP(txch_free, MAX_TXCH);
  39. static DECLARE_BITMAP(rxch_free, MAX_RXCH);
  40. static DECLARE_BITMAP(flags_free, MAX_FLAGS);
  41. static DECLARE_BITMAP(fun_free, MAX_FUN);
  42. /* pasemi_read_iob_reg - read IOB register
  43. * @reg: Register to read (offset into PCI CFG space)
  44. */
  45. unsigned int pasemi_read_iob_reg(unsigned int reg)
  46. {
  47. return in_le32(iob_regs+reg);
  48. }
  49. EXPORT_SYMBOL(pasemi_read_iob_reg);
  50. /* pasemi_write_iob_reg - write IOB register
  51. * @reg: Register to write to (offset into PCI CFG space)
  52. * @val: Value to write
  53. */
  54. void pasemi_write_iob_reg(unsigned int reg, unsigned int val)
  55. {
  56. out_le32(iob_regs+reg, val);
  57. }
  58. EXPORT_SYMBOL(pasemi_write_iob_reg);
  59. /* pasemi_read_mac_reg - read MAC register
  60. * @intf: MAC interface
  61. * @reg: Register to read (offset into PCI CFG space)
  62. */
  63. unsigned int pasemi_read_mac_reg(int intf, unsigned int reg)
  64. {
  65. return in_le32(mac_regs[intf]+reg);
  66. }
  67. EXPORT_SYMBOL(pasemi_read_mac_reg);
  68. /* pasemi_write_mac_reg - write MAC register
  69. * @intf: MAC interface
  70. * @reg: Register to write to (offset into PCI CFG space)
  71. * @val: Value to write
  72. */
  73. void pasemi_write_mac_reg(int intf, unsigned int reg, unsigned int val)
  74. {
  75. out_le32(mac_regs[intf]+reg, val);
  76. }
  77. EXPORT_SYMBOL(pasemi_write_mac_reg);
  78. /* pasemi_read_dma_reg - read DMA register
  79. * @reg: Register to read (offset into PCI CFG space)
  80. */
  81. unsigned int pasemi_read_dma_reg(unsigned int reg)
  82. {
  83. return in_le32(dma_regs+reg);
  84. }
  85. EXPORT_SYMBOL(pasemi_read_dma_reg);
  86. /* pasemi_write_dma_reg - write DMA register
  87. * @reg: Register to write to (offset into PCI CFG space)
  88. * @val: Value to write
  89. */
  90. void pasemi_write_dma_reg(unsigned int reg, unsigned int val)
  91. {
  92. out_le32(dma_regs+reg, val);
  93. }
  94. EXPORT_SYMBOL(pasemi_write_dma_reg);
  95. static int pasemi_alloc_tx_chan(enum pasemi_dmachan_type type)
  96. {
  97. int bit;
  98. int start, limit;
  99. switch (type & (TXCHAN_EVT0|TXCHAN_EVT1)) {
  100. case TXCHAN_EVT0:
  101. start = 0;
  102. limit = 10;
  103. break;
  104. case TXCHAN_EVT1:
  105. start = 10;
  106. limit = MAX_TXCH;
  107. break;
  108. default:
  109. start = 0;
  110. limit = MAX_TXCH;
  111. break;
  112. }
  113. retry:
  114. bit = find_next_bit(txch_free, MAX_TXCH, start);
  115. if (bit >= limit)
  116. return -ENOSPC;
  117. if (!test_and_clear_bit(bit, txch_free))
  118. goto retry;
  119. return bit;
  120. }
  121. static void pasemi_free_tx_chan(int chan)
  122. {
  123. BUG_ON(test_bit(chan, txch_free));
  124. set_bit(chan, txch_free);
  125. }
  126. static int pasemi_alloc_rx_chan(void)
  127. {
  128. int bit;
  129. retry:
  130. bit = find_first_bit(rxch_free, MAX_RXCH);
  131. if (bit >= MAX_TXCH)
  132. return -ENOSPC;
  133. if (!test_and_clear_bit(bit, rxch_free))
  134. goto retry;
  135. return bit;
  136. }
  137. static void pasemi_free_rx_chan(int chan)
  138. {
  139. BUG_ON(test_bit(chan, rxch_free));
  140. set_bit(chan, rxch_free);
  141. }
  142. /* pasemi_dma_alloc_chan - Allocate a DMA channel
  143. * @type: Type of channel to allocate
  144. * @total_size: Total size of structure to allocate (to allow for more
  145. * room behind the structure to be used by the client)
  146. * @offset: Offset in bytes from start of the total structure to the beginning
  147. * of struct pasemi_dmachan. Needed when struct pasemi_dmachan is
  148. * not the first member of the client structure.
  149. *
  150. * pasemi_dma_alloc_chan allocates a DMA channel for use by a client. The
  151. * type argument specifies whether it's a RX or TX channel, and in the case
  152. * of TX channels which group it needs to belong to (if any).
  153. *
  154. * Returns a pointer to the total structure allocated on success, NULL
  155. * on failure.
  156. */
  157. void *pasemi_dma_alloc_chan(enum pasemi_dmachan_type type,
  158. int total_size, int offset)
  159. {
  160. void *buf;
  161. struct pasemi_dmachan *chan;
  162. int chno;
  163. BUG_ON(total_size < sizeof(struct pasemi_dmachan));
  164. buf = kzalloc(total_size, GFP_KERNEL);
  165. if (!buf)
  166. return NULL;
  167. chan = buf + offset;
  168. chan->priv = buf;
  169. switch (type & (TXCHAN|RXCHAN)) {
  170. case RXCHAN:
  171. chno = pasemi_alloc_rx_chan();
  172. chan->chno = chno;
  173. chan->irq = irq_create_mapping(NULL,
  174. base_hw_irq + num_txch + chno);
  175. chan->status = &dma_status->rx_sta[chno];
  176. break;
  177. case TXCHAN:
  178. chno = pasemi_alloc_tx_chan(type);
  179. chan->chno = chno;
  180. chan->irq = irq_create_mapping(NULL, base_hw_irq + chno);
  181. chan->status = &dma_status->tx_sta[chno];
  182. break;
  183. }
  184. chan->chan_type = type;
  185. return chan;
  186. }
  187. EXPORT_SYMBOL(pasemi_dma_alloc_chan);
  188. /* pasemi_dma_free_chan - Free a previously allocated channel
  189. * @chan: Channel to free
  190. *
  191. * Frees a previously allocated channel. It will also deallocate any
  192. * descriptor ring associated with the channel, if allocated.
  193. */
  194. void pasemi_dma_free_chan(struct pasemi_dmachan *chan)
  195. {
  196. if (chan->ring_virt)
  197. pasemi_dma_free_ring(chan);
  198. switch (chan->chan_type & (RXCHAN|TXCHAN)) {
  199. case RXCHAN:
  200. pasemi_free_rx_chan(chan->chno);
  201. break;
  202. case TXCHAN:
  203. pasemi_free_tx_chan(chan->chno);
  204. break;
  205. }
  206. kfree(chan->priv);
  207. }
  208. EXPORT_SYMBOL(pasemi_dma_free_chan);
  209. /* pasemi_dma_alloc_ring - Allocate descriptor ring for a channel
  210. * @chan: Channel for which to allocate
  211. * @ring_size: Ring size in 64-bit (8-byte) words
  212. *
  213. * Allocate a descriptor ring for a channel. Returns 0 on success, errno
  214. * on failure. The passed in struct pasemi_dmachan is updated with the
  215. * virtual and DMA addresses of the ring.
  216. */
  217. int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size)
  218. {
  219. BUG_ON(chan->ring_virt);
  220. chan->ring_size = ring_size;
  221. chan->ring_virt = dma_alloc_coherent(&dma_pdev->dev,
  222. ring_size * sizeof(u64),
  223. &chan->ring_dma, GFP_KERNEL);
  224. if (!chan->ring_virt)
  225. return -ENOMEM;
  226. memset(chan->ring_virt, 0, ring_size * sizeof(u64));
  227. return 0;
  228. }
  229. EXPORT_SYMBOL(pasemi_dma_alloc_ring);
  230. /* pasemi_dma_free_ring - Free an allocated descriptor ring for a channel
  231. * @chan: Channel for which to free the descriptor ring
  232. *
  233. * Frees a previously allocated descriptor ring for a channel.
  234. */
  235. void pasemi_dma_free_ring(struct pasemi_dmachan *chan)
  236. {
  237. BUG_ON(!chan->ring_virt);
  238. dma_free_coherent(&dma_pdev->dev, chan->ring_size * sizeof(u64),
  239. chan->ring_virt, chan->ring_dma);
  240. chan->ring_virt = NULL;
  241. chan->ring_size = 0;
  242. chan->ring_dma = 0;
  243. }
  244. EXPORT_SYMBOL(pasemi_dma_free_ring);
  245. /* pasemi_dma_start_chan - Start a DMA channel
  246. * @chan: Channel to start
  247. * @cmdsta: Additional CCMDSTA/TCMDSTA bits to write
  248. *
  249. * Enables (starts) a DMA channel with optional additional arguments.
  250. */
  251. void pasemi_dma_start_chan(const struct pasemi_dmachan *chan, const u32 cmdsta)
  252. {
  253. if (chan->chan_type == RXCHAN)
  254. pasemi_write_dma_reg(PAS_DMA_RXCHAN_CCMDSTA(chan->chno),
  255. cmdsta | PAS_DMA_RXCHAN_CCMDSTA_EN);
  256. else
  257. pasemi_write_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chno),
  258. cmdsta | PAS_DMA_TXCHAN_TCMDSTA_EN);
  259. }
  260. EXPORT_SYMBOL(pasemi_dma_start_chan);
  261. /* pasemi_dma_stop_chan - Stop a DMA channel
  262. * @chan: Channel to stop
  263. *
  264. * Stops (disables) a DMA channel. This is done by setting the ST bit in the
  265. * CMDSTA register and waiting on the ACT (active) bit to clear, then
  266. * finally disabling the whole channel.
  267. *
  268. * This function will only try for a short while for the channel to stop, if
  269. * it doesn't it will return failure.
  270. *
  271. * Returns 1 on success, 0 on failure.
  272. */
  273. #define MAX_RETRIES 5000
  274. int pasemi_dma_stop_chan(const struct pasemi_dmachan *chan)
  275. {
  276. int reg, retries;
  277. u32 sta;
  278. if (chan->chan_type == RXCHAN) {
  279. reg = PAS_DMA_RXCHAN_CCMDSTA(chan->chno);
  280. pasemi_write_dma_reg(reg, PAS_DMA_RXCHAN_CCMDSTA_ST);
  281. for (retries = 0; retries < MAX_RETRIES; retries++) {
  282. sta = pasemi_read_dma_reg(reg);
  283. if (!(sta & PAS_DMA_RXCHAN_CCMDSTA_ACT)) {
  284. pasemi_write_dma_reg(reg, 0);
  285. return 1;
  286. }
  287. cond_resched();
  288. }
  289. } else {
  290. reg = PAS_DMA_TXCHAN_TCMDSTA(chan->chno);
  291. pasemi_write_dma_reg(reg, PAS_DMA_TXCHAN_TCMDSTA_ST);
  292. for (retries = 0; retries < MAX_RETRIES; retries++) {
  293. sta = pasemi_read_dma_reg(reg);
  294. if (!(sta & PAS_DMA_TXCHAN_TCMDSTA_ACT)) {
  295. pasemi_write_dma_reg(reg, 0);
  296. return 1;
  297. }
  298. cond_resched();
  299. }
  300. }
  301. return 0;
  302. }
  303. EXPORT_SYMBOL(pasemi_dma_stop_chan);
  304. /* pasemi_dma_alloc_buf - Allocate a buffer to use for DMA
  305. * @chan: Channel to allocate for
  306. * @size: Size of buffer in bytes
  307. * @handle: DMA handle
  308. *
  309. * Allocate a buffer to be used by the DMA engine for read/write,
  310. * similar to dma_alloc_coherent().
  311. *
  312. * Returns the virtual address of the buffer, or NULL in case of failure.
  313. */
  314. void *pasemi_dma_alloc_buf(struct pasemi_dmachan *chan, int size,
  315. dma_addr_t *handle)
  316. {
  317. return dma_alloc_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL);
  318. }
  319. EXPORT_SYMBOL(pasemi_dma_alloc_buf);
  320. /* pasemi_dma_free_buf - Free a buffer used for DMA
  321. * @chan: Channel the buffer was allocated for
  322. * @size: Size of buffer in bytes
  323. * @handle: DMA handle
  324. *
  325. * Frees a previously allocated buffer.
  326. */
  327. void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size,
  328. dma_addr_t *handle)
  329. {
  330. dma_free_coherent(&dma_pdev->dev, size, handle, GFP_KERNEL);
  331. }
  332. EXPORT_SYMBOL(pasemi_dma_free_buf);
  333. /* pasemi_dma_alloc_flag - Allocate a flag (event) for channel synchronization
  334. *
  335. * Allocates a flag for use with channel synchronization (event descriptors).
  336. * Returns allocated flag (0-63), < 0 on error.
  337. */
  338. int pasemi_dma_alloc_flag(void)
  339. {
  340. int bit;
  341. retry:
  342. bit = find_next_bit(flags_free, MAX_FLAGS, 0);
  343. if (bit >= MAX_FLAGS)
  344. return -ENOSPC;
  345. if (!test_and_clear_bit(bit, flags_free))
  346. goto retry;
  347. return bit;
  348. }
  349. EXPORT_SYMBOL(pasemi_dma_alloc_flag);
  350. /* pasemi_dma_free_flag - Deallocates a flag (event)
  351. * @flag: Flag number to deallocate
  352. *
  353. * Frees up a flag so it can be reused for other purposes.
  354. */
  355. void pasemi_dma_free_flag(int flag)
  356. {
  357. BUG_ON(test_bit(flag, flags_free));
  358. BUG_ON(flag >= MAX_FLAGS);
  359. set_bit(flag, flags_free);
  360. }
  361. EXPORT_SYMBOL(pasemi_dma_free_flag);
  362. /* pasemi_dma_set_flag - Sets a flag (event) to 1
  363. * @flag: Flag number to set active
  364. *
  365. * Sets the flag provided to 1.
  366. */
  367. void pasemi_dma_set_flag(int flag)
  368. {
  369. BUG_ON(flag >= MAX_FLAGS);
  370. if (flag < 32)
  371. pasemi_write_dma_reg(PAS_DMA_TXF_SFLG0, 1 << flag);
  372. else
  373. pasemi_write_dma_reg(PAS_DMA_TXF_SFLG1, 1 << flag);
  374. }
  375. EXPORT_SYMBOL(pasemi_dma_set_flag);
  376. /* pasemi_dma_clear_flag - Sets a flag (event) to 0
  377. * @flag: Flag number to set inactive
  378. *
  379. * Sets the flag provided to 0.
  380. */
  381. void pasemi_dma_clear_flag(int flag)
  382. {
  383. BUG_ON(flag >= MAX_FLAGS);
  384. if (flag < 32)
  385. pasemi_write_dma_reg(PAS_DMA_TXF_CFLG0, 1 << flag);
  386. else
  387. pasemi_write_dma_reg(PAS_DMA_TXF_CFLG1, 1 << flag);
  388. }
  389. EXPORT_SYMBOL(pasemi_dma_clear_flag);
  390. /* pasemi_dma_alloc_fun - Allocate a function engine
  391. *
  392. * Allocates a function engine to use for crypto/checksum offload
  393. * Returns allocated engine (0-8), < 0 on error.
  394. */
  395. int pasemi_dma_alloc_fun(void)
  396. {
  397. int bit;
  398. retry:
  399. bit = find_next_bit(fun_free, MAX_FLAGS, 0);
  400. if (bit >= MAX_FLAGS)
  401. return -ENOSPC;
  402. if (!test_and_clear_bit(bit, fun_free))
  403. goto retry;
  404. return bit;
  405. }
  406. EXPORT_SYMBOL(pasemi_dma_alloc_fun);
  407. /* pasemi_dma_free_fun - Deallocates a function engine
  408. * @flag: Engine number to deallocate
  409. *
  410. * Frees up a function engine so it can be used for other purposes.
  411. */
  412. void pasemi_dma_free_fun(int fun)
  413. {
  414. BUG_ON(test_bit(fun, fun_free));
  415. BUG_ON(fun >= MAX_FLAGS);
  416. set_bit(fun, fun_free);
  417. }
  418. EXPORT_SYMBOL(pasemi_dma_free_fun);
  419. static void *map_onedev(struct pci_dev *p, int index)
  420. {
  421. struct device_node *dn;
  422. void __iomem *ret;
  423. dn = pci_device_to_OF_node(p);
  424. if (!dn)
  425. goto fallback;
  426. ret = of_iomap(dn, index);
  427. if (!ret)
  428. goto fallback;
  429. return ret;
  430. fallback:
  431. /* This is hardcoded and ugly, but we have some firmware versions
  432. * that don't provide the register space in the device tree. Luckily
  433. * they are at well-known locations so we can just do the math here.
  434. */
  435. return ioremap(0xe0000000 + (p->devfn << 12), 0x2000);
  436. }
  437. /* pasemi_dma_init - Initialize the PA Semi DMA library
  438. *
  439. * This function initializes the DMA library. It must be called before
  440. * any other function in the library.
  441. *
  442. * Returns 0 on success, errno on failure.
  443. */
  444. int pasemi_dma_init(void)
  445. {
  446. static DEFINE_SPINLOCK(init_lock);
  447. struct pci_dev *iob_pdev;
  448. struct pci_dev *pdev;
  449. struct resource res;
  450. struct device_node *dn;
  451. int i, intf, err = 0;
  452. unsigned long timeout;
  453. u32 tmp;
  454. if (!machine_is(pasemi))
  455. return -ENODEV;
  456. spin_lock(&init_lock);
  457. /* Make sure we haven't already initialized */
  458. if (dma_pdev)
  459. goto out;
  460. iob_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL);
  461. if (!iob_pdev) {
  462. BUG();
  463. printk(KERN_WARNING "Can't find I/O Bridge\n");
  464. err = -ENODEV;
  465. goto out;
  466. }
  467. iob_regs = map_onedev(iob_pdev, 0);
  468. dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL);
  469. if (!dma_pdev) {
  470. BUG();
  471. printk(KERN_WARNING "Can't find DMA controller\n");
  472. err = -ENODEV;
  473. goto out;
  474. }
  475. dma_regs = map_onedev(dma_pdev, 0);
  476. base_hw_irq = virq_to_hw(dma_pdev->irq);
  477. pci_read_config_dword(dma_pdev, PAS_DMA_CAP_TXCH, &tmp);
  478. num_txch = (tmp & PAS_DMA_CAP_TXCH_TCHN_M) >> PAS_DMA_CAP_TXCH_TCHN_S;
  479. pci_read_config_dword(dma_pdev, PAS_DMA_CAP_RXCH, &tmp);
  480. num_rxch = (tmp & PAS_DMA_CAP_RXCH_RCHN_M) >> PAS_DMA_CAP_RXCH_RCHN_S;
  481. intf = 0;
  482. for (pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa006, NULL);
  483. pdev;
  484. pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa006, pdev))
  485. mac_regs[intf++] = map_onedev(pdev, 0);
  486. pci_dev_put(pdev);
  487. for (pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa005, NULL);
  488. pdev;
  489. pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa005, pdev))
  490. mac_regs[intf++] = map_onedev(pdev, 0);
  491. pci_dev_put(pdev);
  492. dn = pci_device_to_OF_node(iob_pdev);
  493. if (dn)
  494. err = of_address_to_resource(dn, 1, &res);
  495. if (!dn || err) {
  496. /* Fallback for old firmware */
  497. res.start = 0xfd800000;
  498. res.end = res.start + 0x1000;
  499. }
  500. dma_status = __ioremap(res.start, resource_size(&res), 0);
  501. pci_dev_put(iob_pdev);
  502. for (i = 0; i < MAX_TXCH; i++)
  503. __set_bit(i, txch_free);
  504. for (i = 0; i < MAX_RXCH; i++)
  505. __set_bit(i, rxch_free);
  506. timeout = jiffies + HZ;
  507. pasemi_write_dma_reg(PAS_DMA_COM_RXCMD, 0);
  508. while (pasemi_read_dma_reg(PAS_DMA_COM_RXSTA) & 1) {
  509. if (time_after(jiffies, timeout)) {
  510. pr_warning("Warning: Could not disable RX section\n");
  511. break;
  512. }
  513. }
  514. timeout = jiffies + HZ;
  515. pasemi_write_dma_reg(PAS_DMA_COM_TXCMD, 0);
  516. while (pasemi_read_dma_reg(PAS_DMA_COM_TXSTA) & 1) {
  517. if (time_after(jiffies, timeout)) {
  518. pr_warning("Warning: Could not disable TX section\n");
  519. break;
  520. }
  521. }
  522. /* setup resource allocations for the different DMA sections */
  523. tmp = pasemi_read_dma_reg(PAS_DMA_COM_CFG);
  524. pasemi_write_dma_reg(PAS_DMA_COM_CFG, tmp | 0x18000000);
  525. /* enable tx section */
  526. pasemi_write_dma_reg(PAS_DMA_COM_TXCMD, PAS_DMA_COM_TXCMD_EN);
  527. /* enable rx section */
  528. pasemi_write_dma_reg(PAS_DMA_COM_RXCMD, PAS_DMA_COM_RXCMD_EN);
  529. for (i = 0; i < MAX_FLAGS; i++)
  530. __set_bit(i, flags_free);
  531. for (i = 0; i < MAX_FUN; i++)
  532. __set_bit(i, fun_free);
  533. /* clear all status flags */
  534. pasemi_write_dma_reg(PAS_DMA_TXF_CFLG0, 0xffffffff);
  535. pasemi_write_dma_reg(PAS_DMA_TXF_CFLG1, 0xffffffff);
  536. printk(KERN_INFO "PA Semi PWRficient DMA library initialized "
  537. "(%d tx, %d rx channels)\n", num_txch, num_rxch);
  538. out:
  539. spin_unlock(&init_lock);
  540. return err;
  541. }
  542. EXPORT_SYMBOL(pasemi_dma_init);