Browse Source

add gmac & freq

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 3 months ago
parent
commit
ccdd3616e8
  1. BIN
      pdf/rk3588_guide.pdf
  2. 1
      rk3588_guide.tex
  3. 91
      tex/freq.tex
  4. 87
      tex/resource.tex

BIN
pdf/rk3588_guide.pdf

Binary file not shown.

1
rk3588_guide.tex

@ -203,6 +203,7 @@
\part {开发篇}
\import{tex/}{build}
\import{tex/}{resource}
\import{tex/}{freq}
\import{tex/}{upgrade}
\import{tex/}{issue}
\part {生产部署}

91
tex/freq.tex

@ -0,0 +1,91 @@
\chapter{CPU、DDR 和 NPU 频率}
通常,板子上的各个单元的频率是动态调频,这种情况下测试出来的性能会有波动。为
了防止性能测试结果不一致,在性能评估时,建议固定板子上的相关单元的频率再做测试。
\section{CPU 定频命令}
\subsection{查看 CPU 频率}
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
\end{minted}
\subsection{固定 CPU 频率}
查看可用的频率
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
\end{minted}
可能的输出如下
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
408000 600000 816000 1008000 1200000 1416000 1608000 1800000
\end{minted}
设置 CPU 频率,如 1.8G
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
echo userspace > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
echo 1800000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed
\end{minted}
\section{DDR 定频命令}
\subsection{查看 DDR 频率}
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
cat /sys/class/devfreq/dmc/cur_freq
\end{minted}
\subsection{固定 DDR 频率}
查看 DDR 可用的频率
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
cat /sys/class/devfreq/dmc/available_frequencies
\end{minted}
可能的输出如下
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
528000000 1068000000 1560000000 2112000000
\end{minted}
设置 DDR 频率,例如,2112000000MHZ
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
echo userspace > /sys/class/devfreq/dmc/governor
echo 2112000000 > /sys/class/devfreq/dmc/userspace/set_freq
\end{minted}
\section{NPU 相关}
\subsection{查看 NPU 频率}
用下面命令查看:
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
cat /sys/kernel/debug/clk/clk_summary | grep clk_npu_dsu0
\end{minted}
可能的输出如下:
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
clk_npu_dsu0 3 6 0 250000000 0 0 50000
\end{minted}
\subsection{设置 NPU 频率(需要固件支持)}
例如,设置为 1GHz
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
echo 1000000000 > /sys/kernel/debug/clk/clk_npu_dsu0/clk_rate
\end{minted}
\subsection{查询 NPU 驱动版本}
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
[root@openEuler ~]# cat /sys/kernel/debug/rknpu/version
RKNPU driver: v0.8.2
\end{minted}
\subsection{查询 NPU 电源状态}
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
cat /sys/kernel/debug/rknpu/power
\end{minted}
\subsection{打开 NPU 电源}
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
echo on > /sys/kernel/debug/rknpu/power
\end{minted}
\subsection{关闭 NPU 电源}
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
echo off > /sys/kernel/debug/rknpu/power
\end{minted}

87
tex/resource.tex

@ -86,6 +86,93 @@ eth0 和 eth1。其对应关系如下表所示:
\caption{phy-mode 参数}
\end{table}
\subsection{PHY 寄存器读写调试}
驱动提供了读写寄存器的接口,
路径: /sys/bus/mdio\_bus/devices/stmmac-0:01,其中 stmmac-0:01 表示 gmac0 的 PHY 地址是 1。
\subsubsection{读寄存器}
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
cat /sys/bus/mdio_bus/devices/stmmac-1\:01/phy_registers
\end{minted}
\subsubsection{写寄存器}
例如, 往 reg0 写入 0x8100:
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
echo 00 0x8100 > /sys/bus/mdio_bus/devices/stmmac-1\:01/phy_registers
\end{minted}
\subsection{输出25M时钟}
对 gmac0:
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
&gmac0 {
/* Use rgmii-rxid mode to disable rx delay inside Soc */
phy-mode = "rgmii-rxid";
clock_in_out = "output";
snps,reset-gpio = <&gpio4 RK_PB3 GPIO_ACTIVE_LOW>;
snps,reset-active-low;
/* Reset time is 20ms, 100ms for rtl8211f */
snps,reset-delays-us = <0 20000 100000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&gmac0_miim
+ &gmac0_tx_bus2
+ &gmac0_rx_bus2
+ &gmac0_rgmii_clk
+ &gmac0_rgmii_bus
+ &eth0_pins>;
tx_delay = <0x45>;
/* rx_delay = <0x43>; */
phy-handle = <&rgmii_phy>;
status = "okay";
};
&mdio0 {
rgmii_phy: phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0x1>;
+ clocks = <&cru REFCLKO25M_ETH0_OUT>;
};
};
\end{minted}
对 gmac1:
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
&gmac1 {
/* Use rgmii-rxid mode to disable rx delay inside Soc */
phy-mode = "rgmii-rxid";
+ clock_in_out = "output";
snps,reset-gpio = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>;
snps,reset-active-low;
/* Reset time is 20ms, 100ms for rtl8211f */
snps,reset-delays-us = <0 20000 100000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&gmac1_miim
+ &gmac1_tx_bus2
+ &gmac1_rx_bus2
+ &gmac1_rgmii_clk
+ &gmac1_rgmii_bus
+ &eth1_pins>; tx_delay = <0x45>;
/* rx_delay = <0x43>; */
phy-handle = <&rgmii_phy>;
status = "okay";
};
&mdio1 {
rgmii_phy: phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0x1>;
+ clocks = <&cru REFCLKO25M_ETH0_OUT>;
};
};
\end{minted}
\subsection{RGMII 延时扫描}
通过 /sys/devices/platform/fe1b0000.ethernet 和 /sys/devices/platform/fe1c0000.ethernet 节点下的 phy\_lb\_scan 来扫描延时值。
扫描前需要拔掉网线。
通过 \verb+phy_lb_scan+ 节点扫描到一个窗口,会得到一个中间坐标,需要使用千兆速度 1000 来扫描:
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
echo 1000 > phy_lb_scan
\end{minted}
把扫描的结果配置到 dts 的 gmac0 或 gmac1 节点下 (tx-delay 和 rx-delay)。
\section{Camera}
RK3588 camera 资源硬件如下所示,拥有 2 路 DCPHY, 2 路 DPHY, 一路 DVP, 6 路 CSI HOST, 一个 vicap 控制器, 2个isp控制器。其中 2 路 DPHY 可以分解成 4x2lane 的模式工作,如下图所示:

Loading…
Cancel
Save