blob: 739c053e547880e8a2bd95f4c9e6f70651a329ba [file] [log] [blame]
Channagoud Kadabibca22fa2017-01-11 13:45:19 -08001/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
Channagoud Kadabib1fec942016-08-17 17:00:26 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/of.h>
16#include <linux/platform_device.h>
Channagoud Kadabib1fec942016-08-17 17:00:26 -070017#include <linux/soc/qcom/llcc-qcom.h>
18
19/*
20 * SCT entry contains of the following parameters
21 * name: Name of the client's use case for which the llcc slice is used
22 * uid: Unique id for the client's use case
23 * slice_id: llcc slice id for each client
24 * max_cap: The maximum capacity of the cache slice provided in KB
25 * priority: Priority of the client used to select victim line for replacement
26 * fixed_size: Determine of the slice has a fixed capacity
27 * bonus_ways: Bonus ways to be used by any slice, bonus way is used only if
28 * it't not a reserved way.
29 * res_ways: Reserved ways for the cache slice, the reserved ways cannot be used
30 * by any other client than the one its assigned to.
31 * cache_mode: Each slice operates as a cache, this controls the mode of the
32 * slice normal or TCM
33 * probe_target_ways: Determines what ways to probe for access hit. When
34 * configured to 1 only bonus and reseved ways are probed.
35 * when configured to 0 all ways in llcc are probed.
36 * dis_cap_alloc: Disable capacity based allocation for a client
37 * retain_on_pc: If this bit is set and client has maitained active vote
38 * then the ways assigned to this client are not flushed on power
39 * collapse.
40 * activate_on_init: Activate the slice immidiately after the SCT is programmed
41 */
42#define SCT_ENTRY(n, uid, sid, mc, p, fs, bway, rway, cmod, ptw, dca, rp, a) \
43 { \
44 .name = n, \
45 .usecase_id = uid, \
46 .slice_id = sid, \
47 .max_cap = mc, \
48 .priority = p, \
49 .fixed_size = fs, \
50 .bonus_ways = bway, \
51 .res_ways = rway, \
52 .cache_mode = cmod, \
53 .probe_target_ways = ptw, \
54 .dis_cap_alloc = dca, \
55 .retain_on_pc = rp, \
56 .activate_on_init = a, \
57 }
58
Kyle Yan6a20fae2017-02-14 13:34:41 -080059static struct llcc_slice_config sdm845_data[] = {
Channagoud Kadabi6f28a152017-06-26 12:44:21 -070060 SCT_ENTRY("cpuss", 1, 1, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 1),
61 SCT_ENTRY("vidsc0", 2, 2, 512, 2, 1, 0x0, 0x0F0, 0, 0, 1, 1, 0),
62 SCT_ENTRY("vidsc1", 3, 3, 512, 2, 1, 0x0, 0x0F0, 0, 0, 1, 1, 0),
63 SCT_ENTRY("rotator", 4, 4, 563, 2, 1, 0x0, 0x00F, 2, 0, 1, 1, 0),
64 SCT_ENTRY("voice", 5, 5, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
65 SCT_ENTRY("audio", 6, 6, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
66 SCT_ENTRY("modemhp_grow", 7, 7, 1024, 2, 0, 0x0F0, 0xF0F, 0, 0, 1, 1, 0),
67 SCT_ENTRY("modem", 8, 8, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
68 SCT_ENTRY("compute", 10, 10, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
69 SCT_ENTRY("gpuhtw", 11, 11, 512, 1, 1, 0x0, 0xC, 0, 0, 1, 1, 0),
70 SCT_ENTRY("gpu", 12, 12, 2560, 1, 0, 0xFF0, 0x3, 0, 0, 1, 1, 0),
71 SCT_ENTRY("mmuhwt", 13, 13, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 0, 1),
72 SCT_ENTRY("compute_dma", 15, 15, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
73 SCT_ENTRY("display", 16, 16, 3072, 1, 0, 0xFF0, 0xF, 0, 0, 1, 1, 0),
74 SCT_ENTRY("modemhp_fix", 20, 20, 1024, 2, 1, 0x0, 0xF00, 0, 0, 1, 1, 0),
75 SCT_ENTRY("modem_paging", 21, 21, 1024, 0, 1, 0x0, 0xF, 0, 0, 1, 1, 0),
76 SCT_ENTRY("audiohw", 22, 22, 1024, 1, 1, 0xFF0, 0xF, 0, 0, 1, 1, 0),
Channagoud Kadabib1fec942016-08-17 17:00:26 -070077};
78
Kyle Yan6a20fae2017-02-14 13:34:41 -080079static int sdm845_qcom_llcc_probe(struct platform_device *pdev)
Channagoud Kadabib1fec942016-08-17 17:00:26 -070080{
Kyle Yan6a20fae2017-02-14 13:34:41 -080081 return qcom_llcc_probe(pdev, sdm845_data,
82 ARRAY_SIZE(sdm845_data));
Channagoud Kadabib1fec942016-08-17 17:00:26 -070083}
84
Kyle Yan6a20fae2017-02-14 13:34:41 -080085static const struct of_device_id sdm845_qcom_llcc_of_match[] = {
86 { .compatible = "qcom,sdm845-llcc", },
Channagoud Kadabib1fec942016-08-17 17:00:26 -070087 { },
88};
89
Kyle Yan6a20fae2017-02-14 13:34:41 -080090static struct platform_driver sdm845_qcom_llcc_driver = {
Channagoud Kadabib1fec942016-08-17 17:00:26 -070091 .driver = {
Kyle Yan6a20fae2017-02-14 13:34:41 -080092 .name = "sdm845-llcc",
Channagoud Kadabib1fec942016-08-17 17:00:26 -070093 .owner = THIS_MODULE,
Kyle Yan6a20fae2017-02-14 13:34:41 -080094 .of_match_table = sdm845_qcom_llcc_of_match,
Channagoud Kadabib1fec942016-08-17 17:00:26 -070095 },
Kyle Yan6a20fae2017-02-14 13:34:41 -080096 .probe = sdm845_qcom_llcc_probe,
Channagoud Kadabib1fec942016-08-17 17:00:26 -070097 .remove = qcom_llcc_remove,
98};
99
Kyle Yan6a20fae2017-02-14 13:34:41 -0800100static int __init sdm845_init_qcom_llcc_init(void)
Channagoud Kadabib1fec942016-08-17 17:00:26 -0700101{
Kyle Yan6a20fae2017-02-14 13:34:41 -0800102 return platform_driver_register(&sdm845_qcom_llcc_driver);
Channagoud Kadabib1fec942016-08-17 17:00:26 -0700103}
Kyle Yan6a20fae2017-02-14 13:34:41 -0800104module_init(sdm845_init_qcom_llcc_init);
Channagoud Kadabib1fec942016-08-17 17:00:26 -0700105
Kyle Yan6a20fae2017-02-14 13:34:41 -0800106static void __exit sdm845_exit_qcom_llcc_exit(void)
Channagoud Kadabib1fec942016-08-17 17:00:26 -0700107{
Kyle Yan6a20fae2017-02-14 13:34:41 -0800108 platform_driver_unregister(&sdm845_qcom_llcc_driver);
Channagoud Kadabib1fec942016-08-17 17:00:26 -0700109}
Kyle Yan6a20fae2017-02-14 13:34:41 -0800110module_exit(sdm845_exit_qcom_llcc_exit);
Channagoud Kadabib1fec942016-08-17 17:00:26 -0700111
Kyle Yan6a20fae2017-02-14 13:34:41 -0800112MODULE_DESCRIPTION("QTI sdm845 LLCC driver");
Channagoud Kadabib1fec942016-08-17 17:00:26 -0700113MODULE_LICENSE("GPL v2");