Lines Matching full:rpm

18 #include <dt-bindings/mfd/qcom-rpm.h>
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
436 { .compatible = "qcom,rpm-apq8064", .data = &apq8064_template },
437 { .compatible = "qcom,rpm-msm8660", .data = &msm8660_template },
438 { .compatible = "qcom,rpm-msm8960", .data = &msm8960_template },
439 { .compatible = "qcom,rpm-ipq8064", .data = &ipq806x_template },
440 { .compatible = "qcom,rpm-mdm9615", .data = &mdm9615_template },
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()
534 struct qcom_rpm *rpm; in qcom_rpm_probe() local
541 rpm = devm_kzalloc(&pdev->dev, sizeof(*rpm), GFP_KERNEL); in qcom_rpm_probe()
542 if (!rpm) in qcom_rpm_probe()
545 rpm->dev = &pdev->dev; in qcom_rpm_probe()
546 mutex_init(&rpm->lock); in qcom_rpm_probe()
547 init_completion(&rpm->ack); in qcom_rpm_probe()
550 rpm->ramclk = devm_clk_get(&pdev->dev, "ram"); in qcom_rpm_probe()
551 if (IS_ERR(rpm->ramclk)) { in qcom_rpm_probe()
552 ret = PTR_ERR(rpm->ramclk); in qcom_rpm_probe()
559 rpm->ramclk = NULL; in qcom_rpm_probe()
561 clk_prepare_enable(rpm->ramclk); /* Accepts NULL */ in qcom_rpm_probe()
578 rpm->data = match->data; in qcom_rpm_probe()
581 rpm->status_regs = devm_ioremap_resource(&pdev->dev, res); in qcom_rpm_probe()
582 if (IS_ERR(rpm->status_regs)) in qcom_rpm_probe()
583 return PTR_ERR(rpm->status_regs); in qcom_rpm_probe()
584 rpm->ctrl_regs = rpm->status_regs + 0x400; in qcom_rpm_probe()
585 rpm->req_regs = rpm->status_regs + 0x600; in qcom_rpm_probe()
593 rpm->ipc_regmap = syscon_node_to_regmap(syscon_np); in qcom_rpm_probe()
595 if (IS_ERR(rpm->ipc_regmap)) in qcom_rpm_probe()
596 return PTR_ERR(rpm->ipc_regmap); in qcom_rpm_probe()
599 &rpm->ipc_offset); in qcom_rpm_probe()
606 &rpm->ipc_bit); in qcom_rpm_probe()
612 dev_set_drvdata(&pdev->dev, rpm); in qcom_rpm_probe()
614 fw_version[0] = readl(RPM_STATUS_REG(rpm, 0)); in qcom_rpm_probe()
615 fw_version[1] = readl(RPM_STATUS_REG(rpm, 1)); in qcom_rpm_probe()
616 fw_version[2] = readl(RPM_STATUS_REG(rpm, 2)); in qcom_rpm_probe()
617 if (fw_version[0] != rpm->data->version) { in qcom_rpm_probe()
619 "RPM version %u.%u.%u incompatible with driver version %u", in qcom_rpm_probe()
623 rpm->data->version); in qcom_rpm_probe()
627 writel(fw_version[0], RPM_CTRL_REG(rpm, 0)); in qcom_rpm_probe()
628 writel(fw_version[1], RPM_CTRL_REG(rpm, 1)); in qcom_rpm_probe()
629 writel(fw_version[2], RPM_CTRL_REG(rpm, 2)); in qcom_rpm_probe()
631 dev_info(&pdev->dev, "RPM firmware %u.%u.%u\n", fw_version[0], in qcom_rpm_probe()
640 rpm); in qcom_rpm_probe()
655 rpm); in qcom_rpm_probe()
666 rpm); in qcom_rpm_probe()
681 struct qcom_rpm *rpm = dev_get_drvdata(&pdev->dev); in qcom_rpm_remove() local
684 clk_disable_unprepare(rpm->ramclk); in qcom_rpm_remove()