1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12#pragma once 13 14#include <platsupport/io.h> 15 16#define TK1_I2C_SIZE (0x1000) 17/* Unfortunately, the SPI controllers are not in separate physical frames. 18 * Four of them are in one frame and the other 2 are in another. 19 */ 20#define TK1_I2C_PAGE0 (0x7000C000) 21#define TK1_I2C_PAGE1 (0x7000D000) 22 23#define TK1_I2C0_PADDR (TK1_I2C_PAGE0) 24#define TK1_I2C0_SIZE (TK1_I2C_SIZE) 25#define TK1_I2C1_PADDR (TK1_I2C_PAGE0 + 0x400) 26#define TK1_I2C1_SIZE (TK1_I2C_SIZE) 27#define TK1_I2C2_PADDR (TK1_I2C_PAGE0 + 0x500) 28#define TK1_I2C2_SIZE (TK1_I2C_SIZE) 29#define TK1_I2C3_PADDR (TK1_I2C_PAGE0 + 0x700) 30#define TK1_I2C3_SIZE (TK1_I2C_SIZE) 31#define TK1_I2C4_PADDR (TK1_I2C_PAGE1) 32#define TK1_I2C4_SIZE (TK1_I2C_SIZE) 33#define TK1_I2C5_PADDR (TK1_I2C_PAGE1 + 0x100) 34#define TK1_I2C5_SIZE (TK1_I2C_SIZE) 35 36#define TK1_I2C0_INTERRUPT (70) 37#define TK1_I2C1_INTERRUPT (116) 38#define TK1_I2C2_INTERRUPT (124) 39#define TK1_I2C3_INTERRUPT (152) 40#define TK1_I2C4_INTERRUPT (85) 41#define TK1_I2C5_INTERRUPT (95) 42 43enum i2c_id { 44 TK1_I2C0, 45 TK1_I2C1, 46 TK1_I2C2, 47 TK1_I2C3, 48 TK1_I2C4, 49 TK1_I2C5, 50 NI2C 51}; 52 53struct i2c_bus; 54typedef struct i2c_bus i2c_bus_t; 55 56/** Static initializer. 57 * 58 * @param[in] controller_id 0-based ID for the controller being initialized. 59 * Use one of the IDs defined above in enum i2c_id. 60 * @param[in] vaddr Virtual address of the page that is mapped to 61 * the MMIO registers for the desired device. 62 * @param[in] ib Pointer to an uninitialized i2c_bus_t instance 63 * which will be initialized by this function. 64 * @return 0 if successful. 65 */ 66int tegra_i2c_init(int controller_id, void *vaddr, 67 ps_io_ops_t *io_ops, i2c_bus_t *ib); 68 69