blob: 6b94a439294a59e8ff8b5a73befc0372fae90eee [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
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#ifndef _ARCH_ARM_MACH_MSM_BUS_H
14#define _ARCH_ARM_MACH_MSM_BUS_H
15
16#include <linux/types.h>
17#include <linux/input.h>
Gagan Macbf3676d2012-08-02 18:08:16 -060018#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019
20/*
21 * Macros for clients to convert their data to ib and ab
22 * Ws : Time window over which to transfer the data in SECONDS
23 * Bs : Size of the data block in bytes
24 * Per : Recurrence period
25 * Tb : Throughput bandwidth to prevent stalling
26 * R : Ratio of actual bandwidth used to Tb
27 * Ib : Instantaneous bandwidth
28 * Ab : Arbitrated bandwidth
29 *
30 * IB_RECURRBLOCK and AB_RECURRBLOCK:
31 * These are used if the requirement is to transfer a
32 * recurring block of data over a known time window.
33 *
34 * IB_THROUGHPUTBW and AB_THROUGHPUTBW:
35 * These are used for CPU style masters. Here the requirement
36 * is to have minimum throughput bandwidth available to avoid
37 * stalling.
38 */
39#define IB_RECURRBLOCK(Ws, Bs) ((Ws) == 0 ? 0 : ((Bs)/(Ws)))
40#define AB_RECURRBLOCK(Ws, Per) ((Ws) == 0 ? 0 : ((Bs)/(Per)))
41#define IB_THROUGHPUTBW(Tb) (Tb)
42#define AB_THROUGHPUTBW(Tb, R) ((Tb) * (R))
43
44struct msm_bus_vectors {
45 int src; /* Master */
46 int dst; /* Slave */
Gagan Macb2372ae2012-08-20 19:24:32 -060047 uint64_t ab; /* Arbitrated bandwidth */
48 uint64_t ib; /* Instantaneous bandwidth */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049};
50
51struct msm_bus_paths {
52 int num_paths;
53 struct msm_bus_vectors *vectors;
54};
55
56struct msm_bus_scale_pdata {
57 struct msm_bus_paths *usecase;
58 int num_usecases;
59 const char *name;
60 /*
61 * If the active_only flag is set to 1, the BW request is applied
62 * only when at least one CPU is active (powered on). If the flag
63 * is set to 0, then the BW request is always applied irrespective
64 * of the CPU state.
65 */
66 unsigned int active_only;
67};
68
69/* Scaling APIs */
70
71/*
72 * This function returns a handle to the client. This should be used to
73 * call msm_bus_scale_client_update_request.
74 * The function returns 0 if bus driver is unable to register a client
75 */
76
77#ifdef CONFIG_MSM_BUS_SCALING
78uint32_t msm_bus_scale_register_client(struct msm_bus_scale_pdata *pdata);
79int msm_bus_scale_client_update_request(uint32_t cl, unsigned int index);
80void msm_bus_scale_unregister_client(uint32_t cl);
Gagan Macbf3676d2012-08-02 18:08:16 -060081struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev);
82void msm_bus_cl_clear_pdata(struct msm_bus_scale_pdata *pdata);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070083/* AXI Port configuration APIs */
84int msm_bus_axi_porthalt(int master_port);
85int msm_bus_axi_portunhalt(int master_port);
86
87#else
Gagan Macbf3676d2012-08-02 18:08:16 -060088static inline struct msm_bus_scale_pdata
89*msm_bus_cl_get_pdata(struct platform_device *pdev)
90{
91 return NULL;
92}
93
94static inline void
95msm_bus_cl_clear_pdata(struct msm_bus_scale_pdata *pdata)
96{
97}
98
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099static inline uint32_t
100msm_bus_scale_register_client(struct msm_bus_scale_pdata *pdata)
101{
102 return 1;
103}
104
105static inline int
106msm_bus_scale_client_update_request(uint32_t cl, unsigned int index)
107{
108 return 0;
109}
110
111static inline void
112msm_bus_scale_unregister_client(uint32_t cl)
113{
114}
115
116static inline int msm_bus_axi_porthalt(int master_port)
117{
118 return 0;
119}
120
121static inline int msm_bus_axi_portunhalt(int master_port)
122{
123 return 0;
124}
125#endif
126
127#endif /*_ARCH_ARM_MACH_MSM_BUS_H*/