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

arch/arm64/lspi: improve spi initialization #315

Merged
merged 1 commit into from
Nov 19, 2024
Merged

Conversation

joukkone
Copy link

Hardware initialization is based refcount, not
spi enable bit. Interface to disable selected bus
added

Summary

Impact

Testing

@joukkone joukkone requested a review from jlaitine November 18, 2024 07:37
@jlaitine
Copy link

The priv->refcount doesn't actually work as a reference counter, since the bus can't be uninitialized and refcount doesn't count downwards there. Maybe also add an "uninitialize" function to count down priv->refcount, and from there call the disable when the count goes to 0. Just to have the refcount fully implemented.... Then work this to upstream

{
struct imx9_lpspidev_s *priv = (struct imx9_lpspidev_s *)dev;

if (priv->refcount == 1)

Choose a reason for hiding this comment

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

Why not just first decrease refcount (if refcount > 0) and then disable if refcount == 0 ?


if (priv->refcount == 1)
{
imx9_lpspibus_disable(priv->bus_number);

Choose a reason for hiding this comment

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

I feel bus_number is unnecessary... why not just pass the "struct spi_dev_s *dev" to the "disable".

if (priv->refcount == 0)
{
imx9_lpspi_modifyreg32(priv,
IMX9_LPSPI_CR_OFFSET, LPSPI_CR_MEN, 0);

Choose a reason for hiding this comment

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

indent this line

Hardware initialization is based refcount, not
spi enable bit and add interface to unitialize bus

Signed-off-by: Jouni Ukkonen <[email protected]>
@joukkone joukkone merged commit 7e85f5b into master Nov 19, 2024
11 checks passed
@joukkone joukkone deleted the imx9_spi_init branch November 19, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants