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.

DM365: GPIO not getting toggled

We are trying to toggle GPIO15 with our custom DM365 EVM with OV5642
sensor.  GPIO15 is sensor reset pin for OV5642.

It is observed that pin is not getting toggled.  We tried in u-boot as well as kernel level.  Please find
the sequence followed to toggle GPIO15

Generic Sequence:
---------------------
 1. Pin muxing
 2. Set the gpio direction
 3. toggle GPIO

u-boot 1.3.4:
-------------
At u-boot, we tried the following sequence to toggle GPIO15
 1. Mux setting
      a. Read the value
          md 0x01C4000c 0x1
      b. Write the value
          mw 0x01C4000c <above readvalue & 0xffffbfff>

 2. Setting direction as output
      md 0x01C67010 0x1
      mw 0x01C67010 <readval & 0xffff7fff>

 3. Drive High
      md 0x01C67018 0x1
      mw 0x01C67018 <readval | 0x00008000>

 4. Drive Low
      md 0x01C6701C 0x1
      mw 0x01C6701C <readval | 0x00008000>

----------------------- u-boot log - starts -------------------

DM365 EVM :>
DM365 EVM :>
DM365 EVM :>md 0x01c4000c 1
01c4000c: 015affff    ..Z.
DM365 EVM :>mw 0x01c4000c 015abfff
DM365 EVM :>md 0x01c4000c 1
01c4000c: 015abfff    ..Z.
DM365 EVM :>
DM365 EVM :>
DM365 EVM :>md 0x01c67010 1
01c67010: 00000000    ....
DM365 EVM :>
DM365 EVM :>
DM365 EVM :>md 0x01c67018 1
01c67018: 00100000    ....
DM365 EVM :>mw 0x01c67018 00108000
DM365 EVM :>md 0x01c67018 1
01c67018: 00108000    ....
DM365 EVM :>
DM365 EVM :>
DM365 EVM :>
DM365 EVM :>md 0x01c6701c 1
01c6701c: 00108000    ....
DM365 EVM :>mw 0x01c6701c 00008000
DM365 EVM :>md 0x01c6701c 1
01c6701c: 00100000    ....
DM365 EVM :>md 0x01c67018 1
01c67018: 00108000    ....
DM365 EVM :>
DM365 EVM :>md 0x01c67014 1
01c67014: 00108000    ....
DM365 EVM :>
DM365 EVM :>mw 0x01c67014 00100000
DM365 EVM :>md 0x01c67014 1
01c67014: 00100000    ....
DM365 EVM :>
DM365 EVM :>
DM365 EVM :>mw 0x01c67014 001008000
DM365 EVM :>md 0x01c67014 1
01c67014: 01008000
DM365 EVM :>


----------------------- u-boot-log - ends ---------------------

Kernel 2.6.32.17-davinci1:
-------------------------
The following code is written to toggle the GPIO15

         /* mux settings for GIO15 */
         /* GPIO 15 */
         value = __raw_readl(muxbase + 0x0000000c);
         value = value & 0xffffbfff;
         __raw_writel(value, muxbase);

         /* gpio direction set for 15 */
         value = __raw_readl(gpiobase + 0x00000010);
         value = value & 0xffff7fff;
         __raw_writel(value, gpiobase + 0x00000010);


         /* GPIO15 : Drive Low */
         value = __raw_readl(gpiobase + 0x0000001c);
         value = value & 0x00008000;
         __raw_writel(value, gpiobase + 0x0000001c);

         mdelay(500);

         /* GPIO15 : Drive High */
         value = __raw_readl(gpiobase + 0x00000018);
         value = value & 0x00008000;
         __raw_writel(value, gpiobase + 0x00000018);

 Even though, we are making high, GPIO15 always in Low state.  Please let
 us know that the above sequences are correct?  Are we missing anything
 before pinmuxing?

  • IIRC, the DM365.c file contains a list of GPIO configurations.  IMO this list should be in the board specific file because it's tied to the design of the board.  You need to make sure that list is set up the way you need to configure your pin, and make sure that the board specific file isn't changing your pin settings.  Then you can put your setting in the board specific file (i.e. board-dm365evm.c).

    I had to do this because the UART1 pins had the wrogn assignment for my board.

    John A

  •  Thanks for your quick reply.  In the gpio toggling code, taken care pin muxing, apart from the specific code to set pin muxing  in dm365.c file 

    "MUX_CFG(DM365,  GPIO15,         3,   14,    1,    0,     false)" 

    defined macro in mux.h (DM365_GPIO15)

    and in board-dm365-evm.c

            davinci_cfg_reg(DM365_GPIO15);
            gpio_request(15, "sensor_reset");

    Apart from the above, my code exclusively setting the mode to GPIO, just before driving GPIO15

             /* mux settings for GIO15 */
             /* GPIO 15 */
             value = __raw_readl(muxbase + 0x0000000c);
             value = value & 0xffffbfff;
             __raw_writel(value, muxbase);

    I am setting and driving GPIO in board sepecific file (board-dm365-evm.c).  Please let me know where went wrong?  am I missing any sequence?