drivers/soc/qcom/qcom-pbs.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/qcom-pbs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/qcom-pbs.c- Extension
.c- Size
- 5784 bytes
- Lines
- 229
- 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/cleanup.hlinux/delay.hlinux/err.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/of_platform.hlinux/regmap.hlinux/spmi.hlinux/soc/qcom/qcom-pbs.h
Detected Declarations
struct pbs_devfunction qcom_pbs_wait_for_ackfunction qcom_pbs_trigger_eventfunction get_pbs_client_devicefunction qcom_pbs_probeexport qcom_pbs_trigger_eventexport get_pbs_client_device
Annotated Snippet
struct pbs_dev {
struct device *dev;
struct regmap *regmap;
struct mutex lock;
struct device_link *link;
u32 base;
};
static int qcom_pbs_wait_for_ack(struct pbs_dev *pbs, u8 bit_pos)
{
unsigned int val;
int ret;
ret = regmap_read_poll_timeout(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2,
val, val & BIT(bit_pos), DELAY, DELAY * RETRIES);
if (ret < 0) {
dev_err(pbs->dev, "Timeout for PBS ACK/NACK for bit %u\n", bit_pos);
return -ETIMEDOUT;
}
if (val == PBS_CLIENT_SCRATCH2_ERROR) {
ret = regmap_write(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, 0);
dev_err(pbs->dev, "NACK from PBS for bit %u\n", bit_pos);
return -EINVAL;
}
dev_dbg(pbs->dev, "PBS sequence for bit %u executed!\n", bit_pos);
return 0;
}
/**
* qcom_pbs_trigger_event() - Trigger the PBS RAM sequence
* @pbs: Pointer to PBS device
* @bitmap: bitmap
*
* This function is used to trigger the PBS RAM sequence to be
* executed by the client driver.
*
* The PBS trigger sequence involves
* 1. setting the PBS sequence bit in PBS_CLIENT_SCRATCH1
* 2. Initiating the SW PBS trigger
* 3. Checking the equivalent bit in PBS_CLIENT_SCRATCH2 for the
* completion of the sequence.
* 4. If PBS_CLIENT_SCRATCH2 == 0xFF, the PBS sequence failed to execute
*
* Return: 0 on success, < 0 on failure
*/
int qcom_pbs_trigger_event(struct pbs_dev *pbs, u8 bitmap)
{
unsigned int val;
u16 bit_pos;
int ret;
if (WARN_ON(!bitmap))
return -EINVAL;
if (IS_ERR_OR_NULL(pbs))
return -EINVAL;
guard(mutex)(&pbs->lock);
ret = regmap_read(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, &val);
if (ret < 0)
return ret;
if (val == PBS_CLIENT_SCRATCH2_ERROR) {
/* PBS error - clear SCRATCH2 register */
ret = regmap_write(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, 0);
if (ret < 0)
return ret;
}
for (bit_pos = 0; bit_pos < 8; bit_pos++) {
if (!(bitmap & BIT(bit_pos)))
continue;
/* Clear the PBS sequence bit position */
ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2,
BIT(bit_pos), 0);
if (ret < 0)
break;
/* Set the PBS sequence bit position */
ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1,
BIT(bit_pos), BIT(bit_pos));
if (ret < 0)
break;
/* Initiate the SW trigger */
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/delay.h`, `linux/err.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/of_platform.h`, `linux/regmap.h`.
- Detected declarations: `struct pbs_dev`, `function qcom_pbs_wait_for_ack`, `function qcom_pbs_trigger_event`, `function get_pbs_client_device`, `function qcom_pbs_probe`, `export qcom_pbs_trigger_event`, `export get_pbs_client_device`.
- 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.