zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.49k stars 6.42k forks source link

drivers: xbar: Dedicated xbar driver #55242

Open jeppenodgaard opened 1 year ago

jeppenodgaard commented 1 year ago

Is your enhancement proposal related to a problem? Please describe.

Some features requires usage of the crossbar (xbar) on some nxp processors e.g. mimxrt1050. Currently the quadrature decoder driver configures the xbar and xbar connections.

Describe the solution you'd like

I would like to define the xbar connection in the pinctrl and also relate it to a group. For example:

mimxrt1050_evk-pinctrl.dtsi

    pinmux_qdec1: pinmux_qdec1 {
        group0 {
            pinmux = <&iomuxc_gpio_ad_b0_09_xbar1_xbar_in21>,
                <&iomuxc_gpio_ad_b0_10_xbar1_xbar_in22>;
            xbar-connections =
                /* kXBARA1_InputIomuxXbarIn21 <-> kXBARA1_OutputEnc1PhaseAInput */
                <&xbar1 (21|0x100) (66|0x100)>,
                /* kXBARA1_InputIomuxXbarIn22 <-> kXBARA1_OutputEnc1PhaseBInput */
                <&xbar1 (22|0x100) (67|0x100)>;
            ...
        };
    };

    pinmux_qdec1_single_phase: pinmux_qdec1_single_phase {
        group0 {
            pinmux = <&iomuxc_gpio_ad_b0_09_xbar1_xbar_in21>;
            xbar-connections =
                /* kXBARA1_InputIomuxXbarIn21 <-> kXBARA1_OutputEnc1PhaseAInput */
                <&xbar1 (21|0x100) (66|0x100)>,
                /* kXBARA1_InputLogicLow <-> kXBARA1_OutputEnc1PhaseBInput */
                <&xbar1 (0|0x100) (67|0x100)>;
            ...
        };
    };

mimxrt1050_evk.overlay:

&qdec1 {
    status = "okay";
    pinctrl-0 = <&pinmux_qdec1>;
    pinctrl-1 = <&pinmux_qdec1_single_phase>;
    pinctrl-names = "default", "single-phase";
    counts-per-revolution = < 120 >;
};

&xbar1 {
    status = "okay";
};

Additional context https://github.com/zephyrproject-rtos/zephyr/pull/53068#pullrequestreview-1236278435

henrikbrixandersen commented 1 year ago

I am unsure if pinctrl is the best way to configure internal crossbars. How does Linux handle similar configuration? CC: @gmarull, @galak

gmarull commented 1 year ago

I'm not familiar with this peripheral, some more details would be useful to provide some guidance/ideas. But if pin related, pinctrl driver sounds like a good candidate.

jeppenodgaard commented 1 year ago

@gmarull I was able to find this describtion from NXP. I think it describes the XBAR pretty well:

XBAR is a module intended to provide a flexible crossbar switch function that allows any input (typically from external GPIO or internal module outputs) to be connected to any output (typically to external GPIO or internal module inputs) under user control.

zephyrbot commented 7 months ago

Hi @dleach02, @dleach02,

This issue, marked as an Enhancement, was opened a while ago and did not get any traction. It was just assigned to you based on the labels. If you don't consider yourself the right person to address this issue, please re-assing it to the right person.

Please take a moment to review if the issue is still relevant to the project. If it is, please provide feedback and direction on how to move forward. If it is not, has already been addressed, is a duplicate, or is no longer relevant, please close it with a short comment explaining the reason.

@jeppenodgaard you are also encouraged to help moving this issue forward by providing additional information and confirming this request/issue is still relevant to you.

Thanks!