David Dai | b640f67 | 2016-08-09 14:19:33 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010-2016, The Linux Foundation. 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 __ASM_ARCH_MSM_BUS_BOARD_H |
| 14 | #define __ASM_ARCH_MSM_BUS_BOARD_H |
| 15 | |
| 16 | #include <linux/types.h> |
| 17 | #include <linux/input.h> |
| 18 | |
| 19 | enum context { |
| 20 | DUAL_CTX, |
| 21 | ACTIVE_CTX, |
| 22 | NUM_CTX |
| 23 | }; |
| 24 | |
| 25 | struct msm_bus_fabric_registration { |
| 26 | unsigned int id; |
| 27 | const char *name; |
| 28 | struct msm_bus_node_info *info; |
| 29 | unsigned int len; |
| 30 | int ahb; |
| 31 | const char *fabclk[NUM_CTX]; |
| 32 | const char *iface_clk; |
| 33 | unsigned int offset; |
| 34 | unsigned int haltid; |
| 35 | unsigned int rpm_enabled; |
| 36 | unsigned int nmasters; |
| 37 | unsigned int nslaves; |
| 38 | unsigned int ntieredslaves; |
| 39 | bool il_flag; |
| 40 | const struct msm_bus_board_algorithm *board_algo; |
| 41 | int hw_sel; |
| 42 | void *hw_data; |
| 43 | uint32_t qos_freq; |
| 44 | uint32_t qos_baseoffset; |
| 45 | u64 nr_lim_thresh; |
| 46 | uint32_t eff_fact; |
| 47 | uint32_t qos_delta; |
| 48 | bool virt; |
| 49 | }; |
| 50 | |
| 51 | struct msm_bus_device_node_registration { |
| 52 | struct msm_bus_node_device_type *info; |
| 53 | unsigned int num_devices; |
| 54 | bool virt; |
| 55 | }; |
| 56 | |
| 57 | enum msm_bus_bw_tier_type { |
| 58 | MSM_BUS_BW_TIER1 = 1, |
| 59 | MSM_BUS_BW_TIER2, |
| 60 | MSM_BUS_BW_COUNT, |
| 61 | MSM_BUS_BW_SIZE = 0x7FFFFFFF, |
| 62 | }; |
| 63 | |
| 64 | struct msm_bus_halt_vector { |
| 65 | uint32_t haltval; |
| 66 | uint32_t haltmask; |
| 67 | }; |
| 68 | |
| 69 | extern struct msm_bus_fabric_registration msm_bus_apps_fabric_pdata; |
| 70 | extern struct msm_bus_fabric_registration msm_bus_sys_fabric_pdata; |
| 71 | extern struct msm_bus_fabric_registration msm_bus_mm_fabric_pdata; |
| 72 | extern struct msm_bus_fabric_registration msm_bus_sys_fpb_pdata; |
| 73 | extern struct msm_bus_fabric_registration msm_bus_cpss_fpb_pdata; |
| 74 | extern struct msm_bus_fabric_registration msm_bus_def_fab_pdata; |
| 75 | |
| 76 | extern struct msm_bus_fabric_registration msm_bus_8960_apps_fabric_pdata; |
| 77 | extern struct msm_bus_fabric_registration msm_bus_8960_sys_fabric_pdata; |
| 78 | extern struct msm_bus_fabric_registration msm_bus_8960_mm_fabric_pdata; |
| 79 | extern struct msm_bus_fabric_registration msm_bus_8960_sg_mm_fabric_pdata; |
| 80 | extern struct msm_bus_fabric_registration msm_bus_8960_sys_fpb_pdata; |
| 81 | extern struct msm_bus_fabric_registration msm_bus_8960_cpss_fpb_pdata; |
| 82 | |
| 83 | extern struct msm_bus_fabric_registration msm_bus_8064_apps_fabric_pdata; |
| 84 | extern struct msm_bus_fabric_registration msm_bus_8064_sys_fabric_pdata; |
| 85 | extern struct msm_bus_fabric_registration msm_bus_8064_mm_fabric_pdata; |
| 86 | extern struct msm_bus_fabric_registration msm_bus_8064_sys_fpb_pdata; |
| 87 | extern struct msm_bus_fabric_registration msm_bus_8064_cpss_fpb_pdata; |
| 88 | |
| 89 | extern struct msm_bus_fabric_registration msm_bus_9615_sys_fabric_pdata; |
| 90 | extern struct msm_bus_fabric_registration msm_bus_9615_def_fab_pdata; |
| 91 | |
| 92 | extern struct msm_bus_fabric_registration msm_bus_8930_apps_fabric_pdata; |
| 93 | extern struct msm_bus_fabric_registration msm_bus_8930_sys_fabric_pdata; |
| 94 | extern struct msm_bus_fabric_registration msm_bus_8930_mm_fabric_pdata; |
| 95 | extern struct msm_bus_fabric_registration msm_bus_8930_sys_fpb_pdata; |
| 96 | extern struct msm_bus_fabric_registration msm_bus_8930_cpss_fpb_pdata; |
| 97 | |
| 98 | extern struct msm_bus_fabric_registration msm_bus_8974_sys_noc_pdata; |
| 99 | extern struct msm_bus_fabric_registration msm_bus_8974_mmss_noc_pdata; |
| 100 | extern struct msm_bus_fabric_registration msm_bus_8974_bimc_pdata; |
| 101 | extern struct msm_bus_fabric_registration msm_bus_8974_ocmem_noc_pdata; |
| 102 | extern struct msm_bus_fabric_registration msm_bus_8974_periph_noc_pdata; |
| 103 | extern struct msm_bus_fabric_registration msm_bus_8974_config_noc_pdata; |
| 104 | extern struct msm_bus_fabric_registration msm_bus_8974_ocmem_vnoc_pdata; |
| 105 | |
| 106 | extern struct msm_bus_fabric_registration msm_bus_9625_sys_noc_pdata; |
| 107 | extern struct msm_bus_fabric_registration msm_bus_9625_bimc_pdata; |
| 108 | extern struct msm_bus_fabric_registration msm_bus_9625_periph_noc_pdata; |
| 109 | extern struct msm_bus_fabric_registration msm_bus_9625_config_noc_pdata; |
| 110 | |
| 111 | extern int msm_bus_device_match_adhoc(struct device *dev, void *id); |
| 112 | |
| 113 | void msm_bus_rpm_set_mt_mask(void); |
| 114 | int msm_bus_board_rpm_get_il_ids(uint16_t *id); |
| 115 | int msm_bus_board_get_iid(int id); |
| 116 | |
| 117 | #define NFAB_MSM8226 6 |
| 118 | #define NFAB_MSM8610 5 |
| 119 | |
| 120 | /* |
| 121 | * These macros specify the convention followed for allocating |
| 122 | * ids to fabrics, masters and slaves for 8x60. |
| 123 | * |
| 124 | * A node can be identified as a master/slave/fabric by using |
| 125 | * these ids. |
| 126 | */ |
| 127 | #define FABRIC_ID_KEY 1024 |
| 128 | #define SLAVE_ID_KEY ((FABRIC_ID_KEY) >> 1) |
| 129 | #define MAX_FAB_KEY 7168 /* OR(All fabric ids) */ |
| 130 | #define INT_NODE_START 10000 |
| 131 | |
| 132 | #define GET_FABID(id) ((id) & MAX_FAB_KEY) |
| 133 | |
| 134 | #define NODE_ID(id) ((id) & (FABRIC_ID_KEY - 1)) |
| 135 | #define IS_SLAVE(id) ((NODE_ID(id)) >= SLAVE_ID_KEY ? 1 : 0) |
| 136 | #define CHECK_ID(iid, id) (((iid & id) != id) ? -ENXIO : iid) |
| 137 | |
| 138 | /* |
| 139 | * The following macros are used to format the data for port halt |
| 140 | * and unhalt requests. |
| 141 | */ |
| 142 | #define MSM_BUS_CLK_HALT 0x1 |
| 143 | #define MSM_BUS_CLK_HALT_MASK 0x1 |
| 144 | #define MSM_BUS_CLK_HALT_FIELDSIZE 0x1 |
| 145 | #define MSM_BUS_CLK_UNHALT 0x0 |
| 146 | |
| 147 | #define MSM_BUS_MASTER_SHIFT(master, fieldsize) \ |
| 148 | ((master) * (fieldsize)) |
| 149 | |
| 150 | #define MSM_BUS_SET_BITFIELD(word, fieldmask, fieldvalue) \ |
| 151 | { \ |
| 152 | (word) &= ~(fieldmask); \ |
| 153 | (word) |= (fieldvalue); \ |
| 154 | } |
| 155 | |
| 156 | |
| 157 | #define MSM_BUS_MASTER_HALT(u32haltmask, u32haltval, master) \ |
| 158 | (\ |
| 159 | MSM_BUS_SET_BITFIELD(u32haltmask, \ |
| 160 | MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\ |
| 161 | MSM_BUS_CLK_HALT_FIELDSIZE), \ |
| 162 | MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\ |
| 163 | MSM_BUS_CLK_HALT_FIELDSIZE))\ |
| 164 | MSM_BUS_SET_BITFIELD(u32haltval, \ |
| 165 | MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\ |
| 166 | MSM_BUS_CLK_HALT_FIELDSIZE), \ |
| 167 | MSM_BUS_CLK_HALT<<MSM_BUS_MASTER_SHIFT((master),\ |
| 168 | MSM_BUS_CLK_HALT_FIELDSIZE))\ |
| 169 | ) |
| 170 | |
| 171 | #define MSM_BUS_MASTER_UNHALT(u32haltmask, u32haltval, master) \ |
| 172 | (\ |
| 173 | MSM_BUS_SET_BITFIELD(u32haltmask, \ |
| 174 | MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\ |
| 175 | MSM_BUS_CLK_HALT_FIELDSIZE), \ |
| 176 | MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\ |
| 177 | MSM_BUS_CLK_HALT_FIELDSIZE))\ |
| 178 | MSM_BUS_SET_BITFIELD(u32haltval, \ |
| 179 | MSM_BUS_CLK_HALT_MASK<<MSM_BUS_MASTER_SHIFT((master),\ |
| 180 | MSM_BUS_CLK_HALT_FIELDSIZE), \ |
| 181 | MSM_BUS_CLK_UNHALT<<MSM_BUS_MASTER_SHIFT((master),\ |
| 182 | MSM_BUS_CLK_HALT_FIELDSIZE))\ |
| 183 | ) |
| 184 | |
| 185 | #define RPM_BUS_SLAVE_REQ 0x766c7362 |
| 186 | #define RPM_BUS_MASTER_REQ 0x73616d62 |
| 187 | |
| 188 | enum msm_bus_rpm_slave_field_type { |
| 189 | RPM_SLAVE_FIELD_BW = 0x00007762, |
| 190 | }; |
| 191 | |
| 192 | enum msm_bus_rpm_mas_field_type { |
| 193 | RPM_MASTER_FIELD_BW = 0x00007762, |
| 194 | RPM_MASTER_FIELD_BW_T0 = 0x30747762, |
| 195 | RPM_MASTER_FIELD_BW_T1 = 0x31747762, |
| 196 | RPM_MASTER_FIELD_BW_T2 = 0x32747762, |
| 197 | }; |
| 198 | |
| 199 | #include <dt-bindings/msm/msm-bus-ids.h> |
| 200 | |
| 201 | |
| 202 | #endif /*__ASM_ARCH_MSM_BUS_BOARD_H */ |