drivers/net/ethernet/broadcom/bgmac-platform.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bgmac-platform.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bgmac-platform.c- Extension
.c- Size
- 8012 bytes
- Lines
- 306
- 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
linux/bcma/bcma.hlinux/brcmphy.hlinux/etherdevice.hlinux/of_address.hlinux/of_mdio.hlinux/of_net.hbgmac.h
Detected Declarations
function platform_bgmac_readfunction platform_bgmac_writefunction platform_bgmac_idm_readfunction platform_bgmac_idm_writefunction platform_bgmac_clk_enabledfunction platform_bgmac_clk_enablefunction platform_bgmac_cco_ctl_masksetfunction platform_bgmac_get_bus_clockfunction platform_bgmac_cmn_maskset32function bgmac_nicpm_speed_setfunction platform_phy_connectfunction bgmac_probefunction bgmac_removefunction bgmac_suspendfunction bgmac_resume
Annotated Snippet
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bcma/bcma.h>
#include <linux/brcmphy.h>
#include <linux/etherdevice.h>
#include <linux/of_address.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
#include "bgmac.h"
#define NICPM_PADRING_CFG 0x00000004
#define NICPM_IOMUX_CTRL 0x00000008
#define NICPM_PADRING_CFG_INIT_VAL 0x74000000
#define NICPM_IOMUX_CTRL_INIT_VAL_AX 0x21880000
#define NICPM_IOMUX_CTRL_INIT_VAL 0x3196e000
#define NICPM_IOMUX_CTRL_SPD_SHIFT 10
#define NICPM_IOMUX_CTRL_SPD_10M 0
#define NICPM_IOMUX_CTRL_SPD_100M 1
#define NICPM_IOMUX_CTRL_SPD_1000M 2
static u32 platform_bgmac_read(struct bgmac *bgmac, u16 offset)
{
return readl(bgmac->plat.base + offset);
}
static void platform_bgmac_write(struct bgmac *bgmac, u16 offset, u32 value)
{
writel(value, bgmac->plat.base + offset);
}
static u32 platform_bgmac_idm_read(struct bgmac *bgmac, u16 offset)
{
return readl(bgmac->plat.idm_base + offset);
}
static void platform_bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value)
{
writel(value, bgmac->plat.idm_base + offset);
}
static bool platform_bgmac_clk_enabled(struct bgmac *bgmac)
{
if (!bgmac->plat.idm_base)
return true;
if ((bgmac_idm_read(bgmac, BCMA_IOCTL) & BGMAC_CLK_EN) != BGMAC_CLK_EN)
return false;
if (bgmac_idm_read(bgmac, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
return false;
return true;
}
static void platform_bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
{
u32 val;
if (!bgmac->plat.idm_base)
return;
/* The Reset Control register only contains a single bit to show if the
* controller is currently in reset. Do a sanity check here, just in
* case the bootloader happened to leave the device in reset.
*/
val = bgmac_idm_read(bgmac, BCMA_RESET_CTL);
if (val) {
bgmac_idm_write(bgmac, BCMA_RESET_CTL, 0);
bgmac_idm_read(bgmac, BCMA_RESET_CTL);
udelay(1);
}
val = bgmac_idm_read(bgmac, BCMA_IOCTL);
/* Some bits of BCMA_IOCTL set by HW/ATF and should not change */
val |= flags & ~(BGMAC_AWCACHE | BGMAC_ARCACHE | BGMAC_AWUSER |
BGMAC_ARUSER);
val |= BGMAC_CLK_EN;
bgmac_idm_write(bgmac, BCMA_IOCTL, val);
bgmac_idm_read(bgmac, BCMA_IOCTL);
udelay(1);
}
static void platform_bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset,
u32 mask, u32 set)
{
/* This shouldn't be encountered */
WARN_ON(1);
}
static u32 platform_bgmac_get_bus_clock(struct bgmac *bgmac)
Annotation
- Immediate include surface: `linux/bcma/bcma.h`, `linux/brcmphy.h`, `linux/etherdevice.h`, `linux/of_address.h`, `linux/of_mdio.h`, `linux/of_net.h`, `bgmac.h`.
- Detected declarations: `function platform_bgmac_read`, `function platform_bgmac_write`, `function platform_bgmac_idm_read`, `function platform_bgmac_idm_write`, `function platform_bgmac_clk_enabled`, `function platform_bgmac_clk_enable`, `function platform_bgmac_cco_ctl_maskset`, `function platform_bgmac_get_bus_clock`, `function platform_bgmac_cmn_maskset32`, `function bgmac_nicpm_speed_set`.
- 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.