1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * drivers/mfd/mfd-core.h
6 * Copyright (c) 2006 Ian Molton
7 * Copyright (c) 2007 Dmitry Baryshkov
13 #include <linux/platform_device.h>
16 struct property_entry;
18 /* Matches ACPI PNP id, either _HID or _CID, or ACPI _ADR */
19 struct mfd_cell_acpi_match {
21 const unsigned long long adr;
25 * This struct describes the MFD part ("cell").
26 * After registration the copy of this structure will become the platform data
27 * of the resulting platform_device
33 /* refcounting for multiple drivers to use a single cell */
34 atomic_t *usage_count;
35 int (*enable)(struct platform_device *dev);
36 int (*disable)(struct platform_device *dev);
38 int (*suspend)(struct platform_device *dev);
39 int (*resume)(struct platform_device *dev);
41 /* platform data passed to the sub devices drivers */
45 /* device properties passed to the sub devices drivers */
46 struct property_entry *properties;
49 * Device Tree compatible string
50 * See: Documentation/devicetree/usage-model.txt Chapter 2.2 for details
52 const char *of_compatible;
55 const struct mfd_cell_acpi_match *acpi_match;
58 * These resources can be specified relative to the parent device.
59 * For accessing hardware you should use resources from the platform dev
62 const struct resource *resources;
64 /* don't check for resource conflicts */
65 bool ignore_resource_conflicts;
68 * Disable runtime PM callbacks for this subdevice - see
69 * pm_runtime_no_callbacks().
71 bool pm_runtime_no_callbacks;
73 /* A list of regulator supplies that should be mapped to the MFD
74 * device rather than the child device when requested
76 const char * const *parent_supplies;
77 int num_parent_supplies;
81 * Convenience functions for clients using shared cells. Refcounting
82 * happens automatically, with the cell's enable/disable callbacks
83 * being called only when a device is first being enabled or no other
84 * clients are making use of it.
86 extern int mfd_cell_enable(struct platform_device *pdev);
87 extern int mfd_cell_disable(struct platform_device *pdev);
90 * "Clone" multiple platform devices for a single cell. This is to be used
91 * for devices that have multiple users of a cell. For example, if an mfd
92 * driver wants the cell "foo" to be used by a GPIO driver, an MTD driver,
93 * and a platform driver, the following bit of code would be use after first
94 * calling mfd_add_devices():
96 * const char *fclones[] = { "foo-gpio", "foo-mtd" };
97 * err = mfd_clone_cells("foo", fclones, ARRAY_SIZE(fclones));
99 * Each driver (MTD, GPIO, and platform driver) would then register
100 * platform_drivers for "foo-mtd", "foo-gpio", and "foo", respectively.
101 * The cell's .enable/.disable hooks should be used to deal with hardware
102 * resource contention.
104 extern int mfd_clone_cell(const char *cell, const char **clones,
108 * Given a platform device that's been created by mfd_add_devices(), fetch
109 * the mfd_cell that created it.
111 static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
113 return pdev->mfd_cell;
116 extern int mfd_add_devices(struct device *parent, int id,
117 const struct mfd_cell *cells, int n_devs,
118 struct resource *mem_base,
119 int irq_base, struct irq_domain *irq_domain);
121 static inline int mfd_add_hotplug_devices(struct device *parent,
122 const struct mfd_cell *cells, int n_devs)
124 return mfd_add_devices(parent, PLATFORM_DEVID_AUTO, cells, n_devs,
128 extern void mfd_remove_devices(struct device *parent);
130 extern int devm_mfd_add_devices(struct device *dev, int id,
131 const struct mfd_cell *cells, int n_devs,
132 struct resource *mem_base,
133 int irq_base, struct irq_domain *irq_domain);