0001
0002
0003
0004
0005
0006 #ifndef _LINUX_SLIMBUS_H
0007 #define _LINUX_SLIMBUS_H
0008 #include <linux/device.h>
0009 #include <linux/module.h>
0010 #include <linux/completion.h>
0011 #include <linux/mod_devicetable.h>
0012
0013 extern struct bus_type slimbus_bus;
0014
0015
0016
0017
0018
0019
0020
0021
0022 struct slim_eaddr {
0023 u8 instance;
0024 u8 dev_index;
0025 u16 prod_code;
0026 u16 manf_id;
0027 } __packed;
0028
0029
0030
0031
0032
0033
0034
0035 enum slim_device_status {
0036 SLIM_DEVICE_STATUS_DOWN = 0,
0037 SLIM_DEVICE_STATUS_UP,
0038 SLIM_DEVICE_STATUS_RESERVED,
0039 };
0040
0041 struct slim_controller;
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 struct slim_device {
0059 struct device dev;
0060 struct slim_eaddr e_addr;
0061 struct slim_controller *ctrl;
0062 enum slim_device_status status;
0063 u8 laddr;
0064 bool is_laddr_valid;
0065 struct list_head stream_list;
0066 spinlock_t stream_list_lock;
0067 };
0068
0069 #define to_slim_device(d) container_of(d, struct slim_device, dev)
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 struct slim_driver {
0086 int (*probe)(struct slim_device *sl);
0087 void (*remove)(struct slim_device *sl);
0088 void (*shutdown)(struct slim_device *sl);
0089 int (*device_status)(struct slim_device *sl,
0090 enum slim_device_status s);
0091 struct device_driver driver;
0092 const struct slim_device_id *id_table;
0093 };
0094 #define to_slim_driver(d) container_of(d, struct slim_driver, driver)
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107 struct slim_val_inf {
0108 u16 start_offset;
0109 u8 num_bytes;
0110 u8 *rbuf;
0111 const u8 *wbuf;
0112 struct completion *comp;
0113 };
0114
0115 #define SLIM_DEVICE_MAX_CHANNELS 256
0116
0117 #define SLIM_DEVICE_MAX_PORTS 32
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 struct slim_stream_config {
0135 unsigned int rate;
0136 unsigned int bps;
0137
0138 unsigned int ch_count;
0139 unsigned int *chs;
0140
0141 unsigned long port_mask;
0142 int direction;
0143 };
0144
0145
0146
0147
0148 #define slim_driver_register(drv) \
0149 __slim_driver_register(drv, THIS_MODULE)
0150 int __slim_driver_register(struct slim_driver *drv, struct module *owner);
0151 void slim_driver_unregister(struct slim_driver *drv);
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161 #define module_slim_driver(__slim_driver) \
0162 module_driver(__slim_driver, slim_driver_register, \
0163 slim_driver_unregister)
0164
0165 static inline void *slim_get_devicedata(const struct slim_device *dev)
0166 {
0167 return dev_get_drvdata(&dev->dev);
0168 }
0169
0170 static inline void slim_set_devicedata(struct slim_device *dev, void *data)
0171 {
0172 dev_set_drvdata(&dev->dev, data);
0173 }
0174
0175 struct slim_device *of_slim_get_device(struct slim_controller *ctrl,
0176 struct device_node *np);
0177 struct slim_device *slim_get_device(struct slim_controller *ctrl,
0178 struct slim_eaddr *e_addr);
0179 int slim_get_logical_addr(struct slim_device *sbdev);
0180
0181
0182 #define SLIM_MSG_MC_REQUEST_INFORMATION 0x20
0183 #define SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION 0x21
0184 #define SLIM_MSG_MC_REPLY_INFORMATION 0x24
0185 #define SLIM_MSG_MC_CLEAR_INFORMATION 0x28
0186 #define SLIM_MSG_MC_REPORT_INFORMATION 0x29
0187
0188
0189 #define SLIM_MSG_MC_REQUEST_VALUE 0x60
0190 #define SLIM_MSG_MC_REQUEST_CHANGE_VALUE 0x61
0191 #define SLIM_MSG_MC_REPLY_VALUE 0x64
0192 #define SLIM_MSG_MC_CHANGE_VALUE 0x68
0193
0194 int slim_xfer_msg(struct slim_device *sbdev, struct slim_val_inf *msg,
0195 u8 mc);
0196 int slim_readb(struct slim_device *sdev, u32 addr);
0197 int slim_writeb(struct slim_device *sdev, u32 addr, u8 value);
0198 int slim_read(struct slim_device *sdev, u32 addr, size_t count, u8 *val);
0199 int slim_write(struct slim_device *sdev, u32 addr, size_t count, u8 *val);
0200
0201
0202 struct slim_stream_runtime;
0203 struct slim_stream_runtime *slim_stream_allocate(struct slim_device *dev,
0204 const char *sname);
0205 int slim_stream_prepare(struct slim_stream_runtime *stream,
0206 struct slim_stream_config *c);
0207 int slim_stream_enable(struct slim_stream_runtime *stream);
0208 int slim_stream_disable(struct slim_stream_runtime *stream);
0209 int slim_stream_unprepare(struct slim_stream_runtime *stream);
0210 int slim_stream_free(struct slim_stream_runtime *stream);
0211
0212 #endif