blob: 80837ebddcd43e1d75fd6829336d086db44b02db [file] [log] [blame]
// Copyright 2024 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.hardware.ufs;
/// Maximum size for a descriptor (in bytes).
const MAX_DESCRIPTOR_SIZE uint32 = 256;
/// Descriptor identification values.
/// Defined in UFS 3.1, Section 14.1.1: Descriptor Types.
type DescriptorType = flexible enum : uint8 {
DEVICE = 0x00;
CONFIGURATION = 0X01;
UNIT = 0x02;
INTERCONNECT = 0x04;
STRING = 0x05;
GEOMETRY = 0x07;
POWER = 0x08;
DEVICE_HEALTH = 0x09;
};
/// Identifier is used to identify or distinguish specific elements.
type Identifier = table {
/// The Index value is used to identify a specific element in Descriptor, Flag, Attribute, etc.,
/// and is set within the range of 0 to 255 to select or distinguish a particular item from
/// multiple elements.
1: index uint8;
/// The selector may be used to further identify a specific element of an attribute,
/// descriptor, or flag.
2: selector uint8;
};
/// Data required for reading and writing a Descriptor.
type Descriptor = table {
/// Descriptor identification values.
1: type DescriptorType;
/// Identifier for identifying or distinguishing specific elements.
/// The index value is used to identify a specific descriptor from multiple descriptors
/// (ranging from 0 to 255), and the selector field may be needed to further identify
/// a particular descriptor.
2: identifier Identifier;
/// The number of bytes to read from or write to the Descriptor.
3: length uint16;
};
/// Defined in UFS 3.1, Section 14.2: Flags.
type FlagType = flexible enum : uint8 {
DEVICE_INIT = 0x01;
PERMANENT_WP_EN = 0x02;
POWER_ON_WP_EN = 0x03;
BACKGROUND_OPS_EN = 0x04;
DEVICE_LIFE_SPAN_MODE_EN = 0x05;
PURGE_ENABLE = 0x06;
REFRESH_ENABLE = 0x07;
PHY_RESOURCE_REMOVAL = 0x08;
BUSY_RTC = 0x09;
PERMANENTLY_DISABLE_FW_UPDATE = 0x0B;
WRITE_BOOSTER_EN = 0x0E;
WRITE_BOOSTER_BUFFER_FLUSH_EN = 0x0F;
WRITE_BOOSTER_BUFFER_FLUSH_HIBERNATE = 0x10;
};
/// Data required for reading, setting, resetting, clearing, or toggling a flag.
type Flag = table {
/// Flag identification values.
1: type FlagType;
/// The index value may be needed to identify a specific element of a flag,
/// and the selector may be used to further identify a specific element of a flag.
2: identifier Identifier;
};
/// Defined in UFS 3.1, Section 14.3: Attributes.
type AttributeType = flexible enum : uint8 {
BOOT_LUN_EN = 0x00;
CURRENT_POWER_MODE = 0x02;
ACTIVE_ICC_LEVEL = 0x03;
OUT_OF_ORDER_DATA_EN = 0x04;
BACKGROUND_OP_STATUS = 0x05;
PURGE_STATUS = 0x06;
MAX_DATA_IN_SIZE = 0x07;
MAX_DATA_OUT_SIZE = 0x08;
DYN_CAP_NEEDED = 0x09;
REF_CLK_FREQ = 0x0A;
CONFIG_DESCR_LOCK = 0x0B;
MAX_NUM_OF_RTT = 0x0C;
EXCEPTION_EVENT_CONTROL = 0x0D;
EXCEPTION_EVENT_STATUS = 0x0E;
SECONDS_PASSED = 0x0F;
CONTEXT_CONF = 0x10;
DEVICE_FFU_STATUS = 0x14;
PSA_STATE = 0x15;
PSA_DATA_SIZE = 0x16;
REF_CLK_GATING_WAIT_TIME = 0x17;
DEVICE_CASE_ROUGH_TEMPERATURE = 0x18;
DEVICE_TOO_HIGH_TEMP_BOUNDARY = 0x19;
DEVICE_TOO_LOW_TEMP_BOUNDARY = 0x1A;
THROTTLING_STATUS = 0x1B;
WRITE_BOOSTER_BUFFER_FLUSH_STATUS = 0x1C;
AVAILABLE_WRITE_BOOSTER_BUFFER_SIZE = 0x1D;
WRITE_BOOSTER_BUFFER_LIFE_TIME_EST = 0x1E;
CURRENT_WRITE_BOOSTER_BUFFER_SIZE = 0x1F;
REFRESH_STATUS = 0x2C;
REFRESH_FREQ = 0x2D;
REFRESH_UNIT = 0x2E;
REFRESH_METHOD = 0x2F;
};
type Attribute = table {
/// Attribute identification values.
1: type AttributeType;
/// Index identifies an element in an attribute array (0-255), or is 0 for single-element
/// attributes, and the selector is used if needed, otherwise set to 0.
2: identifier Identifier;
};
/// Defines various error codes for query-related operations.
type QueryErrorCode = flexible enum {
PARAMETER_NOT_READABLE = 0xF6;
PARAMETER_NOT_WRITEABLE = 0xF7;
PARAMETER_ALREADY_WRITTEN = 0xF8;
INVALID_LENGTH = 0xF9;
INVALID_VALUE = 0xFA;
INVALID_SELECTOR = 0xFB;
INVALID_INDEX = 0xFC;
INVALID_IDN = 0xFD;
INVALID_OPCODE = 0xFE;
GENERAL_FAILURE = 0xFF;
};