Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

counter: microchip-tcb-capture: Add capture extensions for registers RA/RB

TCB hardware is capable of capturing the timer value to registers RA and
RB. Add these registers as capture extensions.

Signed-off-by: Bence Csókás <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20250306134441.582819-3-csokas.bence@prolan.hu
Signed-off-by: William Breathitt Gray <wbg@kernel.org>

authored by

Bence Csókás and committed by
William Breathitt Gray
1adc6240 e5d58139

+64
+58
drivers/counter/microchip-tcb-capture.c
··· 253 253 return 0; 254 254 } 255 255 256 + static int mchp_tc_count_cap_read(struct counter_device *counter, 257 + struct counter_count *count, size_t idx, u64 *val) 258 + { 259 + struct mchp_tc_data *const priv = counter_priv(counter); 260 + u32 cnt; 261 + int ret; 262 + 263 + switch (idx) { 264 + case COUNTER_MCHP_EXCAP_RA: 265 + ret = regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], RA), &cnt); 266 + break; 267 + case COUNTER_MCHP_EXCAP_RB: 268 + ret = regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], RB), &cnt); 269 + break; 270 + default: 271 + return -EINVAL; 272 + } 273 + 274 + if (ret < 0) 275 + return ret; 276 + 277 + *val = cnt; 278 + 279 + return 0; 280 + } 281 + 282 + static int mchp_tc_count_cap_write(struct counter_device *counter, 283 + struct counter_count *count, size_t idx, u64 val) 284 + { 285 + struct mchp_tc_data *const priv = counter_priv(counter); 286 + int ret; 287 + 288 + if (val > U32_MAX) 289 + return -ERANGE; 290 + 291 + switch (idx) { 292 + case COUNTER_MCHP_EXCAP_RA: 293 + ret = regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], RA), val); 294 + break; 295 + case COUNTER_MCHP_EXCAP_RB: 296 + ret = regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], RB), val); 297 + break; 298 + default: 299 + return -EINVAL; 300 + } 301 + 302 + return ret; 303 + } 304 + 305 + static DEFINE_COUNTER_ARRAY_CAPTURE(mchp_tc_cnt_cap_array, 2); 306 + 307 + static struct counter_comp mchp_tc_count_ext[] = { 308 + COUNTER_COMP_ARRAY_CAPTURE(mchp_tc_count_cap_read, mchp_tc_count_cap_write, 309 + mchp_tc_cnt_cap_array), 310 + }; 311 + 256 312 static struct counter_count mchp_tc_counts[] = { 257 313 { 258 314 .id = 0, ··· 317 261 .num_functions = ARRAY_SIZE(mchp_tc_count_functions), 318 262 .synapses = mchp_tc_count_synapses, 319 263 .num_synapses = ARRAY_SIZE(mchp_tc_count_synapses), 264 + .ext = mchp_tc_count_ext, 265 + .num_ext = ARRAY_SIZE(mchp_tc_count_ext), 320 266 }, 321 267 }; 322 268
+6
include/uapi/linux/counter/microchip-tcb-capture.h
··· 12 12 * Count 0 13 13 * \__ Synapse 0 -- Signal 0 (Channel A, i.e. TIOA) 14 14 * \__ Synapse 1 -- Signal 1 (Channel B, i.e. TIOB) 15 + * \__ Extension capture0 (RA register) 16 + * \__ Extension capture1 (RB register) 15 17 * 16 18 * It also supports the following events: 17 19 * ··· 26 24 * Channel 2: 27 25 * - RC compare triggered 28 26 */ 27 + 28 + /* Capture extensions */ 29 + #define COUNTER_MCHP_EXCAP_RA 0 30 + #define COUNTER_MCHP_EXCAP_RB 1 29 31 30 32 /* Event channels */ 31 33 #define COUNTER_MCHP_EVCHN_CV 0