0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef MFD_CORE_H
0011 #define MFD_CORE_H
0012
0013 #include <linux/platform_device.h>
0014
0015 #define MFD_RES_SIZE(arr) (sizeof(arr) / sizeof(struct resource))
0016
0017 #define MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg, _use_of_reg, _match) \
0018 { \
0019 .name = (_name), \
0020 .resources = (_res), \
0021 .num_resources = MFD_RES_SIZE((_res)), \
0022 .platform_data = (_pdata), \
0023 .pdata_size = (_pdsize), \
0024 .of_compatible = (_compat), \
0025 .of_reg = (_of_reg), \
0026 .use_of_reg = (_use_of_reg), \
0027 .acpi_match = (_match), \
0028 .id = (_id), \
0029 }
0030
0031 #define MFD_CELL_OF_REG(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg) \
0032 MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg, true, NULL)
0033
0034 #define MFD_CELL_OF(_name, _res, _pdata, _pdsize, _id, _compat) \
0035 MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, 0, false, NULL)
0036
0037 #define MFD_CELL_ACPI(_name, _res, _pdata, _pdsize, _id, _match) \
0038 MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, NULL, 0, false, _match)
0039
0040 #define MFD_CELL_BASIC(_name, _res, _pdata, _pdsize, _id) \
0041 MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, NULL, 0, false, NULL)
0042
0043 #define MFD_CELL_RES(_name, _res) \
0044 MFD_CELL_ALL(_name, _res, NULL, 0, 0, NULL, 0, false, NULL)
0045
0046 #define MFD_CELL_NAME(_name) \
0047 MFD_CELL_ALL(_name, NULL, NULL, 0, 0, NULL, 0, false, NULL)
0048
0049 #define MFD_DEP_LEVEL_NORMAL 0
0050 #define MFD_DEP_LEVEL_HIGH 1
0051
0052 struct irq_domain;
0053 struct software_node;
0054
0055
0056 struct mfd_cell_acpi_match {
0057 const char *pnpid;
0058 const unsigned long long adr;
0059 };
0060
0061
0062
0063
0064
0065
0066 struct mfd_cell {
0067 const char *name;
0068 int id;
0069 int level;
0070
0071 int (*enable)(struct platform_device *dev);
0072 int (*disable)(struct platform_device *dev);
0073
0074 int (*suspend)(struct platform_device *dev);
0075 int (*resume)(struct platform_device *dev);
0076
0077
0078 void *platform_data;
0079 size_t pdata_size;
0080
0081
0082 const struct software_node *swnode;
0083
0084
0085
0086
0087
0088 const char *of_compatible;
0089
0090
0091
0092
0093
0094
0095 const u64 of_reg;
0096
0097
0098 bool use_of_reg;
0099
0100
0101 const struct mfd_cell_acpi_match *acpi_match;
0102
0103
0104
0105
0106
0107 int num_resources;
0108 const struct resource *resources;
0109
0110
0111 bool ignore_resource_conflicts;
0112
0113
0114
0115
0116
0117 bool pm_runtime_no_callbacks;
0118
0119
0120
0121
0122 const char * const *parent_supplies;
0123 int num_parent_supplies;
0124 };
0125
0126
0127
0128
0129
0130
0131
0132 extern int mfd_cell_enable(struct platform_device *pdev);
0133 extern int mfd_cell_disable(struct platform_device *pdev);
0134
0135
0136
0137
0138
0139 static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
0140 {
0141 return pdev->mfd_cell;
0142 }
0143
0144 extern int mfd_add_devices(struct device *parent, int id,
0145 const struct mfd_cell *cells, int n_devs,
0146 struct resource *mem_base,
0147 int irq_base, struct irq_domain *irq_domain);
0148
0149 static inline int mfd_add_hotplug_devices(struct device *parent,
0150 const struct mfd_cell *cells, int n_devs)
0151 {
0152 return mfd_add_devices(parent, PLATFORM_DEVID_AUTO, cells, n_devs,
0153 NULL, 0, NULL);
0154 }
0155
0156 extern void mfd_remove_devices(struct device *parent);
0157 extern void mfd_remove_devices_late(struct device *parent);
0158
0159 extern int devm_mfd_add_devices(struct device *dev, int id,
0160 const struct mfd_cell *cells, int n_devs,
0161 struct resource *mem_base,
0162 int irq_base, struct irq_domain *irq_domain);
0163 #endif