Vinod Koul | 7c3cd18 | 2017-12-14 11:19:34 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) |
| 2 | // Copyright(c) 2015-17 Intel Corporation. |
| 3 | |
| 4 | #ifndef __SDW_BUS_H |
| 5 | #define __SDW_BUS_H |
| 6 | |
| 7 | #if IS_ENABLED(CONFIG_ACPI) |
| 8 | int sdw_acpi_find_slaves(struct sdw_bus *bus); |
| 9 | #else |
| 10 | static inline int sdw_acpi_find_slaves(struct sdw_bus *bus) |
| 11 | { |
| 12 | return -ENOTSUPP; |
| 13 | } |
| 14 | #endif |
| 15 | |
| 16 | void sdw_extract_slave_id(struct sdw_bus *bus, |
| 17 | u64 addr, struct sdw_slave_id *id); |
| 18 | |
Vinod Koul | 9d715fa | 2017-12-14 11:19:37 +0530 | [diff] [blame] | 19 | enum { |
| 20 | SDW_MSG_FLAG_READ = 0, |
| 21 | SDW_MSG_FLAG_WRITE, |
| 22 | }; |
| 23 | |
| 24 | /** |
| 25 | * struct sdw_msg - Message structure |
| 26 | * @addr: Register address accessed in the Slave |
| 27 | * @len: number of messages |
| 28 | * @dev_num: Slave device number |
| 29 | * @addr_page1: SCP address page 1 Slave register |
| 30 | * @addr_page2: SCP address page 2 Slave register |
| 31 | * @flags: transfer flags, indicate if xfer is read or write |
| 32 | * @buf: message data buffer |
| 33 | * @ssp_sync: Send message at SSP (Stream Synchronization Point) |
| 34 | * @page: address requires paging |
| 35 | */ |
| 36 | struct sdw_msg { |
| 37 | u16 addr; |
| 38 | u16 len; |
| 39 | u8 dev_num; |
| 40 | u8 addr_page1; |
| 41 | u8 addr_page2; |
| 42 | u8 flags; |
| 43 | u8 *buf; |
| 44 | bool ssp_sync; |
| 45 | bool page; |
| 46 | }; |
| 47 | |
| 48 | int sdw_transfer(struct sdw_bus *bus, struct sdw_msg *msg); |
| 49 | int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg, |
| 50 | struct sdw_defer *defer); |
| 51 | |
| 52 | int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave, |
| 53 | u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf); |
| 54 | |
Sanyog Kale | d52d7a1 | 2017-12-14 11:19:39 +0530 | [diff] [blame^] | 55 | /* Read-Modify-Write Slave register */ |
| 56 | static inline int |
| 57 | sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val) |
| 58 | { |
| 59 | int tmp; |
| 60 | |
| 61 | tmp = sdw_read(slave, addr); |
| 62 | if (tmp < 0) |
| 63 | return tmp; |
| 64 | |
| 65 | tmp = (tmp & ~mask) | val; |
| 66 | return sdw_write(slave, addr, tmp); |
| 67 | } |
| 68 | |
Vinod Koul | 7c3cd18 | 2017-12-14 11:19:34 +0530 | [diff] [blame] | 69 | #endif /* __SDW_BUS_H */ |