Lines Matching refs:rpm
58 #define RPM_STATUS_REG(rpm, i) ((rpm)->status_regs + (i) * 4) argument
59 #define RPM_CTRL_REG(rpm, i) ((rpm)->ctrl_regs + (i) * 4) argument
60 #define RPM_REQ_REG(rpm, i) ((rpm)->req_regs + (i) * 4) argument
445 int qcom_rpm_write(struct qcom_rpm *rpm, in qcom_rpm_write() argument
451 const struct qcom_rpm_data *data = rpm->data; in qcom_rpm_write()
464 mutex_lock(&rpm->lock); in qcom_rpm_write()
467 writel_relaxed(buf[i], RPM_REQ_REG(rpm, res->target_id + i)); in qcom_rpm_write()
470 for (i = 0; i < rpm->data->req_sel_size; i++) { in qcom_rpm_write()
472 RPM_CTRL_REG(rpm, rpm->data->req_sel_off + i)); in qcom_rpm_write()
475 writel_relaxed(BIT(state), RPM_CTRL_REG(rpm, rpm->data->req_ctx_off)); in qcom_rpm_write()
477 reinit_completion(&rpm->ack); in qcom_rpm_write()
478 regmap_write(rpm->ipc_regmap, rpm->ipc_offset, BIT(rpm->ipc_bit)); in qcom_rpm_write()
480 left = wait_for_completion_timeout(&rpm->ack, RPM_REQUEST_TIMEOUT); in qcom_rpm_write()
483 else if (rpm->ack_status & RPM_REJECTED) in qcom_rpm_write()
486 mutex_unlock(&rpm->lock); in qcom_rpm_write()
494 struct qcom_rpm *rpm = dev; in qcom_rpm_ack_interrupt() local
498 ack = readl_relaxed(RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off)); in qcom_rpm_ack_interrupt()
499 for (i = 0; i < rpm->data->ack_sel_size; i++) in qcom_rpm_ack_interrupt()
501 RPM_CTRL_REG(rpm, rpm->data->ack_sel_off + i)); in qcom_rpm_ack_interrupt()
502 writel(0, RPM_CTRL_REG(rpm, rpm->data->ack_ctx_off)); in qcom_rpm_ack_interrupt()
505 dev_warn(rpm->dev, "ignoring notification!\n"); in qcom_rpm_ack_interrupt()
507 rpm->ack_status = ack; in qcom_rpm_ack_interrupt()
508 complete(&rpm->ack); in qcom_rpm_ack_interrupt()
516 struct qcom_rpm *rpm = dev; in qcom_rpm_err_interrupt() local
518 regmap_write(rpm->ipc_regmap, rpm->ipc_offset, BIT(rpm->ipc_bit)); in qcom_rpm_err_interrupt()
519 dev_err(rpm->dev, "RPM triggered fatal error\n"); in qcom_rpm_err_interrupt()
533 struct qcom_rpm *rpm; in qcom_rpm_probe() local
540 rpm = devm_kzalloc(&pdev->dev, sizeof(*rpm), GFP_KERNEL); in qcom_rpm_probe()
541 if (!rpm) in qcom_rpm_probe()
544 rpm->dev = &pdev->dev; in qcom_rpm_probe()
545 mutex_init(&rpm->lock); in qcom_rpm_probe()
546 init_completion(&rpm->ack); in qcom_rpm_probe()
549 rpm->ramclk = devm_clk_get_enabled(&pdev->dev, "ram"); in qcom_rpm_probe()
550 if (IS_ERR(rpm->ramclk)) { in qcom_rpm_probe()
551 ret = PTR_ERR(rpm->ramclk); in qcom_rpm_probe()
558 rpm->ramclk = NULL; in qcom_rpm_probe()
576 rpm->data = match->data; in qcom_rpm_probe()
578 rpm->status_regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in qcom_rpm_probe()
579 if (IS_ERR(rpm->status_regs)) in qcom_rpm_probe()
580 return PTR_ERR(rpm->status_regs); in qcom_rpm_probe()
581 rpm->ctrl_regs = rpm->status_regs + 0x400; in qcom_rpm_probe()
582 rpm->req_regs = rpm->status_regs + 0x600; in qcom_rpm_probe()
590 rpm->ipc_regmap = syscon_node_to_regmap(syscon_np); in qcom_rpm_probe()
592 if (IS_ERR(rpm->ipc_regmap)) in qcom_rpm_probe()
593 return PTR_ERR(rpm->ipc_regmap); in qcom_rpm_probe()
596 &rpm->ipc_offset); in qcom_rpm_probe()
603 &rpm->ipc_bit); in qcom_rpm_probe()
609 dev_set_drvdata(&pdev->dev, rpm); in qcom_rpm_probe()
611 fw_version[0] = readl(RPM_STATUS_REG(rpm, 0)); in qcom_rpm_probe()
612 fw_version[1] = readl(RPM_STATUS_REG(rpm, 1)); in qcom_rpm_probe()
613 fw_version[2] = readl(RPM_STATUS_REG(rpm, 2)); in qcom_rpm_probe()
614 if (fw_version[0] != rpm->data->version) { in qcom_rpm_probe()
620 rpm->data->version); in qcom_rpm_probe()
624 writel(fw_version[0], RPM_CTRL_REG(rpm, 0)); in qcom_rpm_probe()
625 writel(fw_version[1], RPM_CTRL_REG(rpm, 1)); in qcom_rpm_probe()
626 writel(fw_version[2], RPM_CTRL_REG(rpm, 2)); in qcom_rpm_probe()
637 rpm); in qcom_rpm_probe()
652 rpm); in qcom_rpm_probe()
663 rpm); in qcom_rpm_probe()