xref: /aosp_15_r20/external/coreboot/src/ec/kontron/kempld/kempld_internal.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef EC_KONTRON_KEMPLD_INTERNAL_H
4 #define EC_KONTRON_KEMPLD_INTERNAL_H
5 
6 #include <device/device.h>
7 
8 /* i/o ports */
9 #define KEMPLD_IDX		0xa80
10 #define  KEMPLD_MUTEX_KEY	0x80
11 #define KEMPLD_DAT		0xa81
12 
13 /* indexed registers */
14 #define KEMPLD_SPEC			0x06
15 #define  KEMPLD_SPEC_GET_MINOR(x)	((x) & 0x0f)
16 #define  KEMPLD_SPEC_GET_MAJOR(x)	((x) >> 4 & 0x0f)
17 
18 #define KEMPLD_CFG			0x37
19 #define  KEMPLD_CFG_GPIO_I2C_MUX	(1 << 0)
20 
21 #define KEMPLD_UART_0			0x30
22 #define KEMPLD_UART_1			0x31
23 #define  KEMPLD_UART_IRQ_SHIFT		0
24 #define  KEMPLD_UART_IRQ_MASK		(0xf << KEMPLD_UART_IRQ_SHIFT)
25 #define  KEMPLD_UART_IO_SHIFT		4
26 #define  KEMPLD_UART_IO_MASK		(0x3 << KEMPLD_UART_IO_SHIFT)
27 #define  KEMPLD_UART_ENABLE		0x80
28 
29 #define KEMPLD_CLK 33333333 /* 33MHz */
30 
31 #define KEMPLD_GPIO_MASK(pin_num)	(1 << ((pin_num) % 8))
32 #define KEMPLD_GPIO_DIR(pin_num)	(0x40 + (pin_num) / 8)
33 #define KEMPLD_GPIO_LVL(pin_num)	(0x42 + (pin_num) / 8)
34 
35 void kempld_i2c_device_init(struct device *const dev);
36 int kempld_gpio_pads_config(struct device *dev);
37 
38 #endif /* EC_KONTRON_KEMPLD_INTERNAL_H */
39