ATF bl1 ufshc_dme_get/set处理流程分析

news2024/10/6 10:29:55

ATF bl1 ufshc_dme_get/set处理流程分析

  • UFS术语缩略词
  • 1 ATF的下载链接
  • 2 ATF BL1 ufshc_dme_get/set流程
  • 3 ufs总体架构图
    • 3.1 UFS Top Level Architecture
    • 3.2 UFS System Model
  • 4 ufshc_dme_get/set函数接口详细分析
    • 4.1 ufshc_dme_get
    • 4.2 ufshc_dme_set
    • 4.3 ufshc_send_uic_cmd
    • 4.4 ufs_wait_for_int_status

以海思hikey960为例来介绍,简单介绍在ATF BL1阶段的初始化处理。

UFS术语缩略词

UTP:UFS Transport Protocol
DME:Device Management Entity
UCS:UFS Command Set
UIC:UFS Interconnect
UTRD:UTP Transfer Request Descriptor
UPIU:UFS Protocol Information Unit

1 ATF的下载链接

https://github.com/ARM-software/arm-trusted-firmware

可以通过下面的命令来下载ATF的代码,或者通过打包下载的方式也可以。

git clone git@github.com:ARM-software/arm-trusted-firmware.git

2 ATF BL1 ufshc_dme_get/set流程

  • 设置ufs dme get/set的cmd参数
  • ufshc_send_uic_cmd函数中首先等到UIC READY,然后配置UFS CMD ARG寄存器以及UIC CMD寄存器。

在这里插入图片描述

3 ufs总体架构图

3.1 UFS Top Level Architecture

在这里插入图片描述

3.2 UFS System Model

在这里插入图片描述

4 ufshc_dme_get/set函数接口详细分析

4.1 ufshc_dme_get

  • cmd.op = DME_GET;
  • ufshc_send_uic_cmd(base, &cmd);
int ufshc_dme_get(unsigned int attr, unsigned int idx, unsigned int *val)
{
        uintptr_t base;
        int result, retries;
        uic_cmd_t cmd;

        assert(ufs_params.reg_base != 0);

        if (val == NULL)
                return -EINVAL;

        base = ufs_params.reg_base;
        cmd.arg1 = (attr << 16) | GEN_SELECTOR_IDX(idx);
        cmd.arg2 = 0;
        cmd.arg3 = 0;
        cmd.op = DME_GET;

        for (retries = 0; retries < UFS_UIC_COMMAND_RETRIES; ++retries) {
                result = ufshc_send_uic_cmd(base, &cmd);
                if (result == 0)
                        break;
                /* -EIO requires UFS re-init */
                if (result == -EIO) {
                        return result;
                }
        }
        if (retries >= UFS_UIC_COMMAND_RETRIES)
                return -EIO;

        *val = mmio_read_32(base + UCMDARG3);
        return 0;
}

4.2 ufshc_dme_set

  • cmd.op = DME_SET;
  • ufshc_send_uic_cmd(base, &cmd);
int ufshc_dme_set(unsigned int attr, unsigned int idx, unsigned int val)
{
        uintptr_t base;
        int result, retries;
        uic_cmd_t cmd;

        assert((ufs_params.reg_base != 0));

        base = ufs_params.reg_base;
        cmd.arg1 = (attr << 16) | GEN_SELECTOR_IDX(idx);
        cmd.arg2 = 0;
        cmd.arg3 = val;
        cmd.op = DME_SET;

        for (retries = 0; retries < UFS_UIC_COMMAND_RETRIES; ++retries) {
                result = ufshc_send_uic_cmd(base, &cmd);
                if (result == 0)
                        break;
                /* -EIO requires UFS re-init */
                if (result == -EIO) {
                        return result;
                }                                                                                                                                                                                          
        }
        if (retries >= UFS_UIC_COMMAND_RETRIES)
                return -EIO;

        return 0;
}

4.3 ufshc_send_uic_cmd

  • data = mmio_read_32(base + HCS);读取Host Controller Status寄存器的值,仅当UCRDY置位时才继续执行对应的ufs cmd。该位被置位表示当前ufs 主控制器已经准备好处理UIC命令。
    在这里插入图片描述
  • mmio_write_32(base + IS, ~0);使能IAGES,CQES,SQES,CEFES,SBFES,HCFES,UTPES,DFES,UCCS,UTMRCS,ULSS,ULLS,UHES,UHXS,UPMS,UTMS,UE,UDEPRI,UTRCS
  • mmio_write_32(base + UCMDARG1, cmd->arg1);将arg1参数值写入UCMDARG1寄存器中。
    MIBattribute: Indicates the ID of the attribute of the requested. See MIPI UniPro Specification for the details of the MIBattribute parameter.
    MIBattribute: 表示请求的属性 ID。有关 MIBattribute 参数的详细信息,请参见 MIPI UniPro Specification。
    GenSelectorIndex: Indicates the targeted M-PHY data lane or CPort or Test Feature when relevant. See MIPI UniPro Specification for the details of the GenSelectorIndex parameter.
    GenSelectorIndex: 表示目标 M-PHY 数据通道、CPort 或测试功能(如相关)。有关 GenSelectorIndex 参数的详细信息,请参阅 MIPI UniPro 规范。
    在这里插入图片描述
    ResetMode: Indicates the link startup mode. See MIPI UniPro Specification for the details of the ResetMode parameter.
    重置模式: 表示链路启动模式。有关 ResetMode 参数的详细信息,请参阅 MIPI UniPro 规范。
    在这里插入图片描述
    ResetLevel: Indicates the reset type. See MIPI UniPro Specification for the details of the ResetLevel parameter.
    重置级别: 表示复位类型。有关 ResetLevel 参数的详细信息,请参见 MIPI UniPro Specification。
    在这里插入图片描述

在这里插入图片描述

  • mmio_write_32(base + UCMDARG2, cmd->arg2);将arg2参数值写入UCMDARG2寄存器中。
    在这里插入图片描述
    AttrSetType: Indicates whether the attribute value (AttrSet = NORMAL) or the attribute non-volatile reset value (STATIC) setting is requested. See MIPI UniPro Specification for the details of the AttrSetType parameter.
    AttrSetType: 表示请求设置属性值(AttrSet = NORMAL)还是属性非易失性重置值(STATIC)。有关 AttrSetType 参数的详细信息,请参阅 MIPI UniPro 规范。
    ConfigResultCode: Indicates the result of the UIC configuration command request. It is valid after host controller has set the IS.UCCS bit to ’1’. See MIPI UniPro Specification for the details of the ConfigResultCode parameter.
    ConfigResultCode: 表示 UIC 配置命令请求的结果。它在主机控制器将 IS.UCCS 位设置为 "1 "后有效。有关 ConfigResultCode 参数的详细信息,请参见 MIPI UniPro Specification。
    在这里插入图片描述
    GenericErrorCode: Indicates the result of the UIC control command request. It is valid after host controller has set the IS.UCCS bit to ’1’. See MIPI UniPro Specification for the details of the GenericErrorCode parameter.
    通用错误代码: 表示 UIC 控制命令请求的结果。它在主机控制器将 IS.UCCS 位设置为 "1 "后有效。有关 GenericErrorCode 参数的详细信息,请参见 MIPI UniPro Specification。
    在这里插入图片描述

  • mmio_write_32(base + UCMDARG3, cmd->arg3);将arg3参数值写入UCMDARG3寄存器中。
    在这里插入图片描述
    MIBvalue_R: Indicates the value of the attribute as returned by the UIC command returned. It is valid after host controller has set the IS.UCCS bit to ’1’. See MIPI UniPro Specification for the details of the MIBvalue parameter.
    MIBvalue_R: 表示 UIC 命令返回的属性值。它在主机控制器将 IS.UCCS 位设置为 "1 "后有效。有关 MIBvalue 参数的详细信息,请参阅 MIPI UniPro 规范。
    MIBvalue_W: Indicates the value of the attribute to be set. See MIPI UniPro Specification for details of the MIBvalue parameter.
    MIBvalue_W: 表示要设置的属性值。有关 MIBvalue 参数的详细信息,请参见 MIPI UniPro Specification。

  • mmio_write_32(base + UICCMD, cmd->op);将cmd-ops写入UICCMD寄存器中,使cmd开始处理。
    -

  • ufs_wait_for_int_status(UFS_INT_UCCS, UIC_CMD_TIMEOUT_MS, cmd->op == DME_SET); 等待期待的中断状态

int ufshc_send_uic_cmd(uintptr_t base, uic_cmd_t *cmd)
{
        unsigned int data;
        int result, retries;
                
        if (base == 0 || cmd == NULL)
                return -EINVAL;

        for (retries = 0; retries < 100; retries++) {
                data = mmio_read_32(base + HCS);
                if ((data & HCS_UCRDY) != 0) {
                        break;
                }
                mdelay(1);
        }
        if (retries >= 100) {                                                                                                                                                                              
                return -EBUSY;
        }

        mmio_write_32(base + IS, ~0);
        mmio_write_32(base + UCMDARG1, cmd->arg1);
        mmio_write_32(base + UCMDARG2, cmd->arg2);
        mmio_write_32(base + UCMDARG3, cmd->arg3);
        mmio_write_32(base + UICCMD, cmd->op);

        result = ufs_wait_for_int_status(UFS_INT_UCCS, UIC_CMD_TIMEOUT_MS,
                                         cmd->op == DME_SET);
        if (result != 0) {
                return result;
        }

        return mmio_read_32(base + UCMDARG2) & CONFIG_RESULT_CODE_MASK;
}

4.4 ufs_wait_for_int_status

  • interrupts_enabled = mmio_read_32(ufs_params.reg_base + IE);读取中断使能寄存器的值,该寄存器可启用或禁用向主机软件报告相应的中断。当某位被设置(‘1’)且相应的中断条件处于活动状态时,就会产生中断。被禁用(‘0’)的中断源仍会在 IS 寄存器中显示。该寄存器与 IS 寄存器对称。
  • interrupt_status = mmio_read_32(ufs_params.reg_base + IS) & interrupts_enabled;读取中断状态寄存器的值与中断使能寄存器的值与获取当前中断的状态值。
/*              
 * ufs_wait_for_int_status - wait for expected interrupt status
 * @expected: expected interrupt status bit
 * @timeout_ms: timeout in milliseconds to poll for
 * @ignore_linereset: set to ignore PA_LAYER_GEN_ERR (UIC error)
 *
 * Returns
 * 0 - received expected interrupt and cleared it
 * -EIO - fatal error, needs re-init
 * -EAGAIN - non-fatal error, caller can retry
 * -ETIMEDOUT - timed out waiting for interrupt status
 */
static int ufs_wait_for_int_status(const uint32_t expected_status,
                                   unsigned int timeout_ms,
                                   bool ignore_linereset)
{               
        uint32_t interrupt_status, interrupts_enabled;
        int result = 0;
        
        interrupts_enabled = mmio_read_32(ufs_params.reg_base + IE);
        do {
                interrupt_status = mmio_read_32(ufs_params.reg_base + IS) & interrupts_enabled;                                                                                                            
                if (interrupt_status & UFS_INT_ERR) {
                        mmio_write_32(ufs_params.reg_base + IS, interrupt_status & UFS_INT_ERR);
                        result = ufs_error_handler(interrupt_status, ignore_linereset);
                        if (result != 0) {
                                return result;
                        }
                }
        
                if (interrupt_status & expected_status) {
                        break;
                }
                mdelay(1);
        } while (timeout_ms-- > 0);
        
        if (!(interrupt_status & expected_status)) {
                return -ETIMEDOUT;
        }

        mmio_write_32(ufs_params.reg_base + IS, expected_status);

        return result;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/882809.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Visual Studio 如何放大代码字体的大小

1.打开Visual Studio&#xff0c;新建一个程序&#xff0c;一段代码&#xff0c;为接下去的操作做好准备。单击菜单栏的【工具】选项。 2.在跳出来菜单中找到【选项】&#xff08;一般在最后一项&#xff09;&#xff0c;然后单击。跳出新的窗口。 3.跳出新的窗口后&#xff…

SPI-FlexSPI

概念 SPI 高速全双工通信总线 SPI有四根线&#xff1a; SDO&#xff1a;数据输出-主设备数据输出&#xff0c;从设备数据输入 SDI:数据输入-主设备数据输入&#xff0c;从设备数据输出 SCLK&#xff1a;时钟信号-由主设备产生 CS&#xff1a;片选信号&#xff0c;主设备…

打家劫舍 II——力扣213

动规 int robrange(vector<int>& nums, int start, int end){int first=nums[start]

Python程序设计——字符串处理的特殊方法

学习目标&#xff1a; 学习如何创建字符串使用len、min和max函数获取一个字符串的长度、串中的最大和最小的字符使用下标运算符([])访问字符串中的元素使用截取运算符str[ start:end]从较长的字符串中得到一个子串使用运算符连接两个字符串&#xff0c;通过*运算符复制一个字符…

SegFormer之模型训练

单卡训练&#xff0c;所有配置文件里的【SyncBN】改为【BN】 启动训练 &#xff08;1&#xff09;终端直接运行 python tools/train.py local_configs/segformer/B1/segformer.b1.512x512.ade.160k.py &#xff08;2&#xff09;在编辑器中运行 在 [config] 前面加上’–‘将…

Coremail AI实验室:利用高级语境和视觉智能进行钓鱼邮件检测

在这个日益数字化的时代&#xff0c;对电子邮件安全需求是至关重要的。新兴的高级威胁邮件&#xff1a;应用社工技术的钓鱼邮件&#xff0c;仿冒公检法的钓鱼邮件等等&#xff0c;都需要更高级的防御策略。 Coremail邮件安全人工智能实验室&#xff0c;整合了高级文本语境理解和…

datawhale49期-task02:安装MMSegmentation

task02:安装MMSegmentation 运行环境&#xff1a;window11 ,GPU RTX 4060、CUDA v11.8 1. Pytorch环境 步骤 1. 创建一个 conda 环境&#xff0c;并激活 conda create --name openmmlab python3.8 -y conda activate openmmlabStep 2. 参考 official instructions 安装 PyTor…

抓包分析 TCP 协议

TCP 协议是在传输层中&#xff0c;一种面向连接的、可靠的、基于字节流的传输层通信协议。 环境准备 对接口测试工具进行分类&#xff0c;可以如下几类&#xff1a; 网络嗅探工具&#xff1a;tcpdump&#xff0c;wireshark 代理工具&#xff1a;fiddler&#xff0c;charles&…

vue基础知识四:Vue实例挂载的过程

一、思考 我们都听过知其然知其所以然这句话 那么不知道大家是否思考过new Vue()这个过程中究竟做了些什么&#xff1f; 过程中是如何完成数据的绑定&#xff0c;又是如何将数据渲染到视图的等等 一、分析 首先找到vue的构造函数 源码位置&#xff1a;src\core\instance\…

龙蜥社区安全联盟(OASA)正式成立,启明星辰、绿盟、360 等 23 家厂商重磅加入

7 月 28 日&#xff0c;由启明星辰、绿盟、360、阿里云、统信软件、浪潮信息、中兴通讯&#xff5c;中兴新支点、Intel、中科院软件所等 23 家单位共同发起的龙蜥社区安全联盟&#xff08;OASA&#xff0c;OpenAnolisSecurityAlliance&#xff09;&#xff08;以下简称“安全联…

[xgb] plot tree

xgboost plot tree debug problem1solutionsreference problem2solutionreference problem3solutionreference supplementary explanationplot_tree参数介绍num_treesmodel.get_booster().best_iteration图中信息介绍缺失值叶子的值 训练的XGB模型里有多少棵树 problem1 用xgb…

探索Python编程的技巧:多线程魔法、网络舞台、正则魔法阵与递归迷宫

一 多线程 1.1 进程和线程 进程&#xff1a; 就是一个程序&#xff0c;运行在系统之上&#xff0c;称这个程序为一个运行进程&#xff0c;并分配进程ID方便系统管理。线程&#xff1a;线程是归属于进程的&#xff0c;一个进程可以开启多个线程&#xff0c;执行不同的工作&…

剑指offer-2.1数组

数组 数组可以说是最简单的一种数据结构&#xff0c;它占据一块连续的内存并按照顺序存储数据。创建数组时&#xff0c;我们需要首先指定数组的容量大小&#xff0c;然后根据大小分配内存。即使我们只在数组中存储一个数字&#xff0c;也需要为所有的数据预先分配内存。因此数…

Kotlin实战之获取本地配置文件、远程Apollo配置失败问题排查

背景 Kotlin作为一门JVM脚本语言&#xff0c;收到很多Java开发者的青睐。 项目采用JavaKotlin混合编程。Spring Boot应用开发&#xff0c;不会发生变动的配置放在本地配置文件&#xff0c;可能会变化的配置放在远程Apollo Server。 问题 因为业务需要&#xff0c;需要增加一…

css学习1

1、样式定义如何显示元素。 2、样式通常保存至外部的css文件中。 3、样式可以使内容与表现分离。 4、css主要有两部分组成&#xff1a;选择器与一条或多条声明。 选择器通常为要改变的html元素&#xff0c;每条声明由一个属性和一个值组成。每个属性有一个值&#xff0c;属性…

Centos7.9上(离线)安装Gitlab

1、下载Gitlab的rpm安装包Index of /gitlab-ce/yum/el7/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror 2、安装rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm&#xff0c;如果依赖缺失&#xff0c;yum安装即可 3、vi /etc/gitlab/gitlab.rb 配置external_url&…

超声波一体气象站的介绍

超声波一体气象站集风速、风向、温湿度、噪声采集、PM2.5和 PM10、CO2、大气压力、光照于一体&#xff0c;采用标准 ModBus-RTU 通信协议&#xff0c;RS485信号输出方式&#xff0c;通信距离可达 2000 米&#xff0c;数据能够通过 485 通信的方式上传至客户的监控软件或 PLC 组…

210、仿真-基于51单片机灭火小车超声波避障温度烟雾控制报警Proteus仿真设计(程序+Proteus仿真+配套资料等)

毕设帮助、开题指导、技术解答(有偿)见文未 目录 一、硬件设计 二、设计功能 三、Proteus仿真图 四、程序源码 资料包括&#xff1a; 需要完整的资料可以点击下面的名片加下我&#xff0c;找我要资源压缩包的百度网盘下载地址及提取码。 方案选择 单片机的选择 方案一&a…

Hlang社区-社区主页实现

文章目录 前言首页结构固定导航栏左侧导航itemitem标志头部推荐文章展示ITEM实现ToolTip完整实现首页完整实现前言 废话不多说,直接看到效果,这里的话是我们社区主页,不是产品宣传主页哈: 是的也许你已经发现了这个页面和某个网站长得贼像。没错是这样的,这个布局我确实…

利用OpenCV光流算法实现视频特征点跟踪

光流简介 光流&#xff08;optical flow&#xff09;是运动物体在观察成像平面上的像素运动的瞬时速度。光流法是利用图像序列中像素在时间域上的变化以及相邻帧之间的相关性来找到上一帧跟当前帧之间存在的对应关系&#xff0c;从而计算出相邻帧之间物体的运动信息的一种方法。…