Paul Walmsley | 2ace831 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * OMAP4 PRCM_MPU module 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 | |
Tony Lindgren | ee0839c | 2012-02-24 10:34:35 -0800 | [diff] [blame] | 18 | #include "iomap.h" |
Tony Lindgren | 4e65331 | 2011-11-10 22:45:17 +0100 | [diff] [blame] | 19 | #include "common.h" |
Paul Walmsley | 2ace831 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 20 | #include "prcm_mpu44xx.h" |
| 21 | #include "cm-regbits-44xx.h" |
| 22 | |
Paul Walmsley | d9a16f9 | 2012-10-29 20:57:39 -0600 | [diff] [blame] | 23 | /* |
| 24 | * prcm_mpu_base: the virtual address of the start of the PRCM_MPU IP |
| 25 | * block registers |
| 26 | */ |
| 27 | void __iomem *prcm_mpu_base; |
| 28 | |
Paul Walmsley | 2ace831 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 29 | /* PRCM_MPU low-level functions */ |
| 30 | |
| 31 | u32 omap4_prcm_mpu_read_inst_reg(s16 inst, u16 reg) |
| 32 | { |
Victor Kamensky | edfaf05 | 2014-04-15 20:37:46 +0300 | [diff] [blame] | 33 | return readl_relaxed(OMAP44XX_PRCM_MPU_REGADDR(inst, reg)); |
Paul Walmsley | 2ace831 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void omap4_prcm_mpu_write_inst_reg(u32 val, s16 inst, u16 reg) |
| 37 | { |
Victor Kamensky | edfaf05 | 2014-04-15 20:37:46 +0300 | [diff] [blame] | 38 | writel_relaxed(val, OMAP44XX_PRCM_MPU_REGADDR(inst, reg)); |
Paul Walmsley | 2ace831 | 2010-12-21 21:05:14 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | u32 omap4_prcm_mpu_rmw_inst_reg_bits(u32 mask, u32 bits, s16 inst, s16 reg) |
| 42 | { |
| 43 | u32 v; |
| 44 | |
| 45 | v = omap4_prcm_mpu_read_inst_reg(inst, reg); |
| 46 | v &= ~mask; |
| 47 | v |= bits; |
| 48 | omap4_prcm_mpu_write_inst_reg(v, inst, reg); |
| 49 | |
| 50 | return v; |
| 51 | } |
Paul Walmsley | d9a16f9 | 2012-10-29 20:57:39 -0600 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * omap2_set_globals_prcm_mpu - set the MPU PRCM base address (for early use) |
| 55 | * @prcm_mpu: PRCM_MPU base virtual address |
| 56 | * |
| 57 | * XXX Will be replaced when the PRM/CM drivers are completed. |
| 58 | */ |
| 59 | void __init omap2_set_globals_prcm_mpu(void __iomem *prcm_mpu) |
| 60 | { |
| 61 | prcm_mpu_base = prcm_mpu; |
| 62 | } |