u-boot概述就不概述了,u-boot、kernel、dtb三件套,dddd
经过国庆艰苦奋战,已经成功把所有功能移植好了
进入u-boot的目录
/* 解压源码 */
tar xf u-boot-stm32mp-v2022.10-stm32mp-r1-r0.tar.xz
/* 进入源码目录 */
cd u-boot-stm32mp-v2022.10-stm32mp-r1/
/* 打补丁 */
for p in `ls -1 ../*.patch`; do patch -p1 < $p; done
打开Makefile.sdk,把DEPLOYDIR目录改成这个:
DEPLOYDIR ?= $(SRC_PATH)/../../FIP_artifacts/u-boot
然后第12行开始,我们把157的屏蔽掉,留下135
# Init default config settings
# UBOOT_CONFIGS += trusted
# UBOOT_DEFCONFIG_trusted += stm32mp15_defconfig
# UBOOT_BINARY_stm32mp15_defconfig ?= u-boot.dtb
# UBOOT_DEVICETREE_stm32mp15_defconfig ?= stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2
# Init default config settings
UBOOT_CONFIGS += trusted
UBOOT_DEFCONFIG_trusted += stm32mp13_defconfig
UBOOT_BINARY_stm32mp13_defconfig ?= u-boot.dtb
UBOOT_DEVICETREE_stm32mp13_defconfig ?= stm32mp135f-dk
DEVICETREE ?= stm32mp135f-dk
/* 加载环境 */
source /opt/st/stm32mp1/4.2.1-openstlinux-6.1-yocto-mickledore-mp1-v23.06.21/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
/* 配置环境变量 */
export FIP_DEPLOYDIR_ROOT=$PWD/../../FIP_artifacts
不要关了这个终端,它已经配置好了,关于这部分的配置,可以看上一篇关于TF-A的解释比较详细。
make -f ../Makefile.sdk all
由于之前我们编译过了stm32mp135f-dk的TF-A和optee,这里编译完成之后,会直接调用fiptool工具给我们打包生成fip-stm32mp135-atk-optee.bin到FIP文件夹里。
[fiptool] Create fip-stm32mp135f-dk-optee.bin fip binary into 'FIP_DEPLOYDIR_FIP' folder...
[fiptool] Done
/* 进入设备树目录 */
cd arch/arm/dts/
cp stm32mp135f-dk.dts stm32mp135-atk.dts
cp stm32mp13-pinctrl.dtsi stm32mp13-pinctrl-atk.dtsi
cp stm32mp135f-dk-u-boot.dtsi stm32mp135-atk-u-boot.dtsi
/* 回到源码根目录 */
cd ../../../
打开stm32mp135-atk.dts,把引脚头文件改成我们的
// #include "stm32mp13-pinctrl.dtsi"
#include "stm32mp13-pinctrl-atk.dtsi"
首先找到scmi_regu节点,把里面的内容删,但是节点别删,还得留下一个scmi_v1v8_periph
&scmi_regu {
scmi_vddcpu: voltd-vddcpu {
reg = ;
regulator-name = "vddcpu";
};
scmi_vdd: voltd-vdd {
reg = ;
regulator-name = "vdd";
};
scmi_vddcore: voltd-vddcore {
reg = ;
regulator-name = "vddcore";
};
scmi_vdd_adc: voltd-vdd-adc {
reg = ;
regulator-name = "vdd_adc";
};
scmi_vdd_usb: voltd-vdd-usb {
reg = ;
regulator-name = "vdd_usb";
};
scmi_vdd_sd: voltd-vdd-sd {
reg = ;
regulator-name = "vdd_sd";
};
scmi_v1v8_periph: voltd-v1v8-periph {
reg = ;
regulator-name = "v1v8_periph";
};
scmi_v3v3_sw: voltd-v3v3-sw {
reg = ;
regulator-name = "v3v3_sw";
};
};
修改过后如下:如果有大佬知道怎么解决麻烦底下留言帮帮忙
/* 这一段不知道怎么解决,不能删
删除之后,烧写到u-boot阶段,会被强行复位,但是使用分立电源又不行
*/
&scmi_regu {
scmi_v1v8_periph: voltd-v1v8-periph {
reg = ;
regulator-name = "v1v8_periph";
};
};
笔者尝试过在根节点下加入对1.8V电源的描述,但是并不行,烧录的时候会直接被迫重启,刚学linux不久,大佬带带
/* 想用分立电源代替掉scmi_v1v8_periph,但是没有实现 */
// v1v8: v1v8 {
// compatible = "regulator-fixed";
// regulator-name = "v1v8_periph";
// regulator-min-microvolt = <1800000>;
// regulator-max-microvolt = <1800000>;
// regulator-off-in-suspend;
// regulator-always-on;
// };
删除scmi电源之后,在根节点下面加入我们的电源描述,和之前的一样
vddcore: vddcore {
compatible = "regulator-fixed";
regulator-name = "vddcore";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1350000>;
regulator-off-in-suspend;
regulator-always-on;
};
vddcpu: vddcpu {
compatible = "regulator-fixed";
regulator-name = "vddcpu";
regulator-min-microvolt = <1350000>;
regulator-max-microvolt = <1350000>;
regulator-off-in-suspend;
regulator-always-on;
};
v3v3: v3v3 {
compatible = "regulator-fixed";
regulator-name = "v3v3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-off-in-suspend;
regulator-always-on;
};
vbus_otg: vbus_otg {
compatible = "regulator-fixed";
regulator-name = "vbus_otg";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-off-in-suspend;
regulator-always-on;
};
vdd: vdd {
compatible = "regulator-fixed";
regulator-name = "vdd";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-off-in-suspend;
regulator-always-on;
};
vdd_usb: vdd_usb {
compatible = "regulator-fixed";
regulator-name = "vdd_usb";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-off-in-suspend;
regulator-always-on;
};
可以删除(建议删除)的节点如下
1. &i2c5全部
2. &uart8 &usart1 &usart2三个串口
3. 根节点下的gpio-keys
4. 根节点下aliases里的几个串口,只留下串口4
5. &dcmipp节点
6. &spi5 &timer3 &timer4 &timer8 &timer14这几个都可以删了
正点原子的OTG使用的是usbphyc_port1,而usbphyc_port0是host,找到&usbphyc_port1节点,只需要修改该它的电源即可。
&usbphyc_port1 {
// phy-supply = <&scmi_vdd_usb>; /* 删了原来的 */
phy-supply = <&vdd_usb>;
st,current-boost-microamp = <1000>;
st,decrease-hs-slew-rate;
st,tune-hs-dc-level = <2>;
st,enable-hs-rftime-reduction;
st,trim-hs-current = <11>;
st,trim-hs-impedance = <2>;
st,tune-squelch-level = <1>;
st,enable-hs-rx-gain-eq;
st,no-hs-ftime-ctrl;
st,no-lsfs-sc;
};
修改&usbotg_hs
&usbotg_hs {
phys = <&usbphyc_port1 0>;
phy-names = "usb2-phy";
usb-role-switch;
dr_mode = "otg";
pinctrl-0 = <&usbotg_hs_pins_a>;
pinctrl-names = "default";
vbus-supply = <&vbus_otg>;
status = "okay";
};
同OTG,先把电源改了,下面那个connector好像不要也行
&usbphyc_port0 {
// phy-supply = <&scmi_vdd_usb>; /* 删了原来的 */
phy-supply = <&vdd_usb>;
st,current-boost-microamp = <1000>;
st,decrease-hs-slew-rate;
st,tune-hs-dc-level = <2>;
st,enable-hs-rftime-reduction;
st,trim-hs-current = <11>;
st,trim-hs-impedance = <2>;
st,tune-squelch-level = <1>;
st,enable-hs-rx-gain-eq;
st,no-hs-ftime-ctrl;
st,no-lsfs-sc;
/*
* Hack to keep hub active if wakeup source is enabled
* otherwise the hub will wakeup the port0 as soon as the v3v3_sw is disabled
*/
connector {
compatible = "usb-a-connector";
vbus-supply = <&v3v3>;
};
};
修改usbh_ehci节点:
&usbh_ehci {
phys = <&usbphyc_port0>;
status = "okay";
};
这里,偷个懒,直接把原子的复制过来了,直接替换掉
&sdmmc1 {
pinctrl-names = "default", "opendrain", "sleep";
pinctrl-0 = <&sdmmc1_b4_pins_a &sdmmc1_clk_pins_a>;
pinctrl-1 = <&sdmmc1_b4_od_pins_a &sdmmc1_clk_pins_a>;
pinctrl-2 = <&sdmmc1_b4_sleep_pins_a>;
cd-gpios = <&gpiof 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
disable-wp;
st,neg-edge;
no-1-8-v;
bus-width = <4>;
vmmc-supply = <&v3v3>;
status = "okay";
};
/* EMMC */
&sdmmc2 {
pinctrl-names = "default", "opendrain", "sleep";
pinctrl-0 = <&sdmmc2_b4_pins_a &sdmmc2_b4_b7_pins_a &sdmmc2_clk_pins_a>;
pinctrl-1 = <&sdmmc2_b4_od_pins_a &sdmmc2_b4_b7_od_pins_a &sdmmc2_clk_pins_a>;
pinctrl-2 = <&sdmmc2_b4_sleep_pins_a &sdmmc2_b4_b7_sleep_pins_a>;
non-removable;
st,neg-edge;
mmc-ddr-3_3v;
no-1-8-v;
bus-width = <8>;
vmmc-supply = <&v3v3>;
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
};
在根节点下添加:
atk_pinctrl_lcd {
gpior = <&gpioe 9 GPIO_ACTIVE_LOW>;
gpiog = <&gpioa 15 GPIO_ACTIVE_LOW>;
gpiob = <&gpioe 15 GPIO_ACTIVE_LOW>;
};
修改panel_rgb:panel-rgb,这里继续偷懒,直接复制粘贴了
panel_rgb: panel-rgb {
compatible = "simple-panel";
backlight = <&panel_backlight>;
power-supply = <&v3v3>;
status = "okay";
port {
panel_in_rgb: endpoint {
remote-endpoint = <<dc_out_rgb>;
};
};
display-timings {
native-mode = <&timing0>; /* 时序信息 */
timing0: timing0 { /* 7 寸 1024*600 分辨率 */
clock-frequency = <51200000>; /* LCD 像素时钟,单位 Hz */
hactive = <1024>; /* LCD X 轴像素个数 */
vactive = <600>; /* LCD Y 轴像素个数 */
hfront-porch = <160>; /* LCD hfp 参数 */
hback-porch = <140>; /* LCD hbp 参数 */
hsync-len = <20>; /* LCD hspw 参数 */
vback-porch = <20>; /* LCD vbp 参数 */
vfront-porch = <12>; /* LCD vfp 参数 */
vsync-len = <3>; /* LCD vspw 参数 */
};
};
};
修改panel_backlight,ST用的是PE 12,正点原子用的是PD 13
panel_backlight: panel-backlight {
compatible = "gpio-backlight";
gpios = <&gpiod 13 GPIO_ACTIVE_HIGH>;
default-on;
status = "okay";
};
然后向pinctrl追加:
&pinctrl {
gpio_r:gpio_r {
pins {
pinmux = ; /* PE9.GPIO */
bias-pull-up;
drive-push-pull;
};
};
gpio_g:gpio_g {
pins {
pinmux = ; /* PA15.GPIO */
bias-pull-up;
drive-push-pull;
};
};
gpio_b:gpio_b {
pins {
pinmux = ; /* PE15.GPIO */
bias-pull-up;
drive-push-pull;
};
};
};
找到eth1和eth2两个节点,直接覆盖修改
ð1 {
status = "okay";
pinctrl-0 = <ð1_rgmii_pins_a>;
pinctrl-1 = <ð1_rgmii_sleep_pins_a>;
pinctrl-names = "default", "sleep";
phy-mode = "rgmii-id";
max-speed = <1000>;
phy-handle = <&phy0_eth1>;
nvmem-cells = <ðernet_mac1_address>;
nvmem-cell-names = "mac-address";
mdio1 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "snps,dwmac-mdio";
phy0_eth1: ethernet-phy@1 {
reg = <1>;
};
};
};
/* 需要用eth2就取消注释即可 */
// ð2 {
// status = "okay";
// pinctrl-0 = <ð2_rgmii_pins_a>;
// pinctrl-1 = <ð2_rgmii_sleep_pins_a>;
// pinctrl-names = "default", "sleep";
// phy-mode = "rgmii-id";
// max-speed = <1000>;
// phy-handle = <&phy0_eth2>;
// phy-supply = <&v3v3>;
// nvmem-cells = <ðernet_mac2_address>;
// nvmem-cell-names = "mac-address";
// mdio1 {
// #address-cells = <1>;
// #size-cells = <0>;
// compatible = "snps,dwmac-mdio";
// phy0_eth2: ethernet-phy@2 {
// reg = <2>;
// };
// };
// };
偷个懒,直接照搬原子的引脚配置即可
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
/*
* Copyright (C) STMicroelectronics 2021 - All Rights Reserved
* Author: Alexandre Torgue
*/
#include
&pinctrl {
eth1_rgmii_pins_a: eth1-rgmii-1 {
pins1 {
pinmux = , /* ETH1_RGMII_CLK125 */
, /* ETH1_RGMII_GTX_CLK */
, /* ETH1_RGMII_TXD0 */
, /* ETH1_RGMII_TXD1 */
, /* ETH1_RGMII_TXD2 */
, /* ETH1_RGMII_TXD3 */
, /* ETH1_RGMII_TX_CTL */
, /* ETH1_MDIO */
; /* ETH1_MDC */
bias-disable;
drive-push-pull;
slew-rate = <2>;
};
pins2 {
pinmux = , /* ETH1_RGMII_RXD0 */
, /* ETH1_RGMII_RXD1 */
, /* ETH1_RGMII_RXD2 */
, /* ETH1_RGMII_RXD3 */
, /* ETH1_RGMII_RX_CLK */
; /* ETH1_RGMII_RX_CTL */
bias-disable;
};
};
eth1_rgmii_sleep_pins_a: eth1-rgmii-sleep-1 {
pins1 {
pinmux = , /* ETH1_RGMII_CLK125 */
, /* ETH1_RGMII_GTX_CLK */
, /* ETH1_RGMII_TXD0 */
, /* ETH1_RGMII_TXD1 */
, /* ETH1_RGMII_TXD2 */
, /* ETH1_RGMII_TXD3 */
, /* ETH1_RGMII_TX_CTL */
, /* ETH1_MDIO */
, /* ETH1_MDC */
, /* ETH1_RGMII_RXD0 */
, /* ETH1_RGMII_RXD1 */
, /* ETH1_RGMII_RXD2 */
, /* ETH1_RGMII_RXD3 */
, /* ETH1_RGMII_RX_CLK */
; /* ETH1_RGMII_RX_CTL */
};
};
eth2_rgmii_pins_a: eth2-rgmii-2 {
pins1 {
pinmux = , /* ETH2_RGMII_CLK125 */
, /* ETH2_RGMII_TXD0 */
, /* ETH2_RGMII_TXD1 */
, /* ETH2_RGMII_TXD2 */
, /* ETH2_RGMII_TXD3 */
, /* ETH2_RGMII_GTX_CLK */
, /* ETH2_RGMII_TX_CTL */
, /* ETH2_MDIO */
; /* ETH2_MDC */
bias-disable;
drive-push-pull;
slew-rate = <2>;
};
pins2 {
pinmux = , /* ETH2_RGMII_RXD0 */
, /* ETH2_RGMII_RXD1 */
, /* ETH2_RGMII_RXD2 */
, /* ETH2_RGMII_RXD3 */
, /* ETH2_RGMII_RX_CLK */
; /* ETH2_RGMII_RX_CTL */
bias-disable;
};
};
eth2_rgmii_sleep_pins_a: eth2-rgmii-sleep-2 {
pins1 {
pinmux = , /* ETH2_RGMII_CLK125 */
, /* ETH2_RGMII_TXD0 */
, /* ETH2_RGMII_TXD1 */
, /* ETH2_RGMII_TXD2 */
, /* ETH2_RGMII_TXD3 */
, /* ETH2_RGMII_GTX_CLK */
, /* ETH2_RGMII_TX_CTL */
, /* ETH2_MDIO */
, /* ETH2_MDC */
, /* ETH2_RGMII_RXD0 */
, /* ETH2_RGMII_RXD1 */
, /* ETH2_RGMII_RXD2 */
, /* ETH2_RGMII_RXD3 */
, /* ETH2_RGMII_RX_CLK */
; /* ETH2_RGMII_RX_CTL */
};
};
ltdc_pins_a: ltdc-0 {
pins {
pinmux = , /* LCD_CLK */
, /* LCD_HSYNC */
, /* LCD_VSYNC */
, /* LCD_DE */
, /* LCD_R0 */
, /* LCD_R1 */
, /* LCD_R2 */
, /* LCD_R3 */
, /* LCD_R4 */
, /* LCD_R5 */
, /* LCD_R6 */
, /* LCD_R7 */
, /* LCD_G0 */
, /* LCD_G1 */
, /* LCD_G2 */
, /* LCD_G3 */
, /* LCD_G4 */
, /* LCD_G5 */
, /* LCD_G6 */
, /* LCD_G7 */
, /* LCD_B0 */
, /* LCD_B1 */
, /* LCD_B2 */
, /* LCD_B3 */
, /* LCD_B4 */
, /* LCD_B5 */
, /* LCD_B6 */
; /* LCD_B7 */
bias-disable;
drive-push-pull;
slew-rate = <1>;
};
};
ltdc_sleep_pins_a: ltdc-sleep-0 {
pins {
pinmux = , /* LCD_CLK */
, /* LCD_HSYNC */
, /* LCD_VSYNC */
, /* LCD_DE */
, /* LCD_R0 */
, /* LCD_R1 */
, /* LCD_R2 */
, /* LCD_R3 */
, /* LCD_R4 */
, /* LCD_R5 */
, /* LCD_R6 */
, /* LCD_R7 */
, /* LCD_G0 */
, /* LCD_G1 */
, /* LCD_G2 */
, /* LCD_G3 */
, /* LCD_G4 */
, /* LCD_G5 */
, /* LCD_G6 */
, /* LCD_G7 */
, /* LCD_B0 */
, /* LCD_B1 */
, /* LCD_B2 */
, /* LCD_B3 */
, /* LCD_B4 */
, /* LCD_B5 */
, /* LCD_B6 */
; /* LCD_B7 */
};
};
sdmmc1_b4_pins_a: sdmmc1-b4-0 {
pins {
pinmux = , /* SDMMC1_D0 */
, /* SDMMC1_D1 */
, /* SDMMC1_D2 */
, /* SDMMC1_D3 */
; /* SDMMC1_CMD */
slew-rate = <1>;
drive-push-pull;
bias-disable;
};
};
sdmmc1_b4_od_pins_a: sdmmc1-b4-od-0 {
pins1 {
pinmux = , /* SDMMC1_D0 */
, /* SDMMC1_D1 */
, /* SDMMC1_D2 */
; /* SDMMC1_D3 */
slew-rate = <1>;
drive-push-pull;
bias-disable;
};
pins2 {
pinmux = ; /* SDMMC1_CMD */
slew-rate = <1>;
drive-open-drain;
bias-disable;
};
};
sdmmc1_b4_sleep_pins_a: sdmmc1-b4-sleep-0 {
pins {
pinmux = , /* SDMMC1_D0 */
, /* SDMMC1_D1 */
, /* SDMMC1_D2 */
, /* SDMMC1_D3 */
, /* SDMMC1_CK */
; /* SDMMC1_CMD */
};
};
sdmmc1_clk_pins_a: sdmmc1-clk-0 {
pins {
pinmux = ; /* SDMMC1_CK */
slew-rate = <1>;
drive-push-pull;
bias-disable;
};
};
sdmmc2_b4_pins_a: sdmmc2-b4-0 {
pins {
pinmux = , /* SDMMC2_D0 */
, /* SDMMC2_D1 */
, /* SDMMC2_D2 */
, /* SDMMC2_D3 */
; /* SDMMC2_CMD */
slew-rate = <1>;
drive-push-pull;
bias-pull-up;
};
};
sdmmc2_b4_b7_pins_a: sdmmc2-b4-b7-0 {
pins {
pinmux = , /* SDMMC2_D4 */
, /* SDMMC2_D5 */
, /* SDMMC2_D6 */
; /* SDMMC2_D7 */
slew-rate = <1>;
drive-push-pull;
bias-pull-up;
};
};
sdmmc2_b4_od_pins_a: sdmmc2-b4-od-0 {
pins1 {
pinmux = , /* SDMMC2_D0 */
, /* SDMMC2_D1 */
, /* SDMMC2_D2 */
; /* SDMMC2_D3 */
slew-rate = <1>;
drive-push-pull;
bias-pull-up;
};
pins2 {
pinmux = ; /* SDMMC2_CMD */
slew-rate = <1>;
drive-open-drain;
bias-pull-up;
};
};
sdmmc2_b4_b7_od_pins_a: sdmmc2-b4-b7-od-0 {
pins {
pinmux = , /* SDMMC2_D4 */
, /* SDMMC2_D5 */
, /* SDMMC2_D6 */
; /* SDMMC2_D7 */
slew-rate = <1>;
drive-push-pull;
bias-pull-up;
};
};
sdmmc2_b4_sleep_pins_a: sdmmc2-b4-sleep-0 {
pins {
pinmux = , /* SDMMC2_D0 */
, /* SDMMC2_D1 */
, /* SDMMC2_D2 */
, /* SDMMC2_D3 */
, /* SDMMC2_CK */
; /* SDMMC2_CMD */
};
};
sdmmc2_b4_b7_sleep_pins_a: sdmmc2-b4-b7-sleep-0 {
pins {
pinmux = , /* SDMMC2_D4 */
, /* SDMMC2_D5 */
, /* SDMMC2_D6 */
; /* SDMMC2_D7 */
};
};
sdmmc2_clk_pins_a: sdmmc2-clk-0 {
pins {
pinmux = ; /* SDMMC2_CK */
slew-rate = <1>;
drive-push-pull;
bias-pull-up;
};
};
uart4_pins_a: uart4-0 {
pins1 {
pinmux = ; /* UART4_TX */
bias-disable;
drive-push-pull;
slew-rate = <0>;
};
pins2 {
pinmux = ; /* UART4_RX */
bias-pull-up;
};
};
uart4_idle_pins_a: uart4-idle-0 {
pins1 {
pinmux = ; /* UART4_TX */
};
pins2 {
pinmux = ; /* UART4_RX */
bias-pull-up;
};
};
uart4_sleep_pins_a: uart4-sleep-0 {
pins {
pinmux = , /* UART4_TX */
; /* UART4_RX */
};
};
usbotg_hs_pins_a: usbotg-hs-0 {
pins {
pinmux = ; /* OTG_ID */
};
};
};
在stm32mp135-atk-u-boot.dtsi里,关于adc那一行是检测usb电压的,把它注释掉,然后笔者把快速启动注释了,led灯也没有用到。
config {
// u-boot,boot-led = "led-blue";
// u-boot,error-led = "led-red";
u-boot,mmc-env-partition = "u-boot-env";
// st,adc_usb_pd = <&adc1 6>, <&adc1 12>;
// st,fastboot-gpios = <&gpioa 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
st,stm32prog-gpios = <&gpioa 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};
这里一点至关重要!!!!
正点原子修改了phy的驱动,所以我们要找到drivers\net\phy\phy.c这个文件,在genphy_config_aneg(struct phy_device *phydev)这个函数后面插入
/***************alientek add****************/
#define YT8531_REG_DEBUG_ADDR_OFFSET 0x1e
#define YT8531_REG_DEBUG_DATA 0x1f
static int yt8531_rd_ext(struct phy_device *phydev, u32 regnum)
{
int val;
phy_write(phydev, MDIO_DEVAD_NONE, YT8531_REG_DEBUG_ADDR_OFFSET, regnum);
val = phy_read(phydev, MDIO_DEVAD_NONE, YT8531_REG_DEBUG_DATA);
return val;
}
static int yt8531_wr_ext(struct phy_device *phydev, u32 regnum, u16 val)
{
int ret;
ret = phy_write(phydev, MDIO_DEVAD_NONE, YT8531_REG_DEBUG_ADDR_OFFSET, regnum);
ret = phy_write(phydev, MDIO_DEVAD_NONE, YT8531_REG_DEBUG_DATA, val);
return ret;
}
int yt8531_xtal_init(struct phy_device *phydev)
{
int ret = 0;
int val = 0;
mdelay(50);
do {
ret = yt8531_wr_ext(phydev, 0xa012, 0x88);
if (ret < 0)
return ret;
mdelay(100);
val = yt8531_rd_ext(phydev, 0xa012);
if (val < 0)
return val;
mdelay(20);
} while (val != 0x88);
ret = yt8531_wr_ext(phydev, 0xa012, 0xd0);
if (ret < 0)
return ret;
return ret;
}
void yt8531_led_init(struct phy_device *phydev)
{
yt8531_wr_ext(phydev, 0xa00d, 0x2600); //yellow led blink
yt8531_wr_ext(phydev, 0xa00c, 0x30); //10_100M green led always light
yt8531_wr_ext(phydev, 0xa00e, 0x40); //1000M green led always light
}
/*********************end add***************************/
然后修改 int genphy_update_link(struct phy_device *phydev)这个函数
/**
* genphy_update_link - update link status in @phydev
* @phydev: target phy_device struct
*
* Description: Update the value in phydev->link to reflect the
* current link value. In order to do this, we need to read
* the status register twice, keeping the second value.
*/
int genphy_update_link(struct phy_device *phydev)
{
unsigned int mii_reg;
/************alientek add********/
int ret = 0;
unsigned int phyid1, phyid2;
phyid1 = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID1);
phyid2 = phy_read(phydev, MDIO_DEVAD_NONE, MII_PHYSID2);
if((phyid1 == 0x4f51) && (phyid2 == 0xe91b)) { //YT8531 ID
ret = yt8531_xtal_init(phydev);
if (ret < 0)
{
printf("yt8531_xtal_init failed.\r\n");
return ret;
}
yt8531_led_init(phydev);
}
/*********************end add***************************/
/*
* Wait if the link is up, and autonegotiation is in progress
* (ie - we're capable and it's not done)
*/
mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
/*
* If we already saw the link up, and it hasn't gone down, then
* we don't need to wait for autoneg again
*/
if (phydev->link && mii_reg & BMSR_LSTATUS)
return 0;
if ((phydev->autoneg == AUTONEG_ENABLE) &&
!(mii_reg & BMSR_ANEGCOMPLETE)) {
int i = 0;
printf("%s Waiting for PHY auto negotiation to complete",
phydev->dev->name);
while (!(mii_reg & BMSR_ANEGCOMPLETE)) {
/*
* Timeout reached ?
*/
if (i > (PHY_ANEG_TIMEOUT / 50)) {
printf(" TIMEOUT !\n");
phydev->link = 0;
return -ETIMEDOUT;
}
if (ctrlc()) {
puts("user interrupt!\n");
phydev->link = 0;
return -EINTR;
}
if ((i++ % 10) == 0)
printf(".");
mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
mdelay(50); /* 50 ms */
}
printf(" done\n");
phydev->link = 1;
} else {
/* Read the link a second time to clear the latched state */
mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
if (mii_reg & BMSR_LSTATUS)
phydev->link = 1;
else
phydev->link = 0;
}
return 0;
}
make -f ../Makefile.sdk all
由于我们前面已经编译好了TF-A和optee,在这里编译uboot的时候,会自动用fiptool给我们打包好,然后生成我们需要的fip-stm32mp135-atk-optee.bin文件