drivers/ufs/host/ufshcd-pltfrm.c
Source file repositories/reference/linux-study-clean/drivers/ufs/host/ufshcd-pltfrm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ufs/host/ufshcd-pltfrm.c- Extension
.c- Size
- 14595 bytes
- Lines
- 570
- Domain
- Driver Families
- Bucket
- drivers/ufs
- 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.hlinux/module.hlinux/platform_device.hlinux/pm_opp.hlinux/pm_runtime.hlinux/of.hufs/ufshcd.hufshcd-pltfrm.hufs/unipro.h
Detected Declarations
function Copyrightfunction phandle_existsfunction ufshcd_populate_vregfunction ufshcd_parse_regulator_infofunction ufshcd_init_lanes_per_dirfunction ufshcd_parse_clock_min_max_freqfunction list_for_each_entryfunction ufshcd_parse_operating_pointsfunction ufshcd_negotiate_pwr_paramsfunction ufshcd_parse_gear_limitsfunction ufshcd_init_host_paramsfunction ufshcd_pltfrm_initfunction ufshcd_pltfrm_removeexport ufshcd_populate_vregexport ufshcd_negotiate_pwr_paramsexport ufshcd_parse_gear_limitsexport ufshcd_init_host_paramsexport ufshcd_pltfrm_initexport ufshcd_pltfrm_remove
Annotated Snippet
if (!clki) {
ret = -ENOMEM;
goto out;
}
clki->min_freq = clkfreq[i];
clki->max_freq = clkfreq[i+1];
clki->name = devm_kstrdup(dev, name, GFP_KERNEL);
if (!clki->name) {
ret = -ENOMEM;
goto out;
}
if (!strcmp(name, "ref_clk"))
clki->keep_link_active = true;
dev_dbg(dev, "%s: min %u max %u name %s\n", "freq-table-hz",
clki->min_freq, clki->max_freq, clki->name);
list_add_tail(&clki->list, &hba->clk_list_head);
}
out:
return ret;
}
static bool phandle_exists(const struct device_node *np,
const char *phandle_name, int index)
{
struct device_node *parse_np = of_parse_phandle(np, phandle_name, index);
if (parse_np)
of_node_put(parse_np);
return parse_np != NULL;
}
#define MAX_PROP_SIZE 32
int ufshcd_populate_vreg(struct device *dev, const char *name,
struct ufs_vreg **out_vreg, bool skip_current)
{
char prop_name[MAX_PROP_SIZE];
struct ufs_vreg *vreg = NULL;
struct device_node *np = dev->of_node;
if (!np) {
dev_err(dev, "%s: non DT initialization\n", __func__);
goto out;
}
snprintf(prop_name, MAX_PROP_SIZE, "%s-supply", name);
if (!phandle_exists(np, prop_name, 0)) {
dev_info(dev, "%s: Unable to find %s regulator, assuming enabled\n",
__func__, prop_name);
goto out;
}
vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL);
if (!vreg)
return -ENOMEM;
vreg->name = devm_kstrdup(dev, name, GFP_KERNEL);
if (!vreg->name)
return -ENOMEM;
if (skip_current) {
vreg->max_uA = 0;
goto out;
}
snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name);
if (of_property_read_u32(np, prop_name, &vreg->max_uA)) {
dev_info(dev, "%s: unable to find %s\n", __func__, prop_name);
vreg->max_uA = 0;
}
out:
*out_vreg = vreg;
return 0;
}
EXPORT_SYMBOL_GPL(ufshcd_populate_vreg);
/**
* ufshcd_parse_regulator_info - get regulator info from device tree
* @hba: per adapter instance
*
* Get regulator info from device tree for vcc, vccq, vccq2 power supplies.
* If any of the supplies are not defined it is assumed that they are always-on
* and hence return zero. If the property is defined but parsing is failed
* then return corresponding error.
*
* Return: 0 upon success; < 0 upon failure.
*/
static int ufshcd_parse_regulator_info(struct ufs_hba *hba)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm_opp.h`, `linux/pm_runtime.h`, `linux/of.h`, `ufs/ufshcd.h`, `ufshcd-pltfrm.h`.
- Detected declarations: `function Copyright`, `function phandle_exists`, `function ufshcd_populate_vreg`, `function ufshcd_parse_regulator_info`, `function ufshcd_init_lanes_per_dir`, `function ufshcd_parse_clock_min_max_freq`, `function list_for_each_entry`, `function ufshcd_parse_operating_points`, `function ufshcd_negotiate_pwr_params`, `function ufshcd_parse_gear_limits`.
- Atlas domain: Driver Families / drivers/ufs.
- 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.