From 801ff98205b9b0dd7342044f0efb845d59e8036f Mon Sep 17 00:00:00 2001 From: Saurabh Ambulkar Date: Wed, 26 Aug 2020 11:10:41 +0530 Subject: [PATCH] drivers: soc: Add support for SM6150 llcc driver Add support for sm6150-llcc driver. The driver is written by taking reference from sm6150-llcc driver in msm-4.14 kernel at commit id "5d390f121ba7". Change-Id: I53f200460e3b18dfe3453923745104f8e804b9c5 Signed-off-by: Saurabh Ambulkar --- drivers/soc/qcom/Kconfig | 9 ++++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/llcc-sm6150.c | 92 ++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 drivers/soc/qcom/llcc-sm6150.c diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 60576ea67049..708108024b07 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -221,6 +221,15 @@ config QCOM_SDMSHRIKE_LLCC can start using the LLCC slices. If unsure, say n. +config QCOM_SM6150_LLCC + tristate "Qualcomm Technologies, Inc. SM6150 LLCC driver" + depends on QCOM_LLCC + help + Say yes here to enable the LLCC driver for SM6150. This is 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 d37792330201..18ce7149193d 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -46,6 +46,7 @@ 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_SDMSHRIKE_LLCC) += llcc-sdmshrike.o +obj-$(CONFIG_QCOM_SM6150_LLCC) += llcc-sm6150.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-sm6150.c b/drivers/soc/qcom/llcc-sm6150.c new file mode 100644 index 000000000000..582b7a43cc2f --- /dev/null +++ b/drivers/soc/qcom/llcc-sm6150.c @@ -0,0 +1,92 @@ +// 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 sm6150_data[] = { + SCT_ENTRY(LLCC_CPUSS, 1, 1, 128, 1, 0, 0xF, 0x0, 0, 0, 0, 1, 1), + SCT_ENTRY(LLCC_MDM, 8, 8, 256, 0, 1, 0xF, 0x0, 0, 0, 0, 1, 0), + SCT_ENTRY(LLCC_GPUHTW, 11, 11, 128, 1, 1, 0xF, 0x0, 0, 0, 0, 1, 0), + SCT_ENTRY(LLCC_GPU, 12, 12, 128, 1, 0, 0xF, 0x0, 0, 0, 0, 1, 0), +}; + +static int sm6150_qcom_llcc_probe(struct platform_device *pdev) +{ + return qcom_llcc_probe(pdev, sm6150_data, + ARRAY_SIZE(sm6150_data)); +} + +static const struct of_device_id sm6150_qcom_llcc_of_match[] = { + { .compatible = "qcom,sm6150-llcc", }, + { }, +}; + +static struct platform_driver sm6150_qcom_llcc_driver = { + .driver = { + .name = "sm6150-llcc", + .of_match_table = sm6150_qcom_llcc_of_match, + }, + .probe = sm6150_qcom_llcc_probe, + .remove = qcom_llcc_remove, +}; + +static int __init sm6150_init_qcom_llcc_init(void) +{ + return platform_driver_register(&sm6150_qcom_llcc_driver); +} +module_init(sm6150_init_qcom_llcc_init); + +static void __exit sm6150_exit_qcom_llcc_exit(void) +{ + platform_driver_unregister(&sm6150_qcom_llcc_driver); +} +module_exit(sm6150_exit_qcom_llcc_exit); + +MODULE_DESCRIPTION("Qualcomm Technologies Inc sm6150 LLCC driver"); +MODULE_LICENSE("GPL v2");