1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* SPDX-License-Identifier: BSD-3-Clause */
#include <gpio.h>
#include <soc/gpio.h>
#include <soc/blsp.h>
#include <soc/qup.h>
#define IPQ40XX_I2C0_PINGROUP_1 1
#define IPQ40XX_I2C0_PINGROUP_2 (!IPQ40XX_I2C0_PINGROUP_1)
#define IPQ40XX_I2C1_PINGROUP_1 1
#if IPQ40XX_I2C0_PINGROUP_1
#define SCL_GPIO 20
#define SDA_GPIO 21
#define GPIO_FUNC_SCL 0x1
#define GPIO_FUNC_SDA 0x1
#elif IPQ40XX_I2C0_PINGROUP_2
#define SCL_GPIO 58
#define SDA_GPIO 59
#define GPIO_FUNC_SCL 0x3
#define GPIO_FUNC_SDA 0x2
#else
#warning "TPM: I2C pingroup not specified"
#endif
#if IPQ40XX_I2C1_PINGROUP_1
#define SCL_GPIO_I2C1 34
#define SDA_GPIO_I2C1 35
#define GPIO_I2C1_FUNC_SCL 0x1
#define GPIO_I2C1_FUNC_SDA 0x1
#endif
int blsp_i2c_init_board(blsp_qup_id_t id)
{
switch (id) {
case BLSP_QUP_ID_0:
case BLSP_QUP_ID_1:
case BLSP_QUP_ID_2:
case BLSP_QUP_ID_3:
#if defined(IPQ40XX_I2C0_PINGROUP_1) || defined(IPQ40XX_I2C0_PINGROUP_2)
gpio_tlmm_config_set(SDA_GPIO, GPIO_FUNC_SDA,
GPIO_NO_PULL, GPIO_2MA, 1);
gpio_tlmm_config_set(SCL_GPIO, GPIO_FUNC_SCL,
GPIO_NO_PULL, GPIO_2MA, 1);
#endif /* Pin Group 1 or 2 */
#if defined(IPQ40XX_I2C1_PINGROUP_1)
gpio_tlmm_config_set(SDA_GPIO_I2C1, GPIO_I2C1_FUNC_SDA,
GPIO_NO_PULL, GPIO_2MA, 1);
gpio_tlmm_config_set(SCL_GPIO_I2C1, GPIO_I2C1_FUNC_SCL,
GPIO_NO_PULL, GPIO_2MA, 1);
#endif
break;
default:
return 1;
}
return 0;
}
|