gpr-lite.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /* Copyright (c) 2011-2017, 2019-2021 The Linux Foundation. All rights reserved.
  2. * Copyright (c) 2018, Linaro Limited
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 and
  7. * only version 2 as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/device.h>
  17. #include <linux/spinlock.h>
  18. #include <linux/idr.h>
  19. #include <linux/slab.h>
  20. #include <linux/of_device.h>
  21. #include <ipc/gpr-lite.h>
  22. #include <linux/rpmsg.h>
  23. #include <linux/of.h>
  24. #include <soc/snd_event.h>
  25. #include <dsp/audio_notifier.h>
  26. #define APM_EVENT_MODULE_TO_CLIENT 0x03001000
  27. #define WAKELOCK_TIMEOUT 200
  28. struct gpr {
  29. struct rpmsg_endpoint *ch;
  30. struct device *dev;
  31. spinlock_t gpr_lock;
  32. bool is_initial_boot;
  33. spinlock_t svcs_lock;
  34. struct idr svcs_idr;
  35. int dest_domain_id;
  36. struct work_struct notifier_reg_work;
  37. struct wakeup_source *wsource;
  38. };
  39. static struct gpr_q6 q6;
  40. static struct gpr *gpr_priv;
  41. enum gpr_subsys_state gpr_get_q6_state(void)
  42. {
  43. return atomic_read(&q6.q6_state);
  44. }
  45. EXPORT_SYMBOL(gpr_get_q6_state);
  46. enum gpr_subsys_state gpr_get_modem_state(void)
  47. {
  48. return atomic_read(&q6.modem_state);
  49. }
  50. EXPORT_SYMBOL(gpr_get_modem_state);
  51. void gpr_subsys_notif_register(char *client_name, int domain,
  52. struct notifier_block *nb)
  53. {
  54. int ret;
  55. ret = audio_notifier_register(client_name, domain, nb);
  56. if (ret < 0)
  57. dev_err_ratelimited(gpr_priv->dev, "%s: Audio notifier register failed for domain %d ret = %d\n",
  58. __func__, domain, ret);
  59. }
  60. void gpr_subsys_notif_deregister(char *client_name)
  61. {
  62. int ret;
  63. ret = audio_notifier_deregister(client_name);
  64. if (ret < 0)
  65. dev_err_ratelimited(gpr_priv->dev, "%s: Audio notifier de-register failed for client %s\n",
  66. __func__, client_name);
  67. }
  68. /**
  69. * gpr_send_pkt() - Send a gpr message from gpr device
  70. *
  71. * @adev: Pointer to previously registered gpr device.
  72. * @pkt: Pointer to gpr packet to send
  73. *
  74. * Return: Will be an negative and/or packet size on success.
  75. */
  76. int gpr_send_pkt(struct gpr_device *adev, struct gpr_pkt *pkt)
  77. {
  78. struct gpr *gpr;
  79. struct gpr_hdr *hdr;
  80. unsigned long flags;
  81. uint32_t pkt_size;
  82. int ret;
  83. if(!adev)
  84. {
  85. pr_err_ratelimited("%s: enter pointer adev[%pK] \n", __func__, adev);
  86. return -EINVAL;
  87. }
  88. if(!(adev->dev.parent))
  89. {
  90. pr_err_ratelimited("%s: enter pointer adev->dev.parent[%pK] \n",
  91. __func__, adev->dev.parent);
  92. return -EINVAL;
  93. }
  94. gpr = dev_get_drvdata(adev->dev.parent);
  95. if ((adev->domain_id == GPR_DOMAIN_ADSP) &&
  96. (gpr_get_q6_state() != GPR_SUBSYS_LOADED)) {
  97. dev_err_ratelimited(gpr->dev, "%s: domain_id[%d], Still Dsp is not Up\n",
  98. __func__, adev->domain_id);
  99. return -ENETRESET;
  100. } else if ((adev->domain_id == GPR_DOMAIN_MODEM) &&
  101. (gpr_get_modem_state() == GPR_SUBSYS_DOWN)) {
  102. dev_err_ratelimited(gpr->dev, "%s: domain_id[%d], Still Modem is not Up\n",
  103. __func__, adev->domain_id );
  104. return -ENETRESET;
  105. }
  106. spin_lock_irqsave(&adev->lock, flags);
  107. hdr = &pkt->hdr;
  108. hdr->dst_domain_id = adev->domain_id;
  109. pkt_size = GPR_PKT_GET_PACKET_BYTE_SIZE(hdr->header);
  110. dev_dbg(gpr->dev, "SVC_ID %d %s packet size %d\n",
  111. adev->svc_id, __func__, pkt_size);
  112. ret = rpmsg_trysend(gpr->ch, pkt, pkt_size);
  113. spin_unlock_irqrestore(&adev->lock, flags);
  114. return ret ? ret : pkt_size;
  115. }
  116. EXPORT_SYMBOL_GPL(gpr_send_pkt);
  117. /**
  118. * apr_set_modem_state - Update modem load status.
  119. *
  120. * @state: State to update modem load status
  121. *
  122. */
  123. void gpr_set_modem_state(enum gpr_subsys_state state)
  124. {
  125. atomic_set(&q6.modem_state, state);
  126. }
  127. EXPORT_SYMBOL(gpr_set_modem_state);
  128. static void gpr_modem_down(unsigned long opcode)
  129. {
  130. gpr_set_modem_state(GPR_SUBSYS_DOWN);
  131. //dispatch_event(opcode, APR_DEST_MODEM);
  132. }
  133. static void gpr_modem_up(void)
  134. {
  135. //if (apr_cmpxchg_modem_state(APR_SUBSYS_DOWN, APR_SUBSYS_UP) ==
  136. // APR_SUBSYS_DOWN)
  137. // wake_up(&modem_wait);
  138. //is_modem_up = 1;
  139. }
  140. int gpr_set_q6_state(enum gpr_subsys_state state)
  141. {
  142. dev_dbg(gpr_priv->dev,"%s: setting adsp state %d\n", __func__, state);
  143. if (state < GPR_SUBSYS_DOWN || state > GPR_SUBSYS_LOADED)
  144. return -EINVAL;
  145. atomic_set(&q6.q6_state, state);
  146. return 0;
  147. }
  148. EXPORT_SYMBOL(gpr_set_q6_state);
  149. static void gpr_ssr_disable(struct device *dev, void *data)
  150. {
  151. gpr_set_q6_state(GPR_SUBSYS_DOWN);
  152. }
  153. static const struct snd_event_ops gpr_ssr_ops = {
  154. .disable = gpr_ssr_disable,
  155. };
  156. static void gpr_adsp_down(unsigned long opcode)
  157. {
  158. dev_info_ratelimited(gpr_priv->dev, "%s: Q6 is Down\n", __func__);
  159. gpr_set_q6_state(GPR_SUBSYS_DOWN);
  160. snd_event_notify(gpr_priv->dev, SND_EVENT_DOWN);
  161. }
  162. static void gpr_adsp_up(void)
  163. {
  164. dev_info_ratelimited(gpr_priv->dev, "%s: Q6 is Up\n", __func__);
  165. gpr_set_q6_state(GPR_SUBSYS_LOADED);
  166. snd_event_notify(gpr_priv->dev, SND_EVENT_UP);
  167. }
  168. static int gpr_notifier_service_cb(struct notifier_block *this,
  169. unsigned long opcode, void *data)
  170. {
  171. struct audio_notifier_cb_data *cb_data = data;
  172. if (cb_data == NULL) {
  173. dev_err_ratelimited(gpr_priv->dev, "%s: Callback data is NULL!\n", __func__);
  174. goto done;
  175. }
  176. dev_dbg(gpr_priv->dev,"%s: Service opcode 0x%lx, domain %d\n",
  177. __func__, opcode, cb_data->domain);
  178. switch (opcode) {
  179. case AUDIO_NOTIFIER_SERVICE_DOWN:
  180. /*
  181. * Use flag to ignore down notifications during
  182. * initial boot. There is no benefit from error
  183. * recovery notifications during initial boot
  184. * up since everything is expected to be down.
  185. */
  186. spin_lock(&gpr_priv->gpr_lock);
  187. if (gpr_priv->is_initial_boot) {
  188. spin_unlock(&gpr_priv->gpr_lock);
  189. break;
  190. }
  191. spin_unlock(&gpr_priv->gpr_lock);
  192. if (cb_data->domain == AUDIO_NOTIFIER_MODEM_DOMAIN)
  193. gpr_modem_down(opcode);
  194. else
  195. gpr_adsp_down(opcode);
  196. break;
  197. case AUDIO_NOTIFIER_SERVICE_UP:
  198. if (cb_data->domain == AUDIO_NOTIFIER_MODEM_DOMAIN)
  199. gpr_modem_up();
  200. else
  201. gpr_adsp_up();
  202. spin_lock(&gpr_priv->gpr_lock);
  203. gpr_priv->is_initial_boot = false;
  204. spin_unlock(&gpr_priv->gpr_lock);
  205. break;
  206. default:
  207. break;
  208. }
  209. done:
  210. return NOTIFY_OK;
  211. }
  212. static struct notifier_block adsp_service_nb = {
  213. .notifier_call = gpr_notifier_service_cb,
  214. .priority = 0,
  215. };
  216. static struct notifier_block modem_service_nb = {
  217. .notifier_call = gpr_notifier_service_cb,
  218. .priority = 0,
  219. };
  220. static void gpr_dev_release(struct device *dev)
  221. {
  222. struct gpr_device *adev = to_gpr_device(dev);
  223. kfree(adev);
  224. }
  225. static int gpr_callback(struct rpmsg_device *rpdev, void *buf,
  226. int len, void *priv, u32 addr)
  227. {
  228. struct gpr *gpr = dev_get_drvdata(&rpdev->dev);
  229. uint16_t hdr_size, pkt_size, svc_id;
  230. //uint16_t ver;
  231. struct gpr_device *svc = NULL;
  232. struct gpr_driver *adrv = NULL;
  233. struct gpr_hdr *hdr;
  234. unsigned long flags;
  235. //uint32_t opcode_type;
  236. if (len <= GPR_HDR_SIZE) {
  237. dev_err_ratelimited(gpr->dev, "GPR: Improper gpr pkt received:%p %d\n",
  238. buf, len);
  239. return -EINVAL;
  240. }
  241. hdr = buf;
  242. hdr_size = GPR_PKT_GET_HEADER_BYTE_SIZE(hdr->header);
  243. if (hdr_size < GPR_HDR_SIZE) {
  244. dev_err_ratelimited(gpr->dev, "GPR: Wrong hdr size:%d\n", hdr_size);
  245. return -EINVAL;
  246. }
  247. pkt_size = GPR_PKT_GET_PACKET_BYTE_SIZE(hdr->header);
  248. dev_dbg(gpr->dev,"Header %x", hdr->header);
  249. if (pkt_size < GPR_HDR_SIZE || pkt_size != len) {
  250. dev_err_ratelimited(gpr->dev, "GPR: Wrong packet size\n");
  251. return -EINVAL;
  252. }
  253. dev_dbg(gpr->dev, "%s: dst_port %x hdr_size %d pkt_size %d\n",
  254. __func__ , hdr->dst_port, hdr_size, pkt_size);
  255. if (hdr->opcode == APM_EVENT_MODULE_TO_CLIENT) {
  256. dev_err(gpr->dev, "%s: Acquire wakelock in case of module event with timeout %d",
  257. __func__, WAKELOCK_TIMEOUT);
  258. pm_wakeup_ws_event(gpr_priv->wsource, WAKELOCK_TIMEOUT, true);
  259. }
  260. svc_id = hdr->dst_port;
  261. spin_lock_irqsave(&gpr->svcs_lock, flags);
  262. svc = idr_find(&gpr->svcs_idr, svc_id);
  263. if (svc && svc->dev.driver) {
  264. adrv = to_gpr_driver(svc->dev.driver);
  265. } else {
  266. /*Does not match any SVC ID hence would be routed to audio passthrough*/
  267. svc = idr_find(&gpr->svcs_idr, GPR_SVC_MAX);
  268. if (svc && svc->dev.driver)
  269. adrv = to_gpr_driver(svc->dev.driver);
  270. }
  271. spin_unlock_irqrestore(&gpr->svcs_lock, flags);
  272. if (!adrv) {
  273. dev_err_ratelimited(gpr->dev, "GPR: service is not registered\n");
  274. if (hdr->opcode == APM_EVENT_MODULE_TO_CLIENT)
  275. __pm_relax(gpr_priv->wsource);
  276. return -EINVAL;
  277. }
  278. /*
  279. * NOTE: hdr_size is not same as GPR_HDR_SIZE as remote can include
  280. * optional headers in to gpr_hdr which should be ignored
  281. */
  282. adrv->callback(svc, buf);
  283. return 0;
  284. }
  285. static int gpr_device_match(struct device *dev, struct device_driver *drv)
  286. {
  287. struct gpr_device *adev = to_gpr_device(dev);
  288. struct gpr_driver *adrv = to_gpr_driver(drv);
  289. const struct gpr_device_id *id = adrv->id_table;
  290. /* Attempt an OF style match first */
  291. if (of_driver_match_device(dev, drv))
  292. return 1;
  293. if (!id)
  294. return 0;
  295. while (id->domain_id != 0 || id->svc_id != 0) {
  296. if (id->domain_id == adev->domain_id &&
  297. id->svc_id == adev->svc_id)
  298. return 1;
  299. id++;
  300. }
  301. return 0;
  302. }
  303. static int gpr_device_probe(struct device *dev)
  304. {
  305. struct gpr_device *adev = to_gpr_device(dev);
  306. struct gpr_driver *adrv = to_gpr_driver(dev->driver);
  307. return adrv->probe(adev);
  308. }
  309. static void gpr_device_remove(struct device *dev)
  310. {
  311. struct gpr_device *adev = to_gpr_device(dev);
  312. struct gpr_driver *adrv;
  313. struct gpr *gpr = dev_get_drvdata(adev->dev.parent);
  314. if (dev->driver) {
  315. adrv = to_gpr_driver(dev->driver);
  316. if (adrv->remove)
  317. adrv->remove(adev);
  318. spin_lock(&gpr->svcs_lock);
  319. idr_remove(&gpr->svcs_idr, adev->svc_id);
  320. spin_unlock(&gpr->svcs_lock);
  321. }
  322. return;
  323. }
  324. static int gpr_uevent(struct device *dev, struct kobj_uevent_env *env)
  325. {
  326. struct gpr_device *adev = to_gpr_device(dev);
  327. int ret;
  328. ret = of_device_uevent_modalias(dev, env);
  329. if (ret != -ENODEV)
  330. return ret;
  331. return add_uevent_var(env, "MODALIAS=gpr:%s", adev->name);
  332. }
  333. struct bus_type gprbus = {
  334. .name = "gprbus",
  335. .match = gpr_device_match,
  336. .probe = gpr_device_probe,
  337. .uevent = gpr_uevent,
  338. .remove = gpr_device_remove,
  339. };
  340. EXPORT_SYMBOL_GPL(gprbus);
  341. static int gpr_add_device(struct device *dev, struct device_node *np,
  342. const struct gpr_device_id *id)
  343. {
  344. struct gpr *gpr = dev_get_drvdata(dev);
  345. struct gpr_device *adev = NULL;
  346. int ret;
  347. adev = kzalloc(sizeof(*adev), GFP_KERNEL);
  348. if (!adev)
  349. return -ENOMEM;
  350. spin_lock_init(&adev->lock);
  351. adev->svc_id = id->svc_id;
  352. adev->domain_id = id->domain_id;
  353. adev->version = id->svc_version;
  354. if (np)
  355. strscpy(adev->name, np->name, GPR_NAME_SIZE);
  356. else
  357. strscpy(adev->name, id->name, GPR_NAME_SIZE);
  358. dev_set_name(&adev->dev, "gprsvc:%s:%x:%x", adev->name,
  359. id->domain_id, id->svc_id);
  360. adev->dev.bus = &gprbus;
  361. adev->dev.parent = dev;
  362. adev->dev.of_node = np;
  363. adev->dev.release = gpr_dev_release;
  364. adev->dev.driver = NULL;
  365. spin_lock(&gpr->svcs_lock);
  366. idr_alloc(&gpr->svcs_idr, adev, id->svc_id,
  367. id->svc_id + 1, GFP_ATOMIC);
  368. spin_unlock(&gpr->svcs_lock);
  369. dev_info_ratelimited(dev, "Adding GPR dev: %s\n", dev_name(&adev->dev));
  370. ret = device_register(&adev->dev);
  371. if (ret) {
  372. dev_err_ratelimited(dev, "device_register failed: %d\n", ret);
  373. put_device(&adev->dev);
  374. }
  375. return ret;
  376. }
  377. static void of_register_gpr_devices(struct device *dev)
  378. {
  379. struct gpr *gpr = dev_get_drvdata(dev);
  380. struct device_node *node;
  381. for_each_child_of_node(dev->of_node, node) {
  382. struct gpr_device_id id = { {0} };
  383. if (of_property_read_u32(node, "reg", &id.svc_id))
  384. continue;
  385. id.domain_id = gpr->dest_domain_id;
  386. if (gpr_add_device(dev, node, &id))
  387. dev_err_ratelimited(dev, "Failed to add gpr %d svc\n", id.svc_id);
  388. }
  389. }
  390. static void gpr_notifier_register(struct work_struct *work)
  391. {
  392. if (GPR_DOMAIN_ADSP == gpr_priv->dest_domain_id) {
  393. gpr_subsys_notif_register("gpr_adsp",
  394. AUDIO_NOTIFIER_ADSP_DOMAIN,
  395. &adsp_service_nb);
  396. } else if (GPR_DOMAIN_MODEM == gpr_priv->dest_domain_id) {
  397. gpr_subsys_notif_register("gpr_modem",
  398. AUDIO_NOTIFIER_MODEM_DOMAIN,
  399. &modem_service_nb);
  400. }
  401. dev_info_ratelimited(gpr_priv->dev,
  402. "%s: registered via subsys_notif_register for domain id(%d)",
  403. __func__, gpr_priv->dest_domain_id );
  404. return;
  405. }
  406. static int gpr_probe(struct rpmsg_device *rpdev)
  407. {
  408. struct device *dev = &rpdev->dev;
  409. int ret;
  410. if (!audio_notifier_probe_status()) {
  411. pr_err("%s: Audio notify probe not completed, defer audio gpr probe\n",
  412. __func__);
  413. return -EPROBE_DEFER;
  414. }
  415. gpr_priv = devm_kzalloc(dev, sizeof(*gpr_priv), GFP_KERNEL);
  416. if (!gpr_priv)
  417. return -ENOMEM;
  418. spin_lock_init(&gpr_priv->gpr_lock);
  419. mutex_init(&q6.lock);
  420. spin_lock(&gpr_priv->gpr_lock);
  421. gpr_priv->is_initial_boot = true;
  422. spin_unlock(&gpr_priv->gpr_lock);
  423. dev_set_drvdata(dev, gpr_priv);
  424. gpr_priv->ch = rpdev->ept;
  425. gpr_priv->dev = dev;
  426. spin_lock_init(&gpr_priv->svcs_lock);
  427. idr_init(&gpr_priv->svcs_idr);
  428. ret = snd_event_client_register(&rpdev->dev, &gpr_ssr_ops, NULL);
  429. if (ret) {
  430. dev_err(dev,"%s: Registration with SND event fwk failed ret = %d\n",
  431. __func__, ret);
  432. ret = 0;
  433. }
  434. ret = of_property_read_u32(dev->of_node, "reg", &gpr_priv->dest_domain_id);
  435. if (ret) {
  436. dev_err(dev, "GPR Domain ID not specified in DT\n");
  437. return ret;
  438. }
  439. of_register_gpr_devices(dev);
  440. INIT_WORK(&gpr_priv->notifier_reg_work, gpr_notifier_register);
  441. if (GPR_DOMAIN_ADSP == gpr_priv->dest_domain_id ||
  442. GPR_DOMAIN_MODEM == gpr_priv->dest_domain_id) {
  443. schedule_work(&gpr_priv->notifier_reg_work);
  444. } else {
  445. dev_err(dev, "%s: invalid dest_domain_id %s\n", __func__,
  446. gpr_priv->dest_domain_id);
  447. return -EINVAL;
  448. }
  449. gpr_priv->wsource = wakeup_source_register(gpr_priv->dev, "audio-gpr");
  450. dev_info(dev, "%s: gpr-lite probe success\n",
  451. __func__);
  452. return 0;
  453. }
  454. static int gpr_remove_device(struct device *dev, void *null)
  455. {
  456. struct gpr_device *adev = to_gpr_device(dev);
  457. device_unregister(&adev->dev);
  458. return 0;
  459. }
  460. static void gpr_remove(struct rpmsg_device *rpdev)
  461. {
  462. struct device *dev = &rpdev->dev;
  463. wakeup_source_unregister(gpr_priv->wsource);
  464. snd_event_client_deregister(&rpdev->dev);
  465. dev_info(dev, "%s: deregistering via subsys_notif_register for domain_id(%d)",
  466. __func__, gpr_priv->dest_domain_id );
  467. if (GPR_DOMAIN_ADSP == gpr_priv->dest_domain_id)
  468. {
  469. gpr_subsys_notif_deregister("gpr_adsp");
  470. }
  471. else if(GPR_DOMAIN_MODEM == gpr_priv->dest_domain_id)
  472. {
  473. gpr_subsys_notif_deregister("gpr_modem");
  474. }
  475. device_for_each_child(&rpdev->dev, NULL, gpr_remove_device);
  476. }
  477. /*
  478. * __gpr_driver_register() - Client driver registration with gprbus
  479. *
  480. * @drv:Client driver to be associated with client-device.
  481. * @owner: owning module/driver
  482. *
  483. * This API will register the client driver with the gprbus
  484. * It is called from the driver's module-init function.
  485. */
  486. int __gpr_driver_register(struct gpr_driver *drv, struct module *owner)
  487. {
  488. drv->driver.bus = &gprbus;
  489. drv->driver.owner = owner;
  490. return driver_register(&drv->driver);
  491. }
  492. EXPORT_SYMBOL_GPL(__gpr_driver_register);
  493. /*
  494. * gpr_driver_unregister() - Undo effect of gpr_driver_register
  495. *
  496. * @drv: Client driver to be unregistered
  497. */
  498. void gpr_driver_unregister(struct gpr_driver *drv)
  499. {
  500. driver_unregister(&drv->driver);
  501. }
  502. EXPORT_SYMBOL_GPL(gpr_driver_unregister);
  503. static const struct of_device_id gpr_of_match[] = {
  504. { .compatible = "qcom,gpr"},
  505. {}
  506. };
  507. MODULE_DEVICE_TABLE(of, gpr_of_match);
  508. static struct rpmsg_driver gpr_driver = {
  509. .probe = gpr_probe,
  510. .remove = gpr_remove,
  511. .callback = gpr_callback,
  512. .drv = {
  513. .name = "qcom,gpr",
  514. .of_match_table = gpr_of_match,
  515. },
  516. };
  517. static int __init gpr_init(void)
  518. {
  519. int ret;
  520. ret = bus_register(&gprbus);
  521. if (!ret)
  522. ret = register_rpmsg_driver(&gpr_driver);
  523. else
  524. bus_unregister(&gprbus);
  525. return ret;
  526. }
  527. static void __exit gpr_exit(void)
  528. {
  529. bus_unregister(&gprbus);
  530. unregister_rpmsg_driver(&gpr_driver);
  531. }
  532. subsys_initcall(gpr_init);
  533. module_exit(gpr_exit);
  534. MODULE_LICENSE("GPL v2");
  535. MODULE_DESCRIPTION("QTI GPR Bus");