.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * drivers/mfd/mfd-core.h |
---|
3 | 4 | * |
---|
4 | 5 | * core MFD support |
---|
5 | 6 | * Copyright (c) 2006 Ian Molton |
---|
6 | 7 | * 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 | 8 | */ |
---|
13 | 9 | |
---|
14 | 10 | #ifndef MFD_CORE_H |
---|
15 | 11 | #define MFD_CORE_H |
---|
16 | 12 | |
---|
17 | 13 | #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 |
---|
18 | 51 | |
---|
19 | 52 | struct irq_domain; |
---|
20 | 53 | struct property_entry; |
---|
.. | .. |
---|
33 | 66 | struct mfd_cell { |
---|
34 | 67 | const char *name; |
---|
35 | 68 | int id; |
---|
| 69 | + int level; |
---|
36 | 70 | |
---|
37 | | - /* refcounting for multiple drivers to use a single cell */ |
---|
38 | | - atomic_t *usage_count; |
---|
39 | 71 | int (*enable)(struct platform_device *dev); |
---|
40 | 72 | int (*disable)(struct platform_device *dev); |
---|
41 | 73 | |
---|
.. | .. |
---|
47 | 79 | size_t pdata_size; |
---|
48 | 80 | |
---|
49 | 81 | /* device properties passed to the sub devices drivers */ |
---|
50 | | - struct property_entry *properties; |
---|
| 82 | + const struct property_entry *properties; |
---|
51 | 83 | |
---|
52 | 84 | /* |
---|
53 | 85 | * 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 |
---|
55 | 87 | */ |
---|
56 | 88 | 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; |
---|
57 | 99 | |
---|
58 | 100 | /* Matches ACPI */ |
---|
59 | 101 | const struct mfd_cell_acpi_match *acpi_match; |
---|
.. | .. |
---|
91 | 133 | extern int mfd_cell_disable(struct platform_device *pdev); |
---|
92 | 134 | |
---|
93 | 135 | /* |
---|
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 | | -/* |
---|
112 | 136 | * Given a platform device that's been created by mfd_add_devices(), fetch |
---|
113 | 137 | * the mfd_cell that created it. |
---|
114 | 138 | */ |
---|
.. | .. |
---|
130 | 154 | } |
---|
131 | 155 | |
---|
132 | 156 | extern void mfd_remove_devices(struct device *parent); |
---|
| 157 | +extern void mfd_remove_devices_late(struct device *parent); |
---|
133 | 158 | |
---|
134 | 159 | extern int devm_mfd_add_devices(struct device *dev, int id, |
---|
135 | 160 | const struct mfd_cell *cells, int n_devs, |
---|