drivers/net/ethernet/arc/emac_rockchip.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/arc/emac_rockchip.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/arc/emac_rockchip.c- Extension
.c- Size
- 6988 bytes
- Lines
- 279
- 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/etherdevice.hlinux/mfd/syscon.hlinux/module.hlinux/of_net.hlinux/platform_device.hlinux/regmap.hlinux/regulator/consumer.hemac.h
Detected Declarations
struct emac_rockchip_soc_datastruct rockchip_priv_datafunction emac_rockchip_set_mac_speedfunction emac_rockchip_probefunction emac_rockchip_remove
Annotated Snippet
struct emac_rockchip_soc_data {
unsigned int grf_offset;
unsigned int grf_mode_offset;
unsigned int grf_speed_offset;
bool need_div_macclk;
};
struct rockchip_priv_data {
struct arc_emac_priv emac;
struct regmap *grf;
const struct emac_rockchip_soc_data *soc_data;
struct regulator *regulator;
struct clk *refclk;
struct clk *macclk;
};
static void emac_rockchip_set_mac_speed(void *priv, unsigned int speed)
{
struct rockchip_priv_data *emac = priv;
u32 speed_offset = emac->soc_data->grf_speed_offset;
u32 data;
int err = 0;
switch (speed) {
case 10:
data = (1 << (speed_offset + 16)) | (0 << speed_offset);
break;
case 100:
data = (1 << (speed_offset + 16)) | (1 << speed_offset);
break;
default:
pr_err("speed %u not supported\n", speed);
return;
}
err = regmap_write(emac->grf, emac->soc_data->grf_offset, data);
if (err)
pr_err("unable to apply speed %u to grf (%d)\n", speed, err);
}
static const struct emac_rockchip_soc_data emac_rk3036_emac_data = {
.grf_offset = 0x140, .grf_mode_offset = 8,
.grf_speed_offset = 9, .need_div_macclk = 1,
};
static const struct emac_rockchip_soc_data emac_rk3066_emac_data = {
.grf_offset = 0x154, .grf_mode_offset = 0,
.grf_speed_offset = 1, .need_div_macclk = 0,
};
static const struct emac_rockchip_soc_data emac_rk3188_emac_data = {
.grf_offset = 0x0a4, .grf_mode_offset = 0,
.grf_speed_offset = 1, .need_div_macclk = 0,
};
static const struct of_device_id emac_rockchip_dt_ids[] = {
{
.compatible = "rockchip,rk3036-emac",
.data = &emac_rk3036_emac_data,
},
{
.compatible = "rockchip,rk3066-emac",
.data = &emac_rk3066_emac_data,
},
{
.compatible = "rockchip,rk3188-emac",
.data = &emac_rk3188_emac_data,
},
{ /* Sentinel */ }
};
MODULE_DEVICE_TABLE(of, emac_rockchip_dt_ids);
static int emac_rockchip_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct net_device *ndev;
struct rockchip_priv_data *priv;
const struct of_device_id *match;
phy_interface_t interface;
u32 data;
int err;
if (!pdev->dev.of_node)
return -ENODEV;
ndev = alloc_etherdev(sizeof(struct rockchip_priv_data));
if (!ndev)
return -ENOMEM;
platform_set_drvdata(pdev, ndev);
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of_net.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/regulator/consumer.h`, `emac.h`.
- Detected declarations: `struct emac_rockchip_soc_data`, `struct rockchip_priv_data`, `function emac_rockchip_set_mac_speed`, `function emac_rockchip_probe`, `function emac_rockchip_remove`.
- 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.