Blame view

drivers/memory/atmel-sdramc.c 1.73 KB
2b72c9e36   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-only
e81b6abeb   Alexandre Belloni   memory: add a dri...
2
3
4
  /*
   * Atmel (Multi-port DDR-)SDRAM Controller driver
   *
563b41c98   Paul Gortmaker   memory: atmel-sdr...
5
6
   * Author: Alexandre Belloni <alexandre.belloni@free-electrons.com>
   *
e81b6abeb   Alexandre Belloni   memory: add a dri...
7
   * Copyright (C) 2014 Atmel
e81b6abeb   Alexandre Belloni   memory: add a dri...
8
9
10
11
12
   */
  
  #include <linux/clk.h>
  #include <linux/err.h>
  #include <linux/kernel.h>
563b41c98   Paul Gortmaker   memory: atmel-sdr...
13
  #include <linux/init.h>
e81b6abeb   Alexandre Belloni   memory: add a dri...
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  #include <linux/of_platform.h>
  #include <linux/platform_device.h>
  
  struct at91_ramc_caps {
  	bool has_ddrck;
  	bool has_mpddr_clk;
  };
  
  static const struct at91_ramc_caps at91rm9200_caps = { };
  
  static const struct at91_ramc_caps at91sam9g45_caps = {
  	.has_ddrck = 1,
  	.has_mpddr_clk = 0,
  };
  
  static const struct at91_ramc_caps sama5d3_caps = {
  	.has_ddrck = 1,
  	.has_mpddr_clk = 1,
  };
  
  static const struct of_device_id atmel_ramc_of_match[] = {
  	{ .compatible = "atmel,at91rm9200-sdramc", .data = &at91rm9200_caps, },
  	{ .compatible = "atmel,at91sam9260-sdramc", .data = &at91rm9200_caps, },
  	{ .compatible = "atmel,at91sam9g45-ddramc", .data = &at91sam9g45_caps, },
  	{ .compatible = "atmel,sama5d3-ddramc", .data = &sama5d3_caps, },
  	{},
  };
e81b6abeb   Alexandre Belloni   memory: add a dri...
41
42
43
  
  static int atmel_ramc_probe(struct platform_device *pdev)
  {
e81b6abeb   Alexandre Belloni   memory: add a dri...
44
45
  	const struct at91_ramc_caps *caps;
  	struct clk *clk;
7922118f8   LABBE Corentin   memory: atmel-sdr...
46
  	caps = of_device_get_match_data(&pdev->dev);
e81b6abeb   Alexandre Belloni   memory: add a dri...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  
  	if (caps->has_ddrck) {
  		clk = devm_clk_get(&pdev->dev, "ddrck");
  		if (IS_ERR(clk))
  			return PTR_ERR(clk);
  		clk_prepare_enable(clk);
  	}
  
  	if (caps->has_mpddr_clk) {
  		clk = devm_clk_get(&pdev->dev, "mpddr");
  		if (IS_ERR(clk)) {
  			pr_err("AT91 RAMC: couldn't get mpddr clock
  ");
  			return PTR_ERR(clk);
  		}
  		clk_prepare_enable(clk);
  	}
  
  	return 0;
  }
  
  static struct platform_driver atmel_ramc_driver = {
  	.probe		= atmel_ramc_probe,
  	.driver		= {
  		.name	= "atmel-ramc",
e81b6abeb   Alexandre Belloni   memory: add a dri...
72
73
74
  		.of_match_table = atmel_ramc_of_match,
  	},
  };
af6924006   Wei Yongjun   memory: atmel-sdr...
75
  builtin_platform_driver(atmel_ramc_driver);