bus.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/common/amba.c
  4. *
  5. * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
  6. */
  7. #include <linux/module.h>
  8. #include <linux/init.h>
  9. #include <linux/device.h>
  10. #include <linux/string.h>
  11. #include <linux/slab.h>
  12. #include <linux/io.h>
  13. #include <linux/pm.h>
  14. #include <linux/pm_runtime.h>
  15. #include <linux/pm_domain.h>
  16. #include <linux/amba/bus.h>
  17. #include <linux/sizes.h>
  18. #include <linux/limits.h>
  19. #include <linux/clk/clk-conf.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/property.h>
  22. #include <linux/reset.h>
  23. #include <linux/of_irq.h>
  24. #include <linux/of_device.h>
  25. #include <linux/acpi.h>
  26. #include <linux/iommu.h>
  27. #include <linux/dma-map-ops.h>
  28. #define to_amba_driver(d) container_of_const(d, struct amba_driver, drv)
  29. /* called on periphid match and class 0x9 coresight device. */
  30. static int
  31. amba_cs_uci_id_match(const struct amba_id *table, struct amba_device *dev)
  32. {
  33. int ret = 0;
  34. struct amba_cs_uci_id *uci;
  35. uci = table->data;
  36. /* no table data or zero mask - return match on periphid */
  37. if (!uci || (uci->devarch_mask == 0))
  38. return 1;
  39. /* test against read devtype and masked devarch value */
  40. ret = (dev->uci.devtype == uci->devtype) &&
  41. ((dev->uci.devarch & uci->devarch_mask) == uci->devarch);
  42. return ret;
  43. }
  44. static const struct amba_id *
  45. amba_lookup(const struct amba_id *table, struct amba_device *dev)
  46. {
  47. while (table->mask) {
  48. if (((dev->periphid & table->mask) == table->id) &&
  49. ((dev->cid != CORESIGHT_CID) ||
  50. (amba_cs_uci_id_match(table, dev))))
  51. return table;
  52. table++;
  53. }
  54. return NULL;
  55. }
  56. static int amba_get_enable_pclk(struct amba_device *pcdev)
  57. {
  58. int ret;
  59. pcdev->pclk = clk_get(&pcdev->dev, "apb_pclk");
  60. if (IS_ERR(pcdev->pclk))
  61. return PTR_ERR(pcdev->pclk);
  62. ret = clk_prepare_enable(pcdev->pclk);
  63. if (ret)
  64. clk_put(pcdev->pclk);
  65. return ret;
  66. }
  67. static void amba_put_disable_pclk(struct amba_device *pcdev)
  68. {
  69. clk_disable_unprepare(pcdev->pclk);
  70. clk_put(pcdev->pclk);
  71. }
  72. static ssize_t driver_override_show(struct device *_dev,
  73. struct device_attribute *attr, char *buf)
  74. {
  75. struct amba_device *dev = to_amba_device(_dev);
  76. ssize_t len;
  77. device_lock(_dev);
  78. len = sprintf(buf, "%s\n", dev->driver_override);
  79. device_unlock(_dev);
  80. return len;
  81. }
  82. static ssize_t driver_override_store(struct device *_dev,
  83. struct device_attribute *attr,
  84. const char *buf, size_t count)
  85. {
  86. struct amba_device *dev = to_amba_device(_dev);
  87. int ret;
  88. ret = driver_set_override(_dev, &dev->driver_override, buf, count);
  89. if (ret)
  90. return ret;
  91. return count;
  92. }
  93. static DEVICE_ATTR_RW(driver_override);
  94. #define amba_attr_func(name,fmt,arg...) \
  95. static ssize_t name##_show(struct device *_dev, \
  96. struct device_attribute *attr, char *buf) \
  97. { \
  98. struct amba_device *dev = to_amba_device(_dev); \
  99. return sprintf(buf, fmt, arg); \
  100. } \
  101. static DEVICE_ATTR_RO(name)
  102. amba_attr_func(id, "%08x\n", dev->periphid);
  103. amba_attr_func(resource, "\t%016llx\t%016llx\t%016lx\n",
  104. (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
  105. dev->res.flags);
  106. static struct attribute *amba_dev_attrs[] = {
  107. &dev_attr_id.attr,
  108. &dev_attr_resource.attr,
  109. &dev_attr_driver_override.attr,
  110. NULL,
  111. };
  112. ATTRIBUTE_GROUPS(amba_dev);
  113. static int amba_read_periphid(struct amba_device *dev)
  114. {
  115. struct reset_control *rstc;
  116. u32 size, pid, cid;
  117. void __iomem *tmp;
  118. int i, ret;
  119. ret = dev_pm_domain_attach(&dev->dev, PD_FLAG_ATTACH_POWER_ON);
  120. if (ret) {
  121. dev_dbg(&dev->dev, "can't get PM domain: %d\n", ret);
  122. goto err_out;
  123. }
  124. ret = amba_get_enable_pclk(dev);
  125. if (ret) {
  126. dev_dbg(&dev->dev, "can't get pclk: %d\n", ret);
  127. goto err_pm;
  128. }
  129. /*
  130. * Find reset control(s) of the amba bus and de-assert them.
  131. */
  132. rstc = of_reset_control_array_get_optional_shared(dev->dev.of_node);
  133. if (IS_ERR(rstc)) {
  134. ret = PTR_ERR(rstc);
  135. if (ret != -EPROBE_DEFER)
  136. dev_err(&dev->dev, "can't get reset: %d\n", ret);
  137. goto err_clk;
  138. }
  139. reset_control_deassert(rstc);
  140. reset_control_put(rstc);
  141. size = resource_size(&dev->res);
  142. tmp = ioremap(dev->res.start, size);
  143. if (!tmp) {
  144. ret = -ENOMEM;
  145. goto err_clk;
  146. }
  147. /*
  148. * Read pid and cid based on size of resource
  149. * they are located at end of region
  150. */
  151. for (pid = 0, i = 0; i < 4; i++)
  152. pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) << (i * 8);
  153. for (cid = 0, i = 0; i < 4; i++)
  154. cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) << (i * 8);
  155. if (cid == CORESIGHT_CID) {
  156. /* set the base to the start of the last 4k block */
  157. void __iomem *csbase = tmp + size - 4096;
  158. dev->uci.devarch = readl(csbase + UCI_REG_DEVARCH_OFFSET);
  159. dev->uci.devtype = readl(csbase + UCI_REG_DEVTYPE_OFFSET) & 0xff;
  160. }
  161. if (cid == AMBA_CID || cid == CORESIGHT_CID) {
  162. dev->periphid = pid;
  163. dev->cid = cid;
  164. }
  165. if (!dev->periphid)
  166. ret = -ENODEV;
  167. iounmap(tmp);
  168. err_clk:
  169. amba_put_disable_pclk(dev);
  170. err_pm:
  171. dev_pm_domain_detach(&dev->dev, true);
  172. err_out:
  173. return ret;
  174. }
  175. static int amba_match(struct device *dev, const struct device_driver *drv)
  176. {
  177. struct amba_device *pcdev = to_amba_device(dev);
  178. const struct amba_driver *pcdrv = to_amba_driver(drv);
  179. mutex_lock(&pcdev->periphid_lock);
  180. if (!pcdev->periphid) {
  181. int ret = amba_read_periphid(pcdev);
  182. /*
  183. * Returning any error other than -EPROBE_DEFER from bus match
  184. * can cause driver registration failure. So, if there's a
  185. * permanent failure in reading pid and cid, simply map it to
  186. * -EPROBE_DEFER.
  187. */
  188. if (ret) {
  189. mutex_unlock(&pcdev->periphid_lock);
  190. return -EPROBE_DEFER;
  191. }
  192. dev_set_uevent_suppress(dev, false);
  193. kobject_uevent(&dev->kobj, KOBJ_ADD);
  194. }
  195. mutex_unlock(&pcdev->periphid_lock);
  196. /* When driver_override is set, only bind to the matching driver */
  197. if (pcdev->driver_override)
  198. return !strcmp(pcdev->driver_override, drv->name);
  199. return amba_lookup(pcdrv->id_table, pcdev) != NULL;
  200. }
  201. static int amba_uevent(const struct device *dev, struct kobj_uevent_env *env)
  202. {
  203. const struct amba_device *pcdev = to_amba_device(dev);
  204. int retval = 0;
  205. retval = add_uevent_var(env, "AMBA_ID=%08x", pcdev->periphid);
  206. if (retval)
  207. return retval;
  208. retval = add_uevent_var(env, "MODALIAS=amba:d%08X", pcdev->periphid);
  209. return retval;
  210. }
  211. static int of_amba_device_decode_irq(struct amba_device *dev)
  212. {
  213. struct device_node *node = dev->dev.of_node;
  214. int i, irq = 0;
  215. if (IS_ENABLED(CONFIG_OF_IRQ) && node) {
  216. /* Decode the IRQs and address ranges */
  217. for (i = 0; i < AMBA_NR_IRQS; i++) {
  218. irq = of_irq_get(node, i);
  219. if (irq < 0) {
  220. if (irq == -EPROBE_DEFER)
  221. return irq;
  222. irq = 0;
  223. }
  224. dev->irq[i] = irq;
  225. }
  226. }
  227. return 0;
  228. }
  229. /*
  230. * These are the device model conversion veneers; they convert the
  231. * device model structures to our more specific structures.
  232. */
  233. static int amba_probe(struct device *dev)
  234. {
  235. struct amba_device *pcdev = to_amba_device(dev);
  236. struct amba_driver *pcdrv = to_amba_driver(dev->driver);
  237. const struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev);
  238. int ret;
  239. do {
  240. ret = of_amba_device_decode_irq(pcdev);
  241. if (ret)
  242. break;
  243. ret = of_clk_set_defaults(dev->of_node, false);
  244. if (ret < 0)
  245. break;
  246. ret = dev_pm_domain_attach(dev, PD_FLAG_ATTACH_POWER_ON |
  247. PD_FLAG_DETACH_POWER_OFF);
  248. if (ret)
  249. break;
  250. ret = amba_get_enable_pclk(pcdev);
  251. if (ret)
  252. break;
  253. pm_runtime_get_noresume(dev);
  254. pm_runtime_set_active(dev);
  255. pm_runtime_enable(dev);
  256. ret = pcdrv->probe(pcdev, id);
  257. if (ret == 0)
  258. break;
  259. pm_runtime_disable(dev);
  260. pm_runtime_set_suspended(dev);
  261. pm_runtime_put_noidle(dev);
  262. amba_put_disable_pclk(pcdev);
  263. } while (0);
  264. return ret;
  265. }
  266. static void amba_remove(struct device *dev)
  267. {
  268. struct amba_device *pcdev = to_amba_device(dev);
  269. struct amba_driver *drv = to_amba_driver(dev->driver);
  270. pm_runtime_get_sync(dev);
  271. if (drv->remove)
  272. drv->remove(pcdev);
  273. pm_runtime_put_noidle(dev);
  274. /* Undo the runtime PM settings in amba_probe() */
  275. pm_runtime_disable(dev);
  276. pm_runtime_set_suspended(dev);
  277. pm_runtime_put_noidle(dev);
  278. amba_put_disable_pclk(pcdev);
  279. }
  280. static void amba_shutdown(struct device *dev)
  281. {
  282. struct amba_driver *drv;
  283. if (!dev->driver)
  284. return;
  285. drv = to_amba_driver(dev->driver);
  286. if (drv->shutdown)
  287. drv->shutdown(to_amba_device(dev));
  288. }
  289. static int amba_dma_configure(struct device *dev)
  290. {
  291. struct amba_driver *drv = to_amba_driver(dev->driver);
  292. enum dev_dma_attr attr;
  293. int ret = 0;
  294. if (dev->of_node) {
  295. ret = of_dma_configure(dev, dev->of_node, true);
  296. } else if (has_acpi_companion(dev)) {
  297. attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
  298. ret = acpi_dma_configure(dev, attr);
  299. }
  300. /* @drv may not be valid when we're called from the IOMMU layer */
  301. if (!ret && dev->driver && !drv->driver_managed_dma) {
  302. ret = iommu_device_use_default_domain(dev);
  303. if (ret)
  304. arch_teardown_dma_ops(dev);
  305. }
  306. return ret;
  307. }
  308. static void amba_dma_cleanup(struct device *dev)
  309. {
  310. struct amba_driver *drv = to_amba_driver(dev->driver);
  311. if (!drv->driver_managed_dma)
  312. iommu_device_unuse_default_domain(dev);
  313. }
  314. #ifdef CONFIG_PM
  315. /*
  316. * Hooks to provide runtime PM of the pclk (bus clock). It is safe to
  317. * enable/disable the bus clock at runtime PM suspend/resume as this
  318. * does not result in loss of context.
  319. */
  320. static int amba_pm_runtime_suspend(struct device *dev)
  321. {
  322. struct amba_device *pcdev = to_amba_device(dev);
  323. int ret = pm_generic_runtime_suspend(dev);
  324. if (ret == 0 && dev->driver) {
  325. if (pm_runtime_is_irq_safe(dev))
  326. clk_disable(pcdev->pclk);
  327. else
  328. clk_disable_unprepare(pcdev->pclk);
  329. }
  330. return ret;
  331. }
  332. static int amba_pm_runtime_resume(struct device *dev)
  333. {
  334. struct amba_device *pcdev = to_amba_device(dev);
  335. int ret;
  336. if (dev->driver) {
  337. if (pm_runtime_is_irq_safe(dev))
  338. ret = clk_enable(pcdev->pclk);
  339. else
  340. ret = clk_prepare_enable(pcdev->pclk);
  341. /* Failure is probably fatal to the system, but... */
  342. if (ret)
  343. return ret;
  344. }
  345. return pm_generic_runtime_resume(dev);
  346. }
  347. #endif /* CONFIG_PM */
  348. static const struct dev_pm_ops amba_pm = {
  349. SET_RUNTIME_PM_OPS(
  350. amba_pm_runtime_suspend,
  351. amba_pm_runtime_resume,
  352. NULL
  353. )
  354. };
  355. /*
  356. * Primecells are part of the Advanced Microcontroller Bus Architecture,
  357. * so we call the bus "amba".
  358. * DMA configuration for platform and AMBA bus is same. So here we reuse
  359. * platform's DMA config routine.
  360. */
  361. const struct bus_type amba_bustype = {
  362. .name = "amba",
  363. .dev_groups = amba_dev_groups,
  364. .match = amba_match,
  365. .uevent = amba_uevent,
  366. .probe = amba_probe,
  367. .remove = amba_remove,
  368. .shutdown = amba_shutdown,
  369. .dma_configure = amba_dma_configure,
  370. .dma_cleanup = amba_dma_cleanup,
  371. .pm = &amba_pm,
  372. };
  373. EXPORT_SYMBOL_GPL(amba_bustype);
  374. bool dev_is_amba(const struct device *dev)
  375. {
  376. return dev->bus == &amba_bustype;
  377. }
  378. EXPORT_SYMBOL_GPL(dev_is_amba);
  379. static int __init amba_init(void)
  380. {
  381. return bus_register(&amba_bustype);
  382. }
  383. postcore_initcall(amba_init);
  384. static int amba_proxy_probe(struct amba_device *adev,
  385. const struct amba_id *id)
  386. {
  387. WARN(1, "Stub driver should never match any device.\n");
  388. return -ENODEV;
  389. }
  390. static const struct amba_id amba_stub_drv_ids[] = {
  391. { 0, 0 },
  392. };
  393. static struct amba_driver amba_proxy_drv = {
  394. .drv = {
  395. .name = "amba-proxy",
  396. },
  397. .probe = amba_proxy_probe,
  398. .id_table = amba_stub_drv_ids,
  399. };
  400. static int __init amba_stub_drv_init(void)
  401. {
  402. if (!IS_ENABLED(CONFIG_MODULES))
  403. return 0;
  404. /*
  405. * The amba_match() function will get called only if there is at least
  406. * one amba driver registered. If all amba drivers are modules and are
  407. * only loaded based on uevents, then we'll hit a chicken-and-egg
  408. * situation where amba_match() is waiting on drivers and drivers are
  409. * waiting on amba_match(). So, register a stub driver to make sure
  410. * amba_match() is called even if no amba driver has been registered.
  411. */
  412. return __amba_driver_register(&amba_proxy_drv, NULL);
  413. }
  414. late_initcall_sync(amba_stub_drv_init);
  415. /**
  416. * __amba_driver_register - register an AMBA device driver
  417. * @drv: amba device driver structure
  418. * @owner: owning module/driver
  419. *
  420. * Register an AMBA device driver with the Linux device model
  421. * core. If devices pre-exist, the drivers probe function will
  422. * be called.
  423. */
  424. int __amba_driver_register(struct amba_driver *drv,
  425. struct module *owner)
  426. {
  427. if (!drv->probe)
  428. return -EINVAL;
  429. drv->drv.owner = owner;
  430. drv->drv.bus = &amba_bustype;
  431. return driver_register(&drv->drv);
  432. }
  433. EXPORT_SYMBOL(__amba_driver_register);
  434. /**
  435. * amba_driver_unregister - remove an AMBA device driver
  436. * @drv: AMBA device driver structure to remove
  437. *
  438. * Unregister an AMBA device driver from the Linux device
  439. * model. The device model will call the drivers remove function
  440. * for each device the device driver is currently handling.
  441. */
  442. void amba_driver_unregister(struct amba_driver *drv)
  443. {
  444. driver_unregister(&drv->drv);
  445. }
  446. EXPORT_SYMBOL(amba_driver_unregister);
  447. static void amba_device_release(struct device *dev)
  448. {
  449. struct amba_device *d = to_amba_device(dev);
  450. fwnode_handle_put(dev_fwnode(&d->dev));
  451. if (d->res.parent)
  452. release_resource(&d->res);
  453. mutex_destroy(&d->periphid_lock);
  454. kfree(d);
  455. }
  456. /**
  457. * amba_device_add - add a previously allocated AMBA device structure
  458. * @dev: AMBA device allocated by amba_device_alloc
  459. * @parent: resource parent for this devices resources
  460. *
  461. * Claim the resource, and read the device cell ID if not already
  462. * initialized. Register the AMBA device with the Linux device
  463. * manager.
  464. */
  465. int amba_device_add(struct amba_device *dev, struct resource *parent)
  466. {
  467. int ret;
  468. fwnode_handle_get(dev_fwnode(&dev->dev));
  469. ret = request_resource(parent, &dev->res);
  470. if (ret)
  471. return ret;
  472. /* If primecell ID isn't hard-coded, figure it out */
  473. if (!dev->periphid) {
  474. /*
  475. * AMBA device uevents require reading its pid and cid
  476. * registers. To do this, the device must be on, clocked and
  477. * out of reset. However in some cases those resources might
  478. * not yet be available. If that's the case, we suppress the
  479. * generation of uevents until we can read the pid and cid
  480. * registers. See also amba_match().
  481. */
  482. if (amba_read_periphid(dev))
  483. dev_set_uevent_suppress(&dev->dev, true);
  484. }
  485. ret = device_add(&dev->dev);
  486. if (ret)
  487. release_resource(&dev->res);
  488. return ret;
  489. }
  490. EXPORT_SYMBOL_GPL(amba_device_add);
  491. static void amba_device_initialize(struct amba_device *dev, const char *name)
  492. {
  493. device_initialize(&dev->dev);
  494. if (name)
  495. dev_set_name(&dev->dev, "%s", name);
  496. dev->dev.release = amba_device_release;
  497. dev->dev.bus = &amba_bustype;
  498. dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
  499. dev->dev.dma_parms = &dev->dma_parms;
  500. dev->res.name = dev_name(&dev->dev);
  501. mutex_init(&dev->periphid_lock);
  502. }
  503. /**
  504. * amba_device_alloc - allocate an AMBA device
  505. * @name: sysfs name of the AMBA device
  506. * @base: base of AMBA device
  507. * @size: size of AMBA device
  508. *
  509. * Allocate and initialize an AMBA device structure. Returns %NULL
  510. * on failure.
  511. */
  512. struct amba_device *amba_device_alloc(const char *name, resource_size_t base,
  513. size_t size)
  514. {
  515. struct amba_device *dev;
  516. dev = kzalloc_obj(*dev);
  517. if (dev) {
  518. amba_device_initialize(dev, name);
  519. dev->res.start = base;
  520. dev->res.end = base + size - 1;
  521. dev->res.flags = IORESOURCE_MEM;
  522. }
  523. return dev;
  524. }
  525. EXPORT_SYMBOL_GPL(amba_device_alloc);
  526. /**
  527. * amba_device_register - register an AMBA device
  528. * @dev: AMBA device to register
  529. * @parent: parent memory resource
  530. *
  531. * Setup the AMBA device, reading the cell ID if present.
  532. * Claim the resource, and register the AMBA device with
  533. * the Linux device manager.
  534. */
  535. int amba_device_register(struct amba_device *dev, struct resource *parent)
  536. {
  537. amba_device_initialize(dev, dev->dev.init_name);
  538. dev->dev.init_name = NULL;
  539. return amba_device_add(dev, parent);
  540. }
  541. EXPORT_SYMBOL(amba_device_register);
  542. /**
  543. * amba_device_put - put an AMBA device
  544. * @dev: AMBA device to put
  545. */
  546. void amba_device_put(struct amba_device *dev)
  547. {
  548. put_device(&dev->dev);
  549. }
  550. EXPORT_SYMBOL_GPL(amba_device_put);
  551. /**
  552. * amba_device_unregister - unregister an AMBA device
  553. * @dev: AMBA device to remove
  554. *
  555. * Remove the specified AMBA device from the Linux device
  556. * manager. All files associated with this object will be
  557. * destroyed, and device drivers notified that the device has
  558. * been removed. The AMBA device's resources including
  559. * the amba_device structure will be freed once all
  560. * references to it have been dropped.
  561. */
  562. void amba_device_unregister(struct amba_device *dev)
  563. {
  564. device_unregister(&dev->dev);
  565. }
  566. EXPORT_SYMBOL(amba_device_unregister);
  567. /**
  568. * amba_request_regions - request all mem regions associated with device
  569. * @dev: amba_device structure for device
  570. * @name: name, or NULL to use driver name
  571. */
  572. int amba_request_regions(struct amba_device *dev, const char *name)
  573. {
  574. int ret = 0;
  575. u32 size;
  576. if (!name)
  577. name = dev->dev.driver->name;
  578. size = resource_size(&dev->res);
  579. if (!request_mem_region(dev->res.start, size, name))
  580. ret = -EBUSY;
  581. return ret;
  582. }
  583. EXPORT_SYMBOL(amba_request_regions);
  584. /**
  585. * amba_release_regions - release mem regions associated with device
  586. * @dev: amba_device structure for device
  587. *
  588. * Release regions claimed by a successful call to amba_request_regions.
  589. */
  590. void amba_release_regions(struct amba_device *dev)
  591. {
  592. u32 size;
  593. size = resource_size(&dev->res);
  594. release_mem_region(dev->res.start, size);
  595. }
  596. EXPORT_SYMBOL(amba_release_regions);