hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/mfd/vexpress-sysreg.c
....@@ -1,12 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
2
- * This program is free software; you can redistribute it and/or modify
3
- * it under the terms of the GNU General Public License version 2 as
4
- * published by the Free Software Foundation.
5
- *
6
- * This program is distributed in the hope that it will be useful,
7
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
8
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
- * GNU General Public License for more details.
103 *
114 * Copyright (C) 2012 ARM Limited
125 */
....@@ -15,13 +8,12 @@
158 #include <linux/err.h>
169 #include <linux/io.h>
1710 #include <linux/mfd/core.h>
18
-#include <linux/of_address.h>
11
+#include <linux/module.h>
1912 #include <linux/of_platform.h>
2013 #include <linux/platform_data/syscon.h>
2114 #include <linux/platform_device.h>
2215 #include <linux/slab.h>
2316 #include <linux/stat.h>
24
-#include <linux/vexpress.h>
2517
2618 #define SYS_ID 0x000
2719 #define SYS_SW 0x004
....@@ -44,34 +36,7 @@
4436 #define SYS_CFGCTRL 0x0a4
4537 #define SYS_CFGSTAT 0x0a8
4638
47
-#define SYS_HBI_MASK 0xfff
48
-#define SYS_PROCIDx_HBI_SHIFT 0
49
-
50
-#define SYS_MISC_MASTERSITE (1 << 14)
51
-
52
-void vexpress_flags_set(u32 data)
53
-{
54
- static void __iomem *base;
55
-
56
- if (!base) {
57
- struct device_node *node = of_find_compatible_node(NULL, NULL,
58
- "arm,vexpress-sysreg");
59
-
60
- base = of_iomap(node, 0);
61
- }
62
-
63
- if (WARN_ON(!base))
64
- return;
65
-
66
- writel(~0, base + SYS_FLAGSCLR);
67
- writel(data, base + SYS_FLAGSSET);
68
-}
69
-
7039 /* The sysreg block is just a random collection of various functions... */
71
-
72
-static struct syscon_platform_data vexpress_sysreg_sys_id_pdata = {
73
- .label = "sys_id",
74
-};
7540
7641 static struct bgpio_pdata vexpress_sysreg_sys_led_pdata = {
7742 .label = "sys_led",
....@@ -91,24 +56,8 @@
9156 .ngpio = 1,
9257 };
9358
94
-static struct syscon_platform_data vexpress_sysreg_sys_misc_pdata = {
95
- .label = "sys_misc",
96
-};
97
-
98
-static struct syscon_platform_data vexpress_sysreg_sys_procid_pdata = {
99
- .label = "sys_procid",
100
-};
101
-
10259 static struct mfd_cell vexpress_sysreg_cells[] = {
10360 {
104
- .name = "syscon",
105
- .num_resources = 1,
106
- .resources = (struct resource []) {
107
- DEFINE_RES_MEM(SYS_ID, 0x4),
108
- },
109
- .platform_data = &vexpress_sysreg_sys_id_pdata,
110
- .pdata_size = sizeof(vexpress_sysreg_sys_id_pdata),
111
- }, {
11261 .name = "basic-mmio-gpio",
11362 .of_compatible = "arm,vexpress-sysreg,sys_led",
11463 .num_resources = 1,
....@@ -136,26 +85,10 @@
13685 .platform_data = &vexpress_sysreg_sys_flash_pdata,
13786 .pdata_size = sizeof(vexpress_sysreg_sys_flash_pdata),
13887 }, {
139
- .name = "syscon",
140
- .num_resources = 1,
141
- .resources = (struct resource []) {
142
- DEFINE_RES_MEM(SYS_MISC, 0x4),
143
- },
144
- .platform_data = &vexpress_sysreg_sys_misc_pdata,
145
- .pdata_size = sizeof(vexpress_sysreg_sys_misc_pdata),
146
- }, {
147
- .name = "syscon",
148
- .num_resources = 1,
149
- .resources = (struct resource []) {
150
- DEFINE_RES_MEM(SYS_PROCID0, 0x8),
151
- },
152
- .platform_data = &vexpress_sysreg_sys_procid_pdata,
153
- .pdata_size = sizeof(vexpress_sysreg_sys_procid_pdata),
154
- }, {
15588 .name = "vexpress-syscfg",
15689 .num_resources = 1,
15790 .resources = (struct resource []) {
158
- DEFINE_RES_MEM(SYS_CFGDATA, 0xc),
91
+ DEFINE_RES_MEM(SYS_MISC, 0x4c),
15992 },
16093 }
16194 };
....@@ -165,8 +98,6 @@
16598 struct resource *mem;
16699 void __iomem *base;
167100 struct gpio_chip *mmc_gpio_chip;
168
- int master;
169
- u32 dt_hbi;
170101
171102 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
172103 if (!mem)
....@@ -175,21 +106,6 @@
175106 base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
176107 if (!base)
177108 return -ENOMEM;
178
-
179
- master = readl(base + SYS_MISC) & SYS_MISC_MASTERSITE ?
180
- VEXPRESS_SITE_DB2 : VEXPRESS_SITE_DB1;
181
- vexpress_config_set_master(master);
182
-
183
- /* Confirm board type against DT property, if available */
184
- if (of_property_read_u32(of_root, "arm,hbi", &dt_hbi) == 0) {
185
- u32 id = readl(base + (master == VEXPRESS_SITE_DB1 ?
186
- SYS_PROCID0 : SYS_PROCID1));
187
- u32 hbi = (id >> SYS_PROCIDx_HBI_SHIFT) & SYS_HBI_MASK;
188
-
189
- if (WARN_ON(dt_hbi != hbi))
190
- dev_warn(&pdev->dev, "DT HBI (%x) is not matching hardware (%x)!\n",
191
- dt_hbi, hbi);
192
- }
193109
194110 /*
195111 * Duplicated SYS_MCI pseudo-GPIO controller for compatibility with
....@@ -202,9 +118,9 @@
202118 bgpio_init(mmc_gpio_chip, &pdev->dev, 0x4, base + SYS_MCI,
203119 NULL, NULL, NULL, NULL, 0);
204120 mmc_gpio_chip->ngpio = 2;
205
- gpiochip_add_data(mmc_gpio_chip, NULL);
121
+ devm_gpiochip_add_data(&pdev->dev, mmc_gpio_chip, NULL);
206122
207
- return mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
123
+ return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
208124 vexpress_sysreg_cells,
209125 ARRAY_SIZE(vexpress_sysreg_cells), mem, 0, NULL);
210126 }
....@@ -213,6 +129,7 @@
213129 { .compatible = "arm,vexpress-sysreg", },
214130 {},
215131 };
132
+MODULE_DEVICE_TABLE(of, vexpress_sysreg_match);
216133
217134 static struct platform_driver vexpress_sysreg_driver = {
218135 .driver = {
....@@ -222,14 +139,5 @@
222139 .probe = vexpress_sysreg_probe,
223140 };
224141
225
-static int __init vexpress_sysreg_init(void)
226
-{
227
- struct device_node *node;
228
-
229
- /* Need the sysreg early, before any other device... */
230
- for_each_matching_node(node, vexpress_sysreg_match)
231
- of_platform_device_create(node, NULL, NULL);
232
-
233
- return platform_driver_register(&vexpress_sysreg_driver);
234
-}
235
-core_initcall(vexpress_sysreg_init);
142
+module_platform_driver(vexpress_sysreg_driver);
143
+MODULE_LICENSE("GPL v2");