mtgpio.c 837 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2020, 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_BM_BASE;
  21. break;
  22. case 2:
  23. reg_addr = IOCFG_BL_BASE;
  24. break;
  25. case 3:
  26. reg_addr = IOCFG_BR_BASE;
  27. break;
  28. case 4:
  29. reg_addr = IOCFG_LM_BASE;
  30. break;
  31. case 5:
  32. reg_addr = IOCFG_LB_BASE;
  33. break;
  34. case 6:
  35. reg_addr = IOCFG_RT_BASE;
  36. break;
  37. case 7:
  38. reg_addr = IOCFG_LT_BASE;
  39. break;
  40. case 8:
  41. reg_addr = IOCFG_TL_BASE;
  42. break;
  43. default:
  44. break;
  45. }
  46. return reg_addr;
  47. }