mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 15:41:52 +02:00
Merge remote-tracking branch 'i3c/ib-i3c-iio-v6.20' into togreg
Needed for some stubs to prevent build issues if !CONFIG_I3C
This commit is contained in:
commit
4296b1fb54
|
|
@ -161,3 +161,14 @@ Contact: linux-i3c@vger.kernel.org
|
|||
Description:
|
||||
These directories are just symbolic links to
|
||||
/sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>.
|
||||
|
||||
What: /sys/bus/i3c/devices/i3c-<bus-id>/<bus-id>-<device-pid>/dev_nack_retry_count
|
||||
KernelVersion: 6.18
|
||||
Contact: linux-i3c@vger.kernel.org
|
||||
Description:
|
||||
Expose the dev_nak_retry_count which controls the number of
|
||||
automatic retries that will be performed by the controller when
|
||||
the target device returns a NACK response. A value of 0 disables
|
||||
the automatic retries. Exist only when I3C constroller supports
|
||||
this retry on nack feature.
|
||||
|
||||
|
|
|
|||
|
|
@ -683,6 +683,39 @@ static ssize_t hotjoin_show(struct device *dev, struct device_attribute *da, cha
|
|||
|
||||
static DEVICE_ATTR_RW(hotjoin);
|
||||
|
||||
static ssize_t dev_nack_retry_count_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
return sysfs_emit(buf, "%u\n", dev_to_i3cmaster(dev)->dev_nack_retry_count);
|
||||
}
|
||||
|
||||
static ssize_t dev_nack_retry_count_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct i3c_bus *i3cbus = dev_to_i3cbus(dev);
|
||||
struct i3c_master_controller *master = dev_to_i3cmaster(dev);
|
||||
unsigned long val;
|
||||
int ret;
|
||||
|
||||
ret = kstrtoul(buf, 0, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
i3c_bus_maintenance_lock(i3cbus);
|
||||
ret = master->ops->set_dev_nack_retry(master, val);
|
||||
i3c_bus_maintenance_unlock(i3cbus);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
master->dev_nack_retry_count = val;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_RW(dev_nack_retry_count);
|
||||
|
||||
static struct attribute *i3c_masterdev_attrs[] = {
|
||||
&dev_attr_mode.attr,
|
||||
&dev_attr_current_master.attr,
|
||||
|
|
@ -2370,19 +2403,16 @@ static int of_populate_i3c_bus(struct i3c_master_controller *master)
|
|||
{
|
||||
struct device *dev = &master->dev;
|
||||
struct device_node *i3cbus_np = dev->of_node;
|
||||
struct device_node *node;
|
||||
int ret;
|
||||
u32 val;
|
||||
|
||||
if (!i3cbus_np)
|
||||
return 0;
|
||||
|
||||
for_each_available_child_of_node(i3cbus_np, node) {
|
||||
for_each_available_child_of_node_scoped(i3cbus_np, node) {
|
||||
ret = of_i3c_master_add_dev(master, node);
|
||||
if (ret) {
|
||||
of_node_put(node);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -2959,6 +2989,9 @@ int i3c_master_register(struct i3c_master_controller *master,
|
|||
i3c_master_register_new_i3c_devs(master);
|
||||
i3c_bus_normaluse_unlock(&master->bus);
|
||||
|
||||
if (master->ops->set_dev_nack_retry)
|
||||
device_create_file(&master->dev, &dev_attr_dev_nack_retry_count);
|
||||
|
||||
return 0;
|
||||
|
||||
err_del_dev:
|
||||
|
|
@ -2984,6 +3017,9 @@ void i3c_master_unregister(struct i3c_master_controller *master)
|
|||
{
|
||||
i3c_bus_notify(&master->bus, I3C_NOTIFY_BUS_REMOVE);
|
||||
|
||||
if (master->ops->set_dev_nack_retry)
|
||||
device_remove_file(&master->dev, &dev_attr_dev_nack_retry_count);
|
||||
|
||||
i3c_master_i2c_adapter_cleanup(master);
|
||||
i3c_master_unregister_i3c_devs(master);
|
||||
i3c_master_bus_cleanup(master);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
* Author: Vitor Soares <vitor.soares@synopsys.com>
|
||||
*/
|
||||
|
||||
#include <linux/bitfield.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/completion.h>
|
||||
|
|
@ -204,11 +205,17 @@
|
|||
#define EXTENDED_CAPABILITY 0xe8
|
||||
#define SLAVE_CONFIG 0xec
|
||||
|
||||
#define DW_I3C_DEV_NACK_RETRY_CNT_MAX 0x3
|
||||
#define DEV_ADDR_TABLE_DEV_NACK_RETRY_MASK GENMASK(30, 29)
|
||||
#define DEV_ADDR_TABLE_DYNAMIC_MASK GENMASK(23, 16)
|
||||
#define DEV_ADDR_TABLE_STATIC_MASK GENMASK(6, 0)
|
||||
#define DEV_ADDR_TABLE_IBI_MDB BIT(12)
|
||||
#define DEV_ADDR_TABLE_SIR_REJECT BIT(13)
|
||||
#define DEV_ADDR_TABLE_DEV_NACK_RETRY_CNT(x) \
|
||||
FIELD_PREP(DEV_ADDR_TABLE_DEV_NACK_RETRY_MASK, (x))
|
||||
#define DEV_ADDR_TABLE_LEGACY_I2C_DEV BIT(31)
|
||||
#define DEV_ADDR_TABLE_DYNAMIC_ADDR(x) (((x) << 16) & GENMASK(23, 16))
|
||||
#define DEV_ADDR_TABLE_STATIC_ADDR(x) ((x) & GENMASK(6, 0))
|
||||
#define DEV_ADDR_TABLE_DYNAMIC_ADDR(x) FIELD_PREP(DEV_ADDR_TABLE_DYNAMIC_MASK, x)
|
||||
#define DEV_ADDR_TABLE_STATIC_ADDR(x) FIELD_PREP(DEV_ADDR_TABLE_STATIC_MASK, x)
|
||||
#define DEV_ADDR_TABLE_LOC(start, idx) ((start) + ((idx) << 2))
|
||||
|
||||
#define I3C_BUS_SDR1_SCL_RATE 8000000
|
||||
|
|
@ -1489,6 +1496,40 @@ static irqreturn_t dw_i3c_master_irq_handler(int irq, void *dev_id)
|
|||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static int dw_i3c_master_set_dev_nack_retry(struct i3c_master_controller *m,
|
||||
unsigned long dev_nack_retry_cnt)
|
||||
{
|
||||
struct dw_i3c_master *master = to_dw_i3c_master(m);
|
||||
u32 reg;
|
||||
int i;
|
||||
|
||||
if (dev_nack_retry_cnt > DW_I3C_DEV_NACK_RETRY_CNT_MAX) {
|
||||
dev_err(&master->base.dev,
|
||||
"Value %ld exceeds maximum %d\n",
|
||||
dev_nack_retry_cnt, DW_I3C_DEV_NACK_RETRY_CNT_MAX);
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update DAT entries for all currently attached devices.
|
||||
* We directly iterate through the master's device array.
|
||||
*/
|
||||
for (i = 0; i < master->maxdevs; i++) {
|
||||
/* Skip free/empty slots */
|
||||
if (master->free_pos & BIT(i))
|
||||
continue;
|
||||
|
||||
reg = readl(master->regs +
|
||||
DEV_ADDR_TABLE_LOC(master->datstartaddr, i));
|
||||
reg &= ~DEV_ADDR_TABLE_DEV_NACK_RETRY_MASK;
|
||||
reg |= DEV_ADDR_TABLE_DEV_NACK_RETRY_CNT(dev_nack_retry_cnt);
|
||||
writel(reg, master->regs +
|
||||
DEV_ADDR_TABLE_LOC(master->datstartaddr, i));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i3c_master_controller_ops dw_mipi_i3c_ops = {
|
||||
.bus_init = dw_i3c_master_bus_init,
|
||||
.bus_cleanup = dw_i3c_master_bus_cleanup,
|
||||
|
|
@ -1509,6 +1550,7 @@ static const struct i3c_master_controller_ops dw_mipi_i3c_ops = {
|
|||
.recycle_ibi_slot = dw_i3c_master_recycle_ibi_slot,
|
||||
.enable_hotjoin = dw_i3c_master_enable_hotjoin,
|
||||
.disable_hotjoin = dw_i3c_master_disable_hotjoin,
|
||||
.set_dev_nack_retry = dw_i3c_master_set_dev_nack_retry,
|
||||
};
|
||||
|
||||
/* default platform ops implementations */
|
||||
|
|
@ -1676,11 +1718,16 @@ static void dw_i3c_master_restore_addrs(struct dw_i3c_master *master)
|
|||
if (master->free_pos & BIT(pos))
|
||||
continue;
|
||||
|
||||
if (master->devs[pos].is_i2c_addr)
|
||||
reg_val = DEV_ADDR_TABLE_LEGACY_I2C_DEV |
|
||||
reg_val = readl(master->regs + DEV_ADDR_TABLE_LOC(master->datstartaddr, pos));
|
||||
|
||||
if (master->devs[pos].is_i2c_addr) {
|
||||
reg_val &= ~DEV_ADDR_TABLE_STATIC_MASK;
|
||||
reg_val |= DEV_ADDR_TABLE_LEGACY_I2C_DEV |
|
||||
DEV_ADDR_TABLE_STATIC_ADDR(master->devs[pos].addr);
|
||||
else
|
||||
reg_val = DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr);
|
||||
} else {
|
||||
reg_val &= ~DEV_ADDR_TABLE_DYNAMIC_MASK;
|
||||
reg_val |= DEV_ADDR_TABLE_DYNAMIC_ADDR(master->devs[pos].addr);
|
||||
}
|
||||
|
||||
writel(reg_val, master->regs + DEV_ADDR_TABLE_LOC(master->datstartaddr, pos));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -533,8 +533,8 @@ static int svc_i3c_master_handle_ibi_won(struct svc_i3c_master *master, u32 msta
|
|||
static void svc_i3c_master_ibi_isr(struct svc_i3c_master *master)
|
||||
{
|
||||
struct svc_i3c_i2c_dev_data *data;
|
||||
struct i3c_dev_desc *dev = NULL;
|
||||
unsigned int ibitype, ibiaddr;
|
||||
struct i3c_dev_desc *dev;
|
||||
u32 status, val;
|
||||
int ret;
|
||||
|
||||
|
|
@ -627,7 +627,7 @@ static void svc_i3c_master_ibi_isr(struct svc_i3c_master *master)
|
|||
* for the slave to interrupt again.
|
||||
*/
|
||||
if (svc_i3c_master_error(master)) {
|
||||
if (master->ibi.tbq_slot) {
|
||||
if (master->ibi.tbq_slot && dev) {
|
||||
data = i3c_dev_get_master_data(dev);
|
||||
i3c_generic_ibi_recycle_slot(data->ibi_pool,
|
||||
master->ibi.tbq_slot);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
* @I3C_ERROR_M2: M2 error
|
||||
*
|
||||
* These are the standard error codes as defined by the I3C specification.
|
||||
* When -EIO is returned by the i3c_device_do_priv_xfers() or
|
||||
* When -EIO is returned by the i3c_device_do_i3c_xfers() or
|
||||
* i3c_device_send_hdr_cmds() one can check the error code in
|
||||
* &struct_i3c_xfer.err or &struct i3c_hdr_cmd.err to get a better idea of
|
||||
* what went wrong.
|
||||
|
|
@ -79,9 +79,6 @@ struct i3c_xfer {
|
|||
enum i3c_error_code err;
|
||||
};
|
||||
|
||||
/* keep back compatible */
|
||||
#define i3c_priv_xfer i3c_xfer
|
||||
|
||||
/**
|
||||
* enum i3c_dcr - I3C DCR values
|
||||
* @I3C_DCR_GENERIC_DEVICE: generic I3C device
|
||||
|
|
@ -308,16 +305,24 @@ static __always_inline void i3c_i2c_driver_unregister(struct i3c_driver *i3cdrv,
|
|||
i3c_i2c_driver_unregister, \
|
||||
__i2cdrv)
|
||||
|
||||
#if IS_ENABLED(CONFIG_I3C)
|
||||
int i3c_device_do_xfers(struct i3c_device *dev, struct i3c_xfer *xfers,
|
||||
int nxfers, enum i3c_xfer_mode mode);
|
||||
|
||||
static inline int i3c_device_do_priv_xfers(struct i3c_device *dev,
|
||||
struct i3c_xfer *xfers,
|
||||
int nxfers)
|
||||
u32 i3c_device_get_supported_xfer_mode(struct i3c_device *dev);
|
||||
#else
|
||||
static inline int
|
||||
i3c_device_do_xfers(struct i3c_device *dev, struct i3c_xfer *xfers,
|
||||
int nxfers, enum i3c_xfer_mode mode)
|
||||
{
|
||||
return i3c_device_do_xfers(dev, xfers, nxfers, I3C_SDR);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline u32 i3c_device_get_supported_xfer_mode(struct i3c_device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int i3c_device_do_setdasa(struct i3c_device *dev);
|
||||
|
||||
void i3c_device_get_info(const struct i3c_device *dev, struct i3c_device_info *info);
|
||||
|
|
@ -358,6 +363,5 @@ int i3c_device_request_ibi(struct i3c_device *dev,
|
|||
void i3c_device_free_ibi(struct i3c_device *dev);
|
||||
int i3c_device_enable_ibi(struct i3c_device *dev);
|
||||
int i3c_device_disable_ibi(struct i3c_device *dev);
|
||||
u32 i3c_device_get_supported_xfer_mode(struct i3c_device *dev);
|
||||
|
||||
#endif /* I3C_DEV_H */
|
||||
|
|
|
|||
|
|
@ -462,6 +462,8 @@ struct i3c_bus {
|
|||
* @enable_hotjoin: enable hot join event detect.
|
||||
* @disable_hotjoin: disable hot join event detect.
|
||||
* @set_speed: adjust I3C open drain mode timing.
|
||||
* @set_dev_nack_retry: configure device NACK retry count for the master
|
||||
* controller.
|
||||
*/
|
||||
struct i3c_master_controller_ops {
|
||||
int (*bus_init)(struct i3c_master_controller *master);
|
||||
|
|
@ -491,6 +493,8 @@ struct i3c_master_controller_ops {
|
|||
int (*enable_hotjoin)(struct i3c_master_controller *master);
|
||||
int (*disable_hotjoin)(struct i3c_master_controller *master);
|
||||
int (*set_speed)(struct i3c_master_controller *master, enum i3c_open_drain_speed speed);
|
||||
int (*set_dev_nack_retry)(struct i3c_master_controller *master,
|
||||
unsigned long dev_nack_retry_cnt);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -514,6 +518,7 @@ struct i3c_master_controller_ops {
|
|||
* in a thread context. Typical examples are Hot Join processing which
|
||||
* requires taking the bus lock in maintenance, which in turn, can only
|
||||
* be done from a sleep-able context
|
||||
* @dev_nack_retry_count: retry count when slave device nack
|
||||
*
|
||||
* A &struct i3c_master_controller has to be registered to the I3C subsystem
|
||||
* through i3c_master_register(). None of &struct i3c_master_controller fields
|
||||
|
|
@ -534,6 +539,7 @@ struct i3c_master_controller {
|
|||
} boardinfo;
|
||||
struct i3c_bus bus;
|
||||
struct workqueue_struct *wq;
|
||||
unsigned int dev_nack_retry_count;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user