cgroup: add seq_file forward declaration for struct cftype
[deliverable/linux.git] / arch / arm / mach-imx / mmdc.c
CommitLineData
9fbbe689
SG
1/*
2 * Copyright 2011 Freescale Semiconductor, Inc.
3 * Copyright 2011 Linaro Ltd.
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12
13#include <linux/init.h>
14#include <linux/io.h>
15#include <linux/module.h>
16#include <linux/of.h>
17#include <linux/of_address.h>
18#include <linux/of_device.h>
19
20#define MMDC_MAPSR 0x404
21#define BP_MMDC_MAPSR_PSD 0
22#define BP_MMDC_MAPSR_PSS 4
23
ec336b28
AH
24#define MMDC_MDMISC 0x18
25#define BM_MMDC_MDMISC_DDR_TYPE 0x18
26#define BP_MMDC_MDMISC_DDR_TYPE 0x3
27
28static int ddr_type;
29
351a102d 30static int imx_mmdc_probe(struct platform_device *pdev)
9fbbe689
SG
31{
32 struct device_node *np = pdev->dev.of_node;
33 void __iomem *mmdc_base, *reg;
34 u32 val;
35 int timeout = 0x400;
36
37 mmdc_base = of_iomap(np, 0);
38 WARN_ON(!mmdc_base);
39
ec336b28
AH
40 reg = mmdc_base + MMDC_MDMISC;
41 /* Get ddr type */
42 val = readl_relaxed(reg);
43 ddr_type = (val & BM_MMDC_MDMISC_DDR_TYPE) >>
44 BP_MMDC_MDMISC_DDR_TYPE;
45
9fbbe689
SG
46 reg = mmdc_base + MMDC_MAPSR;
47
48 /* Enable automatic power saving */
49 val = readl_relaxed(reg);
50 val &= ~(1 << BP_MMDC_MAPSR_PSD);
51 writel_relaxed(val, reg);
52
53 /* Ensure it's successfully enabled */
54 while (!(readl_relaxed(reg) & 1 << BP_MMDC_MAPSR_PSS) && --timeout)
55 cpu_relax();
56
57 if (unlikely(!timeout)) {
58 pr_warn("%s: failed to enable automatic power saving\n",
59 __func__);
60 return -EBUSY;
61 }
62
63 return 0;
64}
65
ec336b28
AH
66int imx_mmdc_get_ddr_type(void)
67{
68 return ddr_type;
69}
70
444d2d33 71static const struct of_device_id imx_mmdc_dt_ids[] = {
9fbbe689
SG
72 { .compatible = "fsl,imx6q-mmdc", },
73 { /* sentinel */ }
74};
75
76static struct platform_driver imx_mmdc_driver = {
77 .driver = {
78 .name = "imx-mmdc",
9fbbe689
SG
79 .of_match_table = imx_mmdc_dt_ids,
80 },
81 .probe = imx_mmdc_probe,
82};
83
84static int __init imx_mmdc_init(void)
85{
86 return platform_driver_register(&imx_mmdc_driver);
87}
88postcore_initcall(imx_mmdc_init);
This page took 0.212196 seconds and 5 git commands to generate.