1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2023 Code Construct
5 * Author: Jeremy Kerr <jk@codeconstruct.com.au>
9 #include <linux/i3c/master.h>
10 #include <linux/reset.h>
11 #include <linux/types.h>
13 #define DW_I3C_MAX_DEVS 32
15 struct dw_i3c_master_caps
{
20 struct dw_i3c_dat_entry
{
23 struct i3c_dev_desc
*ibi_dev
;
26 struct dw_i3c_master
{
27 struct i3c_master_controller base
;
33 struct list_head list
;
34 struct dw_i3c_xfer
*cur
;
37 struct dw_i3c_master_caps caps
;
39 struct reset_control
*core_rst
;
55 * Per-device hardware data, used to manage the device address table
58 * Locking: the devs array may be referenced in IRQ context while
59 * processing an IBI. However, IBIs (for a specific device, which
60 * implies a specific DAT entry) can only happen while interrupts are
61 * requested for that device, which is serialised against other
62 * insertions/removals from the array by the global i3c infrastructure.
63 * So, devs_lock protects against concurrent updates to devs->ibi_dev
64 * between request_ibi/free_ibi and the IBI irq event.
66 struct dw_i3c_dat_entry devs
[DW_I3C_MAX_DEVS
];
69 /* platform-specific data */
70 const struct dw_i3c_platform_ops
*platform_ops
;
72 struct work_struct hj_work
;
75 struct dw_i3c_platform_ops
{
77 * Called on early bus init: the i3c has been set up, but before any
78 * transactions have taken place. Platform implementations may use to
79 * perform actual device enabling with the i3c core ready.
81 int (*init
)(struct dw_i3c_master
*i3c
);
84 * Initialise a DAT entry to enable/disable IBIs. Allows the platform
85 * to perform any device workarounds on the DAT entry before
86 * inserting into the hardware table.
88 * Called with the DAT lock held; must not sleep.
90 void (*set_dat_ibi
)(struct dw_i3c_master
*i3c
,
91 struct i3c_dev_desc
*dev
, bool enable
, u32
*reg
);
94 extern int dw_i3c_common_probe(struct dw_i3c_master
*master
,
95 struct platform_device
*pdev
);
96 extern void dw_i3c_common_remove(struct dw_i3c_master
*master
);