pinctrl-mt6797.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Based on pinctrl-mt6765.c
  4. *
  5. * Copyright (C) 2018 MediaTek Inc.
  6. *
  7. * Author: ZH Chen <[email protected]>
  8. *
  9. * Copyright (C) Manivannan Sadhasivam <[email protected]>
  10. *
  11. */
  12. #include "pinctrl-mtk-mt6797.h"
  13. #include "pinctrl-paris.h"
  14. /*
  15. * MT6797 have multiple bases to program pin configuration listed as the below:
  16. * gpio:0x10005000, iocfg[l]:0x10002000, iocfg[b]:0x10002400,
  17. * iocfg[r]:0x10002800, iocfg[t]:0x10002C00.
  18. * _i_base could be used to indicate what base the pin should be mapped into.
  19. */
  20. static const struct mtk_pin_field_calc mt6797_pin_mode_range[] = {
  21. PIN_FIELD(0, 261, 0x300, 0x10, 0, 4),
  22. };
  23. static const struct mtk_pin_field_calc mt6797_pin_dir_range[] = {
  24. PIN_FIELD(0, 261, 0x0, 0x10, 0, 1),
  25. };
  26. static const struct mtk_pin_field_calc mt6797_pin_di_range[] = {
  27. PIN_FIELD(0, 261, 0x200, 0x10, 0, 1),
  28. };
  29. static const struct mtk_pin_field_calc mt6797_pin_do_range[] = {
  30. PIN_FIELD(0, 261, 0x100, 0x10, 0, 1),
  31. };
  32. static const struct mtk_pin_reg_calc mt6797_reg_cals[PINCTRL_PIN_REG_MAX] = {
  33. [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6797_pin_mode_range),
  34. [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6797_pin_dir_range),
  35. [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6797_pin_di_range),
  36. [PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6797_pin_do_range),
  37. };
  38. static const char * const mt6797_pinctrl_register_base_names[] = {
  39. "gpio", "iocfgl", "iocfgb", "iocfgr", "iocfgt",
  40. };
  41. static const struct mtk_pin_soc mt6797_data = {
  42. .reg_cal = mt6797_reg_cals,
  43. .pins = mtk_pins_mt6797,
  44. .npins = ARRAY_SIZE(mtk_pins_mt6797),
  45. .ngrps = ARRAY_SIZE(mtk_pins_mt6797),
  46. .gpio_m = 0,
  47. .base_names = mt6797_pinctrl_register_base_names,
  48. .nbase_names = ARRAY_SIZE(mt6797_pinctrl_register_base_names),
  49. };
  50. static const struct of_device_id mt6797_pinctrl_of_match[] = {
  51. { .compatible = "mediatek,mt6797-pinctrl", .data = &mt6797_data },
  52. { }
  53. };
  54. static struct platform_driver mt6797_pinctrl_driver = {
  55. .driver = {
  56. .name = "mt6797-pinctrl",
  57. .of_match_table = mt6797_pinctrl_of_match,
  58. },
  59. .probe = mtk_paris_pinctrl_probe,
  60. };
  61. static int __init mt6797_pinctrl_init(void)
  62. {
  63. return platform_driver_register(&mt6797_pinctrl_driver);
  64. }
  65. arch_initcall(mt6797_pinctrl_init);