Staging: brcm80211: remove unused ALIGN_ADDR() macro
[wandboard.git] / arch / avr32 / mach-at32ap / hmatrix.c
blob48f5ede77468293ebd9916e7b92825664293634e
1 /*
2 * High-Speed Bus Matrix helper functions
4 * Copyright (C) 2008 Atmel Corporation
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>
13 #include <mach/chip.h>
14 #include <mach/hmatrix.h>
16 static inline void __hmatrix_write_reg(unsigned long offset, u32 value)
18 __raw_writel(value, (void __iomem __force *)(HMATRIX_BASE + offset));
21 static inline u32 __hmatrix_read_reg(unsigned long offset)
23 return __raw_readl((void __iomem __force *)(HMATRIX_BASE + offset));
26 /**
27 * hmatrix_write_reg - write HMATRIX configuration register
28 * @offset: register offset
29 * @value: value to be written to the register at @offset
31 void hmatrix_write_reg(unsigned long offset, u32 value)
33 clk_enable(&at32_hmatrix_clk);
34 __hmatrix_write_reg(offset, value);
35 __hmatrix_read_reg(offset);
36 clk_disable(&at32_hmatrix_clk);
39 /**
40 * hmatrix_read_reg - read HMATRIX configuration register
41 * @offset: register offset
43 * Returns the value of the register at @offset.
45 u32 hmatrix_read_reg(unsigned long offset)
47 u32 value;
49 clk_enable(&at32_hmatrix_clk);
50 value = __hmatrix_read_reg(offset);
51 clk_disable(&at32_hmatrix_clk);
53 return value;
56 /**
57 * hmatrix_sfr_set_bits - set bits in a slave's Special Function Register
58 * @slave_id: operate on the SFR belonging to this slave
59 * @mask: mask of bits to be set in the SFR
61 void hmatrix_sfr_set_bits(unsigned int slave_id, u32 mask)
63 u32 value;
65 clk_enable(&at32_hmatrix_clk);
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));
70 clk_disable(&at32_hmatrix_clk);
73 /**
74 * hmatrix_sfr_set_bits - clear bits in a slave's Special Function Register
75 * @slave_id: operate on the SFR belonging to this slave
76 * @mask: mask of bits to be cleared in the SFR
78 void hmatrix_sfr_clear_bits(unsigned int slave_id, u32 mask)
80 u32 value;
82 clk_enable(&at32_hmatrix_clk);
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));
87 clk_disable(&at32_hmatrix_clk);