Lines Matching refs:chip
19 int mv88e6xxx_g2_read(struct mv88e6xxx_chip *chip, int reg, u16 *val) in mv88e6xxx_g2_read() argument
21 return mv88e6xxx_read(chip, chip->info->global2_addr, reg, val); in mv88e6xxx_g2_read()
24 int mv88e6xxx_g2_write(struct mv88e6xxx_chip *chip, int reg, u16 val) in mv88e6xxx_g2_write() argument
26 return mv88e6xxx_write(chip, chip->info->global2_addr, reg, val); in mv88e6xxx_g2_write()
29 int mv88e6xxx_g2_wait_bit(struct mv88e6xxx_chip *chip, int reg, int in mv88e6xxx_g2_wait_bit() argument
32 return mv88e6xxx_wait_bit(chip, chip->info->global2_addr, reg, in mv88e6xxx_g2_wait_bit()
38 static int mv88e6xxx_g2_int_source(struct mv88e6xxx_chip *chip, u16 *src) in mv88e6xxx_g2_int_source() argument
41 return mv88e6xxx_g2_read(chip, MV88E6XXX_G2_INT_SRC, src); in mv88e6xxx_g2_int_source()
46 static int mv88e6xxx_g2_int_mask(struct mv88e6xxx_chip *chip, u16 mask) in mv88e6xxx_g2_int_mask() argument
48 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_INT_MASK, mask); in mv88e6xxx_g2_int_mask()
53 static int mv88e6xxx_g2_mgmt_enable_2x(struct mv88e6xxx_chip *chip, u16 en2x) in mv88e6xxx_g2_mgmt_enable_2x() argument
55 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_MGMT_EN_2X, en2x); in mv88e6xxx_g2_mgmt_enable_2x()
60 static int mv88e6xxx_g2_mgmt_enable_0x(struct mv88e6xxx_chip *chip, u16 en0x) in mv88e6xxx_g2_mgmt_enable_0x() argument
62 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_MGMT_EN_0X, en0x); in mv88e6xxx_g2_mgmt_enable_0x()
67 static int mv88e6xxx_g2_switch_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_switch_mgmt_rsvd2cpu() argument
73 err = mv88e6xxx_g2_read(chip, MV88E6XXX_G2_SWITCH_MGMT, &val); in mv88e6xxx_g2_switch_mgmt_rsvd2cpu()
82 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_SWITCH_MGMT, val); in mv88e6xxx_g2_switch_mgmt_rsvd2cpu()
85 int mv88e6185_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip) in mv88e6185_g2_mgmt_rsvd2cpu() argument
92 err = mv88e6xxx_g2_mgmt_enable_0x(chip, 0xffff); in mv88e6185_g2_mgmt_rsvd2cpu()
96 return mv88e6xxx_g2_switch_mgmt_rsvd2cpu(chip, true); in mv88e6185_g2_mgmt_rsvd2cpu()
99 int mv88e6352_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip) in mv88e6352_g2_mgmt_rsvd2cpu() argument
106 err = mv88e6xxx_g2_mgmt_enable_2x(chip, 0xffff); in mv88e6352_g2_mgmt_rsvd2cpu()
110 return mv88e6185_g2_mgmt_rsvd2cpu(chip); in mv88e6352_g2_mgmt_rsvd2cpu()
115 int mv88e6xxx_g2_device_mapping_write(struct mv88e6xxx_chip *chip, int target, in mv88e6xxx_g2_device_mapping_write() argument
123 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_DEVICE_MAPPING, in mv88e6xxx_g2_device_mapping_write()
129 int mv88e6xxx_g2_trunk_mask_write(struct mv88e6xxx_chip *chip, int num, in mv88e6xxx_g2_trunk_mask_write() argument
132 u16 val = (num << 12) | (mask & mv88e6xxx_port_mask(chip)); in mv88e6xxx_g2_trunk_mask_write()
137 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_TRUNK_MASK, in mv88e6xxx_g2_trunk_mask_write()
143 int mv88e6xxx_g2_trunk_mapping_write(struct mv88e6xxx_chip *chip, int id, in mv88e6xxx_g2_trunk_mapping_write() argument
146 const u16 port_mask = BIT(mv88e6xxx_num_ports(chip)) - 1; in mv88e6xxx_g2_trunk_mapping_write()
149 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_TRUNK_MAPPING, in mv88e6xxx_g2_trunk_mapping_write()
153 int mv88e6xxx_g2_trunk_clear(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_trunk_clear() argument
155 const u16 port_mask = BIT(mv88e6xxx_num_ports(chip)) - 1; in mv88e6xxx_g2_trunk_clear()
160 err = mv88e6xxx_g2_trunk_mask_write(chip, i, false, port_mask); in mv88e6xxx_g2_trunk_clear()
167 err = mv88e6xxx_g2_trunk_mapping_write(chip, i, 0); in mv88e6xxx_g2_trunk_clear()
179 static int mv88e6xxx_g2_irl_wait(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_irl_wait() argument
183 return mv88e6xxx_g2_wait_bit(chip, MV88E6XXX_G2_IRL_CMD, bit, 0); in mv88e6xxx_g2_irl_wait()
186 static int mv88e6xxx_g2_irl_op(struct mv88e6xxx_chip *chip, u16 op, int port, in mv88e6xxx_g2_irl_op() argument
191 err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_IRL_CMD, in mv88e6xxx_g2_irl_op()
197 return mv88e6xxx_g2_irl_wait(chip); in mv88e6xxx_g2_irl_op()
200 int mv88e6352_g2_irl_init_all(struct mv88e6xxx_chip *chip, int port) in mv88e6352_g2_irl_init_all() argument
202 return mv88e6xxx_g2_irl_op(chip, MV88E6352_G2_IRL_CMD_OP_INIT_ALL, port, in mv88e6352_g2_irl_init_all()
206 int mv88e6390_g2_irl_init_all(struct mv88e6xxx_chip *chip, int port) in mv88e6390_g2_irl_init_all() argument
208 return mv88e6xxx_g2_irl_op(chip, MV88E6390_G2_IRL_CMD_OP_INIT_ALL, port, in mv88e6390_g2_irl_init_all()
216 static int mv88e6xxx_g2_pvt_op_wait(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_pvt_op_wait() argument
220 return mv88e6xxx_g2_wait_bit(chip, MV88E6XXX_G2_PVT_ADDR, bit, 0); in mv88e6xxx_g2_pvt_op_wait()
223 static int mv88e6xxx_g2_pvt_op(struct mv88e6xxx_chip *chip, int src_dev, in mv88e6xxx_g2_pvt_op() argument
235 err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_PVT_ADDR, op); in mv88e6xxx_g2_pvt_op()
239 return mv88e6xxx_g2_pvt_op_wait(chip); in mv88e6xxx_g2_pvt_op()
242 int mv88e6xxx_g2_pvt_read(struct mv88e6xxx_chip *chip, int src_dev, in mv88e6xxx_g2_pvt_read() argument
247 err = mv88e6xxx_g2_pvt_op_wait(chip); in mv88e6xxx_g2_pvt_read()
251 err = mv88e6xxx_g2_pvt_op(chip, src_dev, src_port, in mv88e6xxx_g2_pvt_read()
256 return mv88e6xxx_g2_read(chip, MV88E6XXX_G2_PVT_DATA, data); in mv88e6xxx_g2_pvt_read()
259 int mv88e6xxx_g2_pvt_write(struct mv88e6xxx_chip *chip, int src_dev, in mv88e6xxx_g2_pvt_write() argument
264 err = mv88e6xxx_g2_pvt_op_wait(chip); in mv88e6xxx_g2_pvt_write()
268 err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_PVT_DATA, data); in mv88e6xxx_g2_pvt_write()
272 return mv88e6xxx_g2_pvt_op(chip, src_dev, src_port, in mv88e6xxx_g2_pvt_write()
278 static int mv88e6xxx_g2_switch_mac_write(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_switch_mac_write() argument
283 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_SWITCH_MAC, in mv88e6xxx_g2_switch_mac_write()
287 int mv88e6xxx_g2_set_switch_mac(struct mv88e6xxx_chip *chip, u8 *addr) in mv88e6xxx_g2_set_switch_mac() argument
292 err = mv88e6xxx_g2_switch_mac_write(chip, i, addr[i]); in mv88e6xxx_g2_set_switch_mac()
302 int mv88e6xxx_g2_atu_stats_set(struct mv88e6xxx_chip *chip, u16 kind, u16 bin) in mv88e6xxx_g2_atu_stats_set() argument
304 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_ATU_STATS, in mv88e6xxx_g2_atu_stats_set()
308 int mv88e6xxx_g2_atu_stats_get(struct mv88e6xxx_chip *chip, u16 *stats) in mv88e6xxx_g2_atu_stats_get() argument
310 return mv88e6xxx_g2_read(chip, MV88E6XXX_G2_ATU_STATS, stats); in mv88e6xxx_g2_atu_stats_get()
315 static int mv88e6xxx_g2_pot_write(struct mv88e6xxx_chip *chip, int pointer, in mv88e6xxx_g2_pot_write() argument
320 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_PRIO_OVERRIDE, in mv88e6xxx_g2_pot_write()
324 int mv88e6xxx_g2_pot_clear(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_pot_clear() argument
330 err = mv88e6xxx_g2_pot_write(chip, i, 0); in mv88e6xxx_g2_pot_clear()
343 static int mv88e6xxx_g2_eeprom_wait(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_eeprom_wait() argument
348 err = mv88e6xxx_g2_wait_bit(chip, MV88E6XXX_G2_EEPROM_CMD, bit, 0); in mv88e6xxx_g2_eeprom_wait()
354 return mv88e6xxx_g2_wait_bit(chip, MV88E6XXX_G2_EEPROM_CMD, bit, 0); in mv88e6xxx_g2_eeprom_wait()
357 static int mv88e6xxx_g2_eeprom_cmd(struct mv88e6xxx_chip *chip, u16 cmd) in mv88e6xxx_g2_eeprom_cmd() argument
361 err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_EEPROM_CMD, in mv88e6xxx_g2_eeprom_cmd()
366 return mv88e6xxx_g2_eeprom_wait(chip); in mv88e6xxx_g2_eeprom_cmd()
369 static int mv88e6xxx_g2_eeprom_read8(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_eeprom_read8() argument
375 err = mv88e6xxx_g2_eeprom_wait(chip); in mv88e6xxx_g2_eeprom_read8()
379 err = mv88e6xxx_g2_write(chip, MV88E6390_G2_EEPROM_ADDR, addr); in mv88e6xxx_g2_eeprom_read8()
383 err = mv88e6xxx_g2_eeprom_cmd(chip, cmd); in mv88e6xxx_g2_eeprom_read8()
387 err = mv88e6xxx_g2_read(chip, MV88E6XXX_G2_EEPROM_CMD, &cmd); in mv88e6xxx_g2_eeprom_read8()
396 static int mv88e6xxx_g2_eeprom_write8(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_eeprom_write8() argument
403 err = mv88e6xxx_g2_eeprom_wait(chip); in mv88e6xxx_g2_eeprom_write8()
407 err = mv88e6xxx_g2_write(chip, MV88E6390_G2_EEPROM_ADDR, addr); in mv88e6xxx_g2_eeprom_write8()
411 return mv88e6xxx_g2_eeprom_cmd(chip, cmd | data); in mv88e6xxx_g2_eeprom_write8()
414 static int mv88e6xxx_g2_eeprom_read16(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_eeprom_read16() argument
420 err = mv88e6xxx_g2_eeprom_wait(chip); in mv88e6xxx_g2_eeprom_read16()
424 err = mv88e6xxx_g2_eeprom_cmd(chip, cmd); in mv88e6xxx_g2_eeprom_read16()
428 return mv88e6xxx_g2_read(chip, MV88E6352_G2_EEPROM_DATA, data); in mv88e6xxx_g2_eeprom_read16()
431 static int mv88e6xxx_g2_eeprom_write16(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_eeprom_write16() argument
437 err = mv88e6xxx_g2_eeprom_wait(chip); in mv88e6xxx_g2_eeprom_write16()
441 err = mv88e6xxx_g2_write(chip, MV88E6352_G2_EEPROM_DATA, data); in mv88e6xxx_g2_eeprom_write16()
445 return mv88e6xxx_g2_eeprom_cmd(chip, cmd); in mv88e6xxx_g2_eeprom_write16()
448 int mv88e6xxx_g2_get_eeprom8(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_get_eeprom8() argument
458 err = mv88e6xxx_g2_eeprom_read8(chip, offset, data); in mv88e6xxx_g2_get_eeprom8()
471 int mv88e6xxx_g2_set_eeprom8(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_set_eeprom8() argument
481 err = mv88e6xxx_g2_eeprom_write8(chip, offset, *data); in mv88e6xxx_g2_set_eeprom8()
494 int mv88e6xxx_g2_get_eeprom16(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_get_eeprom16() argument
505 err = mv88e6xxx_g2_eeprom_read16(chip, offset >> 1, &val); in mv88e6xxx_g2_get_eeprom16()
517 err = mv88e6xxx_g2_eeprom_read16(chip, offset >> 1, &val); in mv88e6xxx_g2_get_eeprom16()
530 err = mv88e6xxx_g2_eeprom_read16(chip, offset >> 1, &val); in mv88e6xxx_g2_get_eeprom16()
544 int mv88e6xxx_g2_set_eeprom16(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_set_eeprom16() argument
553 err = mv88e6xxx_g2_read(chip, MV88E6XXX_G2_EEPROM_CMD, &val); in mv88e6xxx_g2_set_eeprom16()
563 err = mv88e6xxx_g2_eeprom_read16(chip, offset >> 1, &val); in mv88e6xxx_g2_set_eeprom16()
569 err = mv88e6xxx_g2_eeprom_write16(chip, offset >> 1, val); in mv88e6xxx_g2_set_eeprom16()
582 err = mv88e6xxx_g2_eeprom_write16(chip, offset >> 1, val); in mv88e6xxx_g2_set_eeprom16()
592 err = mv88e6xxx_g2_eeprom_read16(chip, offset >> 1, &val); in mv88e6xxx_g2_set_eeprom16()
598 err = mv88e6xxx_g2_eeprom_write16(chip, offset >> 1, val); in mv88e6xxx_g2_set_eeprom16()
614 static int mv88e6xxx_g2_smi_phy_wait(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_smi_phy_wait() argument
618 return mv88e6xxx_g2_wait_bit(chip, MV88E6XXX_G2_SMI_PHY_CMD, bit, 0); in mv88e6xxx_g2_smi_phy_wait()
621 static int mv88e6xxx_g2_smi_phy_cmd(struct mv88e6xxx_chip *chip, u16 cmd) in mv88e6xxx_g2_smi_phy_cmd() argument
625 err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_SMI_PHY_CMD, in mv88e6xxx_g2_smi_phy_cmd()
630 return mv88e6xxx_g2_smi_phy_wait(chip); in mv88e6xxx_g2_smi_phy_cmd()
633 static int mv88e6xxx_g2_smi_phy_access(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_access() argument
653 return mv88e6xxx_g2_smi_phy_cmd(chip, cmd); in mv88e6xxx_g2_smi_phy_access()
656 static int mv88e6xxx_g2_smi_phy_access_c22(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_access_c22() argument
660 return mv88e6xxx_g2_smi_phy_access(chip, external, false, op, dev, reg); in mv88e6xxx_g2_smi_phy_access_c22()
664 static int mv88e6xxx_g2_smi_phy_read_data_c22(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_read_data_c22() argument
671 err = mv88e6xxx_g2_smi_phy_wait(chip); in mv88e6xxx_g2_smi_phy_read_data_c22()
675 err = mv88e6xxx_g2_smi_phy_access_c22(chip, external, op, dev, reg); in mv88e6xxx_g2_smi_phy_read_data_c22()
679 return mv88e6xxx_g2_read(chip, MV88E6XXX_G2_SMI_PHY_DATA, data); in mv88e6xxx_g2_smi_phy_read_data_c22()
683 static int mv88e6xxx_g2_smi_phy_write_data_c22(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_write_data_c22() argument
690 err = mv88e6xxx_g2_smi_phy_wait(chip); in mv88e6xxx_g2_smi_phy_write_data_c22()
694 err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_SMI_PHY_DATA, data); in mv88e6xxx_g2_smi_phy_write_data_c22()
698 return mv88e6xxx_g2_smi_phy_access_c22(chip, external, op, dev, reg); in mv88e6xxx_g2_smi_phy_write_data_c22()
701 static int mv88e6xxx_g2_smi_phy_access_c45(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_access_c45() argument
705 return mv88e6xxx_g2_smi_phy_access(chip, external, true, op, port, dev); in mv88e6xxx_g2_smi_phy_access_c45()
709 static int mv88e6xxx_g2_smi_phy_write_addr_c45(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_write_addr_c45() argument
716 err = mv88e6xxx_g2_smi_phy_wait(chip); in mv88e6xxx_g2_smi_phy_write_addr_c45()
720 err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_SMI_PHY_DATA, addr); in mv88e6xxx_g2_smi_phy_write_addr_c45()
724 return mv88e6xxx_g2_smi_phy_access_c45(chip, external, op, port, dev); in mv88e6xxx_g2_smi_phy_write_addr_c45()
728 static int mv88e6xxx_g2_smi_phy_read_data_c45(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_read_data_c45() argument
735 err = mv88e6xxx_g2_smi_phy_access_c45(chip, external, op, port, dev); in mv88e6xxx_g2_smi_phy_read_data_c45()
739 return mv88e6xxx_g2_read(chip, MV88E6XXX_G2_SMI_PHY_DATA, data); in mv88e6xxx_g2_smi_phy_read_data_c45()
742 static int mv88e6xxx_g2_smi_phy_read_c45(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_read_c45() argument
750 err = mv88e6xxx_g2_smi_phy_write_addr_c45(chip, external, port, dev, in mv88e6xxx_g2_smi_phy_read_c45()
755 return mv88e6xxx_g2_smi_phy_read_data_c45(chip, external, port, dev, in mv88e6xxx_g2_smi_phy_read_c45()
760 static int mv88e6xxx_g2_smi_phy_write_data_c45(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_write_data_c45() argument
767 err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_SMI_PHY_DATA, data); in mv88e6xxx_g2_smi_phy_write_data_c45()
771 return mv88e6xxx_g2_smi_phy_access_c45(chip, external, op, port, dev); in mv88e6xxx_g2_smi_phy_write_data_c45()
774 static int mv88e6xxx_g2_smi_phy_write_c45(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_smi_phy_write_c45() argument
782 err = mv88e6xxx_g2_smi_phy_write_addr_c45(chip, external, port, dev, in mv88e6xxx_g2_smi_phy_write_c45()
787 return mv88e6xxx_g2_smi_phy_write_data_c45(chip, external, port, dev, in mv88e6xxx_g2_smi_phy_write_c45()
791 int mv88e6xxx_g2_smi_phy_read(struct mv88e6xxx_chip *chip, struct mii_bus *bus, in mv88e6xxx_g2_smi_phy_read() argument
798 return mv88e6xxx_g2_smi_phy_read_c45(chip, external, addr, reg, in mv88e6xxx_g2_smi_phy_read()
801 return mv88e6xxx_g2_smi_phy_read_data_c22(chip, external, addr, reg, in mv88e6xxx_g2_smi_phy_read()
805 int mv88e6xxx_g2_smi_phy_write(struct mv88e6xxx_chip *chip, struct mii_bus *bus, in mv88e6xxx_g2_smi_phy_write() argument
812 return mv88e6xxx_g2_smi_phy_write_c45(chip, external, addr, reg, in mv88e6xxx_g2_smi_phy_write()
815 return mv88e6xxx_g2_smi_phy_write_data_c22(chip, external, addr, reg, in mv88e6xxx_g2_smi_phy_write()
820 static int mv88e6097_watchdog_action(struct mv88e6xxx_chip *chip, int irq) in mv88e6097_watchdog_action() argument
824 mv88e6xxx_g2_read(chip, MV88E6352_G2_WDOG_CTL, ®); in mv88e6097_watchdog_action()
826 dev_info(chip->dev, "Watchdog event: 0x%04x", reg); in mv88e6097_watchdog_action()
831 static void mv88e6097_watchdog_free(struct mv88e6xxx_chip *chip) in mv88e6097_watchdog_free() argument
835 mv88e6xxx_g2_read(chip, MV88E6352_G2_WDOG_CTL, ®); in mv88e6097_watchdog_free()
840 mv88e6xxx_g2_write(chip, MV88E6352_G2_WDOG_CTL, reg); in mv88e6097_watchdog_free()
843 static int mv88e6097_watchdog_setup(struct mv88e6xxx_chip *chip) in mv88e6097_watchdog_setup() argument
845 return mv88e6xxx_g2_write(chip, MV88E6352_G2_WDOG_CTL, in mv88e6097_watchdog_setup()
857 static void mv88e6250_watchdog_free(struct mv88e6xxx_chip *chip) in mv88e6250_watchdog_free() argument
861 mv88e6xxx_g2_read(chip, MV88E6250_G2_WDOG_CTL, ®); in mv88e6250_watchdog_free()
866 mv88e6xxx_g2_write(chip, MV88E6250_G2_WDOG_CTL, reg); in mv88e6250_watchdog_free()
869 static int mv88e6250_watchdog_setup(struct mv88e6xxx_chip *chip) in mv88e6250_watchdog_setup() argument
871 return mv88e6xxx_g2_write(chip, MV88E6250_G2_WDOG_CTL, in mv88e6250_watchdog_setup()
883 static int mv88e6390_watchdog_setup(struct mv88e6xxx_chip *chip) in mv88e6390_watchdog_setup() argument
885 return mv88e6xxx_g2_write(chip, MV88E6390_G2_WDOG_CTL, in mv88e6390_watchdog_setup()
894 static int mv88e6390_watchdog_action(struct mv88e6xxx_chip *chip, int irq) in mv88e6390_watchdog_action() argument
898 mv88e6xxx_g2_write(chip, MV88E6390_G2_WDOG_CTL, in mv88e6390_watchdog_action()
900 mv88e6xxx_g2_read(chip, MV88E6390_G2_WDOG_CTL, ®); in mv88e6390_watchdog_action()
902 dev_info(chip->dev, "Watchdog event: 0x%04x", in mv88e6390_watchdog_action()
905 mv88e6xxx_g2_write(chip, MV88E6390_G2_WDOG_CTL, in mv88e6390_watchdog_action()
907 mv88e6xxx_g2_read(chip, MV88E6390_G2_WDOG_CTL, ®); in mv88e6390_watchdog_action()
909 dev_info(chip->dev, "Watchdog history: 0x%04x", in mv88e6390_watchdog_action()
913 if (chip->info->ops->reset) in mv88e6390_watchdog_action()
914 chip->info->ops->reset(chip); in mv88e6390_watchdog_action()
916 mv88e6390_watchdog_setup(chip); in mv88e6390_watchdog_action()
921 static void mv88e6390_watchdog_free(struct mv88e6xxx_chip *chip) in mv88e6390_watchdog_free() argument
923 mv88e6xxx_g2_write(chip, MV88E6390_G2_WDOG_CTL, in mv88e6390_watchdog_free()
936 struct mv88e6xxx_chip *chip = dev_id; in mv88e6xxx_g2_watchdog_thread_fn() local
939 mv88e6xxx_reg_lock(chip); in mv88e6xxx_g2_watchdog_thread_fn()
940 if (chip->info->ops->watchdog_ops->irq_action) in mv88e6xxx_g2_watchdog_thread_fn()
941 ret = chip->info->ops->watchdog_ops->irq_action(chip, irq); in mv88e6xxx_g2_watchdog_thread_fn()
942 mv88e6xxx_reg_unlock(chip); in mv88e6xxx_g2_watchdog_thread_fn()
947 static void mv88e6xxx_g2_watchdog_free(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_watchdog_free() argument
949 mv88e6xxx_reg_lock(chip); in mv88e6xxx_g2_watchdog_free()
950 if (chip->info->ops->watchdog_ops->irq_free) in mv88e6xxx_g2_watchdog_free()
951 chip->info->ops->watchdog_ops->irq_free(chip); in mv88e6xxx_g2_watchdog_free()
952 mv88e6xxx_reg_unlock(chip); in mv88e6xxx_g2_watchdog_free()
954 free_irq(chip->watchdog_irq, chip); in mv88e6xxx_g2_watchdog_free()
955 irq_dispose_mapping(chip->watchdog_irq); in mv88e6xxx_g2_watchdog_free()
958 static int mv88e6xxx_g2_watchdog_setup(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_watchdog_setup() argument
962 chip->watchdog_irq = irq_find_mapping(chip->g2_irq.domain, in mv88e6xxx_g2_watchdog_setup()
964 if (chip->watchdog_irq < 0) in mv88e6xxx_g2_watchdog_setup()
965 return chip->watchdog_irq; in mv88e6xxx_g2_watchdog_setup()
967 snprintf(chip->watchdog_irq_name, sizeof(chip->watchdog_irq_name), in mv88e6xxx_g2_watchdog_setup()
968 "mv88e6xxx-%s-watchdog", dev_name(chip->dev)); in mv88e6xxx_g2_watchdog_setup()
970 err = request_threaded_irq(chip->watchdog_irq, NULL, in mv88e6xxx_g2_watchdog_setup()
973 chip->watchdog_irq_name, chip); in mv88e6xxx_g2_watchdog_setup()
977 mv88e6xxx_reg_lock(chip); in mv88e6xxx_g2_watchdog_setup()
978 if (chip->info->ops->watchdog_ops->irq_setup) in mv88e6xxx_g2_watchdog_setup()
979 err = chip->info->ops->watchdog_ops->irq_setup(chip); in mv88e6xxx_g2_watchdog_setup()
980 mv88e6xxx_reg_unlock(chip); in mv88e6xxx_g2_watchdog_setup()
987 static int mv88e6xxx_g2_misc_5_bit_port(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_misc_5_bit_port() argument
993 err = mv88e6xxx_g2_read(chip, MV88E6XXX_G2_MISC, &val); in mv88e6xxx_g2_misc_5_bit_port()
1002 return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_MISC, val); in mv88e6xxx_g2_misc_5_bit_port()
1005 int mv88e6xxx_g2_misc_4_bit_port(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_misc_4_bit_port() argument
1007 return mv88e6xxx_g2_misc_5_bit_port(chip, false); in mv88e6xxx_g2_misc_4_bit_port()
1012 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); in mv88e6xxx_g2_irq_mask() local
1015 chip->g2_irq.masked |= (1 << n); in mv88e6xxx_g2_irq_mask()
1020 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); in mv88e6xxx_g2_irq_unmask() local
1023 chip->g2_irq.masked &= ~(1 << n); in mv88e6xxx_g2_irq_unmask()
1028 struct mv88e6xxx_chip *chip = dev_id; in mv88e6xxx_g2_irq_thread_fn() local
1035 mv88e6xxx_reg_lock(chip); in mv88e6xxx_g2_irq_thread_fn()
1036 err = mv88e6xxx_g2_int_source(chip, ®); in mv88e6xxx_g2_irq_thread_fn()
1037 mv88e6xxx_reg_unlock(chip); in mv88e6xxx_g2_irq_thread_fn()
1043 sub_irq = irq_find_mapping(chip->g2_irq.domain, n); in mv88e6xxx_g2_irq_thread_fn()
1054 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); in mv88e6xxx_g2_irq_bus_lock() local
1056 mv88e6xxx_reg_lock(chip); in mv88e6xxx_g2_irq_bus_lock()
1061 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); in mv88e6xxx_g2_irq_bus_sync_unlock() local
1064 err = mv88e6xxx_g2_int_mask(chip, ~chip->g2_irq.masked); in mv88e6xxx_g2_irq_bus_sync_unlock()
1066 dev_err(chip->dev, "failed to mask interrupts\n"); in mv88e6xxx_g2_irq_bus_sync_unlock()
1068 mv88e6xxx_reg_unlock(chip); in mv88e6xxx_g2_irq_bus_sync_unlock()
1083 struct mv88e6xxx_chip *chip = d->host_data; in mv88e6xxx_g2_irq_domain_map() local
1086 irq_set_chip_and_handler(irq, &chip->g2_irq.chip, handle_level_irq); in mv88e6xxx_g2_irq_domain_map()
1097 void mv88e6xxx_g2_irq_free(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_irq_free() argument
1101 mv88e6xxx_g2_watchdog_free(chip); in mv88e6xxx_g2_irq_free()
1103 free_irq(chip->device_irq, chip); in mv88e6xxx_g2_irq_free()
1104 irq_dispose_mapping(chip->device_irq); in mv88e6xxx_g2_irq_free()
1107 virq = irq_find_mapping(chip->g2_irq.domain, irq); in mv88e6xxx_g2_irq_free()
1111 irq_domain_remove(chip->g2_irq.domain); in mv88e6xxx_g2_irq_free()
1114 int mv88e6xxx_g2_irq_setup(struct mv88e6xxx_chip *chip) in mv88e6xxx_g2_irq_setup() argument
1118 chip->g2_irq.masked = ~0; in mv88e6xxx_g2_irq_setup()
1119 mv88e6xxx_reg_lock(chip); in mv88e6xxx_g2_irq_setup()
1120 err = mv88e6xxx_g2_int_mask(chip, ~chip->g2_irq.masked); in mv88e6xxx_g2_irq_setup()
1121 mv88e6xxx_reg_unlock(chip); in mv88e6xxx_g2_irq_setup()
1125 chip->g2_irq.domain = irq_domain_add_simple( in mv88e6xxx_g2_irq_setup()
1126 chip->dev->of_node, 16, 0, &mv88e6xxx_g2_irq_domain_ops, chip); in mv88e6xxx_g2_irq_setup()
1127 if (!chip->g2_irq.domain) in mv88e6xxx_g2_irq_setup()
1131 irq_create_mapping(chip->g2_irq.domain, irq); in mv88e6xxx_g2_irq_setup()
1133 chip->g2_irq.chip = mv88e6xxx_g2_irq_chip; in mv88e6xxx_g2_irq_setup()
1135 chip->device_irq = irq_find_mapping(chip->g1_irq.domain, in mv88e6xxx_g2_irq_setup()
1137 if (chip->device_irq < 0) { in mv88e6xxx_g2_irq_setup()
1138 err = chip->device_irq; in mv88e6xxx_g2_irq_setup()
1142 snprintf(chip->device_irq_name, sizeof(chip->device_irq_name), in mv88e6xxx_g2_irq_setup()
1143 "mv88e6xxx-%s-g2", dev_name(chip->dev)); in mv88e6xxx_g2_irq_setup()
1145 err = request_threaded_irq(chip->device_irq, NULL, in mv88e6xxx_g2_irq_setup()
1147 IRQF_ONESHOT, chip->device_irq_name, chip); in mv88e6xxx_g2_irq_setup()
1151 return mv88e6xxx_g2_watchdog_setup(chip); in mv88e6xxx_g2_irq_setup()
1155 virq = irq_find_mapping(chip->g2_irq.domain, irq); in mv88e6xxx_g2_irq_setup()
1159 irq_domain_remove(chip->g2_irq.domain); in mv88e6xxx_g2_irq_setup()
1164 int mv88e6xxx_g2_irq_mdio_setup(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_irq_mdio_setup() argument
1169 for (phy = 0; phy < chip->info->num_internal_phys; phy++) { in mv88e6xxx_g2_irq_mdio_setup()
1170 irq = irq_find_mapping(chip->g2_irq.domain, phy); in mv88e6xxx_g2_irq_mdio_setup()
1175 bus->irq[chip->info->phy_base_addr + phy] = irq; in mv88e6xxx_g2_irq_mdio_setup()
1187 void mv88e6xxx_g2_irq_mdio_free(struct mv88e6xxx_chip *chip, in mv88e6xxx_g2_irq_mdio_free() argument
1192 for (phy = 0; phy < chip->info->num_internal_phys; phy++) in mv88e6xxx_g2_irq_mdio_free()