Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* 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 Mac | bf3676d | 2012-08-02 18:08:16 -0600 | [diff] [blame] | 18 | #include <linux/platform_device.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 19 | |
| 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 | |
| 44 | struct msm_bus_vectors { |
| 45 | int src; /* Master */ |
| 46 | int dst; /* Slave */ |
Gagan Mac | b2372ae | 2012-08-20 19:24:32 -0600 | [diff] [blame] | 47 | uint64_t ab; /* Arbitrated bandwidth */ |
| 48 | uint64_t ib; /* Instantaneous bandwidth */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | struct msm_bus_paths { |
| 52 | int num_paths; |
| 53 | struct msm_bus_vectors *vectors; |
| 54 | }; |
| 55 | |
| 56 | struct 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 |
| 78 | uint32_t msm_bus_scale_register_client(struct msm_bus_scale_pdata *pdata); |
| 79 | int msm_bus_scale_client_update_request(uint32_t cl, unsigned int index); |
| 80 | void msm_bus_scale_unregister_client(uint32_t cl); |
Gagan Mac | bf3676d | 2012-08-02 18:08:16 -0600 | [diff] [blame] | 81 | struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev); |
| 82 | void msm_bus_cl_clear_pdata(struct msm_bus_scale_pdata *pdata); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 83 | /* AXI Port configuration APIs */ |
| 84 | int msm_bus_axi_porthalt(int master_port); |
| 85 | int msm_bus_axi_portunhalt(int master_port); |
| 86 | |
| 87 | #else |
Gagan Mac | bf3676d | 2012-08-02 18:08:16 -0600 | [diff] [blame] | 88 | static inline struct msm_bus_scale_pdata |
| 89 | *msm_bus_cl_get_pdata(struct platform_device *pdev) |
| 90 | { |
| 91 | return NULL; |
| 92 | } |
| 93 | |
| 94 | static inline void |
| 95 | msm_bus_cl_clear_pdata(struct msm_bus_scale_pdata *pdata) |
| 96 | { |
| 97 | } |
| 98 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 99 | static inline uint32_t |
| 100 | msm_bus_scale_register_client(struct msm_bus_scale_pdata *pdata) |
| 101 | { |
| 102 | return 1; |
| 103 | } |
| 104 | |
| 105 | static inline int |
| 106 | msm_bus_scale_client_update_request(uint32_t cl, unsigned int index) |
| 107 | { |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | static inline void |
| 112 | msm_bus_scale_unregister_client(uint32_t cl) |
| 113 | { |
| 114 | } |
| 115 | |
| 116 | static inline int msm_bus_axi_porthalt(int master_port) |
| 117 | { |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | static 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*/ |