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/init.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 
59 static struct platform_driver mtk_pinctrl_driver = {
60 	.probe = mt6397_pinctrl_probe,
61 	.driver = {
62 		.name = "mediatek-mt6397-pinctrl",
63 		.of_match_table = mt6397_pctrl_match,
64 	},
65 };
66 
67 builtin_platform_driver(mtk_pinctrl_driver);
68