drivers/media/platform/microchip/microchip-isc-clk.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/microchip/microchip-isc-clk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/microchip/microchip-isc-clk.c- Extension
.c- Size
- 7016 bytes
- Lines
- 312
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/clkdev.hlinux/clk-provider.hlinux/pm_runtime.hlinux/regmap.hmicrochip-isc-regs.hmicrochip-isc.h
Detected Declarations
function Controllerfunction isc_clk_preparefunction isc_clk_unpreparefunction isc_clk_enablefunction isc_clk_disablefunction isc_clk_is_enabledfunction isc_clk_recalc_ratefunction isc_clk_determine_ratefunction isc_clk_set_parentfunction isc_clk_get_parentfunction isc_clk_set_ratefunction isc_clk_registerfunction microchip_isc_clk_initfunction microchip_isc_clk_cleanupexport microchip_isc_clk_initexport microchip_isc_clk_cleanup
Annotated Snippet
if (best_diff < 0 || best_diff > diff) {
best_rate = rate;
best_diff = diff;
req->best_parent_rate = parent_rate;
req->best_parent_hw = parent;
}
if (!best_diff || rate < req->rate)
break;
}
if (!best_diff)
break;
}
dev_dbg(isc_clk->dev,
"ISC CLK: %s, best_rate = %ld, parent clk: %s @ %ld\n",
__func__, best_rate,
__clk_get_name((req->best_parent_hw)->clk),
req->best_parent_rate);
if (best_rate < 0)
return best_rate;
req->rate = best_rate;
return 0;
}
static int isc_clk_set_parent(struct clk_hw *hw, u8 index)
{
struct isc_clk *isc_clk = to_isc_clk(hw);
if (index >= clk_hw_get_num_parents(hw))
return -EINVAL;
isc_clk->parent_id = index;
return 0;
}
static u8 isc_clk_get_parent(struct clk_hw *hw)
{
struct isc_clk *isc_clk = to_isc_clk(hw);
return isc_clk->parent_id;
}
static int isc_clk_set_rate(struct clk_hw *hw,
unsigned long rate,
unsigned long parent_rate)
{
struct isc_clk *isc_clk = to_isc_clk(hw);
u32 div;
if (!rate)
return -EINVAL;
div = DIV_ROUND_CLOSEST(parent_rate, rate);
if (div > (ISC_CLK_MAX_DIV + 1) || !div)
return -EINVAL;
isc_clk->div = div - 1;
return 0;
}
static const struct clk_ops isc_clk_ops = {
.prepare = isc_clk_prepare,
.unprepare = isc_clk_unprepare,
.enable = isc_clk_enable,
.disable = isc_clk_disable,
.is_enabled = isc_clk_is_enabled,
.recalc_rate = isc_clk_recalc_rate,
.determine_rate = isc_clk_determine_rate,
.set_parent = isc_clk_set_parent,
.get_parent = isc_clk_get_parent,
.set_rate = isc_clk_set_rate,
};
static int isc_clk_register(struct isc_device *isc, unsigned int id)
{
struct regmap *regmap = isc->regmap;
struct device_node *np = isc->dev->of_node;
struct isc_clk *isc_clk;
struct clk_init_data init;
const char *clk_name = np->name;
const char *parent_names[3];
int num_parents;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clkdev.h`, `linux/clk-provider.h`, `linux/pm_runtime.h`, `linux/regmap.h`, `microchip-isc-regs.h`, `microchip-isc.h`.
- Detected declarations: `function Controller`, `function isc_clk_prepare`, `function isc_clk_unprepare`, `function isc_clk_enable`, `function isc_clk_disable`, `function isc_clk_is_enabled`, `function isc_clk_recalc_rate`, `function isc_clk_determine_rate`, `function isc_clk_set_parent`, `function isc_clk_get_parent`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.