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/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, true);
  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, true);
  247. if (ret)
  248. break;
  249. ret = amba_get_enable_pclk(pcdev);
  250. if (ret) {
  251. dev_pm_domain_detach(dev, true);
  252. break;
  253. }
  254. pm_runtime_get_noresume(dev);
  255. pm_runtime_set_active(dev);
  256. pm_runtime_enable(dev);
  257. ret = pcdrv->probe(pcdev, id);
  258. if (ret == 0)
  259. break;
  260. pm_runtime_disable(dev);
  261. pm_runtime_set_suspended(dev);
  262. pm_runtime_put_noidle(dev);
  263. amba_put_disable_pclk(pcdev);
  264. dev_pm_domain_detach(dev, true);
  265. } while (0);
  266. return ret;
  267. }
  268. static void amba_remove(struct device *dev)
  269. {
  270. struct amba_device *pcdev = to_amba_device(dev);
  271. struct amba_driver *drv = to_amba_driver(dev->driver);
  272. pm_runtime_get_sync(dev);
  273. if (drv->remove)
  274. drv->remove(pcdev);
  275. pm_runtime_put_noidle(dev);
  276. /* Undo the runtime PM settings in amba_probe() */
  277. pm_runtime_disable(dev);
  278. pm_runtime_set_suspended(dev);
  279. pm_runtime_put_noidle(dev);
  280. amba_put_disable_pclk(pcdev);
  281. dev_pm_domain_detach(dev, true);
  282. }
  283. static void amba_shutdown(struct device *dev)
  284. {
  285. struct amba_driver *drv;
  286. if (!dev->driver)
  287. return;
  288. drv = to_amba_driver(dev->driver);
  289. if (drv->shutdown)
  290. drv->shutdown(to_amba_device(dev));
  291. }
  292. static int amba_dma_configure(struct device *dev)
  293. {
  294. struct amba_driver *drv = to_amba_driver(dev->driver);
  295. enum dev_dma_attr attr;
  296. int ret = 0;
  297. if (dev->of_node) {
  298. ret = of_dma_configure(dev, dev->of_node, true);
  299. } else if (has_acpi_companion(dev)) {
  300. attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
  301. ret = acpi_dma_configure(dev, attr);
  302. }
  303. if (!ret && !drv->driver_managed_dma) {
  304. ret = iommu_device_use_default_domain(dev);
  305. if (ret)
  306. arch_teardown_dma_ops(dev);
  307. }
  308. return ret;
  309. }
  310. static void amba_dma_cleanup(struct device *dev)
  311. {
  312. struct amba_driver *drv = to_amba_driver(dev->driver);
  313. if (!drv->driver_managed_dma)
  314. iommu_device_unuse_default_domain(dev);
  315. }
  316. #ifdef CONFIG_PM
  317. /*
  318. * Hooks to provide runtime PM of the pclk (bus clock). It is safe to
  319. * enable/disable the bus clock at runtime PM suspend/resume as this
  320. * does not result in loss of context.
  321. */
  322. static int amba_pm_runtime_suspend(struct device *dev)
  323. {
  324. struct amba_device *pcdev = to_amba_device(dev);
  325. int ret = pm_generic_runtime_suspend(dev);
  326. if (ret == 0 && dev->driver) {
  327. if (pm_runtime_is_irq_safe(dev))
  328. clk_disable(pcdev->pclk);
  329. else
  330. clk_disable_unprepare(pcdev->pclk);
  331. }
  332. return ret;
  333. }
  334. static int amba_pm_runtime_resume(struct device *dev)
  335. {
  336. struct amba_device *pcdev = to_amba_device(dev);
  337. int ret;
  338. if (dev->driver) {
  339. if (pm_runtime_is_irq_safe(dev))
  340. ret = clk_enable(pcdev->pclk);
  341. else
  342. ret = clk_prepare_enable(pcdev->pclk);
  343. /* Failure is probably fatal to the system, but... */
  344. if (ret)
  345. return ret;
  346. }
  347. return pm_generic_runtime_resume(dev);
  348. }
  349. #endif /* CONFIG_PM */
  350. static const struct dev_pm_ops amba_pm = {
  351. SET_RUNTIME_PM_OPS(
  352. amba_pm_runtime_suspend,
  353. amba_pm_runtime_resume,
  354. NULL
  355. )
  356. };
  357. /*
  358. * Primecells are part of the Advanced Microcontroller Bus Architecture,
  359. * so we call the bus "amba".
  360. * DMA configuration for platform and AMBA bus is same. So here we reuse
  361. * platform's DMA config routine.
  362. */
  363. const struct bus_type amba_bustype = {
  364. .name = "amba",
  365. .dev_groups = amba_dev_groups,
  366. .match = amba_match,
  367. .uevent = amba_uevent,
  368. .probe = amba_probe,
  369. .remove = amba_remove,
  370. .shutdown = amba_shutdown,
  371. .dma_configure = amba_dma_configure,
  372. .dma_cleanup = amba_dma_cleanup,
  373. .pm = &amba_pm,
  374. };
  375. EXPORT_SYMBOL_GPL(amba_bustype);
  376. static int __init amba_init(void)
  377. {
  378. return bus_register(&amba_bustype);
  379. }
  380. postcore_initcall(amba_init);
  381. static int amba_proxy_probe(struct amba_device *adev,
  382. const struct amba_id *id)
  383. {
  384. WARN(1, "Stub driver should never match any device.\n");
  385. return -ENODEV;
  386. }
  387. static const struct amba_id amba_stub_drv_ids[] = {
  388. { 0, 0 },
  389. };
  390. static struct amba_driver amba_proxy_drv = {
  391. .drv = {
  392. .name = "amba-proxy",
  393. },
  394. .probe = amba_proxy_probe,
  395. .id_table = amba_stub_drv_ids,
  396. };
  397. static int __init amba_stub_drv_init(void)
  398. {
  399. if (!IS_ENABLED(CONFIG_MODULES))
  400. return 0;
  401. /*
  402. * The amba_match() function will get called only if there is at least
  403. * one amba driver registered. If all amba drivers are modules and are
  404. * only loaded based on uevents, then we'll hit a chicken-and-egg
  405. * situation where amba_match() is waiting on drivers and drivers are
  406. * waiting on amba_match(). So, register a stub driver to make sure
  407. * amba_match() is called even if no amba driver has been registered.
  408. */
  409. return __amba_driver_register(&amba_proxy_drv, NULL);
  410. }
  411. late_initcall_sync(amba_stub_drv_init);
  412. /**
  413. * __amba_driver_register - register an AMBA device driver
  414. * @drv: amba device driver structure
  415. * @owner: owning module/driver
  416. *
  417. * Register an AMBA device driver with the Linux device model
  418. * core. If devices pre-exist, the drivers probe function will
  419. * be called.
  420. */
  421. int __amba_driver_register(struct amba_driver *drv,
  422. struct module *owner)
  423. {
  424. if (!drv->probe)
  425. return -EINVAL;
  426. drv->drv.owner = owner;
  427. drv->drv.bus = &amba_bustype;
  428. return driver_register(&drv->drv);
  429. }
  430. EXPORT_SYMBOL(__amba_driver_register);
  431. /**
  432. * amba_driver_unregister - remove an AMBA device driver
  433. * @drv: AMBA device driver structure to remove
  434. *
  435. * Unregister an AMBA device driver from the Linux device
  436. * model. The device model will call the drivers remove function
  437. * for each device the device driver is currently handling.
  438. */
  439. void amba_driver_unregister(struct amba_driver *drv)
  440. {
  441. driver_unregister(&drv->drv);
  442. }
  443. EXPORT_SYMBOL(amba_driver_unregister);
  444. static void amba_device_release(struct device *dev)
  445. {
  446. struct amba_device *d = to_amba_device(dev);
  447. fwnode_handle_put(dev_fwnode(&d->dev));
  448. if (d->res.parent)
  449. release_resource(&d->res);
  450. mutex_destroy(&d->periphid_lock);
  451. kfree(d);
  452. }
  453. /**
  454. * amba_device_add - add a previously allocated AMBA device structure
  455. * @dev: AMBA device allocated by amba_device_alloc
  456. * @parent: resource parent for this devices resources
  457. *
  458. * Claim the resource, and read the device cell ID if not already
  459. * initialized. Register the AMBA device with the Linux device
  460. * manager.
  461. */
  462. int amba_device_add(struct amba_device *dev, struct resource *parent)
  463. {
  464. int ret;
  465. fwnode_handle_get(dev_fwnode(&dev->dev));
  466. ret = request_resource(parent, &dev->res);
  467. if (ret)
  468. return ret;
  469. /* If primecell ID isn't hard-coded, figure it out */
  470. if (!dev->periphid) {
  471. /*
  472. * AMBA device uevents require reading its pid and cid
  473. * registers. To do this, the device must be on, clocked and
  474. * out of reset. However in some cases those resources might
  475. * not yet be available. If that's the case, we suppress the
  476. * generation of uevents until we can read the pid and cid
  477. * registers. See also amba_match().
  478. */
  479. if (amba_read_periphid(dev))
  480. dev_set_uevent_suppress(&dev->dev, true);
  481. }
  482. ret = device_add(&dev->dev);
  483. if (ret)
  484. release_resource(&dev->res);
  485. return ret;
  486. }
  487. EXPORT_SYMBOL_GPL(amba_device_add);
  488. static void amba_device_initialize(struct amba_device *dev, const char *name)
  489. {
  490. device_initialize(&dev->dev);
  491. if (name)
  492. dev_set_name(&dev->dev, "%s", name);
  493. dev->dev.release = amba_device_release;
  494. dev->dev.bus = &amba_bustype;
  495. dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
  496. dev->dev.dma_parms = &dev->dma_parms;
  497. dev->res.name = dev_name(&dev->dev);
  498. mutex_init(&dev->periphid_lock);
  499. }
  500. /**
  501. * amba_device_alloc - allocate an AMBA device
  502. * @name: sysfs name of the AMBA device
  503. * @base: base of AMBA device
  504. * @size: size of AMBA device
  505. *
  506. * Allocate and initialize an AMBA device structure. Returns %NULL
  507. * on failure.
  508. */
  509. struct amba_device *amba_device_alloc(const char *name, resource_size_t base,
  510. size_t size)
  511. {
  512. struct amba_device *dev;
  513. dev = kzalloc(sizeof(*dev), GFP_KERNEL);
  514. if (dev) {
  515. amba_device_initialize(dev, name);
  516. dev->res.start = base;
  517. dev->res.end = base + size - 1;
  518. dev->res.flags = IORESOURCE_MEM;
  519. }
  520. return dev;
  521. }
  522. EXPORT_SYMBOL_GPL(amba_device_alloc);
  523. /**
  524. * amba_device_register - register an AMBA device
  525. * @dev: AMBA device to register
  526. * @parent: parent memory resource
  527. *
  528. * Setup the AMBA device, reading the cell ID if present.
  529. * Claim the resource, and register the AMBA device with
  530. * the Linux device manager.
  531. */
  532. int amba_device_register(struct amba_device *dev, struct resource *parent)
  533. {
  534. amba_device_initialize(dev, dev->dev.init_name);
  535. dev->dev.init_name = NULL;
  536. return amba_device_add(dev, parent);
  537. }
  538. EXPORT_SYMBOL(amba_device_register);
  539. /**
  540. * amba_device_put - put an AMBA device
  541. * @dev: AMBA device to put
  542. */
  543. void amba_device_put(struct amba_device *dev)
  544. {
  545. put_device(&dev->dev);
  546. }
  547. EXPORT_SYMBOL_GPL(amba_device_put);
  548. /**
  549. * amba_device_unregister - unregister an AMBA device
  550. * @dev: AMBA device to remove
  551. *
  552. * Remove the specified AMBA device from the Linux device
  553. * manager. All files associated with this object will be
  554. * destroyed, and device drivers notified that the device has
  555. * been removed. The AMBA device's resources including
  556. * the amba_device structure will be freed once all
  557. * references to it have been dropped.
  558. */
  559. void amba_device_unregister(struct amba_device *dev)
  560. {
  561. device_unregister(&dev->dev);
  562. }
  563. EXPORT_SYMBOL(amba_device_unregister);
  564. /**
  565. * amba_request_regions - request all mem regions associated with device
  566. * @dev: amba_device structure for device
  567. * @name: name, or NULL to use driver name
  568. */
  569. int amba_request_regions(struct amba_device *dev, const char *name)
  570. {
  571. int ret = 0;
  572. u32 size;
  573. if (!name)
  574. name = dev->dev.driver->name;
  575. size = resource_size(&dev->res);
  576. if (!request_mem_region(dev->res.start, size, name))
  577. ret = -EBUSY;
  578. return ret;
  579. }
  580. EXPORT_SYMBOL(amba_request_regions);
  581. /**
  582. * amba_release_regions - release mem regions associated with device
  583. * @dev: amba_device structure for device
  584. *
  585. * Release regions claimed by a successful call to amba_request_regions.
  586. */
  587. void amba_release_regions(struct amba_device *dev)
  588. {
  589. u32 size;
  590. size = resource_size(&dev->res);
  591. release_mem_region(dev->res.start, size);
  592. }
  593. EXPORT_SYMBOL(amba_release_regions);