ATF bl1 ufshc_dme_get/set处理流程分析

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.mzph.cn/news/38642.shtml

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

相关文章

nodejs+vue+elementui考研互助交流网站

语言 node.js 框架&#xff1a;Express 前端:Vue.js 数据库&#xff1a;mysql 数据库工具&#xff1a;Navicat 开发软件&#xff1a;VScode 前端nodejsvueelementui,该系统采用vue技术和B/S结构进行开发设计&#xff0c;后台使用MySQL数据库进行数据存储。系统主要分为两大模…

java面试题(16):Mysql一致性视图是啥时候建立的

1 演示错误案例 先给大家来一个错误演示。 我们打开两个会话窗口&#xff0c;默认情况下隔离级别是可重复读&#xff0c;我们来看下&#xff1a; 首先在 A 会话中查看当前 user 表&#xff0c;查看完成后开启事务&#xff1a; 可以看到id3的数据sex是男。 接下来在 B 会话中…

K8S系列一:概念入门

写在前面 本文组织方式&#xff1a; K8S的架构、作用和目的。需要首先对K8S整体有所了解。 K8S是什么&#xff1f; 为什么是K8S&#xff1f; K8S怎么做&#xff1f; K8S的重要概念&#xff0c;即K8S的API对象。要学习和使用K8S必须知道和掌握的几个对象。 Pod 实例 Volume 数…

php错误类型与处理

1 语法编译错误&#xff0c;少了分号&#xff0c;这是系统触发的错误&#xff0c;不需要我们去管。 2 错误类型有四种&#xff1a;error致命错误&#xff0c;代码不会往下运行&#xff1b;warning&#xff1a;提醒错误&#xff0c;会往下运行&#xff0c;但是会有意想不到的结果…

【C++学习】STL容器——stack和queue

目录 一、stack的介绍和使用 1.1 stack的介绍 1.2 stack的使用 1.3 stack的模拟实现 二、queue的介绍和使用 2.1 queue的介绍 2.2 queue的使用 2.3 queue的模拟实现 三、priority_queue的介绍和使用 3.1 priority_queue的介绍和使用 3.2 priority_queue的使用 3.4 p…

JVM---理解jvm之对象已死怎么判断?

目录 引用计数算法 什么是引用 可达性分析算法&#xff08;用的最多的&#xff09; 引用计数算法 定义&#xff1a;在对象中添加一个引用计数器&#xff0c;每当有一个地方引用它时&#xff0c;计数器值就加一&#xff1b;当引用失效时&#xff0c;计数器值就减一&#xff1…

国内外医疗器械政策法规网站集合

随着医疗技术的不断发展&#xff0c;医疗器械在现代医疗中扮演着重要的角色。为了确保医疗器械的安全性、有效性和质量&#xff0c;各国纷纷制定了一系列的政策法规来监管医疗器械的研发、生产、销售和使用。这些政策法规的制定和实施对于保障公众健康、促进医疗器械产业的健康…

旧版本docker未及时更新,导致更新/etc/docker/daemon.json配置文件出现docker重启失败

一、背景 安装完docker和containerd之后&#xff0c;尝试重启docker的时候&#xff0c;报错如下&#xff1a; systemctl restart dockerJob for docker.service failed because the control process exited with error code. See “systemctl status docker.service” and “…

学习ts(一)数据类型(基础类型和任意类型)

运行 起步安装 npm install typescript -g 运行tsc index.ts生成对应的js文件&#xff0c;然后使用node index.js执行js文件 为了方便运行还可以安装插件&#xff0c;ts-node index.ts运行即可 npm i ts-node -g npm init -y npm i types/node -D基本数据类型 // 1.字符…

ARM(汇编指令)

.global _start _start:/*mov r0,#0x5mov r1,#0x6 bl LoopLoop:cmp r0,r1beq stopsubhi r0,r0,r1subcc r1,r1,r0mov pc,lr*/ mov r0,#0x1mov r1,#0x0mov r2,#0x64bl Loop Loop:cmp r0,r2bhi stopadd r1,r1,r0add r0,r0,#0x01mov pc,lr stop:B stop.end

现有的vue3+ts+vite项目集成electron

效果图 什么时Electron Electron是使用JavaScript,HTML和CSS构建跨平台的桌面应用程序框架。 Electron兼容Mac、Windows和Linux,可以构建出三个平台的应用程序。 现有的vue3项目集成Electron 安装依赖 原来有一个vue3+ts+vite+pnpm的项目,其中sub-modules是子项目,web是…

Monge矩阵

Monge矩阵 对一个m*n的实数矩阵A&#xff0c;如果对所有i&#xff0c;j&#xff0c;k和l&#xff0c;1≤ i<k ≤ m和1≤ j<l ≤ n&#xff0c;有 A[i,j]A[k,l] ≤ A[i,l]A[k,j] 那么&#xff0c;此矩阵A为Monge矩阵。 换句话说&#xff0c;每当我们从矩阵中挑…

全面梳理Python下的NLP 库

一、说明 Python 对自然语言处理库有丰富的支持。从文本处理、标记化文本并确定其引理开始&#xff0c;到句法分析、解析文本并分配句法角色&#xff0c;再到语义处理&#xff0c;例如识别命名实体、情感分析和文档分类&#xff0c;一切都由至少一个库提供。那么&#xff0c;你…

地理数据的双重呈现:GIS与数据可视化

前一篇文章带大家了解了GIS与三维GIS的关系&#xff0c;本文就GIS话题带大家一起探讨一下GIS和数据可视化之间的关系。 GIS&#xff08;地理信息系统&#xff09;和数据可视化在地理信息科学领域扮演着重要的角色&#xff0c;它们之间密切相关且相互增强。GIS是一种用于采集、…

欧拉函数和最大公约数

分析&#xff1a;如果两个数的最大公约数是一个质数p&#xff0c;那么这两个数都除以p&#xff0c;得到的两个数的最大公约数一定是1. 反证法&#xff1a;如果得到的两个数的最大公约数不是1&#xff0c;那么把此时的最大公约数乘以上边的最大公约数&#xff0c;得到的一定比上…

文件操作 和 IO

目录 ​编辑一、认识文件 1、文件路径 2、其它知识 二、Java 中操作文件 三、文件内容的读写 1、Reader 2、InputStream 3、输出 一、认识文件 文件是在硬盘上存储数据的一种方式&#xff0c;操作系统帮我们把硬盘的一些细节都封装起来了 我们只需要了解文件相关的一些…

【前端 | CSS】滚动到底部加载,滚动监听、懒加载

背景 在日常开发过程中&#xff0c;我们会遇到图片懒加载的功能&#xff0c;基本原理是&#xff0c;滚动条滚动到底部后再次获取数据进行渲染。 那怎么判断滚动条是否滚动到底部呢&#xff1f;滚动条滚动到底部触发时间的时机和方法又该怎样定义&#xff1f; 针对以上问题我…

数据集成革新:去中心化微服务集群的无限潜能

在当今数据密集型的业务环境下&#xff0c;传统的集中式架构已经难以满足高可用性和高并发性的要求。而去中心化微服务集群则通过分散式的架构&#xff0c;将系统划分为多个小型的、独立部署的微服务单元&#xff0c;每个微服务负责特定的业务功能&#xff0c;实现了系统的高度…

docker搭建opengrok环境

引言&#xff1a; 由于这几天开始 http://aospxref.com/ 网站没法用了。用习惯了opengrok的方式看AOSP的源码&#xff0c;其他的在线查看源码的网站用起来都不是很理想。所以考虑搭建一个环境。 首先网上看了下opengrok的环境搭建的方式&#xff0c;最终还是采用docker的方…

基于C#的无边框窗体阴影绘制方案 - 开源研究系列文章

今天介绍无边框窗体阴影绘制的内容。 上次有介绍使用双窗体的方法来显示阴影&#xff0c;这次介绍使用API函数来进行绘制。这里使用的是Windows API函数&#xff0c;操作系统的窗体也是用的这个来进行的绘制。 1、 项目目录&#xff1b; 下面是项目目录&#xff1b; 2、 函数介…