Magnus Damm | 79714ac | 2009-07-03 10:08:05 +0000 | [diff] [blame] | 1 | #ifndef __ASM_SH_HWBLK_H |
| 2 | #define __ASM_SH_HWBLK_H |
| 3 | |
| 4 | #include <asm/clock.h> |
| 5 | #include <asm/io.h> |
| 6 | |
Magnus Damm | 0f8ee18 | 2009-07-17 14:24:55 +0000 | [diff] [blame] | 7 | #define HWBLK_CNT_USAGE 0 |
Magnus Damm | 6a93dde | 2009-08-14 10:48:16 +0000 | [diff] [blame] | 8 | #define HWBLK_CNT_IDLE 1 |
| 9 | #define HWBLK_CNT_DEVICES 2 |
| 10 | #define HWBLK_CNT_NR 3 |
Magnus Damm | 0f8ee18 | 2009-07-17 14:24:55 +0000 | [diff] [blame] | 11 | |
Magnus Damm | 79714ac | 2009-07-03 10:08:05 +0000 | [diff] [blame] | 12 | #define HWBLK_AREA_FLAG_PARENT (1 << 0) /* valid parent */ |
| 13 | |
| 14 | #define HWBLK_AREA(_flags, _parent) \ |
| 15 | { \ |
| 16 | .flags = _flags, \ |
| 17 | .parent = _parent, \ |
| 18 | } |
| 19 | |
| 20 | struct hwblk_area { |
Magnus Damm | 0f8ee18 | 2009-07-17 14:24:55 +0000 | [diff] [blame] | 21 | int cnt[HWBLK_CNT_NR]; |
Magnus Damm | 79714ac | 2009-07-03 10:08:05 +0000 | [diff] [blame] | 22 | unsigned char parent; |
| 23 | unsigned char flags; |
| 24 | }; |
| 25 | |
| 26 | #define HWBLK(_mstp, _bit, _area) \ |
| 27 | { \ |
| 28 | .mstp = (void __iomem *)_mstp, \ |
| 29 | .bit = _bit, \ |
| 30 | .area = _area, \ |
| 31 | } |
| 32 | |
| 33 | struct hwblk { |
| 34 | void __iomem *mstp; |
| 35 | unsigned char bit; |
| 36 | unsigned char area; |
Magnus Damm | 0f8ee18 | 2009-07-17 14:24:55 +0000 | [diff] [blame] | 37 | int cnt[HWBLK_CNT_NR]; |
Magnus Damm | 79714ac | 2009-07-03 10:08:05 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | struct hwblk_info { |
| 41 | struct hwblk_area *areas; |
| 42 | int nr_areas; |
| 43 | struct hwblk *hwblks; |
| 44 | int nr_hwblks; |
| 45 | }; |
| 46 | |
Guennadi Liakhovetski | 6a06d5b | 2011-11-17 14:55:52 +0100 | [diff] [blame^] | 47 | #if !defined(CONFIG_CPU_SUBTYPE_SH7724) && !defined(CONFIG_CPU_SUBTYPE_SH7722) |
Magnus Damm | 79714ac | 2009-07-03 10:08:05 +0000 | [diff] [blame] | 48 | /* Should be defined by processor-specific code */ |
| 49 | int arch_hwblk_init(void); |
| 50 | int arch_hwblk_sleep_mode(void); |
| 51 | |
| 52 | int hwblk_register(struct hwblk_info *info); |
| 53 | int hwblk_init(void); |
| 54 | |
Magnus Damm | 0f8ee18 | 2009-07-17 14:24:55 +0000 | [diff] [blame] | 55 | void hwblk_enable(struct hwblk_info *info, int hwblk); |
| 56 | void hwblk_disable(struct hwblk_info *info, int hwblk); |
| 57 | |
| 58 | void hwblk_cnt_inc(struct hwblk_info *info, int hwblk, int cnt); |
| 59 | void hwblk_cnt_dec(struct hwblk_info *info, int hwblk, int cnt); |
| 60 | |
Magnus Damm | 79714ac | 2009-07-03 10:08:05 +0000 | [diff] [blame] | 61 | /* allow clocks to enable and disable hardware blocks */ |
Magnus Damm | 08134c3 | 2010-05-10 14:01:44 +0000 | [diff] [blame] | 62 | #define SH_HWBLK_CLK(_hwblk, _parent, _flags) \ |
| 63 | [_hwblk] = { \ |
| 64 | .parent = _parent, \ |
| 65 | .arch_flags = _hwblk, \ |
| 66 | .flags = _flags, \ |
Magnus Damm | 79714ac | 2009-07-03 10:08:05 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | int sh_hwblk_clk_register(struct clk *clks, int nr); |
Guennadi Liakhovetski | 8cc88a5 | 2011-11-17 14:55:47 +0100 | [diff] [blame] | 70 | #else |
| 71 | #define hwblk_init() 0 |
| 72 | #endif |
Magnus Damm | 79714ac | 2009-07-03 10:08:05 +0000 | [diff] [blame] | 73 | #endif /* __ASM_SH_HWBLK_H */ |