drivers/net/dsa/mv88e6060.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/mv88e6060.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/mv88e6060.c- Extension
.c- Size
- 9172 bytes
- Lines
- 384
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/etherdevice.hlinux/jiffies.hlinux/list.hlinux/module.hlinux/netdevice.hlinux/phy.hnet/dsa.hmv88e6060.h
Detected Declarations
function Copyrightfunction reg_writefunction mv88e6060_get_tag_protocolfunction mv88e6060_switch_resetfunction mv88e6060_setup_globalfunction mv88e6060_setup_portfunction mv88e6060_setup_addrfunction mv88e6060_setupfunction mv88e6060_port_to_phy_addrfunction mv88e6060_phy_readfunction mv88e6060_phy_writefunction mv88e6060_phylink_get_capsfunction mv88e6060_probefunction mv88e6060_removefunction mv88e6060_shutdown
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* net/dsa/mv88e6060.c - Driver for Marvell 88e6060 switch chips
* Copyright (c) 2008-2009 Marvell Semiconductor
*/
#include <linux/delay.h>
#include <linux/etherdevice.h>
#include <linux/jiffies.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/phy.h>
#include <net/dsa.h>
#include "mv88e6060.h"
static int reg_read(struct mv88e6060_priv *priv, int addr, int reg)
{
return mdiobus_read_nested(priv->bus, priv->sw_addr + addr, reg);
}
static int reg_write(struct mv88e6060_priv *priv, int addr, int reg, u16 val)
{
return mdiobus_write_nested(priv->bus, priv->sw_addr + addr, reg, val);
}
static const char *mv88e6060_get_name(struct mii_bus *bus, int sw_addr)
{
int ret;
ret = mdiobus_read(bus, sw_addr + REG_PORT(0), PORT_SWITCH_ID);
if (ret >= 0) {
if (ret == PORT_SWITCH_ID_6060)
return "Marvell 88E6060 (A0)";
if (ret == PORT_SWITCH_ID_6060_R1 ||
ret == PORT_SWITCH_ID_6060_R2)
return "Marvell 88E6060 (B0)";
if ((ret & PORT_SWITCH_ID_6060_MASK) == PORT_SWITCH_ID_6060)
return "Marvell 88E6060";
}
return NULL;
}
static enum dsa_tag_protocol mv88e6060_get_tag_protocol(struct dsa_switch *ds,
int port,
enum dsa_tag_protocol m)
{
return DSA_TAG_PROTO_TRAILER;
}
static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)
{
int i;
int ret;
unsigned long timeout;
/* Set all ports to the disabled state. */
for (i = 0; i < MV88E6060_PORTS; i++) {
ret = reg_read(priv, REG_PORT(i), PORT_CONTROL);
if (ret < 0)
return ret;
ret = reg_write(priv, REG_PORT(i), PORT_CONTROL,
ret & ~PORT_CONTROL_STATE_MASK);
if (ret)
return ret;
}
/* Wait for transmit queues to drain. */
usleep_range(2000, 4000);
/* Reset the switch. */
ret = reg_write(priv, REG_GLOBAL, GLOBAL_ATU_CONTROL,
GLOBAL_ATU_CONTROL_SWRESET |
GLOBAL_ATU_CONTROL_LEARNDIS);
if (ret)
return ret;
/* Wait up to one second for reset to complete. */
timeout = jiffies + 1 * HZ;
while (time_before(jiffies, timeout)) {
ret = reg_read(priv, REG_GLOBAL, GLOBAL_STATUS);
if (ret < 0)
return ret;
if (ret & GLOBAL_STATUS_INIT_READY)
break;
usleep_range(1000, 2000);
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/etherdevice.h`, `linux/jiffies.h`, `linux/list.h`, `linux/module.h`, `linux/netdevice.h`, `linux/phy.h`, `net/dsa.h`.
- Detected declarations: `function Copyright`, `function reg_write`, `function mv88e6060_get_tag_protocol`, `function mv88e6060_switch_reset`, `function mv88e6060_setup_global`, `function mv88e6060_setup_port`, `function mv88e6060_setup_addr`, `function mv88e6060_setup`, `function mv88e6060_port_to_phy_addr`, `function mv88e6060_phy_read`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.