blob: f94cb6a51936a0ca98ac73c8ff109970db4c5be4 [file] [log] [blame]
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +05301/*
Murat Sezgin84ca6512014-04-14 13:57:24 -07002 **************************************************************************
3 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
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, 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
25#include <mach/msm_nss_gmac.h>
26#include <mach/msm_nss_crypto.h>
27#include <mach/msm_bus_board.h>
28#include <mach/msm_bus.h>
Murat Sezgin84ca6512014-04-14 13:57:24 -070029#include <nss_api_if.h>
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053030
31/*
32 * NSS PM debug macros
33 */
34#if (NSS_PM_DEBUG_LEVEL < 1)
35#define nss_pm_assert(fmt, args...)
36#else
37#define nss_pm_assert(c) if (!(c)) { BUG_ON(!(c)); }
38#endif
39
40#if (NSS_PM_DEBUG_LEVEL < 2)
41#define nss_pm_warning(fmt, args...)
42#else
43#define nss_pm_warning(fmt, args...) printk(KERN_WARNING "nss_pm:"fmt, ##args)
44#endif
45
46#if (NSS_PM_DEBUG_LEVEL < 3)
47#define nss_pm_info(fmt, args...)
48#else
49#define nss_pm_info(fmt, args...) printk(KERN_INFO "nss_pm:"fmt, ##args)
50#endif
51
52#if (NSS_PM_DEBUG_LEVEL < 4)
53#define nss_pm_trace(fmt, args...)
54#else
55#define nss_pm_trace(fmt, args...) printk(KERN_DEBUG "nss_pm:"fmt, ##args)
56#endif
57
Pamidipati, Vijay5d27d812013-11-22 16:48:11 +053058/*
59 * Define this to use NETAP driver also request for NSS Fab1 BW on behalf of GMAC driver
60 */
61#define NSS_PM_NETAP_GMAC_SCALING 1
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053062
63/*
64 * PM Client data structure
65 */
66typedef struct {
67 uint32_t bus_perf_client;
68 uint32_t clk_handle;
69 uint32_t current_perf_lvl;
70 uint32_t auto_scale;
71 struct dentry *dentry;
Pamidipati, Vijay3e053882013-12-03 17:34:31 +053072 nss_pm_client_t client_id;
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053073} nss_pm_client_data_t;
74
75/*
76 * NSS PM driver context
77 */
78struct nss_pm_global_ctx {
79 struct dentry *pm_dentry;
Pamidipati, Vijayf9b5a272014-01-22 14:24:10 +053080 bool turbo_support;
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +053081 nss_pm_client_data_t nss_pm_client[NSS_PM_MAX_CLIENTS];
82};
83
84/*
85 * Macro defining Bus vector for GMAC driver
86 */
87#define GMAC_BW_MBPS(_data_bw, _desc_bw) \
88{ \
89 .vectors = (struct msm_bus_vectors[]){ \
90 {\
91 .src = MSM_BUS_MASTER_NSS_GMAC_0, \
92 .dst = MSM_BUS_SLAVE_EBI_CH0, \
93 .ab = (_data_bw) * 16 * 1000000ULL, \
94 .ib = (_data_bw) * 16 * 1000000ULL, \
95 }, \
96 { \
97 .src = MSM_BUS_MASTER_NSS_GMAC_0, \
98 .dst = MSM_BUS_SLAVE_NSS_TCM, \
99 .ab = (_desc_bw) * 8 * 1000000ULL, \
100 .ib = (_desc_bw) * 8 * 1000000ULL, \
101 }, \
102 }, \
103 .num_paths = 2, \
104}
105
106/*
107 * Macro defining Bus vector for NSS crypto driver
108 */
109#define CRYPTO_BW_MBPS(_data_bw, _desc_bw) \
110{ \
111 .vectors = (struct msm_bus_vectors[]){ \
112 {\
113 .src = MSM_BUS_MASTER_NSS_CRYPTO5_0, \
114 .dst = MSM_BUS_SLAVE_EBI_CH0, \
115 .ab = (_data_bw) * 16 * 1000000ULL, \
116 .ib = (_data_bw) * 16 * 1000000ULL, \
117 }, \
118 { \
119 .src = MSM_BUS_MASTER_NSS_CRYPTO5_0, \
120 .dst = MSM_BUS_SLAVE_NSS_TCM, \
121 .ab = (_desc_bw) * 8 * 1000000ULL, \
122 .ib = (_desc_bw) * 8 * 1000000ULL, \
123 }, \
124 }, \
125 .num_paths = 2, \
126}
127
128/*
129 * Macro defining Bus vector for NSS driver
130 *
131 */
132#define NETAP_BW_MBPS(_data_bw, _desc_bw) \
133{ \
134 .vectors = (struct msm_bus_vectors[]){ \
135 {\
136 .src = MSM_BUS_MASTER_UBI32_0, \
137 .dst = MSM_BUS_SLAVE_EBI_CH0, \
138 .ab = (_data_bw) * 16 * 1000000ULL, \
139 .ib = (_data_bw) * 16 * 1000000ULL, \
140 }, \
141 { \
142 .src = MSM_BUS_MASTER_UBI32_0, \
143 .dst = MSM_BUS_SLAVE_NSS_TCM, \
144 .ab = (_desc_bw) * 8 * 1000000ULL, \
145 .ib = (_desc_bw) * 8 * 1000000ULL, \
146 }, \
147 }, \
148 .num_paths = 2, \
149}
150
151/*
152 * Initialize NSS PM top level structures
153 */
154void nss_pm_init(void);
155
Pamidipati, Vijayf9b5a272014-01-22 14:24:10 +0530156/*
157 * Sets the turbo support flag globally for all PM clients
158 */
159void nss_pm_set_turbo(void);
160
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +0530161#endif /** __NSS_PM_H */