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.pswp.cn/news/38642.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/38642.shtml
英文地址,請注明出處:http://en.pswp.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數據庫進行數據存儲。系統主要分為兩大模…

大數據課程J2——Scala的基礎語法和函數

文章作者郵箱&#xff1a;yugongshiyesina.cn 地址&#xff1a;廣東惠州 ▲ 本章節目的 ? 掌握Scala的基礎語法&#xff1b; ? 掌握Scala的函數庫&#xff1b; 一、Scala 基礎語法一 1. 概述 語句 說明 示例 var 用來聲明一個變量&#xff0c; 變量聲明后…

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--------介紹、常用命令,國內源配置

1 docker 國內源配置 # 鏡像&#xff1a;一堆文件 -目前從遠程倉庫下載的&#xff1a;https://hub.docker.com/ -鏡像有很多人提供&#xff1a;官方提供&#xff0c;第三方提供 -鏡像--》更新--》Tag不同版本 -centos:latest 最新 -docker pull 能找到…

舊版本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.字符…

探索不同類型的代理服務器 (代理 IP、socks5 代理)及其在網絡安全與爬蟲中的應用

1. 代理服務器簡介 代理服務器是一臺充當中間人的服務器&#xff0c;它在客戶端與目標服務器之間傳遞網絡請求。代理服務器在不同層級上可以執行不同的任務&#xff0c;包括緩存、過濾、負載均衡和隱藏客戶端真實IP地址等。在網絡安全和爬蟲領域&#xff0c;代理服務器具有重要…

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; 針對以上問題我…