pinctrl-mt6397.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 2015 MediaTek Inc.
  3. * Author: Hongzhou.Yang <hongzhou.yang@mediatek.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/of.h>
  17. #include <linux/of_device.h>
  18. #include <linux/pinctrl/pinctrl.h>
  19. #include <linux/pinctrl/pinconf-generic.h>
  20. #include <linux/mfd/mt6397/core.h>
  21. #include "pinctrl-mtk-common.h"
  22. #include "pinctrl-mtk-mt6397.h"
  23. #define MT6397_PIN_REG_BASE 0xc000
  24. static const struct mtk_pinctrl_devdata mt6397_pinctrl_data = {
  25. .pins = mtk_pins_mt6397,
  26. .npins = ARRAY_SIZE(mtk_pins_mt6397),
  27. .dir_offset = (MT6397_PIN_REG_BASE + 0x000),
  28. .ies_offset = MTK_PINCTRL_NOT_SUPPORT,
  29. .smt_offset = MTK_PINCTRL_NOT_SUPPORT,
  30. .pullen_offset = (MT6397_PIN_REG_BASE + 0x020),
  31. .pullsel_offset = (MT6397_PIN_REG_BASE + 0x040),
  32. .dout_offset = (MT6397_PIN_REG_BASE + 0x080),
  33. .din_offset = (MT6397_PIN_REG_BASE + 0x0a0),
  34. .pinmux_offset = (MT6397_PIN_REG_BASE + 0x0c0),
  35. .type1_start = 41,
  36. .type1_end = 41,
  37. .port_shf = 3,
  38. .port_mask = 0x3,
  39. .port_align = 2,
  40. };
  41. static int mt6397_pinctrl_probe(struct platform_device *pdev)
  42. {
  43. struct mt6397_chip *mt6397;
  44. mt6397 = dev_get_drvdata(pdev->dev.parent);
  45. return mtk_pctrl_init(pdev, &mt6397_pinctrl_data, mt6397->regmap);
  46. }
  47. static const struct of_device_id mt6397_pctrl_match[] = {
  48. { .compatible = "mediatek,mt6397-pinctrl", },
  49. { }
  50. };
  51. static struct platform_driver mtk_pinctrl_driver = {
  52. .probe = mt6397_pinctrl_probe,
  53. .driver = {
  54. .name = "mediatek-mt6397-pinctrl",
  55. .of_match_table = mt6397_pctrl_match,
  56. },
  57. };
  58. static int __init mtk_pinctrl_init(void)
  59. {
  60. return platform_driver_register(&mtk_pinctrl_driver);
  61. }
  62. device_initcall(mtk_pinctrl_init);