0001
0002
0003
0004
0005
0006
0007 #ifndef _RMI_BUS_H
0008 #define _RMI_BUS_H
0009
0010 #include <linux/rmi.h>
0011
0012 struct rmi_device;
0013
0014
0015
0016
0017
0018 #define RMI_FN_MAX_IRQS 6
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 struct rmi_function {
0037 struct rmi_function_descriptor fd;
0038 struct rmi_device *rmi_dev;
0039 struct device dev;
0040 struct list_head node;
0041
0042 unsigned int num_of_irqs;
0043 int irq[RMI_FN_MAX_IRQS];
0044 unsigned int irq_pos;
0045 unsigned long irq_mask[];
0046 };
0047
0048 #define to_rmi_function(d) container_of(d, struct rmi_function, dev)
0049
0050 bool rmi_is_function_device(struct device *dev);
0051
0052 int __must_check rmi_register_function(struct rmi_function *);
0053 void rmi_unregister_function(struct rmi_function *);
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 struct rmi_function_handler {
0076 struct device_driver driver;
0077
0078 u8 func;
0079
0080 int (*probe)(struct rmi_function *fn);
0081 void (*remove)(struct rmi_function *fn);
0082 int (*config)(struct rmi_function *fn);
0083 int (*reset)(struct rmi_function *fn);
0084 irqreturn_t (*attention)(int irq, void *ctx);
0085 int (*suspend)(struct rmi_function *fn);
0086 int (*resume)(struct rmi_function *fn);
0087 };
0088
0089 #define to_rmi_function_handler(d) \
0090 container_of(d, struct rmi_function_handler, driver)
0091
0092 int __must_check __rmi_register_function_handler(struct rmi_function_handler *,
0093 struct module *, const char *);
0094 #define rmi_register_function_handler(handler) \
0095 __rmi_register_function_handler(handler, THIS_MODULE, KBUILD_MODNAME)
0096
0097 void rmi_unregister_function_handler(struct rmi_function_handler *);
0098
0099 #define to_rmi_driver(d) \
0100 container_of(d, struct rmi_driver, driver)
0101
0102 #define to_rmi_device(d) container_of(d, struct rmi_device, dev)
0103
0104 static inline struct rmi_device_platform_data *
0105 rmi_get_platform_data(struct rmi_device *d)
0106 {
0107 return &d->xport->pdata;
0108 }
0109
0110 bool rmi_is_physical_device(struct device *dev);
0111
0112
0113
0114
0115
0116
0117
0118
0119 static inline int rmi_reset(struct rmi_device *d)
0120 {
0121 return d->driver->reset_handler(d);
0122 }
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 static inline int rmi_read(struct rmi_device *d, u16 addr, u8 *buf)
0135 {
0136 return d->xport->ops->read_block(d->xport, addr, buf, 1);
0137 }
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150 static inline int rmi_read_block(struct rmi_device *d, u16 addr,
0151 void *buf, size_t len)
0152 {
0153 return d->xport->ops->read_block(d->xport, addr, buf, len);
0154 }
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165 static inline int rmi_write(struct rmi_device *d, u16 addr, u8 data)
0166 {
0167 return d->xport->ops->write_block(d->xport, addr, &data, 1);
0168 }
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180 static inline int rmi_write_block(struct rmi_device *d, u16 addr,
0181 const void *buf, size_t len)
0182 {
0183 return d->xport->ops->write_block(d->xport, addr, buf, len);
0184 }
0185
0186 int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data));
0187
0188 extern struct bus_type rmi_bus_type;
0189
0190 int rmi_of_property_read_u32(struct device *dev, u32 *result,
0191 const char *prop, bool optional);
0192
0193 #define RMI_DEBUG_CORE BIT(0)
0194 #define RMI_DEBUG_XPORT BIT(1)
0195 #define RMI_DEBUG_FN BIT(2)
0196 #define RMI_DEBUG_2D_SENSOR BIT(3)
0197
0198 void rmi_dbg(int flags, struct device *dev, const char *fmt, ...);
0199 #endif