blob: faec860ebc0e9f97916479ca3c60fdb2ea40865f [file] [log] [blame]
Benoît Cousson0be16212010-09-21 10:34:10 -06001/*
2 * OMAP4 PRM module functions
3 *
Benoit Coussoneaac3292011-07-10 05:56:31 -06004 * Copyright (C) 2011 Texas Instruments, Inc.
Benoît Cousson0be16212010-09-21 10:34:10 -06005 * Copyright (C) 2010 Nokia Corporation
6 * Benoît Cousson
7 * Paul Walmsley
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/kernel.h>
15#include <linux/delay.h>
16#include <linux/errno.h>
17#include <linux/err.h>
Paul Walmsley2ace8312010-12-21 21:05:14 -070018#include <linux/io.h>
Benoît Cousson0be16212010-09-21 10:34:10 -060019
20#include <plat/common.h>
21#include <plat/cpu.h>
22#include <plat/prcm.h>
23
Paul Walmsleyd198b512010-12-21 15:30:54 -070024#include "prm44xx.h"
Benoît Cousson0be16212010-09-21 10:34:10 -060025#include "prm-regbits-44xx.h"
26
Paul Walmsley2ace8312010-12-21 21:05:14 -070027/* PRM low-level functions */
28
29/* Read a register in a CM/PRM instance in the PRM module */
30u32 omap4_prm_read_inst_reg(s16 inst, u16 reg)
31{
32 return __raw_readl(OMAP44XX_PRM_REGADDR(inst, reg));
33}
34
35/* Write into a register in a CM/PRM instance in the PRM module */
36void omap4_prm_write_inst_reg(u32 val, s16 inst, u16 reg)
37{
38 __raw_writel(val, OMAP44XX_PRM_REGADDR(inst, reg));
39}
40
41/* Read-modify-write a register in a PRM module. Caller must lock */
42u32 omap4_prm_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 reg)
43{
44 u32 v;
45
46 v = omap4_prm_read_inst_reg(inst, reg);
47 v &= ~mask;
48 v |= bits;
49 omap4_prm_write_inst_reg(v, inst, reg);
50
51 return v;
52}
53
54/* Read a PRM register, AND it, and shift the result down to bit 0 */
55/* XXX deprecated */
56u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask)
57{
58 u32 v;
59
60 v = __raw_readl(reg);
61 v &= mask;
62 v >>= __ffs(mask);
63
64 return v;
65}
66
67/* Read-modify-write a register in a PRM module. Caller must lock */
68/* XXX deprecated */
69u32 omap4_prm_rmw_reg_bits(u32 mask, u32 bits, void __iomem *reg)
70{
71 u32 v;
72
73 v = __raw_readl(reg);
74 v &= ~mask;
75 v |= bits;
76 __raw_writel(v, reg);
77
78 return v;
79}
80
81u32 omap4_prm_set_inst_reg_bits(u32 bits, s16 inst, s16 reg)
82{
83 return omap4_prm_rmw_inst_reg_bits(bits, bits, inst, reg);
84}
85
86u32 omap4_prm_clear_inst_reg_bits(u32 bits, s16 inst, s16 reg)
87{
88 return omap4_prm_rmw_inst_reg_bits(bits, 0x0, inst, reg);
89}
90
Paul Walmsleydac9a772010-12-21 21:05:14 -070091void omap4_prm_global_warm_sw_reset(void)
92{
93 u32 v;
94
95 v = omap4_prm_read_inst_reg(OMAP4430_PRM_DEVICE_INST,
96 OMAP4_RM_RSTCTRL);
97 v |= OMAP4430_RST_GLOBAL_WARM_SW_MASK;
98 omap4_prm_write_inst_reg(v, OMAP4430_PRM_DEVICE_INST,
99 OMAP4_RM_RSTCTRL);
100
101 /* OCP barrier */
102 v = omap4_prm_read_inst_reg(OMAP4430_PRM_DEVICE_INST,
103 OMAP4_RM_RSTCTRL);
104}