hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/soc/sunxi/sunxi_sram.c
....@@ -78,8 +78,8 @@
7878
7979 static struct sunxi_sram_desc sun50i_a64_sram_c = {
8080 .data = SUNXI_SRAM_DATA("C", 0x4, 24, 1,
81
- SUNXI_SRAM_MAP(0, 1, "cpu"),
82
- SUNXI_SRAM_MAP(1, 0, "de2")),
81
+ SUNXI_SRAM_MAP(1, 0, "cpu"),
82
+ SUNXI_SRAM_MAP(0, 1, "de2")),
8383 };
8484
8585 static const struct of_device_id sunxi_sram_dt_ids[] = {
....@@ -155,17 +155,7 @@
155155 return 0;
156156 }
157157
158
-static int sunxi_sram_open(struct inode *inode, struct file *file)
159
-{
160
- return single_open(file, sunxi_sram_show, inode->i_private);
161
-}
162
-
163
-static const struct file_operations sunxi_sram_fops = {
164
- .open = sunxi_sram_open,
165
- .read = seq_read,
166
- .llseek = seq_lseek,
167
- .release = single_release,
168
-};
158
+DEFINE_SHOW_ATTRIBUTE(sunxi_sram);
169159
170160 static inline struct sunxi_sram_desc *to_sram_desc(const struct sunxi_sram_data *data)
171161 {
....@@ -204,7 +194,7 @@
204194 if (!data) {
205195 ret = -EINVAL;
206196 goto err;
207
- };
197
+ }
208198
209199 for (func = data->func; func->func; func++) {
210200 if (val == func->val) {
....@@ -264,6 +254,7 @@
264254 writel(val | ((device << sram_data->offset) & mask),
265255 base + sram_data->reg);
266256
257
+ sram_desc->claimed = true;
267258 spin_unlock(&sram_lock);
268259
269260 return 0;
....@@ -300,6 +291,10 @@
300291 /* Nothing special */
301292 };
302293
294
+static const struct sunxi_sramc_variant sun8i_h3_sramc_variant = {
295
+ .has_emac_clock = true,
296
+};
297
+
303298 static const struct sunxi_sramc_variant sun50i_a64_sramc_variant = {
304299 .has_emac_clock = true,
305300 };
....@@ -324,12 +319,11 @@
324319 .writeable_reg = sunxi_sram_regmap_accessible_reg,
325320 };
326321
327
-static int sunxi_sram_probe(struct platform_device *pdev)
322
+static int __init sunxi_sram_probe(struct platform_device *pdev)
328323 {
329
- struct resource *res;
330
- struct dentry *d;
331324 struct regmap *emac_clock;
332325 const struct sunxi_sramc_variant *variant;
326
+ struct device *dev = &pdev->dev;
333327
334328 sram_dev = &pdev->dev;
335329
....@@ -337,17 +331,9 @@
337331 if (!variant)
338332 return -EINVAL;
339333
340
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
341
- base = devm_ioremap_resource(&pdev->dev, res);
334
+ base = devm_platform_ioremap_resource(pdev, 0);
342335 if (IS_ERR(base))
343336 return PTR_ERR(base);
344
-
345
- of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
346
-
347
- d = debugfs_create_file("sram", S_IRUGO, NULL, NULL,
348
- &sunxi_sram_fops);
349
- if (!d)
350
- return -ENOMEM;
351337
352338 if (variant->has_emac_clock) {
353339 emac_clock = devm_regmap_init_mmio(&pdev->dev, base,
....@@ -356,6 +342,10 @@
356342 if (IS_ERR(emac_clock))
357343 return PTR_ERR(emac_clock);
358344 }
345
+
346
+ of_platform_populate(dev->of_node, NULL, NULL, dev);
347
+
348
+ debugfs_create_file("sram", 0444, NULL, NULL, &sunxi_sram_fops);
359349
360350 return 0;
361351 }
....@@ -379,7 +369,7 @@
379369 },
380370 {
381371 .compatible = "allwinner,sun8i-h3-system-control",
382
- .data = &sun4i_a10_sramc_variant,
372
+ .data = &sun8i_h3_sramc_variant,
383373 },
384374 {
385375 .compatible = "allwinner,sun50i-a64-sram-controller",
....@@ -387,6 +377,10 @@
387377 },
388378 {
389379 .compatible = "allwinner,sun50i-a64-system-control",
380
+ .data = &sun50i_a64_sramc_variant,
381
+ },
382
+ {
383
+ .compatible = "allwinner,sun50i-h5-system-control",
390384 .data = &sun50i_a64_sramc_variant,
391385 },
392386 { },
....@@ -398,9 +392,8 @@
398392 .name = "sunxi-sram",
399393 .of_match_table = sunxi_sram_dt_match,
400394 },
401
- .probe = sunxi_sram_probe,
402395 };
403
-module_platform_driver(sunxi_sram_driver);
396
+builtin_platform_driver_probe(sunxi_sram_driver, sunxi_sram_probe);
404397
405398 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
406399 MODULE_DESCRIPTION("Allwinner sunXi SRAM Controller Driver");