-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
spi: shell: rework command to use SPI devices #73962
base: main
Are you sure you want to change the base?
Conversation
Hello @liambeguin, and thank you very much for your first pull request to the Zephyr project! |
@@ -74,82 +91,12 @@ static int cmd_spi_transceive(const struct shell *ctx, size_t argc, char **argv) | |||
return ret; | |||
} | |||
|
|||
static int cmd_spi_conf(const struct shell *ctx, size_t argc, char **argv) |
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.
The idea with this command was to test things at run-time without any DTS pre-configuration made. An on-the-fly configuration command then.
Note that, however, having something like you propose co-existing with this spi_conf, would be nice.
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.
The idea with this command was to test things at run-time without any DTS pre-configuration made. An on-the-fly configuration command then.
I originally had this as an extra command, but thought it doesn't really take much effort to add the node to an existing devicetree.
Note that, however, having something like you propose co-existing with this spi_conf, would be nice.
Agreed, to me this is very useful for device driver development, and also ensures proper CS handling.
I don't mind adding back the conf command though, but I think we should be explicit about the CS handling.
We could also have a build CONFIG_ to switch between both modes, one interacting with SPI controllers, and another with SPI devices?
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 originally had this as an extra command, but thought it doesn't really take much effort to add the node to an existing devicetree.
True, and I wouldn't see myself doing otherwise.
@benner any input on this one?
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 like this approach because it allows to use different chip selects. During development I did knew how to do something like IS_SPIDEV_NODE
and I was lucky that in my case it was the only one device on SPI bus.
We could also have a build CONFIG_ to switch between both modes, one interacting with SPI controllers, and another with SPI devices?
I agree this is better option
I also found one retrogression (at least for me). I'm getting
After some digging I found one SPI bus device with fake compatible (I was too lazy to create proper bindings).
If I'm disabling it (ant ton of code accessing it) - everything is OK. Not sure how it can be related because I'm using it with same |
I think this comes from the fact that I add the device to a list but because you don't have a valid compatible it gets deleted later on. I'm not entirely sure, but I noticed something similar with a valid compatible and its config disabled. |
@liambeguin, this my assumption too. I quickly described simple dts:
and changed So please ignore this regression for now. I will play more. Problem - I'm on PTO, so not much time I have ATM. Overall code and idea - looks good. |
I know it's rc2 now. Can f451e54 be extracted to separate PR and merged (it's kind fix and fits current stage)? |
sure, I don't mind separating it if someone is ready to take it |
I made PR with just first commit (commit author preserved): #75685 |
@liambeguin would #71912 be useful/applicable for—at least some of—what you're trying to accomplish here? |
@kartben if I understand correctly that MR is related to node labels no? For the SPI shell, I'm looking at all devices that have a required spi property so I don't think it would apply directly. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
@liambeguin Could you rebase against the main branch? @teburd any input? lgtm at least here |
Will do! |
6a921d4
to
4c06a04
Compare
Rework the shell interface to work on SPI devices. This will create a build-time list of all spi device nodes based on the devicetree. At runtime, the shell will autocomplete device names and use spi_transceive_dt() to leverage the devicetree configuration of each node. This removes the need for a conf command, and will ensure that all chip select modes are properly supported (i.e. cs-gpios). Signed-off-by: Liam Beguin <[email protected]>
4c06a04
to
af5a532
Compare
Rework the shell interface to work on SPI devices. This will create a
build-time list of all spi device nodes based on the devicetree.
At runtime, the shell will autocomplete device names and use
spi_transceive_dt() to leverage the devicetree configuration of each
node. This removes the need for a conf command, and will ensure that all
chip select modes are properly supported (i.e. cs-gpios).