pinctrl-mt6397.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/module.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. MODULE_DEVICE_TABLE(of, mt6397_pctrl_match);
  52. static struct platform_driver mtk_pinctrl_driver = {
  53. .probe = mt6397_pinctrl_probe,
  54. .driver = {
  55. .name = "mediatek-mt6397-pinctrl",
  56. .of_match_table = mt6397_pctrl_match,
  57. },
  58. };
  59. static int __init mtk_pinctrl_init(void)
  60. {
  61. return platform_driver_register(&mtk_pinctrl_driver);
  62. }
  63. module_init(mtk_pinctrl_init);
  64. MODULE_LICENSE("GPL v2");
  65. MODULE_DESCRIPTION("MediaTek MT6397 Pinctrl Driver");
  66. MODULE_AUTHOR("Hongzhou Yang <hongzhou.yang@mediatek.com>");