blob: 77d510d8f6003c89dc78296bbfc2cf326307670e [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Thomas Abraham16ca80a2016-04-23 22:18:08 +05302/*
3 * Exynos7420 pinctrl driver.
4 * Copyright (C) 2016 Samsung Electronics
5 * Thomas Abraham <thomas.ab@samsung.com>
Thomas Abraham16ca80a2016-04-23 22:18:08 +05306 */
7
8#include <common.h>
9#include <dm.h>
10#include <errno.h>
11#include <asm/io.h>
12#include <dm/pinctrl.h>
13#include <dm/root.h>
14#include <fdtdec.h>
15#include <asm/arch/pinmux.h>
16#include "pinctrl-exynos.h"
17
Thomas Abraham16ca80a2016-04-23 22:18:08 +053018#define GPD1_OFFSET 0xc0
Sam Protsenko2ed4ba82023-11-30 14:13:49 -060019#define PIN_CON 0x00 /* Offset of pin function register */
20#define PIN_PUD 0x08 /* Offset of pin pull up/down config register */
Thomas Abraham16ca80a2016-04-23 22:18:08 +053021
22static struct exynos_pinctrl_config_data serial2_conf[] = {
23 {
24 .offset = GPD1_OFFSET + PIN_CON,
25 .mask = 0x00ff0000,
26 .value = 0x00220000,
27 }, {
28 .offset = GPD1_OFFSET + PIN_PUD,
29 .mask = 0x00000f00,
30 .value = 0x00000f00,
31 },
32};
33
34static int exynos7420_pinctrl_request(struct udevice *dev, int peripheral,
35 int flags)
36{
37 struct exynos_pinctrl_priv *priv = dev_get_priv(dev);
38 unsigned long base = priv->base;
39
40 switch (PERIPH_ID_UART2) {
41 case PERIPH_ID_UART2:
42 exynos_pinctrl_setup_peri(serial2_conf,
43 ARRAY_SIZE(serial2_conf), base);
44 break;
45 default:
46 return -ENODEV;
47 }
48
49 return 0;
50}
51
52static struct pinctrl_ops exynos7420_pinctrl_ops = {
53 .set_state = exynos_pinctrl_set_state,
54 .request = exynos7420_pinctrl_request,
55};
56
57/* pin banks of Exynos7420 pin-controller - BUS0 */
58static const struct samsung_pin_bank_data exynos7420_pin_banks0[] = {
59 EXYNOS_PIN_BANK(5, 0x000, "gpb0"),
60 EXYNOS_PIN_BANK(8, 0x020, "gpc0"),
61 EXYNOS_PIN_BANK(2, 0x040, "gpc1"),
62 EXYNOS_PIN_BANK(6, 0x060, "gpc2"),
63 EXYNOS_PIN_BANK(8, 0x080, "gpc3"),
64 EXYNOS_PIN_BANK(4, 0x0a0, "gpd0"),
65 EXYNOS_PIN_BANK(6, 0x0c0, "gpd1"),
66 EXYNOS_PIN_BANK(8, 0x0e0, "gpd2"),
67 EXYNOS_PIN_BANK(5, 0x100, "gpd4"),
68 EXYNOS_PIN_BANK(4, 0x120, "gpd5"),
69 EXYNOS_PIN_BANK(6, 0x140, "gpd6"),
70 EXYNOS_PIN_BANK(3, 0x160, "gpd7"),
71 EXYNOS_PIN_BANK(2, 0x180, "gpd8"),
72 EXYNOS_PIN_BANK(2, 0x1a0, "gpg0"),
73 EXYNOS_PIN_BANK(4, 0x1c0, "gpg3"),
74};
75
76/* pin banks of Exynos7420 pin-controller - FSYS0 */
77static const struct samsung_pin_bank_data exynos7420_pin_banks1[] = {
78 EXYNOS_PIN_BANK(7, 0x000, "gpr4"),
79};
80
81/* pin banks of Exynos7420 pin-controller - FSYS1 */
82static const struct samsung_pin_bank_data exynos7420_pin_banks2[] = {
83 EXYNOS_PIN_BANK(4, 0x000, "gpr0"),
84 EXYNOS_PIN_BANK(8, 0x020, "gpr1"),
85 EXYNOS_PIN_BANK(5, 0x040, "gpr2"),
86 EXYNOS_PIN_BANK(8, 0x060, "gpr3"),
87};
88
89const struct samsung_pin_ctrl exynos7420_pin_ctrl[] = {
90 {
91 /* pin-controller instance BUS0 data */
92 .pin_banks = exynos7420_pin_banks0,
93 .nr_banks = ARRAY_SIZE(exynos7420_pin_banks0),
94 }, {
95 /* pin-controller instance FSYS0 data */
96 .pin_banks = exynos7420_pin_banks1,
97 .nr_banks = ARRAY_SIZE(exynos7420_pin_banks1),
98 }, {
99 /* pin-controller instance FSYS1 data */
100 .pin_banks = exynos7420_pin_banks2,
101 .nr_banks = ARRAY_SIZE(exynos7420_pin_banks2),
102 },
103};
104
105static const struct udevice_id exynos7420_pinctrl_ids[] = {
106 { .compatible = "samsung,exynos7420-pinctrl",
107 .data = (ulong)exynos7420_pin_ctrl },
108 { }
109};
110
111U_BOOT_DRIVER(pinctrl_exynos7420) = {
112 .name = "pinctrl_exynos7420",
113 .id = UCLASS_PINCTRL,
114 .of_match = exynos7420_pinctrl_ids,
Simon Glass41575d82020-12-03 16:55:17 -0700115 .priv_auto = sizeof(struct exynos_pinctrl_priv),
Thomas Abraham16ca80a2016-04-23 22:18:08 +0530116 .ops = &exynos7420_pinctrl_ops,
117 .probe = exynos_pinctrl_probe,
Thomas Abraham16ca80a2016-04-23 22:18:08 +0530118};