drivers/soc/bcm/brcmstb/common.c
Source file repositories/reference/linux-study-clean/drivers/soc/bcm/brcmstb/common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/bcm/brcmstb/common.c- Extension
.c- Size
- 2990 bytes
- Lines
- 118
- Domain
- Driver Families
- Bucket
- drivers/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/io.hlinux/of.hlinux/of_address.hlinux/slab.hlinux/soc/brcmstb/brcmstb.hlinux/sys_soc.h
Detected Declarations
struct brcmstb_soc_infofunction brcmstb_get_family_idfunction brcmstb_get_product_idfunction brcmstb_soc_device_initexport brcmstb_get_family_idexport brcmstb_get_product_id
Annotated Snippet
struct brcmstb_soc_info {
u32 family_id;
u32 product_id;
};
static struct brcmstb_soc_info *soc_info;
u32 brcmstb_get_family_id(void)
{
return soc_info ? soc_info->family_id : 0;
}
EXPORT_SYMBOL(brcmstb_get_family_id);
u32 brcmstb_get_product_id(void)
{
return soc_info ? soc_info->product_id : 0;
}
EXPORT_SYMBOL(brcmstb_get_product_id);
static const struct of_device_id sun_top_ctrl_match[] = {
{ .compatible = "brcm,bcm7125-sun-top-ctrl", },
{ .compatible = "brcm,bcm7346-sun-top-ctrl", },
{ .compatible = "brcm,bcm7358-sun-top-ctrl", },
{ .compatible = "brcm,bcm7360-sun-top-ctrl", },
{ .compatible = "brcm,bcm7362-sun-top-ctrl", },
{ .compatible = "brcm,bcm7420-sun-top-ctrl", },
{ .compatible = "brcm,bcm7425-sun-top-ctrl", },
{ .compatible = "brcm,bcm7429-sun-top-ctrl", },
{ .compatible = "brcm,bcm7435-sun-top-ctrl", },
{ .compatible = "brcm,brcmstb-sun-top-ctrl", },
{ }
};
static int __init brcmstb_soc_device_init(void)
{
struct soc_device_attribute *soc_dev_attr;
struct device_node *sun_top_ctrl;
void __iomem *sun_top_ctrl_base;
struct soc_device *soc_dev;
int ret = 0;
/* We could be on a multi-platform kernel, don't make this fatal but
* bail out early
*/
sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match);
if (!sun_top_ctrl)
return 0;
sun_top_ctrl_base = of_iomap(sun_top_ctrl, 0);
if (!sun_top_ctrl_base) {
ret = -ENODEV;
goto out_put_node;
}
soc_info = kzalloc(sizeof(*soc_info), GFP_KERNEL);
if (!soc_info) {
ret = -ENOMEM;
goto out_unmap;
}
soc_info->family_id = readl(sun_top_ctrl_base);
soc_info->product_id = readl(sun_top_ctrl_base + 0x4);
soc_dev_attr = kzalloc_obj(*soc_dev_attr);
if (!soc_dev_attr) {
ret = -ENOMEM;
goto out_free_info;
}
soc_dev_attr->family = kasprintf(GFP_KERNEL, "%x",
soc_info->family_id >> 28 ?
soc_info->family_id >> 16 : soc_info->family_id >> 8);
soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%x",
soc_info->product_id >> 28 ?
soc_info->product_id >> 16 : soc_info->product_id >> 8);
soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c%d",
((soc_info->product_id & 0xf0) >> 4) + 'A',
soc_info->product_id & 0xf);
soc_dev = soc_device_register(soc_dev_attr);
if (IS_ERR(soc_dev)) {
ret = PTR_ERR(soc_dev);
goto out_free_attr;
}
iounmap(sun_top_ctrl_base);
of_node_put(sun_top_ctrl);
return 0;
out_free_attr:
Annotation
- Immediate include surface: `linux/io.h`, `linux/of.h`, `linux/of_address.h`, `linux/slab.h`, `linux/soc/brcmstb/brcmstb.h`, `linux/sys_soc.h`.
- Detected declarations: `struct brcmstb_soc_info`, `function brcmstb_get_family_id`, `function brcmstb_get_product_id`, `function brcmstb_soc_device_init`, `export brcmstb_get_family_id`, `export brcmstb_get_product_id`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: integration 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.