Lines Matching +full:4 +full:- +full:channel

1 // SPDX-License-Identifier: GPL-2.0-only
6 * samsung - Common hr-timer support (s3c and s5p)
41 #define TCFG1_SHIFT(x) ((x) * 4)
45 * Each channel occupies 4 bits in TCON register, but there is a gap of 4
46 * bits (one channel) after channel 0, so channels have different numbering
49 * In addition, the location of autoreload bit for channel 4 (TCON channel 5)
52 #define TCON_START(chan) (1 << (4 * (chan) + 0))
53 #define TCON_MANUALUPDATE(chan) (1 << (4 * (chan) + 1))
54 #define TCON_INVERT(chan) (1 << (4 * (chan) + 2))
55 #define _TCON_AUTORELOAD(chan) (1 << (4 * (chan) + 3))
56 #define _TCON_AUTORELOAD4(chan) (1 << (4 * (chan) + 2))
82 static void samsung_timer_set_prescale(unsigned int channel, u16 prescale) in samsung_timer_set_prescale() argument
88 if (channel >= 2) in samsung_timer_set_prescale()
95 reg |= (prescale - 1) << shift; in samsung_timer_set_prescale()
101 static void samsung_timer_set_divisor(unsigned int channel, u8 divisor) in samsung_timer_set_divisor() argument
103 u8 shift = TCFG1_SHIFT(channel); in samsung_timer_set_divisor()
108 bits = (fls(divisor) - 1) - pwm.variant.div_base; in samsung_timer_set_divisor()
120 static void samsung_time_stop(unsigned int channel) in samsung_time_stop() argument
125 if (channel > 0) in samsung_time_stop()
126 ++channel; in samsung_time_stop()
131 tcon &= ~TCON_START(channel); in samsung_time_stop()
137 static void samsung_time_setup(unsigned int channel, unsigned long tcnt) in samsung_time_setup() argument
141 unsigned int tcon_chan = channel; in samsung_time_setup()
153 writel_relaxed(tcnt, pwm.base + REG_TCNTB(channel)); in samsung_time_setup()
154 writel_relaxed(tcnt, pwm.base + REG_TCMPB(channel)); in samsung_time_setup()
160 static void samsung_time_start(unsigned int channel, bool periodic) in samsung_time_start() argument
165 if (channel > 0) in samsung_time_start()
166 ++channel; in samsung_time_start()
172 tcon &= ~TCON_MANUALUPDATE(channel); in samsung_time_start()
173 tcon |= TCON_START(channel); in samsung_time_start()
176 tcon |= TCON_AUTORELOAD(channel); in samsung_time_start()
178 tcon &= ~TCON_AUTORELOAD(channel); in samsung_time_start()
216 samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick - 1); in samsung_set_periodic()
254 evt->event_handler(evt); in samsung_clock_event_isr()
344 if (pwm.source_id == 4) in samsung_clocksource_init()
360 pwm.tcnt_max = (1UL << pwm.variant.bits) - 1; in samsung_timer_resources()
376 int channel; in _samsung_pwm_clocksource_init() local
378 mask = ~pwm.variant.output_mask & ((1 << SAMSUNG_PWM_NUM) - 1); in _samsung_pwm_clocksource_init()
379 channel = fls(mask) - 1; in _samsung_pwm_clocksource_init()
380 if (channel < 0) { in _samsung_pwm_clocksource_init()
381 pr_crit("failed to find PWM channel for clocksource\n"); in _samsung_pwm_clocksource_init()
382 return -EINVAL; in _samsung_pwm_clocksource_init()
384 pwm.source_id = channel; in _samsung_pwm_clocksource_init()
386 mask &= ~(1 << channel); in _samsung_pwm_clocksource_init()
387 channel = fls(mask) - 1; in _samsung_pwm_clocksource_init()
388 if (channel < 0) { in _samsung_pwm_clocksource_init()
389 pr_crit("failed to find PWM channel for clock event\n"); in _samsung_pwm_clocksource_init()
390 return -EINVAL; in _samsung_pwm_clocksource_init()
392 pwm.event_id = channel; in _samsung_pwm_clocksource_init()
427 of_property_for_each_u32(np, "samsung,pwm-outputs", prop, cur, val) { in samsung_pwm_alloc()
429 pr_warn("%s: invalid channel index in samsung,pwm-outputs property\n", __func__); in samsung_pwm_alloc()
438 return -ENXIO; in samsung_pwm_alloc()
454 .tclk_mask = (1 << 4),
461 TIMER_OF_DECLARE(s3c2410_pwm, "samsung,s3c2410-pwm", s3c2410_pwm_clocksource_init);
474 TIMER_OF_DECLARE(s3c6400_pwm, "samsung,s3c6400-pwm", s3c64xx_pwm_clocksource_init);
487 TIMER_OF_DECLARE(s5p6440_pwm, "samsung,s5p6440-pwm", s5p64x0_pwm_clocksource_init);
500 TIMER_OF_DECLARE(s5pc100_pwm, "samsung,s5pc100-pwm", s5p_pwm_clocksource_init);