Lines Matching full:pbs

15 #include <linux/soc/qcom/qcom-pbs.h>
35 static int qcom_pbs_wait_for_ack(struct pbs_dev *pbs, u8 bit_pos) in qcom_pbs_wait_for_ack() argument
40 ret = regmap_read_poll_timeout(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, in qcom_pbs_wait_for_ack()
44 dev_err(pbs->dev, "Timeout for PBS ACK/NACK for bit %u\n", bit_pos); in qcom_pbs_wait_for_ack()
49 ret = regmap_write(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, 0); in qcom_pbs_wait_for_ack()
50 dev_err(pbs->dev, "NACK from PBS for bit %u\n", bit_pos); in qcom_pbs_wait_for_ack()
54 dev_dbg(pbs->dev, "PBS sequence for bit %u executed!\n", bit_pos); in qcom_pbs_wait_for_ack()
59 * qcom_pbs_trigger_event() - Trigger the PBS RAM sequence
60 * @pbs: Pointer to PBS device
63 * This function is used to trigger the PBS RAM sequence to be
66 * The PBS trigger sequence involves
67 * 1. setting the PBS sequence bit in PBS_CLIENT_SCRATCH1
68 * 2. Initiating the SW PBS trigger
71 * 4. If PBS_CLIENT_SCRATCH2 == 0xFF, the PBS sequence failed to execute
75 int qcom_pbs_trigger_event(struct pbs_dev *pbs, u8 bitmap) in qcom_pbs_trigger_event() argument
84 if (IS_ERR_OR_NULL(pbs)) in qcom_pbs_trigger_event()
87 mutex_lock(&pbs->lock); in qcom_pbs_trigger_event()
88 ret = regmap_read(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, &val); in qcom_pbs_trigger_event()
93 /* PBS error - clear SCRATCH2 register */ in qcom_pbs_trigger_event()
94 ret = regmap_write(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, 0); in qcom_pbs_trigger_event()
103 /* Clear the PBS sequence bit position */ in qcom_pbs_trigger_event()
104 ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, in qcom_pbs_trigger_event()
109 /* Set the PBS sequence bit position */ in qcom_pbs_trigger_event()
110 ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, in qcom_pbs_trigger_event()
116 ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_TRIG_CTL, in qcom_pbs_trigger_event()
121 ret = qcom_pbs_wait_for_ack(pbs, bit_pos); in qcom_pbs_trigger_event()
125 /* Clear the PBS sequence bit position */ in qcom_pbs_trigger_event()
126 regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, BIT(bit_pos), 0); in qcom_pbs_trigger_event()
127 regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, BIT(bit_pos), 0); in qcom_pbs_trigger_event()
132 ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, bitmap, 0); in qcom_pbs_trigger_event()
135 mutex_unlock(&pbs->lock); in qcom_pbs_trigger_event()
142 * get_pbs_client_device() - Get the PBS device used by client
145 * This function is used to get the PBS device that is being
153 struct pbs_dev *pbs; in get_pbs_client_device() local
156 "qcom,pbs", 0); in get_pbs_client_device()
158 dev_err(dev, "Missing qcom,pbs property\n"); in get_pbs_client_device()
164 dev_err(dev, "Unable to find PBS dev_node\n"); in get_pbs_client_device()
168 pbs = platform_get_drvdata(pdev); in get_pbs_client_device()
169 if (!pbs) { in get_pbs_client_device()
170 dev_err(dev, "Cannot get pbs instance from %s\n", dev_name(&pdev->dev)); in get_pbs_client_device()
175 pbs->link = device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER); in get_pbs_client_device()
176 if (!pbs->link) { in get_pbs_client_device()
182 return pbs; in get_pbs_client_device()
188 struct pbs_dev *pbs; in qcom_pbs_probe() local
192 pbs = devm_kzalloc(&pdev->dev, sizeof(*pbs), GFP_KERNEL); in qcom_pbs_probe()
193 if (!pbs) in qcom_pbs_probe()
196 pbs->dev = &pdev->dev; in qcom_pbs_probe()
197 pbs->regmap = dev_get_regmap(pbs->dev->parent, NULL); in qcom_pbs_probe()
198 if (!pbs->regmap) { in qcom_pbs_probe()
199 dev_err(pbs->dev, "Couldn't get parent's regmap\n"); in qcom_pbs_probe()
203 ret = device_property_read_u32(pbs->dev, "reg", &val); in qcom_pbs_probe()
205 dev_err(pbs->dev, "Couldn't find reg, ret = %d\n", ret); in qcom_pbs_probe()
208 pbs->base = val; in qcom_pbs_probe()
209 mutex_init(&pbs->lock); in qcom_pbs_probe()
211 platform_set_drvdata(pdev, pbs); in qcom_pbs_probe()
217 { .compatible = "qcom,pbs" },
224 .name = "qcom-pbs",
231 MODULE_DESCRIPTION("QCOM PBS DRIVER");