blob: 9e9fc5de1f41fab4cc76476fd31d5d8127cbf162 [file] [log] [blame]
Jianguo Zhangbe99c732022-07-29 13:55:03 +08001/*
2 * Copyright (c) 2022, MediaTek Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <assert.h>
8#include <mtgpio.h>
9#include <platform_def.h>
10
11uintptr_t mt_gpio_find_reg_addr(uint32_t pin)
12{
13 uintptr_t reg_addr = 0U;
14 struct mt_pin_info gpio_info;
15
16 assert(pin < MAX_GPIO_PIN);
17
18 gpio_info = mt_pin_infos[pin];
19
20 switch (gpio_info.base & 0x0f) {
21 case 0:
22 reg_addr = IOCFG_RM_BASE;
23 break;
24 case 1:
25 reg_addr = IOCFG_LT_BASE;
26 break;
27 case 2:
28 reg_addr = IOCFG_LM_BASE;
29 break;
30 case 3:
31 reg_addr = IOCFG_RT_BASE;
32 break;
33 default:
34 break;
35 }
36
37 return reg_addr;
38}