omap_device.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * omap_device headers
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. * Paul Walmsley
  6. *
  7. * Developed in collaboration with (alphabetical order): Benoit
  8. * Cousson, Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram
  9. * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard
  10. * Woodruff
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. *
  16. * This type of functionality should be implemented as a proper
  17. * omap_bus/omap_device in Linux.
  18. *
  19. * omap_device differs from omap_hwmod in that it includes external
  20. * (e.g., board- and system-level) integration details. omap_hwmod
  21. * stores hardware data that is invariant for a given OMAP chip.
  22. */
  23. #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
  24. #define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
  25. #include <linux/kernel.h>
  26. #include <linux/platform_device.h>
  27. #include "omap_hwmod.h"
  28. extern struct dev_pm_domain omap_device_pm_domain;
  29. extern struct dev_pm_domain omap_device_fail_pm_domain;
  30. /* omap_device._state values */
  31. #define OMAP_DEVICE_STATE_UNKNOWN 0
  32. #define OMAP_DEVICE_STATE_ENABLED 1
  33. #define OMAP_DEVICE_STATE_IDLE 2
  34. #define OMAP_DEVICE_STATE_SHUTDOWN 3
  35. /* omap_device.flags values */
  36. #define OMAP_DEVICE_SUSPENDED BIT(0)
  37. /**
  38. * struct omap_device - omap_device wrapper for platform_devices
  39. * @pdev: platform_device
  40. * @hwmods: (one .. many per omap_device)
  41. * @hwmods_cnt: ARRAY_SIZE() of @hwmods
  42. * @_state: one of OMAP_DEVICE_STATE_* (see above)
  43. * @flags: device flags
  44. * @_driver_status: one of BUS_NOTIFY_*_DRIVER from <linux/device.h>
  45. *
  46. * Integrates omap_hwmod data into Linux platform_device.
  47. *
  48. * Field names beginning with underscores are for the internal use of
  49. * the omap_device code.
  50. *
  51. */
  52. struct omap_device {
  53. struct platform_device *pdev;
  54. struct omap_hwmod **hwmods;
  55. unsigned long _driver_status;
  56. u8 hwmods_cnt;
  57. u8 _state;
  58. u8 flags;
  59. };
  60. /* Device driver interface (call via platform_data fn ptrs) */
  61. int omap_device_enable(struct platform_device *pdev);
  62. int omap_device_idle(struct platform_device *pdev);
  63. /* Core code interface */
  64. struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
  65. struct omap_hwmod *oh, void *pdata,
  66. int pdata_len);
  67. struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
  68. struct omap_hwmod **oh, int oh_cnt,
  69. void *pdata, int pdata_len);
  70. struct omap_device *omap_device_alloc(struct platform_device *pdev,
  71. struct omap_hwmod **ohs, int oh_cnt);
  72. void omap_device_delete(struct omap_device *od);
  73. int omap_device_register(struct platform_device *pdev);
  74. struct device *omap_device_get_by_hwmod_name(const char *oh_name);
  75. /* OMAP PM interface */
  76. int omap_device_get_context_loss_count(struct platform_device *pdev);
  77. /* Other */
  78. int omap_device_assert_hardreset(struct platform_device *pdev,
  79. const char *name);
  80. int omap_device_deassert_hardreset(struct platform_device *pdev,
  81. const char *name);
  82. /* Get omap_device pointer from platform_device pointer */
  83. static inline struct omap_device *to_omap_device(struct platform_device *pdev)
  84. {
  85. return pdev ? pdev->archdata.od : NULL;
  86. }
  87. #endif