-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i3c/master: introduce the mipi-i3c-hci driver
This adds basic support for hardware implementing the MIPI I3C HCI specification. This driver is currently limited by the capabilities of the I3C subsystem, meaning things like scheduled commands, auto-commands and NCM mode are not yet supported. This supports version 1.0 of the MIPI I3C HCI spec, as well as the imminent release of version 1.1. Support for draft version 2.0 of the spec is also largely included with the caveat that future adjustments to this code are likely as the spec is still a work in progress. This is also lightly tested as actual hardware is still very scarce, even for HCI v1.0. Hence the EXPERIMENTAL tag. Further contributions to this driver are expected once vendor implementations and new I3C devices become available. Signed-off-by: Nicolas Pitre <npitre@baylibre.com> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Link: https://lore.kernel.org/linux-i3c/20201111220510.3622216-3-nico@fluxnic.net
- Loading branch information
Nicolas Pitre
authored and
Boris Brezillon
committed
Nov 23, 2020
1 parent
c307912
commit 9ad9a52
Showing
18 changed files
with
4,264 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
obj-$(CONFIG_CDNS_I3C_MASTER) += i3c-master-cdns.o | ||
obj-$(CONFIG_DW_I3C_MASTER) += dw-i3c-master.o | ||
obj-$(CONFIG_MIPI_I3C_HCI) += mipi-i3c-hci/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
obj-$(CONFIG_MIPI_I3C_HCI) += mipi-i3c-hci.o | ||
mipi-i3c-hci-y := core.o ext_caps.o pio.o dma.o \ | ||
cmd_v1.o cmd_v2.o \ | ||
dat_v1.o dct_v1.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause */ | ||
/* | ||
* Copyright (c) 2020, MIPI Alliance, Inc. | ||
* | ||
* Author: Nicolas Pitre <npitre@baylibre.com> | ||
* | ||
* Common command/response related stuff | ||
*/ | ||
|
||
#ifndef CMD_H | ||
#define CMD_H | ||
|
||
/* | ||
* Those bits are common to all descriptor formats and | ||
* may be manipulated by the core code. | ||
*/ | ||
#define CMD_0_TOC W0_BIT_(31) | ||
#define CMD_0_ROC W0_BIT_(30) | ||
#define CMD_0_ATTR W0_MASK(2, 0) | ||
|
||
/* | ||
* Response Descriptor Structure | ||
*/ | ||
#define RESP_STATUS(resp) FIELD_GET(GENMASK(31, 28), resp) | ||
#define RESP_TID(resp) FIELD_GET(GENMASK(27, 24), resp) | ||
#define RESP_DATA_LENGTH(resp) FIELD_GET(GENMASK(21, 0), resp) | ||
|
||
#define RESP_ERR_FIELD GENMASK(31, 28) | ||
|
||
enum hci_resp_err { | ||
RESP_SUCCESS = 0x0, | ||
RESP_ERR_CRC = 0x1, | ||
RESP_ERR_PARITY = 0x2, | ||
RESP_ERR_FRAME = 0x3, | ||
RESP_ERR_ADDR_HEADER = 0x4, | ||
RESP_ERR_BCAST_NACK_7E = 0x4, | ||
RESP_ERR_NACK = 0x5, | ||
RESP_ERR_OVL = 0x6, | ||
RESP_ERR_I3C_SHORT_READ = 0x7, | ||
RESP_ERR_HC_TERMINATED = 0x8, | ||
RESP_ERR_I2C_WR_DATA_NACK = 0x9, | ||
RESP_ERR_BUS_XFER_ABORTED = 0x9, | ||
RESP_ERR_NOT_SUPPORTED = 0xa, | ||
RESP_ERR_ABORTED_WITH_CRC = 0xb, | ||
/* 0xc to 0xf are reserved for transfer specific errors */ | ||
}; | ||
|
||
/* TID generation (4 bits wide in all cases) */ | ||
#define hci_get_tid(bits) \ | ||
(atomic_inc_return_relaxed(&hci->next_cmd_tid) % (1U << 4)) | ||
|
||
/* This abstracts operations with our command descriptor formats */ | ||
struct hci_cmd_ops { | ||
int (*prep_ccc)(struct i3c_hci *hci, struct hci_xfer *xfer, | ||
u8 ccc_addr, u8 ccc_cmd, bool raw); | ||
void (*prep_i3c_xfer)(struct i3c_hci *hci, struct i3c_dev_desc *dev, | ||
struct hci_xfer *xfer); | ||
void (*prep_i2c_xfer)(struct i3c_hci *hci, struct i2c_dev_desc *dev, | ||
struct hci_xfer *xfer); | ||
int (*perform_daa)(struct i3c_hci *hci); | ||
}; | ||
|
||
/* Our various instances */ | ||
extern const struct hci_cmd_ops mipi_i3c_hci_cmd_v1; | ||
extern const struct hci_cmd_ops mipi_i3c_hci_cmd_v2; | ||
|
||
#endif |
Oops, something went wrong.