2 * Atmel (Multi-port DDR-)SDRAM Controller driver
4 * Copyright (C) 2014 Atmel
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <linux/clk.h>
21 #include <linux/err.h>
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/of_platform.h>
25 #include <linux/platform_device.h>
27 struct at91_ramc_caps {
32 static const struct at91_ramc_caps at91rm9200_caps = { };
34 static const struct at91_ramc_caps at91sam9g45_caps = {
39 static const struct at91_ramc_caps sama5d3_caps = {
44 static const struct of_device_id atmel_ramc_of_match[] = {
45 { .compatible = "atmel,at91rm9200-sdramc", .data = &at91rm9200_caps, },
46 { .compatible = "atmel,at91sam9260-sdramc", .data = &at91rm9200_caps, },
47 { .compatible = "atmel,at91sam9g45-ddramc", .data = &at91sam9g45_caps, },
48 { .compatible = "atmel,sama5d3-ddramc", .data = &sama5d3_caps, },
51 MODULE_DEVICE_TABLE(of, atmel_ramc_of_match);
53 static int atmel_ramc_probe(struct platform_device *pdev)
55 const struct of_device_id *match;
56 const struct at91_ramc_caps *caps;
59 match = of_match_device(atmel_ramc_of_match, &pdev->dev);
62 if (caps->has_ddrck) {
63 clk = devm_clk_get(&pdev->dev, "ddrck");
66 clk_prepare_enable(clk);
69 if (caps->has_mpddr_clk) {
70 clk = devm_clk_get(&pdev->dev, "mpddr");
72 pr_err("AT91 RAMC: couldn't get mpddr clock\n");
75 clk_prepare_enable(clk);
81 static struct platform_driver atmel_ramc_driver = {
82 .probe = atmel_ramc_probe,
85 .of_match_table = atmel_ramc_of_match,
89 static int __init atmel_ramc_init(void)
91 return platform_driver_register(&atmel_ramc_driver);
93 module_init(atmel_ramc_init);
95 MODULE_LICENSE("GPL v2");
96 MODULE_AUTHOR("Alexandre Belloni <alexandre.belloni@free-electrons.com>");
97 MODULE_DESCRIPTION("Atmel (Multi-port DDR-)SDRAM Controller");