|
45 | 45 | #define SLIM_MSG_MC_ASSIGN_LOGICAL_ADDRESS 0x2
|
46 | 46 | #define SLIM_MSG_MC_REPORT_ABSENT 0xF
|
47 | 47 |
|
| 48 | +/* Data channel management messages */ |
| 49 | +#define SLIM_MSG_MC_CONNECT_SOURCE 0x10 |
| 50 | +#define SLIM_MSG_MC_CONNECT_SINK 0x11 |
| 51 | +#define SLIM_MSG_MC_DISCONNECT_PORT 0x14 |
| 52 | +#define SLIM_MSG_MC_CHANGE_CONTENT 0x18 |
| 53 | + |
48 | 54 | /* Clock pause Reconfiguration messages */
|
49 | 55 | #define SLIM_MSG_MC_BEGIN_RECONFIGURATION 0x40
|
50 | 56 | #define SLIM_MSG_MC_NEXT_PAUSE_CLOCK 0x4A
|
| 57 | +#define SLIM_MSG_MC_NEXT_DEFINE_CHANNEL 0x50 |
| 58 | +#define SLIM_MSG_MC_NEXT_DEFINE_CONTENT 0x51 |
| 59 | +#define SLIM_MSG_MC_NEXT_ACTIVATE_CHANNEL 0x54 |
| 60 | +#define SLIM_MSG_MC_NEXT_DEACTIVATE_CHANNEL 0x55 |
| 61 | +#define SLIM_MSG_MC_NEXT_REMOVE_CHANNEL 0x58 |
51 | 62 | #define SLIM_MSG_MC_RECONFIGURE_NOW 0x5F
|
52 | 63 |
|
53 | 64 | /*
|
|
69 | 80 | /* Standard values per SLIMbus spec needed by controllers and devices */
|
70 | 81 | #define SLIM_MAX_CLK_GEAR 10
|
71 | 82 | #define SLIM_MIN_CLK_GEAR 1
|
| 83 | +#define SLIM_SLOT_LEN_BITS 4 |
| 84 | + |
| 85 | +/* Indicate that the frequency of the flow and the bus frequency are locked */ |
| 86 | +#define SLIM_CHANNEL_CONTENT_FL BIT(7) |
72 | 87 |
|
| 88 | +/* Standard values per SLIMbus spec needed by controllers and devices */ |
| 89 | +#define SLIM_CL_PER_SUPERFRAME 6144 |
| 90 | +#define SLIM_SLOTS_PER_SUPERFRAME (SLIM_CL_PER_SUPERFRAME >> 2) |
| 91 | +#define SLIM_SL_PER_SUPERFRAME (SLIM_CL_PER_SUPERFRAME >> 2) |
73 | 92 | /* Manager's logical address is set to 0xFF per spec */
|
74 | 93 | #define SLIM_LA_MANAGER 0xFF
|
75 | 94 |
|
@@ -167,6 +186,170 @@ struct slim_sched {
|
167 | 186 | struct mutex m_reconf;
|
168 | 187 | };
|
169 | 188 |
|
| 189 | +/** |
| 190 | + * enum slim_port_direction: SLIMbus port direction |
| 191 | + * |
| 192 | + * @SLIM_PORT_SINK: SLIMbus port is a sink |
| 193 | + * @SLIM_PORT_SOURCE: SLIMbus port is a source |
| 194 | + */ |
| 195 | +enum slim_port_direction { |
| 196 | + SLIM_PORT_SINK = 0, |
| 197 | + SLIM_PORT_SOURCE, |
| 198 | +}; |
| 199 | +/** |
| 200 | + * enum slim_port_state: SLIMbus Port/Endpoint state machine |
| 201 | + * according to SLIMbus Spec 2.0 |
| 202 | + * @SLIM_PORT_DISCONNECTED: SLIMbus port is disconnected |
| 203 | + * entered from Unconfigure/configured state after |
| 204 | + * DISCONNECT_PORT or REMOVE_CHANNEL core command |
| 205 | + * @SLIM_PORT_UNCONFIGURED: SLIMbus port is in unconfigured state. |
| 206 | + * entered from disconnect state after CONNECT_SOURCE/SINK core command |
| 207 | + * @SLIM_PORT_CONFIGURED: SLIMbus port is in configured state. |
| 208 | + * entered from unconfigured state after DEFINE_CHANNEL, DEFINE_CONTENT |
| 209 | + * and ACTIVATE_CHANNEL core commands. Ready for data transmission. |
| 210 | + */ |
| 211 | +enum slim_port_state { |
| 212 | + SLIM_PORT_DISCONNECTED = 0, |
| 213 | + SLIM_PORT_UNCONFIGURED, |
| 214 | + SLIM_PORT_CONFIGURED, |
| 215 | +}; |
| 216 | + |
| 217 | +/** |
| 218 | + * enum slim_channel_state: SLIMbus channel state machine used by core. |
| 219 | + * @SLIM_CH_STATE_DISCONNECTED: SLIMbus channel is disconnected |
| 220 | + * @SLIM_CH_STATE_ALLOCATED: SLIMbus channel is allocated |
| 221 | + * @SLIM_CH_STATE_ASSOCIATED: SLIMbus channel is associated with port |
| 222 | + * @SLIM_CH_STATE_DEFINED: SLIMbus channel parameters are defined |
| 223 | + * @SLIM_CH_STATE_CONTENT_DEFINED: SLIMbus channel content is defined |
| 224 | + * @SLIM_CH_STATE_ACTIVE: SLIMbus channel is active and ready for data |
| 225 | + * @SLIM_CH_STATE_REMOVED: SLIMbus channel is inactive and removed |
| 226 | + */ |
| 227 | +enum slim_channel_state { |
| 228 | + SLIM_CH_STATE_DISCONNECTED = 0, |
| 229 | + SLIM_CH_STATE_ALLOCATED, |
| 230 | + SLIM_CH_STATE_ASSOCIATED, |
| 231 | + SLIM_CH_STATE_DEFINED, |
| 232 | + SLIM_CH_STATE_CONTENT_DEFINED, |
| 233 | + SLIM_CH_STATE_ACTIVE, |
| 234 | + SLIM_CH_STATE_REMOVED, |
| 235 | +}; |
| 236 | + |
| 237 | +/** |
| 238 | + * enum slim_ch_data_fmt: SLIMbus channel data Type identifiers according to |
| 239 | + * Table 60 of SLIMbus Spec 1.01.01 |
| 240 | + * @SLIM_CH_DATA_FMT_NOT_DEFINED: Undefined |
| 241 | + * @SLIM_CH_DATA_FMT_LPCM_AUDIO: LPCM audio |
| 242 | + * @SLIM_CH_DATA_FMT_IEC61937_COMP_AUDIO: IEC61937 Compressed audio |
| 243 | + * @SLIM_CH_DATA_FMT_PACKED_PDM_AUDIO: Packed PDM audio |
| 244 | + */ |
| 245 | +enum slim_ch_data_fmt { |
| 246 | + SLIM_CH_DATA_FMT_NOT_DEFINED = 0, |
| 247 | + SLIM_CH_DATA_FMT_LPCM_AUDIO = 1, |
| 248 | + SLIM_CH_DATA_FMT_IEC61937_COMP_AUDIO = 2, |
| 249 | + SLIM_CH_DATA_FMT_PACKED_PDM_AUDIO = 3, |
| 250 | +}; |
| 251 | + |
| 252 | +/** |
| 253 | + * enum slim_ch_aux_fmt: SLIMbus channel Aux Field format IDs according to |
| 254 | + * Table 63 of SLIMbus Spec 2.0 |
| 255 | + * @SLIM_CH_AUX_FMT_NOT_APPLICABLE: Undefined |
| 256 | + * @SLIM_CH_AUX_FMT_ZCUV_TUNNEL_IEC60958: ZCUV for tunneling IEC60958 |
| 257 | + * @SLIM_CH_AUX_FMT_USER_DEFINED: User defined |
| 258 | + */ |
| 259 | +enum slim_ch_aux_bit_fmt { |
| 260 | + SLIM_CH_AUX_FMT_NOT_APPLICABLE = 0, |
| 261 | + SLIM_CH_AUX_FMT_ZCUV_TUNNEL_IEC60958 = 1, |
| 262 | + SLIM_CH_AUX_FMT_USER_DEFINED = 0xF, |
| 263 | +}; |
| 264 | + |
| 265 | +/** |
| 266 | + * struct slim_channel - SLIMbus channel, used for state machine |
| 267 | + * |
| 268 | + * @id: ID of channel |
| 269 | + * @prrate: Presense rate of channel from Table 66 of SLIMbus 2.0 Specs |
| 270 | + * @seg_dist: segment distribution code from Table 20 of SLIMbus 2.0 Specs |
| 271 | + * @data_fmt: Data format of channel. |
| 272 | + * @aux_fmt: Aux format for this channel. |
| 273 | + * @state: channel state machine |
| 274 | + */ |
| 275 | +struct slim_channel { |
| 276 | + int id; |
| 277 | + int prrate; |
| 278 | + int seg_dist; |
| 279 | + enum slim_ch_data_fmt data_fmt; |
| 280 | + enum slim_ch_aux_bit_fmt aux_fmt; |
| 281 | + enum slim_channel_state state; |
| 282 | +}; |
| 283 | + |
| 284 | +/** |
| 285 | + * struct slim_port - SLIMbus port |
| 286 | + * |
| 287 | + * @id: Port id |
| 288 | + * @direction: Port direction, Source or Sink. |
| 289 | + * @state: state machine of port. |
| 290 | + * @ch: channel associated with this port. |
| 291 | + */ |
| 292 | +struct slim_port { |
| 293 | + int id; |
| 294 | + enum slim_port_direction direction; |
| 295 | + enum slim_port_state state; |
| 296 | + struct slim_channel ch; |
| 297 | +}; |
| 298 | + |
| 299 | +/** |
| 300 | + * enum slim_transport_protocol: SLIMbus Transport protocol list from |
| 301 | + * Table 47 of SLIMbus 2.0 specs. |
| 302 | + * @SLIM_PROTO_ISO: Isochronous Protocol, no flow control as data rate match |
| 303 | + * channel rate flow control embedded in the data. |
| 304 | + * @SLIM_PROTO_PUSH: Pushed Protocol, includes flow control, Used to carry |
| 305 | + * data whose rate is equal to, or lower than the channel rate. |
| 306 | + * @SLIM_PROTO_PULL: Pulled Protocol, similar usage as pushed protocol |
| 307 | + * but pull is a unicast. |
| 308 | + * @SLIM_PROTO_LOCKED: Locked Protocol |
| 309 | + * @SLIM_PROTO_ASYNC_SMPLX: Asynchronous Protocol-Simplex |
| 310 | + * @SLIM_PROTO_ASYNC_HALF_DUP: Asynchronous Protocol-Half-duplex |
| 311 | + * @SLIM_PROTO_EXT_SMPLX: Extended Asynchronous Protocol-Simplex |
| 312 | + * @SLIM_PROTO_EXT_HALF_DUP: Extended Asynchronous Protocol-Half-duplex |
| 313 | + */ |
| 314 | +enum slim_transport_protocol { |
| 315 | + SLIM_PROTO_ISO = 0, |
| 316 | + SLIM_PROTO_PUSH, |
| 317 | + SLIM_PROTO_PULL, |
| 318 | + SLIM_PROTO_LOCKED, |
| 319 | + SLIM_PROTO_ASYNC_SMPLX, |
| 320 | + SLIM_PROTO_ASYNC_HALF_DUP, |
| 321 | + SLIM_PROTO_EXT_SMPLX, |
| 322 | + SLIM_PROTO_EXT_HALF_DUP, |
| 323 | +}; |
| 324 | + |
| 325 | +/** |
| 326 | + * struct slim_stream_runtime - SLIMbus stream runtime instance |
| 327 | + * |
| 328 | + * @dev: Name of the stream |
| 329 | + * @dev: SLIM Device instance associated with this stream |
| 330 | + * @state: state of stream |
| 331 | + * @direction: direction of stream |
| 332 | + * @prot: Transport protocol used in this stream |
| 333 | + * @rate: Data rate of samples * |
| 334 | + * @bps: bits per sample |
| 335 | + * @ratem: rate multipler which is super frame rate/data rate |
| 336 | + * @num_ports: number of ports |
| 337 | + * @ports: pointer to instance of ports |
| 338 | + * @node: list head for stream associated with slim device. |
| 339 | + */ |
| 340 | +struct slim_stream_runtime { |
| 341 | + const char *name; |
| 342 | + struct slim_device *dev; |
| 343 | + int direction; |
| 344 | + enum slim_transport_protocol prot; |
| 345 | + unsigned int rate; |
| 346 | + unsigned int bps; |
| 347 | + unsigned int ratem; |
| 348 | + int num_ports; |
| 349 | + struct slim_port *ports; |
| 350 | + struct list_head node; |
| 351 | +}; |
| 352 | + |
170 | 353 | /**
|
171 | 354 | * struct slim_controller - Controls every instance of SLIMbus
|
172 | 355 | * (similar to 'master' on SPI)
|
@@ -196,6 +379,10 @@ struct slim_sched {
|
196 | 379 | * @wakeup: This function pointer implements controller-specific procedure
|
197 | 380 | * to wake it up from clock-pause. Framework will call this to bring
|
198 | 381 | * the controller out of clock pause.
|
| 382 | + * @enable_stream: This function pointer implements controller-specific procedure |
| 383 | + * to enable a stream. |
| 384 | + * @disable_stream: This function pointer implements controller-specific procedure |
| 385 | + * to disable stream. |
199 | 386 | *
|
200 | 387 | * 'Manager device' is responsible for device management, bandwidth
|
201 | 388 | * allocation, channel setup, and port associations per channel.
|
@@ -237,6 +424,8 @@ struct slim_controller {
|
237 | 424 | struct slim_eaddr *ea, u8 laddr);
|
238 | 425 | int (*get_laddr)(struct slim_controller *ctrl,
|
239 | 426 | struct slim_eaddr *ea, u8 *laddr);
|
| 427 | + int (*enable_stream)(struct slim_stream_runtime *rt); |
| 428 | + int (*disable_stream)(struct slim_stream_runtime *rt); |
240 | 429 | int (*wakeup)(struct slim_controller *ctrl);
|
241 | 430 | };
|
242 | 431 |
|
|
0 commit comments