bus.c 17 KB

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