bcm-pdc-mailbox.c 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664
  1. /*
  2. * Copyright 2016 Broadcom
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License, version 2, as
  6. * published by the Free Software Foundation (the "GPL").
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License version 2 (GPLv2) for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * version 2 (GPLv2) along with this source code.
  15. */
  16. /*
  17. * Broadcom PDC Mailbox Driver
  18. * The PDC provides a ring based programming interface to one or more hardware
  19. * offload engines. For example, the PDC driver works with both SPU-M and SPU2
  20. * cryptographic offload hardware. In some chips the PDC is referred to as MDE,
  21. * and in others the FA2/FA+ hardware is used with this PDC driver.
  22. *
  23. * The PDC driver registers with the Linux mailbox framework as a mailbox
  24. * controller, once for each PDC instance. Ring 0 for each PDC is registered as
  25. * a mailbox channel. The PDC driver uses interrupts to determine when data
  26. * transfers to and from an offload engine are complete. The PDC driver uses
  27. * threaded IRQs so that response messages are handled outside of interrupt
  28. * context.
  29. *
  30. * The PDC driver allows multiple messages to be pending in the descriptor
  31. * rings. The tx_msg_start descriptor index indicates where the last message
  32. * starts. The txin_numd value at this index indicates how many descriptor
  33. * indexes make up the message. Similar state is kept on the receive side. When
  34. * an rx interrupt indicates a response is ready, the PDC driver processes numd
  35. * descriptors from the tx and rx ring, thus processing one response at a time.
  36. */
  37. #include <linux/errno.h>
  38. #include <linux/module.h>
  39. #include <linux/init.h>
  40. #include <linux/slab.h>
  41. #include <linux/debugfs.h>
  42. #include <linux/interrupt.h>
  43. #include <linux/wait.h>
  44. #include <linux/platform_device.h>
  45. #include <linux/io.h>
  46. #include <linux/of.h>
  47. #include <linux/of_device.h>
  48. #include <linux/of_address.h>
  49. #include <linux/of_irq.h>
  50. #include <linux/mailbox_controller.h>
  51. #include <linux/mailbox/brcm-message.h>
  52. #include <linux/scatterlist.h>
  53. #include <linux/dma-direction.h>
  54. #include <linux/dma-mapping.h>
  55. #include <linux/dmapool.h>
  56. #define PDC_SUCCESS 0
  57. #define RING_ENTRY_SIZE sizeof(struct dma64dd)
  58. /* # entries in PDC dma ring */
  59. #define PDC_RING_ENTRIES 512
  60. /*
  61. * Minimum number of ring descriptor entries that must be free to tell mailbox
  62. * framework that it can submit another request
  63. */
  64. #define PDC_RING_SPACE_MIN 15
  65. #define PDC_RING_SIZE (PDC_RING_ENTRIES * RING_ENTRY_SIZE)
  66. /* Rings are 8k aligned */
  67. #define RING_ALIGN_ORDER 13
  68. #define RING_ALIGN BIT(RING_ALIGN_ORDER)
  69. #define RX_BUF_ALIGN_ORDER 5
  70. #define RX_BUF_ALIGN BIT(RX_BUF_ALIGN_ORDER)
  71. /* descriptor bumping macros */
  72. #define XXD(x, max_mask) ((x) & (max_mask))
  73. #define TXD(x, max_mask) XXD((x), (max_mask))
  74. #define RXD(x, max_mask) XXD((x), (max_mask))
  75. #define NEXTTXD(i, max_mask) TXD((i) + 1, (max_mask))
  76. #define PREVTXD(i, max_mask) TXD((i) - 1, (max_mask))
  77. #define NEXTRXD(i, max_mask) RXD((i) + 1, (max_mask))
  78. #define PREVRXD(i, max_mask) RXD((i) - 1, (max_mask))
  79. #define NTXDACTIVE(h, t, max_mask) TXD((t) - (h), (max_mask))
  80. #define NRXDACTIVE(h, t, max_mask) RXD((t) - (h), (max_mask))
  81. /* Length of BCM header at start of SPU msg, in bytes */
  82. #define BCM_HDR_LEN 8
  83. /*
  84. * PDC driver reserves ringset 0 on each SPU for its own use. The driver does
  85. * not currently support use of multiple ringsets on a single PDC engine.
  86. */
  87. #define PDC_RINGSET 0
  88. /*
  89. * Interrupt mask and status definitions. Enable interrupts for tx and rx on
  90. * ring 0
  91. */
  92. #define PDC_RCVINT_0 (16 + PDC_RINGSET)
  93. #define PDC_RCVINTEN_0 BIT(PDC_RCVINT_0)
  94. #define PDC_INTMASK (PDC_RCVINTEN_0)
  95. #define PDC_LAZY_FRAMECOUNT 1
  96. #define PDC_LAZY_TIMEOUT 10000
  97. #define PDC_LAZY_INT (PDC_LAZY_TIMEOUT | (PDC_LAZY_FRAMECOUNT << 24))
  98. #define PDC_INTMASK_OFFSET 0x24
  99. #define PDC_INTSTATUS_OFFSET 0x20
  100. #define PDC_RCVLAZY0_OFFSET (0x30 + 4 * PDC_RINGSET)
  101. #define FA_RCVLAZY0_OFFSET 0x100
  102. /*
  103. * For SPU2, configure MDE_CKSUM_CONTROL to write 17 bytes of metadata
  104. * before frame
  105. */
  106. #define PDC_SPU2_RESP_HDR_LEN 17
  107. #define PDC_CKSUM_CTRL BIT(27)
  108. #define PDC_CKSUM_CTRL_OFFSET 0x400
  109. #define PDC_SPUM_RESP_HDR_LEN 32
  110. /*
  111. * Sets the following bits for write to transmit control reg:
  112. * 11 - PtyChkDisable - parity check is disabled
  113. * 20:18 - BurstLen = 3 -> 2^7 = 128 byte data reads from memory
  114. */
  115. #define PDC_TX_CTL 0x000C0800
  116. /* Bit in tx control reg to enable tx channel */
  117. #define PDC_TX_ENABLE 0x1
  118. /*
  119. * Sets the following bits for write to receive control reg:
  120. * 7:1 - RcvOffset - size in bytes of status region at start of rx frame buf
  121. * 9 - SepRxHdrDescEn - place start of new frames only in descriptors
  122. * that have StartOfFrame set
  123. * 10 - OflowContinue - on rx FIFO overflow, clear rx fifo, discard all
  124. * remaining bytes in current frame, report error
  125. * in rx frame status for current frame
  126. * 11 - PtyChkDisable - parity check is disabled
  127. * 20:18 - BurstLen = 3 -> 2^7 = 128 byte data reads from memory
  128. */
  129. #define PDC_RX_CTL 0x000C0E00
  130. /* Bit in rx control reg to enable rx channel */
  131. #define PDC_RX_ENABLE 0x1
  132. #define CRYPTO_D64_RS0_CD_MASK ((PDC_RING_ENTRIES * RING_ENTRY_SIZE) - 1)
  133. /* descriptor flags */
  134. #define D64_CTRL1_EOT BIT(28) /* end of descriptor table */
  135. #define D64_CTRL1_IOC BIT(29) /* interrupt on complete */
  136. #define D64_CTRL1_EOF BIT(30) /* end of frame */
  137. #define D64_CTRL1_SOF BIT(31) /* start of frame */
  138. #define RX_STATUS_OVERFLOW 0x00800000
  139. #define RX_STATUS_LEN 0x0000FFFF
  140. #define PDC_TXREGS_OFFSET 0x200
  141. #define PDC_RXREGS_OFFSET 0x220
  142. /* Maximum size buffer the DMA engine can handle */
  143. #define PDC_DMA_BUF_MAX 16384
  144. enum pdc_hw {
  145. FA_HW, /* FA2/FA+ hardware (i.e. Northstar Plus) */
  146. PDC_HW /* PDC/MDE hardware (i.e. Northstar 2, Pegasus) */
  147. };
  148. struct pdc_dma_map {
  149. void *ctx; /* opaque context associated with frame */
  150. };
  151. /* dma descriptor */
  152. struct dma64dd {
  153. u32 ctrl1; /* misc control bits */
  154. u32 ctrl2; /* buffer count and address extension */
  155. u32 addrlow; /* memory address of the date buffer, bits 31:0 */
  156. u32 addrhigh; /* memory address of the date buffer, bits 63:32 */
  157. };
  158. /* dma registers per channel(xmt or rcv) */
  159. struct dma64_regs {
  160. u32 control; /* enable, et al */
  161. u32 ptr; /* last descriptor posted to chip */
  162. u32 addrlow; /* descriptor ring base address low 32-bits */
  163. u32 addrhigh; /* descriptor ring base address bits 63:32 */
  164. u32 status0; /* last rx descriptor written by hw */
  165. u32 status1; /* driver does not use */
  166. };
  167. /* cpp contortions to concatenate w/arg prescan */
  168. #ifndef PAD
  169. #define _PADLINE(line) pad ## line
  170. #define _XSTR(line) _PADLINE(line)
  171. #define PAD _XSTR(__LINE__)
  172. #endif /* PAD */
  173. /* dma registers. matches hw layout. */
  174. struct dma64 {
  175. struct dma64_regs dmaxmt; /* dma tx */
  176. u32 PAD[2];
  177. struct dma64_regs dmarcv; /* dma rx */
  178. u32 PAD[2];
  179. };
  180. /* PDC registers */
  181. struct pdc_regs {
  182. u32 devcontrol; /* 0x000 */
  183. u32 devstatus; /* 0x004 */
  184. u32 PAD;
  185. u32 biststatus; /* 0x00c */
  186. u32 PAD[4];
  187. u32 intstatus; /* 0x020 */
  188. u32 intmask; /* 0x024 */
  189. u32 gptimer; /* 0x028 */
  190. u32 PAD;
  191. u32 intrcvlazy_0; /* 0x030 (Only in PDC, not FA2) */
  192. u32 intrcvlazy_1; /* 0x034 (Only in PDC, not FA2) */
  193. u32 intrcvlazy_2; /* 0x038 (Only in PDC, not FA2) */
  194. u32 intrcvlazy_3; /* 0x03c (Only in PDC, not FA2) */
  195. u32 PAD[48];
  196. u32 fa_intrecvlazy; /* 0x100 (Only in FA2, not PDC) */
  197. u32 flowctlthresh; /* 0x104 */
  198. u32 wrrthresh; /* 0x108 */
  199. u32 gmac_idle_cnt_thresh; /* 0x10c */
  200. u32 PAD[4];
  201. u32 ifioaccessaddr; /* 0x120 */
  202. u32 ifioaccessbyte; /* 0x124 */
  203. u32 ifioaccessdata; /* 0x128 */
  204. u32 PAD[21];
  205. u32 phyaccess; /* 0x180 */
  206. u32 PAD;
  207. u32 phycontrol; /* 0x188 */
  208. u32 txqctl; /* 0x18c */
  209. u32 rxqctl; /* 0x190 */
  210. u32 gpioselect; /* 0x194 */
  211. u32 gpio_output_en; /* 0x198 */
  212. u32 PAD; /* 0x19c */
  213. u32 txq_rxq_mem_ctl; /* 0x1a0 */
  214. u32 memory_ecc_status; /* 0x1a4 */
  215. u32 serdes_ctl; /* 0x1a8 */
  216. u32 serdes_status0; /* 0x1ac */
  217. u32 serdes_status1; /* 0x1b0 */
  218. u32 PAD[11]; /* 0x1b4-1dc */
  219. u32 clk_ctl_st; /* 0x1e0 */
  220. u32 hw_war; /* 0x1e4 (Only in PDC, not FA2) */
  221. u32 pwrctl; /* 0x1e8 */
  222. u32 PAD[5];
  223. #define PDC_NUM_DMA_RINGS 4
  224. struct dma64 dmaregs[PDC_NUM_DMA_RINGS]; /* 0x0200 - 0x2fc */
  225. /* more registers follow, but we don't use them */
  226. };
  227. /* structure for allocating/freeing DMA rings */
  228. struct pdc_ring_alloc {
  229. dma_addr_t dmabase; /* DMA address of start of ring */
  230. void *vbase; /* base kernel virtual address of ring */
  231. u32 size; /* ring allocation size in bytes */
  232. };
  233. /*
  234. * context associated with a receive descriptor.
  235. * @rxp_ctx: opaque context associated with frame that starts at each
  236. * rx ring index.
  237. * @dst_sg: Scatterlist used to form reply frames beginning at a given ring
  238. * index. Retained in order to unmap each sg after reply is processed.
  239. * @rxin_numd: Number of rx descriptors associated with the message that starts
  240. * at a descriptor index. Not set for every index. For example,
  241. * if descriptor index i points to a scatterlist with 4 entries,
  242. * then the next three descriptor indexes don't have a value set.
  243. * @resp_hdr: Virtual address of buffer used to catch DMA rx status
  244. * @resp_hdr_daddr: physical address of DMA rx status buffer
  245. */
  246. struct pdc_rx_ctx {
  247. void *rxp_ctx;
  248. struct scatterlist *dst_sg;
  249. u32 rxin_numd;
  250. void *resp_hdr;
  251. dma_addr_t resp_hdr_daddr;
  252. };
  253. /* PDC state structure */
  254. struct pdc_state {
  255. /* Index of the PDC whose state is in this structure instance */
  256. u8 pdc_idx;
  257. /* Platform device for this PDC instance */
  258. struct platform_device *pdev;
  259. /*
  260. * Each PDC instance has a mailbox controller. PDC receives request
  261. * messages through mailboxes, and sends response messages through the
  262. * mailbox framework.
  263. */
  264. struct mbox_controller mbc;
  265. unsigned int pdc_irq;
  266. /* tasklet for deferred processing after DMA rx interrupt */
  267. struct tasklet_struct rx_tasklet;
  268. /* Number of bytes of receive status prior to each rx frame */
  269. u32 rx_status_len;
  270. /* Whether a BCM header is prepended to each frame */
  271. bool use_bcm_hdr;
  272. /* Sum of length of BCM header and rx status header */
  273. u32 pdc_resp_hdr_len;
  274. /* The base virtual address of DMA hw registers */
  275. void __iomem *pdc_reg_vbase;
  276. /* Pool for allocation of DMA rings */
  277. struct dma_pool *ring_pool;
  278. /* Pool for allocation of metadata buffers for response messages */
  279. struct dma_pool *rx_buf_pool;
  280. /*
  281. * The base virtual address of DMA tx/rx descriptor rings. Corresponding
  282. * DMA address and size of ring allocation.
  283. */
  284. struct pdc_ring_alloc tx_ring_alloc;
  285. struct pdc_ring_alloc rx_ring_alloc;
  286. struct pdc_regs *regs; /* start of PDC registers */
  287. struct dma64_regs *txregs_64; /* dma tx engine registers */
  288. struct dma64_regs *rxregs_64; /* dma rx engine registers */
  289. /*
  290. * Arrays of PDC_RING_ENTRIES descriptors
  291. * To use multiple ringsets, this needs to be extended
  292. */
  293. struct dma64dd *txd_64; /* tx descriptor ring */
  294. struct dma64dd *rxd_64; /* rx descriptor ring */
  295. /* descriptor ring sizes */
  296. u32 ntxd; /* # tx descriptors */
  297. u32 nrxd; /* # rx descriptors */
  298. u32 nrxpost; /* # rx buffers to keep posted */
  299. u32 ntxpost; /* max number of tx buffers that can be posted */
  300. /*
  301. * Index of next tx descriptor to reclaim. That is, the descriptor
  302. * index of the oldest tx buffer for which the host has yet to process
  303. * the corresponding response.
  304. */
  305. u32 txin;
  306. /*
  307. * Index of the first receive descriptor for the sequence of
  308. * message fragments currently under construction. Used to build up
  309. * the rxin_numd count for a message. Updated to rxout when the host
  310. * starts a new sequence of rx buffers for a new message.
  311. */
  312. u32 tx_msg_start;
  313. /* Index of next tx descriptor to post. */
  314. u32 txout;
  315. /*
  316. * Number of tx descriptors associated with the message that starts
  317. * at this tx descriptor index.
  318. */
  319. u32 txin_numd[PDC_RING_ENTRIES];
  320. /*
  321. * Index of next rx descriptor to reclaim. This is the index of
  322. * the next descriptor whose data has yet to be processed by the host.
  323. */
  324. u32 rxin;
  325. /*
  326. * Index of the first receive descriptor for the sequence of
  327. * message fragments currently under construction. Used to build up
  328. * the rxin_numd count for a message. Updated to rxout when the host
  329. * starts a new sequence of rx buffers for a new message.
  330. */
  331. u32 rx_msg_start;
  332. /*
  333. * Saved value of current hardware rx descriptor index.
  334. * The last rx buffer written by the hw is the index previous to
  335. * this one.
  336. */
  337. u32 last_rx_curr;
  338. /* Index of next rx descriptor to post. */
  339. u32 rxout;
  340. struct pdc_rx_ctx rx_ctx[PDC_RING_ENTRIES];
  341. /*
  342. * Scatterlists used to form request and reply frames beginning at a
  343. * given ring index. Retained in order to unmap each sg after reply
  344. * is processed
  345. */
  346. struct scatterlist *src_sg[PDC_RING_ENTRIES];
  347. struct dentry *debugfs_stats; /* debug FS stats file for this PDC */
  348. /* counters */
  349. u32 pdc_requests; /* number of request messages submitted */
  350. u32 pdc_replies; /* number of reply messages received */
  351. u32 last_tx_not_done; /* too few tx descriptors to indicate done */
  352. u32 tx_ring_full; /* unable to accept msg because tx ring full */
  353. u32 rx_ring_full; /* unable to accept msg because rx ring full */
  354. u32 txnobuf; /* unable to create tx descriptor */
  355. u32 rxnobuf; /* unable to create rx descriptor */
  356. u32 rx_oflow; /* count of rx overflows */
  357. /* hardware type - FA2 or PDC/MDE */
  358. enum pdc_hw hw_type;
  359. };
  360. /* Global variables */
  361. struct pdc_globals {
  362. /* Actual number of SPUs in hardware, as reported by device tree */
  363. u32 num_spu;
  364. };
  365. static struct pdc_globals pdcg;
  366. /* top level debug FS directory for PDC driver */
  367. static struct dentry *debugfs_dir;
  368. static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
  369. size_t count, loff_t *offp)
  370. {
  371. struct pdc_state *pdcs;
  372. char *buf;
  373. ssize_t ret, out_offset, out_count;
  374. out_count = 512;
  375. buf = kmalloc(out_count, GFP_KERNEL);
  376. if (!buf)
  377. return -ENOMEM;
  378. pdcs = filp->private_data;
  379. out_offset = 0;
  380. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  381. "SPU %u stats:\n", pdcs->pdc_idx);
  382. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  383. "PDC requests....................%u\n",
  384. pdcs->pdc_requests);
  385. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  386. "PDC responses...................%u\n",
  387. pdcs->pdc_replies);
  388. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  389. "Tx not done.....................%u\n",
  390. pdcs->last_tx_not_done);
  391. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  392. "Tx ring full....................%u\n",
  393. pdcs->tx_ring_full);
  394. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  395. "Rx ring full....................%u\n",
  396. pdcs->rx_ring_full);
  397. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  398. "Tx desc write fail. Ring full...%u\n",
  399. pdcs->txnobuf);
  400. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  401. "Rx desc write fail. Ring full...%u\n",
  402. pdcs->rxnobuf);
  403. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  404. "Receive overflow................%u\n",
  405. pdcs->rx_oflow);
  406. out_offset += snprintf(buf + out_offset, out_count - out_offset,
  407. "Num frags in rx ring............%u\n",
  408. NRXDACTIVE(pdcs->rxin, pdcs->last_rx_curr,
  409. pdcs->nrxpost));
  410. if (out_offset > out_count)
  411. out_offset = out_count;
  412. ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);
  413. kfree(buf);
  414. return ret;
  415. }
  416. static const struct file_operations pdc_debugfs_stats = {
  417. .owner = THIS_MODULE,
  418. .open = simple_open,
  419. .read = pdc_debugfs_read,
  420. };
  421. /**
  422. * pdc_setup_debugfs() - Create the debug FS directories. If the top-level
  423. * directory has not yet been created, create it now. Create a stats file in
  424. * this directory for a SPU.
  425. * @pdcs: PDC state structure
  426. */
  427. static void pdc_setup_debugfs(struct pdc_state *pdcs)
  428. {
  429. char spu_stats_name[16];
  430. if (!debugfs_initialized())
  431. return;
  432. snprintf(spu_stats_name, 16, "pdc%d_stats", pdcs->pdc_idx);
  433. if (!debugfs_dir)
  434. debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
  435. /* S_IRUSR == 0400 */
  436. pdcs->debugfs_stats = debugfs_create_file(spu_stats_name, 0400,
  437. debugfs_dir, pdcs,
  438. &pdc_debugfs_stats);
  439. }
  440. static void pdc_free_debugfs(void)
  441. {
  442. debugfs_remove_recursive(debugfs_dir);
  443. debugfs_dir = NULL;
  444. }
  445. /**
  446. * pdc_build_rxd() - Build DMA descriptor to receive SPU result.
  447. * @pdcs: PDC state for SPU that will generate result
  448. * @dma_addr: DMA address of buffer that descriptor is being built for
  449. * @buf_len: Length of the receive buffer, in bytes
  450. * @flags: Flags to be stored in descriptor
  451. */
  452. static inline void
  453. pdc_build_rxd(struct pdc_state *pdcs, dma_addr_t dma_addr,
  454. u32 buf_len, u32 flags)
  455. {
  456. struct device *dev = &pdcs->pdev->dev;
  457. struct dma64dd *rxd = &pdcs->rxd_64[pdcs->rxout];
  458. dev_dbg(dev,
  459. "Writing rx descriptor for PDC %u at index %u with length %u. flags %#x\n",
  460. pdcs->pdc_idx, pdcs->rxout, buf_len, flags);
  461. rxd->addrlow = cpu_to_le32(lower_32_bits(dma_addr));
  462. rxd->addrhigh = cpu_to_le32(upper_32_bits(dma_addr));
  463. rxd->ctrl1 = cpu_to_le32(flags);
  464. rxd->ctrl2 = cpu_to_le32(buf_len);
  465. /* bump ring index and return */
  466. pdcs->rxout = NEXTRXD(pdcs->rxout, pdcs->nrxpost);
  467. }
  468. /**
  469. * pdc_build_txd() - Build a DMA descriptor to transmit a SPU request to
  470. * hardware.
  471. * @pdcs: PDC state for the SPU that will process this request
  472. * @dma_addr: DMA address of packet to be transmitted
  473. * @buf_len: Length of tx buffer, in bytes
  474. * @flags: Flags to be stored in descriptor
  475. */
  476. static inline void
  477. pdc_build_txd(struct pdc_state *pdcs, dma_addr_t dma_addr, u32 buf_len,
  478. u32 flags)
  479. {
  480. struct device *dev = &pdcs->pdev->dev;
  481. struct dma64dd *txd = &pdcs->txd_64[pdcs->txout];
  482. dev_dbg(dev,
  483. "Writing tx descriptor for PDC %u at index %u with length %u, flags %#x\n",
  484. pdcs->pdc_idx, pdcs->txout, buf_len, flags);
  485. txd->addrlow = cpu_to_le32(lower_32_bits(dma_addr));
  486. txd->addrhigh = cpu_to_le32(upper_32_bits(dma_addr));
  487. txd->ctrl1 = cpu_to_le32(flags);
  488. txd->ctrl2 = cpu_to_le32(buf_len);
  489. /* bump ring index and return */
  490. pdcs->txout = NEXTTXD(pdcs->txout, pdcs->ntxpost);
  491. }
  492. /**
  493. * pdc_receive_one() - Receive a response message from a given SPU.
  494. * @pdcs: PDC state for the SPU to receive from
  495. *
  496. * When the return code indicates success, the response message is available in
  497. * the receive buffers provided prior to submission of the request.
  498. *
  499. * Return: PDC_SUCCESS if one or more receive descriptors was processed
  500. * -EAGAIN indicates that no response message is available
  501. * -EIO an error occurred
  502. */
  503. static int
  504. pdc_receive_one(struct pdc_state *pdcs)
  505. {
  506. struct device *dev = &pdcs->pdev->dev;
  507. struct mbox_controller *mbc;
  508. struct mbox_chan *chan;
  509. struct brcm_message mssg;
  510. u32 len, rx_status;
  511. u32 num_frags;
  512. u8 *resp_hdr; /* virtual addr of start of resp message DMA header */
  513. u32 frags_rdy; /* number of fragments ready to read */
  514. u32 rx_idx; /* ring index of start of receive frame */
  515. dma_addr_t resp_hdr_daddr;
  516. struct pdc_rx_ctx *rx_ctx;
  517. mbc = &pdcs->mbc;
  518. chan = &mbc->chans[0];
  519. mssg.type = BRCM_MESSAGE_SPU;
  520. /*
  521. * return if a complete response message is not yet ready.
  522. * rxin_numd[rxin] is the number of fragments in the next msg
  523. * to read.
  524. */
  525. frags_rdy = NRXDACTIVE(pdcs->rxin, pdcs->last_rx_curr, pdcs->nrxpost);
  526. if ((frags_rdy == 0) ||
  527. (frags_rdy < pdcs->rx_ctx[pdcs->rxin].rxin_numd))
  528. /* No response ready */
  529. return -EAGAIN;
  530. num_frags = pdcs->txin_numd[pdcs->txin];
  531. WARN_ON(num_frags == 0);
  532. dma_unmap_sg(dev, pdcs->src_sg[pdcs->txin],
  533. sg_nents(pdcs->src_sg[pdcs->txin]), DMA_TO_DEVICE);
  534. pdcs->txin = (pdcs->txin + num_frags) & pdcs->ntxpost;
  535. dev_dbg(dev, "PDC %u reclaimed %d tx descriptors",
  536. pdcs->pdc_idx, num_frags);
  537. rx_idx = pdcs->rxin;
  538. rx_ctx = &pdcs->rx_ctx[rx_idx];
  539. num_frags = rx_ctx->rxin_numd;
  540. /* Return opaque context with result */
  541. mssg.ctx = rx_ctx->rxp_ctx;
  542. rx_ctx->rxp_ctx = NULL;
  543. resp_hdr = rx_ctx->resp_hdr;
  544. resp_hdr_daddr = rx_ctx->resp_hdr_daddr;
  545. dma_unmap_sg(dev, rx_ctx->dst_sg, sg_nents(rx_ctx->dst_sg),
  546. DMA_FROM_DEVICE);
  547. pdcs->rxin = (pdcs->rxin + num_frags) & pdcs->nrxpost;
  548. dev_dbg(dev, "PDC %u reclaimed %d rx descriptors",
  549. pdcs->pdc_idx, num_frags);
  550. dev_dbg(dev,
  551. "PDC %u txin %u, txout %u, rxin %u, rxout %u, last_rx_curr %u\n",
  552. pdcs->pdc_idx, pdcs->txin, pdcs->txout, pdcs->rxin,
  553. pdcs->rxout, pdcs->last_rx_curr);
  554. if (pdcs->pdc_resp_hdr_len == PDC_SPUM_RESP_HDR_LEN) {
  555. /*
  556. * For SPU-M, get length of response msg and rx overflow status.
  557. */
  558. rx_status = *((u32 *)resp_hdr);
  559. len = rx_status & RX_STATUS_LEN;
  560. dev_dbg(dev,
  561. "SPU response length %u bytes", len);
  562. if (unlikely(((rx_status & RX_STATUS_OVERFLOW) || (!len)))) {
  563. if (rx_status & RX_STATUS_OVERFLOW) {
  564. dev_err_ratelimited(dev,
  565. "crypto receive overflow");
  566. pdcs->rx_oflow++;
  567. } else {
  568. dev_info_ratelimited(dev, "crypto rx len = 0");
  569. }
  570. return -EIO;
  571. }
  572. }
  573. dma_pool_free(pdcs->rx_buf_pool, resp_hdr, resp_hdr_daddr);
  574. mbox_chan_received_data(chan, &mssg);
  575. pdcs->pdc_replies++;
  576. return PDC_SUCCESS;
  577. }
  578. /**
  579. * pdc_receive() - Process as many responses as are available in the rx ring.
  580. * @pdcs: PDC state
  581. *
  582. * Called within the hard IRQ.
  583. * Return:
  584. */
  585. static int
  586. pdc_receive(struct pdc_state *pdcs)
  587. {
  588. int rx_status;
  589. /* read last_rx_curr from register once */
  590. pdcs->last_rx_curr =
  591. (ioread32(&pdcs->rxregs_64->status0) &
  592. CRYPTO_D64_RS0_CD_MASK) / RING_ENTRY_SIZE;
  593. do {
  594. /* Could be many frames ready */
  595. rx_status = pdc_receive_one(pdcs);
  596. } while (rx_status == PDC_SUCCESS);
  597. return 0;
  598. }
  599. /**
  600. * pdc_tx_list_sg_add() - Add the buffers in a scatterlist to the transmit
  601. * descriptors for a given SPU. The scatterlist buffers contain the data for a
  602. * SPU request message.
  603. * @spu_idx: The index of the SPU to submit the request to, [0, max_spu)
  604. * @sg: Scatterlist whose buffers contain part of the SPU request
  605. *
  606. * If a scatterlist buffer is larger than PDC_DMA_BUF_MAX, multiple descriptors
  607. * are written for that buffer, each <= PDC_DMA_BUF_MAX byte in length.
  608. *
  609. * Return: PDC_SUCCESS if successful
  610. * < 0 otherwise
  611. */
  612. static int pdc_tx_list_sg_add(struct pdc_state *pdcs, struct scatterlist *sg)
  613. {
  614. u32 flags = 0;
  615. u32 eot;
  616. u32 tx_avail;
  617. /*
  618. * Num descriptors needed. Conservatively assume we need a descriptor
  619. * for every entry in sg.
  620. */
  621. u32 num_desc;
  622. u32 desc_w = 0; /* Number of tx descriptors written */
  623. u32 bufcnt; /* Number of bytes of buffer pointed to by descriptor */
  624. dma_addr_t databufptr; /* DMA address to put in descriptor */
  625. num_desc = (u32)sg_nents(sg);
  626. /* check whether enough tx descriptors are available */
  627. tx_avail = pdcs->ntxpost - NTXDACTIVE(pdcs->txin, pdcs->txout,
  628. pdcs->ntxpost);
  629. if (unlikely(num_desc > tx_avail)) {
  630. pdcs->txnobuf++;
  631. return -ENOSPC;
  632. }
  633. /* build tx descriptors */
  634. if (pdcs->tx_msg_start == pdcs->txout) {
  635. /* Start of frame */
  636. pdcs->txin_numd[pdcs->tx_msg_start] = 0;
  637. pdcs->src_sg[pdcs->txout] = sg;
  638. flags = D64_CTRL1_SOF;
  639. }
  640. while (sg) {
  641. if (unlikely(pdcs->txout == (pdcs->ntxd - 1)))
  642. eot = D64_CTRL1_EOT;
  643. else
  644. eot = 0;
  645. /*
  646. * If sg buffer larger than PDC limit, split across
  647. * multiple descriptors
  648. */
  649. bufcnt = sg_dma_len(sg);
  650. databufptr = sg_dma_address(sg);
  651. while (bufcnt > PDC_DMA_BUF_MAX) {
  652. pdc_build_txd(pdcs, databufptr, PDC_DMA_BUF_MAX,
  653. flags | eot);
  654. desc_w++;
  655. bufcnt -= PDC_DMA_BUF_MAX;
  656. databufptr += PDC_DMA_BUF_MAX;
  657. if (unlikely(pdcs->txout == (pdcs->ntxd - 1)))
  658. eot = D64_CTRL1_EOT;
  659. else
  660. eot = 0;
  661. }
  662. sg = sg_next(sg);
  663. if (!sg)
  664. /* Writing last descriptor for frame */
  665. flags |= (D64_CTRL1_EOF | D64_CTRL1_IOC);
  666. pdc_build_txd(pdcs, databufptr, bufcnt, flags | eot);
  667. desc_w++;
  668. /* Clear start of frame after first descriptor */
  669. flags &= ~D64_CTRL1_SOF;
  670. }
  671. pdcs->txin_numd[pdcs->tx_msg_start] += desc_w;
  672. return PDC_SUCCESS;
  673. }
  674. /**
  675. * pdc_tx_list_final() - Initiate DMA transfer of last frame written to tx
  676. * ring.
  677. * @pdcs: PDC state for SPU to process the request
  678. *
  679. * Sets the index of the last descriptor written in both the rx and tx ring.
  680. *
  681. * Return: PDC_SUCCESS
  682. */
  683. static int pdc_tx_list_final(struct pdc_state *pdcs)
  684. {
  685. /*
  686. * write barrier to ensure all register writes are complete
  687. * before chip starts to process new request
  688. */
  689. wmb();
  690. iowrite32(pdcs->rxout << 4, &pdcs->rxregs_64->ptr);
  691. iowrite32(pdcs->txout << 4, &pdcs->txregs_64->ptr);
  692. pdcs->pdc_requests++;
  693. return PDC_SUCCESS;
  694. }
  695. /**
  696. * pdc_rx_list_init() - Start a new receive descriptor list for a given PDC.
  697. * @pdcs: PDC state for SPU handling request
  698. * @dst_sg: scatterlist providing rx buffers for response to be returned to
  699. * mailbox client
  700. * @ctx: Opaque context for this request
  701. *
  702. * Posts a single receive descriptor to hold the metadata that precedes a
  703. * response. For example, with SPU-M, the metadata is a 32-byte DMA header and
  704. * an 8-byte BCM header. Moves the msg_start descriptor indexes for both tx and
  705. * rx to indicate the start of a new message.
  706. *
  707. * Return: PDC_SUCCESS if successful
  708. * < 0 if an error (e.g., rx ring is full)
  709. */
  710. static int pdc_rx_list_init(struct pdc_state *pdcs, struct scatterlist *dst_sg,
  711. void *ctx)
  712. {
  713. u32 flags = 0;
  714. u32 rx_avail;
  715. u32 rx_pkt_cnt = 1; /* Adding a single rx buffer */
  716. dma_addr_t daddr;
  717. void *vaddr;
  718. struct pdc_rx_ctx *rx_ctx;
  719. rx_avail = pdcs->nrxpost - NRXDACTIVE(pdcs->rxin, pdcs->rxout,
  720. pdcs->nrxpost);
  721. if (unlikely(rx_pkt_cnt > rx_avail)) {
  722. pdcs->rxnobuf++;
  723. return -ENOSPC;
  724. }
  725. /* allocate a buffer for the dma rx status */
  726. vaddr = dma_pool_zalloc(pdcs->rx_buf_pool, GFP_ATOMIC, &daddr);
  727. if (unlikely(!vaddr))
  728. return -ENOMEM;
  729. /*
  730. * Update msg_start indexes for both tx and rx to indicate the start
  731. * of a new sequence of descriptor indexes that contain the fragments
  732. * of the same message.
  733. */
  734. pdcs->rx_msg_start = pdcs->rxout;
  735. pdcs->tx_msg_start = pdcs->txout;
  736. /* This is always the first descriptor in the receive sequence */
  737. flags = D64_CTRL1_SOF;
  738. pdcs->rx_ctx[pdcs->rx_msg_start].rxin_numd = 1;
  739. if (unlikely(pdcs->rxout == (pdcs->nrxd - 1)))
  740. flags |= D64_CTRL1_EOT;
  741. rx_ctx = &pdcs->rx_ctx[pdcs->rxout];
  742. rx_ctx->rxp_ctx = ctx;
  743. rx_ctx->dst_sg = dst_sg;
  744. rx_ctx->resp_hdr = vaddr;
  745. rx_ctx->resp_hdr_daddr = daddr;
  746. pdc_build_rxd(pdcs, daddr, pdcs->pdc_resp_hdr_len, flags);
  747. return PDC_SUCCESS;
  748. }
  749. /**
  750. * pdc_rx_list_sg_add() - Add the buffers in a scatterlist to the receive
  751. * descriptors for a given SPU. The caller must have already DMA mapped the
  752. * scatterlist.
  753. * @spu_idx: Indicates which SPU the buffers are for
  754. * @sg: Scatterlist whose buffers are added to the receive ring
  755. *
  756. * If a receive buffer in the scatterlist is larger than PDC_DMA_BUF_MAX,
  757. * multiple receive descriptors are written, each with a buffer <=
  758. * PDC_DMA_BUF_MAX.
  759. *
  760. * Return: PDC_SUCCESS if successful
  761. * < 0 otherwise (e.g., receive ring is full)
  762. */
  763. static int pdc_rx_list_sg_add(struct pdc_state *pdcs, struct scatterlist *sg)
  764. {
  765. u32 flags = 0;
  766. u32 rx_avail;
  767. /*
  768. * Num descriptors needed. Conservatively assume we need a descriptor
  769. * for every entry from our starting point in the scatterlist.
  770. */
  771. u32 num_desc;
  772. u32 desc_w = 0; /* Number of tx descriptors written */
  773. u32 bufcnt; /* Number of bytes of buffer pointed to by descriptor */
  774. dma_addr_t databufptr; /* DMA address to put in descriptor */
  775. num_desc = (u32)sg_nents(sg);
  776. rx_avail = pdcs->nrxpost - NRXDACTIVE(pdcs->rxin, pdcs->rxout,
  777. pdcs->nrxpost);
  778. if (unlikely(num_desc > rx_avail)) {
  779. pdcs->rxnobuf++;
  780. return -ENOSPC;
  781. }
  782. while (sg) {
  783. if (unlikely(pdcs->rxout == (pdcs->nrxd - 1)))
  784. flags = D64_CTRL1_EOT;
  785. else
  786. flags = 0;
  787. /*
  788. * If sg buffer larger than PDC limit, split across
  789. * multiple descriptors
  790. */
  791. bufcnt = sg_dma_len(sg);
  792. databufptr = sg_dma_address(sg);
  793. while (bufcnt > PDC_DMA_BUF_MAX) {
  794. pdc_build_rxd(pdcs, databufptr, PDC_DMA_BUF_MAX, flags);
  795. desc_w++;
  796. bufcnt -= PDC_DMA_BUF_MAX;
  797. databufptr += PDC_DMA_BUF_MAX;
  798. if (unlikely(pdcs->rxout == (pdcs->nrxd - 1)))
  799. flags = D64_CTRL1_EOT;
  800. else
  801. flags = 0;
  802. }
  803. pdc_build_rxd(pdcs, databufptr, bufcnt, flags);
  804. desc_w++;
  805. sg = sg_next(sg);
  806. }
  807. pdcs->rx_ctx[pdcs->rx_msg_start].rxin_numd += desc_w;
  808. return PDC_SUCCESS;
  809. }
  810. /**
  811. * pdc_irq_handler() - Interrupt handler called in interrupt context.
  812. * @irq: Interrupt number that has fired
  813. * @data: device struct for DMA engine that generated the interrupt
  814. *
  815. * We have to clear the device interrupt status flags here. So cache the
  816. * status for later use in the thread function. Other than that, just return
  817. * WAKE_THREAD to invoke the thread function.
  818. *
  819. * Return: IRQ_WAKE_THREAD if interrupt is ours
  820. * IRQ_NONE otherwise
  821. */
  822. static irqreturn_t pdc_irq_handler(int irq, void *data)
  823. {
  824. struct device *dev = (struct device *)data;
  825. struct pdc_state *pdcs = dev_get_drvdata(dev);
  826. u32 intstatus = ioread32(pdcs->pdc_reg_vbase + PDC_INTSTATUS_OFFSET);
  827. if (unlikely(intstatus == 0))
  828. return IRQ_NONE;
  829. /* Disable interrupts until soft handler runs */
  830. iowrite32(0, pdcs->pdc_reg_vbase + PDC_INTMASK_OFFSET);
  831. /* Clear interrupt flags in device */
  832. iowrite32(intstatus, pdcs->pdc_reg_vbase + PDC_INTSTATUS_OFFSET);
  833. /* Wakeup IRQ thread */
  834. tasklet_schedule(&pdcs->rx_tasklet);
  835. return IRQ_HANDLED;
  836. }
  837. /**
  838. * pdc_tasklet_cb() - Tasklet callback that runs the deferred processing after
  839. * a DMA receive interrupt. Reenables the receive interrupt.
  840. * @data: PDC state structure
  841. */
  842. static void pdc_tasklet_cb(unsigned long data)
  843. {
  844. struct pdc_state *pdcs = (struct pdc_state *)data;
  845. pdc_receive(pdcs);
  846. /* reenable interrupts */
  847. iowrite32(PDC_INTMASK, pdcs->pdc_reg_vbase + PDC_INTMASK_OFFSET);
  848. }
  849. /**
  850. * pdc_ring_init() - Allocate DMA rings and initialize constant fields of
  851. * descriptors in one ringset.
  852. * @pdcs: PDC instance state
  853. * @ringset: index of ringset being used
  854. *
  855. * Return: PDC_SUCCESS if ring initialized
  856. * < 0 otherwise
  857. */
  858. static int pdc_ring_init(struct pdc_state *pdcs, int ringset)
  859. {
  860. int i;
  861. int err = PDC_SUCCESS;
  862. struct dma64 *dma_reg;
  863. struct device *dev = &pdcs->pdev->dev;
  864. struct pdc_ring_alloc tx;
  865. struct pdc_ring_alloc rx;
  866. /* Allocate tx ring */
  867. tx.vbase = dma_pool_zalloc(pdcs->ring_pool, GFP_KERNEL, &tx.dmabase);
  868. if (unlikely(!tx.vbase)) {
  869. err = -ENOMEM;
  870. goto done;
  871. }
  872. /* Allocate rx ring */
  873. rx.vbase = dma_pool_zalloc(pdcs->ring_pool, GFP_KERNEL, &rx.dmabase);
  874. if (unlikely(!rx.vbase)) {
  875. err = -ENOMEM;
  876. goto fail_dealloc;
  877. }
  878. dev_dbg(dev, " - base DMA addr of tx ring %pad", &tx.dmabase);
  879. dev_dbg(dev, " - base virtual addr of tx ring %p", tx.vbase);
  880. dev_dbg(dev, " - base DMA addr of rx ring %pad", &rx.dmabase);
  881. dev_dbg(dev, " - base virtual addr of rx ring %p", rx.vbase);
  882. memcpy(&pdcs->tx_ring_alloc, &tx, sizeof(tx));
  883. memcpy(&pdcs->rx_ring_alloc, &rx, sizeof(rx));
  884. pdcs->rxin = 0;
  885. pdcs->rx_msg_start = 0;
  886. pdcs->last_rx_curr = 0;
  887. pdcs->rxout = 0;
  888. pdcs->txin = 0;
  889. pdcs->tx_msg_start = 0;
  890. pdcs->txout = 0;
  891. /* Set descriptor array base addresses */
  892. pdcs->txd_64 = (struct dma64dd *)pdcs->tx_ring_alloc.vbase;
  893. pdcs->rxd_64 = (struct dma64dd *)pdcs->rx_ring_alloc.vbase;
  894. /* Tell device the base DMA address of each ring */
  895. dma_reg = &pdcs->regs->dmaregs[ringset];
  896. /* But first disable DMA and set curptr to 0 for both TX & RX */
  897. iowrite32(PDC_TX_CTL, &dma_reg->dmaxmt.control);
  898. iowrite32((PDC_RX_CTL + (pdcs->rx_status_len << 1)),
  899. &dma_reg->dmarcv.control);
  900. iowrite32(0, &dma_reg->dmaxmt.ptr);
  901. iowrite32(0, &dma_reg->dmarcv.ptr);
  902. /* Set base DMA addresses */
  903. iowrite32(lower_32_bits(pdcs->tx_ring_alloc.dmabase),
  904. &dma_reg->dmaxmt.addrlow);
  905. iowrite32(upper_32_bits(pdcs->tx_ring_alloc.dmabase),
  906. &dma_reg->dmaxmt.addrhigh);
  907. iowrite32(lower_32_bits(pdcs->rx_ring_alloc.dmabase),
  908. &dma_reg->dmarcv.addrlow);
  909. iowrite32(upper_32_bits(pdcs->rx_ring_alloc.dmabase),
  910. &dma_reg->dmarcv.addrhigh);
  911. /* Re-enable DMA */
  912. iowrite32(PDC_TX_CTL | PDC_TX_ENABLE, &dma_reg->dmaxmt.control);
  913. iowrite32((PDC_RX_CTL | PDC_RX_ENABLE | (pdcs->rx_status_len << 1)),
  914. &dma_reg->dmarcv.control);
  915. /* Initialize descriptors */
  916. for (i = 0; i < PDC_RING_ENTRIES; i++) {
  917. /* Every tx descriptor can be used for start of frame. */
  918. if (i != pdcs->ntxpost) {
  919. iowrite32(D64_CTRL1_SOF | D64_CTRL1_EOF,
  920. &pdcs->txd_64[i].ctrl1);
  921. } else {
  922. /* Last descriptor in ringset. Set End of Table. */
  923. iowrite32(D64_CTRL1_SOF | D64_CTRL1_EOF |
  924. D64_CTRL1_EOT, &pdcs->txd_64[i].ctrl1);
  925. }
  926. /* Every rx descriptor can be used for start of frame */
  927. if (i != pdcs->nrxpost) {
  928. iowrite32(D64_CTRL1_SOF,
  929. &pdcs->rxd_64[i].ctrl1);
  930. } else {
  931. /* Last descriptor in ringset. Set End of Table. */
  932. iowrite32(D64_CTRL1_SOF | D64_CTRL1_EOT,
  933. &pdcs->rxd_64[i].ctrl1);
  934. }
  935. }
  936. return PDC_SUCCESS;
  937. fail_dealloc:
  938. dma_pool_free(pdcs->ring_pool, tx.vbase, tx.dmabase);
  939. done:
  940. return err;
  941. }
  942. static void pdc_ring_free(struct pdc_state *pdcs)
  943. {
  944. if (pdcs->tx_ring_alloc.vbase) {
  945. dma_pool_free(pdcs->ring_pool, pdcs->tx_ring_alloc.vbase,
  946. pdcs->tx_ring_alloc.dmabase);
  947. pdcs->tx_ring_alloc.vbase = NULL;
  948. }
  949. if (pdcs->rx_ring_alloc.vbase) {
  950. dma_pool_free(pdcs->ring_pool, pdcs->rx_ring_alloc.vbase,
  951. pdcs->rx_ring_alloc.dmabase);
  952. pdcs->rx_ring_alloc.vbase = NULL;
  953. }
  954. }
  955. /**
  956. * pdc_desc_count() - Count the number of DMA descriptors that will be required
  957. * for a given scatterlist. Account for the max length of a DMA buffer.
  958. * @sg: Scatterlist to be DMA'd
  959. * Return: Number of descriptors required
  960. */
  961. static u32 pdc_desc_count(struct scatterlist *sg)
  962. {
  963. u32 cnt = 0;
  964. while (sg) {
  965. cnt += ((sg->length / PDC_DMA_BUF_MAX) + 1);
  966. sg = sg_next(sg);
  967. }
  968. return cnt;
  969. }
  970. /**
  971. * pdc_rings_full() - Check whether the tx ring has room for tx_cnt descriptors
  972. * and the rx ring has room for rx_cnt descriptors.
  973. * @pdcs: PDC state
  974. * @tx_cnt: The number of descriptors required in the tx ring
  975. * @rx_cnt: The number of descriptors required i the rx ring
  976. *
  977. * Return: true if one of the rings does not have enough space
  978. * false if sufficient space is available in both rings
  979. */
  980. static bool pdc_rings_full(struct pdc_state *pdcs, int tx_cnt, int rx_cnt)
  981. {
  982. u32 rx_avail;
  983. u32 tx_avail;
  984. bool full = false;
  985. /* Check if the tx and rx rings are likely to have enough space */
  986. rx_avail = pdcs->nrxpost - NRXDACTIVE(pdcs->rxin, pdcs->rxout,
  987. pdcs->nrxpost);
  988. if (unlikely(rx_cnt > rx_avail)) {
  989. pdcs->rx_ring_full++;
  990. full = true;
  991. }
  992. if (likely(!full)) {
  993. tx_avail = pdcs->ntxpost - NTXDACTIVE(pdcs->txin, pdcs->txout,
  994. pdcs->ntxpost);
  995. if (unlikely(tx_cnt > tx_avail)) {
  996. pdcs->tx_ring_full++;
  997. full = true;
  998. }
  999. }
  1000. return full;
  1001. }
  1002. /**
  1003. * pdc_last_tx_done() - If both the tx and rx rings have at least
  1004. * PDC_RING_SPACE_MIN descriptors available, then indicate that the mailbox
  1005. * framework can submit another message.
  1006. * @chan: mailbox channel to check
  1007. * Return: true if PDC can accept another message on this channel
  1008. */
  1009. static bool pdc_last_tx_done(struct mbox_chan *chan)
  1010. {
  1011. struct pdc_state *pdcs = chan->con_priv;
  1012. bool ret;
  1013. if (unlikely(pdc_rings_full(pdcs, PDC_RING_SPACE_MIN,
  1014. PDC_RING_SPACE_MIN))) {
  1015. pdcs->last_tx_not_done++;
  1016. ret = false;
  1017. } else {
  1018. ret = true;
  1019. }
  1020. return ret;
  1021. }
  1022. /**
  1023. * pdc_send_data() - mailbox send_data function
  1024. * @chan: The mailbox channel on which the data is sent. The channel
  1025. * corresponds to a DMA ringset.
  1026. * @data: The mailbox message to be sent. The message must be a
  1027. * brcm_message structure.
  1028. *
  1029. * This function is registered as the send_data function for the mailbox
  1030. * controller. From the destination scatterlist in the mailbox message, it
  1031. * creates a sequence of receive descriptors in the rx ring. From the source
  1032. * scatterlist, it creates a sequence of transmit descriptors in the tx ring.
  1033. * After creating the descriptors, it writes the rx ptr and tx ptr registers to
  1034. * initiate the DMA transfer.
  1035. *
  1036. * This function does the DMA map and unmap of the src and dst scatterlists in
  1037. * the mailbox message.
  1038. *
  1039. * Return: 0 if successful
  1040. * -ENOTSUPP if the mailbox message is a type this driver does not
  1041. * support
  1042. * < 0 if an error
  1043. */
  1044. static int pdc_send_data(struct mbox_chan *chan, void *data)
  1045. {
  1046. struct pdc_state *pdcs = chan->con_priv;
  1047. struct device *dev = &pdcs->pdev->dev;
  1048. struct brcm_message *mssg = data;
  1049. int err = PDC_SUCCESS;
  1050. int src_nent;
  1051. int dst_nent;
  1052. int nent;
  1053. u32 tx_desc_req;
  1054. u32 rx_desc_req;
  1055. if (unlikely(mssg->type != BRCM_MESSAGE_SPU))
  1056. return -ENOTSUPP;
  1057. src_nent = sg_nents(mssg->spu.src);
  1058. if (likely(src_nent)) {
  1059. nent = dma_map_sg(dev, mssg->spu.src, src_nent, DMA_TO_DEVICE);
  1060. if (unlikely(nent == 0))
  1061. return -EIO;
  1062. }
  1063. dst_nent = sg_nents(mssg->spu.dst);
  1064. if (likely(dst_nent)) {
  1065. nent = dma_map_sg(dev, mssg->spu.dst, dst_nent,
  1066. DMA_FROM_DEVICE);
  1067. if (unlikely(nent == 0)) {
  1068. dma_unmap_sg(dev, mssg->spu.src, src_nent,
  1069. DMA_TO_DEVICE);
  1070. return -EIO;
  1071. }
  1072. }
  1073. /*
  1074. * Check if the tx and rx rings have enough space. Do this prior to
  1075. * writing any tx or rx descriptors. Need to ensure that we do not write
  1076. * a partial set of descriptors, or write just rx descriptors but
  1077. * corresponding tx descriptors don't fit. Note that we want this check
  1078. * and the entire sequence of descriptor to happen without another
  1079. * thread getting in. The channel spin lock in the mailbox framework
  1080. * ensures this.
  1081. */
  1082. tx_desc_req = pdc_desc_count(mssg->spu.src);
  1083. rx_desc_req = pdc_desc_count(mssg->spu.dst);
  1084. if (unlikely(pdc_rings_full(pdcs, tx_desc_req, rx_desc_req + 1)))
  1085. return -ENOSPC;
  1086. /* Create rx descriptors to SPU catch response */
  1087. err = pdc_rx_list_init(pdcs, mssg->spu.dst, mssg->ctx);
  1088. err |= pdc_rx_list_sg_add(pdcs, mssg->spu.dst);
  1089. /* Create tx descriptors to submit SPU request */
  1090. err |= pdc_tx_list_sg_add(pdcs, mssg->spu.src);
  1091. err |= pdc_tx_list_final(pdcs); /* initiate transfer */
  1092. if (unlikely(err))
  1093. dev_err(&pdcs->pdev->dev,
  1094. "%s failed with error %d", __func__, err);
  1095. return err;
  1096. }
  1097. static int pdc_startup(struct mbox_chan *chan)
  1098. {
  1099. return pdc_ring_init(chan->con_priv, PDC_RINGSET);
  1100. }
  1101. static void pdc_shutdown(struct mbox_chan *chan)
  1102. {
  1103. struct pdc_state *pdcs = chan->con_priv;
  1104. if (!pdcs)
  1105. return;
  1106. dev_dbg(&pdcs->pdev->dev,
  1107. "Shutdown mailbox channel for PDC %u", pdcs->pdc_idx);
  1108. pdc_ring_free(pdcs);
  1109. }
  1110. /**
  1111. * pdc_hw_init() - Use the given initialization parameters to initialize the
  1112. * state for one of the PDCs.
  1113. * @pdcs: state of the PDC
  1114. */
  1115. static
  1116. void pdc_hw_init(struct pdc_state *pdcs)
  1117. {
  1118. struct platform_device *pdev;
  1119. struct device *dev;
  1120. struct dma64 *dma_reg;
  1121. int ringset = PDC_RINGSET;
  1122. pdev = pdcs->pdev;
  1123. dev = &pdev->dev;
  1124. dev_dbg(dev, "PDC %u initial values:", pdcs->pdc_idx);
  1125. dev_dbg(dev, "state structure: %p",
  1126. pdcs);
  1127. dev_dbg(dev, " - base virtual addr of hw regs %p",
  1128. pdcs->pdc_reg_vbase);
  1129. /* initialize data structures */
  1130. pdcs->regs = (struct pdc_regs *)pdcs->pdc_reg_vbase;
  1131. pdcs->txregs_64 = (struct dma64_regs *)
  1132. (((u8 *)pdcs->pdc_reg_vbase) +
  1133. PDC_TXREGS_OFFSET + (sizeof(struct dma64) * ringset));
  1134. pdcs->rxregs_64 = (struct dma64_regs *)
  1135. (((u8 *)pdcs->pdc_reg_vbase) +
  1136. PDC_RXREGS_OFFSET + (sizeof(struct dma64) * ringset));
  1137. pdcs->ntxd = PDC_RING_ENTRIES;
  1138. pdcs->nrxd = PDC_RING_ENTRIES;
  1139. pdcs->ntxpost = PDC_RING_ENTRIES - 1;
  1140. pdcs->nrxpost = PDC_RING_ENTRIES - 1;
  1141. iowrite32(0, &pdcs->regs->intmask);
  1142. dma_reg = &pdcs->regs->dmaregs[ringset];
  1143. /* Configure DMA but will enable later in pdc_ring_init() */
  1144. iowrite32(PDC_TX_CTL, &dma_reg->dmaxmt.control);
  1145. iowrite32(PDC_RX_CTL + (pdcs->rx_status_len << 1),
  1146. &dma_reg->dmarcv.control);
  1147. /* Reset current index pointers after making sure DMA is disabled */
  1148. iowrite32(0, &dma_reg->dmaxmt.ptr);
  1149. iowrite32(0, &dma_reg->dmarcv.ptr);
  1150. if (pdcs->pdc_resp_hdr_len == PDC_SPU2_RESP_HDR_LEN)
  1151. iowrite32(PDC_CKSUM_CTRL,
  1152. pdcs->pdc_reg_vbase + PDC_CKSUM_CTRL_OFFSET);
  1153. }
  1154. /**
  1155. * pdc_hw_disable() - Disable the tx and rx control in the hw.
  1156. * @pdcs: PDC state structure
  1157. *
  1158. */
  1159. static void pdc_hw_disable(struct pdc_state *pdcs)
  1160. {
  1161. struct dma64 *dma_reg;
  1162. dma_reg = &pdcs->regs->dmaregs[PDC_RINGSET];
  1163. iowrite32(PDC_TX_CTL, &dma_reg->dmaxmt.control);
  1164. iowrite32(PDC_RX_CTL + (pdcs->rx_status_len << 1),
  1165. &dma_reg->dmarcv.control);
  1166. }
  1167. /**
  1168. * pdc_rx_buf_pool_create() - Pool of receive buffers used to catch the metadata
  1169. * header returned with each response message.
  1170. * @pdcs: PDC state structure
  1171. *
  1172. * The metadata is not returned to the mailbox client. So the PDC driver
  1173. * manages these buffers.
  1174. *
  1175. * Return: PDC_SUCCESS
  1176. * -ENOMEM if pool creation fails
  1177. */
  1178. static int pdc_rx_buf_pool_create(struct pdc_state *pdcs)
  1179. {
  1180. struct platform_device *pdev;
  1181. struct device *dev;
  1182. pdev = pdcs->pdev;
  1183. dev = &pdev->dev;
  1184. pdcs->pdc_resp_hdr_len = pdcs->rx_status_len;
  1185. if (pdcs->use_bcm_hdr)
  1186. pdcs->pdc_resp_hdr_len += BCM_HDR_LEN;
  1187. pdcs->rx_buf_pool = dma_pool_create("pdc rx bufs", dev,
  1188. pdcs->pdc_resp_hdr_len,
  1189. RX_BUF_ALIGN, 0);
  1190. if (!pdcs->rx_buf_pool)
  1191. return -ENOMEM;
  1192. return PDC_SUCCESS;
  1193. }
  1194. /**
  1195. * pdc_interrupts_init() - Initialize the interrupt configuration for a PDC and
  1196. * specify a threaded IRQ handler for deferred handling of interrupts outside of
  1197. * interrupt context.
  1198. * @pdcs: PDC state
  1199. *
  1200. * Set the interrupt mask for transmit and receive done.
  1201. * Set the lazy interrupt frame count to generate an interrupt for just one pkt.
  1202. *
  1203. * Return: PDC_SUCCESS
  1204. * <0 if threaded irq request fails
  1205. */
  1206. static int pdc_interrupts_init(struct pdc_state *pdcs)
  1207. {
  1208. struct platform_device *pdev = pdcs->pdev;
  1209. struct device *dev = &pdev->dev;
  1210. struct device_node *dn = pdev->dev.of_node;
  1211. int err;
  1212. /* interrupt configuration */
  1213. iowrite32(PDC_INTMASK, pdcs->pdc_reg_vbase + PDC_INTMASK_OFFSET);
  1214. if (pdcs->hw_type == FA_HW)
  1215. iowrite32(PDC_LAZY_INT, pdcs->pdc_reg_vbase +
  1216. FA_RCVLAZY0_OFFSET);
  1217. else
  1218. iowrite32(PDC_LAZY_INT, pdcs->pdc_reg_vbase +
  1219. PDC_RCVLAZY0_OFFSET);
  1220. /* read irq from device tree */
  1221. pdcs->pdc_irq = irq_of_parse_and_map(dn, 0);
  1222. dev_dbg(dev, "pdc device %s irq %u for pdcs %p",
  1223. dev_name(dev), pdcs->pdc_irq, pdcs);
  1224. err = devm_request_irq(dev, pdcs->pdc_irq, pdc_irq_handler, 0,
  1225. dev_name(dev), dev);
  1226. if (err) {
  1227. dev_err(dev, "IRQ %u request failed with err %d\n",
  1228. pdcs->pdc_irq, err);
  1229. return err;
  1230. }
  1231. return PDC_SUCCESS;
  1232. }
  1233. static const struct mbox_chan_ops pdc_mbox_chan_ops = {
  1234. .send_data = pdc_send_data,
  1235. .last_tx_done = pdc_last_tx_done,
  1236. .startup = pdc_startup,
  1237. .shutdown = pdc_shutdown
  1238. };
  1239. /**
  1240. * pdc_mb_init() - Initialize the mailbox controller.
  1241. * @pdcs: PDC state
  1242. *
  1243. * Each PDC is a mailbox controller. Each ringset is a mailbox channel. Kernel
  1244. * driver only uses one ringset and thus one mb channel. PDC uses the transmit
  1245. * complete interrupt to determine when a mailbox message has successfully been
  1246. * transmitted.
  1247. *
  1248. * Return: 0 on success
  1249. * < 0 if there is an allocation or registration failure
  1250. */
  1251. static int pdc_mb_init(struct pdc_state *pdcs)
  1252. {
  1253. struct device *dev = &pdcs->pdev->dev;
  1254. struct mbox_controller *mbc;
  1255. int chan_index;
  1256. int err;
  1257. mbc = &pdcs->mbc;
  1258. mbc->dev = dev;
  1259. mbc->ops = &pdc_mbox_chan_ops;
  1260. mbc->num_chans = 1;
  1261. mbc->chans = devm_kcalloc(dev, mbc->num_chans, sizeof(*mbc->chans),
  1262. GFP_KERNEL);
  1263. if (!mbc->chans)
  1264. return -ENOMEM;
  1265. mbc->txdone_irq = false;
  1266. mbc->txdone_poll = true;
  1267. mbc->txpoll_period = 1;
  1268. for (chan_index = 0; chan_index < mbc->num_chans; chan_index++)
  1269. mbc->chans[chan_index].con_priv = pdcs;
  1270. /* Register mailbox controller */
  1271. err = mbox_controller_register(mbc);
  1272. if (err) {
  1273. dev_crit(dev,
  1274. "Failed to register PDC mailbox controller. Error %d.",
  1275. err);
  1276. return err;
  1277. }
  1278. return 0;
  1279. }
  1280. /* Device tree API */
  1281. static const int pdc_hw = PDC_HW;
  1282. static const int fa_hw = FA_HW;
  1283. static const struct of_device_id pdc_mbox_of_match[] = {
  1284. {.compatible = "brcm,iproc-pdc-mbox", .data = &pdc_hw},
  1285. {.compatible = "brcm,iproc-fa2-mbox", .data = &fa_hw},
  1286. { /* sentinel */ }
  1287. };
  1288. MODULE_DEVICE_TABLE(of, pdc_mbox_of_match);
  1289. /**
  1290. * pdc_dt_read() - Read application-specific data from device tree.
  1291. * @pdev: Platform device
  1292. * @pdcs: PDC state
  1293. *
  1294. * Reads the number of bytes of receive status that precede each received frame.
  1295. * Reads whether transmit and received frames should be preceded by an 8-byte
  1296. * BCM header.
  1297. *
  1298. * Return: 0 if successful
  1299. * -ENODEV if device not available
  1300. */
  1301. static int pdc_dt_read(struct platform_device *pdev, struct pdc_state *pdcs)
  1302. {
  1303. struct device *dev = &pdev->dev;
  1304. struct device_node *dn = pdev->dev.of_node;
  1305. const struct of_device_id *match;
  1306. const int *hw_type;
  1307. int err;
  1308. err = of_property_read_u32(dn, "brcm,rx-status-len",
  1309. &pdcs->rx_status_len);
  1310. if (err < 0)
  1311. dev_err(dev,
  1312. "%s failed to get DMA receive status length from device tree",
  1313. __func__);
  1314. pdcs->use_bcm_hdr = of_property_read_bool(dn, "brcm,use-bcm-hdr");
  1315. pdcs->hw_type = PDC_HW;
  1316. match = of_match_device(of_match_ptr(pdc_mbox_of_match), dev);
  1317. if (match != NULL) {
  1318. hw_type = match->data;
  1319. pdcs->hw_type = *hw_type;
  1320. }
  1321. return 0;
  1322. }
  1323. /**
  1324. * pdc_probe() - Probe function for PDC driver.
  1325. * @pdev: PDC platform device
  1326. *
  1327. * Reserve and map register regions defined in device tree.
  1328. * Allocate and initialize tx and rx DMA rings.
  1329. * Initialize a mailbox controller for each PDC.
  1330. *
  1331. * Return: 0 if successful
  1332. * < 0 if an error
  1333. */
  1334. static int pdc_probe(struct platform_device *pdev)
  1335. {
  1336. int err = 0;
  1337. struct device *dev = &pdev->dev;
  1338. struct resource *pdc_regs;
  1339. struct pdc_state *pdcs;
  1340. /* PDC state for one SPU */
  1341. pdcs = devm_kzalloc(dev, sizeof(*pdcs), GFP_KERNEL);
  1342. if (!pdcs) {
  1343. err = -ENOMEM;
  1344. goto cleanup;
  1345. }
  1346. pdcs->pdev = pdev;
  1347. platform_set_drvdata(pdev, pdcs);
  1348. pdcs->pdc_idx = pdcg.num_spu;
  1349. pdcg.num_spu++;
  1350. err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(39));
  1351. if (err) {
  1352. dev_warn(dev, "PDC device cannot perform DMA. Error %d.", err);
  1353. goto cleanup;
  1354. }
  1355. /* Create DMA pool for tx ring */
  1356. pdcs->ring_pool = dma_pool_create("pdc rings", dev, PDC_RING_SIZE,
  1357. RING_ALIGN, 0);
  1358. if (!pdcs->ring_pool) {
  1359. err = -ENOMEM;
  1360. goto cleanup;
  1361. }
  1362. err = pdc_dt_read(pdev, pdcs);
  1363. if (err)
  1364. goto cleanup_ring_pool;
  1365. pdc_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1366. if (!pdc_regs) {
  1367. err = -ENODEV;
  1368. goto cleanup_ring_pool;
  1369. }
  1370. dev_dbg(dev, "PDC register region res.start = %pa, res.end = %pa",
  1371. &pdc_regs->start, &pdc_regs->end);
  1372. pdcs->pdc_reg_vbase = devm_ioremap_resource(&pdev->dev, pdc_regs);
  1373. if (IS_ERR(pdcs->pdc_reg_vbase)) {
  1374. err = PTR_ERR(pdcs->pdc_reg_vbase);
  1375. dev_err(&pdev->dev, "Failed to map registers: %d\n", err);
  1376. goto cleanup_ring_pool;
  1377. }
  1378. /* create rx buffer pool after dt read to know how big buffers are */
  1379. err = pdc_rx_buf_pool_create(pdcs);
  1380. if (err)
  1381. goto cleanup_ring_pool;
  1382. pdc_hw_init(pdcs);
  1383. /* Init tasklet for deferred DMA rx processing */
  1384. tasklet_init(&pdcs->rx_tasklet, pdc_tasklet_cb, (unsigned long)pdcs);
  1385. err = pdc_interrupts_init(pdcs);
  1386. if (err)
  1387. goto cleanup_buf_pool;
  1388. /* Initialize mailbox controller */
  1389. err = pdc_mb_init(pdcs);
  1390. if (err)
  1391. goto cleanup_buf_pool;
  1392. pdcs->debugfs_stats = NULL;
  1393. pdc_setup_debugfs(pdcs);
  1394. dev_dbg(dev, "pdc_probe() successful");
  1395. return PDC_SUCCESS;
  1396. cleanup_buf_pool:
  1397. tasklet_kill(&pdcs->rx_tasklet);
  1398. dma_pool_destroy(pdcs->rx_buf_pool);
  1399. cleanup_ring_pool:
  1400. dma_pool_destroy(pdcs->ring_pool);
  1401. cleanup:
  1402. return err;
  1403. }
  1404. static int pdc_remove(struct platform_device *pdev)
  1405. {
  1406. struct pdc_state *pdcs = platform_get_drvdata(pdev);
  1407. pdc_free_debugfs();
  1408. tasklet_kill(&pdcs->rx_tasklet);
  1409. pdc_hw_disable(pdcs);
  1410. mbox_controller_unregister(&pdcs->mbc);
  1411. dma_pool_destroy(pdcs->rx_buf_pool);
  1412. dma_pool_destroy(pdcs->ring_pool);
  1413. return 0;
  1414. }
  1415. static struct platform_driver pdc_mbox_driver = {
  1416. .probe = pdc_probe,
  1417. .remove = pdc_remove,
  1418. .driver = {
  1419. .name = "brcm-iproc-pdc-mbox",
  1420. .of_match_table = of_match_ptr(pdc_mbox_of_match),
  1421. },
  1422. };
  1423. module_platform_driver(pdc_mbox_driver);
  1424. MODULE_AUTHOR("Rob Rice <rob.rice@broadcom.com>");
  1425. MODULE_DESCRIPTION("Broadcom PDC mailbox driver");
  1426. MODULE_LICENSE("GPL v2");