Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / drivers / memory / atmel-sdramc.c
blob53a341f3b305d43d8db5d95fa624976591026cf2
1 /*
2 * Atmel (Multi-port DDR-)SDRAM Controller driver
4 * Author: Alexandre Belloni <alexandre.belloni@free-electrons.com>
6 * Copyright (C) 2014 Atmel
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <linux/clk.h>
23 #include <linux/err.h>
24 #include <linux/kernel.h>
25 #include <linux/init.h>
26 #include <linux/of_platform.h>
27 #include <linux/platform_device.h>
29 struct at91_ramc_caps {
30 bool has_ddrck;
31 bool has_mpddr_clk;
34 static const struct at91_ramc_caps at91rm9200_caps = { };
36 static const struct at91_ramc_caps at91sam9g45_caps = {
37 .has_ddrck = 1,
38 .has_mpddr_clk = 0,
41 static const struct at91_ramc_caps sama5d3_caps = {
42 .has_ddrck = 1,
43 .has_mpddr_clk = 1,
46 static const struct of_device_id atmel_ramc_of_match[] = {
47 { .compatible = "atmel,at91rm9200-sdramc", .data = &at91rm9200_caps, },
48 { .compatible = "atmel,at91sam9260-sdramc", .data = &at91rm9200_caps, },
49 { .compatible = "atmel,at91sam9g45-ddramc", .data = &at91sam9g45_caps, },
50 { .compatible = "atmel,sama5d3-ddramc", .data = &sama5d3_caps, },
51 {},
54 static int atmel_ramc_probe(struct platform_device *pdev)
56 const struct of_device_id *match;
57 const struct at91_ramc_caps *caps;
58 struct clk *clk;
60 match = of_match_device(atmel_ramc_of_match, &pdev->dev);
61 caps = match->data;
63 if (caps->has_ddrck) {
64 clk = devm_clk_get(&pdev->dev, "ddrck");
65 if (IS_ERR(clk))
66 return PTR_ERR(clk);
67 clk_prepare_enable(clk);
70 if (caps->has_mpddr_clk) {
71 clk = devm_clk_get(&pdev->dev, "mpddr");
72 if (IS_ERR(clk)) {
73 pr_err("AT91 RAMC: couldn't get mpddr clock\n");
74 return PTR_ERR(clk);
76 clk_prepare_enable(clk);
79 return 0;
82 static struct platform_driver atmel_ramc_driver = {
83 .probe = atmel_ramc_probe,
84 .driver = {
85 .name = "atmel-ramc",
86 .of_match_table = atmel_ramc_of_match,
90 static int __init atmel_ramc_init(void)
92 return platform_driver_register(&atmel_ramc_driver);
94 device_initcall(atmel_ramc_init);