blob: dd885eecf22a9e019cb0f48f7cd72113c6f63ee3 [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
Tony Lindgren4e653312011-11-10 22:45:17 +010020#include "common.h"
Benoît Cousson0be16212010-09-21 10:34:10 -060021#include <plat/cpu.h>
22#include <plat/prcm.h>
23
Kevin Hilman58aaa592011-03-28 10:52:04 -070024#include "vp.h"
Paul Walmsleyd198b512010-12-21 15:30:54 -070025#include "prm44xx.h"
Benoît Cousson0be16212010-09-21 10:34:10 -060026#include "prm-regbits-44xx.h"
Kevin Hilman4bb73ad2011-03-28 10:25:12 -070027#include "prcm44xx.h"
28#include "prminst44xx.h"
Benoît Cousson0be16212010-09-21 10:34:10 -060029
Paul Walmsley2ace8312010-12-21 21:05:14 -070030/* PRM low-level functions */
31
32/* Read a register in a CM/PRM instance in the PRM module */
33u32 omap4_prm_read_inst_reg(s16 inst, u16 reg)
34{
35 return __raw_readl(OMAP44XX_PRM_REGADDR(inst, reg));
36}
37
38/* Write into a register in a CM/PRM instance in the PRM module */
39void omap4_prm_write_inst_reg(u32 val, s16 inst, u16 reg)
40{
41 __raw_writel(val, OMAP44XX_PRM_REGADDR(inst, reg));
42}
43
44/* Read-modify-write a register in a PRM module. Caller must lock */
45u32 omap4_prm_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 reg)
46{
47 u32 v;
48
49 v = omap4_prm_read_inst_reg(inst, reg);
50 v &= ~mask;
51 v |= bits;
52 omap4_prm_write_inst_reg(v, inst, reg);
53
54 return v;
55}
Kevin Hilman58aaa592011-03-28 10:52:04 -070056
57/* PRM VP */
58
59/*
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
63 */
64struct omap4_vp {
65 u32 irqstatus_mpu;
66 u32 tranxdone_status;
67};
68
69static 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,
73 },
74 [OMAP4_VP_VDD_IVA_ID] = {
75 .irqstatus_mpu = OMAP4_PRM_IRQSTATUS_MPU_OFFSET,
76 .tranxdone_status = OMAP4430_VP_IVA_TRANXDONE_ST_MASK,
77 },
78 [OMAP4_VP_VDD_CORE_ID] = {
79 .irqstatus_mpu = OMAP4_PRM_IRQSTATUS_MPU_OFFSET,
80 .tranxdone_status = OMAP4430_VP_CORE_TRANXDONE_ST_MASK,
81 },
82};
83
84u32 omap4_prm_vp_check_txdone(u8 vp_id)
85{
86 struct omap4_vp *vp = &omap4_vp[vp_id];
87 u32 irqstatus;
88
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;
93}
94
95void omap4_prm_vp_clear_txdone(u8 vp_id)
96{
97 struct omap4_vp *vp = &omap4_vp[vp_id];
98
99 omap4_prminst_write_inst_reg(vp->tranxdone_status,
100 OMAP4430_PRM_PARTITION,
101 OMAP4430_PRM_OCP_SOCKET_INST,
102 vp->irqstatus_mpu);
103};
Kevin Hilman4bb73ad2011-03-28 10:25:12 -0700104
105u32 omap4_prm_vcvp_read(u8 offset)
106{
107 return omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION,
108 OMAP4430_PRM_DEVICE_INST, offset);
109}
110
111void omap4_prm_vcvp_write(u32 val, u8 offset)
112{
113 omap4_prminst_write_inst_reg(val, OMAP4430_PRM_PARTITION,
114 OMAP4430_PRM_DEVICE_INST, offset);
115}
116
117u32 omap4_prm_vcvp_rmw(u32 mask, u32 bits, u8 offset)
118{
119 return omap4_prminst_rmw_inst_reg_bits(mask, bits,
120 OMAP4430_PRM_PARTITION,
121 OMAP4430_PRM_DEVICE_INST,
122 offset);
123}