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.

J5-Eco: How to read and write gpio in ti811x

I need to read and write few gpio pins in Bank0, Bank1, Bank2 and Bank3 to enable Ethernet Phy chip from uboot on my custom board. Since there is no GPIO functions implemented in uboot for ti81xx, I tried to use __readl and __writel function to read and write. But code hangs while reading OMAP4_GPIO_OE register. Can some one help me to fix this issue. DO I need to enable clock for GPIOs. Below is my code for your reference. I have added below code in uboot/board/ti/ti811x/evm.c

/********************Console message******************/

Configuring PAD58_CNTRL for E0_RESET_N                    

                     
 Setting pin as: output                                                        
Reading register: 48032134 
/*************************************************************/

/* GPIO Base address */
#define GPIO0_BASE            0x48032000
#define GPIO1_BASE            0x4804C000
//*******
#define GPIO2_BASE            0x481AC000
#define GPIO3_BASE            0x481AE000
#define OMAP4_GPIO_OE            0x0134
#define OMAP4_GPIO_DATAIN        0x0138
#define OMAP4_GPIO_DATAOUT        0x013c
#define OMAP4_GPIO_CLEARDATAOUT        0x0190
#define OMAP4_GPIO_SETDATAOUT        0x0194

#define INPUT    1
#define OUTPUT    0
#define PHY_RESET_GPIO0_PIN    28
#define PHY_EN_GPIO3_PIN    23
#define PHY_WAKE_GPIO3_PIN    16
static void set_pin_direction(unsigned int bank, unsigned int gpio, unsigned int is_input)
{
    printf("Setting pin as: %s\n", ((is_input==INPUT)? "input":"output"));
    unsigned int regAddr=bank+OMAP4_GPIO_OE;
    unsigned int value = 0;
    printf("Reading register: %x\n",regAddr);
    value = __raw_readl(regAddr);
    if (is_input)
        value |= 1 << gpio;
    else
        value &= ~(1 << gpio);
    printf("writing register: %x with %x\n",regAddr, value);
    __raw_writel(value, regAddr);
}

static void set_pin_value(unsigned int bank, unsigned int gpio, unsigned int value)
{
    printf("Setting pin %d with %d\n", gpio, value);
    unsigned int regAddr=bank;
    if (value)
        regAddr += OMAP4_GPIO_SETDATAOUT;
    else
        regAddr += OMAP4_GPIO_CLEARDATAOUT;
    value = 1 << gpio;
    __raw_writel(value, regAddr);
}

called below line in my board_init

val = PAD58_CNTRL; /*GP0[28]E0_RESET_N--OUT*/ //set to 1
PAD58_CNTRL = (volatile unsigned int) (BIT(18) |  /*BIT(17) |*/ BIT(7));
set_pin_direction(GPIO0_BASE, PHY_RESET_GPIO0_PIN, OUTPUT);
set_pin_value(GPIO0_BASE, PHY_RESET_GPIO0_PIN, 0);