1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Zynq power management
5 * Copyright (C) 2012 - 2014 Xilinx
7 * Sören Brinkmann <soren.brinkmann@xilinx.com>
11 #include <linux/of_address.h>
12 #include <linux/of_device.h>
15 /* register offsets */
16 #define DDRC_CTRL_REG1_OFFS 0x60
17 #define DDRC_DRAM_PARAM_REG3_OFFS 0x20
20 #define DDRC_CLOCKSTOP_MASK BIT(23)
21 #define DDRC_SELFREFRESH_MASK BIT(12)
23 static void __iomem
*ddrc_base
;
26 * zynq_pm_ioremap() - Create IO mappings
27 * @comp: DT compatible string
28 * Return: Pointer to the mapped memory or NULL.
30 * Remap the memory region for a compatible DT node.
32 static void __iomem
*zynq_pm_ioremap(const char *comp
)
34 struct device_node
*np
;
35 void __iomem
*base
= NULL
;
37 np
= of_find_compatible_node(NULL
, NULL
, comp
);
39 base
= of_iomap(np
, 0);
42 pr_warn("%s: no compatible node found for '%s'\n", __func__
,
50 * zynq_pm_late_init() - Power management init
52 * Initialization of power management related features and infrastructure.
54 void __init
zynq_pm_late_init(void)
58 ddrc_base
= zynq_pm_ioremap("xlnx,zynq-ddrc-a05");
60 pr_warn("%s: Unable to map DDRC IO memory.\n", __func__
);
63 * Enable DDRC clock stop feature. The HW takes care of
64 * entering/exiting the correct mode depending
67 reg
= readl(ddrc_base
+ DDRC_DRAM_PARAM_REG3_OFFS
);
68 reg
|= DDRC_CLOCKSTOP_MASK
;
69 writel(reg
, ddrc_base
+ DDRC_DRAM_PARAM_REG3_OFFS
);