1 /*- 2 * Copyright 2007-2013 Solarflare Communications Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 */ 25 26 #ifndef _SYS_FALCON_IMPL_H 27 #define _SYS_FALCON_IMPL_H 28 29 #include "efx.h" 30 #include "efx_regs.h" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 typedef struct falcon_i2c_s { 37 boolean_t fi_sda; 38 boolean_t fi_scl; 39 } falcon_i2c_t; 40 41 typedef struct falcon_spi_dev_s { 42 uint32_t fsd_sf_sel; 43 size_t fsd_size; 44 uint32_t fsd_adbcnt; 45 boolean_t fsd_munge; 46 uint32_t fsd_erase_cmd; 47 size_t fsd_erase_size; 48 size_t fsd_write_size; 49 } falcon_spi_dev_t; 50 51 extern __checkReturn int 52 falcon_nic_probe( 53 __in efx_nic_t *enp); 54 55 #if EFSYS_OPT_PCIE_TUNE 56 57 extern int 58 falcon_nic_pcie_tune( 59 __in efx_nic_t *enp, 60 __in unsigned int nlanes); 61 62 #endif 63 64 #define FALCON_NIC_CFG_RAW_SZ 0x400 65 66 extern __checkReturn int 67 falcon_nic_cfg_raw_read_verify( 68 __in efx_nic_t *enp, 69 __in uint32_t offset, 70 __in uint32_t size, 71 __out uint8_t *cfg); 72 73 extern __checkReturn int 74 falcon_nic_cfg_build( 75 __in efx_nic_t *enp, 76 __out efx_nic_cfg_t *encp); 77 78 extern __checkReturn int 79 falcon_nic_reset( 80 __in efx_nic_t *enp); 81 82 extern __checkReturn int 83 falcon_nic_init( 84 __in efx_nic_t *enp); 85 86 #if EFSYS_OPT_DIAG 87 88 extern __checkReturn int 89 falcon_nic_register_test( 90 __in efx_nic_t *enp); 91 92 #endif /* EFSYS_OPT_DIAG */ 93 94 extern void 95 falcon_nic_fini( 96 __in efx_nic_t *enp); 97 98 extern void 99 falcon_nic_unprobe( 100 __in efx_nic_t *enp); 101 102 extern __checkReturn int 103 falcon_nic_mac_reset( 104 __in efx_nic_t *enp); 105 106 extern void 107 falcon_mac_wrapper_enable( 108 __in efx_nic_t *enp); 109 110 extern __checkReturn int 111 falcon_mac_wrapper_disable( 112 __in efx_nic_t *enp); 113 114 #if EFSYS_OPT_LOOPBACK 115 116 extern __checkReturn int 117 falcon_mac_loopback_set( 118 __in efx_nic_t *enp, 119 __in efx_link_mode_t link_mode, 120 __in efx_loopback_type_t loopback_type); 121 122 #endif /* EFSYS_OPT_LOOPBACK */ 123 124 extern void 125 falcon_nic_phy_reset( 126 __in efx_nic_t *enp); 127 128 extern __checkReturn int 129 falcon_nvram_init( 130 __in efx_nic_t *enp); 131 132 #if EFSYS_OPT_NVRAM 133 134 #if EFSYS_OPT_DIAG 135 136 extern __checkReturn int 137 falcon_nvram_test( 138 __in efx_nic_t *enp); 139 140 #endif /* EFSYS_OPT_DIAG */ 141 142 extern __checkReturn int 143 falcon_nvram_size( 144 __in efx_nic_t *enp, 145 __in efx_nvram_type_t type, 146 __out size_t *sizep); 147 148 extern __checkReturn int 149 falcon_nvram_get_version( 150 __in efx_nic_t *enp, 151 __in efx_nvram_type_t type, 152 __out uint32_t *subtypep, 153 __out_ecount(4) uint16_t version[4]); 154 155 extern __checkReturn int 156 falcon_nvram_rw_start( 157 __in efx_nic_t *enp, 158 __in efx_nvram_type_t type, 159 __out size_t *pref_chunkp); 160 161 extern __checkReturn int 162 falcon_nvram_read_chunk( 163 __in efx_nic_t *enp, 164 __in efx_nvram_type_t type, 165 __in unsigned int offset, 166 __out_bcount(size) caddr_t data, 167 __in size_t size); 168 169 extern __checkReturn int 170 falcon_nvram_erase( 171 __in efx_nic_t *enp, 172 __in efx_nvram_type_t type); 173 174 extern __checkReturn int 175 falcon_nvram_write_chunk( 176 __in efx_nic_t *enp, 177 __in efx_nvram_type_t type, 178 __in unsigned int offset, 179 __in_bcount(size) caddr_t data, 180 __in size_t size); 181 182 extern void 183 falcon_nvram_rw_finish( 184 __in efx_nic_t *enp, 185 __in efx_nvram_type_t type); 186 187 extern __checkReturn int 188 falcon_nvram_set_version( 189 __in efx_nic_t *enp, 190 __in efx_nvram_type_t type, 191 __out uint16_t version[4]); 192 193 #endif /* EFSYS_OPT_NVRAM */ 194 195 extern void 196 falcon_nvram_fini( 197 __in efx_nic_t *enp); 198 199 #if EFSYS_OPT_VPD 200 201 extern __checkReturn int 202 falcon_vpd_size( 203 __in efx_nic_t *enp, 204 __out size_t *sizep); 205 206 extern __checkReturn int 207 falcon_vpd_read( 208 __in efx_nic_t *enp, 209 __out_bcount(size) caddr_t data, 210 __in size_t size); 211 212 extern __checkReturn int 213 falcon_vpd_verify( 214 __in efx_nic_t *enp, 215 __in_bcount(size) caddr_t data, 216 __in size_t size); 217 218 extern __checkReturn int 219 falcon_vpd_get( 220 __in efx_nic_t *enp, 221 __in_bcount(size) caddr_t data, 222 __in size_t size, 223 __inout efx_vpd_value_t *evvp); 224 225 extern __checkReturn int 226 falcon_vpd_set( 227 __in efx_nic_t *enp, 228 __in_bcount(size) caddr_t data, 229 __in size_t size, 230 __in efx_vpd_value_t *evvp); 231 232 extern __checkReturn int 233 falcon_vpd_next( 234 __in efx_nic_t *enp, 235 __in_bcount(size) caddr_t data, 236 __in size_t size, 237 __out efx_vpd_value_t *evvp, 238 __inout unsigned int *contp); 239 240 extern __checkReturn int 241 falcon_vpd_write( 242 __in efx_nic_t *enp, 243 __in_bcount(size) caddr_t data, 244 __in size_t size); 245 246 #endif /* EFSYS_OPT_VPD */ 247 248 extern __checkReturn int 249 falcon_sram_init( 250 __in efx_nic_t *enp); 251 252 #if EFSYS_OPT_DIAG 253 254 extern __checkReturn int 255 falcon_sram_test( 256 __in efx_nic_t *enp, 257 __in efx_sram_pattern_fn_t func); 258 259 #endif /* EFSYS_OPT_DIAG */ 260 261 extern void 262 falcon_sram_fini( 263 __in efx_nic_t *enp); 264 265 extern __checkReturn int 266 falcon_i2c_check( 267 __in efx_nic_t *enp, 268 __in uint8_t devid); 269 270 extern __checkReturn int 271 falcon_i2c_read( 272 __in efx_nic_t *enp, 273 __in uint8_t devid, 274 __in uint8_t addr, 275 __out_bcount(size) caddr_t base, 276 __in size_t size); 277 278 extern __checkReturn int 279 falcon_i2c_write( 280 __in efx_nic_t *enp, 281 __in uint8_t devid, 282 __in uint8_t addr, 283 __in_bcount(size) caddr_t base, 284 __in size_t size); 285 286 #if EFSYS_OPT_PHY_NULL 287 288 extern __checkReturn int 289 falcon_i2c_recv( 290 __in efx_nic_t *enp, 291 __in uint8_t devid, 292 __out_bcount(size) caddr_t base, 293 __in size_t size); 294 295 extern __checkReturn int 296 falcon_i2c_send( 297 __in efx_nic_t *enp, 298 __in uint8_t devid, 299 __in_bcount(size) caddr_t base, 300 __in size_t size); 301 302 #endif /* EFSYS_OPT_PHY_NULL */ 303 304 extern __checkReturn int 305 falcon_mdio_write( 306 __in efx_nic_t *enp, 307 __in uint8_t port, 308 __in uint8_t mmd, 309 __in uint16_t reg, 310 __in efx_word_t *ewp); 311 312 extern __checkReturn int 313 falcon_mdio_read( 314 __in efx_nic_t *enp, 315 __in uint8_t port, 316 __in uint8_t mmd, 317 __in uint16_t reg, 318 __out efx_word_t *ewp); 319 320 #if EFSYS_OPT_MAC_STATS 321 322 extern __checkReturn int 323 falcon_mac_stats_upload( 324 __in efx_nic_t *enp, 325 __in efsys_mem_t *esmp); 326 327 #endif /* EFSYS_OPT_MAC_STATS */ 328 329 extern __checkReturn int 330 falcon_mac_poll( 331 __in efx_nic_t *enp, 332 __out efx_link_mode_t *link_modep); 333 334 extern __checkReturn int 335 falcon_mac_up( 336 __in efx_nic_t *enp, 337 __out boolean_t *mac_upp); 338 339 #if EFSYS_OPT_LOOPBACK 340 341 extern __checkReturn int 342 falcon_mac_loopback_set( 343 __in efx_nic_t *enp, 344 __in efx_link_mode_t link_mode, 345 __in efx_loopback_type_t loopback_type); 346 347 #endif /* EFSYS_OPT_LOOPBACK */ 348 349 typedef enum falcon_spi_type_e { 350 FALCON_SPI_FLASH = 0, 351 FALCON_SPI_EEPROM, 352 FALCON_SPI_NTYPES 353 } falcon_spi_type_t; 354 355 extern __checkReturn int 356 falcon_spi_dev_read( 357 __in efx_nic_t *enp, 358 __in falcon_spi_type_t type, 359 __in uint32_t addr, 360 __out_bcount(size) caddr_t base, 361 __in size_t size); 362 363 extern __checkReturn int 364 falcon_spi_dev_write( 365 __in efx_nic_t *enp, 366 __in falcon_spi_type_t type, 367 __in uint32_t addr, 368 __in_bcount(size) caddr_t base, 369 __in size_t size); 370 371 extern __checkReturn int 372 falcon_spi_dev_erase( 373 __in efx_nic_t *enp, 374 __in falcon_spi_type_t type, 375 __in uint32_t addr, 376 __in size_t size); 377 378 #ifdef __cplusplus 379 } 380 #endif 381 382 #endif /* _SYS_FALCON_IMPL_H */