-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: input: add support for Renesas CTSU #92433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
drivers: input: add support for Renesas CTSU #92433
Conversation
Update rev of hal_renesas to add support for CTSU Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
The following west manifest projects have changed revision in this Pull Request:
⛔ DNM label due to: 1 project with PR revision Note: This message is automatically posted and updated by the Manifest GitHub Action. |
203be5e
to
c26a69a
Compare
Woops, added few comments on #92434, should have probably done it here, could you pick the initial comments from there? Sorry for the confusion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabiobaltieri Move conversion from #92434 due to this PR should be the correct place for review
threshold = <769>; | ||
hysteresis = <38>; | ||
event-code = <INPUT_KEY_0>; | ||
status = "okay"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood that a status = "okay";
is not necessary in the node example for documentation, right? If its correct, I will remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also not necessary in the first place unless you are overriding a node that has been defined with status disabled, typically these would be the basic SoC device nodes defined under soc/
and enabled from boards/
, but for these pseudo-device node things that are defined in board
without overriding anything you don't need to set the status, they are enabled by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
understood. I will remove the status
from the documentation and the board/shield dts
#define K_POLLING K_MSEC(CONFIG_INPUT_RENESAS_RA_CTSU_POLLING_INTERVAL_MS) | ||
#define K_STABILIZATION K_USEC(CONFIG_INPUT_RENESAS_RA_CTSU_STABILIZATION_TIME_US) | ||
|
||
static ALWAYS_INLINE void renesas_ra_ctsu_drv_handler(void *arg0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refer it from some skeleton code that exist in Zephyr repo (ex: udc_skeleton.c). So, if it's not good/suitable for this driver, I will change as your suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't bother unless you know that it is actually making a difference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so back on this one, I'd suggest
- drop the ALWAYS_INLINE
- add the extra 2 dummy argument, drop the
renesas_ra_ctsu_thread##inst
generated wrapper and call this directly from k_thread_create
Thanks for porting the comments over from the other PR |
c26a69a
to
2d79335
Compare
}; \ | ||
\ | ||
DEVICE_DT_INST_DEFINE(inst, ctsu_device_init, NULL, NULL, &ctsu_button_cfg##inst, \ | ||
POST_KERNEL, CONFIG_INPUT_INIT_PRIORITY, NULL);)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you formatting manually? I'd move the ))
down a line and at the same indentation as the IF_ENABLED
, this is a bit hard to follow as it is
#define K_POLLING K_MSEC(CONFIG_INPUT_RENESAS_RA_CTSU_POLLING_INTERVAL_MS) | ||
#define K_STABILIZATION K_USEC(CONFIG_INPUT_RENESAS_RA_CTSU_STABILIZATION_TIME_US) | ||
|
||
static ALWAYS_INLINE void renesas_ra_ctsu_drv_handler(void *arg0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so back on this one, I'd suggest
- drop the ALWAYS_INLINE
- add the extra 2 dummy argument, drop the
renesas_ra_ctsu_thread##inst
generated wrapper and call this directly from k_thread_create
static void renesas_ra_ctsu_make_thread##inst(const struct device *dev) \ | ||
{ \ | ||
struct renesas_ra_ctsu_data *data = dev->data; \ | ||
\ | ||
k_thread_create(&data->thread_data, renesas_ra_ctsu_drv_stack##inst, \ | ||
K_THREAD_STACK_SIZEOF(renesas_ra_ctsu_drv_stack##inst), \ | ||
renesas_ra_ctsu_thread##inst, (void *)dev, NULL, NULL, \ | ||
K_PRIO_COOP(CTSU_DRV_THREAD_PRIORITY), K_ESSENTIAL, K_NO_WAIT); \ | ||
k_thread_name_set(&data->thread_data, dev->name); \ | ||
} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for this wrapper, declare the stack as part of renesas_ra_ctsu_data
and move this code directly in renesas_ra_ctsu_init
, you can check out input_analog_axis.c
for reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I moved stack memory into data structure.
PINCTRL_DT_INST_DEFINE(inst); \ | ||
K_THREAD_STACK_DEFINE(renesas_ra_ctsu_drv_stack##inst, CTSU_DRV_THREAD_STACK_SIZE); \ | ||
\ | ||
static void renesas_ra_ctsu_thread##inst(void *dev, void *arg1, void *arg2) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for this wrapper, see the comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. The thread creation was called directly in init() function.
const struct ctsu_device_cfg *cfg = dev->config; | ||
uint16_t *p_data = data; | ||
|
||
if (p_data != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swap the condition, normal execution inline
if (p_data == NULL) {
return;
}
input_report_abs(...);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if (cfg->num_button > 0) { | ||
if (*data->p_button_status != 0) { | ||
uint64_t tmp_status = *data->p_button_status; | ||
|
||
while (tmp_status != 0) { | ||
int num = u64_count_trailing_zeros(tmp_status); | ||
struct renesas_ra_ctsu_device_cb *p_button_cb = | ||
&data->p_button_cb[num]; | ||
|
||
p_button_cb->device_cb(p_button_cb->dev, NULL); | ||
WRITE_BIT(tmp_status, num, 0); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about refactoring this and the two below in their own functions? flag those as maybe_unused, have an early return for
if (cfg->num_button == 0) {
return;
}
so you have one less indentation level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. 3 new reading function was created for buttons, wheels and sliders
5331c27
to
07d5949
Compare
First commit to add support for Renesas RA Capasitive Sensing Unit Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Add CTSU pin function selection for Renesas RA devices Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Add device node support for Renesas RA SoCs Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
Enable support for CTSU button on ek_ra2a1 board Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
07d5949
to
0c1eaa3
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a couple more comments, then I guess this is waiting for the hal PR to be reviewed, can you get it approved by someone else working on renesas? then I can merge it
{ | ||
ARG_UNUSED(arg1); | ||
ARG_UNUSED(arg2); | ||
const struct device *ctsu_dev = (const struct device *)arg0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the casting, arg0 is a void *
there's nothing the compiler can check for you
#if DT_HAS_COMPAT_STATUS_OKAY(renesas_ra_ctsu_slider) | ||
static void renesas_ra_ctsu_group_sliders_read(const struct device *dev) | ||
{ | ||
const struct renesas_ra_ctsu_group_cfg *cfg = dev->config; | ||
struct renesas_ra_ctsu_group_data *data = dev->data; | ||
|
||
if (cfg->num_slider == 0) { | ||
return; | ||
} | ||
|
||
for (int i = 0; i < cfg->num_slider; i++) { | ||
uint16_t slider_position = data->p_slider_position[i]; | ||
|
||
if (slider_position != UINT16_MAX) { | ||
struct renesas_ra_ctsu_device_cb *p_slider_cb = &data->p_slider_cb[i]; | ||
|
||
p_slider_cb->device_cb(p_slider_cb->dev, &slider_position); | ||
} | ||
} | ||
} | ||
#endif /* DT_HAS_COMPAT_STATUS_OKAY(renesas_ra_ctsu_slider) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move the #if
condition inside the function body and let it be a no-op when this is not enabled, then you can remove the conditionals from renesas_ra_ctsu_group_reading_handler
and always call these, they'll just get optimized out when they are not needed
This PR to add Input subsys support on Renesas CTSU HWIP