/*----------------------------------------------------------------------------- | Function :S32 gpio_pin_init(U16 pin_num, U8 in_out) +------------------------------------------------------------------------------ | Description :This function is to initialize the gpio pin as input or output. | | Parameters :pin_num | - gpio pin that needs to be configured. | | in_out | - specifies whether the pin is to be configured as an | input or output. | | Returns : DAL_SUCCESS, if the initialization is successful. | else DAL_ERROR. +-----------------------------------------------------------------------------*/ S32 gpio_pin_init(U16 pin_num, U8 in_out) { U8 module_num = pin_num/NUM_OF_BITS_IN_REG + 1; /* GPIO module to which the GPIO number belongs to */ U32 snum = (module_num-1)*NUM_OF_BITS_IN_REG; U32 offset = pin_num - snum; U32 pinmask; S32 ret_val = OMAPFLASH_SUCCESS; /* check whether the gpio number is valid */ /* if yes continue else return*/ ret_val = check_gpio_pin_num(pin_num); if(ret_val != OMAPFLASH_SUCCESS) { dbg_print(DBG_LEVEL_CRITICAL, "wrong gpio-pin number \n"); return(ret_val); } /* this variable will have the position of the pin in the corresponding gpio module */ pinmask = GPIO_PIN<<offset; /* call this function to configure the pin as input or output */ set_gpio_in_out(module_num, pinmask, in_out<<offset); /*return from this function*/ dbg_print(DBG_LEVEL_INFO, "gpio pin %d initialized \n",pin_num); return (ret_val); }
/* This function is to initialize the gpio pin as input or output. */ S32 gpio_pin_init(U16 pin_num, U8 in_out) { /* GPIO module to which the GPIO number belongs to. */ U8 module_num = (pin_num / NUM_OF_BITS_IN_REG + 1); U32 snum = ((module_num - 1) * NUM_OF_BITS_IN_REG); U32 offset = (pin_num - snum); U32 pinmask; S32 ret_val = SUCCESS; /* ** Check whether the gpio number is valid. ** If yes continue else return. */ ret_val = check_gpio_pin_num(pin_num); if (SUCCESS != ret_val) { #ifdef OMAP3530_DEBUG DEBUG("%s:%d - Wrong gpio-pin number.\r\n", __FILE__, __LINE__); #endif return (ret_val); } /* ** This variable will have the position of the pin in ** the corresponding gpio module. */ pinmask = (GPIO_PIN << offset); /* Call this function to configure the pin as input or output. */ set_gpio_in_out(module_num, pinmask, (in_out << offset)); #ifdef OMAP3530_DEBUG DEBUG("gpio pin %d initialized.\r\n", pin_num); #endif return (ret_val); }