Troy Kisky | d4fdc99 | 2012-07-19 08:18:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Troy Kisky | d4fdc99 | 2012-07-19 08:18:25 +0000 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __ASM_ARCH_MXC_MXC_I2C_H__ |
| 7 | #define __ASM_ARCH_MXC_MXC_I2C_H__ |
| 8 | #include <asm/imx-common/iomux-v3.h> |
| 9 | |
| 10 | struct i2c_pin_ctrl { |
| 11 | iomux_v3_cfg_t i2c_mode; |
| 12 | iomux_v3_cfg_t gpio_mode; |
| 13 | unsigned char gp; |
| 14 | unsigned char spare; |
| 15 | }; |
| 16 | |
| 17 | struct i2c_pads_info { |
| 18 | struct i2c_pin_ctrl scl; |
| 19 | struct i2c_pin_ctrl sda; |
| 20 | }; |
| 21 | |
Nikita Kiryanov | ef73783 | 2014-08-20 15:08:54 +0300 | [diff] [blame] | 22 | #if defined(CONFIG_MX6QDL) |
| 23 | #define I2C_PADS(name, scl_i2c, scl_gpio, scl_gp, sda_i2c, sda_gpio, sda_gp) \ |
| 24 | struct i2c_pads_info mx6q_##name = { \ |
| 25 | .scl = { \ |
| 26 | .i2c_mode = MX6Q_##scl_i2c, \ |
| 27 | .gpio_mode = MX6Q_##scl_gpio, \ |
| 28 | .gp = scl_gp, \ |
| 29 | }, \ |
| 30 | .sda = { \ |
| 31 | .i2c_mode = MX6Q_##sda_i2c, \ |
| 32 | .gpio_mode = MX6Q_##sda_gpio, \ |
| 33 | .gp = sda_gp, \ |
| 34 | } \ |
| 35 | }; \ |
| 36 | struct i2c_pads_info mx6s_##name = { \ |
| 37 | .scl = { \ |
| 38 | .i2c_mode = MX6DL_##scl_i2c, \ |
| 39 | .gpio_mode = MX6DL_##scl_gpio, \ |
| 40 | .gp = scl_gp, \ |
| 41 | }, \ |
| 42 | .sda = { \ |
| 43 | .i2c_mode = MX6DL_##sda_i2c, \ |
| 44 | .gpio_mode = MX6DL_##sda_gpio, \ |
| 45 | .gp = sda_gp, \ |
| 46 | } \ |
| 47 | }; |
| 48 | |
| 49 | |
| 50 | #define I2C_PADS_INFO(name) \ |
| 51 | (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) ? \ |
| 52 | &mx6q_##name : &mx6s_##name |
| 53 | #endif |
| 54 | |
Troy Kisky | d4fdc99 | 2012-07-19 08:18:25 +0000 | [diff] [blame] | 55 | void setup_i2c(unsigned i2c_index, int speed, int slave_addr, |
| 56 | struct i2c_pads_info *p); |
| 57 | void bus_i2c_init(void *base, int speed, int slave_addr, |
| 58 | int (*idle_bus_fn)(void *p), void *p); |
| 59 | int bus_i2c_read(void *base, uchar chip, uint addr, int alen, uchar *buf, |
| 60 | int len); |
| 61 | int bus_i2c_write(void *base, uchar chip, uint addr, int alen, |
| 62 | const uchar *buf, int len); |
| 63 | #endif |