1
2
3
4
5
6
7
8
9
10#ifndef MFD_CORE_H
11#define MFD_CORE_H
12
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 MFD_CELL_OF_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 MFD_CELL_OF(_name, _res, _pdata, _pdsize, _id, _compat) \
35 MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, 0, false, NULL)
36
37#define MFD_CELL_ACPI(_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
51
52struct irq_domain;
53struct software_node;
54
55
56struct mfd_cell_acpi_match {
57 const char *pnpid;
58 const unsigned long long adr;
59};
60
61
62
63
64
65
66struct mfd_cell {
67 const char *name;
68 int id;
69 int level;
70
71 int (*enable)(struct platform_device *dev);
72 int (*disable)(struct platform_device *dev);
73
74 int (*suspend)(struct platform_device *dev);
75 int (*resume)(struct platform_device *dev);
76
77
78 void *platform_data;
79 size_t pdata_size;
80
81
82 const struct software_node *swnode;
83
84
85
86
87
88 const char *of_compatible;
89
90
91
92
93
94
95 const u64 of_reg;
96
97
98 bool use_of_reg;
99
100
101 const struct mfd_cell_acpi_match *acpi_match;
102
103
104
105
106
107 int num_resources;
108 const struct resource *resources;
109
110
111 bool ignore_resource_conflicts;
112
113
114
115
116
117 bool pm_runtime_no_callbacks;
118
119
120
121
122 const char * const *parent_supplies;
123 int num_parent_supplies;
124};
125
126
127
128
129
130
131
132extern int mfd_cell_enable(struct platform_device *pdev);
133extern int mfd_cell_disable(struct platform_device *pdev);
134
135
136
137
138
139static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
140{
141 return pdev->mfd_cell;
142}
143
144extern int mfd_add_devices(struct device *parent, int id,
145 const struct mfd_cell *cells, int n_devs,
146 struct resource *mem_base,
147 int irq_base, struct irq_domain *irq_domain);
148
149static inline int mfd_add_hotplug_devices(struct device *parent,
150 const struct mfd_cell *cells, int n_devs)
151{
152 return mfd_add_devices(parent, PLATFORM_DEVID_AUTO, cells, n_devs,
153 NULL, 0, NULL);
154}
155
156extern void mfd_remove_devices(struct device *parent);
157extern void mfd_remove_devices_late(struct device *parent);
158
159extern int devm_mfd_add_devices(struct device *dev, int id,
160 const struct mfd_cell *cells, int n_devs,
161 struct resource *mem_base,
162 int irq_base, struct irq_domain *irq_domain);
163#endif
164