These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / pinctrl / mediatek / pinctrl-mt6397.c
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
15 #include <linux/module.h>
16 #include <linux/platform_device.h>
17 #include <linux/of.h>
18 #include <linux/of_device.h>
19 #include <linux/pinctrl/pinctrl.h>
20 #include <linux/pinctrl/pinconf-generic.h>
21 #include <linux/mfd/mt6397/core.h>
22
23 #include "pinctrl-mtk-common.h"
24 #include "pinctrl-mtk-mt6397.h"
25
26 #define MT6397_PIN_REG_BASE  0xc000
27
28 static const struct mtk_pinctrl_devdata mt6397_pinctrl_data = {
29         .pins = mtk_pins_mt6397,
30         .npins = ARRAY_SIZE(mtk_pins_mt6397),
31         .dir_offset = (MT6397_PIN_REG_BASE + 0x000),
32         .ies_offset = MTK_PINCTRL_NOT_SUPPORT,
33         .smt_offset = MTK_PINCTRL_NOT_SUPPORT,
34         .pullen_offset = (MT6397_PIN_REG_BASE + 0x020),
35         .pullsel_offset = (MT6397_PIN_REG_BASE + 0x040),
36         .dout_offset = (MT6397_PIN_REG_BASE + 0x080),
37         .din_offset = (MT6397_PIN_REG_BASE + 0x0a0),
38         .pinmux_offset = (MT6397_PIN_REG_BASE + 0x0c0),
39         .type1_start = 41,
40         .type1_end = 41,
41         .port_shf = 3,
42         .port_mask = 0x3,
43         .port_align = 2,
44 };
45
46 static int mt6397_pinctrl_probe(struct platform_device *pdev)
47 {
48         struct mt6397_chip *mt6397;
49
50         mt6397 = dev_get_drvdata(pdev->dev.parent);
51         return mtk_pctrl_init(pdev, &mt6397_pinctrl_data, mt6397->regmap);
52 }
53
54 static const struct of_device_id mt6397_pctrl_match[] = {
55         { .compatible = "mediatek,mt6397-pinctrl", },
56         { }
57 };
58 MODULE_DEVICE_TABLE(of, mt6397_pctrl_match);
59
60 static struct platform_driver mtk_pinctrl_driver = {
61         .probe = mt6397_pinctrl_probe,
62         .driver = {
63                 .name = "mediatek-mt6397-pinctrl",
64                 .of_match_table = mt6397_pctrl_match,
65         },
66 };
67
68 static int __init mtk_pinctrl_init(void)
69 {
70         return platform_driver_register(&mtk_pinctrl_driver);
71 }
72
73 module_init(mtk_pinctrl_init);
74
75 MODULE_LICENSE("GPL v2");
76 MODULE_DESCRIPTION("MediaTek MT6397 Pinctrl Driver");
77 MODULE_AUTHOR("Hongzhou Yang <hongzhou.yang@mediatek.com>");