Benoît Cousson | 0be1621 | 2010-09-21 10:34:10 -0600 | [diff] [blame] | 1 | /* |
| 2 | * OMAP4 PRM module functions |
| 3 | * |
Benoit Cousson | eaac329 | 2011-07-10 05:56:31 -0600 | [diff] [blame] | 4 | * Copyright (C) 2011 Texas Instruments, Inc. |
Benoît Cousson | 0be1621 | 2010-09-21 10:34:10 -0600 | [diff] [blame] | 5 | * 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 Walmsley | 2ace831 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 18 | #include <linux/io.h> |
Benoît Cousson | 0be1621 | 2010-09-21 10:34:10 -0600 | [diff] [blame] | 19 | |
Tony Lindgren | 4e65331 | 2011-11-10 22:45:17 +0100 | [diff] [blame] | 20 | #include "common.h" |
Benoît Cousson | 0be1621 | 2010-09-21 10:34:10 -0600 | [diff] [blame] | 21 | #include <plat/cpu.h> |
| 22 | #include <plat/prcm.h> |
| 23 | |
Kevin Hilman | 58aaa59 | 2011-03-28 10:52:04 -0700 | [diff] [blame] | 24 | #include "vp.h" |
Paul Walmsley | d198b51 | 2010-12-21 15:30:54 -0700 | [diff] [blame] | 25 | #include "prm44xx.h" |
Benoît Cousson | 0be1621 | 2010-09-21 10:34:10 -0600 | [diff] [blame] | 26 | #include "prm-regbits-44xx.h" |
Kevin Hilman | 4bb73ad | 2011-03-28 10:25:12 -0700 | [diff] [blame] | 27 | #include "prcm44xx.h" |
| 28 | #include "prminst44xx.h" |
Benoît Cousson | 0be1621 | 2010-09-21 10:34:10 -0600 | [diff] [blame] | 29 | |
Paul Walmsley | 2ace831 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 30 | /* PRM low-level functions */ |
| 31 | |
| 32 | /* Read a register in a CM/PRM instance in the PRM module */ |
| 33 | u32 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 */ |
| 39 | void 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 */ |
| 45 | u32 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 Hilman | 58aaa59 | 2011-03-28 10:52:04 -0700 | [diff] [blame] | 56 | |
| 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 | */ |
| 64 | struct omap4_vp { |
| 65 | u32 irqstatus_mpu; |
| 66 | u32 tranxdone_status; |
| 67 | }; |
| 68 | |
| 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, |
| 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 | |
| 84 | u32 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 | |
| 95 | void 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 Hilman | 4bb73ad | 2011-03-28 10:25:12 -0700 | [diff] [blame] | 104 | |
| 105 | u32 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 | |
| 111 | void 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 | |
| 117 | u32 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 | } |