blob: a303242972786b227e46dd181d2e74467cac6674 [file] [log] [blame]
Paul Walmsley2ace8312010-12-21 21:05:14 -07001/*
2 * OMAP4 PRM instance functions
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/errno.h>
15#include <linux/err.h>
16#include <linux/io.h>
17
18#include <plat/common.h>
19
20#include "prm44xx.h"
21#include "prminst44xx.h"
22#include "prm-regbits-44xx.h"
23#include "prcm44xx.h"
24#include "prcm_mpu44xx.h"
25
26static u32 _prm_bases[OMAP4_MAX_PRCM_PARTITIONS] = {
27 [OMAP4430_INVALID_PRCM_PARTITION] = 0,
28 [OMAP4430_PRM_PARTITION] = OMAP4430_PRM_BASE,
29 [OMAP4430_CM1_PARTITION] = 0,
30 [OMAP4430_CM2_PARTITION] = 0,
31 [OMAP4430_SCRM_PARTITION] = 0,
32 [OMAP4430_PRCM_MPU_PARTITION] = OMAP4430_PRCM_MPU_BASE,
33};
34
35/* Read a register in a PRM instance */
36u32 omap4_prminst_read_inst_reg(u8 part, s16 inst, u16 idx)
37{
38 BUG_ON(part >= OMAP4_MAX_PRCM_PARTITIONS ||
39 part == OMAP4430_INVALID_PRCM_PARTITION ||
40 !_prm_bases[part]);
41 return __raw_readl(OMAP2_L4_IO_ADDRESS(_prm_bases[part] + inst +
42 idx));
43}
44
45/* Write into a register in a PRM instance */
46void omap4_prminst_write_inst_reg(u32 val, u8 part, s16 inst, u16 idx)
47{
48 BUG_ON(part >= OMAP4_MAX_PRCM_PARTITIONS ||
49 part == OMAP4430_INVALID_PRCM_PARTITION ||
50 !_prm_bases[part]);
51 __raw_writel(val, OMAP2_L4_IO_ADDRESS(_prm_bases[part] + inst + idx));
52}
53
54/* Read-modify-write a register in PRM. Caller must lock */
55u32 omap4_prminst_rmw_inst_reg_bits(u32 mask, u32 bits, u8 part, s16 inst,
56 s16 idx)
57{
58 u32 v;
59
60 v = omap4_prminst_read_inst_reg(part, inst, idx);
61 v &= ~mask;
62 v |= bits;
63 omap4_prminst_write_inst_reg(v, part, inst, idx);
64
65 return v;
66}