1 /* SPDX-License-Identifier: BSD-3-Clause */
2
3 #include <device/mmio.h>
4 #include <soc/blsp.h>
5 #include <soc/gpio.h>
6 #include <soc/iomap.h>
7 #include <soc/clock.h>
8
blsp_i2c_init(blsp_qup_id_t id)9 blsp_return_t blsp_i2c_init(blsp_qup_id_t id)
10 {
11 void *base;
12
13 switch (id) {
14 case BLSP_QUP_ID_1:
15 gpio_configure
16 (GPIO(24), 2, GPIO_PULL_UP, GPIO_2MA, GPIO_OUTPUT);
17 gpio_configure
18 (GPIO(25), 2, GPIO_PULL_UP, GPIO_2MA, GPIO_OUTPUT);
19 break;
20 default:
21 return BLSP_ID_ERROR;
22 }
23
24 clock_configure_i2c(19200000);
25 clock_enable_i2c();
26
27 base = blsp_qup_base(id);
28
29 if (!base)
30 return BLSP_ID_ERROR;
31
32 /* Configure Mini core to I2C core */
33 clrsetbits32(base, BLSP_MINI_CORE_MASK, BLSP_MINI_CORE_I2C);
34
35 return BLSP_SUCCESS;
36 }
37