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

Commit 682136f8 authored by Shiju Mathew's avatar Shiju Mathew
Browse files

msm: thermal: Add uio extension in KTM for memory mapping



Since /dev/mem node no longer available for userspace
IO memory access, add UIO support in KTM for userspace
app to access IO memory mapped region. A UIO device
will be in the format /dev/uioX. Userspace uses mmap()
on these devices to access registers/memory.

Change-Id: I7a1a258cdf76a327b77e0995c8dad2ea0be63577
Signed-off-by: default avatarShiju Mathew <shijum@codeaurora.org>
parent 4313aedf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ Required properties

Optional properties

- reg:                  Physical address for uio mapping
- qcom,core-limit-temp: Threshold temperature to start shutting down cores
			in degC
- qcom,core-temp-hysteresis: Degrees C below which the cores will be brought
@@ -225,6 +226,7 @@ Example:

	qcom,msm-thermal {
		compatible = "qcom,msm-thermal";
		reg = <0x70000 0x1000>;
		qcom,sensor-id = <0>;
		qcom,poll-ms = <250>;
		qcom,limit-temp = <60>;
+50 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
#include <linux/cpumask.h>
#include <linux/suspend.h>
#include <linux/uaccess.h>
#include <linux/uio_driver.h>

#define CREATE_TRACE_POINTS
#define TRACE_MSM_THERMAL
@@ -72,6 +73,7 @@
#define MSM_THERMAL_THRESH_UPDATE "update"
#define DEVM_NAME_MAX 30
#define HOTPLUG_RETRY_INTERVAL_MS 100
#define UIO_VERSION "1.0"

#define VALIDATE_AND_SET_MASK(_node, _key, _mask, _cpu) \
	do { \
@@ -441,6 +443,50 @@ static ssize_t thermal_config_debugfs_write(struct file *file,
		_flag = 0; \
	} while (0)

static void uio_init(struct platform_device *pdev)
{
	int ret = 0;
	struct uio_info *uio_reg_info = NULL;
	struct resource *clnt_res = NULL;
	u32 mem_size = 0;
	phys_addr_t mem_pyhsical = 0;

	clnt_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!clnt_res) {
		pr_debug("resource not found\n");
		goto exit;
	}
	mem_size = resource_size(clnt_res);
	if (mem_size == 0) {
		pr_err("resource memory size is zero\n");
		goto exit;
	}

	uio_reg_info = devm_kzalloc(&pdev->dev, sizeof(struct uio_info),
			GFP_KERNEL);
	if (!uio_reg_info)
		goto exit;

	mem_pyhsical = clnt_res->start;

	/* Setup device */
	uio_reg_info->name = clnt_res->name;
	uio_reg_info->version = UIO_VERSION;
	uio_reg_info->mem[0].addr = mem_pyhsical;
	uio_reg_info->mem[0].size = mem_size;
	uio_reg_info->mem[0].memtype = UIO_MEM_PHYS;

	ret = uio_register_device(&pdev->dev, uio_reg_info);
	if (ret) {
		devm_kfree(&pdev->dev, uio_reg_info);
		pr_err("uio register failed ret=%d\n", ret);
		goto exit;
	}
	dev_set_drvdata(&pdev->dev, uio_reg_info);

exit:
	return;
}

static void get_cluster_mask(uint32_t cpu, cpumask_t *mask)
{
@@ -6865,7 +6911,9 @@ static int msm_thermal_dev_exit(struct platform_device *inp_dev)
	int i = 0;
	uint32_t _cluster = 0;
	struct cluster_info *cluster_ptr = NULL;
	struct uio_info *info = dev_get_drvdata(&inp_dev->dev);

	uio_unregister_device(info);
	unregister_reboot_notifier(&msm_thermal_reboot_notifier);
	if (msm_therm_debugfs && msm_therm_debugfs->parent)
		debugfs_remove_recursive(msm_therm_debugfs->parent);
@@ -6975,6 +7023,8 @@ int __init msm_thermal_late_init(void)
	create_cpu_topology_sysfs();
	create_thermal_debugfs();
	msm_thermal_add_bucket_info_nodes();
	uio_init(msm_thermal_info.pdev);

	return 0;
}
late_initcall(msm_thermal_late_init);