From ff6d3c8d994d505045d7df581b45b17e317db759 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Date: Tue, 19 May 2020 17:12:46 +0530 Subject: [PATCH] drivers: soc: Add support for sm8150 llcc driver Add support for sm8150-llcc driver. The driver is written by taking reference from sm8150-llcc driver in msm-4.14 kernel at commit id "f6969550b4". Change-Id: Iaa7711f56066fc1c8e098beaf19185522bb5581d Signed-off-by: Vivek Kumar --- drivers/soc/qcom/Kconfig | 9 +++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/llcc-sm8150.c | 109 +++++++++++++++++++++++++++++ include/linux/soc/qcom/llcc-qcom.h | 1 + 4 files changed, 120 insertions(+) create mode 100644 drivers/soc/qcom/llcc-sm8150.c diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 04855f925da3..3f0402d9306a 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -203,6 +203,15 @@ config QCOM_YUPIK_LLCC can start using the LLCC slices. If unsure, say n. +config QCOM_SM8150_LLCC + tristate "Qualcomm Technologies, Inc. SM8150 LLCC driver" + depends on QCOM_LLCC + help + Say y or m here to enable the LLCC driver for SM8150 platform. + This provides data required to configure LLCC so that clients + can start using the LLCC slices. + If unsure, say n. + config QCOM_SDM845_LLCC tristate "Qualcomm Technologies, Inc. SDM845 LLCC driver" depends on QCOM_LLCC diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index fc105b0abb0b..ea5a2f91ffcf 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -44,6 +44,7 @@ obj-$(CONFIG_QCOM_LAHAINA_LLCC) += llcc-lahaina.o obj-$(CONFIG_QCOM_SDXLEMUR_LLCC) += llcc-sdxlemur.o obj-$(CONFIG_QCOM_SHIMA_LLCC) += llcc-shima.o obj-$(CONFIG_QCOM_YUPIK_LLCC) += llcc-yupik.o +obj-$(CONFIG_QCOM_SM8150_LLCC) += llcc-sm8150.o obj-$(CONFIG_QCOM_MINIDUMP) += msm_minidump.o minidump_log.o obj-$(CONFIG_QCOM_MEM_OFFLINE) += mem-offline.o obj-$(CONFIG_QCOM_MEM_BUF) += mem-buf.o mem_buf_dma_buf.o diff --git a/drivers/soc/qcom/llcc-sm8150.c b/drivers/soc/qcom/llcc-sm8150.c new file mode 100644 index 000000000000..3c76ecb1c2ec --- /dev/null +++ b/drivers/soc/qcom/llcc-sm8150.c @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2017-2018,2020 The Linux Foundation. All rights reserved. + * + */ + +#include +#include +#include +#include +#include + +/* + * SCT entry contains of the following parameters + * name: Name of the client's use case for which the llcc slice is used + * uid: Unique id for the client's use case + * slice_id: llcc slice id for each client + * max_cap: The maximum capacity of the cache slice provided in KB + * priority: Priority of the client used to select victim line for replacement + * fixed_size: Determine of the slice has a fixed capacity + * bonus_ways: Bonus ways to be used by any slice, bonus way is used only if + * it't not a reserved way. + * res_ways: Reserved ways for the cache slice, the reserved ways cannot be used + * by any other client than the one its assigned to. + * cache_mode: Each slice operates as a cache, this controls the mode of the + * slice normal or TCM + * probe_target_ways: Determines what ways to probe for access hit. When + * configured to 1 only bonus and reserved ways are probed. + * when configured to 0 all ways in llcc are probed. + * dis_cap_alloc: Disable capacity based allocation for a client + * retain_on_pc: If this bit is set and client has maitained active vote + * then the ways assigned to this client are not flushed on power + * collapse. + * activate_on_init: Activate the slice immidiately after the SCT is programmed + */ +#define SCT_ENTRY(uid, sid, mc, p, fs, bway, rway, cmod, ptw, dca, wse, rp, a) \ + { .usecase_id = uid, \ + .slice_id = sid, \ + .max_cap = mc, \ + .priority = p, \ + .fixed_size = fs, \ + .bonus_ways = bway, \ + .res_ways = rway, \ + .cache_mode = cmod, \ + .probe_target_ways = ptw, \ + .dis_cap_alloc = dca, \ + .write_scid_en = wse, \ + .retain_on_pc = rp, \ + .activate_on_init = a, \ + } + +static struct llcc_slice_config sm8150_data[] = { + SC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, 0, 0, 1, 0), + SCT_ENTRY(LLCC_NPU, 23, 3072, 1, 1, 0xFFF, 0x0, 0, 0, 0, 0, 1, 0), + SCT_ENTRY(LLCC_WLNHW, 24, 3072, 1, 1, 0xFFF, 0x0, 0, 0, 0, 0, 1, 0), + SCT_ENTRY(LLCC_MDMVPE, 29, 256, 1, 1, 0xF, 0x0, 0, 0, 0, 0, 1, 0), + SCT_ENTRY(LLCC_APTCM, 30, 256, 3, 1, 0x0, 0x1, 1, 0, 0, 0, 0, 0), + SCT_ENTRY(LLCC_WRTCH, 31, 128, 1, 1, 0xFFF, 0x0, 0, 0, 0, 0, 0, 0), +}; + +static int sm8150_qcom_llcc_probe(struct platform_device *pdev) +{ + return qcom_llcc_probe(pdev, sm8150_data, + ARRAY_SIZE(sm8150_data)); +} + +static const struct of_device_id sm8150_qcom_llcc_of_match[] = { + { .compatible = "qcom,sm8150-llcc", }, + { }, +}; + +static struct platform_driver sm8150_qcom_llcc_driver = { + .driver = { + .name = "sm8150-llcc", + .of_match_table = sm8150_qcom_llcc_of_match, + }, + .probe = sm8150_qcom_llcc_probe, + .remove = qcom_llcc_remove, +}; + +static int __init sm8150_init_qcom_llcc_init(void) +{ + return platform_driver_register(&sm8150_qcom_llcc_driver); +} +module_init(sm8150_init_qcom_llcc_init); + +static void __exit sm8150_exit_qcom_llcc_exit(void) +{ + platform_driver_unregister(&sm8150_qcom_llcc_driver); +} +module_exit(sm8150_exit_qcom_llcc_exit); + +MODULE_DESCRIPTION("Qualcomm Technologies Inc sm8150 LLCC driver"); +MODULE_LICENSE("GPL v2"); diff --git a/include/linux/soc/qcom/llcc-qcom.h b/include/linux/soc/qcom/llcc-qcom.h index 7bcbe5b2a38d..6de5d6be4b71 100644 --- a/include/linux/soc/qcom/llcc-qcom.h +++ b/include/linux/soc/qcom/llcc-qcom.h @@ -27,6 +27,7 @@ #define LLCC_MDMHPFX 20 #define LLCC_MDMPNG 21 #define LLCC_AUDHW 22 +#define LLCC_NPU 23 #define LLCC_WLNHW 24 #define LLCC_CVP 28 #define LLCC_MDMVPE 29