summaryrefslogtreecommitdiffstats
path: root/plat/mediatek/mt8192/drivers/gpio/mtgpio.c
blob: c78332d348dbe675d984ba5e5680c0ed104bc123 (plain)
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
/*
 * Copyright (c) 2020, MediaTek Inc. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <assert.h>
#include <mtgpio.h>
#include <platform_def.h>

uintptr_t mt_gpio_find_reg_addr(uint32_t pin)
{
	uintptr_t reg_addr = 0U;
	struct mt_pin_info gpio_info;

	assert(pin < MAX_GPIO_PIN);

	gpio_info = mt_pin_infos[pin];

	switch (gpio_info.base & 0x0f) {
	case 0:
		reg_addr = IOCFG_RM_BASE;
		break;
	case 1:
		reg_addr = IOCFG_BM_BASE;
		break;
	case 2:
		reg_addr = IOCFG_BL_BASE;
		break;
	case 3:
		reg_addr = IOCFG_BR_BASE;
		break;
	case 4:
		reg_addr = IOCFG_LM_BASE;
		break;
	case 5:
		reg_addr = IOCFG_LB_BASE;
		break;
	case 6:
		reg_addr = IOCFG_RT_BASE;
		break;
	case 7:
		reg_addr = IOCFG_LT_BASE;
		break;
	case 8:
		reg_addr = IOCFG_TL_BASE;
		break;
	default:
		break;
	}

	return reg_addr;
}