aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-zynq
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2014-01-06 08:52:02 -0500
committerMichal Simek <michal.simek@xilinx.com>2014-02-10 05:21:22 -0500
commit871c6971ec38d485fa601f6d9f60cb8d25a5aae1 (patch)
tree13cee4c85e4027522750bc3c8211fb5b8f206a38 /arch/arm/mach-zynq
parent7b274efef794fe566ee42f3091276d0598952558 (diff)
ARM: zynq: Add and use zynq_slcr_read/write() helper functions
Use zynq_slcr_read/write helper functions for reg access instead of readl/writel. Also use regmap when it is ready. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'arch/arm/mach-zynq')
-rw-r--r--arch/arm/mach-zynq/slcr.c56
1 files changed, 48 insertions, 8 deletions
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c
index 34c1c2a20d8b..ab85f4e8edb0 100644
--- a/arch/arm/mach-zynq/slcr.c
+++ b/arch/arm/mach-zynq/slcr.c
@@ -35,6 +35,42 @@ static void __iomem *zynq_slcr_base;
35static struct regmap *zynq_slcr_regmap; 35static struct regmap *zynq_slcr_regmap;
36 36
37/** 37/**
38 * zynq_slcr_write - Write to a register in SLCR block
39 *
40 * @val: Value to write to the register
41 * @offset: Register offset in SLCR block
42 *
43 * Return: a negative value on error, 0 on success
44 */
45static int zynq_slcr_write(u32 val, u32 offset)
46{
47 if (!zynq_slcr_regmap) {
48 writel(val, zynq_slcr_base + offset);
49 return 0;
50 }
51
52 return regmap_write(zynq_slcr_regmap, offset, val);
53}
54
55/**
56 * zynq_slcr_read - Read a register in SLCR block
57 *
58 * @val: Pointer to value to be read from SLCR
59 * @offset: Register offset in SLCR block
60 *
61 * Return: a negative value on error, 0 on success
62 */
63static int zynq_slcr_read(u32 *val, u32 offset)
64{
65 if (zynq_slcr_regmap)
66 return regmap_read(zynq_slcr_regmap, offset, val);
67
68 *val = readl(zynq_slcr_base + offset);
69
70 return 0;
71}
72
73/**
38 * zynq_slcr_system_reset - Reset the entire system. 74 * zynq_slcr_system_reset - Reset the entire system.
39 */ 75 */
40void zynq_slcr_system_reset(void) 76void zynq_slcr_system_reset(void)
@@ -53,9 +89,9 @@ void zynq_slcr_system_reset(void)
53 * the FSBL not loading the bitstream after soft-reboot 89 * the FSBL not loading the bitstream after soft-reboot
54 * This is a temporary solution until we know more. 90 * This is a temporary solution until we know more.
55 */ 91 */
56 reboot = readl(zynq_slcr_base + SLCR_REBOOT_STATUS_OFFSET); 92 zynq_slcr_read(&reboot, SLCR_REBOOT_STATUS_OFFSET);
57 writel(reboot & 0xF0FFFFFF, zynq_slcr_base + SLCR_REBOOT_STATUS_OFFSET); 93 zynq_slcr_write(reboot & 0xF0FFFFFF, SLCR_REBOOT_STATUS_OFFSET);
58 writel(1, zynq_slcr_base + SLCR_PS_RST_CTRL_OFFSET); 94 zynq_slcr_write(1, SLCR_PS_RST_CTRL_OFFSET);
59} 95}
60 96
61/** 97/**
@@ -64,11 +100,13 @@ void zynq_slcr_system_reset(void)
64 */ 100 */
65void zynq_slcr_cpu_start(int cpu) 101void zynq_slcr_cpu_start(int cpu)
66{ 102{
67 u32 reg = readl(zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET); 103 u32 reg;
104
105 zynq_slcr_read(&reg, SLCR_A9_CPU_RST_CTRL_OFFSET);
68 reg &= ~(SLCR_A9_CPU_RST << cpu); 106 reg &= ~(SLCR_A9_CPU_RST << cpu);
69 writel(reg, zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET); 107 zynq_slcr_write(reg, SLCR_A9_CPU_RST_CTRL_OFFSET);
70 reg &= ~(SLCR_A9_CPU_CLKSTOP << cpu); 108 reg &= ~(SLCR_A9_CPU_CLKSTOP << cpu);
71 writel(reg, zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET); 109 zynq_slcr_write(reg, SLCR_A9_CPU_RST_CTRL_OFFSET);
72} 110}
73 111
74/** 112/**
@@ -77,9 +115,11 @@ void zynq_slcr_cpu_start(int cpu)
77 */ 115 */
78void zynq_slcr_cpu_stop(int cpu) 116void zynq_slcr_cpu_stop(int cpu)
79{ 117{
80 u32 reg = readl(zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET); 118 u32 reg;
119
120 zynq_slcr_read(&reg, SLCR_A9_CPU_RST_CTRL_OFFSET);
81 reg |= (SLCR_A9_CPU_CLKSTOP | SLCR_A9_CPU_RST) << cpu; 121 reg |= (SLCR_A9_CPU_CLKSTOP | SLCR_A9_CPU_RST) << cpu;
82 writel(reg, zynq_slcr_base + SLCR_A9_CPU_RST_CTRL_OFFSET); 122 zynq_slcr_write(reg, SLCR_A9_CPU_RST_CTRL_OFFSET);
83} 123}
84 124
85/** 125/**