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

Commit 9a3a741d authored by David Dai's avatar David Dai
Browse files

msm: msm_bus: Add driver to fetch rpmh rsc clients



Change rpmh and command db APIS to match new version,
and add additional helper function to fetch device handles from
rsc nodes under rpmh.

Change-Id: Id2ae276105ba21eb313ee8acb83ca266db6064bc
Signed-off-by: default avatarDavid Dai <daidavid1@codeaurora.org>
parent 09b9f72c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ topology in order to apply client bandwidth requests.
The mandatory properties for bus driver are:

compatible:		"qcom,msm-bus-device"
compatible:		"qcom,msm-bus-rsc"

The register space associated with the bus devices are represented with
the following optional properties:
+96 −29
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#include <linux/device.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/of.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -20,6 +21,8 @@
#include "msm_bus_noc.h"
#include "msm_bus_bimc.h"

#define MSM_BUS_RSC_COUNT		(MSM_BUS_RSC_LAST-MSM_BUS_RSC_FIRST+1)

#define BCM_TCS_CMD_COMMIT_SHFT		30
#define BCM_TCS_CMD_COMMIT_MASK		0x40000000
#define BCM_TCS_CMD_VALID_SHFT		29
@@ -42,6 +45,13 @@ static struct list_head bcm_query_list_inorder[VCD_MAX_CNT];
static struct msm_bus_node_device_type *cur_rsc;
static bool init_time = true;

struct msm_bus_rsc_client {
	uint32_t rsc_id;
	struct device *client;
};

struct msm_bus_rsc_client rsc_clients[MSM_BUS_RSC_COUNT];

struct bcm_db {
	uint32_t unit_size;
	uint16_t width;
@@ -262,7 +272,7 @@ static int tcs_cmd_gen(struct msm_bus_node_device_type *cur_bcm,

	cmd->addr = cur_bcm->bcmdev->addr;
	cmd->data = BCM_TCS_CMD(commit, valid, vec_a, vec_b);
	cmd->complete = commit;
	cmd->wait = commit;

	return ret;
}
@@ -301,7 +311,7 @@ static int tcs_cmd_list_gen(int *n_active,
						&cur_bcm_clist[i])) {
					cmdlist_active[last_tcs].data |=
						BCM_TCS_CMD_COMMIT_MASK;
					cmdlist_active[last_tcs].complete
					cmdlist_active[last_tcs].wait
								= true;
				}
				continue;
@@ -344,8 +354,8 @@ static int tcs_cmd_list_gen(int *n_active,
						BCM_TCS_CMD_COMMIT_MASK;
					cmdlist_sleep[last_tcs].data |=
						BCM_TCS_CMD_COMMIT_MASK;
					cmdlist_wake[last_tcs].complete = true;
					cmdlist_sleep[last_tcs].complete = true;
					cmdlist_wake[last_tcs].wait = true;
					cmdlist_sleep[last_tcs].wait = true;
					idx++;
				}
				continue;
@@ -363,9 +373,6 @@ static int tcs_cmd_list_gen(int *n_active,
				cur_bcm->node_vec[ACTIVE_CTX].vec_a,
				cur_bcm->node_vec[ACTIVE_CTX].vec_b, commit);

			if (cur_rsc->rscdev->req_state == RPMH_AWAKE_STATE)
				commit = false;

			tcs_cmd_gen(cur_bcm, &cmdlist_sleep[k],
				cur_bcm->node_vec[DUAL_CTX].vec_a,
				cur_bcm->node_vec[DUAL_CTX].vec_b, commit);
@@ -543,7 +550,7 @@ int msm_bus_commit_data(struct list_head *clist)
	struct tcs_cmd *cmdlist_active = NULL;
	struct tcs_cmd *cmdlist_wake = NULL;
	struct tcs_cmd *cmdlist_sleep = NULL;
	struct rpmh_client *cur_mbox = NULL;
	struct device *cur_mbox = NULL;
	struct list_head *cur_bcm_clist = NULL;
	int n_active[VCD_MAX_CNT];
	int n_wake[VCD_MAX_CNT];
@@ -707,25 +714,17 @@ static void bcm_commit_single_req(struct msm_bus_node_device_type *cur_bcm,
					uint64_t vec_a, uint64_t vec_b)
{
	struct msm_bus_node_device_type *cur_rsc = NULL;
	struct rpmh_client *cur_mbox = NULL;
	struct tcs_cmd *cmd_active = NULL;
	struct device *cur_mbox = NULL;
	struct tcs_cmd cmd_active;

	if (!cur_bcm->node_info->num_rsc_devs)
		return;

	cmd_active = kzalloc(sizeof(struct tcs_cmd), GFP_KERNEL);

	if (!cmd_active)
		return;

	cur_rsc = to_msm_bus_node(cur_bcm->node_info->rsc_devs[0]);
	cur_mbox = cur_rsc->rscdev->mbox;

	tcs_cmd_gen(cur_bcm, cmd_active, vec_a, vec_b, true);
	rpmh_write_single(cur_mbox, RPMH_ACTIVE_ONLY_STATE,
					cmd_active->addr, cmd_active->data);

	kfree(cmd_active);
	tcs_cmd_gen(cur_bcm, &cmd_active, vec_a, vec_b, true);
	rpmh_write(cur_mbox, RPMH_ACTIVE_ONLY_STATE, &cmd_active, 1);
}

void *msm_bus_realloc_devmem(struct device *dev, void *p, size_t old_size,
@@ -1162,18 +1161,16 @@ static int msm_bus_bcm_init(struct device *dev,

	node_dev->bcmdev = bcmdev;
	bcmdev->name = pdata->bcmdev->name;

	if (!cmd_db_get_aux_data_len(bcmdev->name)) {
	if (!cmd_db_read_aux_data_len(bcmdev->name)) {
		MSM_BUS_ERR("%s: Error getting bcm info, bcm:%s",
			__func__, bcmdev->name);
		ret = -ENXIO;
		goto exit_bcm_init;
	}

	cmd_db_get_aux_data(bcmdev->name, (u8 *)&aux_data,
	cmd_db_read_aux_data(bcmdev->name, (u8 *)&aux_data,
						sizeof(struct bcm_db));

	bcmdev->addr = cmd_db_get_addr(bcmdev->name);
	bcmdev->addr = cmd_db_read_addr(bcmdev->name);
	bcmdev->width = (uint32_t)aux_data.width;
	bcmdev->clk_domain = aux_data.clk_domain;
	bcmdev->unit_size = aux_data.unit_size;
@@ -1212,12 +1209,19 @@ static int msm_bus_rsc_init(struct platform_device *pdev,

	node_dev->rscdev = rscdev;
	rscdev->req_state = pdata->rscdev->req_state;
	rscdev->mbox = rpmh_get_byname(pdev, node_dev->node_info->name);

	for (i = 0; i < MSM_BUS_RSC_COUNT; i++) {
		if (rsc_clients[i].rsc_id == node_dev->node_info->id) {
			rscdev->mbox = rsc_clients[i].client;

			if (IS_ERR_OR_NULL(rscdev->mbox)) {
		MSM_BUS_ERR("%s: Failed to get mbox:%s", __func__,
						node_dev->node_info->name);
				MSM_BUS_ERR("%s: Failed to get mbox:%s",
					__func__, node_dev->node_info->name);
			}
			break;
		}
	}


	// Add way to count # of VCDs, initialize LL
	for (i = 0; i < VCD_MAX_CNT; i++)
@@ -1911,6 +1915,42 @@ int msm_bus_device_rules_remove(struct platform_device *pdev)
	return 0;
}

static int msm_bus_rsc_probe(struct platform_device *pdev)
{
	int i = 0;
	int ret = 0;
	uint32_t rsc_id = 0;

	ret = of_property_read_u32(pdev->dev.of_node, "qcom,msm-bus-id",
								&rsc_id);
	if (ret) {
		MSM_BUS_ERR("unable to find msm bus id\n");
		return ret;
	}

	for (i = 0; i < MSM_BUS_RSC_COUNT - 1; i++) {
		if (!rsc_clients[i].rsc_id) {
			rsc_clients[i].rsc_id = rsc_id;
			rsc_clients[i].client = &pdev->dev;
			if (IS_ERR_OR_NULL(rsc_clients[i].client)) {
				rsc_clients[i].rsc_id = 0;
				rsc_clients[i].client = NULL;
			}
		}
	}
	return 0;
}

int msm_bus_rsc_remove(struct platform_device *pdev)
{
	int i;

	for (i = 0; i < MSM_BUS_RSC_COUNT - 1; i++) {
		rsc_clients[i].rsc_id = 0;
		rsc_clients[i].client = NULL;
	}
	return 0;
}

static const struct of_device_id rules_match[] = {
	{.compatible = "qcom,msm-bus-static-bw-rules"},
@@ -1940,6 +1980,32 @@ static struct platform_driver msm_bus_device_driver = {
	},
};

static const struct of_device_id rsc_match[] = {
	{.compatible = "qcom,msm-bus-rsc"},
	{}
};

static struct platform_driver msm_bus_rsc_driver = {
	.probe = msm_bus_rsc_probe,
	.remove = msm_bus_rsc_remove,
	.driver = {
		.name = "msm_bus_rsc",
		.of_match_table = rsc_match,
	},
};

int __init msm_bus_rsc_init_driver(void)
{
	int rc;

	rc =  platform_driver_register(&msm_bus_rsc_driver);
	if (rc)
		MSM_BUS_ERR("Failed to register msm bus rsc device driver");

	return rc;
}


int __init msm_bus_device_init_driver(void)
{
	int rc;
@@ -1961,5 +2027,6 @@ int __init msm_bus_device_late_init(void)
	init_time = false;
	return commit_late_init_data(false);
}
core_initcall(msm_bus_rsc_init_driver);
subsys_initcall(msm_bus_device_init_driver);
late_initcall_sync(msm_bus_device_late_init);
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ struct qos_bcm_type {
};

struct msm_bus_rsc_device_type {
	struct rpmh_client *mbox;
	struct device *mbox;
	struct list_head bcm_clist[VCD_MAX_CNT];
	int req_state;
	uint32_t acv[NUM_CTX];
+2 −0
Original line number Diff line number Diff line
@@ -89,8 +89,10 @@
#define	MSM_BUS_BCM_CO1 7041
#define	MSM_BUS_BCM_CO2 7042

#define	MSM_BUS_RSC_FIRST 8000
#define	MSM_BUS_RSC_APPS 8000
#define	MSM_BUS_RSC_DISP 8001
#define	MSM_BUS_RSC_LAST 8001

#define	MSM_BUS_BCM_MC0_DISPLAY 27000
#define	MSM_BUS_BCM_SH0_DISPLAY 27001