blob: aaca293cb8b5c7913636d541809004a5c9171d6d [file] [log] [blame]
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +05301/*
Murat Sezgin84ca6512014-04-14 13:57:24 -07002 **************************************************************************
Arunkumar5ce0a6e2015-10-08 21:18:18 +05303 * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
Murat Sezgin84ca6512014-04-14 13:57:24 -07004 * 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, Vijay7f413b52013-09-24 19:07:12 +05307 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
Murat Sezgin84ca6512014-04-14 13:57:24 -07008 * 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, Vijay7f413b52013-09-24 19:07:12 +053015 */
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 Srinivasan4691ba62014-11-07 11:24:07 -080025#include<linux/version.h>
26
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053027#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 Srinivasan4691ba62014-11-07 11:24:07 -080031
Murat Sezgin84ca6512014-04-14 13:57:24 -070032#include <nss_api_if.h>
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053033
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, Vijay5d27d812013-11-22 16:48:11 +053061/*
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, Vijay7f413b52013-09-24 19:07:12 +053065
66/*
67 * PM Client data structure
68 */
69typedef 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, Vijay3e053882013-12-03 17:34:31 +053075 nss_pm_client_t client_id;
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053076} nss_pm_client_data_t;
77
78/*
79 * NSS PM driver context
80 */
81struct nss_pm_global_ctx {
82 struct dentry *pm_dentry;
Pamidipati, Vijayf9b5a272014-01-22 14:24:10 +053083 bool turbo_support;
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053084 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 Jiguruf3647692015-08-18 19:37:04 +0530118 .ab = 0, \
119 .ib = 0, \
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +0530120 }, \
121 { \
122 .src = MSM_BUS_MASTER_NSS_CRYPTO5_0, \
123 .dst = MSM_BUS_SLAVE_NSS_TCM, \
Arunkumar5ce0a6e2015-10-08 21:18:18 +0530124 .ab = (_desc_bw) * 8 * 1000000ULL, \
125 .ib = (_desc_bw) * 8 * 1000000ULL, \
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +0530126 }, \
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 */
157void nss_pm_init(void);
158
Pamidipati, Vijayf9b5a272014-01-22 14:24:10 +0530159/*
160 * Sets the turbo support flag globally for all PM clients
161 */
162void nss_pm_set_turbo(void);
163
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +0530164#endif /** __NSS_PM_H */