hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/mfd/core.h
....@@ -1,20 +1,53 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * drivers/mfd/mfd-core.h
34 *
45 * core MFD support
56 * Copyright (c) 2006 Ian Molton
67 * 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
- *
128 */
139
1410 #ifndef MFD_CORE_H
1511 #define MFD_CORE_H
1612
1713 #include <linux/platform_device.h>
14
+
15
+#define MFD_RES_SIZE(arr) (sizeof(arr) / sizeof(struct resource))
16
+
17
+#define MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg, _use_of_reg, _match) \
18
+ { \
19
+ .name = (_name), \
20
+ .resources = (_res), \
21
+ .num_resources = MFD_RES_SIZE((_res)), \
22
+ .platform_data = (_pdata), \
23
+ .pdata_size = (_pdsize), \
24
+ .of_compatible = (_compat), \
25
+ .of_reg = (_of_reg), \
26
+ .use_of_reg = (_use_of_reg), \
27
+ .acpi_match = (_match), \
28
+ .id = (_id), \
29
+ }
30
+
31
+#define OF_MFD_CELL_REG(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg) \
32
+ MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg, true, NULL)
33
+
34
+#define OF_MFD_CELL(_name, _res, _pdata, _pdsize, _id, _compat) \
35
+ MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, 0, false, NULL)
36
+
37
+#define ACPI_MFD_CELL(_name, _res, _pdata, _pdsize, _id, _match) \
38
+ MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, NULL, 0, false, _match)
39
+
40
+#define MFD_CELL_BASIC(_name, _res, _pdata, _pdsize, _id) \
41
+ MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, NULL, 0, false, NULL)
42
+
43
+#define MFD_CELL_RES(_name, _res) \
44
+ MFD_CELL_ALL(_name, _res, NULL, 0, 0, NULL, 0, false, NULL)
45
+
46
+#define MFD_CELL_NAME(_name) \
47
+ MFD_CELL_ALL(_name, NULL, NULL, 0, 0, NULL, 0, false, NULL)
48
+
49
+#define MFD_DEP_LEVEL_NORMAL 0
50
+#define MFD_DEP_LEVEL_HIGH 1
1851
1952 struct irq_domain;
2053 struct property_entry;
....@@ -33,9 +66,8 @@
3366 struct mfd_cell {
3467 const char *name;
3568 int id;
69
+ int level;
3670
37
- /* refcounting for multiple drivers to use a single cell */
38
- atomic_t *usage_count;
3971 int (*enable)(struct platform_device *dev);
4072 int (*disable)(struct platform_device *dev);
4173
....@@ -47,13 +79,23 @@
4779 size_t pdata_size;
4880
4981 /* device properties passed to the sub devices drivers */
50
- struct property_entry *properties;
82
+ const struct property_entry *properties;
5183
5284 /*
5385 * Device Tree compatible string
54
- * See: Documentation/devicetree/usage-model.txt Chapter 2.2 for details
86
+ * See: Documentation/devicetree/usage-model.rst Chapter 2.2 for details
5587 */
5688 const char *of_compatible;
89
+
90
+ /*
91
+ * Address as defined in Device Tree. Used to compement 'of_compatible'
92
+ * (above) when matching OF nodes with devices that have identical
93
+ * compatible strings
94
+ */
95
+ const u64 of_reg;
96
+
97
+ /* Set to 'true' to use 'of_reg' (above) - allows for of_reg=0 */
98
+ bool use_of_reg;
5799
58100 /* Matches ACPI */
59101 const struct mfd_cell_acpi_match *acpi_match;
....@@ -91,24 +133,6 @@
91133 extern int mfd_cell_disable(struct platform_device *pdev);
92134
93135 /*
94
- * "Clone" multiple platform devices for a single cell. This is to be used
95
- * for devices that have multiple users of a cell. For example, if an mfd
96
- * driver wants the cell "foo" to be used by a GPIO driver, an MTD driver,
97
- * and a platform driver, the following bit of code would be use after first
98
- * calling mfd_add_devices():
99
- *
100
- * const char *fclones[] = { "foo-gpio", "foo-mtd" };
101
- * err = mfd_clone_cells("foo", fclones, ARRAY_SIZE(fclones));
102
- *
103
- * Each driver (MTD, GPIO, and platform driver) would then register
104
- * platform_drivers for "foo-mtd", "foo-gpio", and "foo", respectively.
105
- * The cell's .enable/.disable hooks should be used to deal with hardware
106
- * resource contention.
107
- */
108
-extern int mfd_clone_cell(const char *cell, const char **clones,
109
- size_t n_clones);
110
-
111
-/*
112136 * Given a platform device that's been created by mfd_add_devices(), fetch
113137 * the mfd_cell that created it.
114138 */
....@@ -130,6 +154,7 @@
130154 }
131155
132156 extern void mfd_remove_devices(struct device *parent);
157
+extern void mfd_remove_devices_late(struct device *parent);
133158
134159 extern int devm_mfd_add_devices(struct device *dev, int id,
135160 const struct mfd_cell *cells, int n_devs,