Guodong Liu | 532016e | 2021-10-15 16:52:18 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021, 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 | |
| 11 | uintptr_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_LT_BASE; |
| 23 | break; |
| 24 | case 1: |
| 25 | reg_addr = IOCFG_LM_BASE; |
| 26 | break; |
| 27 | case 2: |
| 28 | reg_addr = IOCFG_LB_BASE; |
| 29 | break; |
| 30 | case 3: |
| 31 | reg_addr = IOCFG_BL_BASE; |
| 32 | break; |
| 33 | case 4: |
| 34 | reg_addr = IOCFG_RB_BASE; |
| 35 | break; |
| 36 | case 5: |
| 37 | reg_addr = IOCFG_RT_BASE; |
| 38 | break; |
| 39 | default: |
| 40 | break; |
| 41 | } |
| 42 | |
| 43 | return reg_addr; |
| 44 | } |