1
2
3
4
5#ifndef __ASM_ARCH_MXC_MXC_I2C_H__
6#define __ASM_ARCH_MXC_MXC_I2C_H__
7#include <asm-generic/gpio.h>
8#include <asm/mach-imx/iomux-v3.h>
9#if CONFIG_IS_ENABLED(CLK)
10#include <clk.h>
11#endif
12
13struct i2c_pin_ctrl {
14 iomux_v3_cfg_t i2c_mode;
15 iomux_v3_cfg_t gpio_mode;
16 unsigned char gp;
17 unsigned char spare;
18};
19
20struct i2c_pads_info {
21 struct i2c_pin_ctrl scl;
22 struct i2c_pin_ctrl sda;
23};
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41struct mxc_i2c_bus {
42
43
44
45
46
47
48 int index;
49 ulong base;
50 ulong driver_data;
51 int speed;
52 struct i2c_pads_info *pads_info;
53#if CONFIG_IS_ENABLED(CLK)
54 struct clk per_clk;
55#endif
56#if !CONFIG_IS_ENABLED(DM_I2C)
57 int (*idle_bus_fn)(void *p);
58 void *idle_bus_data;
59#else
60 struct udevice *bus;
61
62 struct gpio_desc scl_gpio;
63 struct gpio_desc sda_gpio;
64#endif
65};
66
67#if defined(CONFIG_MX6QDL)
68#define I2C_PADS(name, scl_i2c, scl_gpio, scl_gp, sda_i2c, sda_gpio, sda_gp) \
69 struct i2c_pads_info mx6q_##name = { \
70 .scl = { \
71 .i2c_mode = MX6Q_##scl_i2c, \
72 .gpio_mode = MX6Q_##scl_gpio, \
73 .gp = scl_gp, \
74 }, \
75 .sda = { \
76 .i2c_mode = MX6Q_##sda_i2c, \
77 .gpio_mode = MX6Q_##sda_gpio, \
78 .gp = sda_gp, \
79 } \
80 }; \
81 struct i2c_pads_info mx6s_##name = { \
82 .scl = { \
83 .i2c_mode = MX6DL_##scl_i2c, \
84 .gpio_mode = MX6DL_##scl_gpio, \
85 .gp = scl_gp, \
86 }, \
87 .sda = { \
88 .i2c_mode = MX6DL_##sda_i2c, \
89 .gpio_mode = MX6DL_##sda_gpio, \
90 .gp = sda_gp, \
91 } \
92 };
93
94
95#define I2C_PADS_INFO(name) \
96 (is_mx6dq() || is_mx6dqp()) ? &mx6q_##name : &mx6s_##name
97#endif
98
99int setup_i2c(unsigned i2c_index, int speed, int slave_addr,
100 struct i2c_pads_info *p);
101void bus_i2c_init(int index, int speed, int slave_addr,
102 int (*idle_bus_fn)(void *p), void *p);
103int force_idle_bus(void *priv);
104int i2c_idle_bus(struct mxc_i2c_bus *i2c_bus);
105#endif
106