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.

How to use gpio_set_var() to control gp1[13] of DM8168 in kernel 2.6.37?

I want to use gpio_set_var() in kernel to control gp1[0:31] in kernel. But it seems gp1[12] is no equal 32 + 12. How post gpio_num to gpio api in kernel when use gp1?  

gpio_direction_output(num, 1); 

gpio_set_value(num, val);

  • I use RDK reference board.  I use the kernel in rdk 01.01.00.04. I want to set alarm 1 ouput 1 or 0. In schematic, this is gp1[12]. But when I use gpio_set_value(12 + 32, 0/1), the gpio do not do the action.

    Besides, I enabled gpio sysfs. Use gpio sysfs also can not triggle the gp1[12]. I want to know:

    (1) The gp1[x] is not (32 + x) in kernel driver?

    (2) Before I use [root@/sys/kernel/debug]# ls
    asoc      bdi       clock     gpio      kprobes   memblock  musb      omap_mux  regdump   testmode  usb       vram
    [root@/sys/kernel/debug]# cat gpio
    GPIOs 0-31, gpio:
     gpio-0   (vgpio 0             ) in  lo
     gpio-1   (vgpio 1             ) in  lo
     gpio-2   (vgpio 2             ) in  lo
     gpio-3   (vgpio 3             ) in  lo
     gpio-16  (eeprom sd0          ) out lo
     gpio-17  (eeprom sdi          ) in  lo
     gpio-18  (eeprom clk          ) out hi
     gpio-19  (eeprom cs           ) out lo

    gpio_direction_output(num, 1);

    gpio_set_value(num, val);

    What should  I check firstly? Thanks.

     

    GPIOs 32-63, gpio:
     gpio-44  (sysfs               ) out lo
    [root@/sys/kernel/debug]# echo 1>/sys/class/gpio/gpio44/value
    [root@/sys/kernel/debug]# cat gpio
    GPIOs 0-31, gpio:
     gpio-0   (vgpio 0             ) in  lo
     gpio-1   (vgpio 1             ) in  lo
     gpio-2   (vgpio 2             ) in  lo
     gpio-3   (vgpio 3             ) in  lo
     gpio-16  (eeprom sd0          ) out lo
     gpio-17  (eeprom sdi          ) in  lo
     gpio-18  (eeprom clk          ) out hi
     gpio-19  (eeprom cs           ) out lo

    GPIOs 32-63, gpio:
     gpio-44  (sysfs               ) out lo
    [root@/sys/kernel/debug]#

  • Hi Yaming Deng,

    Could you please follow this post

    http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/p/130602/486897.aspx

    Regards

    Anilkumar

    --------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.
    --------------------------------------------------------------------------------------------------------

  • The problem is the kernel gpio api gpio_free() .

    gpio_free()

      |

      \----- omap_gpio_free()

            |

            \----- _reset_gpio() ==> this will set gpio as input. That maybe the root cause.

    So, If you want to set the gpio output, during the period,  you can not  call gpio_free(). I think it is reasonable for power sensitive product such as consumptive electronicy.

    But others, it maybe not good for use.

  • Hi Yaming Deng,

    While setting the gpio output, why are you touching gpio_free()?

    Regards

    Anilkumar

    ---------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    ---------------------------------------------------------------------------------------------------------

  • Hi Anilkumar,

    We add a char driver of gpio for our product restore button, led, alarm in, alarm out and soon on.

    We use kernel gpio lib api.

    (1) gpio_request();

    (2) gpio_directxx()

    (3) gpio_set/get_value()

    (4) gpio_free()

     That is why I touch the gpio_free(). Do you think gpio_free() should change the last status of gpio? Do you have a better idea? Thanks.

    Yaming

  • Hi Yaming,

    These are the steps you have to follow for GPIO to functional in expected behaviour.

    1. gpio_request(<gpio_number>, "label_name")

    Ex: gpio_request(20, "test_gpio");

    2. Write some thing to gpio pin

    gpio_direction_output(<gpio_number>, 0 or 1);

     Ex: gpio_direction_output(20, 0);

    3. Read data from gpio pin

    value = gpio_get_value(<gpio_number>);

    Ex: value = gpio_get_value(20);

    4. Once you done with your operation then call

    gpio_free(<gpio_number>);

    Ex: gpio_free(20);

    In your case you should not call gpio_free() API. If you do above steps sequentially then "set value become default value after 4th step".

    Regards

    Anilkumar

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    --------------------------------------------------------------------------------------------------------