halReturn_t HalGpioSetResource(void)
{
    int status;
    struct iomux_pin        *pIntPin = NULL; //interrupt pin "T28"
    struct iomux_pin        *pRstPin = NULL; //Reset pin "T26"
    /*Set interrupt GPIO resource*/
    pIntPin = iomux_get_pin(PIN_NAME_INT);
    if( !pIntPin )
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
                        "HalGpioSetResource: get pin of GPIO %d failed\n",
                        W_INT_GPIO);
        return HAL_RET_FAILURE;
    }
    status = pinmux_setpullupdown(pIntPin, PULLUP);
    if (status < 0)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
                        "HalGpioSetResource: pinmux_setpullupdown of GPIO %d failed, status = %d \n",
                        W_INT_GPIO,status);
        return HAL_RET_FAILURE;
    }

    /*Set Reset GPIO resource*/
    pRstPin = iomux_get_pin(PIN_NAME_RST);
    if( !pRstPin )
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
                        "HalGpioSetResource get pin of GPIO %d failed\n",
                        W_RST_GPIO);
        return HAL_RET_FAILURE;
    }
    status = pinmux_setpullupdown(pIntPin, PULLUP);
    if (status < 0)
    {
        SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
                        "HalGpioSetResource: pinmux_setpullupdown of GPIO %d failed, status = %d \n",
                        W_RST_GPIO,status);
        return HAL_RET_FAILURE;
    }

    return HAL_RET_SUCCESS;
}
/*
 **************************************************************************
 * FunctionName: camera_power_core_ldo;
 * Description : NA;
 * Input       : NA;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
int camera_power_core_ldo(camera_power_state power)
{
	int ret = 0;

        /*V9R1 do not need this to power sensor core vcc*/

#if 0
	print_debug("enter %s", __FUNCTION__);
	if (NULL == gpio_core_ldo) {
		gpio_core_ldo = iomux_get_pin(CAM_VCC_PIN);
		if (!gpio_core_ldo) {
			print_error("fail to get CAM_VCC_PIN");
			return -EINVAL;
		}
	}

	if (POWER_ON == power) {
		print_info("power on core ldo");
		ret = pinmux_setpullupdown(gpio_core_ldo, NOPULL);
		if (ret < 0)
			print_error("fail to set gpio_core_ldo to NOPULL");

		ret = gpio_request(GPIO_21_5, "cam_vcc_en");
		if (ret < 0)
			print_error("fail to get GPIO_21_5");
		ret = gpio_direction_output(GPIO_21_5, 1);
		if (ret < 0)
			print_error("fail to set GPIO_21_5 to 1");

	} else {
		print_info("power off core ldo");
		ret = gpio_direction_output(GPIO_21_5, 0);
		if (ret < 0)
			print_error("fail to set GPIO_21_5 to 0");
		gpio_free(GPIO_21_5);
	}
#endif

	return ret;
}
/*
 **************************************************************************
 * FunctionName: camera_power_id_gpio;
 * Description : NA;
 * Input       : NA;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
int camera_power_id_gpio(camera_power_state power)
{
	int ret = 0;

	print_debug("enter %s", __FUNCTION__);

	if (POWER_ON == power) {
		if (NULL == gpio_main_camera_id) {
			gpio_main_camera_id = iomux_get_pin(CAM_ID_PIN);
			if (!gpio_main_camera_id) {
				print_error("fail to get CAM_ID_PIN");
				return -EINVAL;
			}
		}

		ret = pinmux_setpullupdown(gpio_main_camera_id, PULLUP);
		if (ret < 0)
			print_error("fail to set gpio_main_camera_id to PULLUP");

		ret = gpio_request(GPIO_13_7, NULL);
		if (ret < 0)
			print_error("fail to get GPIO_13_7");
		ret = gpio_direction_input(GPIO_13_7);
		if (ret < 0) {
			print_error("fail to set GPIO_13_7 input");
		} else {
			ret = gpio_get_value(GPIO_13_7);
			if (ret < 0)
				print_error("fail to get GPIO_13_7 value");
			set_camera_timing_type(ret);
		}

		if (NULL == gpio_slave_camera_id) {
			gpio_slave_camera_id = iomux_get_pin(SCAM_ID_PIN);
			if (!gpio_slave_camera_id) {
				print_error("fail to get CAM_ID_PIN");
				return -EINVAL;
			}
		}

		ret = pinmux_setpullupdown(gpio_slave_camera_id, PULLUP);
		if (ret < 0)
			print_error("fail to set gpio_slave_camera_id to PULLUP");

		ret = gpio_request(GPIO_14_0, NULL);
		if (ret < 0)
			print_error("fail to get GPIO_14_0");
		ret = gpio_direction_input(GPIO_14_0);
		if (ret < 0)
			print_error("fail to set GPIO_14_0 input");

	} else {
		if (NULL != gpio_main_camera_id) {
			if (pinmux_setpullupdown(gpio_main_camera_id, NOPULL) < 0)
				print_error("fail to set gpio_main_camera_id to NOPULL");
			gpio_main_camera_id = NULL;
			gpio_free(GPIO_13_7);
		}

		if (NULL != gpio_slave_camera_id) {
			if (pinmux_setpullupdown(gpio_slave_camera_id, NOPULL))
				print_error("fail to set gpio_slave_camera_id to NOPULL");
			gpio_slave_camera_id = NULL;
			gpio_free(GPIO_14_0);
		}
	}

	return ret;
}