mtgpio.c 699 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2021, 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_LT_BASE;
  18. break;
  19. case 1:
  20. reg_addr = IOCFG_LM_BASE;
  21. break;
  22. case 2:
  23. reg_addr = IOCFG_LB_BASE;
  24. break;
  25. case 3:
  26. reg_addr = IOCFG_BL_BASE;
  27. break;
  28. case 4:
  29. reg_addr = IOCFG_RB_BASE;
  30. break;
  31. case 5:
  32. reg_addr = IOCFG_RT_BASE;
  33. break;
  34. default:
  35. break;
  36. }
  37. return reg_addr;
  38. }