Lines Matching refs:slave
764 struct gbe_slave *slave; member
1728 #define for_each_sec_slave(slave, priv) \ argument
1729 list_for_each_entry((slave), &(priv)->secondary_slaves, slave_list)
1944 if (!gbe_intf->slave) in keystone_get_link_ksettings()
1948 cmd->base.port = gbe_intf->slave->phy_port_t; in keystone_get_link_ksettings()
1976 if (!gbe_intf->slave) in keystone_set_link_ksettings()
1979 if (port != gbe_intf->slave->phy_port_t) { in keystone_set_link_ksettings()
1996 gbe_intf->slave->phy_port_t = port; in keystone_set_link_ksettings()
2056 static void gbe_set_slave_mac(struct gbe_slave *slave, in gbe_set_slave_mac() argument
2061 writel(mac_hi(ndev->dev_addr), GBE_REG_ADDR(slave, port_regs, sa_hi)); in gbe_set_slave_mac()
2062 writel(mac_lo(ndev->dev_addr), GBE_REG_ADDR(slave, port_regs, sa_lo)); in gbe_set_slave_mac()
2075 struct gbe_slave *slave, in netcp_ethss_link_state_action() argument
2078 struct phy_device *phy = slave->phy; in netcp_ethss_link_state_action()
2082 mac_control = slave->mac_control; in netcp_ethss_link_state_action()
2091 writel(mac_control, GBE_REG_ADDR(slave, emac_regs, in netcp_ethss_link_state_action()
2094 cpsw_ale_control_set(gbe_dev->ale, slave->port_num, in netcp_ethss_link_state_action()
2098 if (ndev && slave->open && in netcp_ethss_link_state_action()
2099 ((slave->link_interface != SGMII_LINK_MAC_PHY) && in netcp_ethss_link_state_action()
2100 (slave->link_interface != RGMII_LINK_MAC_PHY) && in netcp_ethss_link_state_action()
2101 (slave->link_interface != XGMII_LINK_MAC_PHY))) in netcp_ethss_link_state_action()
2104 writel(mac_control, GBE_REG_ADDR(slave, emac_regs, in netcp_ethss_link_state_action()
2106 cpsw_ale_control_set(gbe_dev->ale, slave->port_num, in netcp_ethss_link_state_action()
2110 ((slave->link_interface != SGMII_LINK_MAC_PHY) && in netcp_ethss_link_state_action()
2111 (slave->link_interface != RGMII_LINK_MAC_PHY) && in netcp_ethss_link_state_action()
2112 (slave->link_interface != XGMII_LINK_MAC_PHY))) in netcp_ethss_link_state_action()
2120 static bool gbe_phy_link_status(struct gbe_slave *slave) in gbe_phy_link_status() argument
2122 return !slave->phy || slave->phy->link; in gbe_phy_link_status()
2136 struct gbe_slave *slave, in netcp_ethss_update_link_state() argument
2140 int sp = slave->slave_num, link_state; in netcp_ethss_update_link_state()
2142 if (!slave->open) in netcp_ethss_update_link_state()
2145 if (SLAVE_LINK_IS_RGMII(slave)) in netcp_ethss_update_link_state()
2148 if (SLAVE_LINK_IS_SGMII(slave)) in netcp_ethss_update_link_state()
2152 phy_link_state = gbe_phy_link_status(slave); in netcp_ethss_update_link_state()
2155 if (atomic_xchg(&slave->link_state, link_state) != link_state) in netcp_ethss_update_link_state()
2156 netcp_ethss_link_state_action(gbe_dev, ndev, slave, in netcp_ethss_update_link_state()
2169 netcp_ethss_update_link_state(gbe_intf->gbe_dev, gbe_intf->slave, in xgbe_adjust_link()
2182 netcp_ethss_update_link_state(gbe_intf->gbe_dev, gbe_intf->slave, in gbe_adjust_link()
2189 struct gbe_slave *slave; in gbe_adjust_link_sec_slaves() local
2191 for_each_sec_slave(slave, gbe_dev) in gbe_adjust_link_sec_slaves()
2192 netcp_ethss_update_link_state(gbe_dev, slave, NULL); in gbe_adjust_link_sec_slaves()
2198 static int gbe_port_reset(struct gbe_slave *slave) in gbe_port_reset() argument
2203 writel(SOFT_RESET, GBE_REG_ADDR(slave, emac_regs, soft_reset)); in gbe_port_reset()
2207 v = readl(GBE_REG_ADDR(slave, emac_regs, soft_reset)); in gbe_port_reset()
2217 static void gbe_port_config(struct gbe_priv *gbe_dev, struct gbe_slave *slave, in gbe_port_config() argument
2228 (slave->link_interface >= XGMII_LINK_MAC_PHY)) { in gbe_port_config()
2230 xgmii_mode |= (1 << slave->slave_num); in gbe_port_config()
2235 rx_maxlen_reg = GBE_REG_ADDR(slave, port_regs, rx_maxlen); in gbe_port_config()
2237 rx_maxlen_reg = GBE_REG_ADDR(slave, emac_regs, rx_maxlen); in gbe_port_config()
2240 writel(slave->mac_control, GBE_REG_ADDR(slave, emac_regs, mac_control)); in gbe_port_config()
2244 struct gbe_slave *slave, bool set) in gbe_sgmii_rtreset() argument
2246 if (SLAVE_LINK_IS_XGMII(slave)) in gbe_sgmii_rtreset()
2249 netcp_sgmii_rtreset(SGMII_BASE(priv, slave->slave_num), in gbe_sgmii_rtreset()
2250 slave->slave_num, set); in gbe_sgmii_rtreset()
2256 struct gbe_slave *slave = intf->slave; in gbe_slave_stop() local
2259 gbe_sgmii_rtreset(gbe_dev, slave, true); in gbe_slave_stop()
2260 gbe_port_reset(slave); in gbe_slave_stop()
2262 cpsw_ale_control_set(gbe_dev->ale, slave->port_num, in gbe_slave_stop()
2265 1 << slave->port_num, 0, 0); in gbe_slave_stop()
2267 if (!slave->phy) in gbe_slave_stop()
2270 phy_stop(slave->phy); in gbe_slave_stop()
2271 phy_disconnect(slave->phy); in gbe_slave_stop()
2272 slave->phy = NULL; in gbe_slave_stop()
2275 static void gbe_sgmii_config(struct gbe_priv *priv, struct gbe_slave *slave) in gbe_sgmii_config() argument
2277 if (SLAVE_LINK_IS_XGMII(slave)) in gbe_sgmii_config()
2280 netcp_sgmii_reset(SGMII_BASE(priv, slave->slave_num), slave->slave_num); in gbe_sgmii_config()
2281 netcp_sgmii_config(SGMII_BASE(priv, slave->slave_num), slave->slave_num, in gbe_sgmii_config()
2282 slave->link_interface); in gbe_sgmii_config()
2288 struct gbe_slave *slave = gbe_intf->slave; in gbe_slave_open() local
2296 gbe_sgmii_config(priv, slave); in gbe_slave_open()
2297 gbe_port_reset(slave); in gbe_slave_open()
2299 gbe_sgmii_rtreset(priv, slave, false); in gbe_slave_open()
2300 gbe_port_config(priv, slave, priv->rx_packet_max); in gbe_slave_open()
2301 gbe_set_slave_mac(slave, gbe_intf); in gbe_slave_open()
2307 GBE_REG_ADDR(slave, port_regs, rx_pri_map)); in gbe_slave_open()
2310 cpsw_ale_control_set(priv->ale, slave->port_num, in gbe_slave_open()
2313 1 << slave->port_num, 0, 0, ALE_MCAST_FWD_2); in gbe_slave_open()
2315 if (slave->link_interface == SGMII_LINK_MAC_PHY) { in gbe_slave_open()
2318 slave->phy_port_t = PORT_MII; in gbe_slave_open()
2319 } else if (slave->link_interface == RGMII_LINK_MAC_PHY) { in gbe_slave_open()
2321 err = of_get_phy_mode(slave->node, &phy_mode); in gbe_slave_open()
2333 slave->phy_port_t = PORT_MII; in gbe_slave_open()
2334 } else if (slave->link_interface == XGMII_LINK_MAC_PHY) { in gbe_slave_open()
2337 slave->phy_port_t = PORT_FIBRE; in gbe_slave_open()
2344 slave->phy = of_phy_connect(gbe_intf->ndev, in gbe_slave_open()
2345 slave->phy_node, in gbe_slave_open()
2348 if (!slave->phy) { in gbe_slave_open()
2350 slave->slave_num); in gbe_slave_open()
2354 phydev_name(slave->phy)); in gbe_slave_open()
2355 phy_start(slave->phy); in gbe_slave_open()
2618 struct gbe_slave *slave = gbe_intf->slave; in gbe_hwtstamp() local
2623 writel(0, GBE_REG_ADDR(slave, port_regs, ts_ctl)); in gbe_hwtstamp()
2630 (slave->ts_ctl.dst_port_map << TS_CTL_DST_PORT_SHIFT) | in gbe_hwtstamp()
2631 (slave->ts_ctl.uni ? TS_UNI_EN : in gbe_hwtstamp()
2632 slave->ts_ctl.maddr_map << TS_CTL_MADDR_SHIFT); in gbe_hwtstamp()
2640 writel(ts_en, GBE_REG_ADDR(slave, port_regs, ts_ctl)); in gbe_hwtstamp()
2641 writel(seq_id, GBE_REG_ADDR(slave, port_regs, ts_seq_ltype)); in gbe_hwtstamp()
2642 writel(ctl, GBE_REG_ADDR(slave, port_regs, ts_ctl_ltype2)); in gbe_hwtstamp()
2822 struct phy_device *phy = gbe_intf->slave->phy; in gbe_ioctl()
2843 struct gbe_slave *slave; in netcp_ethss_timer() local
2847 if (!gbe_intf->slave->open) in netcp_ethss_timer()
2849 netcp_ethss_update_link_state(gbe_dev, gbe_intf->slave, in netcp_ethss_timer()
2854 for_each_sec_slave(slave, gbe_dev) { in netcp_ethss_timer()
2855 netcp_ethss_update_link_state(gbe_dev, slave, NULL); in netcp_ethss_timer()
2893 struct gbe_slave *slave = gbe_intf->slave; in gbe_open() local
2894 int port_num = slave->port_num; in gbe_open()
2943 slave->open = true; in gbe_open()
2944 netcp_ethss_update_link_state(gbe_dev, slave, ndev); in gbe_open()
2968 gbe_intf->slave->open = false; in gbe_close()
2969 atomic_set(&gbe_intf->slave->link_state, NETCP_LINK_STATE_INVALID); in gbe_close()
2974 static void init_slave_ts_ctl(struct gbe_slave *slave) in init_slave_ts_ctl() argument
2976 slave->ts_ctl.uni = 1; in init_slave_ts_ctl()
2977 slave->ts_ctl.dst_port_map = in init_slave_ts_ctl()
2979 slave->ts_ctl.maddr_map = in init_slave_ts_ctl()
2984 static void init_slave_ts_ctl(struct gbe_slave *slave) in init_slave_ts_ctl() argument
2989 static int init_slave(struct gbe_priv *gbe_dev, struct gbe_slave *slave, in init_slave() argument
2996 if (of_property_read_u32(node, "slave-port", &slave->slave_num)) { in init_slave()
3002 &slave->link_interface)) { in init_slave()
3005 slave->link_interface = SGMII_LINK_MAC_PHY; in init_slave()
3008 slave->node = node; in init_slave()
3009 slave->open = false; in init_slave()
3010 if ((slave->link_interface == SGMII_LINK_MAC_PHY) || in init_slave()
3011 (slave->link_interface == RGMII_LINK_MAC_PHY) || in init_slave()
3012 (slave->link_interface == XGMII_LINK_MAC_PHY)) in init_slave()
3013 slave->phy_node = of_parse_phandle(node, "phy-handle", 0); in init_slave()
3014 slave->port_num = gbe_get_slave_port(gbe_dev, slave->slave_num); in init_slave()
3016 if (slave->link_interface >= XGMII_LINK_MAC_PHY) in init_slave()
3017 slave->mac_control = GBE_DEF_10G_MAC_CONTROL; in init_slave()
3019 slave->mac_control = GBE_DEF_1G_MAC_CONTROL; in init_slave()
3022 port_reg_num = slave->slave_num; in init_slave()
3024 if (slave->slave_num > 1) { in init_slave()
3049 slave->port_regs = gbe_dev->switch_regs + port_reg_ofs + in init_slave()
3051 slave->emac_regs = gbe_dev->switch_regs + emac_reg_ofs + in init_slave()
3052 (emac_reg_blk_sz * slave->slave_num); in init_slave()
3056 GBE_SET_REG_OFS(slave, port_regs, port_vlan); in init_slave()
3057 GBE_SET_REG_OFS(slave, port_regs, tx_pri_map); in init_slave()
3058 GBE_SET_REG_OFS(slave, port_regs, sa_lo); in init_slave()
3059 GBE_SET_REG_OFS(slave, port_regs, sa_hi); in init_slave()
3060 GBE_SET_REG_OFS(slave, port_regs, ts_ctl); in init_slave()
3061 GBE_SET_REG_OFS(slave, port_regs, ts_seq_ltype); in init_slave()
3062 GBE_SET_REG_OFS(slave, port_regs, ts_vlan); in init_slave()
3063 GBE_SET_REG_OFS(slave, port_regs, ts_ctl_ltype2); in init_slave()
3064 GBE_SET_REG_OFS(slave, port_regs, ts_ctl2); in init_slave()
3067 GBE_SET_REG_OFS(slave, emac_regs, mac_control); in init_slave()
3068 GBE_SET_REG_OFS(slave, emac_regs, soft_reset); in init_slave()
3069 GBE_SET_REG_OFS(slave, emac_regs, rx_maxlen); in init_slave()
3073 GBENU_SET_REG_OFS(slave, port_regs, port_vlan); in init_slave()
3074 GBENU_SET_REG_OFS(slave, port_regs, tx_pri_map); in init_slave()
3075 GBENU_SET_REG_OFS(slave, port_regs, rx_pri_map); in init_slave()
3076 GBENU_SET_REG_OFS(slave, port_regs, sa_lo); in init_slave()
3077 GBENU_SET_REG_OFS(slave, port_regs, sa_hi); in init_slave()
3078 GBENU_SET_REG_OFS(slave, port_regs, ts_ctl); in init_slave()
3079 GBENU_SET_REG_OFS(slave, port_regs, ts_seq_ltype); in init_slave()
3080 GBENU_SET_REG_OFS(slave, port_regs, ts_vlan); in init_slave()
3081 GBENU_SET_REG_OFS(slave, port_regs, ts_ctl_ltype2); in init_slave()
3082 GBENU_SET_REG_OFS(slave, port_regs, ts_ctl2); in init_slave()
3083 GBENU_SET_REG_OFS(slave, port_regs, rx_maxlen); in init_slave()
3086 GBENU_SET_REG_OFS(slave, emac_regs, mac_control); in init_slave()
3087 GBENU_SET_REG_OFS(slave, emac_regs, soft_reset); in init_slave()
3091 XGBE_SET_REG_OFS(slave, port_regs, port_vlan); in init_slave()
3092 XGBE_SET_REG_OFS(slave, port_regs, tx_pri_map); in init_slave()
3093 XGBE_SET_REG_OFS(slave, port_regs, sa_lo); in init_slave()
3094 XGBE_SET_REG_OFS(slave, port_regs, sa_hi); in init_slave()
3095 XGBE_SET_REG_OFS(slave, port_regs, ts_ctl); in init_slave()
3096 XGBE_SET_REG_OFS(slave, port_regs, ts_seq_ltype); in init_slave()
3097 XGBE_SET_REG_OFS(slave, port_regs, ts_vlan); in init_slave()
3098 XGBE_SET_REG_OFS(slave, port_regs, ts_ctl_ltype2); in init_slave()
3099 XGBE_SET_REG_OFS(slave, port_regs, ts_ctl2); in init_slave()
3102 XGBE_SET_REG_OFS(slave, emac_regs, mac_control); in init_slave()
3103 XGBE_SET_REG_OFS(slave, emac_regs, soft_reset); in init_slave()
3104 XGBE_SET_REG_OFS(slave, emac_regs, rx_maxlen); in init_slave()
3107 atomic_set(&slave->link_state, NETCP_LINK_STATE_INVALID); in init_slave()
3109 init_slave_ts_ctl(slave); in init_slave()
3120 struct gbe_slave *slave; in init_secondary_ports() local
3124 slave = devm_kzalloc(dev, sizeof(*slave), GFP_KERNEL); in init_secondary_ports()
3125 if (!slave) { in init_secondary_ports()
3131 if (init_slave(gbe_dev, slave, port)) { in init_secondary_ports()
3135 devm_kfree(dev, slave); in init_secondary_ports()
3140 gbe_sgmii_config(gbe_dev, slave); in init_secondary_ports()
3141 gbe_port_reset(slave); in init_secondary_ports()
3142 gbe_port_config(gbe_dev, slave, gbe_dev->rx_packet_max); in init_secondary_ports()
3143 list_add_tail(&slave->slave_list, &gbe_dev->secondary_slaves); in init_secondary_ports()
3145 if ((slave->link_interface == SGMII_LINK_MAC_PHY) || in init_secondary_ports()
3146 (slave->link_interface == XGMII_LINK_MAC_PHY)) in init_secondary_ports()
3149 slave->open = true; in init_secondary_ports()
3171 if (slave->link_interface == SGMII_LINK_MAC_PHY) { in init_secondary_ports()
3173 slave->phy_port_t = PORT_MII; in init_secondary_ports()
3174 } else if (slave->link_interface == RGMII_LINK_MAC_PHY) { in init_secondary_ports()
3176 slave->phy_port_t = PORT_MII; in init_secondary_ports()
3179 slave->phy_port_t = PORT_FIBRE; in init_secondary_ports()
3182 for_each_sec_slave(slave, gbe_dev) { in init_secondary_ports()
3183 if ((slave->link_interface != SGMII_LINK_MAC_PHY) && in init_secondary_ports()
3184 (slave->link_interface != RGMII_LINK_MAC_PHY) && in init_secondary_ports()
3185 (slave->link_interface != XGMII_LINK_MAC_PHY)) in init_secondary_ports()
3187 slave->phy = in init_secondary_ports()
3189 slave->phy_node, in init_secondary_ports()
3192 if (!slave->phy) { in init_secondary_ports()
3194 slave->slave_num); in init_secondary_ports()
3197 phydev_name(slave->phy)); in init_secondary_ports()
3198 phy_start(slave->phy); in init_secondary_ports()
3205 struct gbe_slave *slave; in free_secondary_ports() local
3208 slave = first_sec_slave(gbe_dev); in free_secondary_ports()
3210 if (slave->phy) in free_secondary_ports()
3211 phy_disconnect(slave->phy); in free_secondary_ports()
3212 list_del(&slave->slave_list); in free_secondary_ports()
3764 gbe_intf->slave = devm_kzalloc(gbe_dev->dev, in gbe_attach()
3765 sizeof(*gbe_intf->slave), in gbe_attach()
3767 if (!gbe_intf->slave) { in gbe_attach()
3772 if (init_slave(gbe_dev, gbe_intf->slave, node)) { in gbe_attach()
3784 if (gbe_intf->slave) in gbe_attach()
3785 devm_kfree(gbe_dev->dev, gbe_intf->slave); in gbe_attach()
3797 devm_kfree(gbe_intf->dev, gbe_intf->slave); in gbe_release()