| 1 | #ifndef __CB_BDK_TWSI_H__ |
| 2 | #define __CB_BDK_TWSI_H__ |
| 3 | /***********************license start*********************************** |
| 4 | * Copyright (c) 2003-2017 Cavium Inc. ([email protected]). All rights |
| 5 | * reserved. |
| 6 | * |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions are |
| 10 | * met: |
| 11 | * |
| 12 | * * Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * |
| 15 | * * Redistributions in binary form must reproduce the above |
| 16 | * copyright notice, this list of conditions and the following |
| 17 | * disclaimer in the documentation and/or other materials provided |
| 18 | * with the distribution. |
| 19 | * |
| 20 | * * Neither the name of Cavium Inc. nor the names of |
| 21 | * its contributors may be used to endorse or promote products |
| 22 | * derived from this software without specific prior written |
| 23 | * permission. |
| 24 | * |
| 25 | * This Software, including technical data, may be subject to U.S. export |
| 26 | * control laws, including the U.S. Export Administration Act and its |
| 27 | * associated regulations, and may be subject to export or import |
| 28 | * regulations in other countries. |
| 29 | * |
| 30 | * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
| 31 | * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR |
| 32 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT |
| 33 | * TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY |
| 34 | * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT |
| 35 | * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES |
| 36 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR |
| 37 | * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, |
| 38 | * QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK |
| 39 | * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. |
| 40 | ***********************license end**************************************/ |
| 41 | |
| 42 | /** |
| 43 | * @file |
| 44 | * |
| 45 | * Interface to the TWSI / I2C bus |
| 46 | * |
| 47 | * Note: Currently on 7 bit device addresses are supported |
| 48 | * |
| 49 | * <hr>$Revision: 49448 $<hr> |
| 50 | * |
| 51 | * @addtogroup hal |
| 52 | * @{ |
| 53 | */ |
| 54 | #include <libbdk-arch/bdk-numa.h> |
| 55 | |
| 56 | /** |
| 57 | * Do a twsi read from a 7 bit device address using an (optional) |
| 58 | * internal address. Up to 4 bytes can be read at a time. |
| 59 | * |
| 60 | * @param node Node to use in a Numa setup. Can be an exact ID or a special |
| 61 | * value. |
| 62 | * @param twsi_id which TWSI bus to use |
| 63 | * @param dev_addr Device address (7 bit) |
| 64 | * @param internal_addr |
| 65 | * Internal address. Can be 0, 1 or 2 bytes in width |
| 66 | * @param num_bytes Number of data bytes to read (1-4) |
| 67 | * @param ia_width_bytes |
| 68 | * Internal address size in bytes (0, 1, or 2) |
| 69 | * |
| 70 | * @return Read data, or -1 on failure |
| 71 | */ |
| 72 | extern int64_t bdk_twsix_read_ia(bdk_node_t node, int twsi_id, uint8_t dev_addr, uint16_t internal_addr, int num_bytes, int ia_width_bytes); |
| 73 | |
| 74 | /** |
| 75 | * Write 1-8 bytes to a TWSI device using an internal address. |
| 76 | * |
| 77 | * @param node Node to use in a Numa setup. Can be an exact ID or a special |
| 78 | * value. |
| 79 | * @param twsi_id which TWSI interface to use |
| 80 | * @param dev_addr TWSI device address (7 bit only) |
| 81 | * @param internal_addr |
| 82 | * TWSI internal address (0, 8, or 16 bits) |
| 83 | * @param num_bytes Number of bytes to write (1-8) |
| 84 | * @param ia_width_bytes |
| 85 | * internal address width, in bytes (0, 1, 2) |
| 86 | * @param data Data to write. Data is written MSB first on the twsi bus, and |
| 87 | * only the lower num_bytes bytes of the argument are valid. (If |
| 88 | * a 2 byte write is done, only the low 2 bytes of the argument is |
| 89 | * used. |
| 90 | * |
| 91 | * @return Zero on success, -1 on error |
| 92 | */ |
| 93 | extern int bdk_twsix_write_ia(bdk_node_t node, int twsi_id, uint8_t dev_addr, uint16_t internal_addr, int num_bytes, int ia_width_bytes, uint64_t data); |
| 94 | |
| 95 | /** @} */ |
| 96 | #endif /* !__CB_BDK_TWSI_H__ */ |