How to set a GPIO PULLUP on IMX6ULL

Dear guys,
I want to compute a motor rpm.

For thi reason I want to use a PIN like Motor speed feedback input and to read the PIN state.

I want to set this PIN as be a PULL-UP resistor.

Is it right to compile a tree with the property PAD_CTRL_HYS_PU and I can to use i2c1 to monitor this PIN?
Or is there an better way?

Moreover I can to get idea from example 4 of this page Basic GPIO usage - Colibri Evaluation Board - Colibri iMX6

Sure you can set some pin as GPIO/input and select proper pull up value
But how its related to I2C? Could you clarify?

Dear @alex.tx,

thank for your replay.

I read your link and maybe I understood what I need to do.

I got confused and i2C doesn’t have much to do with it.

I want to use the PIN 28 to read the rpm and I need to set this PIN how input pull-up.
The PIN:
MX6UL_PAD_NAND_DQS__GPIO4_IO16

on the default tree this PIN is associated to PWN5 (enabled) and to Touchgpios (disabled):

pinctrl_pwm5: pwm5grp {
                    fsl,pins = <
                            MX6UL_PAD_NAND_DQS__PWM5_OUT    0x00079
                    >;
            };

and

     &iomuxc {
             imx6ull-eval-v3 {
                      pinctrl_gpiotouch: touchgpios {
                           fsl,pins = <
                            MX6UL_PAD_NAND_DQS__GPIO4_IO16          0x74
                            MX6UL_PAD_ENET1_TX_EN__GPIO2_IO05       0x14
                          >;
                      };
                };
          };

In my application the touch is not necessary so I can to use it and the touch is disabled by default.

I think to disable the PWN5 in order to use this PIN and I can add it on other functionality.

Could you suggest where could I insert this PIN for my purpose?

Could you tell my the right the bitwise definition for the last cell of the definition in order to use the PIN how PULL UP resistor of 22KOhm, I understood to change the bit 15-14 with 11, but the entire value is not clear for me.

I don’t need to change anythink on the file imx6ul-pinfunc.h

           #define MX6UL_PAD_NAND_CE1_B__GPIO4_IO14                0x01b0 0x043c 0x0000 5 0

Or Am I wrong?

Thank you for your support.

Best regards

Matteo

Hi @Matte

I think to disable the PWN5 in order to use this PIN and I can add it on other functionality.
Could you suggest where could I insert this PIN for my purpose?

It depends what exactly do you want to do? How do you measure the Motorspeed?

Could you tell my the right the bitwise definition for the last cell of the definition in order to use the PIN how PULL UP resistor of 22KOhm, I understood to change the bit 15-14 with 11, but the entire value is not clear for me.

You just need to change the values in binary to hex format? What exactly you did not understand?

I don’t need to change anythink on the file imx6ul-pinfunc.h

You never change the values in imx6ul-pinfunc.h unless there is a bug.

Thank you for your support.

You are welcome.

Best regards,
Jaski

Dear @jaski.tx,
In order to compute RPM I want to count the PIN value on a finite time.

For this reason I need to set a PIN as input and this PIN must be a pull up resistor of 22 KOhm.

I selected the PIN 28 and I think that pwn4 is not necessary for this goal.

if I’m not wrong I need to configure the tree with this setting. Buy I don’t kown how to Do It.
Could you help me?
Best regards
Matteo

Hi @Matte,

You need to check the pinmux details of the iMX6ULL as presented here.

For the pin you want to use, you then set the combination in the given sequence.

Best regards,
André Curvello

Dear guys,
thank you for the support.
I compute the number associated to my functionality:

   16    --> 1
  15-14 --> 11
  13    --> 1
  12    --> 1
  11 --> 0
   7-6 --> 00
   5-3 --> 000
   0 --> 1

So the number is 0xf81 = 0b111110000001

Where can I insert the following line on the tree:

MX6UL_PAD_NAND_DQS__GPIO4_IO16 0xF81

Best regards
Matteo

Like in the section you presented above, you can do something like this:

  &iomuxc {
      pinctrl-names = "default";  
      
      imx6ull-eval-v3 {
          pinctrl_additionalgpio: additionalgpios {
              fsl,pins = <
                             MX6UL_PAD_NAND_DQS__GPIO4_IO16 0xF81
                             >;
           };
      };
 };

Of course, adjusting it according to other changes you may have in the same section, ok?

See if that helps!

Best regards,
André Curvello

Dear @andrecurvello.tx,

I added some other PINS on additionalgpios section.

Are there any line commands to understand if all PINS are setted right?

Best regards
Matteo

Hi @Matte,

You can check them by executing the following command:

cat /sys/kernel/debug/gpio

That will indicate its configuration.

But if you require deeper analysis, then the Device-tree is the only source.

Best regards,
André Curvello