Exemplo n.º 1
0
static int dbg_pinmux_show(struct seq_file *s, void *unused)
{
	int i = 0;
	struct  iomux_pin *pin_temp = NULL;

	seq_printf(s, "pinname	       pin_owner        func        \
			pullud        driverstrength		\n");
	seq_printf(s, "-----------------------------------------"
			"-----------------------------------------------\n");

	mutex_lock(&iomux_lock);
	while (pins_table[i].pinname) {
		pin_temp = iomux_get_pin(pins_table[i].pinname);
		if (pin_temp) {
			seq_printf(s, "%s        %s        %d        %s        %d\r\n",
				pin_temp->pin_name,
				pin_temp->pin_owner,
				pin_temp->pin_func,
				pin_pull_status(pin_temp),
				pin_temp->pin_drive_strength);
		}
		i++;
	}
	mutex_unlock(&iomux_lock);
	return 0;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 4
0
static int mshci_hi_start_signal_voltage_switch(struct mshci_host *ms_host,
				struct mmc_ios *ios)
{
	struct himci_host *hi_host = (struct himci_host *)(ms_host->private);
	int ret =0;
	struct iomux_pin *pin_temp = NULL;

	hi_host_trace(HIMCI_TRACE_SIGNIFICANT, "++");

	himci_assert(ios);
	himci_assert(hi_host);

	hi_host_trace(HIMCI_TRACE_SIGNIFICANT, "old_sig_voltage = %d ",
					hi_host->old_sig_voltage);
	hi_host_trace(HIMCI_TRACE_SIGNIFICANT, "new_sig_voltage = %d ",
					ios->signal_voltage);
	hi_host_trace(HIMCI_TRACE_SIGNIFICANT, "allow_switch_signal_voltage = %d ",
					hi_host->allow_switch_signal_voltage);

	if (hi_host->allow_switch_signal_voltage &&
		(hi_host->old_sig_voltage != ios->signal_voltage)) {
		switch (ios->signal_voltage) {
		case MMC_SIGNAL_VOLTAGE_330:
			/* alter driver 6mA */
			hi_host_trace(HIMCI_TRACE_SIGNIFICANT, "alter driver 6mA");
			pin_temp = iomux_get_pin(SD_CLK_PIN);
			if (pin_temp) {
				ret = pinmux_setdrivestrength(pin_temp, LEVEL2);
				if (ret < 0)
					himci_error("pinmux_setdrivestrength error");
			} else {
				himci_error("failed to get iomux pin");
			}

			hi_host->old_sig_voltage = ios->signal_voltage;
			/* if there is signal vcc, set vcc to signal voltage */
		    if (hi_host->signal_vcc) {
				ret = regulator_set_voltage(hi_host->signal_vcc, 2600000, 2600000);
				if (ret != 0) {
					himci_error("failed to regulator_set_voltage");
				}
				ret = regulator_enable(hi_host->signal_vcc);
				if (ret) {
					himci_error("failed to regulator_enable");
				}
		    }

			/* update time config*/
			mshci_hi_update_timing(ms_host, 0);
			break;
		case MMC_SIGNAL_VOLTAGE_180:
			/* alter driver 8mA */
			hi_host_trace(HIMCI_TRACE_SIGNIFICANT, "alter driver 8mA");
			pin_temp = iomux_get_pin(SD_CLK_PIN);
			if (pin_temp) {
				ret = pinmux_setdrivestrength(pin_temp, LEVEL3);
				if (ret < 0)
					himci_error("pinmux_setdrivestrength error");
			} else {
				himci_error("failed to get iomux pin");
			}

			hi_host->old_sig_voltage = ios->signal_voltage;
			/* if there is signal vcc, set vcc to signal voltage */
		    if (hi_host->signal_vcc) {
				ret = regulator_set_voltage(hi_host->signal_vcc, 1800000, 1800000);
				if (ret != 0) {
					himci_error("failed to regulator_set_voltage");
				}
				ret = regulator_enable(hi_host->signal_vcc);
				if (ret) {
					himci_error("failed to regulator_enable");
				}
		    }
			/* update time config*/
			mshci_hi_update_timing(ms_host, 0);
			break;

		case MMC_SIGNAL_VOLTAGE_120:
			/* FIXME */
			/* 1.20v is not support */
			himci_error("1.20V is not supported");
			break;
		default:
			himci_error("unknown signal voltage");
			break;
		}
	}

	hi_host_trace(HIMCI_TRACE_SIGNIFICANT, "--");

	return 0;
}
/*
 **************************************************************************
 * 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;
}