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 | |
Peng Fan | 8262cb1 | 2015-05-15 07:29:12 +0800 | [diff] [blame] | 22 | /* |
| 23 | * Information about i2c controller |
| 24 | * struct mxc_i2c_bus - information about the i2c[x] bus |
| 25 | * @index: i2c bus index |
| 26 | * @base: Address of I2C bus controller |
| 27 | * @driver_data: Flags for different platforms, such as I2C_QUIRK_FLAG. |
| 28 | * @speed: Speed of I2C bus |
| 29 | * @pads_info: pinctrl info for this i2c bus, will be used when pinctrl is ok. |
| 30 | * The following two is only to be compatible with non-DM part. |
| 31 | * @idle_bus_fn: function to force bus idle |
| 32 | * @idle_bus_data: parameter for idle_bus_fun |
| 33 | */ |
| 34 | struct mxc_i2c_bus { |
| 35 | /* |
| 36 | * board file can use this index to locate which i2c_pads_info is for |
| 37 | * i2c_idle_bus. When pinmux is implement, this entry can be |
| 38 | * discarded. Here we do not use dev->seq, because we do not want to |
| 39 | * export device to board file. |
| 40 | */ |
| 41 | int index; |
| 42 | ulong base; |
| 43 | ulong driver_data; |
| 44 | int speed; |
| 45 | struct i2c_pads_info *pads_info; |
| 46 | #ifndef CONFIG_DM_I2C |
| 47 | int (*idle_bus_fn)(void *p); |
| 48 | void *idle_bus_data; |
| 49 | #endif |
| 50 | }; |
| 51 | |
Nikita Kiryanov | ef73783 | 2014-08-20 15:08:54 +0300 | [diff] [blame] | 52 | #if defined(CONFIG_MX6QDL) |
| 53 | #define I2C_PADS(name, scl_i2c, scl_gpio, scl_gp, sda_i2c, sda_gpio, sda_gp) \ |
| 54 | struct i2c_pads_info mx6q_##name = { \ |
| 55 | .scl = { \ |
| 56 | .i2c_mode = MX6Q_##scl_i2c, \ |
| 57 | .gpio_mode = MX6Q_##scl_gpio, \ |
| 58 | .gp = scl_gp, \ |
| 59 | }, \ |
| 60 | .sda = { \ |
| 61 | .i2c_mode = MX6Q_##sda_i2c, \ |
| 62 | .gpio_mode = MX6Q_##sda_gpio, \ |
| 63 | .gp = sda_gp, \ |
| 64 | } \ |
| 65 | }; \ |
| 66 | struct i2c_pads_info mx6s_##name = { \ |
| 67 | .scl = { \ |
| 68 | .i2c_mode = MX6DL_##scl_i2c, \ |
| 69 | .gpio_mode = MX6DL_##scl_gpio, \ |
| 70 | .gp = scl_gp, \ |
| 71 | }, \ |
| 72 | .sda = { \ |
| 73 | .i2c_mode = MX6DL_##sda_i2c, \ |
| 74 | .gpio_mode = MX6DL_##sda_gpio, \ |
| 75 | .gp = sda_gp, \ |
| 76 | } \ |
| 77 | }; |
| 78 | |
| 79 | |
| 80 | #define I2C_PADS_INFO(name) \ |
| 81 | (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) ? \ |
| 82 | &mx6q_##name : &mx6s_##name |
| 83 | #endif |
| 84 | |
Simon Glass | 8d91436 | 2014-10-01 19:57:24 -0600 | [diff] [blame] | 85 | int setup_i2c(unsigned i2c_index, int speed, int slave_addr, |
| 86 | struct i2c_pads_info *p); |
Peng Fan | 8262cb1 | 2015-05-15 07:29:12 +0800 | [diff] [blame] | 87 | void bus_i2c_init(int index, int speed, int slave_addr, |
Troy Kisky | d4fdc99 | 2012-07-19 08:18:25 +0000 | [diff] [blame] | 88 | int (*idle_bus_fn)(void *p), void *p); |
Peng Fan | 8262cb1 | 2015-05-15 07:29:12 +0800 | [diff] [blame] | 89 | int force_idle_bus(void *priv); |
| 90 | int i2c_idle_bus(struct mxc_i2c_bus *i2c_bus); |
Troy Kisky | d4fdc99 | 2012-07-19 08:18:25 +0000 | [diff] [blame] | 91 | #endif |