drivers/net/dsa/mv88e6xxx/global2_scratch.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/mv88e6xxx/global2_scratch.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/mv88e6xxx/global2_scratch.c- Extension
.c- Size
- 9081 bytes
- Lines
- 371
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
chip.hglobal2.h
Detected Declarations
function Copyrightfunction mv88e6xxx_g2_scratch_writefunction mv88e6xxx_g2_scratch_get_bitfunction mv88e6xxx_g2_scratch_set_bitfunction mv88e6352_g2_scratch_gpio_get_datafunction mv88e6352_g2_scratch_gpio_set_datafunction mv88e6352_g2_scratch_gpio_get_dirfunction mv88e6352_g2_scratch_gpio_set_dirfunction mv88e6352_g2_scratch_gpio_get_pctlfunction mv88e6352_g2_scratch_gpio_set_pctlfunction mv88e6390_g2_scratch_gpio_set_smifunction mv88e6393x_g2_scratch_gpio_set_smifunction mv88e6352_g2_cache_global_scratch_config3function mv88e6352_g2_scratch_port_has_serdes
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Marvell 88E6xxx Switch Global 2 Scratch & Misc Registers support
*
* Copyright (c) 2008 Marvell Semiconductor
*
* Copyright (c) 2017 National Instruments
* Brandon Streiff <brandon.streiff@ni.com>
*/
#include "chip.h"
#include "global2.h"
/* Offset 0x1A: Scratch and Misc. Register */
static int mv88e6xxx_g2_scratch_read(struct mv88e6xxx_chip *chip, int reg,
u8 *data)
{
u16 value;
int err;
err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_SCRATCH_MISC_MISC,
reg << 8);
if (err)
return err;
err = mv88e6xxx_g2_read(chip, MV88E6XXX_G2_SCRATCH_MISC_MISC, &value);
if (err)
return err;
*data = (value & MV88E6XXX_G2_SCRATCH_MISC_DATA_MASK);
return 0;
}
static int mv88e6xxx_g2_scratch_write(struct mv88e6xxx_chip *chip, int reg,
u8 data)
{
u16 value = (reg << 8) | data;
return mv88e6xxx_g2_write(chip, MV88E6XXX_G2_SCRATCH_MISC_MISC,
MV88E6XXX_G2_SCRATCH_MISC_UPDATE | value);
}
/**
* mv88e6xxx_g2_scratch_get_bit - get a bit
* @chip: chip private data
* @base_reg: base of scratch bits
* @offset: index of bit within the register
* @set: is bit set?
*/
static int mv88e6xxx_g2_scratch_get_bit(struct mv88e6xxx_chip *chip,
int base_reg, unsigned int offset,
int *set)
{
int reg = base_reg + (offset / 8);
u8 mask = (1 << (offset & 0x7));
u8 val;
int err;
err = mv88e6xxx_g2_scratch_read(chip, reg, &val);
if (err)
return err;
*set = !!(mask & val);
return 0;
}
/**
* mv88e6xxx_g2_scratch_set_bit - set (or clear) a bit
* @chip: chip private data
* @base_reg: base of scratch bits
* @offset: index of bit within the register
* @set: should this bit be set?
*
* Helper function for dealing with the direction and data registers.
*/
static int mv88e6xxx_g2_scratch_set_bit(struct mv88e6xxx_chip *chip,
int base_reg, unsigned int offset,
int set)
{
int reg = base_reg + (offset / 8);
u8 mask = (1 << (offset & 0x7));
u8 val;
int err;
err = mv88e6xxx_g2_scratch_read(chip, reg, &val);
if (err)
return err;
Annotation
- Immediate include surface: `chip.h`, `global2.h`.
- Detected declarations: `function Copyright`, `function mv88e6xxx_g2_scratch_write`, `function mv88e6xxx_g2_scratch_get_bit`, `function mv88e6xxx_g2_scratch_set_bit`, `function mv88e6352_g2_scratch_gpio_get_data`, `function mv88e6352_g2_scratch_gpio_set_data`, `function mv88e6352_g2_scratch_gpio_get_dir`, `function mv88e6352_g2_scratch_gpio_set_dir`, `function mv88e6352_g2_scratch_gpio_get_pctl`, `function mv88e6352_g2_scratch_gpio_set_pctl`.
- 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.