Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 1 | /* |
| 2 | * OMAP2/3 System Control Module register access |
| 3 | * |
| 4 | * Copyright (C) 2007 Texas Instruments, Inc. |
| 5 | * Copyright (C) 2007 Nokia Corporation |
| 6 | * |
| 7 | * Written by 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 | #undef DEBUG |
| 14 | |
| 15 | #include <linux/kernel.h> |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 16 | #include <linux/io.h> |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 17 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 18 | #include <mach/common.h> |
| 19 | #include <mach/control.h> |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 20 | |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 21 | static void __iomem *omap2_ctrl_base; |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 22 | |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 23 | #define OMAP_CTRL_REGADDR(reg) (omap2_ctrl_base + (reg)) |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 24 | |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 25 | void __init omap2_set_globals_control(struct omap_globals *omap2_globals) |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 26 | { |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 27 | omap2_ctrl_base = omap2_globals->ctrl; |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 28 | } |
| 29 | |
Tony Lindgren | a58caad | 2008-07-03 12:24:44 +0300 | [diff] [blame] | 30 | void __iomem *omap_ctrl_base_get(void) |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 31 | { |
| 32 | return omap2_ctrl_base; |
| 33 | } |
| 34 | |
| 35 | u8 omap_ctrl_readb(u16 offset) |
| 36 | { |
| 37 | return __raw_readb(OMAP_CTRL_REGADDR(offset)); |
| 38 | } |
| 39 | |
| 40 | u16 omap_ctrl_readw(u16 offset) |
| 41 | { |
| 42 | return __raw_readw(OMAP_CTRL_REGADDR(offset)); |
| 43 | } |
| 44 | |
| 45 | u32 omap_ctrl_readl(u16 offset) |
| 46 | { |
| 47 | return __raw_readl(OMAP_CTRL_REGADDR(offset)); |
| 48 | } |
| 49 | |
| 50 | void omap_ctrl_writeb(u8 val, u16 offset) |
| 51 | { |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 52 | __raw_writeb(val, OMAP_CTRL_REGADDR(offset)); |
| 53 | } |
| 54 | |
| 55 | void omap_ctrl_writew(u16 val, u16 offset) |
| 56 | { |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 57 | __raw_writew(val, OMAP_CTRL_REGADDR(offset)); |
| 58 | } |
| 59 | |
| 60 | void omap_ctrl_writel(u32 val, u16 offset) |
| 61 | { |
Paul Walmsley | 69d88a0 | 2008-03-18 10:02:50 +0200 | [diff] [blame] | 62 | __raw_writel(val, OMAP_CTRL_REGADDR(offset)); |
| 63 | } |
| 64 | |