Skip to content

Commit 080ffb4

Browse files
committed
Merge tag 'i3c/for-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux
Pull i3c updates from Alexandre Belloni: "New driver: - Analog Devices I3C Controller Subsystem: - fix big-endian FIFO transfers - fix default I2C adapter timeout value Drivers: - dw: shutdown support - mipi-i3c-hci: Intel Wildcat Lake-U support, IOMMU support - renesas: RZ/V2H(P) and RZ/V2N support" * tag 'i3c/for-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/i3c/linux: (22 commits) i3c: fix big-endian FIFO transfers i3c: master: adi: fix number of bytes written to fifo i3c: Remove superfluous FIXME i3c: master: adi: fix header location i3c: dw: Add shutdown support to dw_i3c_master driver i3c: renesas: Simplify return statement in 'renesas_i3c_daa' dt-bindings: i3c: renesas,i3c: Add RZ/V2H(P) and RZ/V2N support i3c: master: svc: Recycle unused IBI slot i3c: master: svc: Use manual response for IBI events i3c: master: Add driver for Analog Devices I3C Controller IP dt-bindings: i3c: Add adi-i3c-master i3c: Fix default I2C adapter timeout value i3c: mipi-i3c-hci: Convert remaining DBG() prints to dev_dbg() i3c: mipi-i3c-hci: Remove function enter DBG() printouts i3c: mipi-i3c-hci: Uniform ring number printouts i3c: mipi-i3c-hci: Remove nonexistent ring interrupt i3c: mipi-i3c-hci: Change interrupt status prints to dev_dbg() i3c: mipi-i3c-hci: Use own DMA bounce buffer management for I2C transfers i3c: mipi-i3c-hci: Use physical device pointer with DMA API i3c: mipi-i3c-hci: Use core helpers for DMA mapping and bounce buffering ...
2 parents cf8da11 + d6ddd9b commit 080ffb4

20 files changed

Lines changed: 1410 additions & 168 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/i3c/adi,i3c-master.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Analog Devices I3C Controller
8+
9+
description:
10+
FPGA-based I3C controller designed to interface with I3C and I2C peripherals,
11+
implementing a subset of the I3C-basic specification. The IP core is tested
12+
on arm, microblaze, and arm64 architectures.
13+
14+
https://analogdevicesinc.github.io/hdl/library/i3c_controller
15+
16+
maintainers:
17+
- Jorge Marques <jorge.marques@analog.com>
18+
19+
properties:
20+
compatible:
21+
const: adi,i3c-master-v1
22+
23+
reg:
24+
maxItems: 1
25+
26+
clocks:
27+
minItems: 1
28+
items:
29+
- description: The AXI interconnect clock, drives the register map.
30+
- description:
31+
The secondary clock, drives the internal logic asynchronously to the
32+
register map. The presence of this entry states that the IP Core was
33+
synthesized with a second clock input, and the absence of this entry
34+
indicates a topology where a single clock input drives all the
35+
internal logic.
36+
37+
clock-names:
38+
minItems: 1
39+
items:
40+
- const: axi
41+
- const: i3c
42+
43+
interrupts:
44+
maxItems: 1
45+
46+
required:
47+
- compatible
48+
- reg
49+
- clocks
50+
- clock-names
51+
- interrupts
52+
53+
allOf:
54+
- $ref: i3c.yaml#
55+
56+
unevaluatedProperties: false
57+
58+
examples:
59+
- |
60+
#include <dt-bindings/interrupt-controller/irq.h>
61+
62+
i3c@44a00000 {
63+
compatible = "adi,i3c-master-v1";
64+
reg = <0x44a00000 0x1000>;
65+
interrupts = <3 IRQ_TYPE_LEVEL_HIGH>;
66+
clocks = <&clkc 15>, <&clkc 15>;
67+
clock-names = "axi", "i3c";
68+
#address-cells = <3>;
69+
#size-cells = <0>;
70+
71+
/* I3C and I2C devices */
72+
};

Documentation/devicetree/bindings/i3c/renesas,i3c.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@
44
$id: http://devicetree.org/schemas/i3c/renesas,i3c.yaml#
55
$schema: http://devicetree.org/meta-schemas/core.yaml#
66

7-
title: Renesas RZ/G3S and RZ/G3E I3C Bus Interface
7+
title: Renesas I3C Bus Interface
88

99
maintainers:
1010
- Wolfram Sang <wsa+renesas@sang-engineering.com>
1111
- Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
1212

1313
properties:
1414
compatible:
15-
items:
16-
- enum:
17-
- renesas,r9a08g045-i3c # RZ/G3S
18-
- renesas,r9a09g047-i3c # RZ/G3E
15+
oneOf:
16+
- items:
17+
- enum:
18+
- renesas,r9a08g045-i3c # RZ/G3S
19+
- renesas,r9a09g047-i3c # RZ/G3E
20+
- items:
21+
- enum:
22+
- renesas,r9a09g056-i3c # RZ/V2N
23+
- renesas,r9a09g057-i3c # RZ/V2H(P)
24+
- const: renesas,r9a09g047-i3c
1925

2026
reg:
2127
maxItems: 1

MAINTAINERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11674,6 +11674,12 @@ S: Maintained
1167411674
F: Documentation/devicetree/bindings/i3c/aspeed,ast2600-i3c.yaml
1167511675
F: drivers/i3c/master/ast2600-i3c-master.c
1167611676

11677+
I3C DRIVER FOR ANALOG DEVICES I3C CONTROLLER IP
11678+
M: Jorge Marques <jorge.marques@analog.com>
11679+
S: Maintained
11680+
F: Documentation/devicetree/bindings/i3c/adi,i3c-master.yaml
11681+
F: drivers/i3c/master/adi-i3c-master.c
11682+
1167711683
I3C DRIVER FOR CADENCE I3C MASTER IP
1167811684
M: Przemysław Gaj <pgaj@cadence.com>
1167911685
S: Maintained

drivers/i3c/internals.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ static inline void i3c_writel_fifo(void __iomem *addr, const void *buf,
3838
u32 tmp = 0;
3939

4040
memcpy(&tmp, buf + (nbytes & ~3), nbytes & 3);
41-
writel(tmp, addr);
41+
/*
42+
* writesl() instead of writel() to keep FIFO
43+
* byteorder on big-endian targets
44+
*/
45+
writesl(addr, &tmp, 1);
4246
}
4347
}
4448

@@ -55,7 +59,11 @@ static inline void i3c_readl_fifo(const void __iomem *addr, void *buf,
5559
if (nbytes & 3) {
5660
u32 tmp;
5761

58-
tmp = readl(addr);
62+
/*
63+
* readsl() instead of readl() to keep FIFO
64+
* byteorder on big-endian targets
65+
*/
66+
readsl(addr, &tmp, 1);
5967
memcpy(buf + (nbytes & ~3), &tmp, nbytes & 3);
6068
}
6169
}

drivers/i3c/master.c

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/atomic.h>
99
#include <linux/bug.h>
1010
#include <linux/device.h>
11+
#include <linux/dma-mapping.h>
1112
#include <linux/err.h>
1213
#include <linux/export.h>
1314
#include <linux/kernel.h>
@@ -1727,6 +1728,79 @@ int i3c_master_do_daa(struct i3c_master_controller *master)
17271728
}
17281729
EXPORT_SYMBOL_GPL(i3c_master_do_daa);
17291730

1731+
/**
1732+
* i3c_master_dma_map_single() - Map buffer for single DMA transfer
1733+
* @dev: device object of a device doing DMA
1734+
* @buf: destination/source buffer for DMA
1735+
* @len: length of transfer
1736+
* @force_bounce: true, force to use a bounce buffer,
1737+
* false, function will auto check is a bounce buffer required
1738+
* @dir: DMA direction
1739+
*
1740+
* Map buffer for a DMA transfer and allocate a bounce buffer if required.
1741+
*
1742+
* Return: I3C DMA transfer descriptor or NULL in case of error.
1743+
*/
1744+
struct i3c_dma *i3c_master_dma_map_single(struct device *dev, void *buf,
1745+
size_t len, bool force_bounce, enum dma_data_direction dir)
1746+
{
1747+
struct i3c_dma *dma_xfer __free(kfree) = NULL;
1748+
void *bounce __free(kfree) = NULL;
1749+
void *dma_buf = buf;
1750+
1751+
dma_xfer = kzalloc(sizeof(*dma_xfer), GFP_KERNEL);
1752+
if (!dma_xfer)
1753+
return NULL;
1754+
1755+
dma_xfer->dev = dev;
1756+
dma_xfer->buf = buf;
1757+
dma_xfer->dir = dir;
1758+
dma_xfer->len = len;
1759+
dma_xfer->map_len = len;
1760+
1761+
if (is_vmalloc_addr(buf))
1762+
force_bounce = true;
1763+
1764+
if (force_bounce) {
1765+
dma_xfer->map_len = ALIGN(len, cache_line_size());
1766+
if (dir == DMA_FROM_DEVICE)
1767+
bounce = kzalloc(dma_xfer->map_len, GFP_KERNEL);
1768+
else
1769+
bounce = kmemdup(buf, dma_xfer->map_len, GFP_KERNEL);
1770+
if (!bounce)
1771+
return NULL;
1772+
dma_buf = bounce;
1773+
}
1774+
1775+
dma_xfer->addr = dma_map_single(dev, dma_buf, dma_xfer->map_len, dir);
1776+
if (dma_mapping_error(dev, dma_xfer->addr))
1777+
return NULL;
1778+
1779+
dma_xfer->bounce_buf = no_free_ptr(bounce);
1780+
return no_free_ptr(dma_xfer);
1781+
}
1782+
EXPORT_SYMBOL_GPL(i3c_master_dma_map_single);
1783+
1784+
/**
1785+
* i3c_master_dma_unmap_single() - Unmap buffer after DMA
1786+
* @dma_xfer: DMA transfer and mapping descriptor
1787+
*
1788+
* Unmap buffer and cleanup DMA transfer descriptor.
1789+
*/
1790+
void i3c_master_dma_unmap_single(struct i3c_dma *dma_xfer)
1791+
{
1792+
dma_unmap_single(dma_xfer->dev, dma_xfer->addr,
1793+
dma_xfer->map_len, dma_xfer->dir);
1794+
if (dma_xfer->bounce_buf) {
1795+
if (dma_xfer->dir == DMA_FROM_DEVICE)
1796+
memcpy(dma_xfer->buf, dma_xfer->bounce_buf,
1797+
dma_xfer->len);
1798+
kfree(dma_xfer->bounce_buf);
1799+
}
1800+
kfree(dma_xfer);
1801+
}
1802+
EXPORT_SYMBOL_GPL(i3c_master_dma_unmap_single);
1803+
17301804
/**
17311805
* i3c_master_set_info() - set master device information
17321806
* @master: master used to send frames on the bus
@@ -2490,9 +2564,7 @@ static int i3c_master_i2c_adapter_init(struct i3c_master_controller *master)
24902564
adap->owner = master->dev.parent->driver->owner;
24912565
adap->algo = &i3c_master_i2c_algo;
24922566
strscpy(adap->name, dev_name(master->dev.parent), sizeof(adap->name));
2493-
2494-
/* FIXME: Should we allow i3c masters to override these values? */
2495-
adap->timeout = 1000;
2567+
adap->timeout = HZ;
24962568
adap->retries = 3;
24972569

24982570
id = of_alias_get_id(master->dev.of_node, "i2c");

drivers/i3c/master/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2+
config ADI_I3C_MASTER
3+
tristate "Analog Devices I3C master driver"
4+
depends on HAS_IOMEM
5+
help
6+
Support for Analog Devices I3C Controller IP, an AXI-interfaced IP
7+
core that supports I3C and I2C devices, multiple speed-grades and I3C
8+
IBIs.
9+
10+
This driver can also be built as a module. If so, the module will be
11+
called adi-i3c-master.
12+
213
config CDNS_I3C_MASTER
314
tristate "Cadence I3C master driver"
415
depends on HAS_IOMEM

drivers/i3c/master/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2+
obj-$(CONFIG_ADI_I3C_MASTER) += adi-i3c-master.o
23
obj-$(CONFIG_CDNS_I3C_MASTER) += i3c-master-cdns.o
34
obj-$(CONFIG_DW_I3C_MASTER) += dw-i3c-master.o
45
obj-$(CONFIG_AST2600_I3C_MASTER) += ast2600-i3c-master.o

0 commit comments

Comments
 (0)