[ARM] S3C64XX: Update TCFG for new timer divider settings.
[linux-2.6/openmoko-kernel.git] / arch / arm / plat-s3c24xx / include / mach / pwm-clock.h
bloba087de21bc205ef4511a8e9af6c2dcc2614ef9f7
1 /* linux/arch/arm/plat-s3c24xx/include/mach/pwm-clock.h
3 * Copyright 2008 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 * http://armlinux.simtec.co.uk/
7 * S3C24xx - pwm clock and timer support
8 */
10 /**
11 * pwm_cfg_src_is_tclk() - return whether the given mux config is a tclk
12 * @cfg: The timer TCFG1 register bits shifted down to 0.
14 * Return true if the given configuration from TCFG1 is a TCLK instead
15 * any of the TDIV clocks.
17 static inline int pwm_cfg_src_is_tclk(unsigned long tcfg)
19 return tcfg == S3C2410_TCFG1_MUX_TCLK;
22 /**
23 * tcfg_to_divisor() - convert tcfg1 setting to a divisor
24 * @tcfg1: The tcfg1 setting, shifted down.
26 * Get the divisor value for the given tcfg1 setting. We assume the
27 * caller has already checked to see if this is not a TCLK source.
29 static inline unsigned long tcfg_to_divisor(unsigned long tcfg1)
31 return 1 << (1 + tcfg1);
34 /**
35 * pwm_tdiv_has_div1() - does the tdiv setting have a /1
37 * Return true if we have a /1 in the tdiv setting.
39 static inline unsigned int pwm_tdiv_has_div1(void)
41 return 0;
44 /**
45 * pwm_tdiv_div_bits() - calculate TCFG1 divisor value.
46 * @div: The divisor to calculate the bit information for.
48 * Turn a divisor into the necessary bit field for TCFG1.
50 static inline unsigned long pwm_tdiv_div_bits(unsigned int div)
52 return ilog2(div) - 1;
55 #define S3C_TCFG1_MUX_TCLK S3C2410_TCFG1_MUX_TCLK