Lines Matching +full:xbar +full:- +full:cfg

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2014-2015 Hisilicon Limited.
35 if (dsaf_dev->sub_ctrl) in dsaf_write_sub()
36 dsaf_write_syscon(dsaf_dev->sub_ctrl, reg, val); in dsaf_write_sub()
38 dsaf_write_reg(dsaf_dev->sc_base, reg, val); in dsaf_write_sub()
46 if (dsaf_dev->sub_ctrl) { in dsaf_read_sub()
47 err = dsaf_read_syscon(dsaf_dev->sub_ctrl, reg, &ret); in dsaf_read_sub()
49 dev_err(dsaf_dev->dev, "dsaf_read_syscon error %d!\n", in dsaf_read_sub()
52 ret = dsaf_read_reg(dsaf_dev->sc_base, reg); in dsaf_read_sub()
75 obj = acpi_evaluate_dsm(ACPI_HANDLE(mac_cb->dev), in hns_dsaf_acpi_ledctrl_by_port()
78 dev_warn(mac_cb->dev, "ledctrl fail, link:%d port:%d act:%d!\n", in hns_dsaf_acpi_ledctrl_by_port()
102 obj = acpi_evaluate_dsm(ACPI_HANDLE(mac_cb->dev), in hns_dsaf_acpi_locate_ledctrl_by_port()
105 dev_err(mac_cb->dev, "ledctrl fail, locate:%d port:%d!\n", in hns_dsaf_acpi_locate_ledctrl_by_port()
123 if (!mac_cb->cpld_ctrl) { in hns_cpld_set_led()
124 dev_err(mac_cb->dev, "mac_id=%d, cpld syscon is null !\n", in hns_cpld_set_led()
125 mac_cb->mac_id); in hns_cpld_set_led()
132 value = mac_cb->cpld_led_value; in hns_cpld_set_led()
140 if (value != mac_cb->cpld_led_value) { in hns_cpld_set_led()
141 dsaf_write_syscon(mac_cb->cpld_ctrl, in hns_cpld_set_led()
142 mac_cb->cpld_ctrl_reg, value); in hns_cpld_set_led()
143 mac_cb->cpld_led_value = value; in hns_cpld_set_led()
146 value = (mac_cb->cpld_led_value) & (0x1 << DSAF_LED_ANCHOR_B); in hns_cpld_set_led()
147 dsaf_write_syscon(mac_cb->cpld_ctrl, in hns_cpld_set_led()
148 mac_cb->cpld_ctrl_reg, value); in hns_cpld_set_led()
149 mac_cb->cpld_led_value = value; in hns_cpld_set_led()
162 link_status, mac_cb->mac_id, data); in hns_cpld_set_led_acpi()
167 if (!mac_cb || !mac_cb->cpld_ctrl) in cpld_led_reset()
170 dsaf_write_syscon(mac_cb->cpld_ctrl, mac_cb->cpld_ctrl_reg, in cpld_led_reset()
172 mac_cb->cpld_led_value = CPLD_LED_DEFAULT_VALUE; in cpld_led_reset()
182 if (mac_cb->media_type != HNAE_MEDIA_TYPE_FIBER) in cpld_led_reset_acpi()
186 0, mac_cb->mac_id, 0); in cpld_led_reset_acpi()
195 if (!mac_cb->cpld_ctrl) in cpld_set_led_id()
200 ret = dsaf_read_syscon(mac_cb->cpld_ctrl, mac_cb->cpld_ctrl_reg, in cpld_set_led_id()
206 dsaf_write_syscon(mac_cb->cpld_ctrl, mac_cb->cpld_ctrl_reg, in cpld_set_led_id()
208 mac_cb->cpld_led_value = val; in cpld_set_led_id()
211 dsaf_set_bit(mac_cb->cpld_led_value, DSAF_LED_ANCHOR_B, in cpld_set_led_id()
213 dsaf_write_syscon(mac_cb->cpld_ctrl, mac_cb->cpld_ctrl_reg, in cpld_set_led_id()
214 mac_cb->cpld_led_value); in cpld_set_led_id()
217 dev_err(mac_cb->dev, "invalid led state: %d!", status); in cpld_set_led_id()
218 return -EINVAL; in cpld_set_led_id()
232 mac_cb->mac_id); in cpld_set_led_id_acpi()
238 mac_cb->mac_id); in cpld_set_led_id_acpi()
241 dev_err(mac_cb->dev, "invalid led state: %d!", status); in cpld_set_led_id_acpi()
242 return -EINVAL; in cpld_set_led_id_acpi()
267 obj = acpi_evaluate_dsm(ACPI_HANDLE(dsaf_dev->dev), in hns_dsaf_acpi_srst_by_port()
270 dev_warn(dsaf_dev->dev, "reset port_type%d port%d fail!", in hns_dsaf_acpi_srst_by_port()
312 reg_val |= 0x2082082 << dsaf_dev->mac_cb[port]->port_rst_off; in hns_dsaf_xge_srst_by_port()
330 * hns_dsaf_srst_chns - reset dsaf channels
332 * @msk: xbar channels mask value:
333 * @dereset: false - request reset , true - drop reset
335 * bit0-5 for xge0-5
336 * bit6-11 for ppe0-5
337 * bit12-17 for roce0-5
338 * bit18-19 for com/dfx
354 * hns_dsaf_srst_chns_acpi - reset dsaf channels
356 * @msk: xbar channels mask value:
357 * @dereset: false - request reset , true - drop reset
359 * bit0-5 for xge0-5
360 * bit6-11 for ppe0-5
361 * bit12-17 for roce0-5
362 * bit18-19 for com/dfx
408 port_rst_off = dsaf_dev->mac_cb[port]->port_rst_off; in hns_dsaf_ge_srst_by_port()
410 reg_val_2 = AE_IS_VER1(dsaf_dev->dsaf_ver) ? in hns_dsaf_ge_srst_by_port()
429 reg_val_2 = AE_IS_VER1(dsaf_dev->dsaf_ver) ? 0x100 : 0x40; in hns_dsaf_ge_srst_by_port()
431 reg_val_1 <<= dsaf_dev->reset_offset; in hns_dsaf_ge_srst_by_port()
432 reg_val_2 <<= dsaf_dev->reset_offset; in hns_dsaf_ge_srst_by_port()
463 reg_val |= RESET_REQ_OR_DREQ << dsaf_dev->mac_cb[port]->port_rst_off; in hns_ppe_srst_by_port()
485 if (!(dev_of_node(dsaf_dev->dev))) in hns_ppe_com_srst()
496 reg_val = 0x100 << dsaf_dev->reset_offset; in hns_ppe_com_srst()
508 * hns_mac_get_phy_if - get phy ifterface form serdes mode
516 bool is_ver1 = AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver); in hns_mac_get_phy_if()
517 int mac_id = mac_cb->mac_id; in hns_mac_get_phy_if()
521 if (HNS_DSAF_IS_DEBUG(mac_cb->dsaf_dev)) in hns_mac_get_phy_if()
529 if (!HNS_DSAF_IS_DEBUG(mac_cb->dsaf_dev) && mac_id <= 3) in hns_mac_get_phy_if()
535 mode = dsaf_read_sub(mac_cb->dsaf_dev, reg); in hns_mac_get_phy_if()
536 if (dsaf_get_bit(mode, mac_cb->port_mode_off)) in hns_mac_get_phy_if()
551 obj_args.integer.value = mac_cb->mac_id; in hns_mac_get_phy_if_acpi()
557 obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(mac_cb->dev), in hns_mac_get_phy_if_acpi()
564 phy_if = obj->integer.value ? in hns_mac_get_phy_if_acpi()
567 dev_dbg(mac_cb->dev, "mac_id=%d, phy_if=%d\n", mac_cb->mac_id, phy_if); in hns_mac_get_phy_if_acpi()
579 if (!mac_cb->cpld_ctrl) in hns_mac_get_sfp_prsnt()
580 return -ENODEV; in hns_mac_get_sfp_prsnt()
582 ret = dsaf_read_syscon(mac_cb->cpld_ctrl, in hns_mac_get_sfp_prsnt()
583 mac_cb->cpld_ctrl_reg + MAC_SFP_PORT_OFFSET, in hns_mac_get_sfp_prsnt()
598 obj_args.integer.value = mac_cb->mac_id; in hns_mac_get_sfp_prsnt_acpi()
604 obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(mac_cb->dev), in hns_mac_get_sfp_prsnt_acpi()
609 return -ENODEV; in hns_mac_get_sfp_prsnt_acpi()
611 *sfp_prsnt = obj->integer.value; in hns_mac_get_sfp_prsnt_acpi()
619 * hns_mac_config_sds_loopback - set loop back for serdes
627 0, /* mac 0 -> lane 0 */ in hns_mac_config_sds_loopback()
628 1, /* mac 1 -> lane 1 */ in hns_mac_config_sds_loopback()
629 2, /* mac 2 -> lane 2 */ in hns_mac_config_sds_loopback()
630 3, /* mac 3 -> lane 3 */ in hns_mac_config_sds_loopback()
631 2, /* mac 4 -> lane 2 */ in hns_mac_config_sds_loopback()
632 3, /* mac 5 -> lane 3 */ in hns_mac_config_sds_loopback()
633 0, /* mac 6 -> lane 0 */ in hns_mac_config_sds_loopback()
634 1 /* mac 7 -> lane 1 */ in hns_mac_config_sds_loopback()
637 u64 reg_offset = RX_CSR(lane_id[mac_cb->mac_id], 0); in hns_mac_config_sds_loopback()
642 if (!mac_cb->phy_dev) { in hns_mac_config_sds_loopback()
650 if (mac_cb->serdes_ctrl) { in hns_mac_config_sds_loopback()
653 if (!AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver)) { in hns_mac_config_sds_loopback()
656 * xge u adaptor. There is a hilink access sel cfg in hns_mac_config_sds_loopback()
659 if ((!HNS_DSAF_IS_DEBUG(mac_cb->dsaf_dev)) && in hns_mac_config_sds_loopback()
660 (mac_cb->mac_id <= 3)) in hns_mac_config_sds_loopback()
661 dsaf_write_syscon(mac_cb->serdes_ctrl, in hns_mac_config_sds_loopback()
664 dsaf_write_syscon(mac_cb->serdes_ctrl, in hns_mac_config_sds_loopback()
668 ret = dsaf_read_syscon(mac_cb->serdes_ctrl, reg_offset, in hns_mac_config_sds_loopback()
674 dsaf_write_syscon(mac_cb->serdes_ctrl, reg_offset, origin); in hns_mac_config_sds_loopback()
676 u8 __iomem *base_addr = mac_cb->serdes_vaddr + in hns_mac_config_sds_loopback()
677 (mac_cb->mac_id <= 3 ? 0x00280000 : 0x00200000); in hns_mac_config_sds_loopback()
691 obj_args[0].integer.value = mac_cb->mac_id; in hns_mac_config_sds_loopback_acpi()
699 obj = acpi_evaluate_dsm(ACPI_HANDLE(mac_cb->dsaf_dev->dev), in hns_mac_config_sds_loopback_acpi()
703 dev_warn(mac_cb->dsaf_dev->dev, "set port%d serdes lp fail!", in hns_mac_config_sds_loopback_acpi()
704 mac_cb->mac_id); in hns_mac_config_sds_loopback_acpi()
706 return -ENOTSUPP; in hns_mac_config_sds_loopback_acpi()
718 misc_op = devm_kzalloc(dsaf_dev->dev, sizeof(*misc_op), GFP_KERNEL); in hns_misc_op_get()
722 if (dev_of_node(dsaf_dev->dev)) { in hns_misc_op_get()
723 misc_op->cpld_set_led = hns_cpld_set_led; in hns_misc_op_get()
724 misc_op->cpld_reset_led = cpld_led_reset; in hns_misc_op_get()
725 misc_op->cpld_set_led_id = cpld_set_led_id; in hns_misc_op_get()
727 misc_op->dsaf_reset = hns_dsaf_rst; in hns_misc_op_get()
728 misc_op->xge_srst = hns_dsaf_xge_srst_by_port; in hns_misc_op_get()
729 misc_op->ge_srst = hns_dsaf_ge_srst_by_port; in hns_misc_op_get()
730 misc_op->ppe_srst = hns_ppe_srst_by_port; in hns_misc_op_get()
731 misc_op->ppe_comm_srst = hns_ppe_com_srst; in hns_misc_op_get()
732 misc_op->hns_dsaf_srst_chns = hns_dsaf_srst_chns; in hns_misc_op_get()
733 misc_op->hns_dsaf_roce_srst = hns_dsaf_roce_srst; in hns_misc_op_get()
735 misc_op->get_phy_if = hns_mac_get_phy_if; in hns_misc_op_get()
736 misc_op->get_sfp_prsnt = hns_mac_get_sfp_prsnt; in hns_misc_op_get()
738 misc_op->cfg_serdes_loopback = hns_mac_config_sds_loopback; in hns_misc_op_get()
739 } else if (is_acpi_node(dsaf_dev->dev->fwnode)) { in hns_misc_op_get()
740 misc_op->cpld_set_led = hns_cpld_set_led_acpi; in hns_misc_op_get()
741 misc_op->cpld_reset_led = cpld_led_reset_acpi; in hns_misc_op_get()
742 misc_op->cpld_set_led_id = cpld_set_led_id_acpi; in hns_misc_op_get()
744 misc_op->dsaf_reset = hns_dsaf_rst_acpi; in hns_misc_op_get()
745 misc_op->xge_srst = hns_dsaf_xge_srst_by_port_acpi; in hns_misc_op_get()
746 misc_op->ge_srst = hns_dsaf_ge_srst_by_port_acpi; in hns_misc_op_get()
747 misc_op->ppe_srst = hns_ppe_srst_by_port_acpi; in hns_misc_op_get()
748 misc_op->ppe_comm_srst = hns_ppe_com_srst; in hns_misc_op_get()
749 misc_op->hns_dsaf_srst_chns = hns_dsaf_srst_chns_acpi; in hns_misc_op_get()
750 misc_op->hns_dsaf_roce_srst = hns_dsaf_roce_srst_acpi; in hns_misc_op_get()
752 misc_op->get_phy_if = hns_mac_get_phy_if_acpi; in hns_misc_op_get()
753 misc_op->get_sfp_prsnt = hns_mac_get_sfp_prsnt_acpi; in hns_misc_op_get()
755 misc_op->cfg_serdes_loopback = hns_mac_config_sds_loopback_acpi; in hns_misc_op_get()
757 devm_kfree(dsaf_dev->dev, (void *)misc_op); in hns_misc_op_get()