162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2020, MIPI Alliance, Inc.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Author: Nicolas Pitre <npitre@baylibre.com>
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Transfer Mode/Rate Table definitions as found in extended capability
862306a36Sopenharmony_ci * sections 0x04 and 0x08.
962306a36Sopenharmony_ci * This applies starting from I3C HCI v2.0.
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef XFER_MODE_RATE_H
1362306a36Sopenharmony_ci#define XFER_MODE_RATE_H
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/*
1662306a36Sopenharmony_ci * Master Transfer Mode Table Fixed Indexes.
1762306a36Sopenharmony_ci *
1862306a36Sopenharmony_ci * Indexes 0x0 and 0x8 are mandatory. Availability for the rest must be
1962306a36Sopenharmony_ci * obtained from the mode table in the extended capability area.
2062306a36Sopenharmony_ci * Presence and definitions for indexes beyond these ones may vary.
2162306a36Sopenharmony_ci */
2262306a36Sopenharmony_ci#define XFERMODE_IDX_I3C_SDR		0x00	/* I3C SDR Mode */
2362306a36Sopenharmony_ci#define XFERMODE_IDX_I3C_HDR_DDR	0x01	/* I3C HDR-DDR Mode */
2462306a36Sopenharmony_ci#define XFERMODE_IDX_I3C_HDR_T		0x02	/* I3C HDR-Ternary Mode */
2562306a36Sopenharmony_ci#define XFERMODE_IDX_I3C_HDR_BT		0x03	/* I3C HDR-BT Mode */
2662306a36Sopenharmony_ci#define XFERMODE_IDX_I2C		0x08	/* Legacy I2C Mode */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/*
2962306a36Sopenharmony_ci * Transfer Mode Table Entry Bits Definitions
3062306a36Sopenharmony_ci */
3162306a36Sopenharmony_ci#define XFERMODE_VALID_XFER_ADD_FUNC	GENMASK(21, 16)
3262306a36Sopenharmony_ci#define XFERMODE_ML_DATA_XFER_CODING	GENMASK(15, 11)
3362306a36Sopenharmony_ci#define XFERMODE_ML_ADDL_LANES		GENMASK(10, 8)
3462306a36Sopenharmony_ci#define XFERMODE_SUPPORTED		BIT(7)
3562306a36Sopenharmony_ci#define XFERMODE_MODE			GENMASK(3, 0)
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci/*
3862306a36Sopenharmony_ci * Master Data Transfer Rate Selector Values.
3962306a36Sopenharmony_ci *
4062306a36Sopenharmony_ci * These are the values to be used in the command descriptor XFER_RATE field
4162306a36Sopenharmony_ci * and found in the RATE_ID field below.
4262306a36Sopenharmony_ci * The I3C_SDR0, I3C_SDR1, I3C_SDR2, I3C_SDR3, I3C_SDR4 and I2C_FM rates
4362306a36Sopenharmony_ci * are required, everything else is optional and discoverable in the
4462306a36Sopenharmony_ci * Data Transfer Rate Table. Indicated are typical rates. The actual
4562306a36Sopenharmony_ci * rates may vary slightly and are also specified in the Data Transfer
4662306a36Sopenharmony_ci * Rate Table.
4762306a36Sopenharmony_ci */
4862306a36Sopenharmony_ci#define XFERRATE_I3C_SDR0		0x00	/* 12.5 MHz */
4962306a36Sopenharmony_ci#define XFERRATE_I3C_SDR1		0x01	/* 8 MHz */
5062306a36Sopenharmony_ci#define XFERRATE_I3C_SDR2		0x02	/* 6 MHz */
5162306a36Sopenharmony_ci#define XFERRATE_I3C_SDR3		0x03	/* 4 MHz */
5262306a36Sopenharmony_ci#define XFERRATE_I3C_SDR4		0x04	/* 2 MHz */
5362306a36Sopenharmony_ci#define XFERRATE_I3C_SDR_FM_FMP		0x05	/* 400 KHz / 1 MHz */
5462306a36Sopenharmony_ci#define XFERRATE_I3C_SDR_USER6		0x06	/* User Defined */
5562306a36Sopenharmony_ci#define XFERRATE_I3C_SDR_USER7		0x07	/* User Defined */
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#define XFERRATE_I2C_FM			0x00	/* 400 KHz */
5862306a36Sopenharmony_ci#define XFERRATE_I2C_FMP		0x01	/* 1 MHz */
5962306a36Sopenharmony_ci#define XFERRATE_I2C_USER2		0x02	/* User Defined */
6062306a36Sopenharmony_ci#define XFERRATE_I2C_USER3		0x03	/* User Defined */
6162306a36Sopenharmony_ci#define XFERRATE_I2C_USER4		0x04	/* User Defined */
6262306a36Sopenharmony_ci#define XFERRATE_I2C_USER5		0x05	/* User Defined */
6362306a36Sopenharmony_ci#define XFERRATE_I2C_USER6		0x06	/* User Defined */
6462306a36Sopenharmony_ci#define XFERRATE_I2C_USER7		0x07	/* User Defined */
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci/*
6762306a36Sopenharmony_ci * Master Data Transfer Rate Table Mode ID values.
6862306a36Sopenharmony_ci */
6962306a36Sopenharmony_ci#define XFERRATE_MODE_I3C		0x00
7062306a36Sopenharmony_ci#define XFERRATE_MODE_I2C		0x08
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/*
7362306a36Sopenharmony_ci * Master Data Transfer Rate Table Entry Bits Definitions
7462306a36Sopenharmony_ci */
7562306a36Sopenharmony_ci#define XFERRATE_MODE_ID		GENMASK(31, 28)
7662306a36Sopenharmony_ci#define XFERRATE_RATE_ID		GENMASK(22, 20)
7762306a36Sopenharmony_ci#define XFERRATE_ACTUAL_RATE_KHZ	GENMASK(19, 0)
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#endif
80