Lingutla Chandrasekhar | 9cecdb2 | 2017-05-30 10:36:38 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2017, The Linux Foundation. All rights reserved. |
| 2 | * |
| 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> |
| 17 | #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 | |
| 59 | static struct llcc_slice_config sdm670_data[] = { |
Kaushal Kumar | 36d256a | 2017-10-16 16:30:30 +0530 | [diff] [blame] | 60 | SCT_ENTRY("cpuss", 1, 1, 512, 1, 0, 0xF, 0x0, 0, 0, 1, 1, 1), |
| 61 | SCT_ENTRY("rotator", 4, 4, 384, 2, 1, 0x0, 0xE, 2, 0, 1, 1, 0), |
| 62 | SCT_ENTRY("voice", 5, 5, 512, 1, 0, 0xF, 0x0, 0, 0, 1, 1, 0), |
| 63 | SCT_ENTRY("audio", 6, 6, 512, 1, 0, 0xF, 0x0, 0, 0, 1, 1, 0), |
| 64 | SCT_ENTRY("modem", 8, 8, 512, 1, 0, 0xF, 0x0, 0, 0, 1, 1, 0), |
| 65 | SCT_ENTRY("gpu", 12, 12, 384, 1, 1, 0x0, 0x0, 0, 0, 1, 1, 0), |
Kaushal Kumar | e9fd36d | 2017-10-27 14:40:33 +0530 | [diff] [blame] | 66 | SCT_ENTRY("mmuhwt", 13, 13, 512, 1, 0, 0xF, 0x0, 0, 0, 1, 0, 1), |
Kaushal Kumar | 36d256a | 2017-10-16 16:30:30 +0530 | [diff] [blame] | 67 | SCT_ENTRY("audiohw", 22, 22, 512, 1, 1, 0xF, 0x0, 0, 0, 1, 1, 0), |
Lingutla Chandrasekhar | 9cecdb2 | 2017-05-30 10:36:38 +0530 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | static int sdm670_qcom_llcc_probe(struct platform_device *pdev) |
| 71 | { |
| 72 | return qcom_llcc_probe(pdev, sdm670_data, |
| 73 | ARRAY_SIZE(sdm670_data)); |
| 74 | } |
| 75 | |
| 76 | static const struct of_device_id sdm670_qcom_llcc_of_match[] = { |
| 77 | { .compatible = "qcom,sdm670-llcc", }, |
| 78 | { }, |
| 79 | }; |
| 80 | |
| 81 | static struct platform_driver sdm670_qcom_llcc_driver = { |
| 82 | .driver = { |
| 83 | .name = "sdm670-llcc", |
| 84 | .owner = THIS_MODULE, |
| 85 | .of_match_table = sdm670_qcom_llcc_of_match, |
| 86 | }, |
| 87 | .probe = sdm670_qcom_llcc_probe, |
| 88 | .remove = qcom_llcc_remove, |
| 89 | }; |
| 90 | |
| 91 | static int __init sdm670_init_qcom_llcc_init(void) |
| 92 | { |
| 93 | return platform_driver_register(&sdm670_qcom_llcc_driver); |
| 94 | } |
| 95 | module_init(sdm670_init_qcom_llcc_init); |
| 96 | |
| 97 | static void __exit sdm670_exit_qcom_llcc_exit(void) |
| 98 | { |
| 99 | platform_driver_unregister(&sdm670_qcom_llcc_driver); |
| 100 | } |
| 101 | module_exit(sdm670_exit_qcom_llcc_exit); |
| 102 | |
| 103 | MODULE_DESCRIPTION("QTI sdm670 LLCC driver"); |
| 104 | MODULE_LICENSE("GPL v2"); |