This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-AM62A-LP: Two questions about GPIO function?

Part Number: SK-AM62A-LP

Tool/software:

We are using AM62A SoC to control out dToF sensor, and the GPIO0_60 is used to reset our dToF sensor. Now I have two questions about the pin, would you please help to check and help me?

Q1: What is the default level for GPIO0_60, which document can I check for this?  I tried to add the following line in k3-am62a7-sk.dts to set this pin to LOW after power-on, but our HW engineer said the pin will keep HIGH until after 12 seconds after power-on, is there any other method to setup this pin to LOW more earlier?

	main_ads6311_pins_default: main-ads6311-pins-default {
		pinctrl-single,pins = <
			AM62AX_IOPAD(0x00f0, PIN_INPUT_PULLDOWN, 7) /* (Y21) VOUT0_DATA14.GPIO0_59 */
			AM62AX_IOPAD(0x00f4, PIN_OUTPUT_PULLDOWN, 7) /* (Y22) VOUT0_DATA15.GPIO0_60 */
		>;
	};



	ads6311_spi@0 {
		status = "okay";
		reg = <0>;
		compatible = "adaps,ads6311spi";
		clocks = <&clk_ads6311_fixed>;
		clock-names = "xclk";
		spi-max-frequency = <15000000>;
		pinctrl-names = "default";
		pinctrl-0 = <&main_ads6311_pins_default>;
		interrupt-parent = <&main_gpio0>;
		interrupts = <59 IRQ_TYPE_LEVEL_HIGH>;
		reset-gpios = <&main_gpio0 60 GPIO_ACTIVE_LOW>;
		pwms = <&epwm1 1 100000 0>;
		port {
			ads6311_spi_out: endpoint {
				remote-endpoint = <&csi2rx0_in_sensor>;
				/* link-frequencies = /bits/ 64 <456000000>; */
				clock-lanes = <0>;
				data-lanes = <1 2 3 4>;
			};
		};
	};

Q2: In my Linux driver code, I tried to call 'gpiod_set_value_cansleep(sensor->reset_gpio, 1);' and 'gpiod_set_value_cansleep(sensor->reset_gpio, 0);' to setup this pin to HIGH or LOW, then we use a multimeter to measure the voltage level of this GPIO pin, the results are matched with our expectation. But from the software point of the view, I tried to call val = gpiod_get_value(sensor->reset_gpio) to check the result, I always got the value 1 for both cases. Please help to check the root cause and provide a patch.

BTW, I'm using Linux SDK 9.1 (ti-processor-sdk-linux-edgeai-am62axx-evm-09_01_00_07-Linux-x86-Install.bin) now.

Thanks and Best Regards,

David

  • Hi David,

    What is the default level for GPIO0_60

    When the GPIO is not initialized yet (not High or Low), it is in a floating state which has an undefined voltage. From my own measurements, its about 110-120mV. I haven't found a document that explicitly states this.

    is there any other method to setup this pin to LOW more earlier?

    You can try using the U-Boot commands for GPIOs, but I'm not sure if it meets your requirements: https://docs.u-boot.org/en/latest/usage/cmd/gpio.html

    I will get back to you on item 2. I'm not familiar with the libgpiod API.

    Thanks,

    Anshu

  • I will get back to you on item 2. I'm not familiar with the libgpiod API.

    Hi Anshu,

       Is there any update about my question 2?  Would you please help re-assign this ticket to any other proper engineer?

    Thanks and best Regards,

    David

  • Hi David,

    Can you provide any more details? You can also reach out to the Linux community regarding the libgpiod API.

    Thanks,

    Anshu

  • Can you provide any more details? You can also reach out to the Linux community regarding the libgpiod API.

    Hi Anshu,

        I'm sorry I didn't let the problem clear. Now I'm adding some information for this issue.

        From my test, it seems there is some problem on the GPIO controller driver code (board-support/ti-linux-kernel-6.1.46+gitAUTOINC+247b2535b2-g247b2535b2/drivers/gpio/gpio-davinci.c), it is NOT related with libgpiod.

        TEST GPIO:  gpio0_60  (main_gpio0 60)

        My test steps as below:

         step 1:

           call gpiod_get_value_cansleep(gpiodesc) to get the current value, and printk it in dump_a_gpio().

         step 2:

           call gpiod_set_value_cansleep(sensor->reset_gpio, val) to set it to 0.

         step 3:

           call gpiod_get_value_cansleep(gpiodesc) to get the current value, and printk it in dump_a_gpio().

         step 4:

           call gpiod_set_value_cansleep(sensor->reset_gpio, val) to set it to 1.

         step 3:

           call gpiod_get_value_cansleep(gpiodesc) to get the current value, and printk it in dump_a_gpio().

        I modified a little code in gpio-davinci.c to trace my test result as blow:

         From my tested log (as below), you can see the get value from davinci_gpio_get() always return a same value (0). That is my raised problem. Would you please help to check the reason and try to fix it? I guess you can reproduce this issue with your Am62ax-sk development board.

    Thanks and Best Regards,

    David

  • Hi David,


    Thanks for the explanation.

    It looks like when the get and set functions are called, the direction of the GPIO gets changed. So when set function is called, the GPIO direction is output. Then get function is called afterwards, the direction of the GPIO changes to input.

    Try to print the direction parameter if possible to check this.

    Thanks,

    Anshu

  • Try to print the direction parameter if possible to check this.

    Hi Anshu,

        I continued to modify a little code as below, then I saw the output as below

    static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset)
    {
    struct davinci_gpio_controller *d = gpiochip_get_data(chip);
    struct davinci_gpio_regs __iomem *g;
    int bank = offset / 32;
    int ret = -1;

    g = d->regs[bank];

    ret = !!(__gpio_mask(offset) & readl_relaxed(&g->in_data));
    printk(KERN_ERR "-=-GPIO_DBG---davinci_gpio_get(%p, %d) return value:%d, __gpio_mask(offset):0x%x, dir:0x%x, in_data: 0x%x, out_data: 0x%x-------\n",
    chip, offset, ret, __gpio_mask(offset), readl_relaxed(&g->dir), readl_relaxed(&g->in_data), readl_relaxed(&g->out_data));
    return ret;
    }

    It looks the dir is right (output) for gpio0_60.

    Thanks

    David

  • Hi Anshu,

        According to the log at the previous comment, I guess there is some bug in davinci_gpio_get(), so I tried to modify it as below, now from my test, it looks correct.  Would you please help me double confirm whether my modification is real CORRECT from your GPIO controller driver's owner (ie. the author of gpio-davinci.c)

    Thanks and best Regards,

    David

  • Hi David,

    Sorry for the delayed response. I've forwarded this thread to someone else who might be able to help.

    Please note that I will be out of office for the next few weeks.

    Thanks,

    Anshu

  • Hi David,

    The feedback I received from discussing internally was the following:

    "Even if the gpio is to be driven as input the pad configuration aka pin much should always be Pin_input in DTS. Basically bit18 of the pad configuration register should be set. That can help physically toggle the gpio as per need."

    Thanks,

    Anshu