core.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /* mfd_data can be used to pass data to client drivers */
  29. void *mfd_data;
  30. /*
  31. * These resources can be specified relative to the parent device.
  32. * For accessing hardware you should use resources from the platform dev
  33. */
  34. int num_resources;
  35. const struct resource *resources;
  36. /* don't check for resource conflicts */
  37. bool ignore_resource_conflicts;
  38. /*
  39. * Disable runtime PM callbacks for this subdevice - see
  40. * pm_runtime_no_callbacks().
  41. */
  42. bool pm_runtime_no_callbacks;
  43. };
  44. /*
  45. * Given a platform device that's been created by mfd_add_devices(), fetch
  46. * the mfd_cell that created it.
  47. */
  48. static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
  49. {
  50. return pdev->dev.platform_data;
  51. }
  52. /*
  53. * Given a platform device that's been created by mfd_add_devices(), fetch
  54. * the .mfd_data entry from the mfd_cell that created it.
  55. */
  56. static inline void *mfd_get_data(struct platform_device *pdev)
  57. {
  58. return mfd_get_cell(pdev)->mfd_data;
  59. }
  60. extern int mfd_add_devices(struct device *parent, int id,
  61. const struct mfd_cell *cells, int n_devs,
  62. struct resource *mem_base,
  63. int irq_base);
  64. extern void mfd_remove_devices(struct device *parent);
  65. #endif