linux/include/ufs/ufs.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Universal Flash Storage Host controller driver
 * Copyright (C) 2011-2013 Samsung India Software Operations
 *
 * Authors:
 *	Santosh Yaraganavi <[email protected]>
 *	Vinayak Holikatti <[email protected]>
 */

#ifndef _UFS_H
#define _UFS_H

#include <linux/bitops.h>
#include <linux/types.h>
#include <uapi/scsi/scsi_bsg_ufs.h>
#include <linux/time64.h>

/*
 * Using static_assert() is not allowed in UAPI header files. Hence the check
 * in this header file of the size of struct utp_upiu_header.
 */
static_assert();

#define GENERAL_UPIU_REQUEST_SIZE
#define QUERY_DESC_MAX_SIZE
#define QUERY_DESC_MIN_SIZE
#define QUERY_DESC_HDR_SIZE
#define QUERY_OSF_SIZE
#define UFS_SENSE_SIZE

/*
 * UFS device may have standard LUs and LUN id could be from 0x00 to
 * 0x7F. Standard LUs use "Peripheral Device Addressing Format".
 * UFS device may also have the Well Known LUs (also referred as W-LU)
 * which again could be from 0x00 to 0x7F. For W-LUs, device only use
 * the "Extended Addressing Format" which means the W-LUNs would be
 * from 0xc100 (SCSI_W_LUN_BASE) onwards.
 * This means max. LUN number reported from UFS device could be 0xC17F.
 */
#define UFS_UPIU_MAX_UNIT_NUM_ID
#define UFS_MAX_LUNS
#define UFS_UPIU_WLUN_ID

/* WriteBooster buffer is available only for the logical unit from 0 to 7 */
#define UFS_UPIU_MAX_WB_LUN_ID

/*
 * WriteBooster buffer lifetime has a limit setted by vendor.
 * If it is over the limit, WriteBooster feature will be disabled.
 */
#define UFS_WB_EXCEED_LIFETIME

/*
 * In UFS Spec, the Extra Header Segment (EHS) starts from byte 32 in UPIU request/response packet
 */
#define EHS_OFFSET_IN_RESPONSE

/* Well known logical unit id in LUN field of UPIU */
enum {};

/*
 * UFS Protocol Information Unit related definitions
 */

/* Task management functions */
enum {};

/* UTP UPIU Transaction Codes Initiator to Target */
enum upiu_request_transaction {};

/* UTP UPIU Transaction Codes Target to Initiator */
enum upiu_response_transaction {};

/* UPIU Read/Write flags. See also table "UPIU Flags" in the UFS standard. */
enum {};

/* UPIU response flags */
enum {};

/* UPIU Task Attributes */
enum {};

/* UPIU Query request function */
enum {};

/* Flag idn for Query Requests*/
enum flag_idn {};

/* Attribute idn for Query requests */
enum attr_idn {};

/* Descriptor idn for Query requests */
enum desc_idn {};

enum desc_header_offset {};

/* Unit descriptor parameters offsets in bytes*/
enum unit_desc_param {};

/* RPMB Unit descriptor parameters offsets in bytes*/
enum rpmb_unit_desc_param {};

/* Device descriptor parameters offsets in bytes*/
enum device_desc_param {};

/* Interconnect descriptor parameters offsets in bytes*/
enum interconnect_desc_param {};

/* Geometry descriptor parameters offsets in bytes*/
enum geometry_desc_param {};

/* Health descriptor parameters offsets in bytes*/
enum health_desc_param {};

/* WriteBooster buffer mode */
enum {};

/*
 * Logical Unit Write Protect
 * 00h: LU not write protected
 * 01h: LU write protected when fPowerOnWPEn =1
 * 02h: LU permanently write protected when fPermanentWPEn =1
 */
enum ufs_lu_wp_type {};

/* bActiveICCLevel parameter current units */
enum {};

/* Possible values for dExtendedUFSFeaturesSupport */
enum {};
#define UFS_DEV_HPB_SUPPORT_VERSION

#define POWER_DESC_MAX_ACTV_ICC_LVLS

/* Attribute  bActiveICCLevel parameter bit masks definitions */
#define ATTR_ICC_LVL_UNIT_OFFSET
#define ATTR_ICC_LVL_UNIT_MASK
#define ATTR_ICC_LVL_VALUE_MASK

/* Power descriptor parameters offsets in bytes */
enum power_desc_param_offset {};

/* Exception event mask values */
enum {};
#define MASK_EE_URGENT_TEMP

/* Background operation status */
enum bkops_status {};

/* UTP QUERY Transaction Specific Fields OpCode */
enum query_opcode {};

/* bRefClkFreq attribute values */
enum ufs_ref_clk_freq {};

/* Query response result code */
enum {};

/* UTP Transfer Request Command Type (CT) */
enum {};

/* Offset of the response code in the UPIU header */
#define UPIU_RSP_CODE_OFFSET

enum {};

/* Task management service response */
enum {};

/* UFS device power modes */
enum ufs_dev_pwr_mode {};

#define UFS_WB_BUF_REMAIN_PERCENT(val)

/**
 * struct utp_cmd_rsp - Response UPIU structure
 * @residual_transfer_count: Residual transfer count DW-3
 * @reserved: Reserved double words DW-4 to DW-7
 * @sense_data_len: Sense data length DW-8 U16
 * @sense_data: Sense data field DW-8 to DW-12
 */
struct utp_cmd_rsp {};

/**
 * struct utp_upiu_rsp - general upiu response structure
 * @header: UPIU header structure DW-0 to DW-2
 * @sr: fields structure for scsi command DW-3 to DW-12
 * @qr: fields structure for query request DW-3 to DW-7
 */
struct utp_upiu_rsp {};

/*
 * VCCQ & VCCQ2 current requirement when UFS device is in sleep state
 * and link is in Hibern8 state.
 */
#define UFS_VREG_LPM_LOAD_UA

struct ufs_vreg {};

struct ufs_vreg_info {};

/* UFS device descriptor wPeriodicRTCUpdate bit9 defines RTC time baseline */
#define UFS_RTC_TIME_BASELINE

enum ufs_rtc_time {};

struct ufs_dev_info {};

/*
 * This enum is used in string mapping in include/trace/events/ufs.h.
 */
enum ufs_trace_str_t {};

/*
 * Transaction Specific Fields (TSF) type in the UPIU package, this enum is
 * used in include/trace/events/ufs.h for UFS command trace.
 */
enum ufs_trace_tsf_t {};

#endif /* End of Header */