Skip to content
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

driver: input: add input driver for rts5912 #86755

Conversation

JasonLin-RealTek
Copy link
Collaborator

Add input driver for Realtek rts5912.

@zephyrbot zephyrbot added platform: Realtek EC area: Input Input Subsystem and Drivers labels Mar 7, 2025
@JasonLin-RealTek JasonLin-RealTek force-pushed the add_realtek_rts5912_input_driver branch 2 times, most recently from e0e0726 to bd23873 Compare March 7, 2025 11:13
Copy link
Member

@fabiobaltieri fabiobaltieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, just a couple of minor comments

@@ -17,6 +17,7 @@
zephyr,sram = &sram0;
zephyr,console = &uart0;
zephyr,flash = &flash0;
zephyr,keyboard-scan = &kscan_input;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you drop this? this api is being removed in this release, sorry for the noise

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 52 to 54
kscan_input: kscan-input {
compatible = "zephyr,kscan-input";
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, drop

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, drop it.

@@ -0,0 +1,10 @@
# Copyright (c) 2021 Realtek Corporation. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025, happy new year :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy new year!
it's 2025

depends on DT_HAS_REALTEK_RTS5912_KBD_ENABLED
select INPUT_KBD_MATRIX
help
This option enables the REALTEK keyboard scan driver.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realtek? RealTek? Pick one and stick to it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We picked RealTek here.

Comment on lines 19 to 20
#define LOG_LEVEL CONFIG_INPUT_LOG_LEVEL
LOG_MODULE_REGISTER(input_realtek_rts5912_kbd);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG_MODULE_REGISTER(input_realtek_rts5912_kbd, CONFIG_INPUT_LOG_LEVEL); keep it compact

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


/* Set KSO output data */
key = irq_lock();
inst->SCANOUT = kso_val;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey just checking, inst->SCANOUT is not going to change pins that are not mapped to the keyboad driver in pin control right? As in: if some of those pins are used as gpios, this should not be affecting them

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We add the kso_ignore_mask to this function.

KBM_Type *const inst = config->base;

/* Bits are active-low, so toggle it (return 1 means key pressed) */
return ((inst->SCANIN ^ data->ksi_pin_mask) & data->ksi_pin_mask);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you not just invert all the bits in the register all the time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, tks

Comment on lines 226 to 227
BUILD_ASSERT(IN_RANGE(DT_INST_PROP(0, row_size), 1, 10), "invalid row-size");
BUILD_ASSERT(IN_RANGE(DT_INST_PROP(0, col_size), 1, 20), "invalid col-size");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10x20? that's a seriously big keyboard :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review!
Our maximum keyboard can support kso19 and ksi9.

@JasonLin-RealTek JasonLin-RealTek force-pushed the add_realtek_rts5912_input_driver branch 5 times, most recently from ff52039 to d6a13c7 Compare March 14, 2025 11:41
Copy link
Contributor

@keith-zephyr keith-zephyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiobaltieri are there any tests or samples that this driver can be added to so that the module gets compiled by CI?

@fabiobaltieri
Copy link
Member

@fabiobaltieri are there any tests or samples that this driver can be added to so that the module gets compiled by CI?

This should happen automatically since the device is instantiated in the board, at least in the weekly, but it also looks like the PR run here correctly built it as well, I see these in the junit file

                <testcase classname="rts5912_evb/rts5912:sample.input.input_dump" name="sample.input.input_dump" time="0.00" />
                <testcase classname="rts5912_evb/rts5912:sample.input.input_dump_shell" name="sample.input.input_dump_shell" time="0.00" />

* @brief Keyboard Matrix Controller (KBM)
*/

typedef struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't create new typedefs. Use struct kbm_regs or something similar. Also, make the entire structure volatile instead of the individual fields.

volatile struct kbm_regs *base;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,
We change the way to define the kbm register and use volatile on the whole fields of the structure.

@JasonLin-RealTek JasonLin-RealTek force-pushed the add_realtek_rts5912_input_driver branch from d6a13c7 to 85af136 Compare March 18, 2025 10:13
fabiobaltieri
fabiobaltieri previously approved these changes Mar 18, 2025
Comment on lines 15 to 18
uint32_t SCANOUT;
uint32_t SCANIN;
uint32_t INTEN;
uint32_t CTRL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please snake case to match Zephyr coding style. Convert these fields to lower case.
https://docs.zephyrproject.org/latest/contribute/style/code.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,
We use the snake case to name the variable.

Add input driver for Realtek rts5912.

Signed-off-by: Lin Yu-Cheng <lin_yu_cheng@realtek.com>
@JasonLin-RealTek JasonLin-RealTek force-pushed the add_realtek_rts5912_input_driver branch from 8d6408c to faa0352 Compare March 19, 2025 10:39
@kartben kartben merged commit 2d541a0 into zephyrproject-rtos:main Mar 19, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Input Input Subsystem and Drivers platform: Realtek EC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants