|
7 | 7 |
|
8 | 8 | #include <linux/clk-provider.h> |
9 | 9 | #include <linux/io.h> |
10 | | -#include <linux/of_address.h> |
| 10 | +#include <linux/module.h> |
| 11 | +#include <linux/of_device.h> |
| 12 | +#include <linux/platform_device.h> |
11 | 13 |
|
12 | 14 | #include "ccu_common.h" |
13 | 15 | #include "ccu_reset.h" |
@@ -1425,18 +1427,19 @@ static const struct sunxi_ccu_desc sun7i_a20_ccu_desc = { |
1425 | 1427 | .num_resets = ARRAY_SIZE(sunxi_a10_a20_ccu_resets), |
1426 | 1428 | }; |
1427 | 1429 |
|
1428 | | -static void __init sun4i_ccu_init(struct device_node *node, |
1429 | | - const struct sunxi_ccu_desc *desc) |
| 1430 | +static int sun4i_a10_ccu_probe(struct platform_device *pdev) |
1430 | 1431 | { |
| 1432 | + const struct sunxi_ccu_desc *desc; |
1431 | 1433 | void __iomem *reg; |
1432 | 1434 | u32 val; |
1433 | 1435 |
|
1434 | | - reg = of_io_request_and_map(node, 0, of_node_full_name(node)); |
1435 | | - if (IS_ERR(reg)) { |
1436 | | - pr_err("%s: Could not map the clock registers\n", |
1437 | | - of_node_full_name(node)); |
1438 | | - return; |
1439 | | - } |
| 1436 | + desc = of_device_get_match_data(&pdev->dev); |
| 1437 | + if (!desc) |
| 1438 | + return -EINVAL; |
| 1439 | + |
| 1440 | + reg = devm_platform_ioremap_resource(pdev, 0); |
| 1441 | + if (IS_ERR(reg)) |
| 1442 | + return PTR_ERR(reg); |
1440 | 1443 |
|
1441 | 1444 | val = readl(reg + SUN4I_PLL_AUDIO_REG); |
1442 | 1445 |
|
@@ -1464,19 +1467,30 @@ static void __init sun4i_ccu_init(struct device_node *node, |
1464 | 1467 | val &= ~GENMASK(7, 6); |
1465 | 1468 | writel(val | (2 << 6), reg + SUN4I_AHB_REG); |
1466 | 1469 |
|
1467 | | - of_sunxi_ccu_probe(node, reg, desc); |
| 1470 | + return devm_sunxi_ccu_probe(&pdev->dev, reg, desc); |
1468 | 1471 | } |
1469 | 1472 |
|
1470 | | -static void __init sun4i_a10_ccu_setup(struct device_node *node) |
1471 | | -{ |
1472 | | - sun4i_ccu_init(node, &sun4i_a10_ccu_desc); |
1473 | | -} |
1474 | | -CLK_OF_DECLARE(sun4i_a10_ccu, "allwinner,sun4i-a10-ccu", |
1475 | | - sun4i_a10_ccu_setup); |
| 1473 | +static const struct of_device_id sun4i_a10_ccu_ids[] = { |
| 1474 | + { |
| 1475 | + .compatible = "allwinner,sun4i-a10-ccu", |
| 1476 | + .data = &sun4i_a10_ccu_desc, |
| 1477 | + }, |
| 1478 | + { |
| 1479 | + .compatible = "allwinner,sun7i-a20-ccu", |
| 1480 | + .data = &sun7i_a20_ccu_desc, |
| 1481 | + }, |
| 1482 | + { } |
| 1483 | +}; |
1476 | 1484 |
|
1477 | | -static void __init sun7i_a20_ccu_setup(struct device_node *node) |
1478 | | -{ |
1479 | | - sun4i_ccu_init(node, &sun7i_a20_ccu_desc); |
1480 | | -} |
1481 | | -CLK_OF_DECLARE(sun7i_a20_ccu, "allwinner,sun7i-a20-ccu", |
1482 | | - sun7i_a20_ccu_setup); |
| 1485 | +static struct platform_driver sun4i_a10_ccu_driver = { |
| 1486 | + .probe = sun4i_a10_ccu_probe, |
| 1487 | + .driver = { |
| 1488 | + .name = "sun4i-a10-ccu", |
| 1489 | + .suppress_bind_attrs = true, |
| 1490 | + .of_match_table = sun4i_a10_ccu_ids, |
| 1491 | + }, |
| 1492 | +}; |
| 1493 | +module_platform_driver(sun4i_a10_ccu_driver); |
| 1494 | + |
| 1495 | +MODULE_IMPORT_NS(SUNXI_CCU); |
| 1496 | +MODULE_LICENSE("GPL"); |
0 commit comments