1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 2018 Cadence Design Systems Inc. 4 * 5 * Author: Boris Brezillon <boris.brezillon@bootlin.com> 6 */ 7 8 #ifndef I3C_INTERNALS_H 9 #define I3C_INTERNALS_H 10 11 #include <linux/i3c/master.h> 12 #include <linux/io.h> 13 14 void i3c_bus_normaluse_lock(struct i3c_bus *bus); 15 void i3c_bus_normaluse_unlock(struct i3c_bus *bus); 16 17 int i3c_dev_setdasa_locked(struct i3c_dev_desc *dev); 18 int i3c_dev_do_priv_xfers_locked(struct i3c_dev_desc *dev, 19 struct i3c_priv_xfer *xfers, 20 int nxfers); 21 int i3c_dev_disable_ibi_locked(struct i3c_dev_desc *dev); 22 int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev); 23 int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev, 24 const struct i3c_ibi_setup *req); 25 void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev); 26 27 /** 28 * i3c_writel_fifo - Write data buffer to 32bit FIFO 29 * @addr: FIFO Address to write to 30 * @buf: Pointer to the data bytes to write 31 * @nbytes: Number of bytes to write 32 */ 33 static inline void i3c_writel_fifo(void __iomem *addr, const void *buf, 34 int nbytes) 35 { 36 writesl(addr, buf, nbytes / 4); 37 if (nbytes & 3) { 38 u32 tmp = 0; 39 40 memcpy(&tmp, buf + (nbytes & ~3), nbytes & 3); 41 writel(tmp, addr); 42 } 43 } 44 45 /** 46 * i3c_readl_fifo - Read data buffer from 32bit FIFO 47 * @addr: FIFO Address to read from 48 * @buf: Pointer to the buffer to store read bytes 49 * @nbytes: Number of bytes to read 50 */ 51 static inline void i3c_readl_fifo(const void __iomem *addr, void *buf, 52 int nbytes) 53 { 54 readsl(addr, buf, nbytes / 4); 55 if (nbytes & 3) { 56 u32 tmp; 57 58 tmp = readl(addr); 59 memcpy(buf + (nbytes & ~3), &tmp, nbytes & 3); 60 } 61 } 62 63 #endif /* I3C_INTERNAL_H */ 64