Message ID | 20230816111310.1656224-1-keguang.zhang@gmail.com |
---|---|
Headers | show |
Series | Move Loongson1 MAC arch-code to the driver dir | expand |
On Wed, Aug 16, 2023 at 07:13:09PM +0800, Keguang Zhang wrote: > This glue driver is created based on the arch-code > implemented earlier with the platform-specific settings. > > Use syscon for SYSCON register access. > > Partialy based on the previous work by Serge Semin. Hi Keguang Zhang, as it looks like there will be a v3 for other reasons, a minor nit from my side: Partialy -> Partially ...
> +static int ls1b_dwmac_syscon_init(struct plat_stmmacenet_data *plat) > +{ > + struct ls1x_dwmac *dwmac = plat->bsp_priv; > + struct regmap_field **regmap_fields = dwmac->regmap_fields; > + > + if (plat->bus_id) { > + regmap_field_write(regmap_fields[GMAC1_USE_UART1], 1); > + regmap_field_write(regmap_fields[GMAC1_USE_UART0], 1); > + > + switch (plat->phy_interface) { > + case PHY_INTERFACE_MODE_RGMII: > + regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 0); > + regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 0); > + break; What about the other three RGMII modes? Plain rgmii is pretty unusual, rgmii-id is the most used. > + case PHY_INTERFACE_MODE_MII: > + regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 1); > + regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 1); > + break; > + default: > + dev_err(dwmac->dev, "Unsupported PHY mode %u\n", > + plat->phy_interface); > + return -EOPNOTSUPP; > + } > + > + regmap_field_write(regmap_fields[GMAC1_SHUT], 0); > + } else { > + switch (plat->phy_interface) { > + case PHY_INTERFACE_MODE_RGMII: > + regmap_field_write(regmap_fields[GMAC0_USE_TXCLK], 0); > + regmap_field_write(regmap_fields[GMAC0_USE_PWM01], 0); > + break; same here. Andrew
On Sun, Aug 20, 2023 at 3:05 AM Simon Horman <horms@kernel.org> wrote: > > On Wed, Aug 16, 2023 at 07:13:09PM +0800, Keguang Zhang wrote: > > This glue driver is created based on the arch-code > > implemented earlier with the platform-specific settings. > > > > Use syscon for SYSCON register access. > > > > Partialy based on the previous work by Serge Semin. > > Hi Keguang Zhang, > > as it looks like there will be a v3 for other reasons, > a minor nit from my side: Partialy -> Partially > Will do. Thanks! > ...
On Mon, Aug 21, 2023 at 3:04 AM Andrew Lunn <andrew@lunn.ch> wrote: > > > +static int ls1b_dwmac_syscon_init(struct plat_stmmacenet_data *plat) > > +{ > > + struct ls1x_dwmac *dwmac = plat->bsp_priv; > > + struct regmap_field **regmap_fields = dwmac->regmap_fields; > > + > > + if (plat->bus_id) { > > + regmap_field_write(regmap_fields[GMAC1_USE_UART1], 1); > > + regmap_field_write(regmap_fields[GMAC1_USE_UART0], 1); > > + > > + switch (plat->phy_interface) { > > + case PHY_INTERFACE_MODE_RGMII: > > + regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 0); > > + regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 0); > > + break; > > What about the other three RGMII modes? Plain rgmii is pretty unusual, > rgmii-id is the most used. > According to the LS1B datasheet, only RGMII and MII are supported. And I can confirm that MII mode does work for LS1B. > > + case PHY_INTERFACE_MODE_MII: > > + regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 1); > > + regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 1); > > + break; > > + default: > > + dev_err(dwmac->dev, "Unsupported PHY mode %u\n", > > + plat->phy_interface); > > + return -EOPNOTSUPP; > > + } > > + > > + regmap_field_write(regmap_fields[GMAC1_SHUT], 0); > > + } else { > > + switch (plat->phy_interface) { > > + case PHY_INTERFACE_MODE_RGMII: > > + regmap_field_write(regmap_fields[GMAC0_USE_TXCLK], 0); > > + regmap_field_write(regmap_fields[GMAC0_USE_PWM01], 0); > > + break; > > same here. > > Andrew
On Tue, Aug 22, 2023 at 5:47 PM Keguang Zhang <keguang.zhang@gmail.com> wrote: > > On Mon, Aug 21, 2023 at 3:04 AM Andrew Lunn <andrew@lunn.ch> wrote: > > > > > +static int ls1b_dwmac_syscon_init(struct plat_stmmacenet_data *plat) > > > +{ > > > + struct ls1x_dwmac *dwmac = plat->bsp_priv; > > > + struct regmap_field **regmap_fields = dwmac->regmap_fields; > > > + > > > + if (plat->bus_id) { > > > + regmap_field_write(regmap_fields[GMAC1_USE_UART1], 1); > > > + regmap_field_write(regmap_fields[GMAC1_USE_UART0], 1); > > > + > > > + switch (plat->phy_interface) { > > > + case PHY_INTERFACE_MODE_RGMII: > > > + regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 0); > > > + regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 0); > > > + break; > > > > What about the other three RGMII modes? Plain rgmii is pretty unusual, > > rgmii-id is the most used. > > > According to the LS1B datasheet, only RGMII and MII are supported. > And I can confirm that MII mode does work for LS1B. > Sorry! The RGMII mode does work for LS1B. > > > + case PHY_INTERFACE_MODE_MII: > > > + regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 1); > > > + regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 1); > > > + break; > > > + default: > > > + dev_err(dwmac->dev, "Unsupported PHY mode %u\n", > > > + plat->phy_interface); > > > + return -EOPNOTSUPP; > > > + } > > > + > > > + regmap_field_write(regmap_fields[GMAC1_SHUT], 0); > > > + } else { > > > + switch (plat->phy_interface) { > > > + case PHY_INTERFACE_MODE_RGMII: > > > + regmap_field_write(regmap_fields[GMAC0_USE_TXCLK], 0); > > > + regmap_field_write(regmap_fields[GMAC0_USE_PWM01], 0); > > > + break; > > > > same here. > > > > Andrew > > > > -- > Best regards, > > Keguang Zhang
> > What about the other three RGMII modes? Plain rgmii is pretty unusual, > > rgmii-id is the most used. > > > According to the LS1B datasheet, only RGMII and MII are supported. > And I can confirm that MII mode does work for LS1B. What does your device tree look like? What are you setting phy-mode to in the rgmii case? As i said, "rgmii" is pretty unusual, you normally need "rgmii-id". Something in the system needs to add 2ns delays to the RGMII clock lines. Generally in device tree you pass phy-mode = "rgmii-id"; The MAC configures itself for RGMII, and passes PHY_INTERFACE_MODE_RGMII_ID to the PHY when it is attached. The PHY then inserts the delays. What is inserting the delays in your system? Andrew
> Sorry! The RGMII mode does work for LS1B.
and the question then is: How does it work?
Andrew
On Tue, Aug 22, 2023 at 11:20 PM Andrew Lunn <andrew@lunn.ch> wrote: > > > > What about the other three RGMII modes? Plain rgmii is pretty unusual, > > > rgmii-id is the most used. > > > > > According to the LS1B datasheet, only RGMII and MII are supported. > > And I can confirm that MII mode does work for LS1B. > > What does your device tree look like? What are you setting phy-mode to > in the rgmii case? As i said, "rgmii" is pretty unusual, you normally > need "rgmii-id". > > Something in the system needs to add 2ns delays to the RGMII clock > lines. Generally in device tree you pass phy-mode = "rgmii-id"; The > MAC configures itself for RGMII, and passes > PHY_INTERFACE_MODE_RGMII_ID to the PHY when it is attached. The PHY > then inserts the delays. > > What is inserting the delays in your system? > I understand the delay issue of RGMII. Just tried phy-mode = "rgmii-id", it still works. I will use PHY_INTERFACE_MODE_RGMII_ID instead. Thanks! > Andrew >
> I understand the delay issue of RGMII. > Just tried phy-mode = "rgmii-id", it still works. That indicates something is broken. Both "rgmii-id" and "rgmii" should not work, just one of them. What PHY driver are you using? Andrew
On Wed, Aug 23, 2023 at 11:46 AM Andrew Lunn <andrew@lunn.ch> wrote: > > > I understand the delay issue of RGMII. > > Just tried phy-mode = "rgmii-id", it still works. > > That indicates something is broken. Both "rgmii-id" and "rgmii" should > not work, just one of them. What PHY driver are you using? > I used generic PHY driver. Both "rgmii" and "rgmii-id" work with this driver. The PHY is RTL8211E. So I switch the PHY driver to Realtek driver. Now only "rgmii-id" works. Thanks! > Andrew > -- Best regards, Keguang Zhang