1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2012 - 2018 Xilinx, Inc
6 * Author: Punnaiah Choudary Kalluri <punnaiah@xilinx.com>
7 * Author: Naga Sureshkumar Relli <nagasure@xilinx.com>
10 #include <linux/clk.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
14 #include <linux/of_platform.h>
15 #include <linux/platform_device.h>
16 #include <linux/amba/bus.h>
19 * struct pl353_smc_data - Private smc driver structure
20 * @memclk: Pointer to the peripheral clock
21 * @aclk: Pointer to the AXI peripheral clock
23 struct pl353_smc_data
{
28 static int __maybe_unused
pl353_smc_suspend(struct device
*dev
)
30 struct pl353_smc_data
*pl353_smc
= dev_get_drvdata(dev
);
32 clk_disable(pl353_smc
->memclk
);
33 clk_disable(pl353_smc
->aclk
);
38 static int __maybe_unused
pl353_smc_resume(struct device
*dev
)
40 struct pl353_smc_data
*pl353_smc
= dev_get_drvdata(dev
);
43 ret
= clk_enable(pl353_smc
->aclk
);
45 dev_err(dev
, "Cannot enable axi domain clock.\n");
49 ret
= clk_enable(pl353_smc
->memclk
);
51 dev_err(dev
, "Cannot enable memory clock.\n");
52 clk_disable(pl353_smc
->aclk
);
59 static SIMPLE_DEV_PM_OPS(pl353_smc_dev_pm_ops
, pl353_smc_suspend
,
62 static const struct of_device_id pl353_smc_supported_children
[] = {
64 .compatible
= "cfi-flash"
67 .compatible
= "arm,pl353-nand-r2p1",
72 static int pl353_smc_probe(struct amba_device
*adev
, const struct amba_id
*id
)
74 struct device_node
*of_node
= adev
->dev
.of_node
;
75 const struct of_device_id
*match
= NULL
;
76 struct pl353_smc_data
*pl353_smc
;
78 pl353_smc
= devm_kzalloc(&adev
->dev
, sizeof(*pl353_smc
), GFP_KERNEL
);
82 pl353_smc
->aclk
= devm_clk_get_enabled(&adev
->dev
, "apb_pclk");
83 if (IS_ERR(pl353_smc
->aclk
))
84 return dev_err_probe(&adev
->dev
, PTR_ERR(pl353_smc
->aclk
),
85 "aclk clock not found.\n");
87 pl353_smc
->memclk
= devm_clk_get_enabled(&adev
->dev
, "memclk");
88 if (IS_ERR(pl353_smc
->memclk
))
89 return dev_err_probe(&adev
->dev
, PTR_ERR(pl353_smc
->memclk
),
90 "memclk clock not found.\n");
92 amba_set_drvdata(adev
, pl353_smc
);
94 /* Find compatible children. Only a single child is supported */
95 for_each_available_child_of_node_scoped(of_node
, child
) {
96 match
= of_match_node(pl353_smc_supported_children
, child
);
98 dev_warn(&adev
->dev
, "unsupported child node\n");
101 of_platform_device_create(child
, NULL
, &adev
->dev
);
105 dev_err(&adev
->dev
, "no matching children\n");
112 static const struct amba_id pl353_ids
[] = {
119 MODULE_DEVICE_TABLE(amba
, pl353_ids
);
121 static struct amba_driver pl353_smc_driver
= {
124 .pm
= &pl353_smc_dev_pm_ops
,
126 .id_table
= pl353_ids
,
127 .probe
= pl353_smc_probe
,
130 module_amba_driver(pl353_smc_driver
);
132 MODULE_AUTHOR("Xilinx, Inc.");
133 MODULE_DESCRIPTION("ARM PL353 SMC Driver");
134 MODULE_LICENSE("GPL");