2017-12-14 05:49:34 +00:00
|
|
|
// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
|
|
|
|
// Copyright(c) 2015-17 Intel Corporation.
|
|
|
|
|
|
|
|
#ifndef __SDW_BUS_H
|
|
|
|
#define __SDW_BUS_H
|
|
|
|
|
|
|
|
#if IS_ENABLED(CONFIG_ACPI)
|
|
|
|
int sdw_acpi_find_slaves(struct sdw_bus *bus);
|
|
|
|
#else
|
|
|
|
static inline int sdw_acpi_find_slaves(struct sdw_bus *bus)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void sdw_extract_slave_id(struct sdw_bus *bus,
|
|
|
|
u64 addr, struct sdw_slave_id *id);
|
|
|
|
|
2017-12-14 05:49:37 +00:00
|
|
|
enum {
|
|
|
|
SDW_MSG_FLAG_READ = 0,
|
|
|
|
SDW_MSG_FLAG_WRITE,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct sdw_msg - Message structure
|
|
|
|
* @addr: Register address accessed in the Slave
|
|
|
|
* @len: number of messages
|
|
|
|
* @dev_num: Slave device number
|
|
|
|
* @addr_page1: SCP address page 1 Slave register
|
|
|
|
* @addr_page2: SCP address page 2 Slave register
|
|
|
|
* @flags: transfer flags, indicate if xfer is read or write
|
|
|
|
* @buf: message data buffer
|
|
|
|
* @ssp_sync: Send message at SSP (Stream Synchronization Point)
|
|
|
|
* @page: address requires paging
|
|
|
|
*/
|
|
|
|
struct sdw_msg {
|
|
|
|
u16 addr;
|
|
|
|
u16 len;
|
|
|
|
u8 dev_num;
|
|
|
|
u8 addr_page1;
|
|
|
|
u8 addr_page2;
|
|
|
|
u8 flags;
|
|
|
|
u8 *buf;
|
|
|
|
bool ssp_sync;
|
|
|
|
bool page;
|
|
|
|
};
|
|
|
|
|
|
|
|
int sdw_transfer(struct sdw_bus *bus, struct sdw_msg *msg);
|
|
|
|
int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg,
|
|
|
|
struct sdw_defer *defer);
|
|
|
|
|
2017-12-14 05:49:40 +00:00
|
|
|
#define SDW_READ_INTR_CLEAR_RETRY 10
|
|
|
|
|
2017-12-14 05:49:37 +00:00
|
|
|
int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave,
|
|
|
|
u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf);
|
|
|
|
|
2017-12-14 05:49:39 +00:00
|
|
|
/* Read-Modify-Write Slave register */
|
|
|
|
static inline int
|
|
|
|
sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val)
|
|
|
|
{
|
|
|
|
int tmp;
|
|
|
|
|
|
|
|
tmp = sdw_read(slave, addr);
|
|
|
|
if (tmp < 0)
|
|
|
|
return tmp;
|
|
|
|
|
|
|
|
tmp = (tmp & ~mask) | val;
|
|
|
|
return sdw_write(slave, addr, tmp);
|
|
|
|
}
|
|
|
|
|
2017-12-14 05:49:34 +00:00
|
|
|
#endif /* __SDW_BUS_H */
|