hwspinlock.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * OMAP hardware spinlock device initialization
  3. *
  4. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
  5. *
  6. * Contact: Simon Que <sque@ti.com>
  7. * Hari Kanigeri <h-kanigeri2@ti.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/err.h>
  21. #include <plat/omap_hwmod.h>
  22. #include <plat/omap_device.h>
  23. struct omap_device_pm_latency omap_spinlock_latency[] = {
  24. {
  25. .deactivate_func = omap_device_idle_hwmods,
  26. .activate_func = omap_device_enable_hwmods,
  27. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  28. }
  29. };
  30. int __init hwspinlocks_init(void)
  31. {
  32. int retval = 0;
  33. struct omap_hwmod *oh;
  34. struct omap_device *od;
  35. const char *oh_name = "spinlock";
  36. const char *dev_name = "omap_hwspinlock";
  37. /*
  38. * Hwmod lookup will fail in case our platform doesn't support the
  39. * hardware spinlock module, so it is safe to run this initcall
  40. * on all omaps
  41. */
  42. oh = omap_hwmod_lookup(oh_name);
  43. if (oh == NULL)
  44. return -EINVAL;
  45. od = omap_device_build(dev_name, 0, oh, NULL, 0,
  46. omap_spinlock_latency,
  47. ARRAY_SIZE(omap_spinlock_latency), false);
  48. if (IS_ERR(od)) {
  49. pr_err("Can't build omap_device for %s:%s\n", dev_name,
  50. oh_name);
  51. retval = PTR_ERR(od);
  52. }
  53. return retval;
  54. }
  55. /* early board code might need to reserve specific hwspinlock instances */
  56. postcore_initcall(hwspinlocks_init);