RS485: fix inconsistencies in the meaning of some variables
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap2 / prm44xx.c
blob495a31a7e8a7534cd3fdfca70b6a4e99686e4f6b
1 /*
2 * OMAP4 PRM module functions
4 * Copyright (C) 2011 Texas Instruments, Inc.
5 * Copyright (C) 2010 Nokia Corporation
6 * BenoƮt Cousson
7 * Paul Walmsley
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.
14 #include <linux/kernel.h>
15 #include <linux/delay.h>
16 #include <linux/errno.h>
17 #include <linux/err.h>
18 #include <linux/io.h>
20 #include <plat/common.h>
21 #include <plat/cpu.h>
22 #include <plat/prcm.h>
24 #include "vp.h"
25 #include "prm44xx.h"
26 #include "prm-regbits-44xx.h"
27 #include "prcm44xx.h"
28 #include "prminst44xx.h"
30 /* PRM low-level functions */
32 /* Read a register in a CM/PRM instance in the PRM module */
33 u32 omap4_prm_read_inst_reg(s16 inst, u16 reg)
35 return __raw_readl(OMAP44XX_PRM_REGADDR(inst, reg));
38 /* Write into a register in a CM/PRM instance in the PRM module */
39 void omap4_prm_write_inst_reg(u32 val, s16 inst, u16 reg)
41 __raw_writel(val, OMAP44XX_PRM_REGADDR(inst, reg));
44 /* Read-modify-write a register in a PRM module. Caller must lock */
45 u32 omap4_prm_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 reg)
47 u32 v;
49 v = omap4_prm_read_inst_reg(inst, reg);
50 v &= ~mask;
51 v |= bits;
52 omap4_prm_write_inst_reg(v, inst, reg);
54 return v;
57 /* PRM VP */
60 * struct omap4_vp - OMAP4 VP register access description.
61 * @irqstatus_mpu: offset to IRQSTATUS_MPU register for VP
62 * @tranxdone_status: VP_TRANXDONE_ST bitmask in PRM_IRQSTATUS_MPU reg
64 struct omap4_vp {
65 u32 irqstatus_mpu;
66 u32 tranxdone_status;
69 static struct omap4_vp omap4_vp[] = {
70 [OMAP4_VP_VDD_MPU_ID] = {
71 .irqstatus_mpu = OMAP4_PRM_IRQSTATUS_MPU_2_OFFSET,
72 .tranxdone_status = OMAP4430_VP_MPU_TRANXDONE_ST_MASK,
74 [OMAP4_VP_VDD_IVA_ID] = {
75 .irqstatus_mpu = OMAP4_PRM_IRQSTATUS_MPU_OFFSET,
76 .tranxdone_status = OMAP4430_VP_IVA_TRANXDONE_ST_MASK,
78 [OMAP4_VP_VDD_CORE_ID] = {
79 .irqstatus_mpu = OMAP4_PRM_IRQSTATUS_MPU_OFFSET,
80 .tranxdone_status = OMAP4430_VP_CORE_TRANXDONE_ST_MASK,
84 u32 omap4_prm_vp_check_txdone(u8 vp_id)
86 struct omap4_vp *vp = &omap4_vp[vp_id];
87 u32 irqstatus;
89 irqstatus = omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION,
90 OMAP4430_PRM_OCP_SOCKET_INST,
91 vp->irqstatus_mpu);
92 return irqstatus & vp->tranxdone_status;
95 void omap4_prm_vp_clear_txdone(u8 vp_id)
97 struct omap4_vp *vp = &omap4_vp[vp_id];
99 omap4_prminst_write_inst_reg(vp->tranxdone_status,
100 OMAP4430_PRM_PARTITION,
101 OMAP4430_PRM_OCP_SOCKET_INST,
102 vp->irqstatus_mpu);
105 u32 omap4_prm_vcvp_read(u8 offset)
107 return omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION,
108 OMAP4430_PRM_DEVICE_INST, offset);
111 void omap4_prm_vcvp_write(u32 val, u8 offset)
113 omap4_prminst_write_inst_reg(val, OMAP4430_PRM_PARTITION,
114 OMAP4430_PRM_DEVICE_INST, offset);
117 u32 omap4_prm_vcvp_rmw(u32 mask, u32 bits, u8 offset)
119 return omap4_prminst_rmw_inst_reg_bits(mask, bits,
120 OMAP4430_PRM_PARTITION,
121 OMAP4430_PRM_DEVICE_INST,
122 offset);