linux/drivers/ufs/core/ufs-sysfs.c

// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2018 Western Digital Corporation

#include <linux/err.h>
#include <linux/string.h>
#include <linux/bitfield.h>
#include <linux/unaligned.h>

#include <ufs/ufs.h>
#include <ufs/unipro.h>
#include "ufs-sysfs.h"
#include "ufshcd-priv.h"

static const char *ufs_pa_pwr_mode_to_string(enum ufs_pa_pwr_mode mode)
{}

static const char *ufs_hs_gear_rate_to_string(enum ufs_hs_gear_rate rate)
{}

static const char *ufs_pwm_gear_to_string(enum ufs_pwm_gear_tag gear)
{}

static const char *ufs_hs_gear_to_string(enum ufs_hs_gear_tag gear)
{}

static const char *ufshcd_uic_link_state_to_string(
			enum uic_link_state state)
{}

static const char *ufshcd_ufs_dev_pwr_mode_to_string(
			enum ufs_dev_pwr_mode state)
{}

static inline ssize_t ufs_sysfs_pm_lvl_store(struct device *dev,
					     struct device_attribute *attr,
					     const char *buf, size_t count,
					     bool rpm)
{}

static ssize_t rpm_lvl_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t rpm_lvl_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{}

static ssize_t rpm_target_dev_state_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t rpm_target_link_state_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t spm_lvl_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t spm_lvl_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{}

static ssize_t spm_target_dev_state_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t spm_target_link_state_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

/* Convert Auto-Hibernate Idle Timer register value to microseconds */
static int ufshcd_ahit_to_us(u32 ahit)
{}

/* Convert microseconds to Auto-Hibernate Idle Timer register value */
static u32 ufshcd_us_to_ahit(unsigned int timer)
{}

static int ufshcd_read_hci_reg(struct ufs_hba *hba, u32 *val, unsigned int reg)
{}

static ssize_t auto_hibern8_show(struct device *dev,
				 struct device_attribute *attr, char *buf)
{}

static ssize_t auto_hibern8_store(struct device *dev,
				  struct device_attribute *attr,
				  const char *buf, size_t count)
{}

static ssize_t wb_on_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{}

static ssize_t wb_on_store(struct device *dev, struct device_attribute *attr,
			   const char *buf, size_t count)
{}

static ssize_t rtc_update_ms_show(struct device *dev, struct device_attribute *attr,
				  char *buf)
{}

static ssize_t rtc_update_ms_store(struct device *dev, struct device_attribute *attr,
				   const char *buf, size_t count)
{}

static ssize_t enable_wb_buf_flush_show(struct device *dev,
				    struct device_attribute *attr,
				    char *buf)
{}

static ssize_t enable_wb_buf_flush_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{}

static ssize_t wb_flush_threshold_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{}

static ssize_t wb_flush_threshold_store(struct device *dev,
					  struct device_attribute *attr,
					  const char *buf, size_t count)
{}

/**
 * pm_qos_enable_show - sysfs handler to show pm qos enable value
 * @dev: device associated with the UFS controller
 * @attr: sysfs attribute handle
 * @buf: buffer for sysfs file
 *
 * Print 1 if PM QoS feature is enabled, 0 if disabled.
 *
 * Returns number of characters written to @buf.
 */
static ssize_t pm_qos_enable_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

/**
 * pm_qos_enable_store - sysfs handler to store value
 * @dev: device associated with the UFS controller
 * @attr: sysfs attribute handle
 * @buf: buffer for sysfs file
 * @count: stores buffer characters count
 *
 * Input 0 to disable PM QoS and 1 value to enable.
 * Default state: 1
 *
 * Return: number of characters written to @buf on success, < 0 upon failure.
 */
static ssize_t pm_qos_enable_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{}

static DEVICE_ATTR_RW(rpm_lvl);
static DEVICE_ATTR_RO(rpm_target_dev_state);
static DEVICE_ATTR_RO(rpm_target_link_state);
static DEVICE_ATTR_RW(spm_lvl);
static DEVICE_ATTR_RO(spm_target_dev_state);
static DEVICE_ATTR_RO(spm_target_link_state);
static DEVICE_ATTR_RW(auto_hibern8);
static DEVICE_ATTR_RW(wb_on);
static DEVICE_ATTR_RW(enable_wb_buf_flush);
static DEVICE_ATTR_RW(wb_flush_threshold);
static DEVICE_ATTR_RW(rtc_update_ms);
static DEVICE_ATTR_RW(pm_qos_enable);

static struct attribute *ufs_sysfs_ufshcd_attrs[] =;

static const struct attribute_group ufs_sysfs_default_group =;

static ssize_t clock_scaling_show(struct device *dev, struct device_attribute *attr,
				  char *buf)
{}

static ssize_t write_booster_show(struct device *dev, struct device_attribute *attr,
				  char *buf)
{}

static DEVICE_ATTR_RO(clock_scaling);
static DEVICE_ATTR_RO(write_booster);

/*
 * See Documentation/ABI/testing/sysfs-driver-ufs for the semantics of this
 * group.
 */
static struct attribute *ufs_sysfs_capabilities_attrs[] =;

static const struct attribute_group ufs_sysfs_capabilities_group =;

static ssize_t version_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t product_id_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t man_id_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(version);
static DEVICE_ATTR_RO(product_id);
static DEVICE_ATTR_RO(man_id);

static struct attribute *ufs_sysfs_ufshci_cap_attrs[] =;

static const struct attribute_group ufs_sysfs_ufshci_group =;

static ssize_t monitor_enable_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}

static ssize_t monitor_enable_store(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t count)
{}

static ssize_t monitor_chunk_size_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}

static ssize_t monitor_chunk_size_store(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t count)
{}

static ssize_t read_total_sectors_show(struct device *dev,
				       struct device_attribute *attr, char *buf)
{}

static ssize_t read_total_busy_show(struct device *dev,
				    struct device_attribute *attr, char *buf)
{}

static ssize_t read_nr_requests_show(struct device *dev,
				     struct device_attribute *attr, char *buf)
{}

static ssize_t read_req_latency_avg_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{}

static ssize_t read_req_latency_max_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{}

static ssize_t read_req_latency_min_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{}

static ssize_t read_req_latency_sum_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{}

static ssize_t write_total_sectors_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{}

static ssize_t write_total_busy_show(struct device *dev,
				     struct device_attribute *attr, char *buf)
{}

static ssize_t write_nr_requests_show(struct device *dev,
				      struct device_attribute *attr, char *buf)
{}

static ssize_t write_req_latency_avg_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static ssize_t write_req_latency_max_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static ssize_t write_req_latency_min_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static ssize_t write_req_latency_sum_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static DEVICE_ATTR_RW(monitor_enable);
static DEVICE_ATTR_RW(monitor_chunk_size);
static DEVICE_ATTR_RO(read_total_sectors);
static DEVICE_ATTR_RO(read_total_busy);
static DEVICE_ATTR_RO(read_nr_requests);
static DEVICE_ATTR_RO(read_req_latency_avg);
static DEVICE_ATTR_RO(read_req_latency_max);
static DEVICE_ATTR_RO(read_req_latency_min);
static DEVICE_ATTR_RO(read_req_latency_sum);
static DEVICE_ATTR_RO(write_total_sectors);
static DEVICE_ATTR_RO(write_total_busy);
static DEVICE_ATTR_RO(write_nr_requests);
static DEVICE_ATTR_RO(write_req_latency_avg);
static DEVICE_ATTR_RO(write_req_latency_max);
static DEVICE_ATTR_RO(write_req_latency_min);
static DEVICE_ATTR_RO(write_req_latency_sum);

static struct attribute *ufs_sysfs_monitor_attrs[] =;

static const struct attribute_group ufs_sysfs_monitor_group =;

static ssize_t lane_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}

static ssize_t mode_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}

static ssize_t rate_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}

static ssize_t gear_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}

static ssize_t dev_pm_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}

static ssize_t link_state_show(struct device *dev,
			       struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(lane);
static DEVICE_ATTR_RO(mode);
static DEVICE_ATTR_RO(rate);
static DEVICE_ATTR_RO(gear);
static DEVICE_ATTR_RO(dev_pm);
static DEVICE_ATTR_RO(link_state);

static struct attribute *ufs_power_info_attrs[] =;

static const struct attribute_group ufs_sysfs_power_info_group =;

static ssize_t ufs_sysfs_read_desc_param(struct ufs_hba *hba,
				  enum desc_idn desc_id,
				  u8 desc_index,
				  u8 param_offset,
				  u8 *sysfs_buf,
				  u8 param_size)
{}

#define UFS_DESC_PARAM(_name, _puname, _duname, _size)

#define UFS_DEVICE_DESC_PARAM(_name, _uname, _size)

UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();
UFS_DEVICE_DESC_PARAM();

static struct attribute *ufs_sysfs_device_descriptor[] =;

static const struct attribute_group ufs_sysfs_device_descriptor_group =;

#define UFS_INTERCONNECT_DESC_PARAM(_name, _uname, _size)

UFS_INTERCONNECT_DESC_PARAM();
UFS_INTERCONNECT_DESC_PARAM();

static struct attribute *ufs_sysfs_interconnect_descriptor[] =;

static const struct attribute_group ufs_sysfs_interconnect_descriptor_group =;

#define UFS_GEOMETRY_DESC_PARAM(_name, _uname, _size)

UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();
UFS_GEOMETRY_DESC_PARAM();


static struct attribute *ufs_sysfs_geometry_descriptor[] =;

static const struct attribute_group ufs_sysfs_geometry_descriptor_group =;

#define UFS_HEALTH_DESC_PARAM(_name, _uname, _size)

UFS_HEALTH_DESC_PARAM();
UFS_HEALTH_DESC_PARAM();
UFS_HEALTH_DESC_PARAM();

static struct attribute *ufs_sysfs_health_descriptor[] =;

static const struct attribute_group ufs_sysfs_health_descriptor_group =;

#define UFS_POWER_DESC_PARAM(_name, _uname, _index)

UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();
UFS_POWER_DESC_PARAM();

static struct attribute *ufs_sysfs_power_descriptor[] =;

static const struct attribute_group ufs_sysfs_power_descriptor_group =;

#define UFS_STRING_DESCRIPTOR(_name, _pname)

UFS_STRING_DESCRIPTOR();
UFS_STRING_DESCRIPTOR();
UFS_STRING_DESCRIPTOR();
UFS_STRING_DESCRIPTOR();
UFS_STRING_DESCRIPTOR();

static struct attribute *ufs_sysfs_string_descriptors[] =;

static const struct attribute_group ufs_sysfs_string_descriptors_group =;

static inline bool ufshcd_is_wb_flags(enum flag_idn idn)
{}

#define UFS_FLAG(_name, _uname)

UFS_FLAG();
UFS_FLAG();
UFS_FLAG();
UFS_FLAG();
UFS_FLAG();
UFS_FLAG();
UFS_FLAG();
UFS_FLAG();
UFS_FLAG();
UFS_FLAG();
UFS_FLAG();

static struct attribute *ufs_sysfs_device_flags[] =;

static const struct attribute_group ufs_sysfs_flags_group =;

static ssize_t max_number_of_rtt_show(struct device *dev,
				      struct device_attribute *attr, char *buf)
{}

static ssize_t max_number_of_rtt_store(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t count)
{}

static DEVICE_ATTR_RW(max_number_of_rtt);

static inline bool ufshcd_is_wb_attrs(enum attr_idn idn)
{}

#define UFS_ATTRIBUTE(_name, _uname)

UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();
UFS_ATTRIBUTE();


static struct attribute *ufs_sysfs_attributes[] =;

static const struct attribute_group ufs_sysfs_attributes_group =;

static const struct attribute_group *ufs_sysfs_groups[] =;

#define UFS_LUN_DESC_PARAM(_pname, _puname, _duname, _size)

#define UFS_UNIT_DESC_PARAM(_name, _uname, _size)

UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();
UFS_UNIT_DESC_PARAM();

static struct attribute *ufs_sysfs_unit_descriptor[] =;

static umode_t ufs_unit_descriptor_is_visible(struct kobject *kobj, struct attribute *attr, int n)
{}


const struct attribute_group ufs_sysfs_unit_descriptor_group =;

static ssize_t dyn_cap_needed_attribute_show(struct device *dev,
	struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(dyn_cap_needed_attribute);

static struct attribute *ufs_sysfs_lun_attributes[] =;

const struct attribute_group ufs_sysfs_lun_attributes_group =;

void ufs_sysfs_add_nodes(struct device *dev)
{}

void ufs_sysfs_remove_nodes(struct device *dev)
{}