Skip to content

Commit b9b627a

Browse files
committed
Merge tag 'i3c/for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux
Pull i3c updates from Boris Brezillon: "Core changes: - Make i3c_bus_set_mode() static Driver changes: - Add a per-SoC data_hold_delay property to the Cadence driver - Fix formatting issues in the 'CADENCE I3C MASTER IP' MAINTAINERS entry - Use devm_platform_ioremap_resource() where appropriate - Adjust DesignWare reattach logic" * tag 'i3c/for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux: i3c: master: dw: reattach device on first available location of address table i3c: master: cdns: convert to devm_platform_ioremap_resource i3c: master: dw: convert to devm_platform_ioremap_resource MAINTAINERS: fix style in CADENCE I3C MASTER IP entry i3c: master: make i3c_bus_set_mode static i3c: master: cdns: add data hold delay support
2 parents 067ba54 + 3952cf8 commit b9b627a

File tree

4 files changed

+68
-17
lines changed

4 files changed

+68
-17
lines changed

MAINTAINERS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7851,10 +7851,10 @@ F: Documentation/devicetree/bindings/i3c/snps,dw-i3c-master.txt
78517851
F: drivers/i3c/master/dw*
78527852

78537853
I3C DRIVER FOR CADENCE I3C MASTER IP
7854-
M: Przemysław Gaj <[email protected]>
7855-
S: Maintained
7856-
F: Documentation/devicetree/bindings/i3c/cdns,i3c-master.txt
7857-
F: drivers/i3c/master/i3c-master-cdns.c
7854+
M: Przemysław Gaj <[email protected]>
7855+
S: Maintained
7856+
F: Documentation/devicetree/bindings/i3c/cdns,i3c-master.txt
7857+
F: drivers/i3c/master/i3c-master-cdns.c
78587858

78597859
IA64 (Itanium) PLATFORM
78607860
M: Tony Luck <[email protected]>

drivers/i3c/master.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ static const struct device_type i3c_masterdev_type = {
527527
.groups = i3c_masterdev_groups,
528528
};
529529

530-
int i3c_bus_set_mode(struct i3c_bus *i3cbus, enum i3c_bus_mode mode,
531-
unsigned long max_i2c_scl_rate)
530+
static int i3c_bus_set_mode(struct i3c_bus *i3cbus, enum i3c_bus_mode mode,
531+
unsigned long max_i2c_scl_rate)
532532
{
533533
struct i3c_master_controller *master = i3c_bus_to_i3c_master(i3cbus);
534534

drivers/i3c/master/dw-i3c-master.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,22 @@ static int dw_i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev,
899899
struct dw_i3c_i2c_dev_data *data = i3c_dev_get_master_data(dev);
900900
struct i3c_master_controller *m = i3c_dev_get_master(dev);
901901
struct dw_i3c_master *master = to_dw_i3c_master(m);
902+
int pos;
903+
904+
pos = dw_i3c_master_get_free_pos(master);
905+
906+
if (data->index > pos && pos > 0) {
907+
writel(0,
908+
master->regs +
909+
DEV_ADDR_TABLE_LOC(master->datstartaddr, data->index));
910+
911+
master->addrs[data->index] = 0;
912+
master->free_pos |= BIT(data->index);
913+
914+
data->index = pos;
915+
master->addrs[pos] = dev->info.dyn_addr;
916+
master->free_pos &= ~BIT(pos);
917+
}
902918

903919
writel(DEV_ADDR_TABLE_DYNAMIC_ADDR(dev->info.dyn_addr),
904920
master->regs +
@@ -1100,15 +1116,13 @@ static const struct i3c_master_controller_ops dw_mipi_i3c_ops = {
11001116
static int dw_i3c_probe(struct platform_device *pdev)
11011117
{
11021118
struct dw_i3c_master *master;
1103-
struct resource *res;
11041119
int ret, irq;
11051120

11061121
master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL);
11071122
if (!master)
11081123
return -ENOMEM;
11091124

1110-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1111-
master->regs = devm_ioremap_resource(&pdev->dev, res);
1125+
master->regs = devm_platform_ioremap_resource(pdev, 0);
11121126
if (IS_ERR(master->regs))
11131127
return PTR_ERR(master->regs);
11141128

drivers/i3c/master/i3c-master-cdns.c

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/slab.h>
2323
#include <linux/spinlock.h>
2424
#include <linux/workqueue.h>
25+
#include <linux/of_device.h>
2526

2627
#define DEV_ID 0x0
2728
#define DEV_ID_I3C_MASTER 0x5034
@@ -60,6 +61,7 @@
6061
#define CTRL_HALT_EN BIT(30)
6162
#define CTRL_MCS BIT(29)
6263
#define CTRL_MCS_EN BIT(28)
64+
#define CTRL_THD_DELAY(x) (((x) << 24) & GENMASK(25, 24))
6365
#define CTRL_HJ_DISEC BIT(8)
6466
#define CTRL_MST_ACK BIT(7)
6567
#define CTRL_HJ_ACK BIT(6)
@@ -70,6 +72,7 @@
7072
#define CTRL_MIXED_FAST_BUS_MODE 2
7173
#define CTRL_MIXED_SLOW_BUS_MODE 3
7274
#define CTRL_BUS_MODE_MASK GENMASK(1, 0)
75+
#define THD_DELAY_MAX 3
7376

7477
#define PRESCL_CTRL0 0x14
7578
#define PRESCL_CTRL0_I2C(x) ((x) << 16)
@@ -388,6 +391,10 @@ struct cdns_i3c_xfer {
388391
struct cdns_i3c_cmd cmds[0];
389392
};
390393

394+
struct cdns_i3c_data {
395+
u8 thd_delay_ns;
396+
};
397+
391398
struct cdns_i3c_master {
392399
struct work_struct hj_work;
393400
struct i3c_master_controller base;
@@ -408,6 +415,7 @@ struct cdns_i3c_master {
408415
struct clk *pclk;
409416
struct cdns_i3c_master_caps caps;
410417
unsigned long i3c_scl_lim;
418+
const struct cdns_i3c_data *devdata;
411419
};
412420

413421
static inline struct cdns_i3c_master *
@@ -1181,6 +1189,20 @@ static int cdns_i3c_master_do_daa(struct i3c_master_controller *m)
11811189
return 0;
11821190
}
11831191

1192+
static u8 cdns_i3c_master_calculate_thd_delay(struct cdns_i3c_master *master)
1193+
{
1194+
unsigned long sysclk_rate = clk_get_rate(master->sysclk);
1195+
u8 thd_delay = DIV_ROUND_UP(master->devdata->thd_delay_ns,
1196+
(NSEC_PER_SEC / sysclk_rate));
1197+
1198+
/* Every value greater than 3 is not valid. */
1199+
if (thd_delay > THD_DELAY_MAX)
1200+
thd_delay = THD_DELAY_MAX;
1201+
1202+
/* CTLR_THD_DEL value is encoded. */
1203+
return (THD_DELAY_MAX - thd_delay);
1204+
}
1205+
11841206
static int cdns_i3c_master_bus_init(struct i3c_master_controller *m)
11851207
{
11861208
struct cdns_i3c_master *master = to_cdns_i3c_master(m);
@@ -1264,6 +1286,15 @@ static int cdns_i3c_master_bus_init(struct i3c_master_controller *m)
12641286
* We will issue ENTDAA afterwards from the threaded IRQ handler.
12651287
*/
12661288
ctrl |= CTRL_HJ_ACK | CTRL_HJ_DISEC | CTRL_HALT_EN | CTRL_MCS_EN;
1289+
1290+
/*
1291+
* Configure data hold delay based on device-specific data.
1292+
*
1293+
* MIPI I3C Specification 1.0 defines non-zero minimal tHD_PP timing on
1294+
* master output. This setting allows to meet this timing on master's
1295+
* SoC outputs, regardless of PCB balancing.
1296+
*/
1297+
ctrl |= CTRL_THD_DELAY(cdns_i3c_master_calculate_thd_delay(master));
12671298
writel(ctrl, master->regs + CTRL);
12681299

12691300
cdns_i3c_master_enable(master);
@@ -1521,19 +1552,30 @@ static void cdns_i3c_master_hj(struct work_struct *work)
15211552
i3c_master_do_daa(&master->base);
15221553
}
15231554

1555+
static struct cdns_i3c_data cdns_i3c_devdata = {
1556+
.thd_delay_ns = 10,
1557+
};
1558+
1559+
static const struct of_device_id cdns_i3c_master_of_ids[] = {
1560+
{ .compatible = "cdns,i3c-master", .data = &cdns_i3c_devdata },
1561+
{ /* sentinel */ },
1562+
};
1563+
15241564
static int cdns_i3c_master_probe(struct platform_device *pdev)
15251565
{
15261566
struct cdns_i3c_master *master;
1527-
struct resource *res;
15281567
int ret, irq;
15291568
u32 val;
15301569

15311570
master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL);
15321571
if (!master)
15331572
return -ENOMEM;
15341573

1535-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1536-
master->regs = devm_ioremap_resource(&pdev->dev, res);
1574+
master->devdata = of_device_get_match_data(&pdev->dev);
1575+
if (!master->devdata)
1576+
return -EINVAL;
1577+
1578+
master->regs = devm_platform_ioremap_resource(pdev, 0);
15371579
if (IS_ERR(master->regs))
15381580
return PTR_ERR(master->regs);
15391581

@@ -1631,11 +1673,6 @@ static int cdns_i3c_master_remove(struct platform_device *pdev)
16311673
return 0;
16321674
}
16331675

1634-
static const struct of_device_id cdns_i3c_master_of_ids[] = {
1635-
{ .compatible = "cdns,i3c-master" },
1636-
{ /* sentinel */ },
1637-
};
1638-
16391676
static struct platform_driver cdns_i3c_master = {
16401677
.probe = cdns_i3c_master_probe,
16411678
.remove = cdns_i3c_master_remove,

0 commit comments

Comments
 (0)