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: mcux: flexio: Added generic MCUX FlexIO driver #53748

Merged
merged 5 commits into from Mar 12, 2024

Conversation

MikhailSiomin
Copy link
Contributor

@MikhailSiomin MikhailSiomin commented Jan 12, 2023

The driver has been tested on a mimxrt1064_evk board with 4 FlexIO SPI running at the same time.

prj.conf:

CONFIG_SPI=y
# CONFIG_SPI_ASYNC=y # supported
CONFIG_SPI_MCUX_FLEXIO=y

mimxrt1064_evk.overlay:

&pinctrl {
	pinmux_flexio3spi0: pinmux_flexio3spi0 {
		group0 {
			pinmux =
				<&iomuxc_gpio_ad_b0_09_gpio1_io09>, /* cs */
				<&iomuxc_gpio_ad_b0_10_gpio1_io10>, /* cs */
				<&iomuxc_gpio_ad_b1_10_flexio3_flexio10>, /* sck */
				<&iomuxc_gpio_ad_b1_11_flexio3_flexio11>, /* sdo */
				<&iomuxc_gpio_ad_b1_04_flexio3_flexio04>; /* sdi */
			drive-strength = "r0-6";
			slew-rate = "slow";
			nxp,speed = "150-mhz";
		};
	};
	pinmux_flexio3spi1: pinmux_flexio3spi1 {
		group0 {
			pinmux =
				<&iomuxc_gpio_ad_b0_02_gpio1_io02>, /* cs */
				<&iomuxc_gpio_ad_b0_03_gpio1_io03>, /* cs */
				<&iomuxc_gpio_ad_b1_05_flexio3_flexio05>, /* sck */
				<&iomuxc_gpio_ad_b1_01_flexio3_flexio01>, /* sdo */
				<&iomuxc_gpio_ad_b1_00_flexio3_flexio00>; /* sdi */
			drive-strength = "r0-6";
			slew-rate = "slow";
			nxp,speed = "150-mhz";
		};
	};
	pinmux_flexio3spi2: pinmux_flexio3spi2 {
		group0 {
			pinmux =
				<&iomuxc_gpio_ad_b0_11_gpio1_io11>, /* cs */
				<&iomuxc_gpio_ad_b1_07_flexio3_flexio07>, /* sck */
				<&iomuxc_gpio_ad_b1_06_flexio3_flexio06>, /* sdo */
				<&iomuxc_gpio_ad_b1_08_flexio3_flexio08>; /* sdi */
			drive-strength = "r0-6";
			slew-rate = "slow";
			nxp,speed = "150-mhz";
		};
	};
	pinmux_flexio3spi3: pinmux_flexio3spi3 {
		group0 {
			pinmux =
				<&iomuxc_gpio_ad_b1_00_gpio1_io16>, /* cs */
				<&iomuxc_gpio_ad_b1_02_flexio3_flexio02>, /* sck */
				<&iomuxc_gpio_ad_b1_03_flexio3_flexio03>, /* sdo */
				<&iomuxc_gpio_ad_b1_15_flexio3_flexio15>; /* sdi */
			drive-strength = "r0-6";
			slew-rate = "slow";
			nxp,speed = "150-mhz";
		};
	};
};

&flexio3 {
	status = "okay";
	flexio3_spi0: flexio3_spi0 {
		compatible = "nxp,imx-flexio-spi";
		status = "okay";
		#address-cells = <1>;
		#size-cells = <0>;
		cs-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>,
				<&gpio1 10 GPIO_ACTIVE_LOW>;
		sdo-pin = <11>;
		sdi-pin = <4>; 
		sck-pin = <10>;
		pinctrl-0 = <&pinmux_flexio3spi0>;
		pinctrl-names = "default";
		flexio3_spi0_device0: flexio-spi-device@0 {
			compatible = "vnd,spi-device";
			status = "okay";
			reg = <0>;
			spi-max-frequency = <7500000>;
			frame-format = <0>;
		};
		flexio3_spi0_device1: flexio-spi-device@1 {
			compatible = "vnd,spi-device";
			status = "disabled";
			reg = <1>;
			spi-max-frequency = <100000>;
			frame-format = <0>;
		};
	};
	flexio3_spi1: flexio3_spi1 {
		compatible = "nxp,imx-flexio-spi";
		status = "okay";
		#address-cells = <1>;
		#size-cells = <0>;
		cs-gpios = <&gpio1 2 GPIO_ACTIVE_LOW>,
				<&gpio1 3 GPIO_ACTIVE_LOW>;
		sdo-pin = <1>;
		sdi-pin = <0>; 
		sck-pin = <5>;
		pinctrl-0 = <&pinmux_flexio3spi1>;
		pinctrl-names = "default";
		flexio3_spi1_device0: flexio-spi-device@0 {
			compatible = "vnd,spi-device";
			status = "disabled";
			reg = <0>;
			spi-max-frequency = <1000000>;
			frame-format = <0>;
		};
		flexio3_spi1_device1: flexio-spi-device@1 {
			compatible = "vnd,spi-device";
			status = "okay";
			reg = <1>;
			spi-max-frequency = <7500000>;
			frame-format = <0>;
		};
	};
	flexio3_spi2: flexio3_spi2 {
		compatible = "nxp,imx-flexio-spi";
		status = "okay";
		#address-cells = <1>;
		#size-cells = <0>;
		cs-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
		sdo-pin = <6>;
		sdi-pin = <8>; 
		sck-pin = <7>;
		pinctrl-0 = <&pinmux_flexio3spi2>;
		pinctrl-names = "default";
		flexio3_spi2_device0: flexio-spi-device@0 {
			compatible = "vnd,spi-device";
			status = "okay";
			reg = <0>;
			spi-max-frequency = <7500000>;
			frame-format = <0>;
		};
	};
	flexio3_spi3: flexio3_spi3 {
		compatible = "nxp,imx-flexio-spi";
		status = "okay";
		#address-cells = <1>;
		#size-cells = <0>;
		cs-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;
		sdo-pin = <3>;
		sdi-pin = <15>; 
		sck-pin = <2>;
		pinctrl-0 = <&pinmux_flexio3spi3>;
		pinctrl-names = "default";
		flexio3_spi3_device0: flexio-spi-device@0 {
			compatible = "vnd,spi-device";
			status = "okay";
			reg = <0>;
			spi-max-frequency = <7500000>;
			frame-format = <0>;
		};
	};
};

&lpspi3 {
	status = "disabled";
};

Signed-off-by: Mikhail Siomin victorovich.01@mail.ru

@MikhailSiomin
Copy link
Contributor Author

MikhailSiomin commented Jan 12, 2023

The driver will not pass the tests until the drivers of HAL are enabled (zephyrproject-rtos/hal_nxp#205).
Also, the driver will not pass the tests if they are run on the board, because tests expect SPI dummy data to be 0x00 (zephyrproject-rtos/hal_nxp#223).
You can run the driver tests yourself with the following command (the serial port may be different):
python.exe .\scripts\twister -vvv --short-build-path --tag flexio -p mimxrt1064_evk -T tests/drivers/spi/spi_loopback --device-testing --device-serial COM4 -X spi_loopback

# SPDX-License-Identifier: Apache-2.0

config SPI_MCUX_FLEXIO
bool "MCUX FlexIO SPI driver"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this missing default y

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danieldegrasse, Is it worth making this amendment to this PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes- thank you for adding it. We should change the dependency here to be on DT_HAS_NXP_FLEXIO_SPI_ENABLED though

drivers.spi.mcux_flexio_spi.loopback:
extra_args: EXTRA_DTC_OVERLAY_FILE="overlay-mcux-flexio-spi.overlay"
extra_configs:
- CONFIG_SPI_MCUX_FLEXIO=y
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not needed if we default y the driver Kconfig

danieldegrasse
danieldegrasse previously approved these changes Feb 23, 2024
danieldegrasse
danieldegrasse previously approved these changes Mar 4, 2024
@danieldegrasse
Copy link
Collaborator

@MikhailSiomin can you take a look at the twister failures?

@MikhailSiomin
Copy link
Contributor Author

@danieldegrasse, It seems to me that failed tests are not related to changes in the PR.

Added description of flexio peripherals for i.MX rt10xx
and kinetis ke1xf series.

Signed-off-by: Mikhail Siomin <victorovich.01@mail.ru>
Added clock control support for flexIO for i.MX series.

Signed-off-by: Mikhail Siomin <victorovich.01@mail.ru>
@MikhailSiomin
Copy link
Contributor Author

Resolved merge conflicts.

danieldegrasse
danieldegrasse previously approved these changes Mar 11, 2024
mmahadevan108
mmahadevan108 previously approved these changes Mar 11, 2024
@mmahadevan108
Copy link
Collaborator

@MikhailSiomin , thank your contribution. The HAL PR has been merged. Can you please update the Zephyr side.

Added FlexIO driver that distributes hardware resources
between interfaces using them.

Signed-off-by: Mikhail Siomin <victorovich.01@mail.ru>
Added SPI driver using FlexIO.

Signed-off-by: Mikhail Siomin <victorovich.01@mail.ru>
Added FlexIO SPI test. Overlay in the tests for mimxrt1064_evk
board only.

Signed-off-by: Mikhail Siomin <victorovich.01@mail.ru>
@zephyrbot zephyrbot removed the DNM This PR should not be merged (Do Not Merge) label Mar 11, 2024
@MikhailSiomin
Copy link
Contributor Author

Thank you all for the work done on the PR.

@aescolar aescolar merged commit 0157a89 into zephyrproject-rtos:main Mar 12, 2024
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

mcux: flexio: Add generic MCUX FlexIO driver.