Commit a1ffd9e2e634b5d573210d8ae0081d325f919c6d
Committed by
Stefano Babic
1 parent
03073a6665
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
i2c: imx: Take mx6dqp in consideration in the I2C_PADS_INFO macro
We should take the MX6DP and MX6QP options in consideration in the I2C_PADS_INFO macro. Based on a patch by Pierluigi Passaro <pierluigi.p@variscite.com> Signed-off-by: Eran Matityahu <eran.m@variscite.com> Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Showing 1 changed file with 1 additions and 2 deletions Inline Diff
arch/arm/include/asm/mach-imx/mxc_i2c.h
1 | /* | 1 | /* |
2 | * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. | 2 | * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: GPL-2.0+ | 4 | * SPDX-License-Identifier: GPL-2.0+ |
5 | */ | 5 | */ |
6 | #ifndef __ASM_ARCH_MXC_MXC_I2C_H__ | 6 | #ifndef __ASM_ARCH_MXC_MXC_I2C_H__ |
7 | #define __ASM_ARCH_MXC_MXC_I2C_H__ | 7 | #define __ASM_ARCH_MXC_MXC_I2C_H__ |
8 | #include <asm-generic/gpio.h> | 8 | #include <asm-generic/gpio.h> |
9 | #include <asm/mach-imx/iomux-v3.h> | 9 | #include <asm/mach-imx/iomux-v3.h> |
10 | 10 | ||
11 | struct i2c_pin_ctrl { | 11 | struct i2c_pin_ctrl { |
12 | iomux_v3_cfg_t i2c_mode; | 12 | iomux_v3_cfg_t i2c_mode; |
13 | iomux_v3_cfg_t gpio_mode; | 13 | iomux_v3_cfg_t gpio_mode; |
14 | unsigned char gp; | 14 | unsigned char gp; |
15 | unsigned char spare; | 15 | unsigned char spare; |
16 | }; | 16 | }; |
17 | 17 | ||
18 | struct i2c_pads_info { | 18 | struct i2c_pads_info { |
19 | struct i2c_pin_ctrl scl; | 19 | struct i2c_pin_ctrl scl; |
20 | struct i2c_pin_ctrl sda; | 20 | struct i2c_pin_ctrl sda; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | /* | 23 | /* |
24 | * Information about i2c controller | 24 | * Information about i2c controller |
25 | * struct mxc_i2c_bus - information about the i2c[x] bus | 25 | * struct mxc_i2c_bus - information about the i2c[x] bus |
26 | * @index: i2c bus index | 26 | * @index: i2c bus index |
27 | * @base: Address of I2C bus controller | 27 | * @base: Address of I2C bus controller |
28 | * @driver_data: Flags for different platforms, such as I2C_QUIRK_FLAG. | 28 | * @driver_data: Flags for different platforms, such as I2C_QUIRK_FLAG. |
29 | * @speed: Speed of I2C bus | 29 | * @speed: Speed of I2C bus |
30 | * @pads_info: pinctrl info for this i2c bus, will be used when pinctrl is ok. | 30 | * @pads_info: pinctrl info for this i2c bus, will be used when pinctrl is ok. |
31 | * The following two is only to be compatible with non-DM part. | 31 | * The following two is only to be compatible with non-DM part. |
32 | * @idle_bus_fn: function to force bus idle | 32 | * @idle_bus_fn: function to force bus idle |
33 | * @idle_bus_data: parameter for idle_bus_fun | 33 | * @idle_bus_data: parameter for idle_bus_fun |
34 | * For DM: | 34 | * For DM: |
35 | * bus: The device structure for i2c bus controller | 35 | * bus: The device structure for i2c bus controller |
36 | * scl-gpio: specify the gpio related to SCL pin | 36 | * scl-gpio: specify the gpio related to SCL pin |
37 | * sda-gpio: specify the gpio related to SDA pin | 37 | * sda-gpio: specify the gpio related to SDA pin |
38 | */ | 38 | */ |
39 | struct mxc_i2c_bus { | 39 | struct mxc_i2c_bus { |
40 | /* | 40 | /* |
41 | * board file can use this index to locate which i2c_pads_info is for | 41 | * board file can use this index to locate which i2c_pads_info is for |
42 | * i2c_idle_bus. When pinmux is implement, this entry can be | 42 | * i2c_idle_bus. When pinmux is implement, this entry can be |
43 | * discarded. Here we do not use dev->seq, because we do not want to | 43 | * discarded. Here we do not use dev->seq, because we do not want to |
44 | * export device to board file. | 44 | * export device to board file. |
45 | */ | 45 | */ |
46 | int index; | 46 | int index; |
47 | ulong base; | 47 | ulong base; |
48 | ulong driver_data; | 48 | ulong driver_data; |
49 | int speed; | 49 | int speed; |
50 | struct i2c_pads_info *pads_info; | 50 | struct i2c_pads_info *pads_info; |
51 | #ifndef CONFIG_DM_I2C | 51 | #ifndef CONFIG_DM_I2C |
52 | int (*idle_bus_fn)(void *p); | 52 | int (*idle_bus_fn)(void *p); |
53 | void *idle_bus_data; | 53 | void *idle_bus_data; |
54 | #else | 54 | #else |
55 | struct udevice *bus; | 55 | struct udevice *bus; |
56 | /* Use gpio to force bus idle when bus state is abnormal */ | 56 | /* Use gpio to force bus idle when bus state is abnormal */ |
57 | struct gpio_desc scl_gpio; | 57 | struct gpio_desc scl_gpio; |
58 | struct gpio_desc sda_gpio; | 58 | struct gpio_desc sda_gpio; |
59 | #endif | 59 | #endif |
60 | }; | 60 | }; |
61 | 61 | ||
62 | #if defined(CONFIG_MX6QDL) | 62 | #if defined(CONFIG_MX6QDL) |
63 | #define I2C_PADS(name, scl_i2c, scl_gpio, scl_gp, sda_i2c, sda_gpio, sda_gp) \ | 63 | #define I2C_PADS(name, scl_i2c, scl_gpio, scl_gp, sda_i2c, sda_gpio, sda_gp) \ |
64 | struct i2c_pads_info mx6q_##name = { \ | 64 | struct i2c_pads_info mx6q_##name = { \ |
65 | .scl = { \ | 65 | .scl = { \ |
66 | .i2c_mode = MX6Q_##scl_i2c, \ | 66 | .i2c_mode = MX6Q_##scl_i2c, \ |
67 | .gpio_mode = MX6Q_##scl_gpio, \ | 67 | .gpio_mode = MX6Q_##scl_gpio, \ |
68 | .gp = scl_gp, \ | 68 | .gp = scl_gp, \ |
69 | }, \ | 69 | }, \ |
70 | .sda = { \ | 70 | .sda = { \ |
71 | .i2c_mode = MX6Q_##sda_i2c, \ | 71 | .i2c_mode = MX6Q_##sda_i2c, \ |
72 | .gpio_mode = MX6Q_##sda_gpio, \ | 72 | .gpio_mode = MX6Q_##sda_gpio, \ |
73 | .gp = sda_gp, \ | 73 | .gp = sda_gp, \ |
74 | } \ | 74 | } \ |
75 | }; \ | 75 | }; \ |
76 | struct i2c_pads_info mx6s_##name = { \ | 76 | struct i2c_pads_info mx6s_##name = { \ |
77 | .scl = { \ | 77 | .scl = { \ |
78 | .i2c_mode = MX6DL_##scl_i2c, \ | 78 | .i2c_mode = MX6DL_##scl_i2c, \ |
79 | .gpio_mode = MX6DL_##scl_gpio, \ | 79 | .gpio_mode = MX6DL_##scl_gpio, \ |
80 | .gp = scl_gp, \ | 80 | .gp = scl_gp, \ |
81 | }, \ | 81 | }, \ |
82 | .sda = { \ | 82 | .sda = { \ |
83 | .i2c_mode = MX6DL_##sda_i2c, \ | 83 | .i2c_mode = MX6DL_##sda_i2c, \ |
84 | .gpio_mode = MX6DL_##sda_gpio, \ | 84 | .gpio_mode = MX6DL_##sda_gpio, \ |
85 | .gp = sda_gp, \ | 85 | .gp = sda_gp, \ |
86 | } \ | 86 | } \ |
87 | }; | 87 | }; |
88 | 88 | ||
89 | 89 | ||
90 | #define I2C_PADS_INFO(name) \ | 90 | #define I2C_PADS_INFO(name) \ |
91 | (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) ? \ | 91 | (is_mx6dq() || is_mx6dqp()) ? &mx6q_##name : &mx6s_##name |
92 | &mx6q_##name : &mx6s_##name | ||
93 | #endif | 92 | #endif |
94 | 93 | ||
95 | int setup_i2c(unsigned i2c_index, int speed, int slave_addr, | 94 | int setup_i2c(unsigned i2c_index, int speed, int slave_addr, |
96 | struct i2c_pads_info *p); | 95 | struct i2c_pads_info *p); |
97 | void bus_i2c_init(int index, int speed, int slave_addr, | 96 | void bus_i2c_init(int index, int speed, int slave_addr, |
98 | int (*idle_bus_fn)(void *p), void *p); | 97 | int (*idle_bus_fn)(void *p), void *p); |
99 | int force_idle_bus(void *priv); | 98 | int force_idle_bus(void *priv); |
100 | int i2c_idle_bus(struct mxc_i2c_bus *i2c_bus); | 99 | int i2c_idle_bus(struct mxc_i2c_bus *i2c_bus); |
101 | #endif | 100 | #endif |
102 | 101 |