| .. | .. |
|---|
| 78 | 78 | |
|---|
| 79 | 79 | static struct sunxi_sram_desc sun50i_a64_sram_c = { |
|---|
| 80 | 80 | .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")), |
|---|
| 83 | 83 | }; |
|---|
| 84 | 84 | |
|---|
| 85 | 85 | static const struct of_device_id sunxi_sram_dt_ids[] = { |
|---|
| .. | .. |
|---|
| 155 | 155 | return 0; |
|---|
| 156 | 156 | } |
|---|
| 157 | 157 | |
|---|
| 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); |
|---|
| 169 | 159 | |
|---|
| 170 | 160 | static inline struct sunxi_sram_desc *to_sram_desc(const struct sunxi_sram_data *data) |
|---|
| 171 | 161 | { |
|---|
| .. | .. |
|---|
| 204 | 194 | if (!data) { |
|---|
| 205 | 195 | ret = -EINVAL; |
|---|
| 206 | 196 | goto err; |
|---|
| 207 | | - }; |
|---|
| 197 | + } |
|---|
| 208 | 198 | |
|---|
| 209 | 199 | for (func = data->func; func->func; func++) { |
|---|
| 210 | 200 | if (val == func->val) { |
|---|
| .. | .. |
|---|
| 264 | 254 | writel(val | ((device << sram_data->offset) & mask), |
|---|
| 265 | 255 | base + sram_data->reg); |
|---|
| 266 | 256 | |
|---|
| 257 | + sram_desc->claimed = true; |
|---|
| 267 | 258 | spin_unlock(&sram_lock); |
|---|
| 268 | 259 | |
|---|
| 269 | 260 | return 0; |
|---|
| .. | .. |
|---|
| 300 | 291 | /* Nothing special */ |
|---|
| 301 | 292 | }; |
|---|
| 302 | 293 | |
|---|
| 294 | +static const struct sunxi_sramc_variant sun8i_h3_sramc_variant = { |
|---|
| 295 | + .has_emac_clock = true, |
|---|
| 296 | +}; |
|---|
| 297 | + |
|---|
| 303 | 298 | static const struct sunxi_sramc_variant sun50i_a64_sramc_variant = { |
|---|
| 304 | 299 | .has_emac_clock = true, |
|---|
| 305 | 300 | }; |
|---|
| .. | .. |
|---|
| 324 | 319 | .writeable_reg = sunxi_sram_regmap_accessible_reg, |
|---|
| 325 | 320 | }; |
|---|
| 326 | 321 | |
|---|
| 327 | | -static int sunxi_sram_probe(struct platform_device *pdev) |
|---|
| 322 | +static int __init sunxi_sram_probe(struct platform_device *pdev) |
|---|
| 328 | 323 | { |
|---|
| 329 | | - struct resource *res; |
|---|
| 330 | | - struct dentry *d; |
|---|
| 331 | 324 | struct regmap *emac_clock; |
|---|
| 332 | 325 | const struct sunxi_sramc_variant *variant; |
|---|
| 326 | + struct device *dev = &pdev->dev; |
|---|
| 333 | 327 | |
|---|
| 334 | 328 | sram_dev = &pdev->dev; |
|---|
| 335 | 329 | |
|---|
| .. | .. |
|---|
| 337 | 331 | if (!variant) |
|---|
| 338 | 332 | return -EINVAL; |
|---|
| 339 | 333 | |
|---|
| 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); |
|---|
| 342 | 335 | if (IS_ERR(base)) |
|---|
| 343 | 336 | 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; |
|---|
| 351 | 337 | |
|---|
| 352 | 338 | if (variant->has_emac_clock) { |
|---|
| 353 | 339 | emac_clock = devm_regmap_init_mmio(&pdev->dev, base, |
|---|
| .. | .. |
|---|
| 356 | 342 | if (IS_ERR(emac_clock)) |
|---|
| 357 | 343 | return PTR_ERR(emac_clock); |
|---|
| 358 | 344 | } |
|---|
| 345 | + |
|---|
| 346 | + of_platform_populate(dev->of_node, NULL, NULL, dev); |
|---|
| 347 | + |
|---|
| 348 | + debugfs_create_file("sram", 0444, NULL, NULL, &sunxi_sram_fops); |
|---|
| 359 | 349 | |
|---|
| 360 | 350 | return 0; |
|---|
| 361 | 351 | } |
|---|
| .. | .. |
|---|
| 379 | 369 | }, |
|---|
| 380 | 370 | { |
|---|
| 381 | 371 | .compatible = "allwinner,sun8i-h3-system-control", |
|---|
| 382 | | - .data = &sun4i_a10_sramc_variant, |
|---|
| 372 | + .data = &sun8i_h3_sramc_variant, |
|---|
| 383 | 373 | }, |
|---|
| 384 | 374 | { |
|---|
| 385 | 375 | .compatible = "allwinner,sun50i-a64-sram-controller", |
|---|
| .. | .. |
|---|
| 387 | 377 | }, |
|---|
| 388 | 378 | { |
|---|
| 389 | 379 | .compatible = "allwinner,sun50i-a64-system-control", |
|---|
| 380 | + .data = &sun50i_a64_sramc_variant, |
|---|
| 381 | + }, |
|---|
| 382 | + { |
|---|
| 383 | + .compatible = "allwinner,sun50i-h5-system-control", |
|---|
| 390 | 384 | .data = &sun50i_a64_sramc_variant, |
|---|
| 391 | 385 | }, |
|---|
| 392 | 386 | { }, |
|---|
| .. | .. |
|---|
| 398 | 392 | .name = "sunxi-sram", |
|---|
| 399 | 393 | .of_match_table = sunxi_sram_dt_match, |
|---|
| 400 | 394 | }, |
|---|
| 401 | | - .probe = sunxi_sram_probe, |
|---|
| 402 | 395 | }; |
|---|
| 403 | | -module_platform_driver(sunxi_sram_driver); |
|---|
| 396 | +builtin_platform_driver_probe(sunxi_sram_driver, sunxi_sram_probe); |
|---|
| 404 | 397 | |
|---|
| 405 | 398 | MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>"); |
|---|
| 406 | 399 | MODULE_DESCRIPTION("Allwinner sunXi SRAM Controller Driver"); |
|---|