core.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * drivers/mfd/mfd-core.h
  3. *
  4. * core MFD support
  5. * Copyright (c) 2006 Ian Molton
  6. * Copyright (c) 2007 Dmitry Baryshkov
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #ifndef MFD_CORE_H
  14. #define MFD_CORE_H
  15. #include <linux/platform_device.h>
  16. /*
  17. * This struct describes the MFD part ("cell").
  18. * After registration the copy of this structure will become the platform data
  19. * of the resulting platform_device
  20. */
  21. struct mfd_cell {
  22. const char *name;
  23. int id;
  24. int (*enable)(struct platform_device *dev);
  25. int (*disable)(struct platform_device *dev);
  26. int (*suspend)(struct platform_device *dev);
  27. int (*resume)(struct platform_device *dev);
  28. /* driver-specific data for MFD-aware "cell" drivers */
  29. void *driver_data;
  30. /* mfd_data can be used to pass data to client drivers */
  31. void *mfd_data;
  32. /*
  33. * These resources can be specified relative to the parent device.
  34. * For accessing hardware you should use resources from the platform dev
  35. */
  36. int num_resources;
  37. const struct resource *resources;
  38. /* don't check for resource conflicts */
  39. bool ignore_resource_conflicts;
  40. /*
  41. * Disable runtime PM callbacks for this subdevice - see
  42. * pm_runtime_no_callbacks().
  43. */
  44. bool pm_runtime_no_callbacks;
  45. };
  46. /*
  47. * Given a platform device that's been created by mfd_add_devices(), fetch
  48. * the mfd_cell that created it.
  49. */
  50. static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
  51. {
  52. return pdev->dev.platform_data;
  53. }
  54. /*
  55. * Given a platform device that's been created by mfd_add_devices(), fetch
  56. * the .mfd_data entry from the mfd_cell that created it.
  57. */
  58. static inline void *mfd_get_data(struct platform_device *pdev)
  59. {
  60. return mfd_get_cell(pdev)->mfd_data;
  61. }
  62. extern int mfd_add_devices(struct device *parent, int id,
  63. const struct mfd_cell *cells, int n_devs,
  64. struct resource *mem_base,
  65. int irq_base);
  66. extern void mfd_remove_devices(struct device *parent);
  67. #endif