diff options
Diffstat (limited to 'firmware/target/arm/imx233/pwm-imx233.h')
-rw-r--r-- | firmware/target/arm/imx233/pwm-imx233.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/pwm-imx233.h b/firmware/target/arm/imx233/pwm-imx233.h new file mode 100644 index 0000000000..48c7811d47 --- /dev/null +++ b/firmware/target/arm/imx233/pwm-imx233.h | |||
@@ -0,0 +1,68 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef __PWM_IMX233_H__ | ||
22 | #define __PWM_IMX233_H__ | ||
23 | |||
24 | #include "system.h" | ||
25 | |||
26 | #define HW_PWM_BASE 0x80064000 | ||
27 | |||
28 | #define HW_PWM_CTRL (*(volatile uint32_t *)(HW_PWM_BASE + 0x0)) | ||
29 | #define HW_PWM_CTRL__PWMx_ENABLE(x) (1 << (x)) | ||
30 | |||
31 | #define HW_PWM_ACTIVEx(x) (*(volatile uint32_t *)(HW_PWM_BASE + 0x10 + (x) * 0x20)) | ||
32 | #define HW_PWM_ACTIVEx__ACTIVE_BP 0 | ||
33 | #define HW_PWM_ACTIVEx__ACTIVE_BM 0xffff | ||
34 | #define HW_PWM_ACTIVEx__INACTIVE_BP 16 | ||
35 | #define HW_PWM_ACTIVEx__INACTIVE_BM 0xffff0000 | ||
36 | |||
37 | #define HW_PWM_PERIODx(x) (*(volatile uint32_t *)(HW_PWM_BASE + 0x20 + (x) * 0x20)) | ||
38 | #define HW_PWM_PERIODx__PERIOD_BP 0 | ||
39 | #define HW_PWM_PERIODx__PERIOD_BM 0xffff | ||
40 | #define HW_PWM_PERIODx__ACTIVE_STATE_BP 16 | ||
41 | #define HW_PWM_PERIODx__ACTIVE_STATE_BM (0x3 << 16) | ||
42 | #define HW_PWM_PERIODx__INACTIVE_STATE_BP 18 | ||
43 | #define HW_PWM_PERIODx__INACTIVE_STATE_BM (0x3 << 18) | ||
44 | #define HW_PWM_PERIODx__CDIV_BP 20 | ||
45 | #define HW_PWM_PERIODx__CDIV_BM (0x7 << 20) | ||
46 | #define HW_PWM_PERIODx__CDIV__DIV_1 0 | ||
47 | #define HW_PWM_PERIODx__CDIV__DIV_2 1 | ||
48 | #define HW_PWM_PERIODx__CDIV__DIV_4 2 | ||
49 | #define HW_PWM_PERIODx__CDIV__DIV_8 3 | ||
50 | #define HW_PWM_PERIODx__CDIV__DIV_16 4 | ||
51 | #define HW_PWM_PERIODx__CDIV__DIV_64 5 | ||
52 | #define HW_PWM_PERIODx__CDIV__DIV_256 6 | ||
53 | #define HW_PWM_PERIODx__CDIV__DIV_1024 7 | ||
54 | |||
55 | #define HW_PWM_PERIODx__STATE__HI_Z 0 | ||
56 | #define HW_PWM_PERIODx__STATE__LOW 2 | ||
57 | #define HW_PWM_PERIODx__STATE__HIGH 3 | ||
58 | |||
59 | #define IMX233_PWM_PIN_BANK(channel) 1 | ||
60 | #define IMX233_PWM_PIN(channel) (26 + (channel)) | ||
61 | |||
62 | void imx233_pwm_init(void); | ||
63 | void imx233_pwm_setup_channel(int channel, int period, int cdiv, int active, | ||
64 | int active_state, int inactive, int inactive_state); | ||
65 | void imx233_pwm_enable_channel(int channel, bool enable); | ||
66 | bool imx233_pwm_is_channel_enable(int channel); | ||
67 | |||
68 | #endif /* __PWM_IMX233_H__ */ | ||