没志青年
发布于 2025-09-08 / 15 阅读
0

Linux 以太网驱动移植

将 pinctrl_spi4 修改为

pinctrl_spi4: spi4grp {
  fsl,pins = <
    MX6ULL_PAD_BOOT_MODE0__GPIO5_IO10        0x70a1
    MX6ULL_PAD_BOOT_MODE1__GPIO5_IO11        0x70a1
  >;
};

将 spi4 修改为

	spi4 {
		compatible = "spi-gpio";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_spi4>;
		
		status = "okay";
		gpio-sck = <&gpio5 11 0>;
		gpio-mosi = <&gpio5 10 0>;
		
		num-chipselects = <1>;
		#address-cells = <1>;
		#size-cells = <0>;

		gpio_spi: gpio_spi@0 {
			compatible = "fairchild,74hc595";
			gpio-controller;
			#gpio-cells = <2>;
			reg = <0>;
			registers-number = <1>;
			registers-default = /bits/ 8 <0x57>;
			spi-max-frequency = <100000>;
		};
	};

在 &iomuxc_snvs 节点下添加

pinctrl_enet1_reset: enet1resetgrp {
	fsl,pins = <
		MX6ULL_PAD_SNVS_TAMPER7__GPIO5_IO07 0x10B0 
	>;
};

pinctrl_enet2_reset: enet2resetgrp {
	fsl,pins = <
		MX6ULL_PAD_SNVS_TAMPER8__GPIO5_IO08 0x10B0 
	>;
};

确保 MX6UL_PAD_ENET1_TX_CLK__ENET1_REF_CLK1 和 MX6UL_PAD_ENET2_TX_CLK__ENET2_REF_CLK2 的值为 0x4001b031,默认就是这个。

修改

&fec1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_enet1
			&pinctrl_enet1_reset>;
	phy-mode = "rmii";
	phy-handle = <&ethphy0>;
	phy-reset-gpios = <&gpio5 7 GPIO_ACTIVE_LOW>;
	phy-reset-duration = <200>;
	status = "okay";
};

&fec2 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_enet2
			&pinctrl_enet2_reset>;
	phy-mode = "rmii";
	phy-handle = <&ethphy1>;
	phy-reset-gpios = <&gpio5 8 GPIO_ACTIVE_LOW>;
	phy-reset-duration = <200>;
	status = "okay";

	mdio {
		#address-cells = <1>;
		#size-cells = <0>;

		ethphy0: ethernet-phy@2 {
			compatible = "ethernet-phy-ieee802.3-c22";
			smsc,disable-energy-detect;
			reg = <2>;
		};

		ethphy1: ethernet-phy@1 {
			compatible = "ethernet-phy-ieee802.3-c22";
			smsc,disable-energy-detect;
			reg = <1>;
		};
	};
};

修改 drivers/net/ethernet/freescale/fec_main.c

在3356行添加msleep(200);