mxs-dcp.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202
  1. /*
  2. * Freescale i.MX23/i.MX28 Data Co-Processor driver
  3. *
  4. * Copyright (C) 2013 Marek Vasut <marex@denx.de>
  5. *
  6. * The code contained herein is licensed under the GNU General Public
  7. * License. You may obtain a copy of the GNU General Public License
  8. * Version 2 or later at the following locations:
  9. *
  10. * http://www.opensource.org/licenses/gpl-license.html
  11. * http://www.gnu.org/copyleft/gpl.html
  12. */
  13. #include <linux/dma-mapping.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/io.h>
  16. #include <linux/kernel.h>
  17. #include <linux/kthread.h>
  18. #include <linux/module.h>
  19. #include <linux/of.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/stmp_device.h>
  22. #include <crypto/aes.h>
  23. #include <crypto/sha.h>
  24. #include <crypto/internal/hash.h>
  25. #include <crypto/internal/skcipher.h>
  26. #define DCP_MAX_CHANS 4
  27. #define DCP_BUF_SZ PAGE_SIZE
  28. #define DCP_SHA_PAY_SZ 64
  29. #define DCP_ALIGNMENT 64
  30. /*
  31. * Null hashes to align with hw behavior on imx6sl and ull
  32. * these are flipped for consistency with hw output
  33. */
  34. static const uint8_t sha1_null_hash[] =
  35. "\x09\x07\xd8\xaf\x90\x18\x60\x95\xef\xbf"
  36. "\x55\x32\x0d\x4b\x6b\x5e\xee\xa3\x39\xda";
  37. static const uint8_t sha256_null_hash[] =
  38. "\x55\xb8\x52\x78\x1b\x99\x95\xa4"
  39. "\x4c\x93\x9b\x64\xe4\x41\xae\x27"
  40. "\x24\xb9\x6f\x99\xc8\xf4\xfb\x9a"
  41. "\x14\x1c\xfc\x98\x42\xc4\xb0\xe3";
  42. /* DCP DMA descriptor. */
  43. struct dcp_dma_desc {
  44. uint32_t next_cmd_addr;
  45. uint32_t control0;
  46. uint32_t control1;
  47. uint32_t source;
  48. uint32_t destination;
  49. uint32_t size;
  50. uint32_t payload;
  51. uint32_t status;
  52. };
  53. /* Coherent aligned block for bounce buffering. */
  54. struct dcp_coherent_block {
  55. uint8_t aes_in_buf[DCP_BUF_SZ];
  56. uint8_t aes_out_buf[DCP_BUF_SZ];
  57. uint8_t sha_in_buf[DCP_BUF_SZ];
  58. uint8_t sha_out_buf[DCP_SHA_PAY_SZ];
  59. uint8_t aes_key[2 * AES_KEYSIZE_128];
  60. struct dcp_dma_desc desc[DCP_MAX_CHANS];
  61. };
  62. struct dcp {
  63. struct device *dev;
  64. void __iomem *base;
  65. uint32_t caps;
  66. struct dcp_coherent_block *coh;
  67. struct completion completion[DCP_MAX_CHANS];
  68. spinlock_t lock[DCP_MAX_CHANS];
  69. struct task_struct *thread[DCP_MAX_CHANS];
  70. struct crypto_queue queue[DCP_MAX_CHANS];
  71. };
  72. enum dcp_chan {
  73. DCP_CHAN_HASH_SHA = 0,
  74. DCP_CHAN_CRYPTO = 2,
  75. };
  76. struct dcp_async_ctx {
  77. /* Common context */
  78. enum dcp_chan chan;
  79. uint32_t fill;
  80. /* SHA Hash-specific context */
  81. struct mutex mutex;
  82. uint32_t alg;
  83. unsigned int hot:1;
  84. /* Crypto-specific context */
  85. struct crypto_sync_skcipher *fallback;
  86. unsigned int key_len;
  87. uint8_t key[AES_KEYSIZE_128];
  88. };
  89. struct dcp_aes_req_ctx {
  90. unsigned int enc:1;
  91. unsigned int ecb:1;
  92. };
  93. struct dcp_sha_req_ctx {
  94. unsigned int init:1;
  95. unsigned int fini:1;
  96. };
  97. struct dcp_export_state {
  98. struct dcp_sha_req_ctx req_ctx;
  99. struct dcp_async_ctx async_ctx;
  100. };
  101. /*
  102. * There can even be only one instance of the MXS DCP due to the
  103. * design of Linux Crypto API.
  104. */
  105. static struct dcp *global_sdcp;
  106. /* DCP register layout. */
  107. #define MXS_DCP_CTRL 0x00
  108. #define MXS_DCP_CTRL_GATHER_RESIDUAL_WRITES (1 << 23)
  109. #define MXS_DCP_CTRL_ENABLE_CONTEXT_CACHING (1 << 22)
  110. #define MXS_DCP_STAT 0x10
  111. #define MXS_DCP_STAT_CLR 0x18
  112. #define MXS_DCP_STAT_IRQ_MASK 0xf
  113. #define MXS_DCP_CHANNELCTRL 0x20
  114. #define MXS_DCP_CHANNELCTRL_ENABLE_CHANNEL_MASK 0xff
  115. #define MXS_DCP_CAPABILITY1 0x40
  116. #define MXS_DCP_CAPABILITY1_SHA256 (4 << 16)
  117. #define MXS_DCP_CAPABILITY1_SHA1 (1 << 16)
  118. #define MXS_DCP_CAPABILITY1_AES128 (1 << 0)
  119. #define MXS_DCP_CONTEXT 0x50
  120. #define MXS_DCP_CH_N_CMDPTR(n) (0x100 + ((n) * 0x40))
  121. #define MXS_DCP_CH_N_SEMA(n) (0x110 + ((n) * 0x40))
  122. #define MXS_DCP_CH_N_STAT(n) (0x120 + ((n) * 0x40))
  123. #define MXS_DCP_CH_N_STAT_CLR(n) (0x128 + ((n) * 0x40))
  124. /* DMA descriptor bits. */
  125. #define MXS_DCP_CONTROL0_HASH_TERM (1 << 13)
  126. #define MXS_DCP_CONTROL0_HASH_INIT (1 << 12)
  127. #define MXS_DCP_CONTROL0_PAYLOAD_KEY (1 << 11)
  128. #define MXS_DCP_CONTROL0_CIPHER_ENCRYPT (1 << 8)
  129. #define MXS_DCP_CONTROL0_CIPHER_INIT (1 << 9)
  130. #define MXS_DCP_CONTROL0_ENABLE_HASH (1 << 6)
  131. #define MXS_DCP_CONTROL0_ENABLE_CIPHER (1 << 5)
  132. #define MXS_DCP_CONTROL0_DECR_SEMAPHORE (1 << 1)
  133. #define MXS_DCP_CONTROL0_INTERRUPT (1 << 0)
  134. #define MXS_DCP_CONTROL1_HASH_SELECT_SHA256 (2 << 16)
  135. #define MXS_DCP_CONTROL1_HASH_SELECT_SHA1 (0 << 16)
  136. #define MXS_DCP_CONTROL1_CIPHER_MODE_CBC (1 << 4)
  137. #define MXS_DCP_CONTROL1_CIPHER_MODE_ECB (0 << 4)
  138. #define MXS_DCP_CONTROL1_CIPHER_SELECT_AES128 (0 << 0)
  139. static int mxs_dcp_start_dma(struct dcp_async_ctx *actx)
  140. {
  141. struct dcp *sdcp = global_sdcp;
  142. const int chan = actx->chan;
  143. uint32_t stat;
  144. unsigned long ret;
  145. struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
  146. dma_addr_t desc_phys = dma_map_single(sdcp->dev, desc, sizeof(*desc),
  147. DMA_TO_DEVICE);
  148. reinit_completion(&sdcp->completion[chan]);
  149. /* Clear status register. */
  150. writel(0xffffffff, sdcp->base + MXS_DCP_CH_N_STAT_CLR(chan));
  151. /* Load the DMA descriptor. */
  152. writel(desc_phys, sdcp->base + MXS_DCP_CH_N_CMDPTR(chan));
  153. /* Increment the semaphore to start the DMA transfer. */
  154. writel(1, sdcp->base + MXS_DCP_CH_N_SEMA(chan));
  155. ret = wait_for_completion_timeout(&sdcp->completion[chan],
  156. msecs_to_jiffies(1000));
  157. if (!ret) {
  158. dev_err(sdcp->dev, "Channel %i timeout (DCP_STAT=0x%08x)\n",
  159. chan, readl(sdcp->base + MXS_DCP_STAT));
  160. return -ETIMEDOUT;
  161. }
  162. stat = readl(sdcp->base + MXS_DCP_CH_N_STAT(chan));
  163. if (stat & 0xff) {
  164. dev_err(sdcp->dev, "Channel %i error (CH_STAT=0x%08x)\n",
  165. chan, stat);
  166. return -EINVAL;
  167. }
  168. dma_unmap_single(sdcp->dev, desc_phys, sizeof(*desc), DMA_TO_DEVICE);
  169. return 0;
  170. }
  171. /*
  172. * Encryption (AES128)
  173. */
  174. static int mxs_dcp_run_aes(struct dcp_async_ctx *actx,
  175. struct ablkcipher_request *req, int init)
  176. {
  177. struct dcp *sdcp = global_sdcp;
  178. struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
  179. struct dcp_aes_req_ctx *rctx = ablkcipher_request_ctx(req);
  180. int ret;
  181. dma_addr_t key_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_key,
  182. 2 * AES_KEYSIZE_128,
  183. DMA_TO_DEVICE);
  184. dma_addr_t src_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_in_buf,
  185. DCP_BUF_SZ, DMA_TO_DEVICE);
  186. dma_addr_t dst_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_out_buf,
  187. DCP_BUF_SZ, DMA_FROM_DEVICE);
  188. if (actx->fill % AES_BLOCK_SIZE) {
  189. dev_err(sdcp->dev, "Invalid block size!\n");
  190. ret = -EINVAL;
  191. goto aes_done_run;
  192. }
  193. /* Fill in the DMA descriptor. */
  194. desc->control0 = MXS_DCP_CONTROL0_DECR_SEMAPHORE |
  195. MXS_DCP_CONTROL0_INTERRUPT |
  196. MXS_DCP_CONTROL0_ENABLE_CIPHER;
  197. /* Payload contains the key. */
  198. desc->control0 |= MXS_DCP_CONTROL0_PAYLOAD_KEY;
  199. if (rctx->enc)
  200. desc->control0 |= MXS_DCP_CONTROL0_CIPHER_ENCRYPT;
  201. if (init)
  202. desc->control0 |= MXS_DCP_CONTROL0_CIPHER_INIT;
  203. desc->control1 = MXS_DCP_CONTROL1_CIPHER_SELECT_AES128;
  204. if (rctx->ecb)
  205. desc->control1 |= MXS_DCP_CONTROL1_CIPHER_MODE_ECB;
  206. else
  207. desc->control1 |= MXS_DCP_CONTROL1_CIPHER_MODE_CBC;
  208. desc->next_cmd_addr = 0;
  209. desc->source = src_phys;
  210. desc->destination = dst_phys;
  211. desc->size = actx->fill;
  212. desc->payload = key_phys;
  213. desc->status = 0;
  214. ret = mxs_dcp_start_dma(actx);
  215. aes_done_run:
  216. dma_unmap_single(sdcp->dev, key_phys, 2 * AES_KEYSIZE_128,
  217. DMA_TO_DEVICE);
  218. dma_unmap_single(sdcp->dev, src_phys, DCP_BUF_SZ, DMA_TO_DEVICE);
  219. dma_unmap_single(sdcp->dev, dst_phys, DCP_BUF_SZ, DMA_FROM_DEVICE);
  220. return ret;
  221. }
  222. static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
  223. {
  224. struct dcp *sdcp = global_sdcp;
  225. struct ablkcipher_request *req = ablkcipher_request_cast(arq);
  226. struct dcp_async_ctx *actx = crypto_tfm_ctx(arq->tfm);
  227. struct dcp_aes_req_ctx *rctx = ablkcipher_request_ctx(req);
  228. struct scatterlist *dst = req->dst;
  229. struct scatterlist *src = req->src;
  230. const int nents = sg_nents(req->src);
  231. const int out_off = DCP_BUF_SZ;
  232. uint8_t *in_buf = sdcp->coh->aes_in_buf;
  233. uint8_t *out_buf = sdcp->coh->aes_out_buf;
  234. uint8_t *out_tmp, *src_buf, *dst_buf = NULL;
  235. uint32_t dst_off = 0;
  236. uint32_t last_out_len = 0;
  237. uint8_t *key = sdcp->coh->aes_key;
  238. int ret = 0;
  239. int split = 0;
  240. unsigned int i, len, clen, rem = 0, tlen = 0;
  241. int init = 0;
  242. bool limit_hit = false;
  243. actx->fill = 0;
  244. /* Copy the key from the temporary location. */
  245. memcpy(key, actx->key, actx->key_len);
  246. if (!rctx->ecb) {
  247. /* Copy the CBC IV just past the key. */
  248. memcpy(key + AES_KEYSIZE_128, req->info, AES_KEYSIZE_128);
  249. /* CBC needs the INIT set. */
  250. init = 1;
  251. } else {
  252. memset(key + AES_KEYSIZE_128, 0, AES_KEYSIZE_128);
  253. }
  254. for_each_sg(req->src, src, nents, i) {
  255. src_buf = sg_virt(src);
  256. len = sg_dma_len(src);
  257. tlen += len;
  258. limit_hit = tlen > req->nbytes;
  259. if (limit_hit)
  260. len = req->nbytes - (tlen - len);
  261. do {
  262. if (actx->fill + len > out_off)
  263. clen = out_off - actx->fill;
  264. else
  265. clen = len;
  266. memcpy(in_buf + actx->fill, src_buf, clen);
  267. len -= clen;
  268. src_buf += clen;
  269. actx->fill += clen;
  270. /*
  271. * If we filled the buffer or this is the last SG,
  272. * submit the buffer.
  273. */
  274. if (actx->fill == out_off || sg_is_last(src) ||
  275. limit_hit) {
  276. ret = mxs_dcp_run_aes(actx, req, init);
  277. if (ret)
  278. return ret;
  279. init = 0;
  280. out_tmp = out_buf;
  281. last_out_len = actx->fill;
  282. while (dst && actx->fill) {
  283. if (!split) {
  284. dst_buf = sg_virt(dst);
  285. dst_off = 0;
  286. }
  287. rem = min(sg_dma_len(dst) - dst_off,
  288. actx->fill);
  289. memcpy(dst_buf + dst_off, out_tmp, rem);
  290. out_tmp += rem;
  291. dst_off += rem;
  292. actx->fill -= rem;
  293. if (dst_off == sg_dma_len(dst)) {
  294. dst = sg_next(dst);
  295. split = 0;
  296. } else {
  297. split = 1;
  298. }
  299. }
  300. }
  301. } while (len);
  302. if (limit_hit)
  303. break;
  304. }
  305. /* Copy the IV for CBC for chaining */
  306. if (!rctx->ecb) {
  307. if (rctx->enc)
  308. memcpy(req->info, out_buf+(last_out_len-AES_BLOCK_SIZE),
  309. AES_BLOCK_SIZE);
  310. else
  311. memcpy(req->info, in_buf+(last_out_len-AES_BLOCK_SIZE),
  312. AES_BLOCK_SIZE);
  313. }
  314. return ret;
  315. }
  316. static int dcp_chan_thread_aes(void *data)
  317. {
  318. struct dcp *sdcp = global_sdcp;
  319. const int chan = DCP_CHAN_CRYPTO;
  320. struct crypto_async_request *backlog;
  321. struct crypto_async_request *arq;
  322. int ret;
  323. while (!kthread_should_stop()) {
  324. set_current_state(TASK_INTERRUPTIBLE);
  325. spin_lock(&sdcp->lock[chan]);
  326. backlog = crypto_get_backlog(&sdcp->queue[chan]);
  327. arq = crypto_dequeue_request(&sdcp->queue[chan]);
  328. spin_unlock(&sdcp->lock[chan]);
  329. if (!backlog && !arq) {
  330. schedule();
  331. continue;
  332. }
  333. set_current_state(TASK_RUNNING);
  334. if (backlog)
  335. backlog->complete(backlog, -EINPROGRESS);
  336. if (arq) {
  337. ret = mxs_dcp_aes_block_crypt(arq);
  338. arq->complete(arq, ret);
  339. }
  340. }
  341. return 0;
  342. }
  343. static int mxs_dcp_block_fallback(struct ablkcipher_request *req, int enc)
  344. {
  345. struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
  346. struct dcp_async_ctx *ctx = crypto_ablkcipher_ctx(tfm);
  347. SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, ctx->fallback);
  348. int ret;
  349. skcipher_request_set_sync_tfm(subreq, ctx->fallback);
  350. skcipher_request_set_callback(subreq, req->base.flags, NULL, NULL);
  351. skcipher_request_set_crypt(subreq, req->src, req->dst,
  352. req->nbytes, req->info);
  353. if (enc)
  354. ret = crypto_skcipher_encrypt(subreq);
  355. else
  356. ret = crypto_skcipher_decrypt(subreq);
  357. skcipher_request_zero(subreq);
  358. return ret;
  359. }
  360. static int mxs_dcp_aes_enqueue(struct ablkcipher_request *req, int enc, int ecb)
  361. {
  362. struct dcp *sdcp = global_sdcp;
  363. struct crypto_async_request *arq = &req->base;
  364. struct dcp_async_ctx *actx = crypto_tfm_ctx(arq->tfm);
  365. struct dcp_aes_req_ctx *rctx = ablkcipher_request_ctx(req);
  366. int ret;
  367. if (unlikely(actx->key_len != AES_KEYSIZE_128))
  368. return mxs_dcp_block_fallback(req, enc);
  369. rctx->enc = enc;
  370. rctx->ecb = ecb;
  371. actx->chan = DCP_CHAN_CRYPTO;
  372. spin_lock(&sdcp->lock[actx->chan]);
  373. ret = crypto_enqueue_request(&sdcp->queue[actx->chan], &req->base);
  374. spin_unlock(&sdcp->lock[actx->chan]);
  375. wake_up_process(sdcp->thread[actx->chan]);
  376. return -EINPROGRESS;
  377. }
  378. static int mxs_dcp_aes_ecb_decrypt(struct ablkcipher_request *req)
  379. {
  380. return mxs_dcp_aes_enqueue(req, 0, 1);
  381. }
  382. static int mxs_dcp_aes_ecb_encrypt(struct ablkcipher_request *req)
  383. {
  384. return mxs_dcp_aes_enqueue(req, 1, 1);
  385. }
  386. static int mxs_dcp_aes_cbc_decrypt(struct ablkcipher_request *req)
  387. {
  388. return mxs_dcp_aes_enqueue(req, 0, 0);
  389. }
  390. static int mxs_dcp_aes_cbc_encrypt(struct ablkcipher_request *req)
  391. {
  392. return mxs_dcp_aes_enqueue(req, 1, 0);
  393. }
  394. static int mxs_dcp_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
  395. unsigned int len)
  396. {
  397. struct dcp_async_ctx *actx = crypto_ablkcipher_ctx(tfm);
  398. unsigned int ret;
  399. /*
  400. * AES 128 is supposed by the hardware, store key into temporary
  401. * buffer and exit. We must use the temporary buffer here, since
  402. * there can still be an operation in progress.
  403. */
  404. actx->key_len = len;
  405. if (len == AES_KEYSIZE_128) {
  406. memcpy(actx->key, key, len);
  407. return 0;
  408. }
  409. /*
  410. * If the requested AES key size is not supported by the hardware,
  411. * but is supported by in-kernel software implementation, we use
  412. * software fallback.
  413. */
  414. crypto_sync_skcipher_clear_flags(actx->fallback, CRYPTO_TFM_REQ_MASK);
  415. crypto_sync_skcipher_set_flags(actx->fallback,
  416. tfm->base.crt_flags & CRYPTO_TFM_REQ_MASK);
  417. ret = crypto_sync_skcipher_setkey(actx->fallback, key, len);
  418. if (!ret)
  419. return 0;
  420. tfm->base.crt_flags &= ~CRYPTO_TFM_RES_MASK;
  421. tfm->base.crt_flags |= crypto_sync_skcipher_get_flags(actx->fallback) &
  422. CRYPTO_TFM_RES_MASK;
  423. return ret;
  424. }
  425. static int mxs_dcp_aes_fallback_init(struct crypto_tfm *tfm)
  426. {
  427. const char *name = crypto_tfm_alg_name(tfm);
  428. struct dcp_async_ctx *actx = crypto_tfm_ctx(tfm);
  429. struct crypto_sync_skcipher *blk;
  430. blk = crypto_alloc_sync_skcipher(name, 0, CRYPTO_ALG_NEED_FALLBACK);
  431. if (IS_ERR(blk))
  432. return PTR_ERR(blk);
  433. actx->fallback = blk;
  434. tfm->crt_ablkcipher.reqsize = sizeof(struct dcp_aes_req_ctx);
  435. return 0;
  436. }
  437. static void mxs_dcp_aes_fallback_exit(struct crypto_tfm *tfm)
  438. {
  439. struct dcp_async_ctx *actx = crypto_tfm_ctx(tfm);
  440. crypto_free_sync_skcipher(actx->fallback);
  441. }
  442. /*
  443. * Hashing (SHA1/SHA256)
  444. */
  445. static int mxs_dcp_run_sha(struct ahash_request *req)
  446. {
  447. struct dcp *sdcp = global_sdcp;
  448. int ret;
  449. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  450. struct dcp_async_ctx *actx = crypto_ahash_ctx(tfm);
  451. struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
  452. struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
  453. dma_addr_t digest_phys = 0;
  454. dma_addr_t buf_phys = dma_map_single(sdcp->dev, sdcp->coh->sha_in_buf,
  455. DCP_BUF_SZ, DMA_TO_DEVICE);
  456. /* Fill in the DMA descriptor. */
  457. desc->control0 = MXS_DCP_CONTROL0_DECR_SEMAPHORE |
  458. MXS_DCP_CONTROL0_INTERRUPT |
  459. MXS_DCP_CONTROL0_ENABLE_HASH;
  460. if (rctx->init)
  461. desc->control0 |= MXS_DCP_CONTROL0_HASH_INIT;
  462. desc->control1 = actx->alg;
  463. desc->next_cmd_addr = 0;
  464. desc->source = buf_phys;
  465. desc->destination = 0;
  466. desc->size = actx->fill;
  467. desc->payload = 0;
  468. desc->status = 0;
  469. /*
  470. * Align driver with hw behavior when generating null hashes
  471. */
  472. if (rctx->init && rctx->fini && desc->size == 0) {
  473. struct hash_alg_common *halg = crypto_hash_alg_common(tfm);
  474. const uint8_t *sha_buf =
  475. (actx->alg == MXS_DCP_CONTROL1_HASH_SELECT_SHA1) ?
  476. sha1_null_hash : sha256_null_hash;
  477. memcpy(sdcp->coh->sha_out_buf, sha_buf, halg->digestsize);
  478. ret = 0;
  479. goto done_run;
  480. }
  481. /* Set HASH_TERM bit for last transfer block. */
  482. if (rctx->fini) {
  483. digest_phys = dma_map_single(sdcp->dev, sdcp->coh->sha_out_buf,
  484. DCP_SHA_PAY_SZ, DMA_FROM_DEVICE);
  485. desc->control0 |= MXS_DCP_CONTROL0_HASH_TERM;
  486. desc->payload = digest_phys;
  487. }
  488. ret = mxs_dcp_start_dma(actx);
  489. if (rctx->fini)
  490. dma_unmap_single(sdcp->dev, digest_phys, DCP_SHA_PAY_SZ,
  491. DMA_FROM_DEVICE);
  492. done_run:
  493. dma_unmap_single(sdcp->dev, buf_phys, DCP_BUF_SZ, DMA_TO_DEVICE);
  494. return ret;
  495. }
  496. static int dcp_sha_req_to_buf(struct crypto_async_request *arq)
  497. {
  498. struct dcp *sdcp = global_sdcp;
  499. struct ahash_request *req = ahash_request_cast(arq);
  500. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  501. struct dcp_async_ctx *actx = crypto_ahash_ctx(tfm);
  502. struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
  503. struct hash_alg_common *halg = crypto_hash_alg_common(tfm);
  504. const int nents = sg_nents(req->src);
  505. uint8_t *in_buf = sdcp->coh->sha_in_buf;
  506. uint8_t *out_buf = sdcp->coh->sha_out_buf;
  507. uint8_t *src_buf;
  508. struct scatterlist *src;
  509. unsigned int i, len, clen;
  510. int ret;
  511. int fin = rctx->fini;
  512. if (fin)
  513. rctx->fini = 0;
  514. for_each_sg(req->src, src, nents, i) {
  515. src_buf = sg_virt(src);
  516. len = sg_dma_len(src);
  517. do {
  518. if (actx->fill + len > DCP_BUF_SZ)
  519. clen = DCP_BUF_SZ - actx->fill;
  520. else
  521. clen = len;
  522. memcpy(in_buf + actx->fill, src_buf, clen);
  523. len -= clen;
  524. src_buf += clen;
  525. actx->fill += clen;
  526. /*
  527. * If we filled the buffer and still have some
  528. * more data, submit the buffer.
  529. */
  530. if (len && actx->fill == DCP_BUF_SZ) {
  531. ret = mxs_dcp_run_sha(req);
  532. if (ret)
  533. return ret;
  534. actx->fill = 0;
  535. rctx->init = 0;
  536. }
  537. } while (len);
  538. }
  539. if (fin) {
  540. rctx->fini = 1;
  541. /* Submit whatever is left. */
  542. if (!req->result)
  543. return -EINVAL;
  544. ret = mxs_dcp_run_sha(req);
  545. if (ret)
  546. return ret;
  547. actx->fill = 0;
  548. /* For some reason the result is flipped */
  549. for (i = 0; i < halg->digestsize; i++)
  550. req->result[i] = out_buf[halg->digestsize - i - 1];
  551. }
  552. return 0;
  553. }
  554. static int dcp_chan_thread_sha(void *data)
  555. {
  556. struct dcp *sdcp = global_sdcp;
  557. const int chan = DCP_CHAN_HASH_SHA;
  558. struct crypto_async_request *backlog;
  559. struct crypto_async_request *arq;
  560. struct dcp_sha_req_ctx *rctx;
  561. struct ahash_request *req;
  562. int ret, fini;
  563. while (!kthread_should_stop()) {
  564. set_current_state(TASK_INTERRUPTIBLE);
  565. spin_lock(&sdcp->lock[chan]);
  566. backlog = crypto_get_backlog(&sdcp->queue[chan]);
  567. arq = crypto_dequeue_request(&sdcp->queue[chan]);
  568. spin_unlock(&sdcp->lock[chan]);
  569. if (!backlog && !arq) {
  570. schedule();
  571. continue;
  572. }
  573. set_current_state(TASK_RUNNING);
  574. if (backlog)
  575. backlog->complete(backlog, -EINPROGRESS);
  576. if (arq) {
  577. req = ahash_request_cast(arq);
  578. rctx = ahash_request_ctx(req);
  579. ret = dcp_sha_req_to_buf(arq);
  580. fini = rctx->fini;
  581. arq->complete(arq, ret);
  582. }
  583. }
  584. return 0;
  585. }
  586. static int dcp_sha_init(struct ahash_request *req)
  587. {
  588. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  589. struct dcp_async_ctx *actx = crypto_ahash_ctx(tfm);
  590. struct hash_alg_common *halg = crypto_hash_alg_common(tfm);
  591. /*
  592. * Start hashing session. The code below only inits the
  593. * hashing session context, nothing more.
  594. */
  595. memset(actx, 0, sizeof(*actx));
  596. if (strcmp(halg->base.cra_name, "sha1") == 0)
  597. actx->alg = MXS_DCP_CONTROL1_HASH_SELECT_SHA1;
  598. else
  599. actx->alg = MXS_DCP_CONTROL1_HASH_SELECT_SHA256;
  600. actx->fill = 0;
  601. actx->hot = 0;
  602. actx->chan = DCP_CHAN_HASH_SHA;
  603. mutex_init(&actx->mutex);
  604. return 0;
  605. }
  606. static int dcp_sha_update_fx(struct ahash_request *req, int fini)
  607. {
  608. struct dcp *sdcp = global_sdcp;
  609. struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
  610. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  611. struct dcp_async_ctx *actx = crypto_ahash_ctx(tfm);
  612. int ret;
  613. /*
  614. * Ignore requests that have no data in them and are not
  615. * the trailing requests in the stream of requests.
  616. */
  617. if (!req->nbytes && !fini)
  618. return 0;
  619. mutex_lock(&actx->mutex);
  620. rctx->fini = fini;
  621. if (!actx->hot) {
  622. actx->hot = 1;
  623. rctx->init = 1;
  624. }
  625. spin_lock(&sdcp->lock[actx->chan]);
  626. ret = crypto_enqueue_request(&sdcp->queue[actx->chan], &req->base);
  627. spin_unlock(&sdcp->lock[actx->chan]);
  628. wake_up_process(sdcp->thread[actx->chan]);
  629. mutex_unlock(&actx->mutex);
  630. return -EINPROGRESS;
  631. }
  632. static int dcp_sha_update(struct ahash_request *req)
  633. {
  634. return dcp_sha_update_fx(req, 0);
  635. }
  636. static int dcp_sha_final(struct ahash_request *req)
  637. {
  638. ahash_request_set_crypt(req, NULL, req->result, 0);
  639. req->nbytes = 0;
  640. return dcp_sha_update_fx(req, 1);
  641. }
  642. static int dcp_sha_finup(struct ahash_request *req)
  643. {
  644. return dcp_sha_update_fx(req, 1);
  645. }
  646. static int dcp_sha_digest(struct ahash_request *req)
  647. {
  648. int ret;
  649. ret = dcp_sha_init(req);
  650. if (ret)
  651. return ret;
  652. return dcp_sha_finup(req);
  653. }
  654. static int dcp_sha_import(struct ahash_request *req, const void *in)
  655. {
  656. struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
  657. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  658. struct dcp_async_ctx *actx = crypto_ahash_ctx(tfm);
  659. const struct dcp_export_state *export = in;
  660. memset(rctx, 0, sizeof(struct dcp_sha_req_ctx));
  661. memset(actx, 0, sizeof(struct dcp_async_ctx));
  662. memcpy(rctx, &export->req_ctx, sizeof(struct dcp_sha_req_ctx));
  663. memcpy(actx, &export->async_ctx, sizeof(struct dcp_async_ctx));
  664. return 0;
  665. }
  666. static int dcp_sha_export(struct ahash_request *req, void *out)
  667. {
  668. struct dcp_sha_req_ctx *rctx_state = ahash_request_ctx(req);
  669. struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
  670. struct dcp_async_ctx *actx_state = crypto_ahash_ctx(tfm);
  671. struct dcp_export_state *export = out;
  672. memcpy(&export->req_ctx, rctx_state, sizeof(struct dcp_sha_req_ctx));
  673. memcpy(&export->async_ctx, actx_state, sizeof(struct dcp_async_ctx));
  674. return 0;
  675. }
  676. static int dcp_sha_cra_init(struct crypto_tfm *tfm)
  677. {
  678. crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
  679. sizeof(struct dcp_sha_req_ctx));
  680. return 0;
  681. }
  682. static void dcp_sha_cra_exit(struct crypto_tfm *tfm)
  683. {
  684. }
  685. /* AES 128 ECB and AES 128 CBC */
  686. static struct crypto_alg dcp_aes_algs[] = {
  687. {
  688. .cra_name = "ecb(aes)",
  689. .cra_driver_name = "ecb-aes-dcp",
  690. .cra_priority = 400,
  691. .cra_alignmask = 15,
  692. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
  693. CRYPTO_ALG_ASYNC |
  694. CRYPTO_ALG_NEED_FALLBACK,
  695. .cra_init = mxs_dcp_aes_fallback_init,
  696. .cra_exit = mxs_dcp_aes_fallback_exit,
  697. .cra_blocksize = AES_BLOCK_SIZE,
  698. .cra_ctxsize = sizeof(struct dcp_async_ctx),
  699. .cra_type = &crypto_ablkcipher_type,
  700. .cra_module = THIS_MODULE,
  701. .cra_u = {
  702. .ablkcipher = {
  703. .min_keysize = AES_MIN_KEY_SIZE,
  704. .max_keysize = AES_MAX_KEY_SIZE,
  705. .setkey = mxs_dcp_aes_setkey,
  706. .encrypt = mxs_dcp_aes_ecb_encrypt,
  707. .decrypt = mxs_dcp_aes_ecb_decrypt
  708. },
  709. },
  710. }, {
  711. .cra_name = "cbc(aes)",
  712. .cra_driver_name = "cbc-aes-dcp",
  713. .cra_priority = 400,
  714. .cra_alignmask = 15,
  715. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
  716. CRYPTO_ALG_ASYNC |
  717. CRYPTO_ALG_NEED_FALLBACK,
  718. .cra_init = mxs_dcp_aes_fallback_init,
  719. .cra_exit = mxs_dcp_aes_fallback_exit,
  720. .cra_blocksize = AES_BLOCK_SIZE,
  721. .cra_ctxsize = sizeof(struct dcp_async_ctx),
  722. .cra_type = &crypto_ablkcipher_type,
  723. .cra_module = THIS_MODULE,
  724. .cra_u = {
  725. .ablkcipher = {
  726. .min_keysize = AES_MIN_KEY_SIZE,
  727. .max_keysize = AES_MAX_KEY_SIZE,
  728. .setkey = mxs_dcp_aes_setkey,
  729. .encrypt = mxs_dcp_aes_cbc_encrypt,
  730. .decrypt = mxs_dcp_aes_cbc_decrypt,
  731. .ivsize = AES_BLOCK_SIZE,
  732. },
  733. },
  734. },
  735. };
  736. /* SHA1 */
  737. static struct ahash_alg dcp_sha1_alg = {
  738. .init = dcp_sha_init,
  739. .update = dcp_sha_update,
  740. .final = dcp_sha_final,
  741. .finup = dcp_sha_finup,
  742. .digest = dcp_sha_digest,
  743. .import = dcp_sha_import,
  744. .export = dcp_sha_export,
  745. .halg = {
  746. .digestsize = SHA1_DIGEST_SIZE,
  747. .statesize = sizeof(struct dcp_export_state),
  748. .base = {
  749. .cra_name = "sha1",
  750. .cra_driver_name = "sha1-dcp",
  751. .cra_priority = 400,
  752. .cra_alignmask = 63,
  753. .cra_flags = CRYPTO_ALG_ASYNC,
  754. .cra_blocksize = SHA1_BLOCK_SIZE,
  755. .cra_ctxsize = sizeof(struct dcp_async_ctx),
  756. .cra_module = THIS_MODULE,
  757. .cra_init = dcp_sha_cra_init,
  758. .cra_exit = dcp_sha_cra_exit,
  759. },
  760. },
  761. };
  762. /* SHA256 */
  763. static struct ahash_alg dcp_sha256_alg = {
  764. .init = dcp_sha_init,
  765. .update = dcp_sha_update,
  766. .final = dcp_sha_final,
  767. .finup = dcp_sha_finup,
  768. .digest = dcp_sha_digest,
  769. .import = dcp_sha_import,
  770. .export = dcp_sha_export,
  771. .halg = {
  772. .digestsize = SHA256_DIGEST_SIZE,
  773. .statesize = sizeof(struct dcp_export_state),
  774. .base = {
  775. .cra_name = "sha256",
  776. .cra_driver_name = "sha256-dcp",
  777. .cra_priority = 400,
  778. .cra_alignmask = 63,
  779. .cra_flags = CRYPTO_ALG_ASYNC,
  780. .cra_blocksize = SHA256_BLOCK_SIZE,
  781. .cra_ctxsize = sizeof(struct dcp_async_ctx),
  782. .cra_module = THIS_MODULE,
  783. .cra_init = dcp_sha_cra_init,
  784. .cra_exit = dcp_sha_cra_exit,
  785. },
  786. },
  787. };
  788. static irqreturn_t mxs_dcp_irq(int irq, void *context)
  789. {
  790. struct dcp *sdcp = context;
  791. uint32_t stat;
  792. int i;
  793. stat = readl(sdcp->base + MXS_DCP_STAT);
  794. stat &= MXS_DCP_STAT_IRQ_MASK;
  795. if (!stat)
  796. return IRQ_NONE;
  797. /* Clear the interrupts. */
  798. writel(stat, sdcp->base + MXS_DCP_STAT_CLR);
  799. /* Complete the DMA requests that finished. */
  800. for (i = 0; i < DCP_MAX_CHANS; i++)
  801. if (stat & (1 << i))
  802. complete(&sdcp->completion[i]);
  803. return IRQ_HANDLED;
  804. }
  805. static int mxs_dcp_probe(struct platform_device *pdev)
  806. {
  807. struct device *dev = &pdev->dev;
  808. struct dcp *sdcp = NULL;
  809. int i, ret;
  810. struct resource *iores;
  811. int dcp_vmi_irq, dcp_irq;
  812. if (global_sdcp) {
  813. dev_err(dev, "Only one DCP instance allowed!\n");
  814. return -ENODEV;
  815. }
  816. iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  817. dcp_vmi_irq = platform_get_irq(pdev, 0);
  818. if (dcp_vmi_irq < 0) {
  819. dev_err(dev, "Failed to get IRQ: (%d)!\n", dcp_vmi_irq);
  820. return dcp_vmi_irq;
  821. }
  822. dcp_irq = platform_get_irq(pdev, 1);
  823. if (dcp_irq < 0) {
  824. dev_err(dev, "Failed to get IRQ: (%d)!\n", dcp_irq);
  825. return dcp_irq;
  826. }
  827. sdcp = devm_kzalloc(dev, sizeof(*sdcp), GFP_KERNEL);
  828. if (!sdcp)
  829. return -ENOMEM;
  830. sdcp->dev = dev;
  831. sdcp->base = devm_ioremap_resource(dev, iores);
  832. if (IS_ERR(sdcp->base))
  833. return PTR_ERR(sdcp->base);
  834. ret = devm_request_irq(dev, dcp_vmi_irq, mxs_dcp_irq, 0,
  835. "dcp-vmi-irq", sdcp);
  836. if (ret) {
  837. dev_err(dev, "Failed to claim DCP VMI IRQ!\n");
  838. return ret;
  839. }
  840. ret = devm_request_irq(dev, dcp_irq, mxs_dcp_irq, 0,
  841. "dcp-irq", sdcp);
  842. if (ret) {
  843. dev_err(dev, "Failed to claim DCP IRQ!\n");
  844. return ret;
  845. }
  846. /* Allocate coherent helper block. */
  847. sdcp->coh = devm_kzalloc(dev, sizeof(*sdcp->coh) + DCP_ALIGNMENT,
  848. GFP_KERNEL);
  849. if (!sdcp->coh)
  850. return -ENOMEM;
  851. /* Re-align the structure so it fits the DCP constraints. */
  852. sdcp->coh = PTR_ALIGN(sdcp->coh, DCP_ALIGNMENT);
  853. /* Restart the DCP block. */
  854. ret = stmp_reset_block(sdcp->base);
  855. if (ret)
  856. return ret;
  857. /* Initialize control register. */
  858. writel(MXS_DCP_CTRL_GATHER_RESIDUAL_WRITES |
  859. MXS_DCP_CTRL_ENABLE_CONTEXT_CACHING | 0xf,
  860. sdcp->base + MXS_DCP_CTRL);
  861. /* Enable all DCP DMA channels. */
  862. writel(MXS_DCP_CHANNELCTRL_ENABLE_CHANNEL_MASK,
  863. sdcp->base + MXS_DCP_CHANNELCTRL);
  864. /*
  865. * We do not enable context switching. Give the context buffer a
  866. * pointer to an illegal address so if context switching is
  867. * inadvertantly enabled, the DCP will return an error instead of
  868. * trashing good memory. The DCP DMA cannot access ROM, so any ROM
  869. * address will do.
  870. */
  871. writel(0xffff0000, sdcp->base + MXS_DCP_CONTEXT);
  872. for (i = 0; i < DCP_MAX_CHANS; i++)
  873. writel(0xffffffff, sdcp->base + MXS_DCP_CH_N_STAT_CLR(i));
  874. writel(0xffffffff, sdcp->base + MXS_DCP_STAT_CLR);
  875. global_sdcp = sdcp;
  876. platform_set_drvdata(pdev, sdcp);
  877. for (i = 0; i < DCP_MAX_CHANS; i++) {
  878. spin_lock_init(&sdcp->lock[i]);
  879. init_completion(&sdcp->completion[i]);
  880. crypto_init_queue(&sdcp->queue[i], 50);
  881. }
  882. /* Create the SHA and AES handler threads. */
  883. sdcp->thread[DCP_CHAN_HASH_SHA] = kthread_run(dcp_chan_thread_sha,
  884. NULL, "mxs_dcp_chan/sha");
  885. if (IS_ERR(sdcp->thread[DCP_CHAN_HASH_SHA])) {
  886. dev_err(dev, "Error starting SHA thread!\n");
  887. return PTR_ERR(sdcp->thread[DCP_CHAN_HASH_SHA]);
  888. }
  889. sdcp->thread[DCP_CHAN_CRYPTO] = kthread_run(dcp_chan_thread_aes,
  890. NULL, "mxs_dcp_chan/aes");
  891. if (IS_ERR(sdcp->thread[DCP_CHAN_CRYPTO])) {
  892. dev_err(dev, "Error starting SHA thread!\n");
  893. ret = PTR_ERR(sdcp->thread[DCP_CHAN_CRYPTO]);
  894. goto err_destroy_sha_thread;
  895. }
  896. /* Register the various crypto algorithms. */
  897. sdcp->caps = readl(sdcp->base + MXS_DCP_CAPABILITY1);
  898. if (sdcp->caps & MXS_DCP_CAPABILITY1_AES128) {
  899. ret = crypto_register_algs(dcp_aes_algs,
  900. ARRAY_SIZE(dcp_aes_algs));
  901. if (ret) {
  902. /* Failed to register algorithm. */
  903. dev_err(dev, "Failed to register AES crypto!\n");
  904. goto err_destroy_aes_thread;
  905. }
  906. }
  907. if (sdcp->caps & MXS_DCP_CAPABILITY1_SHA1) {
  908. ret = crypto_register_ahash(&dcp_sha1_alg);
  909. if (ret) {
  910. dev_err(dev, "Failed to register %s hash!\n",
  911. dcp_sha1_alg.halg.base.cra_name);
  912. goto err_unregister_aes;
  913. }
  914. }
  915. if (sdcp->caps & MXS_DCP_CAPABILITY1_SHA256) {
  916. ret = crypto_register_ahash(&dcp_sha256_alg);
  917. if (ret) {
  918. dev_err(dev, "Failed to register %s hash!\n",
  919. dcp_sha256_alg.halg.base.cra_name);
  920. goto err_unregister_sha1;
  921. }
  922. }
  923. return 0;
  924. err_unregister_sha1:
  925. if (sdcp->caps & MXS_DCP_CAPABILITY1_SHA1)
  926. crypto_unregister_ahash(&dcp_sha1_alg);
  927. err_unregister_aes:
  928. if (sdcp->caps & MXS_DCP_CAPABILITY1_AES128)
  929. crypto_unregister_algs(dcp_aes_algs, ARRAY_SIZE(dcp_aes_algs));
  930. err_destroy_aes_thread:
  931. kthread_stop(sdcp->thread[DCP_CHAN_CRYPTO]);
  932. err_destroy_sha_thread:
  933. kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]);
  934. return ret;
  935. }
  936. static int mxs_dcp_remove(struct platform_device *pdev)
  937. {
  938. struct dcp *sdcp = platform_get_drvdata(pdev);
  939. if (sdcp->caps & MXS_DCP_CAPABILITY1_SHA256)
  940. crypto_unregister_ahash(&dcp_sha256_alg);
  941. if (sdcp->caps & MXS_DCP_CAPABILITY1_SHA1)
  942. crypto_unregister_ahash(&dcp_sha1_alg);
  943. if (sdcp->caps & MXS_DCP_CAPABILITY1_AES128)
  944. crypto_unregister_algs(dcp_aes_algs, ARRAY_SIZE(dcp_aes_algs));
  945. kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]);
  946. kthread_stop(sdcp->thread[DCP_CHAN_CRYPTO]);
  947. platform_set_drvdata(pdev, NULL);
  948. global_sdcp = NULL;
  949. return 0;
  950. }
  951. static const struct of_device_id mxs_dcp_dt_ids[] = {
  952. { .compatible = "fsl,imx23-dcp", .data = NULL, },
  953. { .compatible = "fsl,imx28-dcp", .data = NULL, },
  954. { /* sentinel */ }
  955. };
  956. MODULE_DEVICE_TABLE(of, mxs_dcp_dt_ids);
  957. static struct platform_driver mxs_dcp_driver = {
  958. .probe = mxs_dcp_probe,
  959. .remove = mxs_dcp_remove,
  960. .driver = {
  961. .name = "mxs-dcp",
  962. .of_match_table = mxs_dcp_dt_ids,
  963. },
  964. };
  965. module_platform_driver(mxs_dcp_driver);
  966. MODULE_AUTHOR("Marek Vasut <marex@denx.de>");
  967. MODULE_DESCRIPTION("Freescale MXS DCP Driver");
  968. MODULE_LICENSE("GPL");
  969. MODULE_ALIAS("platform:mxs-dcp");