/** * rtl83xx_lock() - Locks the mutex used by regmaps * @ctx: realtek_priv pointer * * This function is passed to regmap to be used as the lock function. * It is also used externally to block regmap before executing multiple * operations that must happen in sequence (which will use * realtek_priv.map_nolock instead). * * Context: Can sleep. Holds priv->map_lock lock. * Return: nothing
*/ void rtl83xx_lock(void *ctx)
{ struct realtek_priv *priv = ctx;
/** * rtl83xx_setup_user_mdio() - register the user mii bus driver * @ds: DSA switch associated with this user_mii_bus * * Registers the MDIO bus for built-in Ethernet PHYs, and associates it with * the mandatory 'mdio' child OF node of the switch. * * Context: Can sleep. * Return: 0 on success, negative value for failure.
*/ int rtl83xx_setup_user_mdio(struct dsa_switch *ds)
{ struct realtek_priv *priv = ds->priv; struct device_node *mdio_np; struct mii_bus *bus; int ret = 0;
mdio_np = of_get_child_by_name(priv->dev->of_node, "mdio"); if (!mdio_np) {
dev_err(priv->dev, "no MDIO bus node\n"); return -ENODEV;
}
bus = devm_mdiobus_alloc(priv->dev); if (!bus) {
ret = -ENOMEM; goto err_put_node;
}
ret = devm_of_mdiobus_register(priv->dev, bus, mdio_np); if (ret) {
dev_err(priv->dev, "unable to register MDIO bus %s\n",
bus->id); goto err_put_node;
}
/** * rtl83xx_probe() - probe a Realtek switch * @dev: the device being probed * @interface_info: specific management interface info. * * This function initializes realtek_priv and reads data from the device tree * node. The switch is hard resetted if a method is provided. * * Context: Can sleep. * Return: Pointer to the realtek_priv or ERR_PTR() in case of failure. * * The realtek_priv pointer does not need to be freed as it is controlled by * devres.
*/ struct realtek_priv *
rtl83xx_probe(struct device *dev, conststruct realtek_interface_info *interface_info)
{ conststruct realtek_variant *var; struct realtek_priv *priv; struct regmap_config rc = {
.reg_bits = 10, /* A4..A0 R4..R0 */
.val_bits = 16,
.reg_stride = 1,
.max_register = 0xffff,
.reg_format_endian = REGMAP_ENDIAN_BIG,
.reg_read = interface_info->reg_read,
.reg_write = interface_info->reg_write,
.cache_type = REGCACHE_NONE,
.lock = rtl83xx_lock,
.unlock = rtl83xx_unlock,
}; int ret;
var = of_device_get_match_data(dev); if (!var) return ERR_PTR(-EINVAL);
priv = devm_kzalloc(dev, size_add(sizeof(*priv), var->chip_data_sz),
GFP_KERNEL); if (!priv) return ERR_PTR(-ENOMEM);
/* TODO: if power is software controlled, set up any regulators here */
priv->reset_ctl = devm_reset_control_get_optional(dev, NULL); if (IS_ERR(priv->reset_ctl)) return dev_err_cast_probe(dev, priv->reset_ctl, "failed to get reset control\n");
priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(priv->reset)) {
dev_err(dev, "failed to get RESET GPIO\n"); return ERR_CAST(priv->reset);
}
/** * rtl83xx_register_switch() - detects and register a switch * @priv: realtek_priv pointer * * This function first checks the switch chip ID and register a DSA * switch. * * Context: Can sleep. Takes and releases priv->map_lock. * Return: 0 on success, negative value for failure.
*/ int rtl83xx_register_switch(struct realtek_priv *priv)
{ struct dsa_switch *ds = &priv->ds; int ret;
ret = priv->ops->detect(priv); if (ret) {
dev_err_probe(priv->dev, ret, "unable to detect switch\n"); return ret;
}
/** * rtl83xx_shutdown() - shutdown a switch * @priv: realtek_priv pointer * * This function shuts down the DSA switch and cleans the platform driver data, * to prevent realtek_{smi,mdio}_remove() from running afterwards, which is * possible if the parent bus implements its own .shutdown() as .remove(). * * Context: Can sleep. * Return: Nothing.
*/ void rtl83xx_shutdown(struct realtek_priv *priv)
{ struct dsa_switch *ds = &priv->ds;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.