Twitter E-mail RSS
formats

How should I define GPIOs

Identifying GPIO’s

The i.MX23 has four banks of pins. Three of them can serve as GPIOs banks numbered as 0,1, and 2. Each bank has 32 pins numbered as 0,1,…,31. Kernel numbers are calculated as:

<number> = <pin_number_on_bank> + <bank_number> * 32

For example GPIO 91 correspond to pin 27 on 2 bank (91 = 27 + 2 * 32). Pin multiplexing and GPIO definition’s are documented on kernel file: Documentation/devicetree/bindings/pinctrl/fsl,mxs-pinctrl.txt

GPIO definition’s are in format: <pin_name>__GPIO_<bank>_<pin_number_on_bank> So looking on file for something like <pin_name>__GPIO_2_27.

Searching under section:

Valid values for i.MX23 pinmux-id:

pinmux id              —— —

we find:

MX23_PAD_GPMI_CE1N__GPIO_2_27 0x21b3

Pin MX23_PAD_GPMI_CE1N correspond to kernel GPIO’s number 91 and it’s pinmux id is 0x21b3. In order to use this pin as GPIO needed to pass pinmux id on device tree file imx23-olinuxino.dts.

Add GPIO id on DTS file

Pin control is defined in following section:

            pinctrl@80018000 {
pinctrl-names = “default”;
pinctrl-0 = <&hog_pins_a>;

hog_pins_a: hog@0 {
reg = <0>;
fsl,pinmux-ids = <
0x0113 /* MX23_PAD_GPMI_ALE__GPIO_0_17 */
>;
fsl,drive-strength = <0>;
fsl,voltage = <1>;
fsl,pull-up = <0>;
};

led_pin_gpio2_1: led_gpio2_1@0 {
reg = <0>;
fsl,pinmux-ids = <
0x2013 /* MX23_PAD_SSP1_DETECT__GPIO_2_1 */
>;
fsl,drive-strength = <0>;
fsl,voltage = <1>;
fsl,pull-up = <0>;
};
};

Add following node on pinctrl section:

pinctrl@80018000 {
pinctrl-names = “default”;
pinctrl-0 = <&hog_pins_a>;

hog_pins_a: hog@0 {
reg = <0>;
fsl,pinmux-ids = <
0x0113 /* MX23_PAD_GPMI_ALE__GPIO_0_17 */
>;
fsl,drive-strength = <0>;
fsl,voltage = <1>;
fsl,pull-up = <0>;
};

led_pin_gpio2_1: led_gpio2_1@0 {
reg = <0>;
fsl,pinmux-ids = <
0x2013 /* MX23_PAD_SSP1_DETECT__GPIO_2_1 */
>;
fsl,drive-strength = <0>;
fsl,voltage = <1>;
fsl,pull-up = <0>;
};

                    my_gpio2_27: led_gpio2_27@0 {
                    reg = <0>;
                    fsl,pinmux-ids = <
                        0x21b3   /* MX23_PAD_GPMI_CE1N__GPIO_2_27 */
                    >;
                    fsl,drive-strength = <0>;
                    fsl,voltage = <1>;
                    fsl,pull-up = <0>;
                };
};

Last think to do is compile imx23-olinuxino.dts and join to kernel image using bootlets Building a kernel 3.12-rc2 for the imx23-olinuxino or a bootloader u-boot bootloader for imx23-olinuxino board.

Creative Commons License
This work by http://g-lab.ca is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at http://g-lab.ca.

Home imx23-olinuxino kernel 3.x gpio How should I define GPIOs