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

drivers: syscon: Set default for CONFIG_SYSCON to y #38762

Closed
wants to merge 1 commit into from

Conversation

yperess
Copy link
Collaborator

@yperess yperess commented Sep 23, 2021

Currently for large projects with many boards, using the syscon driver
is a bit of a pain. It has the convinience of using dt_compat_enabled
for CONFIG_GENERIC_SYSCON but that only works if CONFIG_SYSCON is
also enabled.

Set the default for CONFIG_SYSCON=y so that the driver can be enabled
by simply setting the devicetree node to status = "okay";

Signed-off-by: Yuval Peress [email protected]

@yperess
Copy link
Collaborator Author

yperess commented Sep 23, 2021

For reference, https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3177749 is the change that integrates syscon. If we don't have this default value for CONFIG_SYSCON then we would need to also make changes to all the boards under zephyr/boards/arm AND make sure that every new board also has this in the _defconfig. It's not impossible, but seems that the driver is already gated by the compatible string so there's no need to have double gating.

Copy link
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

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

How about using simple changing the default for CONFIG_SYSCON to y in the soc/<arch>/<soc>/Kconfig.defconfig.series for the SoCs containing a SYSCON device?

Copy link
Collaborator

@carlocaione carlocaione left a comment

Choose a reason for hiding this comment

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

This is ugly. What about using something like

default y if $(dt_compat_enabled,$(DT_COMPAT_SYSCON))

or something like that

@yperess
Copy link
Collaborator Author

yperess commented Sep 24, 2021

My initial approach was actually to collapse the two into a single config SYSCON (which in a way is very similar to what you said @carlocaione). It would remove SYSCON_GENERIC since it's basically redundant and move the default dt_compat_enabled up to the SYSCON config, it would look something like:

DT_COMPAT_SYSCON := syscon

menuconfig SYSCON
	bool "SYSCON (System Controller) drivers"
	default $(dt_compat_enabled,$(DT_COMPAT_SYSCON))
	help
	  SYSCON (System Controller) drivers. System controller node represents
	  a register region containing a set of miscellaneous registers. The
	  registers are not cohesive enough to represent as any specific type
	  of device. The typical use-case is for some other node's driver, or
	  platform-specific code, to acquire a reference to the syscon node and
	  extract information from there.
if SYSCON

module = SYSCON
module-str = syscon
source "subsys/logging/Kconfig.template.log_config"

config SYSCON_INIT_PRIORITY

Would that work for you? I was thinking it was too big of a change and decided to go with the minimal approach originally.

@henrikbrixandersen
Copy link
Member

Would that work for you? I was thinking it was too big of a change and decided to go with the minimal approach originally.

This will require changes if we bring in a SoC specific SYSCON driver in the future. I think we need to keep the "top-level" Kconfig for enabling SYSCON support and then have the drivers underneath that (as it is today).

@yperess
Copy link
Collaborator Author

yperess commented Sep 24, 2021

Would that work for you? I was thinking it was too big of a change and decided to go with the minimal approach originally.

This will require changes if we bring in a SoC specific SYSCON driver in the future. I think we need to keep the "top-level" Kconfig for enabling SYSCON support and then have the drivers underneath that (as it is today).

I see what you're saying, I would argue that CONFIG_SYSCON then is obsolete. We could do something similar to the logging template where CONFIG_SYSCON is enabled automatically if CONFIG_SYSCON_GENERIC is enabled (eventually other implementations). Should I update the PR so it's easier to see?

@henrikbrixandersen
Copy link
Member

henrikbrixandersen commented Sep 24, 2021

I see what you're saying, I would argue that CONFIG_SYSCON then is obsolete. We could do something similar to the logging template where CONFIG_SYSCON is enabled automatically if CONFIG_SYSCON_GENERIC is enabled (eventually other implementations). Should I update the PR so it's easier to see?

As far as I can tell, this would go against how all other drivers (except maybe interrupt controllers, where we recently had issues due to this exact construct (no top-level gating, see #37910 (comment))) handles Kconfig.

@yperess yperess requested a review from nashif as a code owner September 25, 2021 03:56
@github-actions github-actions bot added the area: Tests Issues related to a particular existing or missing test label Sep 25, 2021
drivers/syscon/CMakeLists.txt Outdated Show resolved Hide resolved
drivers/syscon/Kconfig Outdated Show resolved Hide resolved
drivers/syscon/Kconfig Outdated Show resolved Hide resolved
coreboot-org-bot pushed a commit to coreboot/chrome-ec that referenced this pull request Sep 28, 2021
Note that currently CONFIG_SYSCON=y is required. There's an ongoing
PR (zephyrproject-rtos/zephyr#38762) to remove
that requirement in favor of simply detecting an enabled node in DT
via the compatible string.

BRANCH=none
BUG=b:179900857, b:165777478, b:200642229
TEST=zmake testall

Signed-off-by: Yuval Peress <[email protected]>
Change-Id: Idad1f53afbda503e0e0b2fdf2931d5267a391d4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3177749
Reviewed-by: Sam Hurst <[email protected]>
@yperess yperess force-pushed the syscon branch 3 times, most recently from ddf7c27 to 8426328 Compare September 29, 2021 15:32
@yperess
Copy link
Collaborator Author

yperess commented Oct 5, 2021

Ping, I went ahead with the original suggestion of defaulting the CONFIG_SYSCON the same as CONFIG_GENERIC_SYSCON. Thoughts?

Copy link
Collaborator

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

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

Make sense to default the syscon drivers menu based on the devicetree settings.
Downstream users with custom drivers can do similar, and use zephyr_library_amend() to place a custom driver in the lib.

Just a minor nit.

drivers/syscon/CMakeLists.txt Outdated Show resolved Hide resolved
Currently for large projects with many boards, using the syscon driver
is a bit of a pain. It has the convinience of using dt_compat_enabled
for CONFIG_GENERIC_SYSCON but that only works if CONFIG_SYSCON is
also enabled.

Set the default for CONFIG_SYSCON to use the compat string. This makes
using syscon much simpler since all a developer needs to do is add it
to the devicetree and set the status to "okay".

Signed-off-by: Yuval Peress <[email protected]>
@yperess
Copy link
Collaborator Author

yperess commented Oct 6, 2021

Accidentally force pushed the wrong commit, all better now :)

Copy link
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

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

My initial comment still stands:

How about using simple changing the default for CONFIG_SYSCON to y in the soc/<arch>/<soc>/Kconfig.defconfig.series for the SoCs containing a SYSCON device?

Why does this need to be handled differently than all other drivers classes?

@tejlmand
Copy link
Collaborator

tejlmand commented Oct 6, 2021

How about using simple changing the default for CONFIG_SYSCON to y in the soc/<arch>/<soc>/Kconfig.defconfig.series for the SoCs containing a SYSCON device?

Why does this need to be handled differently than all other drivers classes?

But wouldn't that result in the same issue that @mbolivar-nordic tries to cleanup here ?
#38510

Having a config SYSCON\r default y in board series Kconfig will result in one of those two things:

Maybe we need to rethink how we enable drivers in general and where we place them in libraries.
Does each driver needs its own library if that library contains only a single file ?

@carlocaione
Copy link
Collaborator

While I agree with @henrikbrixandersen I wanted to point out that something similar is already used in zephyr, see https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/i2c/Kconfig.stm32#L7

@yperess
Copy link
Collaborator Author

yperess commented Oct 6, 2021

While I agree with @henrikbrixandersen I wanted to point out that something similar is already used in zephyr, see https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/i2c/Kconfig.stm32#L7

I think there's precedence for most different ways to enable things. I would propose that we create an issue to discuss this and once there are several comments on it we can bring it up at the weekly dev meeting?

@yperess
Copy link
Collaborator Author

yperess commented Oct 12, 2021

Ping

@carlocaione
Copy link
Collaborator

I think there's precedence for most different ways to enable things. I would propose that we create an issue to discuss this and once there are several comments on it we can bring it up at the weekly dev meeting?

Feel free to bring this to the next dev-meeting. Add a label for that in this case.

@yperess yperess added the dev-review To be discussed in dev-review meeting label Oct 12, 2021
@yperess
Copy link
Collaborator Author

yperess commented Oct 12, 2021

I think there's precedence for most different ways to enable things. I would propose that we create an issue to discuss this and once there are several comments on it we can bring it up at the weekly dev meeting?

Feel free to bring this to the next dev-meeting. Add a label for that in this case.

Done

@yperess
Copy link
Collaborator Author

yperess commented Oct 14, 2021

Discussed at dev meeting, no longer needed.

@yperess yperess closed this Oct 14, 2021
@yperess yperess deleted the syscon branch October 14, 2021 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System area: Tests Issues related to a particular existing or missing test dev-review To be discussed in dev-review meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants