blob: cdd6a7516b4fd0b9bdb14e2e453b1f0ec9afcbb3 [file] [log] [blame]
Pamidipati, Vijay7f413b52013-09-24 19:07:12 +05301/*
2 * Copyright (c) 2013, Qualcomm Atheros Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
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
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>
29#include "nss_api_if.h"
30
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;
80 nss_pm_client_data_t nss_pm_client[NSS_PM_MAX_CLIENTS];
81};
82
83/*
84 * Macro defining Bus vector for GMAC driver
85 */
86#define GMAC_BW_MBPS(_data_bw, _desc_bw) \
87{ \
88 .vectors = (struct msm_bus_vectors[]){ \
89 {\
90 .src = MSM_BUS_MASTER_NSS_GMAC_0, \
91 .dst = MSM_BUS_SLAVE_EBI_CH0, \
92 .ab = (_data_bw) * 16 * 1000000ULL, \
93 .ib = (_data_bw) * 16 * 1000000ULL, \
94 }, \
95 { \
96 .src = MSM_BUS_MASTER_NSS_GMAC_0, \
97 .dst = MSM_BUS_SLAVE_NSS_TCM, \
98 .ab = (_desc_bw) * 8 * 1000000ULL, \
99 .ib = (_desc_bw) * 8 * 1000000ULL, \
100 }, \
101 }, \
102 .num_paths = 2, \
103}
104
105/*
106 * Macro defining Bus vector for NSS crypto driver
107 */
108#define CRYPTO_BW_MBPS(_data_bw, _desc_bw) \
109{ \
110 .vectors = (struct msm_bus_vectors[]){ \
111 {\
112 .src = MSM_BUS_MASTER_NSS_CRYPTO5_0, \
113 .dst = MSM_BUS_SLAVE_EBI_CH0, \
114 .ab = (_data_bw) * 16 * 1000000ULL, \
115 .ib = (_data_bw) * 16 * 1000000ULL, \
116 }, \
117 { \
118 .src = MSM_BUS_MASTER_NSS_CRYPTO5_0, \
119 .dst = MSM_BUS_SLAVE_NSS_TCM, \
120 .ab = (_desc_bw) * 8 * 1000000ULL, \
121 .ib = (_desc_bw) * 8 * 1000000ULL, \
122 }, \
123 }, \
124 .num_paths = 2, \
125}
126
127/*
128 * Macro defining Bus vector for NSS driver
129 *
130 */
131#define NETAP_BW_MBPS(_data_bw, _desc_bw) \
132{ \
133 .vectors = (struct msm_bus_vectors[]){ \
134 {\
135 .src = MSM_BUS_MASTER_UBI32_0, \
136 .dst = MSM_BUS_SLAVE_EBI_CH0, \
137 .ab = (_data_bw) * 16 * 1000000ULL, \
138 .ib = (_data_bw) * 16 * 1000000ULL, \
139 }, \
140 { \
141 .src = MSM_BUS_MASTER_UBI32_0, \
142 .dst = MSM_BUS_SLAVE_NSS_TCM, \
143 .ab = (_desc_bw) * 8 * 1000000ULL, \
144 .ib = (_desc_bw) * 8 * 1000000ULL, \
145 }, \
146 }, \
147 .num_paths = 2, \
148}
149
150/*
151 * Initialize NSS PM top level structures
152 */
153void nss_pm_init(void);
154
155#endif /** __NSS_PM_H */