2 * drivers/mfd/mfd-core.h
5 * Copyright (c) 2006 Ian Molton
6 * Copyright (c) 2007 Dmitry Baryshkov
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.
17 #include <linux/platform_device.h>
20 * This struct describes the MFD part ("cell").
21 * After registration the copy of this structure will become the platform data
22 * of the resulting platform_device
28 /* refcounting for multiple drivers to use a single cell */
29 atomic_t *usage_count;
30 int (*enable)(struct platform_device *dev);
31 int (*disable)(struct platform_device *dev);
33 int (*suspend)(struct platform_device *dev);
34 int (*resume)(struct platform_device *dev);
36 /* mfd_data can be used to pass data to client drivers */
40 * These resources can be specified relative to the parent device.
41 * For accessing hardware you should use resources from the platform dev
44 const struct resource *resources;
46 /* don't check for resource conflicts */
47 bool ignore_resource_conflicts;
50 * Disable runtime PM callbacks for this subdevice - see
51 * pm_runtime_no_callbacks().
53 bool pm_runtime_no_callbacks;
57 * Convenience functions for clients using shared cells. Refcounting
58 * happens automatically, with the cell's enable/disable callbacks
59 * being called only when a device is first being enabled or no other
60 * clients are making use of it.
62 extern int mfd_cell_enable(struct platform_device *pdev);
63 extern int mfd_cell_disable(struct platform_device *pdev);
66 * Given a platform device that's been created by mfd_add_devices(), fetch
67 * the mfd_cell that created it.
69 static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
71 return pdev->dev.platform_data;
75 * Given a platform device that's been created by mfd_add_devices(), fetch
76 * the .mfd_data entry from the mfd_cell that created it.
78 static inline void *mfd_get_data(struct platform_device *pdev)
80 return mfd_get_cell(pdev)->mfd_data;
83 extern int mfd_add_devices(struct device *parent, int id,
84 struct mfd_cell *cells, int n_devs,
85 struct resource *mem_base,
88 extern void mfd_remove_devices(struct device *parent);
91 * For MFD drivers with clients sharing access to resources, these create
92 * multiple platform devices per cell. Contention handling must still be
93 * handled via drivers (ie, with enable/disable hooks).
95 extern int mfd_shared_platform_driver_register(struct platform_driver *drv,
96 const char *cellname);
97 extern void mfd_shared_platform_driver_unregister(struct platform_driver *drv);