target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl930x.c
int rtl930x_eee_port_ability(struct rtl838x_switch_priv *priv, struct ethtool_eee *e, int port)
{
	u32 link, a;

	if (port >= 26)
		return -ENOTSUPP;

	pr_info("In %s, port %d\n", __func__, port);
	link = sw_r32(RTL930X_MAC_LINK_STS);
	link = sw_r32(RTL930X_MAC_LINK_STS);
	if (!(link & BIT(port)))
		return 0;

	pr_info("Setting advertised\n");
	if (sw_r32(rtl930x_mac_force_mode_ctrl(port)) & BIT(10))
		e->advertised |= ADVERTISED_100baseT_Full;

	if (sw_r32(rtl930x_mac_force_mode_ctrl(port)) & BIT(12))
		e->advertised |= ADVERTISED_1000baseT_Full;

	if (priv->ports[port].is2G5 && sw_r32(rtl930x_mac_force_mode_ctrl(port)) & BIT(13)) {
		pr_info("ADVERTISING 2.5G EEE\n");
		e->advertised |= ADVERTISED_2500baseX_Full;
	}

	if (priv->ports[port].is10G && sw_r32(rtl930x_mac_force_mode_ctrl(port)) & BIT(15))
		e->advertised |= ADVERTISED_10000baseT_Full;

	a = sw_r32(RTL930X_MAC_EEE_ABLTY);
	a = sw_r32(RTL930X_MAC_EEE_ABLTY);
	pr_info("Link partner: %08x\n", a);
	if (a & BIT(port)) {
		e->lp_advertised = ADVERTISED_100baseT_Full;
		e->lp_advertised |= ADVERTISED_1000baseT_Full;
		if (priv->ports[port].is2G5)
			e->lp_advertised |= ADVERTISED_2500baseX_Full;
		if (priv->ports[port].is10G)
			e->lp_advertised |= ADVERTISED_10000baseT_Full;
	}

	// Read 2x to clear latched state
	a = sw_r32(RTL930X_EEEP_PORT_CTRL(port));
	a = sw_r32(RTL930X_EEEP_PORT_CTRL(port));
	pr_info("%s RTL930X_EEEP_PORT_CTRL: %08x\n", __func__, a);

	return 0;
}
/*
 * Get EEE own capabilities and negotiation result
 */
Get EEE own capabilities and negotiation result
Get EEE own capabilities and negotiation result
int rtl930x_eee_port_ability(struct rtl838x_switch_priv *priv, struct ethtool_eee *e, int port)
{
	u32 link, a;
	if (port >= 26)
		return -ENOTSUPP;
	pr_info("In %s, port %d\n", __func__, port);
	link = sw_r32(RTL930X_MAC_LINK_STS);
	link = sw_r32(RTL930X_MAC_LINK_STS);
	if (!(link & BIT(port)))
		return 0;
	pr_info("Setting advertised\n");
	if (sw_r32(rtl930x_mac_force_mode_ctrl(port)) & BIT(10))
		e->advertised |= ADVERTISED_100baseT_Full;
	if (sw_r32(rtl930x_mac_force_mode_ctrl(port)) & BIT(12))
		e->advertised |= ADVERTISED_1000baseT_Full;
	if (priv->ports[port].is2G5 && sw_r32(rtl930x_mac_force_mode_ctrl(port)) & BIT(13)) {
		pr_info("ADVERTISING 2.5G EEE\n");
		e->advertised |= ADVERTISED_2500baseX_Full;
	}
	if (priv->ports[port].is10G && sw_r32(rtl930x_mac_force_mode_ctrl(port)) & BIT(15))
		e->advertised |= ADVERTISED_10000baseT_Full;
	a = sw_r32(RTL930X_MAC_EEE_ABLTY);
	a = sw_r32(RTL930X_MAC_EEE_ABLTY);
	pr_info("Link partner: %08x\n", a);
	if (a & BIT(port)) {
		e->lp_advertised = ADVERTISED_100baseT_Full;
		e->lp_advertised |= ADVERTISED_1000baseT_Full;
		if (priv->ports[port].is2G5)
			e->lp_advertised |= ADVERTISED_2500baseX_Full;
		if (priv->ports[port].is10G)
			e->lp_advertised |= ADVERTISED_10000baseT_Full;
	}
	a = sw_r32(RTL930X_EEEP_PORT_CTRL(port));
	a = sw_r32(RTL930X_EEEP_PORT_CTRL(port));
	pr_info("%s RTL930X_EEEP_PORT_CTRL: %08x\n", __func__, a);
	return 0;
}
int rtl930x_eee_port_ability ( struct rtl838x_switch_priv * priv , struct ethtool_eee * e , int port ) { u32 link , a ; if ( port >= 26 ) return - ENOTSUPP ; pr_info ( " \n " , __func__ , port ) ; link = sw_r32 ( RTL930X_MAC_LINK_STS ) ; link = sw_r32 ( RTL930X_MAC_LINK_STS ) ; if ( ! ( link & BIT ( port ) ) ) return 0 ; pr_info ( " \n " ) ; if ( sw_r32 ( rtl930x_mac_force_mode_ctrl ( port ) ) & BIT ( 10 ) ) e -> advertised |= ADVERTISED_100baseT_Full ; if ( sw_r32 ( rtl930x_mac_force_mode_ctrl ( port ) ) & BIT ( 12 ) ) e -> advertised |= ADVERTISED_1000baseT_Full ; if ( priv -> ports [ port ] . is2G5 && sw_r32 ( rtl930x_mac_force_mode_ctrl ( port ) ) & BIT ( 13 ) ) { pr_info ( " \n " ) ; e -> advertised |= ADVERTISED_2500baseX_Full ; } if ( priv -> ports [ port ] . is10G && sw_r32 ( rtl930x_mac_force_mode_ctrl ( port ) ) & BIT ( 15 ) ) e -> advertised |= ADVERTISED_10000baseT_Full ; a = sw_r32 ( RTL930X_MAC_EEE_ABLTY ) ; a = sw_r32 ( RTL930X_MAC_EEE_ABLTY ) ; pr_info ( " \n " , a ) ; if ( a & BIT ( port ) ) { e -> lp_advertised = ADVERTISED_100baseT_Full ; e -> lp_advertised |= ADVERTISED_1000baseT_Full ; if ( priv -> ports [ port ] . is2G5 ) e -> lp_advertised |= ADVERTISED_2500baseX_Full ; if ( priv -> ports [ port ] . is10G ) e -> lp_advertised |= ADVERTISED_10000baseT_Full ; } a = sw_r32 ( RTL930X_EEEP_PORT_CTRL ( port ) ) ; a = sw_r32 ( RTL930X_EEEP_PORT_CTRL ( port ) ) ; pr_info ( " \n " , __func__ , a ) ; return 0 ; }
Get EEE own capabilities and negotiation result
Get EEE own capabilities and negotiation result
// Read 2x to clear latched state