Lines Matching +full:quad +full:- +full:channel

1 // SPDX-License-Identifier: GPL-2.0+
2 /* Broadcom BCM54140 Quad SGMII/QSGMII Copper/Fiber Gigabit PHY
13 #include "bcm-phy-lib.h"
15 /* RDB per-port registers
60 #define BCM54140_RDB_MON_CTRL_SEL_RR 3 /* meassure all round-robin */
61 #define BCM54140_RDB_MON_CTRL_PWR_DOWN BIT(0) /* power-down monitor */
80 * T = 413.35 - (0.49055 * bits[9:0])
82 #define BCM54140_HWMON_TO_TEMP(v) (413350L - (v) * 491)
83 #define BCM54140_HWMON_FROM_TEMP(v) DIV_ROUND_CLOSEST_ULL(413350L - (v), 491)
144 u32 attr, int channel) in bcm54140_hwmon_is_visible() argument
179 struct bcm54140_priv *priv = phydev->priv; in bcm54140_hwmon_read_alarm()
182 mutex_lock(&priv->alarm_lock); in bcm54140_hwmon_read_alarm()
190 priv->alarm |= tmp; in bcm54140_hwmon_read_alarm()
192 *val = !!(priv->alarm & bit); in bcm54140_hwmon_read_alarm()
193 priv->alarm &= ~bit; in bcm54140_hwmon_read_alarm()
196 mutex_unlock(&priv->alarm_lock); in bcm54140_hwmon_read_alarm()
221 return -EOPNOTSUPP; in bcm54140_hwmon_read_temp()
234 int channel, long *val) in bcm54140_hwmon_read_in() argument
242 reg = BCM54140_HWMON_IN_VAL_REG(channel); in bcm54140_hwmon_read_in()
245 reg = BCM54140_HWMON_IN_MIN_REG(channel); in bcm54140_hwmon_read_in()
248 reg = BCM54140_HWMON_IN_MAX_REG(channel); in bcm54140_hwmon_read_in()
251 bit = BCM54140_HWMON_IN_ALARM_BIT(channel); in bcm54140_hwmon_read_in()
254 return -EOPNOTSUPP; in bcm54140_hwmon_read_in()
261 tmp &= BCM54140_HWMON_IN_MASK(channel); in bcm54140_hwmon_read_in()
262 *val = BCM54140_HWMON_TO_IN(channel, tmp); in bcm54140_hwmon_read_in()
269 int channel, long *val) in bcm54140_hwmon_read() argument
275 return bcm54140_hwmon_read_in(dev, attr, channel, val); in bcm54140_hwmon_read()
277 return -EOPNOTSUPP; in bcm54140_hwmon_read()
288 int channel, const char **str) in bcm54140_hwmon_read_string() argument
294 *str = bcm54140_hwmon_in_labels[channel]; in bcm54140_hwmon_read_string()
297 return -EOPNOTSUPP; in bcm54140_hwmon_read_string()
300 return -EOPNOTSUPP; in bcm54140_hwmon_read_string()
305 int channel, long val) in bcm54140_hwmon_write_temp() argument
322 return -EOPNOTSUPP; in bcm54140_hwmon_write_temp()
330 int channel, long val) in bcm54140_hwmon_write_in() argument
333 u16 mask = BCM54140_HWMON_IN_MASK(channel); in bcm54140_hwmon_write_in()
336 val = clamp_val(val, 0, BCM54140_HWMON_TO_IN(channel, mask)); in bcm54140_hwmon_write_in()
340 reg = BCM54140_HWMON_IN_MIN_REG(channel); in bcm54140_hwmon_write_in()
343 reg = BCM54140_HWMON_IN_MAX_REG(channel); in bcm54140_hwmon_write_in()
346 return -EOPNOTSUPP; in bcm54140_hwmon_write_in()
350 BCM54140_HWMON_FROM_IN(channel, val)); in bcm54140_hwmon_write_in()
355 int channel, long val) in bcm54140_hwmon_write() argument
359 return bcm54140_hwmon_write_temp(dev, attr, channel, val); in bcm54140_hwmon_write()
361 return bcm54140_hwmon_write_in(dev, attr, channel, val); in bcm54140_hwmon_write()
363 return -EOPNOTSUPP; in bcm54140_hwmon_write()
398 /* select round-robin */ in bcm54140_enable_monitoring()
403 /* remove power-down bit */ in bcm54140_enable_monitoring()
419 hwmon = devm_hwmon_device_register_with_info(&phydev->mdio.dev, in bcm54140_probe_once()
492 /* The BCM54140 is a quad PHY where only the first port has access to the
498 struct bcm54140_priv *priv = phydev->priv; in bcm54140_get_base_addr_and_port()
499 struct mii_bus *bus = phydev->mdio.bus; in bcm54140_get_base_addr_and_port()
505 min_addr = phydev->mdio.addr; in bcm54140_get_base_addr_and_port()
506 max_addr = phydev->mdio.addr; in bcm54140_get_base_addr_and_port()
507 addr = phydev->mdio.addr; in bcm54140_get_base_addr_and_port()
516 * to the base address of this quad PHY. in bcm54140_get_base_addr_and_port()
527 addr--; in bcm54140_get_base_addr_and_port()
531 addr = phydev->mdio.addr; in bcm54140_get_base_addr_and_port()
547 if ((phy_id & phydev->drv->phy_id_mask) != in bcm54140_get_base_addr_and_port()
548 (phydev->drv->phy_id & phydev->drv->phy_id_mask)) { in bcm54140_get_base_addr_and_port()
549 addr = phydev->mdio.addr; in bcm54140_get_base_addr_and_port()
558 if ((max_addr - min_addr + 1) % 4) { in bcm54140_get_base_addr_and_port()
559 dev_err(&phydev->mdio.dev, in bcm54140_get_base_addr_and_port()
560 "Detected Quad PHY IDs %d..%d doesn't make sense.\n", in bcm54140_get_base_addr_and_port()
562 return -EINVAL; in bcm54140_get_base_addr_and_port()
565 priv->port = (phydev->mdio.addr - min_addr) % 4; in bcm54140_get_base_addr_and_port()
566 priv->base_addr = phydev->mdio.addr - priv->port; in bcm54140_get_base_addr_and_port()
576 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); in bcm54140_probe()
578 return -ENOMEM; in bcm54140_probe()
580 phydev->priv = priv; in bcm54140_probe()
586 devm_phy_package_join(&phydev->mdio.dev, phydev, priv->base_addr, 0); in bcm54140_probe()
589 mutex_init(&priv->alarm_lock); in bcm54140_probe()
599 priv->port, priv->base_addr); in bcm54140_probe()
610 if (BCM54140_PHY_ID_REV(phydev->phy_id) == BCM54140_REV_B0) { in bcm54140_config_init()
679 struct bcm54140_priv *priv = phydev->priv; in bcm54140_config_intr()
686 if (priv->port >= ARRAY_SIZE(port_to_imr_bit)) in bcm54140_config_intr()
687 return -EINVAL; in bcm54140_config_intr()
693 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { in bcm54140_config_intr()
698 reg &= ~port_to_imr_bit[priv->port]; in bcm54140_config_intr()
701 reg |= port_to_imr_bit[priv->port]; in bcm54140_config_intr()
743 return -EINVAL; in bcm54140_set_downshift()
758 set = FIELD_PREP(BCM54140_RDB_SPARE2_WS_RTRY_LIMIT, cnt - 2); in bcm54140_set_downshift()
824 return -EINVAL; in bcm54140_set_edpd()
833 switch (tuna->id) { in bcm54140_get_tunable()
839 return -EOPNOTSUPP; in bcm54140_get_tunable()
846 switch (tuna->id) { in bcm54140_set_tunable()
852 return -EOPNOTSUPP; in bcm54140_set_tunable()