Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 1 | /* |
Murat Sezgin | 84ca651 | 2014-04-14 13:57:24 -0700 | [diff] [blame] | 2 | ************************************************************************** |
Arunkumar | 5ce0a6e | 2015-10-08 21:18:18 +0530 | [diff] [blame] | 3 | * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. |
Murat Sezgin | 84ca651 | 2014-04-14 13:57:24 -0700 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all copies. |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
Murat Sezgin | 84ca651 | 2014-04-14 13:57:24 -0700 | [diff] [blame] | 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 13 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | ************************************************************************** |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * nss_pm.h |
| 19 | * NSS PM Driver header file |
| 20 | */ |
| 21 | |
| 22 | #ifndef __NSS_PM_H |
| 23 | #define __NSS_PM_H |
| 24 | |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 25 | #include<linux/version.h> |
| 26 | |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 27 | #include <mach/msm_nss_gmac.h> |
| 28 | #include <mach/msm_nss_crypto.h> |
| 29 | #include <mach/msm_bus_board.h> |
| 30 | #include <mach/msm_bus.h> |
Sundarajan Srinivasan | 4691ba6 | 2014-11-07 11:24:07 -0800 | [diff] [blame] | 31 | |
Murat Sezgin | 84ca651 | 2014-04-14 13:57:24 -0700 | [diff] [blame] | 32 | #include <nss_api_if.h> |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 33 | |
| 34 | /* |
| 35 | * NSS PM debug macros |
| 36 | */ |
| 37 | #if (NSS_PM_DEBUG_LEVEL < 1) |
| 38 | #define nss_pm_assert(fmt, args...) |
| 39 | #else |
| 40 | #define nss_pm_assert(c) if (!(c)) { BUG_ON(!(c)); } |
| 41 | #endif |
| 42 | |
| 43 | #if (NSS_PM_DEBUG_LEVEL < 2) |
| 44 | #define nss_pm_warning(fmt, args...) |
| 45 | #else |
| 46 | #define nss_pm_warning(fmt, args...) printk(KERN_WARNING "nss_pm:"fmt, ##args) |
| 47 | #endif |
| 48 | |
| 49 | #if (NSS_PM_DEBUG_LEVEL < 3) |
| 50 | #define nss_pm_info(fmt, args...) |
| 51 | #else |
| 52 | #define nss_pm_info(fmt, args...) printk(KERN_INFO "nss_pm:"fmt, ##args) |
| 53 | #endif |
| 54 | |
| 55 | #if (NSS_PM_DEBUG_LEVEL < 4) |
| 56 | #define nss_pm_trace(fmt, args...) |
| 57 | #else |
| 58 | #define nss_pm_trace(fmt, args...) printk(KERN_DEBUG "nss_pm:"fmt, ##args) |
| 59 | #endif |
| 60 | |
Pamidipati, Vijay | 5d27d81 | 2013-11-22 16:48:11 +0530 | [diff] [blame] | 61 | /* |
| 62 | * Define this to use NETAP driver also request for NSS Fab1 BW on behalf of GMAC driver |
| 63 | */ |
| 64 | #define NSS_PM_NETAP_GMAC_SCALING 1 |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 65 | |
| 66 | /* |
| 67 | * PM Client data structure |
| 68 | */ |
| 69 | typedef struct { |
| 70 | uint32_t bus_perf_client; |
| 71 | uint32_t clk_handle; |
| 72 | uint32_t current_perf_lvl; |
| 73 | uint32_t auto_scale; |
| 74 | struct dentry *dentry; |
Pamidipati, Vijay | 3e05388 | 2013-12-03 17:34:31 +0530 | [diff] [blame] | 75 | nss_pm_client_t client_id; |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 76 | } nss_pm_client_data_t; |
| 77 | |
| 78 | /* |
| 79 | * NSS PM driver context |
| 80 | */ |
| 81 | struct nss_pm_global_ctx { |
| 82 | struct dentry *pm_dentry; |
Pamidipati, Vijay | f9b5a27 | 2014-01-22 14:24:10 +0530 | [diff] [blame] | 83 | bool turbo_support; |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 84 | nss_pm_client_data_t nss_pm_client[NSS_PM_MAX_CLIENTS]; |
| 85 | }; |
| 86 | |
| 87 | /* |
| 88 | * Macro defining Bus vector for GMAC driver |
| 89 | */ |
| 90 | #define GMAC_BW_MBPS(_data_bw, _desc_bw) \ |
| 91 | { \ |
| 92 | .vectors = (struct msm_bus_vectors[]){ \ |
| 93 | {\ |
| 94 | .src = MSM_BUS_MASTER_NSS_GMAC_0, \ |
| 95 | .dst = MSM_BUS_SLAVE_EBI_CH0, \ |
| 96 | .ab = (_data_bw) * 16 * 1000000ULL, \ |
| 97 | .ib = (_data_bw) * 16 * 1000000ULL, \ |
| 98 | }, \ |
| 99 | { \ |
| 100 | .src = MSM_BUS_MASTER_NSS_GMAC_0, \ |
| 101 | .dst = MSM_BUS_SLAVE_NSS_TCM, \ |
| 102 | .ab = (_desc_bw) * 8 * 1000000ULL, \ |
| 103 | .ib = (_desc_bw) * 8 * 1000000ULL, \ |
| 104 | }, \ |
| 105 | }, \ |
| 106 | .num_paths = 2, \ |
| 107 | } |
| 108 | |
| 109 | /* |
| 110 | * Macro defining Bus vector for NSS crypto driver |
| 111 | */ |
| 112 | #define CRYPTO_BW_MBPS(_data_bw, _desc_bw) \ |
| 113 | { \ |
| 114 | .vectors = (struct msm_bus_vectors[]){ \ |
| 115 | {\ |
| 116 | .src = MSM_BUS_MASTER_NSS_CRYPTO5_0, \ |
| 117 | .dst = MSM_BUS_SLAVE_EBI_CH0, \ |
Radha krishna Simha Jiguru | f364769 | 2015-08-18 19:37:04 +0530 | [diff] [blame] | 118 | .ab = 0, \ |
| 119 | .ib = 0, \ |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 120 | }, \ |
| 121 | { \ |
| 122 | .src = MSM_BUS_MASTER_NSS_CRYPTO5_0, \ |
| 123 | .dst = MSM_BUS_SLAVE_NSS_TCM, \ |
Arunkumar | 5ce0a6e | 2015-10-08 21:18:18 +0530 | [diff] [blame] | 124 | .ab = (_desc_bw) * 8 * 1000000ULL, \ |
| 125 | .ib = (_desc_bw) * 8 * 1000000ULL, \ |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 126 | }, \ |
| 127 | }, \ |
| 128 | .num_paths = 2, \ |
| 129 | } |
| 130 | |
| 131 | /* |
| 132 | * Macro defining Bus vector for NSS driver |
| 133 | * |
| 134 | */ |
| 135 | #define NETAP_BW_MBPS(_data_bw, _desc_bw) \ |
| 136 | { \ |
| 137 | .vectors = (struct msm_bus_vectors[]){ \ |
| 138 | {\ |
| 139 | .src = MSM_BUS_MASTER_UBI32_0, \ |
| 140 | .dst = MSM_BUS_SLAVE_EBI_CH0, \ |
| 141 | .ab = (_data_bw) * 16 * 1000000ULL, \ |
| 142 | .ib = (_data_bw) * 16 * 1000000ULL, \ |
| 143 | }, \ |
| 144 | { \ |
| 145 | .src = MSM_BUS_MASTER_UBI32_0, \ |
| 146 | .dst = MSM_BUS_SLAVE_NSS_TCM, \ |
| 147 | .ab = (_desc_bw) * 8 * 1000000ULL, \ |
| 148 | .ib = (_desc_bw) * 8 * 1000000ULL, \ |
| 149 | }, \ |
| 150 | }, \ |
| 151 | .num_paths = 2, \ |
| 152 | } |
| 153 | |
| 154 | /* |
| 155 | * Initialize NSS PM top level structures |
| 156 | */ |
| 157 | void nss_pm_init(void); |
| 158 | |
Pamidipati, Vijay | f9b5a27 | 2014-01-22 14:24:10 +0530 | [diff] [blame] | 159 | /* |
| 160 | * Sets the turbo support flag globally for all PM clients |
| 161 | */ |
| 162 | void nss_pm_set_turbo(void); |
| 163 | |
Pamidipati, Vijay | 7f413b5 | 2013-09-24 19:07:12 +0530 | [diff] [blame] | 164 | #endif /** __NSS_PM_H */ |