Lines Matching refs:counter
9 #include <linux/counter.h>
66 * struct rz_mtu3_cnt - MTU3 counter private data
97 static inline struct rz_mtu3_channel *rz_mtu3_get_ch(struct counter_device *counter, int id)
99 struct rz_mtu3_cnt *const priv = counter_priv(counter);
105 static bool rz_mtu3_is_counter_invalid(struct counter_device *counter, int id)
107 struct rz_mtu3_cnt *const priv = counter_priv(counter);
123 static int rz_mtu3_lock_if_counter_is_valid(struct counter_device *counter,
135 if (rz_mtu3_is_counter_invalid(counter, id)) {
157 static int rz_mtu3_count_read(struct counter_device *counter,
160 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
161 struct rz_mtu3_cnt *const priv = counter_priv(counter);
164 ret = rz_mtu3_lock_if_counter_is_valid(counter, ch, priv, count->id);
179 static int rz_mtu3_count_write(struct counter_device *counter,
182 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
183 struct rz_mtu3_cnt *const priv = counter_priv(counter);
186 ret = rz_mtu3_lock_if_counter_is_valid(counter, ch, priv, count->id);
231 static int rz_mtu3_count_function_read(struct counter_device *counter,
235 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
236 struct rz_mtu3_cnt *const priv = counter_priv(counter);
249 static int rz_mtu3_count_function_write(struct counter_device *counter,
253 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
254 struct rz_mtu3_cnt *const priv = counter_priv(counter);
290 static int rz_mtu3_count_direction_read(struct counter_device *counter,
294 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
295 struct rz_mtu3_cnt *const priv = counter_priv(counter);
314 static int rz_mtu3_count_ceiling_read(struct counter_device *counter,
318 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
319 struct rz_mtu3_cnt *const priv = counter_priv(counter);
323 ret = rz_mtu3_lock_if_counter_is_valid(counter, ch, priv, count->id);
345 static int rz_mtu3_count_ceiling_write(struct counter_device *counter,
349 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
350 struct rz_mtu3_cnt *const priv = counter_priv(counter);
354 ret = rz_mtu3_lock_if_counter_is_valid(counter, ch, priv, count->id);
393 static void rz_mtu3_32bit_cnt_setting(struct counter_device *counter)
395 struct rz_mtu3_channel *const ch1 = rz_mtu3_get_ch(counter, 0);
396 struct rz_mtu3_channel *const ch2 = rz_mtu3_get_ch(counter, 1);
408 static void rz_mtu3_16bit_cnt_setting(struct counter_device *counter, int id)
410 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, id);
420 static int rz_mtu3_initialize_counter(struct counter_device *counter, int id)
422 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, id);
423 struct rz_mtu3_channel *const ch1 = rz_mtu3_get_ch(counter, 0);
424 struct rz_mtu3_channel *const ch2 = rz_mtu3_get_ch(counter, 1);
432 rz_mtu3_16bit_cnt_setting(counter, id);
437 * cascade counter.
447 rz_mtu3_32bit_cnt_setting(counter);
455 static void rz_mtu3_terminate_counter(struct counter_device *counter, int id)
457 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, id);
458 struct rz_mtu3_channel *const ch1 = rz_mtu3_get_ch(counter, 0);
459 struct rz_mtu3_channel *const ch2 = rz_mtu3_get_ch(counter, 1);
472 static int rz_mtu3_count_enable_read(struct counter_device *counter,
475 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
476 struct rz_mtu3_channel *const ch1 = rz_mtu3_get_ch(counter, 0);
477 struct rz_mtu3_channel *const ch2 = rz_mtu3_get_ch(counter, 1);
478 struct rz_mtu3_cnt *const priv = counter_priv(counter);
495 static int rz_mtu3_count_enable_write(struct counter_device *counter,
498 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
499 struct rz_mtu3_cnt *const priv = counter_priv(counter);
505 ret = rz_mtu3_initialize_counter(counter, count->id);
511 rz_mtu3_terminate_counter(counter, count->id);
532 static int rz_mtu3_cascade_counts_enable_get(struct counter_device *counter,
535 struct rz_mtu3_cnt *const priv = counter_priv(counter);
552 static int rz_mtu3_cascade_counts_enable_set(struct counter_device *counter,
555 struct rz_mtu3_cnt *const priv = counter_priv(counter);
571 static int rz_mtu3_ext_input_phase_clock_select_get(struct counter_device *counter,
574 struct rz_mtu3_cnt *const priv = counter_priv(counter);
591 static int rz_mtu3_ext_input_phase_clock_select_set(struct counter_device *counter,
594 struct rz_mtu3_cnt *const priv = counter_priv(counter);
625 static int rz_mtu3_action_read(struct counter_device *counter,
632 struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
633 struct rz_mtu3_cnt *const priv = counter_priv(counter);
838 struct counter_device *counter;
844 counter = devm_counter_alloc(dev, sizeof(*priv));
845 if (!counter)
848 priv = counter_priv(counter);
868 counter->name = dev_name(dev);
869 counter->parent = dev;
870 counter->ops = &rz_mtu3_cnt_ops;
871 counter->counts = rz_mtu3_counts;
872 counter->num_counts = ARRAY_SIZE(rz_mtu3_counts);
873 counter->signals = rz_mtu3_signals;
874 counter->num_signals = ARRAY_SIZE(rz_mtu3_signals);
875 counter->ext = rz_mtu3_device_ext;
876 counter->num_ext = ARRAY_SIZE(rz_mtu3_device_ext);
879 ret = devm_counter_add(dev, counter);
881 dev_err_probe(dev, ret, "Failed to add counter\n");
896 .name = "rz-mtu3-counter",
903 MODULE_ALIAS("platform:rz-mtu3-counter");
904 MODULE_DESCRIPTION("Renesas RZ/G2L MTU3a counter driver");