Channagoud Kadabi | bca22fa | 2017-01-11 13:45:19 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 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> |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 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 | |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 59 | static struct llcc_slice_config sdm845_data[] = { |
Channagoud Kadabi | 6f28a15 | 2017-06-26 12:44:21 -0700 | [diff] [blame] | 60 | 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 Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 79 | static int sdm845_qcom_llcc_probe(struct platform_device *pdev) |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 80 | { |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 81 | return qcom_llcc_probe(pdev, sdm845_data, |
| 82 | ARRAY_SIZE(sdm845_data)); |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 85 | static const struct of_device_id sdm845_qcom_llcc_of_match[] = { |
| 86 | { .compatible = "qcom,sdm845-llcc", }, |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 87 | { }, |
| 88 | }; |
| 89 | |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 90 | static struct platform_driver sdm845_qcom_llcc_driver = { |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 91 | .driver = { |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 92 | .name = "sdm845-llcc", |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 93 | .owner = THIS_MODULE, |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 94 | .of_match_table = sdm845_qcom_llcc_of_match, |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 95 | }, |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 96 | .probe = sdm845_qcom_llcc_probe, |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 97 | .remove = qcom_llcc_remove, |
| 98 | }; |
| 99 | |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 100 | static int __init sdm845_init_qcom_llcc_init(void) |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 101 | { |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 102 | return platform_driver_register(&sdm845_qcom_llcc_driver); |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 103 | } |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 104 | module_init(sdm845_init_qcom_llcc_init); |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 105 | |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 106 | static void __exit sdm845_exit_qcom_llcc_exit(void) |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 107 | { |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 108 | platform_driver_unregister(&sdm845_qcom_llcc_driver); |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 109 | } |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 110 | module_exit(sdm845_exit_qcom_llcc_exit); |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 111 | |
Kyle Yan | 6a20fae | 2017-02-14 13:34:41 -0800 | [diff] [blame] | 112 | MODULE_DESCRIPTION("QTI sdm845 LLCC driver"); |
Channagoud Kadabi | b1fec94 | 2016-08-17 17:00:26 -0700 | [diff] [blame] | 113 | MODULE_LICENSE("GPL v2"); |