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

[DNM] ASoC: SOF: imx: imx driver refactorization and imx95 driver introduction #5307

Draft
wants to merge 9 commits into
base: topic/sof-dev
Choose a base branch
from

Conversation

LaurentiuM1234
Copy link

@LaurentiuM1234 LaurentiuM1234 commented Jan 23, 2025

A rather aggressive but arguably much needed refactorization of the imx SOF drivers. The refactorization is meant to address the code duplication in the imx drivers and decrease the coding effort required for introducing a new imx platform.

After the refactorization, only two drivers remain: imx8 (meant for imx chips belonging to the imx8 family: imx8 (aka imx8qm), imx8x (aka imx8qxp), imx8m, imx8ulp) and imx9 (mean for imx chips belonging to the imx9 family: imx95).

The series also includes the introduction of the imx95 driver.

The series requires some CI testing, which is why it's tagged with [DNM]. Submitted for initial comments.

@LaurentiuM1234 LaurentiuM1234 force-pushed the feat/imx_driver_refactor branch 2 times, most recently from eb54f7b to d6dbfe0 Compare January 23, 2025 14:53
The SOF drivers for imx chips have a lot of duplicate code
and routines/code snippets that could certainly be reused
among drivers.

As such, introduce a new set of structures and functions
that will help eliminate the redundancy and code size of
the drivers.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
The common interface for imx chips (defined in imx-common.c) contains the
definitions for a lot of functions required by the SOF core. As such, the
platform driver can just use the common definitions instead of duplicating
code by re-defining aforementioned functions.

Make the transition to the new common interface. This consists of:

  1) Removing unneeded functions, which are already defined in the
  common interface.

  2) Defining some chip-specific operations/structures required by the
  interface to work.

  3) Dropping structure definitions that are no longer needed.

  4) Adapting some existing functions to the new interface.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
The definition of 'struct sof_dev_desc' has the following properties
for imx chips:

  1) FW path is the same for all chips.
  2) Topology path is the same for all chips.
  3) FW name can be written as: "sof-${machine_name}.ri"
  4) IPC3 is the only supported protocol

The structure takes quite a few lines of code. Since the intention
is to add support for more imx8 chips in the same driver, we need
to try and reduce the number of lines taken by information that's
not particularly useful. As such, we can use 'IMX_SOF_DEV_DESC()'
to reduce the declaration of the structure to just one line. The
only information that's particularly useful can be seen from the
parameters of the macro.

Of course, if any of the assumptions don't apply anymore, driver
writers can simply declare the 'struct sof_dev_desc' the "old
fashioned way". No reason to make the macro suit multiple needs.

The same logic applies to the array of 'struct snd_soc_dai_driver'.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
Shuffle the definitions of some structures and functions such that
they are better grouped. This is purely a cosmetic change.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
Drop some unneeded/unused macro definitions and header includes.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
@LaurentiuM1234 LaurentiuM1234 force-pushed the feat/imx_driver_refactor branch from d6dbfe0 to bea6639 Compare January 23, 2025 18:11
The definition for the ops_init() operation is similar among the imx8
chips (namely: imx8, imx8x, imx8m, and imx8ulp). The only difference is
the name of the 'struct snd_soc_dai_driver' array used to fill the SOF
ops structure.

As such, 'imx8_ops_init()' can be made into an utility function that takes
the 'struct snd_soc_dai_driver' array and its size as parameters and fills
the SOF ops structure fields accordingly. This will allow us to reuse this
function when the other drivers (imx8m, imx8ulp) are merged into this one.

Since the definition of the function is changed, it can no longer be
used directly by the SOF core. Therefore, also introduce a wrapper:
'imx_ops_init()' that will call 'imx8_ops_init()' with the right
parameters based on the chip.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
Now that the common interface for imx chip has been introduced,
there's no longer a need to have a separate platform driver for
imx8m. As such, merge the driver with the imx8 driver. Furthermore,
delete the old driver as it's no longer useful.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
Now that the common interface for imx chip has been introduced,
there's no longer a need to have a separate platform driver for
imx8ulp. As such, merge the driver with the imx8 driver. Furthermore,
delete the old driver as it's no longer useful.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
@LaurentiuM1234 LaurentiuM1234 force-pushed the feat/imx_driver_refactor branch from bea6639 to 252b1bd Compare January 23, 2025 18:19
Add SOF support for the imx95 chip. Although the support is just
for the imx95 chip, the driver is intended for all chips in the imx9
family.

Note that the imx95 support could have just as easily been added
to the imx8 platform driver but a new platform driver was created
because the intention is to keep the families in separate drivers.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
@LaurentiuM1234 LaurentiuM1234 force-pushed the feat/imx_driver_refactor branch from 252b1bd to 386ce80 Compare January 23, 2025 18:21
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.

1 participant