0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/clk.h>
0011 #include <linux/err.h>
0012 #include <linux/kernel.h>
0013 #include <linux/init.h>
0014 #include <linux/of_platform.h>
0015 #include <linux/platform_device.h>
0016
0017 struct at91_ramc_caps {
0018 bool has_ddrck;
0019 bool has_mpddr_clk;
0020 };
0021
0022 static const struct at91_ramc_caps at91rm9200_caps = { };
0023
0024 static const struct at91_ramc_caps at91sam9g45_caps = {
0025 .has_ddrck = 1,
0026 .has_mpddr_clk = 0,
0027 };
0028
0029 static const struct at91_ramc_caps sama5d3_caps = {
0030 .has_ddrck = 1,
0031 .has_mpddr_clk = 1,
0032 };
0033
0034 static const struct of_device_id atmel_ramc_of_match[] = {
0035 { .compatible = "atmel,at91rm9200-sdramc", .data = &at91rm9200_caps, },
0036 { .compatible = "atmel,at91sam9260-sdramc", .data = &at91rm9200_caps, },
0037 { .compatible = "atmel,at91sam9g45-ddramc", .data = &at91sam9g45_caps, },
0038 { .compatible = "atmel,sama5d3-ddramc", .data = &sama5d3_caps, },
0039 {},
0040 };
0041
0042 static int atmel_ramc_probe(struct platform_device *pdev)
0043 {
0044 const struct at91_ramc_caps *caps;
0045 struct clk *clk;
0046
0047 caps = of_device_get_match_data(&pdev->dev);
0048
0049 if (caps->has_ddrck) {
0050 clk = devm_clk_get(&pdev->dev, "ddrck");
0051 if (IS_ERR(clk))
0052 return PTR_ERR(clk);
0053 clk_prepare_enable(clk);
0054 }
0055
0056 if (caps->has_mpddr_clk) {
0057 clk = devm_clk_get(&pdev->dev, "mpddr");
0058 if (IS_ERR(clk)) {
0059 pr_err("AT91 RAMC: couldn't get mpddr clock\n");
0060 return PTR_ERR(clk);
0061 }
0062 clk_prepare_enable(clk);
0063 }
0064
0065 return 0;
0066 }
0067
0068 static struct platform_driver atmel_ramc_driver = {
0069 .probe = atmel_ramc_probe,
0070 .driver = {
0071 .name = "atmel-ramc",
0072 .of_match_table = atmel_ramc_of_match,
0073 },
0074 };
0075
0076 builtin_platform_driver(atmel_ramc_driver);