summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/timrot-imx233.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-05-02 21:37:38 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2016-05-28 17:18:32 +0200
commit643c0a1e0e80ee6010353201792ba6e2be7e1ced (patch)
tree0b039050be720483935978575f77351db143463f /firmware/target/arm/imx233/timrot-imx233.h
parent423c64770c04a62e34775c37a7e09a60f6ccbc4c (diff)
downloadrockbox-643c0a1e0e80ee6010353201792ba6e2be7e1ced.tar.gz
rockbox-643c0a1e0e80ee6010353201792ba6e2be7e1ced.tar.bz2
rockbox-643c0a1e0e80ee6010353201792ba6e2be7e1ced.zip
imx233: simplify timrot API
The old timrot setup API was very low-level and unfriendly. The new one makes in easier to select the frequency source. Use to simplify timer and kernel timer code. Change-Id: Iffcdf11c00e925be9ec8d9a4efc74b197b6bd2aa
Diffstat (limited to 'firmware/target/arm/imx233/timrot-imx233.h')
-rw-r--r--firmware/target/arm/imx233/timrot-imx233.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/timrot-imx233.h b/firmware/target/arm/imx233/timrot-imx233.h
index 778cd1add9..0add64e9ce 100644
--- a/firmware/target/arm/imx233/timrot-imx233.h
+++ b/firmware/target/arm/imx233/timrot-imx233.h
@@ -25,6 +25,7 @@
#include "cpu.h"
#include "icoll-imx233.h"
+/* WARNING timrot code assumes APBX is running at 24MHz */
/* list of timers */
enum
{
@@ -33,6 +34,20 @@ enum
TIMER_WATCHDOG, /* for watchdog */
};
+/* timer sources */
+enum imx233_timrot_src_t
+{
+ TIMER_SRC_24MHZ,
+ TIMER_SRC_12MHZ,
+ TIMER_SRC_6MHZ,
+ TIMER_SRC_3MHZ,
+ TIMER_SRC_32KHZ,
+ TIMER_SRC_8KHZ,
+ TIMER_SRC_4KHZ,
+ TIMER_SRC_1KHZ,
+ TIMER_SRC_STOP
+};
+
struct imx233_timrot_info_t
{
unsigned fixed_count, run_count;
@@ -45,10 +60,21 @@ struct imx233_timrot_info_t
typedef void (*imx233_timer_fn_t)(void);
+/* maximum count for non-periodic timers, add one for periodic timers */
+#define IMX233_TIMROT_MAX_COUNT 0xffff
+
void imx233_timrot_init(void);
+/* low-level function all-in-one function */
void imx233_timrot_setup(unsigned timer_nr, bool reload, unsigned count,
unsigned src, unsigned prescale, bool polarity, imx233_timer_fn_t fn);
+/* change interrupt priority */
void imx233_timrot_set_priority(unsigned timer_nr, unsigned prio);
+/* simple setup function */
+void imx233_timrot_setup_simple(unsigned timer_nr, bool periodic, unsigned count,
+ enum imx233_timrot_src_t src, imx233_timer_fn_t fn);
+/* get timer count */
+unsigned imx233_timrot_get_count(unsigned timer_nr);
+/* update timer running count */
struct imx233_timrot_info_t imx233_timrot_get_info(unsigned timer_nr);
#endif /* TIMROT_IMX233_H */