msm_qmp.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/io.h>
  7. #include <linux/interrupt.h>
  8. #include <linux/types.h>
  9. #include <linux/spinlock.h>
  10. #include <linux/completion.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mailbox_controller.h>
  13. #include <linux/mailbox_client.h>
  14. #include <linux/module.h>
  15. #include <linux/of.h>
  16. #include <linux/of_irq.h>
  17. #include <linux/kthread.h>
  18. #include <linux/workqueue.h>
  19. #include <linux/mailbox/qmp.h>
  20. #include <linux/ipc_logging.h>
  21. #include <linux/soc/qcom/smem.h>
  22. #include <linux/soc/qcom/qcom_aoss.h>
  23. #define QMP_MAGIC 0x4d41494c /* MAIL */
  24. #define QMP_VERSION 0x1
  25. #define QMP_FEATURES 0x0
  26. #define QMP_TOUT_MS 5000
  27. #define QMP_TX_TOUT_MS 1000
  28. #define QMP_SMEM_ID 629
  29. #define QMP_MBOX_LINK_DOWN 0xFFFF0000
  30. #define QMP_MBOX_LINK_UP 0x0000FFFF
  31. #define QMP_MBOX_CH_DISCONNECTED 0xFFFF0000
  32. #define QMP_MBOX_CH_CONNECTED 0x0000FFFF
  33. #define MSG_RAM_ALIGN_BYTES 3
  34. #define QMP_IPC_LOG_PAGE_CNT 2
  35. #define QMP_INFO(ctxt, x, ...) \
  36. ipc_log_string(ctxt, "[%s]: "x, __func__, ##__VA_ARGS__)
  37. #define QMP_ERR(ctxt, x, ...) \
  38. do { \
  39. printk_ratelimited("%s[%s]: "x, KERN_ERR, __func__, ##__VA_ARGS__); \
  40. ipc_log_string(ctxt, "%s[%s]: "x, "", __func__, ##__VA_ARGS__); \
  41. } while (0)
  42. #ifdef CONFIG_QMP_DEBUGFS_CLIENT
  43. #define QMP_BUG(x) BUG_ON(x)
  44. #else
  45. #define QMP_BUG(x) do {} while (0)
  46. #endif
  47. /**
  48. * enum qmp_local_state - definition of the local state machine
  49. * @LINK_DISCONNECTED: Init state, waiting for ucore to start
  50. * @LINK_NEGOTIATION: Set local link state to up, wait for ucore ack
  51. * @LINK_CONNECTED: Link state up, channel not connected
  52. * @LOCAL_CONNECTING: Channel opening locally, wait for ucore ack
  53. * @LOCAL_CONNECTED: Channel opened locally
  54. * @CHANNEL_CONNECTED: Channel fully opened
  55. * @LOCAL_DISCONNECTING: Channel closing locally, wait for ucore ack
  56. */
  57. enum qmp_local_state {
  58. LINK_DISCONNECTED,
  59. LINK_NEGOTIATION,
  60. LINK_CONNECTED,
  61. LOCAL_CONNECTING,
  62. LOCAL_CONNECTED,
  63. CHANNEL_CONNECTED,
  64. LOCAL_DISCONNECTING,
  65. };
  66. /**
  67. * struct channel_desc - description of a core's link, channel and mailbox state
  68. * @link_state Current link state of core
  69. * @link_state_ack Ack for other core to use when link state changes
  70. * @ch_state Current channel state of core
  71. * @ch_state_ack Ack for other core to use when channel state changes
  72. * @mailbox_size Size of this core's mailbox
  73. * @mailbox_offset Location of core's mailbox from a base smem location
  74. */
  75. struct channel_desc {
  76. u32 link_state;
  77. u32 link_state_ack;
  78. u32 ch_state;
  79. u32 ch_state_ack;
  80. u32 mailbox_size;
  81. u32 mailbox_offset;
  82. };
  83. /**
  84. * struct mbox_desc - description of the protocol's mailbox state
  85. * @magic Magic number field to be set by ucore
  86. * @version Version field to be set by ucore
  87. * @features Features field to be set by ucore
  88. * @ucore Channel descriptor to hold state of ucore
  89. * @mcore Channel descriptor to hold state of mcore
  90. * @reserved Reserved in case of future use
  91. *
  92. * This structure resides in SMEM and contains the control information for the
  93. * mailbox channel. Each core in the link will have one channel descriptor
  94. */
  95. struct mbox_desc {
  96. u32 magic;
  97. u32 version;
  98. u32 features;
  99. struct channel_desc ucore;
  100. struct channel_desc mcore;
  101. u32 reserved;
  102. };
  103. /**
  104. * struct qmp_core_version - local structure to hold version and features
  105. * @version Version field to indicate what version the ucore supports
  106. * @features Features field to indicate what features the ucore supports
  107. */
  108. struct qmp_core_version {
  109. u32 version;
  110. u32 features;
  111. };
  112. /**
  113. * struct qmp_mbox - local information for managing a single mailbox
  114. * @list: List head for adding mbox to linked list
  115. * @ctrl: Controller for this mailbox
  116. * @priority: Priority of mailbox in the linked list
  117. * @num_assigned: Number of channels assigned for allocated pool
  118. * @num_shutdown: Number of channels that have shutdown
  119. * @desc: Reference to the mailbox descriptor in SMEM
  120. * @rx_disabled: Disable rx if multiple client are sending from this mbox
  121. * @tx_sent: True if tx is sent and remote proc has not sent ack
  122. * @idx_in_flight: current channel idx whos tx is in flight
  123. * @mcore_mbox_offset: Offset of mcore mbox from the msgram start
  124. * @mcore_mbox_size: Size of the mcore mbox
  125. * @rx_pkt: buffer to pass to client, holds copied data from mailbox
  126. * @version: Version and features received during link negotiation
  127. * @local_state: Current state of the mailbox protocol
  128. * @state_lock: Serialize mailbox state changes
  129. * @tx_lock: Serialize access for writes to mailbox
  130. * @link_complete: Use to block until link negotiation with remote proc
  131. * @ch_complete: Use to block until the channel is fully opened
  132. * @ch_in_use: True if this mailbox's channel owned by a client
  133. * @dwork: Delayed work to detect timed out tx
  134. */
  135. struct qmp_mbox {
  136. struct list_head list;
  137. struct mbox_controller ctrl;
  138. int priority;
  139. u32 num_assigned;
  140. u32 num_shutdown;
  141. void __iomem *desc;
  142. bool rx_disabled;
  143. bool tx_sent;
  144. u32 idx_in_flight;
  145. u32 mcore_mbox_offset;
  146. u32 mcore_mbox_size;
  147. struct qmp_pkt rx_pkt;
  148. struct qmp_pkt tx_pkt;
  149. struct work_struct tx_work;
  150. struct qmp_core_version version;
  151. enum qmp_local_state local_state;
  152. struct mutex state_lock;
  153. spinlock_t tx_lock;
  154. struct completion link_complete;
  155. struct completion ch_complete;
  156. struct delayed_work dwork;
  157. struct qmp_device *mdev;
  158. bool suspend_flag;
  159. };
  160. /**
  161. * struct qmp_device - local information for managing a single qmp edge
  162. * @dev: The device that corresponds to this edge
  163. * @name: The name of this mailbox
  164. * @mboxes: The mbox controller for this mailbox
  165. * @msgram: Reference to the start of msgram
  166. * @tx_irq_reg: Reference to the register to send an irq to remote proc
  167. * @rx_reset_reg: Reference to the register to reset the rx irq, if
  168. * applicable
  169. * @irq_mask: Mask written to @tx_irq_reg to trigger irq
  170. * @rx_irq_line: The incoming interrupt line
  171. * @tx_irq_count: Number of tx interrupts triggered
  172. * @rx_irq_count: Number of rx interrupts received
  173. * @ilc: IPC logging context
  174. */
  175. struct qmp_device {
  176. struct device *dev;
  177. const char *name;
  178. struct list_head mboxes;
  179. void __iomem *msgram;
  180. void __iomem *tx_irq_reg;
  181. void __iomem *rx_reset_reg;
  182. u32 irq_mask;
  183. u32 rx_irq_line;
  184. u32 tx_irq_count;
  185. u32 rx_irq_count;
  186. struct mbox_client mbox_client;
  187. struct mbox_chan *mbox_chan;
  188. struct qmp *qmp;
  189. void *ilc;
  190. bool early_boot;
  191. };
  192. /**
  193. * send_irq() - send an irq to a remote entity as an event signal.
  194. * @mdev: Which remote entity that should receive the irq.
  195. */
  196. static void send_irq(struct qmp_device *mdev)
  197. {
  198. /*
  199. * Any data associated with this event must be visable to the remote
  200. * before the interrupt is triggered
  201. */
  202. wmb();
  203. if (mdev->mbox_chan) {
  204. mbox_send_message(mdev->mbox_chan, NULL);
  205. mbox_client_txdone(mdev->mbox_chan, 0);
  206. } else {
  207. writel_relaxed(mdev->irq_mask, mdev->tx_irq_reg);
  208. }
  209. mdev->tx_irq_count++;
  210. }
  211. static void memcpy32_toio(void __iomem *dest, void *src, size_t size)
  212. {
  213. u32 *dest_local = (u32 *)dest;
  214. u32 *src_local = (u32 *)src;
  215. WARN_ON(size & MSG_RAM_ALIGN_BYTES);
  216. size /= sizeof(u32);
  217. while (size--)
  218. iowrite32(*src_local++, dest_local++);
  219. }
  220. static void memcpy32_fromio(void *dest, void __iomem *src, size_t size)
  221. {
  222. u32 *dest_local = (u32 *)dest;
  223. u32 *src_local = (u32 *)src;
  224. WARN_ON(size & MSG_RAM_ALIGN_BYTES);
  225. size /= sizeof(u32);
  226. while (size--)
  227. *dest_local++ = ioread32(src_local++);
  228. }
  229. /**
  230. * qmp_notify_timeout() - Notify client of tx timeout with -ETIME
  231. * @work: Structure for work that was scheduled.
  232. */
  233. static void qmp_notify_timeout(struct work_struct *work)
  234. {
  235. struct delayed_work *dwork = to_delayed_work(work);
  236. struct qmp_mbox *mbox = container_of(dwork, struct qmp_mbox, dwork);
  237. struct mbox_chan *chan = &mbox->ctrl.chans[mbox->idx_in_flight];
  238. int err = -ETIME;
  239. unsigned long flags;
  240. spin_lock_irqsave(&mbox->tx_lock, flags);
  241. if (!mbox->tx_sent) {
  242. spin_unlock_irqrestore(&mbox->tx_lock, flags);
  243. return;
  244. }
  245. QMP_ERR(mbox->mdev->ilc, "tx timeout for %d\n", mbox->idx_in_flight);
  246. QMP_BUG(mbox->tx_sent);
  247. iowrite32(0, mbox->desc + mbox->mcore_mbox_offset);
  248. mbox->tx_sent = false;
  249. spin_unlock_irqrestore(&mbox->tx_lock, flags);
  250. mbox_chan_txdone(chan, err);
  251. }
  252. static inline void qmp_schedule_tx_timeout(struct qmp_mbox *mbox)
  253. {
  254. schedule_delayed_work(&mbox->dwork, msecs_to_jiffies(QMP_TX_TOUT_MS));
  255. }
  256. /**
  257. * set_ucore_link_ack() - set the link ack in the ucore channel desc.
  258. * @mbox: the mailbox for the field that is being set.
  259. * @state: the value to set the ack field to.
  260. */
  261. static void set_ucore_link_ack(struct qmp_mbox *mbox, u32 state)
  262. {
  263. u32 offset;
  264. offset = offsetof(struct mbox_desc, ucore);
  265. offset += offsetof(struct channel_desc, link_state_ack);
  266. iowrite32(state, mbox->desc + offset);
  267. }
  268. /**
  269. * set_ucore_ch_ack() - set the channel ack in the ucore channel desc.
  270. * @mbox: the mailbox for the field that is being set.
  271. * @state: the value to set the ack field to.
  272. */
  273. static void set_ucore_ch_ack(struct qmp_mbox *mbox, u32 state)
  274. {
  275. u32 offset;
  276. offset = offsetof(struct mbox_desc, ucore);
  277. offset += offsetof(struct channel_desc, ch_state_ack);
  278. iowrite32(state, mbox->desc + offset);
  279. }
  280. /**
  281. * set_mcore_ch() - set the channel state in the mcore channel desc.
  282. * @mbox: the mailbox for the field that is being set.
  283. * @state: the value to set the channel field to.
  284. */
  285. static void set_mcore_ch(struct qmp_mbox *mbox, u32 state)
  286. {
  287. u32 offset;
  288. offset = offsetof(struct mbox_desc, mcore);
  289. offset += offsetof(struct channel_desc, ch_state);
  290. iowrite32(state, mbox->desc + offset);
  291. }
  292. /**
  293. * qmp_startup() - Start qmp mailbox channel for communication. Waits for
  294. * remote subsystem to open channel if link is not
  295. * initated or until timeout.
  296. * @chan: mailbox channel that is being opened.
  297. *
  298. * Return: 0 on succes or standard Linux error code.
  299. */
  300. static int qmp_startup(struct mbox_chan *chan)
  301. {
  302. struct qmp_mbox *mbox = chan->con_priv;
  303. unsigned long ret;
  304. if (!mbox)
  305. return -EINVAL;
  306. ret = wait_for_completion_timeout(&mbox->link_complete,
  307. msecs_to_jiffies(QMP_TOUT_MS));
  308. if (!ret)
  309. return -EAGAIN;
  310. mutex_lock(&mbox->state_lock);
  311. if (mbox->local_state == LINK_CONNECTED) {
  312. set_mcore_ch(mbox, QMP_MBOX_CH_CONNECTED);
  313. mbox->local_state = LOCAL_CONNECTING;
  314. send_irq(mbox->mdev);
  315. }
  316. mutex_unlock(&mbox->state_lock);
  317. ret = wait_for_completion_timeout(&mbox->ch_complete,
  318. msecs_to_jiffies(QMP_TOUT_MS));
  319. if (!ret)
  320. return -ETIME;
  321. return 0;
  322. }
  323. /**
  324. * qmp_send_data() - Copy the data to the channel's mailbox and notify
  325. * remote subsystem of new data. This function will
  326. * return an error if the previous message sent has
  327. * not been read. Cannot Sleep.
  328. * @chan: mailbox channel that data is to be sent over.
  329. * @data: Data to be sent to remote processor, should be in the format of
  330. * a qmp_pkt.
  331. *
  332. * Return: 0 on succes or standard Linux error code.
  333. */
  334. static int qmp_send_data(struct mbox_chan *chan, void *data)
  335. {
  336. struct qmp_mbox *mbox = chan->con_priv;
  337. struct qmp_device *mdev;
  338. struct qmp_pkt *pkt = (struct qmp_pkt *)data;
  339. void __iomem *addr;
  340. unsigned long flags;
  341. u32 size;
  342. int i;
  343. if (!mbox || !data || !completion_done(&mbox->ch_complete))
  344. return -EINVAL;
  345. mdev = mbox->mdev;
  346. spin_lock_irqsave(&mbox->tx_lock, flags);
  347. addr = mbox->desc + mbox->mcore_mbox_offset;
  348. if (mbox->tx_sent) {
  349. spin_unlock_irqrestore(&mbox->tx_lock, flags);
  350. return -EAGAIN;
  351. }
  352. if (pkt->size + sizeof(pkt->size) > mbox->mcore_mbox_size) {
  353. spin_unlock_irqrestore(&mbox->tx_lock, flags);
  354. return -EINVAL;
  355. }
  356. memcpy32_toio(addr + sizeof(pkt->size), pkt->data, pkt->size);
  357. iowrite32(pkt->size, addr);
  358. /* readback to ensure write reflects in msgram */
  359. size = ioread32(addr);
  360. mbox->tx_sent = true;
  361. for (i = 0; i < mbox->ctrl.num_chans; i++) {
  362. if (chan == &mbox->ctrl.chans[i])
  363. mbox->idx_in_flight = i;
  364. }
  365. QMP_INFO(mdev->ilc, "Copied buffer to msgram sz:%d i:%d\n",
  366. size, mbox->idx_in_flight);
  367. send_irq(mdev);
  368. qmp_schedule_tx_timeout(mbox);
  369. spin_unlock_irqrestore(&mbox->tx_lock, flags);
  370. return 0;
  371. }
  372. /**
  373. * qmp_shutdown() - Disconnect this mailbox channel so the client does not
  374. * receive anymore data and can reliquish control
  375. * of the channel
  376. * @chan: mailbox channel to be shutdown.
  377. */
  378. static void qmp_shutdown(struct mbox_chan *chan)
  379. {
  380. struct qmp_mbox *mbox = chan->con_priv;
  381. mutex_lock(&mbox->state_lock);
  382. if (mbox->local_state <= LINK_CONNECTED) {
  383. mbox->num_assigned--;
  384. goto out;
  385. }
  386. if (mbox->local_state == LOCAL_CONNECTING) {
  387. mbox->num_assigned--;
  388. mbox->local_state = LINK_CONNECTED;
  389. goto out;
  390. }
  391. mbox->num_shutdown++;
  392. if (mbox->num_shutdown < mbox->num_assigned)
  393. goto out;
  394. if (mbox->local_state != LINK_DISCONNECTED) {
  395. mbox->local_state = LOCAL_DISCONNECTING;
  396. set_mcore_ch(mbox, QMP_MBOX_CH_DISCONNECTED);
  397. send_irq(mbox->mdev);
  398. }
  399. mbox->num_shutdown = 0;
  400. mbox->num_assigned = 0;
  401. out:
  402. mutex_unlock(&mbox->state_lock);
  403. }
  404. /**
  405. * qmp_last_tx_done() - qmp does not support polling operations, print
  406. * error of unexpected usage and return true to
  407. * resume operation.
  408. * @chan: Corresponding mailbox channel for requested last tx.
  409. *
  410. * Return: true
  411. */
  412. static bool qmp_last_tx_done(struct mbox_chan *chan)
  413. {
  414. pr_err("In %s, unexpected usage of last_tx_done\n", __func__);
  415. return true;
  416. }
  417. /**
  418. * qmp_recv_data() - received notification that data is available in the
  419. * mailbox. Copy data from mailbox and pass to client.
  420. * @mbox: mailbox device that received the notification.
  421. * @mbox_of: offset of mailbox from msgram start.
  422. */
  423. static void qmp_recv_data(struct qmp_mbox *mbox, u32 mbox_of)
  424. {
  425. void __iomem *addr;
  426. struct qmp_pkt *pkt;
  427. size_t read_size;
  428. addr = mbox->desc + mbox_of;
  429. pkt = &mbox->rx_pkt;
  430. pkt->size = ioread32(addr);
  431. read_size = (pkt->size + 0x3) & ~0x3;
  432. if (read_size > mbox->mcore_mbox_size)
  433. QMP_ERR(mbox->mdev->ilc, "Invalid mailbox packet\n");
  434. else {
  435. memcpy32_fromio(pkt->data, addr + sizeof(pkt->size), read_size);
  436. mbox_chan_received_data(&mbox->ctrl.chans[mbox->idx_in_flight],
  437. pkt);
  438. }
  439. iowrite32(0, addr);
  440. QMP_INFO(mbox->mdev->ilc, "recv sz:%d\n", pkt->size);
  441. send_irq(mbox->mdev);
  442. }
  443. /**
  444. * init_mcore_state() - initialize the mcore state of a mailbox.
  445. * @mdev: mailbox device to be initialized.
  446. */
  447. static void init_mcore_state(struct qmp_mbox *mbox)
  448. {
  449. struct channel_desc mcore;
  450. u32 offset = offsetof(struct mbox_desc, mcore);
  451. mcore.link_state = QMP_MBOX_LINK_UP;
  452. mcore.link_state_ack = QMP_MBOX_LINK_DOWN;
  453. mcore.ch_state = QMP_MBOX_CH_DISCONNECTED;
  454. mcore.ch_state_ack = QMP_MBOX_CH_DISCONNECTED;
  455. mcore.mailbox_size = mbox->mcore_mbox_size;
  456. mcore.mailbox_offset = mbox->mcore_mbox_offset;
  457. memcpy32_toio(mbox->desc + offset, &mcore, sizeof(mcore));
  458. }
  459. /**
  460. * qmp_irq_handler() - handle irq from remote entitity.
  461. * @irq: irq number for the trggered interrupt.
  462. * @priv: private pointer to qmp mbox device.
  463. */
  464. static irqreturn_t qmp_irq_handler(int irq, void *priv)
  465. {
  466. struct qmp_device *mdev = (struct qmp_device *)priv;
  467. if (mdev->rx_reset_reg)
  468. writel_relaxed(mdev->irq_mask, mdev->rx_reset_reg);
  469. mdev->rx_irq_count++;
  470. return IRQ_WAKE_THREAD;
  471. }
  472. /**
  473. * __qmp_rx_worker() - Handle incoming messages from remote processor.
  474. * @mbox: mailbox device that received notification.
  475. */
  476. static void __qmp_rx_worker(struct qmp_mbox *mbox)
  477. {
  478. u32 msg_len, idx;
  479. struct mbox_desc desc;
  480. struct qmp_device *mdev = mbox->mdev;
  481. unsigned long flags;
  482. memcpy_fromio(&desc, mbox->desc, sizeof(desc));
  483. if (desc.magic != QMP_MAGIC)
  484. return;
  485. mutex_lock(&mbox->state_lock);
  486. switch (mbox->local_state) {
  487. case LINK_DISCONNECTED:
  488. mbox->version.version = desc.version;
  489. mbox->version.features = desc.features;
  490. set_ucore_link_ack(mbox, desc.ucore.link_state);
  491. if (desc.mcore.mailbox_size) {
  492. mbox->mcore_mbox_size = desc.mcore.mailbox_size;
  493. mbox->mcore_mbox_offset = desc.mcore.mailbox_offset;
  494. }
  495. init_mcore_state(mbox);
  496. mbox->local_state = LINK_NEGOTIATION;
  497. mbox->rx_pkt.data = kzalloc(desc.ucore.mailbox_size,
  498. GFP_KERNEL);
  499. if (!mbox->rx_pkt.data) {
  500. QMP_ERR(mdev->ilc, "Failed to allocate rx pkt\n");
  501. break;
  502. }
  503. QMP_INFO(mdev->ilc, "Set to link negotiation\n");
  504. send_irq(mdev);
  505. break;
  506. case LINK_NEGOTIATION:
  507. if (desc.mcore.link_state_ack != QMP_MBOX_LINK_UP ||
  508. desc.mcore.link_state != QMP_MBOX_LINK_UP) {
  509. QMP_ERR(mdev->ilc, "RX int without negotiation ack\n");
  510. break;
  511. }
  512. mbox->local_state = LINK_CONNECTED;
  513. complete_all(&mbox->link_complete);
  514. QMP_INFO(mdev->ilc, "Set to link connected\n");
  515. /*
  516. * If link connection happened after hibernation
  517. * manualy trigger the channel open procedure since client
  518. * won't try to re-open the channel
  519. */
  520. if (mbox->suspend_flag) {
  521. set_mcore_ch(mbox, QMP_MBOX_CH_CONNECTED);
  522. mbox->local_state = LOCAL_CONNECTING;
  523. send_irq(mbox->mdev);
  524. }
  525. break;
  526. case LINK_CONNECTED:
  527. if (desc.ucore.ch_state == desc.ucore.ch_state_ack) {
  528. QMP_ERR(mdev->ilc, "RX int without ch open\n");
  529. break;
  530. }
  531. set_ucore_ch_ack(mbox, desc.ucore.ch_state);
  532. send_irq(mdev);
  533. QMP_INFO(mdev->ilc, "Received remote ch open\n");
  534. break;
  535. case LOCAL_CONNECTING:
  536. if (desc.mcore.ch_state_ack == QMP_MBOX_CH_CONNECTED &&
  537. desc.mcore.ch_state == QMP_MBOX_CH_CONNECTED) {
  538. mbox->local_state = LOCAL_CONNECTED;
  539. QMP_INFO(mdev->ilc, "Received local ch open ack\n");
  540. }
  541. if (desc.ucore.ch_state != desc.ucore.ch_state_ack) {
  542. set_ucore_ch_ack(mbox, desc.ucore.ch_state);
  543. send_irq(mdev);
  544. QMP_INFO(mdev->ilc, "Received remote channel open\n");
  545. }
  546. if (mbox->local_state == LOCAL_CONNECTED &&
  547. desc.mcore.ch_state == QMP_MBOX_CH_CONNECTED &&
  548. desc.ucore.ch_state == QMP_MBOX_CH_CONNECTED) {
  549. mbox->local_state = CHANNEL_CONNECTED;
  550. complete_all(&mbox->ch_complete);
  551. QMP_INFO(mdev->ilc, "Set to channel connected\n");
  552. }
  553. break;
  554. case LOCAL_CONNECTED:
  555. if (desc.ucore.ch_state == desc.ucore.ch_state_ack) {
  556. QMP_ERR(mdev->ilc, "RX int without remote ch open\n");
  557. break;
  558. }
  559. set_ucore_ch_ack(mbox, desc.ucore.ch_state);
  560. mbox->local_state = CHANNEL_CONNECTED;
  561. send_irq(mdev);
  562. complete_all(&mbox->ch_complete);
  563. QMP_INFO(mdev->ilc, "Set to channel connected\n");
  564. break;
  565. case CHANNEL_CONNECTED:
  566. if (desc.ucore.ch_state == QMP_MBOX_CH_DISCONNECTED) {
  567. set_ucore_ch_ack(mbox, desc.ucore.ch_state);
  568. mbox->local_state = LOCAL_CONNECTED;
  569. QMP_INFO(mdev->ilc, "REMOTE DISCONNECT\n");
  570. send_irq(mdev);
  571. }
  572. msg_len = ioread32(mbox->desc + desc.ucore.mailbox_offset);
  573. if (msg_len && !mbox->rx_disabled)
  574. qmp_recv_data(mbox, desc.ucore.mailbox_offset);
  575. spin_lock_irqsave(&mbox->tx_lock, flags);
  576. idx = mbox->idx_in_flight;
  577. if (mbox->tx_sent) {
  578. msg_len = ioread32(mbox->desc +
  579. mbox->mcore_mbox_offset);
  580. if (msg_len == 0) {
  581. mbox->tx_sent = false;
  582. cancel_delayed_work(&mbox->dwork);
  583. QMP_INFO(mdev->ilc, "TX flag cleared, idx%d\n",
  584. idx);
  585. spin_unlock_irqrestore(&mbox->tx_lock, flags);
  586. mbox_chan_txdone(&mbox->ctrl.chans[idx], 0);
  587. spin_lock_irqsave(&mbox->tx_lock, flags);
  588. }
  589. }
  590. spin_unlock_irqrestore(&mbox->tx_lock, flags);
  591. break;
  592. case LOCAL_DISCONNECTING:
  593. if (desc.mcore.ch_state_ack == QMP_MBOX_CH_DISCONNECTED &&
  594. desc.mcore.ch_state == desc.mcore.ch_state_ack) {
  595. mbox->local_state = LINK_CONNECTED;
  596. QMP_INFO(mdev->ilc, "Channel closed\n");
  597. reinit_completion(&mbox->ch_complete);
  598. }
  599. break;
  600. default:
  601. QMP_ERR(mdev->ilc, "Local Channel State corrupted\n");
  602. }
  603. mutex_unlock(&mbox->state_lock);
  604. }
  605. static irqreturn_t qmp_thread_irq_handler(int irq, void *priv)
  606. {
  607. struct qmp_device *mdev = (struct qmp_device *)priv;
  608. struct qmp_mbox *mbox;
  609. list_for_each_entry(mbox, &mdev->mboxes, list) {
  610. __qmp_rx_worker(mbox);
  611. }
  612. return IRQ_HANDLED;
  613. }
  614. /**
  615. * qmp_mbox_of_xlate() - Returns a mailbox channel to be used for this mailbox
  616. * device. Make sure the channel is not already in use.
  617. * @mbox: Mailbox device controlls the requested channel.
  618. * @spec: Device tree arguments to specify which channel is requested.
  619. */
  620. static struct mbox_chan *qmp_mbox_of_xlate(struct mbox_controller *mbox,
  621. const struct of_phandle_args *spec)
  622. {
  623. struct qmp_mbox *dev = container_of(mbox, struct qmp_mbox, ctrl);
  624. struct mbox_chan *chan;
  625. if (dev->num_assigned >= mbox->num_chans || !dev->ctrl.chans) {
  626. pr_err("%s: QMP out of channels\n", __func__);
  627. return ERR_PTR(-ENOMEM);
  628. }
  629. mutex_lock(&dev->state_lock);
  630. chan = &dev->ctrl.chans[dev->num_assigned++];
  631. mutex_unlock(&dev->state_lock);
  632. return chan;
  633. }
  634. /**
  635. * get_mbox_num_chans() - Find how many mbox channels need to be allocated
  636. *
  637. * @node: device node for this mailbox.
  638. *
  639. * Return: the number of phandles referring to this device node
  640. */
  641. static u32 get_mbox_num_chans(struct device_node *node)
  642. {
  643. int i, j, ret;
  644. u32 num_chans = 0;
  645. struct device_node *np;
  646. struct of_phandle_args p;
  647. for_each_node_with_property(np, "mboxes") {
  648. if (!of_device_is_available(np))
  649. continue;
  650. i = of_count_phandle_with_args(np, "mboxes", "#mbox-cells");
  651. for (j = 0; j < i; j++) {
  652. ret = of_parse_phandle_with_args(np, "mboxes",
  653. "#mbox-cells", j, &p);
  654. if (!ret && p.np == node) {
  655. num_chans++;
  656. break;
  657. }
  658. }
  659. }
  660. if (num_chans)
  661. return num_chans;
  662. return 1;
  663. }
  664. /**
  665. * mdev_add_mbox() - Add a mailbox to qmp device based on priority
  666. *
  667. * @mdev: qmp device to add mailbox to.
  668. * @new: new mailbox to add to qmp device.
  669. */
  670. static void mdev_add_mbox(struct qmp_device *mdev, struct qmp_mbox *new)
  671. {
  672. struct qmp_mbox *mbox;
  673. list_for_each_entry(mbox, &mdev->mboxes, list) {
  674. if (mbox->priority > new->priority)
  675. continue;
  676. list_add_tail(&new->list, &mbox->list);
  677. return;
  678. }
  679. list_add_tail(&new->list, &mdev->mboxes);
  680. }
  681. static struct mbox_chan_ops qmp_mbox_ops = {
  682. .startup = qmp_startup,
  683. .shutdown = qmp_shutdown,
  684. .send_data = qmp_send_data,
  685. .last_tx_done = qmp_last_tx_done,
  686. };
  687. static int qmp_shim_startup(struct mbox_chan *chan)
  688. {
  689. struct qmp_mbox *mbox = chan->con_priv;
  690. if (!mbox || !mbox->mdev)
  691. return -EINVAL;
  692. if (!mbox->mdev->qmp)
  693. return -EAGAIN;
  694. return 0;
  695. }
  696. static void qmp_shim_shutdown(struct mbox_chan *chan) { }
  697. static void qmp_shim_worker(struct work_struct *work)
  698. {
  699. struct qmp_mbox *mbox = container_of(work, struct qmp_mbox, tx_work);
  700. struct qmp_pkt *pkt = &mbox->tx_pkt;
  701. int rc;
  702. rc = qmp_send(mbox->mdev->qmp, pkt->data, pkt->size);
  703. mbox_chan_txdone(&mbox->ctrl.chans[mbox->idx_in_flight], rc);
  704. }
  705. static int qmp_shim_send_data(struct mbox_chan *chan, void *data)
  706. {
  707. struct qmp_mbox *mbox = chan->con_priv;
  708. struct qmp_pkt *pkt = (struct qmp_pkt *)data;
  709. int i;
  710. if (!mbox || !mbox->mdev || !data)
  711. return -EINVAL;
  712. if (pkt->size > SZ_4K)
  713. return -EINVAL;
  714. for (i = 0; i < mbox->ctrl.num_chans; i++) {
  715. if (chan == &mbox->ctrl.chans[i]) {
  716. mbox->idx_in_flight = i;
  717. break;
  718. }
  719. }
  720. mbox->tx_pkt.size = pkt->size;
  721. memcpy(mbox->tx_pkt.data, pkt->data, pkt->size);
  722. queue_work(system_highpri_wq, &mbox->tx_work);
  723. return 0;
  724. }
  725. static struct mbox_chan_ops qmp_mbox_shim_ops = {
  726. .startup = qmp_shim_startup,
  727. .shutdown = qmp_shim_shutdown,
  728. .send_data = qmp_shim_send_data,
  729. .last_tx_done = qmp_last_tx_done,
  730. };
  731. /**
  732. * qmp_mbox_init() - Parse the device tree for qmp mailbox and init structure
  733. *
  734. * @n: child device node representing a mailbox.
  735. * @mbox: device structure for this edge.
  736. *
  737. * Return: 0 on succes or standard Linux error code.
  738. */
  739. static int qmp_mbox_init(struct device_node *n, struct qmp_device *mdev)
  740. {
  741. int rc, i;
  742. char *key;
  743. struct qmp_mbox *mbox;
  744. struct mbox_chan *chans;
  745. u32 mbox_of, mbox_size, desc_of, priority, num_chans;
  746. key = "mbox-desc-offset";
  747. rc = of_property_read_u32(n, key, &desc_of);
  748. if (rc) {
  749. pr_err("%s: missing key %s\n", __func__, key);
  750. return 0;
  751. }
  752. key = "priority";
  753. rc = of_property_read_u32(n, key, &priority);
  754. if (rc) {
  755. pr_err("%s: missing key %s\n", __func__, key);
  756. return 0;
  757. }
  758. mbox = devm_kzalloc(mdev->dev, sizeof(*mbox), GFP_KERNEL);
  759. if (!mbox)
  760. return -ENOMEM;
  761. rc = of_property_read_u32(n, "mbox-offset", &mbox_of);
  762. if (!rc)
  763. mbox->mcore_mbox_offset = mbox_of;
  764. rc = of_property_read_u32(n, "mbox-size", &mbox_size);
  765. if (!rc)
  766. mbox->mcore_mbox_size = mbox_size;
  767. mbox->mdev = mdev;
  768. mbox->priority = priority;
  769. mbox->desc = mdev->msgram + desc_of;
  770. num_chans = get_mbox_num_chans(n);
  771. mbox->rx_disabled = (num_chans > 1) ? true : false;
  772. chans = devm_kzalloc(mdev->dev, sizeof(*chans) * num_chans, GFP_KERNEL);
  773. if (!chans)
  774. return -ENOMEM;
  775. for (i = 0; i < num_chans; i++)
  776. chans[i].con_priv = mbox;
  777. mbox->ctrl.dev = mdev->dev;
  778. mbox->ctrl.ops = &qmp_mbox_ops;
  779. mbox->ctrl.chans = chans;
  780. mbox->ctrl.num_chans = num_chans;
  781. mbox->ctrl.txdone_irq = true;
  782. mbox->ctrl.txdone_poll = false;
  783. mbox->ctrl.of_xlate = qmp_mbox_of_xlate;
  784. rc = mbox_controller_register(&mbox->ctrl);
  785. if (rc) {
  786. pr_err("%s: failed to register mbox controller %d\n", __func__,
  787. rc);
  788. return rc;
  789. }
  790. spin_lock_init(&mbox->tx_lock);
  791. mutex_init(&mbox->state_lock);
  792. mbox->local_state = LINK_DISCONNECTED;
  793. init_completion(&mbox->link_complete);
  794. init_completion(&mbox->ch_complete);
  795. mbox->tx_sent = false;
  796. mbox->num_assigned = 0;
  797. INIT_DELAYED_WORK(&mbox->dwork, qmp_notify_timeout);
  798. mbox->suspend_flag = false;
  799. mdev_add_mbox(mdev, mbox);
  800. return 0;
  801. }
  802. static int qmp_parse_ipc(struct platform_device *pdev)
  803. {
  804. struct qmp_device *mdev = platform_get_drvdata(pdev);
  805. struct device_node *node = pdev->dev.of_node;
  806. struct resource *res;
  807. int rc;
  808. res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  809. "irq-reg-base");
  810. if (!res) {
  811. pr_err("%s: missing key irq-reg-base\n", __func__);
  812. return -ENODEV;
  813. }
  814. rc = of_property_read_u32(node, "qcom,irq-mask", &mdev->irq_mask);
  815. if (rc) {
  816. pr_err("%s: missing key qcom,irq-mask\n", __func__);
  817. return -ENODEV;
  818. }
  819. mdev->tx_irq_reg = devm_ioremap(&pdev->dev, res->start,
  820. resource_size(res));
  821. if (!mdev->tx_irq_reg) {
  822. pr_err("%s: unable to map tx irq reg\n", __func__);
  823. return -EIO;
  824. }
  825. return 0;
  826. }
  827. static int qmp_shim_init(struct platform_device *pdev, struct qmp_device *mdev)
  828. {
  829. struct mbox_chan *chans;
  830. struct qmp_mbox *mbox;
  831. u32 num_chans;
  832. int rc;
  833. int i;
  834. mdev->qmp = qmp_get(&pdev->dev);
  835. if (IS_ERR(mdev->qmp))
  836. return PTR_ERR(mdev->qmp);
  837. mdev->name = of_get_property(pdev->dev.of_node, "label", NULL);
  838. if (!mdev->name) {
  839. pr_err("%s: missing label\n", __func__);
  840. return -ENODEV;
  841. }
  842. INIT_LIST_HEAD(&mdev->mboxes);
  843. mdev->dev = &pdev->dev;
  844. mbox = devm_kzalloc(mdev->dev, sizeof(*mbox), GFP_KERNEL);
  845. if (!mbox)
  846. return -ENOMEM;
  847. mbox->tx_pkt.data = devm_kzalloc(mdev->dev, SZ_4K, GFP_KERNEL);
  848. if (!mbox->tx_pkt.data)
  849. return -ENOMEM;
  850. num_chans = get_mbox_num_chans(pdev->dev.of_node);
  851. mbox->rx_disabled = (num_chans > 1) ? true : false;
  852. chans = devm_kzalloc(mdev->dev, sizeof(*chans) * num_chans, GFP_KERNEL);
  853. if (!chans)
  854. return -ENOMEM;
  855. for (i = 0; i < num_chans; i++)
  856. chans[i].con_priv = mbox;
  857. mbox->ctrl.dev = mdev->dev;
  858. mbox->ctrl.ops = &qmp_mbox_shim_ops;
  859. mbox->ctrl.chans = chans;
  860. mbox->ctrl.num_chans = num_chans;
  861. mbox->ctrl.txdone_irq = true;
  862. mbox->ctrl.txdone_poll = false;
  863. mbox->ctrl.of_xlate = qmp_mbox_of_xlate;
  864. mutex_init(&mbox->state_lock);
  865. mbox->num_assigned = 0;
  866. mbox->mdev = mdev;
  867. INIT_WORK(&mbox->tx_work, qmp_shim_worker);
  868. rc = mbox_controller_register(&mbox->ctrl);
  869. if (rc) {
  870. pr_err("%s: failed to register mbox ctrl %d\n", __func__, rc);
  871. return rc;
  872. }
  873. mdev_add_mbox(mdev, mbox);
  874. mdev->ilc = ipc_log_context_create(QMP_IPC_LOG_PAGE_CNT, mdev->name, 0);
  875. return 0;
  876. }
  877. static int qmp_smem_init(struct qmp_device *mdev, struct device_node *node)
  878. {
  879. void __iomem *buf;
  880. u32 remote_pid;
  881. size_t size;
  882. int ret;
  883. ret = of_property_read_u32(node, "qcom,remote-pid", &remote_pid);
  884. if (ret) {
  885. pr_err("failed to parse qcom,remote-pid %d\n", ret);
  886. return ret;
  887. }
  888. buf = qcom_smem_get(remote_pid, QMP_SMEM_ID, &size);
  889. if (IS_ERR_OR_NULL(buf))
  890. return PTR_ERR(buf);
  891. mdev->msgram = buf;
  892. return 0;
  893. }
  894. /**
  895. * qmp_edge_init() - Parse the device tree information for QMP, map io
  896. * memory and register for needed interrupts
  897. * @pdev: platform device for this driver.
  898. *
  899. * Return: 0 on succes or standard Linux error code.
  900. */
  901. static int qmp_edge_init(struct platform_device *pdev)
  902. {
  903. struct qmp_device *mdev = platform_get_drvdata(pdev);
  904. struct device_node *node = pdev->dev.of_node;
  905. struct resource *msgram_r;
  906. int rc;
  907. mdev->name = of_get_property(node, "label", NULL);
  908. if (!mdev->name) {
  909. pr_err("%s: missing label\n", __func__);
  910. return -ENODEV;
  911. }
  912. INIT_LIST_HEAD(&mdev->mboxes);
  913. mdev->dev = &pdev->dev;
  914. msgram_r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "msgram");
  915. if (!msgram_r) {
  916. /* fallback to smem mailbox */
  917. rc = qmp_smem_init(mdev, node);
  918. if (rc)
  919. return rc;
  920. } else {
  921. mdev->msgram = devm_ioremap(&pdev->dev, msgram_r->start,
  922. resource_size(msgram_r));
  923. if (!mdev->msgram)
  924. return -EIO;
  925. }
  926. mdev->mbox_client.dev = &pdev->dev;
  927. mdev->mbox_client.knows_txdone = true;
  928. mdev->mbox_chan = mbox_request_channel(&mdev->mbox_client, 0);
  929. if (IS_ERR(mdev->mbox_chan)) {
  930. if (PTR_ERR(mdev->mbox_chan) != -ENODEV)
  931. return PTR_ERR(mdev->mbox_chan);
  932. mdev->mbox_chan = NULL;
  933. rc = qmp_parse_ipc(pdev);
  934. if (rc)
  935. return rc;
  936. }
  937. mdev->rx_irq_line = irq_of_parse_and_map(node, 0);
  938. if (!mdev->rx_irq_line) {
  939. pr_err("%s: missing interrupts\n", __func__);
  940. return -ENODEV;
  941. }
  942. return 0;
  943. }
  944. static int qmp_mbox_remove(struct platform_device *pdev)
  945. {
  946. struct qmp_device *mdev = platform_get_drvdata(pdev);
  947. struct qmp_mbox *mbox = NULL;
  948. disable_irq(mdev->rx_irq_line);
  949. list_for_each_entry(mbox, &mdev->mboxes, list) {
  950. mbox_controller_unregister(&mbox->ctrl);
  951. kfree(mbox->rx_pkt.data);
  952. }
  953. return 0;
  954. }
  955. static int qmp_mbox_probe(struct platform_device *pdev)
  956. {
  957. struct device_node *edge_node = pdev->dev.of_node;
  958. struct qmp_device *mdev;
  959. struct qmp_mbox *mbox;
  960. int ret = 0;
  961. mdev = devm_kzalloc(&pdev->dev, sizeof(*mdev), GFP_KERNEL);
  962. if (!mdev)
  963. return -ENOMEM;
  964. platform_set_drvdata(pdev, mdev);
  965. if (of_parse_phandle(edge_node, "qcom,qmp", 0))
  966. return qmp_shim_init(pdev, mdev);
  967. ret = qmp_edge_init(pdev);
  968. if (ret)
  969. return ret;
  970. ret = qmp_mbox_init(edge_node, mdev);
  971. if (ret)
  972. return ret;
  973. dev_set_drvdata(&pdev->dev, mdev);
  974. mdev->ilc = ipc_log_context_create(QMP_IPC_LOG_PAGE_CNT, mdev->name, 0);
  975. ret = devm_request_threaded_irq(&pdev->dev, mdev->rx_irq_line,
  976. qmp_irq_handler, qmp_thread_irq_handler,
  977. IRQF_TRIGGER_RISING,
  978. edge_node->name, (void *)mdev);
  979. if (ret < 0) {
  980. qmp_mbox_remove(pdev);
  981. QMP_ERR(mdev->ilc, "request threaded irq on %d failed: %d\n",
  982. mdev->rx_irq_line, ret);
  983. return ret;
  984. }
  985. ret = enable_irq_wake(mdev->rx_irq_line);
  986. if (ret < 0)
  987. QMP_ERR(mdev->ilc, "enable_irq_wake on %d failed: %d\n",
  988. mdev->rx_irq_line, ret);
  989. /* Trigger fake RX in case of missed interrupt */
  990. if (of_property_read_bool(edge_node, "qcom,early-boot")) {
  991. list_for_each_entry(mbox, &mdev->mboxes, list) {
  992. __qmp_rx_worker(mbox);
  993. }
  994. mdev->early_boot = true;
  995. }
  996. return 0;
  997. }
  998. static int qmp_mbox_freeze(struct device *dev)
  999. {
  1000. return 0;
  1001. }
  1002. static int qmp_mbox_restore(struct device *dev)
  1003. {
  1004. struct qmp_device *mdev = dev_get_drvdata(dev);
  1005. struct qmp_mbox *mbox;
  1006. list_for_each_entry(mbox, &mdev->mboxes, list) {
  1007. mbox->local_state = LINK_DISCONNECTED;
  1008. init_completion(&mbox->link_complete);
  1009. init_completion(&mbox->ch_complete);
  1010. mbox->tx_sent = false;
  1011. /*
  1012. * set suspend flag to indicate self channel open is required
  1013. * after restore operation
  1014. */
  1015. mbox->suspend_flag = true;
  1016. /* Release rx packet buffer */
  1017. kfree(mbox->rx_pkt.data);
  1018. mbox->rx_pkt.data = NULL;
  1019. if (mdev->early_boot)
  1020. __qmp_rx_worker(mbox);
  1021. }
  1022. return 0;
  1023. }
  1024. static const struct dev_pm_ops qmp_mbox_pm_ops = {
  1025. .freeze_late = qmp_mbox_freeze,
  1026. .restore_early = qmp_mbox_restore,
  1027. };
  1028. static const struct of_device_id qmp_mbox_dt_match[] = {
  1029. { .compatible = "qcom,qmp-mbox" },
  1030. {},
  1031. };
  1032. static struct platform_driver qmp_mbox_driver = {
  1033. .driver = {
  1034. .name = "qmp_mbox",
  1035. .of_match_table = qmp_mbox_dt_match,
  1036. .pm = &qmp_mbox_pm_ops,
  1037. },
  1038. .probe = qmp_mbox_probe,
  1039. .remove = qmp_mbox_remove,
  1040. };
  1041. module_platform_driver(qmp_mbox_driver);
  1042. MODULE_DESCRIPTION("MSM QTI Mailbox Protocol");
  1043. MODULE_LICENSE("GPL v2");