| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* Copyright (C) 2018 Cadence Design Systems Inc. |
| 4 |
* |
| 5 |
* Author: Boris Brezillon <[email protected]> |
| 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 |
int __must_check i3c_bus_rpm_get(struct i3c_bus *bus); |
| 15 |
void i3c_bus_rpm_put(struct i3c_bus *bus); |
| 16 |
bool i3c_bus_rpm_ibi_allowed(struct i3c_bus *bus); |
| 17 |
|
| 18 |
void i3c_bus_normaluse_lock(struct i3c_bus *bus); |
| 19 |
void i3c_bus_normaluse_unlock(struct i3c_bus *bus); |
| 20 |
|
| 21 |
int i3c_dev_setdasa_locked(struct i3c_dev_desc *dev); |
| 22 |
int i3c_dev_do_xfers_locked(struct i3c_dev_desc *dev, |
| 23 |
struct i3c_xfer *xfers, |
| 24 |
int nxfers, enum i3c_xfer_mode mode); |
| 25 |
int i3c_dev_disable_ibi_locked(struct i3c_dev_desc *dev); |
| 26 |
int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev); |
| 27 |
int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev, |
| 28 |
const struct i3c_ibi_setup *req); |
| 29 |
void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev); |
| 30 |
|
| 31 |
/** |
| 32 |
* i3c_writel_fifo - Write data buffer to 32bit FIFO |
| 33 |
* @addr: FIFO Address to write to |
| 34 |
* @buf: Pointer to the data bytes to write |
| 35 |
* @nbytes: Number of bytes to write |
| 36 |
*/ |
| 37 |
static inline void i3c_writel_fifo(void __iomem *addr, const void *buf, |
| 38 |
int nbytes) |
| 39 |
{ |
| 40 |
writesl(addr, buf, nbytes / 4); |
| 41 |
if (nbytes & 3) { |
| 42 |
u32 tmp = 0; |
| 43 |
|
| 44 |
memcpy(&tmp, buf + (nbytes & ~3), nbytes & 3); |
| 45 |
/* |
| 46 |
* writesl() instead of writel() to keep FIFO |
| 47 |
* byteorder on big-endian targets |
| 48 |
*/ |
| 49 |
writesl(addr, &tmp, 1); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* i3c_readl_fifo - Read data buffer from 32bit FIFO |
| 55 |
* @addr: FIFO Address to read from |
| 56 |
* @buf: Pointer to the buffer to store read bytes |
| 57 |
* @nbytes: Number of bytes to read |
| 58 |
*/ |
| 59 |
static inline void i3c_readl_fifo(const void __iomem *addr, void *buf, |
| 60 |
int nbytes) |
| 61 |
{ |
| 62 |
readsl(addr, buf, nbytes / 4); |
| 63 |
if (nbytes & 3) { |
| 64 |
u32 tmp; |
| 65 |
|
| 66 |
/* |
| 67 |
* readsl() instead of readl() to keep FIFO |
| 68 |
* byteorder on big-endian targets |
| 69 |
*/ |
| 70 |
readsl(addr, &tmp, 1); |
| 71 |
memcpy(buf + (nbytes & ~3), &tmp, nbytes & 3); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
#endif /* I3C_INTERNAL_H */ |