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

Add realtek rts5912 soc #75267

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

JasonLin-RealTek
Copy link

This PR adds support for the RTS5912 EC Chip from Realtek.

The initial support for the board includes TIMER, GPIO, CLOCK_CONTROL, PINCTRL.

please help us review the pull request.

Thanks!

@zephyrbot zephyrbot added area: UART Universal Asynchronous Receiver-Transmitter area: Timer Timer area: Pinctrl area: GPIO area: Devicetree Binding PR modifies or adds a Device Tree binding area: Clock Control labels Jul 1, 2024
Copy link

github-actions bot commented Jul 1, 2024

Hello @JasonLin-RealTek, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

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

please, organize commit content properly, it seems that first commit contains e.g. pinctrl stuff which should not be there.

Comment on lines 8 to 9
config BOARD
default "rts5912_evb"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
config BOARD
default "rts5912_evb"

this is hwmv1

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

#

config BOARD_RTS5912_EVB
bool "Realtek RTS5912 Evaluation Board"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
bool "Realtek RTS5912 Evaluation Board"

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Collaborator

Choose a reason for hiding this comment

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

convert to webp, then put it through https://tinypng.com/

Copy link
Author

Choose a reason for hiding this comment

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

done

&cpu0 {
cpu-power-states = <&idle &suspend_to_ram>;
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

non-blocking comment: should there be flash partitions here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

unaddressed

Copy link
Member

Choose a reason for hiding this comment

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

power states must not be at board level

Copy link
Author

Choose a reason for hiding this comment

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

We have put those power state to rts5912.dtsi.

# Serial Driver
CONFIG_SERIAL=y

# CONSOLE
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# CONSOLE
# Console

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 6 to 10
if SOC_FAMILY_REALTEK_EC
rsource "*/Kconfig.defconfig.series"
endif # SOC_FAMILY_REALTEK_EC
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if SOC_FAMILY_REALTEK_EC
rsource "*/Kconfig.defconfig.series"
endif # SOC_FAMILY_REALTEK_EC
if SOC_FAMILY_REALTEK_EC
rsource "*/Kconfig.defconfig.series"
endif # SOC_FAMILY_REALTEK_EC

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 6 to 9
config SOC_FAMILY_REALTEK_EC
bool
config SOC_FAMILY
Copy link
Collaborator

Choose a reason for hiding this comment

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

add newline

Copy link
Author

Choose a reason for hiding this comment

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

done

soc/realtek/ec/rts5912/Kconfig Outdated Show resolved Hide resolved
bool "Realtek RTS5912 Series EC"
select ARM
select CPU_CORTEX_M33
select SOC_FAMILY_REALTEK_EC
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
select SOC_FAMILY_REALTEK_EC

Copy link
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 12 to 20
config SOC_SERIES
default "rts5912" if SOC_SERIES_RTS5912

config SOC_RTS5912
bool
select SOC_SERIES_RTS5912

config SOC
default "rts5912" if SOC_RTS5912
Copy link
Collaborator

Choose a reason for hiding this comment

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

non-blocking comment: do you really need a soc series when the soc and soc series name as the same? Is this really a series?

Copy link
Author

Choose a reason for hiding this comment

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

There may be series and plenty of SoCs with different names in the future.

In order to maintain the consistency of the folder structure, we will use the same name for the series and SoCs for now.

@JasonLin-RealTek JasonLin-RealTek force-pushed the add_realtek_rts5912_soc branch 2 times, most recently from e16ff4a to 7a10790 Compare July 3, 2024 11:08
@JasonLin-RealTek
Copy link
Author

JasonLin-RealTek commented Jul 4, 2024

please, organize commit content properly, it seems that first commit contains e.g. pinctrl stuff which should not be there.

We followed the suggestions to fix the code and passed the twister testing.
Are there any further suggestions? Could you please approve the PR?

Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

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

I can't see any changes regarding my previous request

@JasonLin-RealTek
Copy link
Author

I can't see any changes regarding my previous request

We misunderstood the request and moved the [pinctrl+register] files to their own commit.
Now we have committed the device tree file into a single commit.
Is that correct?

if SOC_FAMILY_REALTEK_EC

menuconfig REALTEK_RTS5912_IMG_HEADER
bool "The output binary with RTS5912 image header"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
bool "The output binary with RTS5912 image header"
bool "Add RTS5912 image header to output binary"

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

menuconfig REALTEK_RTS5912_IMG_HEADER
bool "The output binary with RTS5912 image header"
help
the RTS5912 ROM code loads firmware image from flash to RAM by the image header setting.
Copy link
Collaborator

Choose a reason for hiding this comment

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

*The

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

soc/realtek/ec/Kconfig Outdated Show resolved Hide resolved
Comment on lines 40 to 22
choice REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_CHOICE
prompt "Clock frequency to use for SPI flash"
default REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_DIV1
help
This selects the SPI clock frequency that will be used for loading
firmware binary from flash to RAM.

config REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_DIV1
bool "SPI flash clock frequency is SPIC engine clock divide 1"

config REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_DIV2
bool "SPI flash clock frequency is SPIC engine clock divide 2"

config REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_DIV4
bool "SPI flash clock frequency is SPIC engine clock divide 4"

config REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_DIV8
bool "SPI flash clock frequency is SPIC engine clock divide 8"

endchoice # REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_CHOICE

config REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ
int
default 0 if REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_DIV1
default 1 if REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_DIV2
default 2 if REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_DIV4
default 3 if REALTEK_RTS5912_IMG_HEADER_SPI_FREQ_MHZ_DIV8

Copy link
Collaborator

Choose a reason for hiding this comment

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

But they should come from dts, not Kconfig


endif # REALTEK_RTS5912_IMG_HEADER

#source "soc/realtek/*/Kconfig.soc"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#source "soc/realtek/*/Kconfig.soc"

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

drivers/clock_control/clock_control_rts5912_sccon.c Outdated Show resolved Hide resolved
drivers/clock_control/clock_control_rts5912_sccon.c Outdated Show resolved Hide resolved
drivers/clock_control/clock_control_rts5912_sccon.c Outdated Show resolved Hide resolved
drivers/timer/realtek_rts5912_rtmr.c Outdated Show resolved Hide resolved
drivers/timer/realtek_rts5912_rtmr.c Outdated Show resolved Hide resolved
drivers/timer/realtek_rts5912_rtmr.c Outdated Show resolved Hide resolved
drivers/timer/realtek_rts5912_rtmr.c Outdated Show resolved Hide resolved
drivers/gpio/gpio_rts5912.c Outdated Show resolved Hide resolved
drivers/gpio/gpio_rts5912.c Outdated Show resolved Hide resolved
drivers/serial/uart_realtek_rts5912.c Outdated Show resolved Hide resolved
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.

Just a couple more nitpicks from me, thanks

Comment on lines 69 to 70
pinctrl-0 = < &jtag_tdi_gpio87 &jtag_tdo_gpio88 &jtag_rst_gpio89
&jtag_clk_gpio90 &jtag_tms_gpio91>;
Copy link
Member

Choose a reason for hiding this comment

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

nit, the indentation got a bit funny here, drop the leading spaces

Copy link
Author

Choose a reason for hiding this comment

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

We remove the leading spaces in next version of PR and align jtag_clk_gpio90 to the jtag_tdi_gpio87.

Comment on lines 93 to 96
interrupts = < 0 0 1 0 2 0 3 0
4 0 5 0 6 0 7 0
8 0 9 0 10 0 11 0
12 0 13 0 14 0 15 0>;
Copy link
Member

Choose a reason for hiding this comment

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

same for all of these

				interrupts = <0 0 1 0 2 0 3 0
					      4 0 5 0 6 0 7 0

etc

Copy link
Author

Choose a reason for hiding this comment

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

As the sample, we modified the interrupt numbers format.

@JasonLin-RealTek JasonLin-RealTek force-pushed the add_realtek_rts5912_soc branch 2 times, most recently from 5538070 to af9133b Compare November 26, 2024 06:51
@JasonLin-RealTek
Copy link
Author

We have run ruff to format the img_gen.py.

@JasonLin-RealTek
Copy link
Author

Fix merging conflicts.

Add support for Realtek RTS5912 embedded controller (EC).

Signed-off-by: Lin Yu-Cheng <[email protected]>
Add Realtek RTS5912 chip and driver device tree files.

Signed-off-by: Lin Yu-Cheng <[email protected]>
@JasonLin-RealTek JasonLin-RealTek force-pushed the add_realtek_rts5912_soc branch 2 times, most recently from 737ac11 to aaa6d25 Compare November 28, 2024 03:24
fabiobaltieri
fabiobaltieri previously approved these changes Nov 29, 2024
Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

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

Looks good, cool to see an soc can be added without deleting a single line of code :)

drivers/clock_control/clock_control_rts5912_sccon.c Outdated Show resolved Hide resolved
drivers/gpio/gpio_rts5912.c Outdated Show resolved Hide resolved
drivers/serial/uart_realtek_rts5912.c Outdated Show resolved Hide resolved
Add clock controller driver for Realtek RTS5912.

Signed-off-by: Lin Yu-Cheng <[email protected]>
Add pinctrl driver for Realtek RTS5912.

Signed-off-by: Lin Yu-Cheng <[email protected]>
Add swj driver for Realtek RTS5912.

Signed-off-by: Lin Yu-Cheng <[email protected]>
Add timer driver for Realtek RTS5912.

Signed-off-by: Lin Yu-Cheng <[email protected]>
Add gpio driver for Realtek RTS5912.

Signed-off-by: Lin Yu-Cheng <[email protected]>
Add UART driver for Realtek RTS5912.

Signed-off-by: Lin Yu-Cheng <[email protected]>
Add support for Realtek rts5912_evb board

Signed-off-by: Lin Yu-Cheng <[email protected]>
This commit adds api and driver of Realtek EC to maintainers.yml

Signed-off-by: Lin Yu-Cheng <[email protected]>

#include <zephyr/logging/log.h>
#include <zephyr/kernel.h>
#include <zephyr/pm/pm.h>
Copy link
Member

Choose a reason for hiding this comment

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

why is PM involved at all here?

Comment on lines +6 to +23
description: |
This binding gives a base representation of the pins configuration

compatible: "realtek,rts5912-pinctrl"

include: [base.yaml, pinctrl-device.yaml, pincfg-node.yaml]

properties:
reg:
required: true

child-binding:
description: |
This binding gives a base representation of the pins configuration

include:
- name: pincfg-node.yaml

Copy link
Member

Choose a reason for hiding this comment

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

missing docs, list of allowed properties?

Comment on lines +56 to +60
#define STD_GPIO_FUNC1 \
((REALTEK_RTS5912_FUNC1) | (REALTEK_RTS5912_GPIO_PINON) | (REALTEK_RTS5912_GPIO_SCHMITTER))
#define STD_GPIO_FUNC2 \
((REALTEK_RTS5912_FUNC2) | (REALTEK_RTS5912_GPIO_PINON) | (REALTEK_RTS5912_GPIO_SCHMITTER))
#define STD_GPIO_FUNC3 \
Copy link
Member

Choose a reason for hiding this comment

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

why is schmitt trigger configured here? there are standard properties for that

Comment on lines +21 to +30
#define REALTEK_RTS5912_GPIO_DRIVING BIT(11) /* DRIVING : 0 low 1 high */
#define REALTEK_RTS5912_GPIO_SLEW BIT(12) /* SLEW : 0 fast 1 slow */
#define REALTEK_RTS5912_GPIO_PULLDN BIT(13) /* PULL DOWN : 0 disable 1 ebable */
#define REALTEK_RTS5912_GPIO_PULLUP BIT(14) /* PULL UP : 0 disable 1 ebable */
#define REALTEK_RTS5912_GPIO_SCHMITTER BIT(15) /* Schmitter : 1 ebable 0 disable */
#define REALTEK_RTS5912_GPIO_TYPE BIT(16) /* TYPE : 0 PP 1 OD */
#define REALTEK_RTS5912_GPIO_HILOW BIT(17) /* OUTPUT : 0 low 1 high */

#define REALTEK_RTS5912_INPUT_OUTPUT_POS 0
#define REALTEK_RTS5912_INPUT_DETECTION_POS 1
Copy link
Member

Choose a reason for hiding this comment

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

same here: these are props that need to be managed using standard props.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Clock Control area: Comparator area: Devicetree Binding PR modifies or adds a Device Tree binding area: GPIO area: Pinctrl area: Process area: RTC Real Time Clock area: Timer Timer area: UART Universal Asynchronous Receiver-Transmitter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants