1
2
3
4
5
6#ifndef _LINUX_SLIMBUS_H
7#define _LINUX_SLIMBUS_H
8#include <linux/device.h>
9#include <linux/module.h>
10#include <linux/completion.h>
11#include <linux/mod_devicetable.h>
12
13extern struct bus_type slimbus_bus;
14
15
16
17
18
19
20
21
22struct slim_eaddr {
23 u16 manf_id;
24 u16 prod_code;
25 u8 dev_index;
26 u8 instance;
27} __packed;
28
29
30
31
32
33
34
35enum slim_device_status {
36 SLIM_DEVICE_STATUS_DOWN = 0,
37 SLIM_DEVICE_STATUS_UP,
38 SLIM_DEVICE_STATUS_RESERVED,
39};
40
41struct slim_controller;
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56struct slim_device {
57 struct device dev;
58 struct slim_eaddr e_addr;
59 struct slim_controller *ctrl;
60 enum slim_device_status status;
61 u8 laddr;
62 bool is_laddr_valid;
63};
64
65#define to_slim_device(d) container_of(d, struct slim_device, dev)
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81struct slim_driver {
82 int (*probe)(struct slim_device *sl);
83 void (*remove)(struct slim_device *sl);
84 void (*shutdown)(struct slim_device *sl);
85 int (*device_status)(struct slim_device *sl,
86 enum slim_device_status s);
87 struct device_driver driver;
88 const struct slim_device_id *id_table;
89};
90#define to_slim_driver(d) container_of(d, struct slim_driver, driver)
91
92
93
94
95
96
97
98
99
100
101
102
103struct slim_val_inf {
104 u16 start_offset;
105 u8 num_bytes;
106 u8 *rbuf;
107 const u8 *wbuf;
108 struct completion *comp;
109};
110
111
112
113
114#define slim_driver_register(drv) \
115 __slim_driver_register(drv, THIS_MODULE)
116int __slim_driver_register(struct slim_driver *drv, struct module *owner);
117void slim_driver_unregister(struct slim_driver *drv);
118
119
120
121
122
123
124
125
126
127#define module_slim_driver(__slim_driver) \
128 module_driver(__slim_driver, slim_driver_register, \
129 slim_driver_unregister)
130
131static inline void *slim_get_devicedata(const struct slim_device *dev)
132{
133 return dev_get_drvdata(&dev->dev);
134}
135
136static inline void slim_set_devicedata(struct slim_device *dev, void *data)
137{
138 dev_set_drvdata(&dev->dev, data);
139}
140
141struct slim_device *slim_get_device(struct slim_controller *ctrl,
142 struct slim_eaddr *e_addr);
143int slim_get_logical_addr(struct slim_device *sbdev);
144
145
146#define SLIM_MSG_MC_REQUEST_INFORMATION 0x20
147#define SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION 0x21
148#define SLIM_MSG_MC_REPLY_INFORMATION 0x24
149#define SLIM_MSG_MC_CLEAR_INFORMATION 0x28
150#define SLIM_MSG_MC_REPORT_INFORMATION 0x29
151
152
153#define SLIM_MSG_MC_REQUEST_VALUE 0x60
154#define SLIM_MSG_MC_REQUEST_CHANGE_VALUE 0x61
155#define SLIM_MSG_MC_REPLY_VALUE 0x64
156#define SLIM_MSG_MC_CHANGE_VALUE 0x68
157
158int slim_xfer_msg(struct slim_device *sbdev, struct slim_val_inf *msg,
159 u8 mc);
160int slim_readb(struct slim_device *sdev, u32 addr);
161int slim_writeb(struct slim_device *sdev, u32 addr, u8 value);
162int slim_read(struct slim_device *sdev, u32 addr, size_t count, u8 *val);
163int slim_write(struct slim_device *sdev, u32 addr, size_t count, u8 *val);
164#endif
165