Skip to content

Conversation

@mildsunrise
Copy link
Contributor

expands the Python driver / regmaps with many of the things in AsahiLinux/docs#225 and implements the basic functionality as a C driver

@mildsunrise mildsunrise force-pushed the spmi-driver branch 2 times, most recently from d6876ed to 01bb482 Compare December 2, 2025 16:13
Copy link
Member

@svenpeter42 svenpeter42 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 to me except for a few very minor comments

src/spmi.c Outdated
#define SPMI_STATUS_TX_EMPTY BIT(8)
#define SPMI_STATUS_TX_COUNT GENMASK(7, 0)

#define SPMI_CMD__RESET 0x10
Copy link
Member

Choose a reason for hiding this comment

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

that double __ is a bit unusual but I can't thing of a better name schema here either.

Copy link
Contributor Author

@mildsunrise mildsunrise Dec 7, 2025

Choose a reason for hiding this comment

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

yeah, same... I think I'll change it to SPMI_OPCODE_ (or SPMI_OPC_) which is what Linux uses (well, Linux uses it for the name of the parameter in methods, not for the constants, but...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a commit with the rename, let me know if it's okay or you prefer something else (or if you want the commit squashed into the previous ones)

Copy link
Member

Choose a reason for hiding this comment

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

please squash the commit and then i'm going to merge this. you can ignore the pytest CI failure fwiw

- refactor into a single raw_command method for simplicity

- add timeout when waiting for RX data

- implement all slave commands, including the rest of the
  register access commands (this is necessary for the USB-PD
  controller, which REQUIRES a reg 0 write command specifically.
  if written using any other command, it will appear to work
  but the other registers won't be updated)

- parse and check replies (check command / slave, padding,
  frame parity)

- validate command inputs

Signed-off-by: Alba Mendez <[email protected]>
(especially interrupts)

Signed-off-by: Alba Mendez <[email protected]>
a straightforward translation of the Python version in hw.spmi,
but I was too lazy to implement all of the commands

Signed-off-by: Alba Mendez <[email protected]>
we'll use 'command' (or 'cmd') to mean the entire
transaction, and 'opcode' (or 'opc') to mean the part
of a command that specifies which kind of operation
to perform (i.e. the value carried in the SPMI
"command frame")

Signed-off-by: Alba Mendez <[email protected]>
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