drivers/clk/spacemit/ccu_common.c
Source file repositories/reference/linux-study-clean/drivers/clk/spacemit/ccu_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/spacemit/ccu_common.c- Extension
.c- Size
- 4211 bytes
- Lines
- 178
- Domain
- Driver Families
- Bucket
- drivers/clk
- 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/clk-provider.hlinux/device/devres.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/slab.hsoc/spacemit/ccu.hccu_common.h
Detected Declarations
function spacemit_ccu_registerfunction spacemit_cadev_releasefunction spacemit_adev_unregisterfunction spacemit_ccu_reset_registerfunction spacemit_ccu_probe
Annotated Snippet
if (!hw) {
clk_data->hws[i] = ERR_PTR(-ENOENT);
continue;
}
name = hw->init->name;
common = hw_to_ccu_common(hw);
common->regmap = regmap;
common->lock_regmap = lock_regmap;
ret = devm_clk_hw_register(dev, hw);
if (ret) {
dev_err(dev, "Cannot register clock %d - %s\n",
i, name);
return ret;
}
clk_data->hws[i] = hw;
}
ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
if (ret)
dev_err(dev, "failed to add clock hardware provider (%d)\n", ret);
return ret;
}
static void spacemit_cadev_release(struct device *dev)
{
struct auxiliary_device *adev = to_auxiliary_dev(dev);
ida_free(&auxiliary_ids, adev->id);
kfree(to_spacemit_ccu_adev(adev));
}
static void spacemit_adev_unregister(void *data)
{
struct auxiliary_device *adev = data;
auxiliary_device_delete(adev);
auxiliary_device_uninit(adev);
}
static int spacemit_ccu_reset_register(struct device *dev,
struct regmap *regmap,
const char *reset_name)
{
struct spacemit_ccu_adev *cadev;
struct auxiliary_device *adev;
int ret;
/* Nothing to do if the CCU does not implement a reset controller */
if (!reset_name)
return 0;
cadev = kzalloc_obj(*cadev);
if (!cadev)
return -ENOMEM;
cadev->regmap = regmap;
adev = &cadev->adev;
adev->name = reset_name;
adev->dev.parent = dev;
adev->dev.release = spacemit_cadev_release;
adev->dev.of_node = dev->of_node;
ret = ida_alloc(&auxiliary_ids, GFP_KERNEL);
if (ret < 0)
goto err_free_cadev;
adev->id = ret;
ret = auxiliary_device_init(adev);
if (ret)
goto err_free_aux_id;
ret = auxiliary_device_add(adev);
if (ret) {
auxiliary_device_uninit(adev);
return ret;
}
return devm_add_action_or_reset(dev, spacemit_adev_unregister, adev);
err_free_aux_id:
ida_free(&auxiliary_ids, adev->id);
err_free_cadev:
kfree(cadev);
return ret;
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/device/devres.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/slab.h`, `soc/spacemit/ccu.h`, `ccu_common.h`.
- Detected declarations: `function spacemit_ccu_register`, `function spacemit_cadev_release`, `function spacemit_adev_unregister`, `function spacemit_ccu_reset_register`, `function spacemit_ccu_probe`.
- Atlas domain: Driver Families / drivers/clk.
- 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.