Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67b66a5e authored by Isaac J. Manjarres's avatar Isaac J. Manjarres
Browse files

soc: qcom: aop_ddrss_cmds: Add support to send DDRSS cmds to AOP



Introduce a driver to communicate with the AOP to change
the behavior of the DDRSS at boot.

Change-Id: I2f3f3d9fcc582555a4112b68a2ebff38f57b4c35
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent e37c51b4
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
AOP (Always-On-Processor) DDRSS Commands

The AOP DDRSS commands driver is used to send commands
to the AOP, using the mailbox interface, to affect the
behavior of the DDR.

Required properties

- compatible : "qcom,aop-ddrss-cmds"
- mbox : QMP mailbox phandle and channel identifier

Optional properties:
-mbox-name: name of the mailbox

Example:
	qcom,aop-ddrss-cmds {
		compatible = "qcom,aop-ddrss-cmds";
		mboxes = <&qmp_aop 0>;
	};
+6 −0
Original line number Diff line number Diff line
@@ -888,6 +888,12 @@ config QCOM_AOP_DDR_MESSAGING
	  This driver sends messages to the AOP to adjust the DDR frequency when
	  the device is rebooting, to ensure that the device is powered off
	  cleanly.

config QCOM_AOP_DDRSS_COMMANDS
	bool "Send commands to AOP to affect the behavior of the DDRSS"
	help
	  This driver allows messages to be sent to the AOP to affect the DDRSS
	  behavior.
endmenu

config QCOM_HYP_CORE_CTL
+1 −0
Original line number Diff line number Diff line
@@ -100,3 +100,4 @@ obj-$(CONFIG_QCOM_CX_IPEAK) += cx_ipeak.o
obj-$(CONFIG_QCOM_AOP_DDR_MESSAGING) += aop_ddr_msgs.o
obj-$(CONFIG_MSM_HAB) += hab/
obj-$(CONFIG_QCOM_HYP_CORE_CTL) += hyp_core_ctl.o
obj-$(CONFIG_QCOM_AOP_DDRSS_COMMANDS) += aop_ddrss_cmds.o
+80 −0
Original line number Diff line number Diff line
/* Copyright (c) 2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/mailbox_client.h>
#include <linux/mailbox/qmp.h>

#define MAX_AOP_MSG_LEN			96

static void send_aop_ddrss_cmd(struct mbox_chan *aop_mbox)
{
	struct qmp_pkt pkt;
	char mbox_msg[MAX_AOP_MSG_LEN + 1] = {0};
	int rc;

	strlcpy(mbox_msg, "{class: ddr, perfmode: on}", MAX_AOP_MSG_LEN);
	pkt.size = MAX_AOP_MSG_LEN;
	pkt.data = mbox_msg;

	rc = mbox_send_message(aop_mbox, &pkt);

	if (rc < 0)
		pr_err("Failed to send AOP DDRSS command\n");
}

static int aop_ddrss_cmd_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct mbox_client cl = {0};
	struct mbox_chan *aop_mbox;
	int rc = 0;

	cl.dev = dev;
	cl.tx_block = true;
	cl.tx_tout = 1000;
	cl.knows_txdone = false;
	aop_mbox = mbox_request_channel(&cl, 0);
	if (IS_ERR(aop_mbox)) {
		rc = PTR_ERR(aop_mbox);
		pr_err("Failed to get mailbox channel rc: %d\n", rc);
		return rc;
	}

	send_aop_ddrss_cmd(aop_mbox);
	mbox_free_channel(aop_mbox);

	return rc;
}

static const struct of_device_id of_aop_ddrss_cmd_match_tbl[] = {
	{ .compatible = "qcom,aop-ddrss-cmds", },
	{},
};
MODULE_DEVICE_TABLE(of, of_aop_ddrss_cmd_match_tbl);

static struct platform_driver aop_ddrss_cmd_driver = {
	.probe = aop_ddrss_cmd_probe,
	.driver = {
		.name = "aop-ddrss-cmds",
		.of_match_table = of_match_ptr(of_aop_ddrss_cmd_match_tbl),
	},
};
module_platform_driver(aop_ddrss_cmd_driver);

MODULE_DESCRIPTION("QTI AOP DDRSS Commands driver");
MODULE_LICENSE("GPL v2");