mtgpio.c 607 B

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