Device Driver Configuration

A DTS/DTSI file is used to store all the device tree configuration.

The device tree of Ethernet is stored in the following path:
linux-5.10/arch/riscv/boot/dts/starfive/
The following code block shows the DTS file structure for Ethernet.
linux-5.15.0
└-- arch
└-- | -- riscv
| -- | -- | -- boot
| -- | -- | -- | -- dts
| -- | -- | -- | -- | -- starfive
| -- | -- | -- | -- | -- | -- jh7110-common.dtsi
| -- | -- | -- | -- | -- | -- jh7110.dts
The following code block shows an example of the device tree source code of the "gmac0" in the file jh7110.dts.
		gmac0: ethernet@16030000 {
			compatible = "starfive,dwmac","snps,dwmac-5.10a";
			reg = <0x0 0x16030000 0x0 0x10000>;
			clock-names = "gtx",
				"tx",
				"ptp_ref",
				"stmmaceth",
				"pclk",
				"gtxc",
				"rmii_rtx";
			clocks = <&clkgen JH7110_GMAC0_GTXCLK>,
				 <&clkgen JH7110_U0_GMAC5_CLK_TX>,
				 <&clkgen JH7110_GMAC0_PTP>,
				 <&clkgen JH7110_U0_GMAC5_CLK_AHB>,
				 <&clkgen JH7110_U0_GMAC5_CLK_AXI>,
				 <&clkgen JH7110_GMAC0_GTXC>,
				 <&clkgen JH7110_GMAC0_RMII_RTX>;
			resets = <&rstgen RSTN_U0_DW_GMAC5_AXI64_AHB>,
				 <&rstgen RSTN_U0_DW_GMAC5_AXI64_AXI>;
			reset-names = "ahb", "stmmaceth";
			interrupts = <7>, <6>, <5> ;
			interrupt-names = "macirq", "eth_wake_irq", "eth_lpi";
			max-frame-size = <9000>;
			phy-mode = "rgmii-id";
			snps,multicast-filter-bins = <64>;
			snps,perfect-filter-entries = <128>;
			rx-fifo-depth = <2048>;
			tx-fifo-depth = <2048>;
			snps,fixed-burst;
			snps,no-pbl-x8;
			snps,force_thresh_dma_mode;
			snps,axi-config = <&stmmac_axi_setup>;
			snps,tso;
			snps,en-tx-lpi-clockgating;
			snps,en-lpi;
			snps,write-requests = <4>;
			snps,read-requests = <4>;
			snps,burst-map = <0x7>;
			snps,txpbl = <16>;
			snps,rxpbl = <16>;
			status = "disabled";
		};

The following list provides explanations for the parameters included in the above code block.

  • compatible: Compatibility information, used to associate the driver and its target device.
  • reg: Register base address "0x16030000" and range "0x10000".
  • clocks: The clocks used by the Ethernet module.
  • clock-names: The names of the above clocks.
  • resets: The reset signals used by the Ethernet module.
  • reset-names: The names of the above reset signals.
  • interrupts: Hardware interrupt ID.
  • interrupt-names: The names of the above interrupts.
  • phy-mode: The Ethernet PHY mode, for example, "rgmii" or "rmii".
  • snps: See Synopsis documentation for PHY specific parameters.
  • status: The work status of the Ethernet, "enabled" or "disabled".
The following code block shows an example of the device tree source code of the "gmac0" in the file jh7110-common.dtsi:
&gmac0 {
	status = "okay";
	#address-cells = <1>;
	#size-cells = <0>;
	phy0: ethernet-phy@0 {
		rxc_dly_en = <1>;
		rx_delay_sel = <0>;
		tx_delay_sel_fe = <5>;
		tx_delay_sel = <0xa>;
		tx_inverted_10 = <0x1>;
		tx_inverted_100 = <0x1>;
		tx_inverted_1000 = <0x1>;
	};
};

&gmac1 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";
	phy1: ethernet-phy@1 {
		tx_delay_sel_fe = <5>;
		tx_delay_sel = <0>;
		rxc_dly_en = <0>;
		rx_delay_sel = <0>;
		tx_inverted_10 = <0x1>;
		tx_inverted_100 = <0x1>;
		tx_inverted_1000 = <0x0>;
	};
};};22 };

The following list provides an explanation of the parameters in the above code block.

  • rxc_dly_en: This field is used to set whether to enable the 2ns time delay of the receiver in RGMII mode. 1: Enable. 0: Disable.
  • rx_delay_sel: This field is used to configure the receiver clock time delay, 150 ps per step width, accepted range: 0x0 - 0xf.
  • tx_delay_sel_fe: This field is used to configure the transmitter clock time delay in 10 M/100 M mode, 150 ps per step width, accepted range: 0x0 - 0xf.
  • tx_delay_sel: This field is used to configure the transmitter clock time delay in 1,000 M mode, 150 ps per step width, accepted range: 0x0 - 0xf.
  • tx_inverted_10: This field is used to set whether to enable the transmitter clock inversion in 10 M mode. 1: Enable. 0: Disable.
  • tx_inverted_100: This field is used to set whether to enable the transmitter clock inversion in 100 M mode. 1: Enable. 0: Disable.
  • tx_inverted_1000: This field is used to set whether to enable the transmitter clock inversion in 1,000 M mode. 1: Enable. 0: Disable.