Lines Matching +full:tcon +full:- +full:channel
1 // SPDX-License-Identifier: GPL-2.0-only
6 * samsung - Common hr-timer support (s3c and s5p)
44 * Each channel occupies 4 bits in TCON register, but there is a gap of 4
45 * bits (one channel) after channel 0, so channels have different numbering
46 * when accessing TCON register.
48 * In addition, the location of autoreload bit for channel 4 (TCON channel 5)
81 static void samsung_timer_set_prescale(unsigned int channel, u16 prescale) in samsung_timer_set_prescale() argument
87 if (channel >= 2) in samsung_timer_set_prescale()
94 reg |= (prescale - 1) << shift; in samsung_timer_set_prescale()
100 static void samsung_timer_set_divisor(unsigned int channel, u8 divisor) in samsung_timer_set_divisor() argument
102 u8 shift = TCFG1_SHIFT(channel); in samsung_timer_set_divisor()
107 bits = (fls(divisor) - 1) - pwm.variant.div_base; in samsung_timer_set_divisor()
119 static void samsung_time_stop(unsigned int channel) in samsung_time_stop() argument
121 unsigned long tcon; in samsung_time_stop() local
124 if (channel > 0) in samsung_time_stop()
125 ++channel; in samsung_time_stop()
129 tcon = readl_relaxed(pwm.base + REG_TCON); in samsung_time_stop()
130 tcon &= ~TCON_START(channel); in samsung_time_stop()
131 writel_relaxed(tcon, pwm.base + REG_TCON); in samsung_time_stop()
136 static void samsung_time_setup(unsigned int channel, unsigned long tcnt) in samsung_time_setup() argument
138 unsigned long tcon; in samsung_time_setup() local
140 unsigned int tcon_chan = channel; in samsung_time_setup()
147 tcon = readl_relaxed(pwm.base + REG_TCON); in samsung_time_setup()
149 tcon &= ~(TCON_START(tcon_chan) | TCON_AUTORELOAD(tcon_chan)); in samsung_time_setup()
150 tcon |= TCON_MANUALUPDATE(tcon_chan); in samsung_time_setup()
152 writel_relaxed(tcnt, pwm.base + REG_TCNTB(channel)); in samsung_time_setup()
153 writel_relaxed(tcnt, pwm.base + REG_TCMPB(channel)); in samsung_time_setup()
154 writel_relaxed(tcon, pwm.base + REG_TCON); in samsung_time_setup()
159 static void samsung_time_start(unsigned int channel, bool periodic) in samsung_time_start() argument
161 unsigned long tcon; in samsung_time_start() local
164 if (channel > 0) in samsung_time_start()
165 ++channel; in samsung_time_start()
169 tcon = readl_relaxed(pwm.base + REG_TCON); in samsung_time_start()
171 tcon &= ~TCON_MANUALUPDATE(channel); in samsung_time_start()
172 tcon |= TCON_START(channel); in samsung_time_start()
175 tcon |= TCON_AUTORELOAD(channel); in samsung_time_start()
177 tcon &= ~TCON_AUTORELOAD(channel); in samsung_time_start()
179 writel_relaxed(tcon, pwm.base + REG_TCON); in samsung_time_start()
215 samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick - 1); in samsung_set_periodic()
255 evt->event_handler(evt); in samsung_clock_event_isr()
362 pwm.tcnt_max = (1UL << pwm.variant.bits) - 1; in samsung_timer_resources()
378 int channel; in _samsung_pwm_clocksource_init() local
380 mask = ~pwm.variant.output_mask & ((1 << SAMSUNG_PWM_NUM) - 1); in _samsung_pwm_clocksource_init()
381 channel = fls(mask) - 1; in _samsung_pwm_clocksource_init()
382 if (channel < 0) { in _samsung_pwm_clocksource_init()
383 pr_crit("failed to find PWM channel for clocksource\n"); in _samsung_pwm_clocksource_init()
384 return -EINVAL; in _samsung_pwm_clocksource_init()
386 pwm.source_id = channel; in _samsung_pwm_clocksource_init()
388 mask &= ~(1 << channel); in _samsung_pwm_clocksource_init()
389 channel = fls(mask) - 1; in _samsung_pwm_clocksource_init()
390 if (channel < 0) { in _samsung_pwm_clocksource_init()
391 pr_crit("failed to find PWM channel for clock event\n"); in _samsung_pwm_clocksource_init()
392 return -EINVAL; in _samsung_pwm_clocksource_init()
394 pwm.event_id = channel; in _samsung_pwm_clocksource_init()
428 of_property_for_each_u32(np, "samsung,pwm-outputs", val) { in samsung_pwm_alloc()
430 pr_warn("%s: invalid channel index in samsung,pwm-outputs property\n", __func__); in samsung_pwm_alloc()
439 return -ENXIO; in samsung_pwm_alloc()
476 TIMER_OF_DECLARE(s3c2410_pwm, "samsung,s3c2410-pwm", s3c2410_pwm_clocksource_init);
489 TIMER_OF_DECLARE(s3c6400_pwm, "samsung,s3c6400-pwm", s3c64xx_pwm_clocksource_init);
502 TIMER_OF_DECLARE(s5p6440_pwm, "samsung,s5p6440-pwm", s5p64x0_pwm_clocksource_init);
515 TIMER_OF_DECLARE(s5pc100_pwm, "samsung,s5pc100-pwm", s5p_pwm_clocksource_init);