Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hmatrix.c
Go to the documentation of this file.
1 /*
2  * High-Speed Bus Matrix helper functions
3  *
4  * Copyright (C) 2008 Atmel Corporation
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #include <linux/clk.h>
11 #include <linux/io.h>
12 
13 #include <mach/chip.h>
14 #include <mach/hmatrix.h>
15 
16 static inline void __hmatrix_write_reg(unsigned long offset, u32 value)
17 {
18  __raw_writel(value, (void __iomem __force *)(HMATRIX_BASE + offset));
19 }
20 
21 static inline u32 __hmatrix_read_reg(unsigned long offset)
22 {
23  return __raw_readl((void __iomem __force *)(HMATRIX_BASE + offset));
24 }
25 
31 void hmatrix_write_reg(unsigned long offset, u32 value)
32 {
34  __hmatrix_write_reg(offset, value);
35  __hmatrix_read_reg(offset);
37 }
38 
45 u32 hmatrix_read_reg(unsigned long offset)
46 {
47  u32 value;
48 
50  value = __hmatrix_read_reg(offset);
52 
53  return value;
54 }
55 
61 void hmatrix_sfr_set_bits(unsigned int slave_id, u32 mask)
62 {
63  u32 value;
64 
66  value = __hmatrix_read_reg(HMATRIX_SFR(slave_id));
67  value |= mask;
68  __hmatrix_write_reg(HMATRIX_SFR(slave_id), value);
69  __hmatrix_read_reg(HMATRIX_SFR(slave_id));
71 }
72 
78 void hmatrix_sfr_clear_bits(unsigned int slave_id, u32 mask)
79 {
80  u32 value;
81 
83  value = __hmatrix_read_reg(HMATRIX_SFR(slave_id));
84  value &= ~mask;
85  __hmatrix_write_reg(HMATRIX_SFR(slave_id), value);
86  __hmatrix_read_reg(HMATRIX_SFR(slave_id));
88 }