static void android_irrc_enable_pwm(struct timed_irrc_data *irrc, int PWM_CLK, int duty)
{
	int rc;

	cancel_delayed_work_sync(&irrc->gpio_off_work); //android_irrc_disable_pwm

	if(g_pwm_enabled == true) {
		INFO_MSG("pwm already enabled !!!\n");
		return;
	}

	if (irrc->vreg != NULL) {
		rc = regulator_enable(irrc->vreg);
		ERR_MSG("regulator_enabled1\n");
		if (rc < 0)
			ERR_MSG("regulator_enable failed\n");
	}
	/*if (irrc->vreg2 != NULL) {
		rc = regulator_enable(irrc->vreg2);
        ERR_MSG("irrc->vreg2 set!!\n");
		if (rc < 0)
			ERR_MSG("regulator_enable failed2\n");
	}*/

	if((PWM_CLK == 0) || (duty == 100)){
		INFO_MSG("gpio set to high!!!\n");

	rc = pinctrl_select_state(irrc->pctrl, irrc->active_state);
	if(rc < 0) {
		ERR_MSG("select active state failed\n");
	} else {
		ERR_MSG("state changed to active\n");
	}
	gpio_direction_output(irrc->pwm_gpio, 1);
	gpio_set_value(irrc->pwm_gpio, 1);

		gpio_high_flag = 1;

	} else if((PWM_CLK < 23) || (PWM_CLK > 1200) || (duty > 60) || (duty < 20) ){
		INFO_MSG("Out of range ! \n");
	} else {
		INFO_MSG("gpio set to gp!!!\n");

		rc = pinctrl_select_state(irrc->pctrl, irrc->suspended_state);
		if(rc < 0){
			ERR_MSG("select suspended state failed\n");
		} else {
			ERR_MSG("state changed to suspended\n");
		}

		gpio_direction_output(irrc->pwm_gpio, 1);
		//gpio_set_value(irrc->pwm_gpio, 1); no need
		clk_set_rate(irrc->gp_clk, irrc->clk_rate);
		clk_prepare_enable(irrc->gp_clk);
		android_irrc_set_pwm(1, PWM_CLK, duty);

		gpio_high_flag = 0;
	}
	g_pwm_enabled = true;
}
int mtkcam_gpio_set(int PinIdx, int PwrType, int Val)
{
	int ret = 0;
	switch (PwrType) {
	case CAMRST:
		if (PinIdx == 0) {
			if (Val == 0)
				pinctrl_select_state(camctrl, cam0_rst_l);
			else
				pinctrl_select_state(camctrl, cam0_rst_h);
		} else {
			if (Val == 0)
				pinctrl_select_state(camctrl, cam1_rst_l);
			else
				pinctrl_select_state(camctrl, cam1_rst_h);
		}
		break;
	default:
		PK_DBG("PwrType(%d) is invalid !!\n", PwrType);
		break;
	};

	PK_DBG("PinIdx(%d) PwrType(%d) val(%d)\n", PinIdx, PwrType, Val);

	return ret;
}
Example #3
0
static int tegra_sdhci_set_padctrl(struct sdhci_host *host, int voltage)
{
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
	int ret;

	if (!tegra_host->pad_control_available)
		return 0;

	if (voltage == MMC_SIGNAL_VOLTAGE_180) {
		ret = pinctrl_select_state(tegra_host->pinctrl_sdmmc,
					   tegra_host->pinctrl_state_1v8);
		if (ret < 0)
			dev_err(mmc_dev(host->mmc),
				"setting 1.8V failed, ret: %d\n", ret);
	} else {
		ret = pinctrl_select_state(tegra_host->pinctrl_sdmmc,
					   tegra_host->pinctrl_state_3v3);
		if (ret < 0)
			dev_err(mmc_dev(host->mmc),
				"setting 3.3V failed, ret: %d\n", ret);
	}

	return ret;
}
Example #4
0
/*
 * We provide an interface via debugfs to switch between host and device modes
 * depending on user input.
 * This is useful in special cases, such as uses TYPE-A receptacle but also
 * wants to support dual-role mode.
 * It generates cable state changes by pulling up/down IDPIN and
 * notifies driver to switch mode by "extcon-usb-gpio".
 * NOTE: when use MICRO receptacle, should not enable this interface.
 */
static void ssusb_mode_manual_switch(struct ssusb_mtk *ssusb, int to_host)
{
	struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;

	if (to_host)
		pinctrl_select_state(otg_sx->id_pinctrl, otg_sx->id_ground);
	else
		pinctrl_select_state(otg_sx->id_pinctrl, otg_sx->id_float);
}
static int ci13xxx_msm_install_wake_gpio(struct platform_device *pdev,
				struct resource *res)
{
	int wake_irq;
	int ret;
	struct pinctrl_state *set_state;

	dev_dbg(&pdev->dev, "ci13xxx_msm_install_wake_gpio\n");

	_udc_ctxt.wake_gpio = res->start;
	if (_udc_ctxt.ci13xxx_pinctrl) {
		set_state = pinctrl_lookup_state(_udc_ctxt.ci13xxx_pinctrl,
				"ci13xxx_active");
		if (IS_ERR(set_state)) {
			pr_err("cannot get ci13xxx pinctrl active state\n");
			return PTR_ERR(set_state);
		}
		pinctrl_select_state(_udc_ctxt.ci13xxx_pinctrl, set_state);
	}
	gpio_request(_udc_ctxt.wake_gpio, "USB_RESUME");
	gpio_direction_input(_udc_ctxt.wake_gpio);
	wake_irq = gpio_to_irq(_udc_ctxt.wake_gpio);
	if (wake_irq < 0) {
		dev_err(&pdev->dev, "could not register USB_RESUME GPIO.\n");
		return -ENXIO;
	}

	dev_dbg(&pdev->dev, "_udc_ctxt.gpio_irq = %d and irq = %d\n",
			_udc_ctxt.wake_gpio, wake_irq);
	ret = request_irq(wake_irq, ci13xxx_msm_resume_irq,
		IRQF_TRIGGER_RISING | IRQF_ONESHOT, "usb resume", NULL);
	if (ret < 0) {
		dev_err(&pdev->dev, "could not register USB_RESUME IRQ.\n");
		goto gpio_free;
	}
	disable_irq(wake_irq);
	_udc_ctxt.wake_irq = wake_irq;

	return 0;

gpio_free:
	gpio_free(_udc_ctxt.wake_gpio);
	if (_udc_ctxt.ci13xxx_pinctrl) {
		set_state = pinctrl_lookup_state(_udc_ctxt.ci13xxx_pinctrl,
				"ci13xxx_sleep");
		if (IS_ERR(set_state))
			pr_err("cannot get ci13xxx pinctrl sleep state\n");
		else
			pinctrl_select_state(_udc_ctxt.ci13xxx_pinctrl,
					set_state);
	}
	_udc_ctxt.wake_gpio = 0;
	return ret;
}
Example #6
0
static int config_irq(int n, int t) {
    
    int ret;

    if(n == 2) {
        trigger1_type = t;
        ret = pinctrl_select_state(pinctrl, pin_irq1);
        if(ret<0) {
            printk("pinctrl select state pin irq[%d] error \n", n);
        }
        irq1 = gpio_to_irq(pin[n]);
        printk("%s : requesting IRQ1 %d name = %s \n", __func__, irq1, "irq1");
        ret = request_irq(irq1, vdev_irq1_handler,
                IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND , "irq1", vdev_dev);
        if(ret < 0) {
            printk("request irq1 error\n");
            return -1;
        }
    } else if(n == 7) {
        trigger2_type = t;
        ret = pinctrl_select_state(pinctrl, pin_irq2);
        if(ret<0) {
            printk("pinctrl select state pin irq[%d] error \n", n);
        }
        irq2 = gpio_to_irq(pin[n]);
        printk("%s : requesting IRQ2 %d name = %s \n", __func__, irq2, "irq2");
        ret = request_irq(irq2, vdev_irq2_handler,
                IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND , "irq2", vdev_dev);
        if(ret < 0) {
            printk("request irq2 error\n");
            return -1;
        }

    } else if(n == 9) {
        trigger3_type = t;
        ret = pinctrl_select_state(pinctrl, pin_irq3);
        if(ret<0) {
            printk("pinctrl select state pin irq[%d] error \n", n);
        }
        irq3 = gpio_to_irq(pin[n]);
        printk("%s : requesting IRQ3 %d name = %s \n", __func__, irq3, "irq3");
        ret = request_irq(irq3, vdev_irq3_handler,
                IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND , "irq3", vdev_dev);
        if(ret < 0) {
            printk("request irq3 error\n");
            return -1;
        }
    }

    device_init_wakeup(&pn547_dev->client->dev, 1);
    
    return ret;
}
static int c55_ctrl_suspend(struct platform_device *dev, pm_message_t state)
{
	struct c55_ctrl_data *cdata = dev_get_drvdata(&dev->dev);
	struct m4sensorhub_data *m4sensorhub = m4sensorhub_client_get_drvdata();

	if (cdata->c55_mode != C55_OFF) {
		dev_warn(&dev->dev, "C55 still ON when going into suspend\n");

		/* Disable C55->AP IRQ when turning off C55 */
		if (cdata->c55_ap_int_enabled) {
			disable_irq_nosync(
				__gpio_to_irq(cdata->c55_ap_int_gpio));
			cdata->c55_ap_int_enabled = 0;
		}

		if (m4sensorhub_reg_write_1byte
		    (m4sensorhub, M4SH_REG_USERSETTINGS_AUDIOSTATUS,
		    AUDIO_STATUS_OFF, 0xFF) != 1) {
			dev_err(&dev->dev,
				"Unable to set screen status to 0x00\n");
		}

		/* AP->C55 interrupt needs to be set low when C55 is off
		 * for current drain reasons */
		gpio_set_value(cdata->ap_c55_int_gpio, 0);

		cdata->c55_mode = C55_OFF;
	}

	pinctrl_select_state(cdata->pctrl, cdata->states[C55_OFF]);

	return 0;
}
static int c55_ctrl_pin_setup(struct device *dev, struct c55_ctrl_data *cdata)
{
	int i, ret = 0;

	cdata->pctrl = devm_pinctrl_get(dev);
	if (IS_ERR(cdata->pctrl)) {
		ret = PTR_ERR(cdata->pctrl);
		dev_dbg(dev, "no pinctrl handle\n");
	}

	for (i = 0; !ret && (i < C55_MODE_MAX); i++) {
		cdata->states[i] = pinctrl_lookup_state(cdata->pctrl,
			c55_pin_state_labels[i]);
		if (IS_ERR(cdata->states[i])) {
			ret = PTR_ERR(cdata->states[i]);
			dev_dbg(dev, "no %s pinctrl state\n",
				c55_pin_state_labels[i]);
		}
	}

	if (!ret) {
		ret = pinctrl_select_state(cdata->pctrl,
			cdata->states[C55_OFF]);
		if (ret)
			dev_dbg(dev, "failed to activate %s pinctrl state\n",
				c55_pin_state_labels[C55_OFF]);
	}

	return ret;
}
/**
 * Will try to select the set of pins (GPIOS) defined in a pin control node of
 * the device tree named @p name.
 *
 * The node can contain several eg. GPIOs that is controlled when selecting it.
 * The node may activate or deactivate the pins it contains, the action is
 * defined in the device tree node itself and not here. The states used
 * internally is fetched at probe time.
 *
 * @see pctl_names
 * @see fpc1020_probe
 */
static int select_pin_ctl(struct fpc1020_data *fpc1020, const char *name)
{
	struct device *dev = fpc1020->dev;
	size_t i;
	int rc;

	for (i = 0; i < ARRAY_SIZE(fpc1020->pinctrl_state); i++) {
		const char *n = pctl_names[i];
		if (!strncmp(n, name, strlen(n))) {
			rc = pinctrl_select_state(fpc1020->fingerprint_pinctrl,
					fpc1020->pinctrl_state[i]);
			if (rc)
				dev_err(dev, "cannot select '%s'\n", name);
			else
				dev_dbg(dev, "Selected '%s'\n", name);

			goto exit;
		}
	}
	rc = -EINVAL;
	dev_err(dev, "%s:'%s' not found\n", __func__, name);

exit:
	return rc;
}
Example #10
0
static int twi_request_gpio(struct sunxi_i2c *i2c)
{
	int ret = 0;

	I2C_DBG("Pinctrl init %d ... [%s]\n", i2c->bus_num, i2c->adap.dev.parent->init_name);

	if (!twi_chan_is_enable(i2c->bus_num))
		return -1;
	
	i2c->pctrl = devm_pinctrl_get(i2c->adap.dev.parent);
	if (IS_ERR(i2c->pctrl)) {
		I2C_ERR("TWI%d devm_pinctrl_get() failed! return %ld\n", i2c->bus_num, PTR_ERR(i2c->pctrl));
		return -1;
	}

	i2c->pctrl_state = pinctrl_lookup_state(i2c->pctrl, PINCTRL_STATE_DEFAULT);
	if (IS_ERR(i2c->pctrl_state)) {
		I2C_ERR("TWI%d pinctrl_lookup_state() failed! return %p \n", i2c->bus_num, i2c->pctrl_state);
		return -1;
	}

	ret = pinctrl_select_state(i2c->pctrl, i2c->pctrl_state);
	if (ret < 0)
		I2C_ERR("TWI%d pinctrl_select_state() failed! return %d \n", i2c->bus_num, ret);
	
	return ret;
}
static int isdbt_pinctrl_init(void)
{
	struct pinctrl *tdmb_pinctrl;
	struct pinctrl_state *gpio_state_suspend;

	tdmb_pinctrl = devm_pinctrl_get(&(IsdbCtrlInfo.pdev->dev));


	if(IS_ERR_OR_NULL(tdmb_pinctrl)) {
		pr_err("%s: Getting pinctrl handle failed\n", __func__);
		return -EINVAL;
	}
	gpio_state_suspend
	 = pinctrl_lookup_state(tdmb_pinctrl, "isdbt_gpio_suspend");

	 if(IS_ERR_OR_NULL(gpio_state_suspend)) {
	 	pr_err("%s: [dtv]Failed to get the suspend state pinctrl handle\n", __func__);
	 	return -EINVAL;
	}

	if(pinctrl_select_state(tdmb_pinctrl, gpio_state_suspend)) {
		pr_err("%s: [dtv]error on pinctrl_select_state DTV GPIOs\n", __func__);
		return -EINVAL;
	}
	else {
		printk("%s: success to set pinctrl_select_state for DTV GPIOss\n", __func__);
	}

	return 0;
}
Example #12
0
static int msm_flash_lm3642_i2c_remove(struct i2c_client *client)
{
	struct msm_camera_sensor_board_info *flashdata = NULL;
	struct msm_camera_power_ctrl_t *power_info = NULL;
	int rc = 0 ;
	LM3642_DBG("%s entry\n", __func__);
	flashdata = fctrl.flashdata;
	power_info = &flashdata->power_info;

	rc = msm_camera_request_gpio_table(
		power_info->gpio_conf->cam_gpio_req_tbl,
		power_info->gpio_conf->cam_gpio_req_tbl_size, 0);
	if (rc < 0) {
		pr_err("%s: request gpio failed\n", __func__);
		return rc;
	}

	if (fctrl.pinctrl_info.use_pinctrl == true) {
		rc = pinctrl_select_state(fctrl.pinctrl_info.pinctrl,
				fctrl.pinctrl_info.gpio_state_suspend);
		if (rc)
			pr_err("%s:%d cannot set pin to suspend state",
				__func__, __LINE__);
	}
	return rc;
}
static int pinctrl_init(struct i2c_client *client)
{
    struct lge_touch_data *ts = i2c_get_clientdata(client);

    /* Get pinctrl if target uses pinctrl */
    ts->ts_pinctrl = devm_pinctrl_get(&(client->dev));
    if (IS_ERR(ts->ts_pinctrl)) {
        if (PTR_ERR(ts->ts_pinctrl) == -EPROBE_DEFER) {
            LGTC_ERR("ts_pinctrl == -EPROBE_DEFER\n");
            return -EPROBE_DEFER;
        }
        LGTC_DBG("Target does not use pinctrl(ts->ts_pinctrl == NULL) \n");
        ts->ts_pinctrl = NULL;
    }

    if (ts->ts_pinctrl) {
        ts->ts_pinset_state_active = pinctrl_lookup_state(ts->ts_pinctrl, "pmx_ts_active");
        if (IS_ERR(ts->ts_pinset_state_active))
            LGTC_DBG("cannot get ts pinctrl active state\n");

        ts->ts_pinset_state_suspend = pinctrl_lookup_state(ts->ts_pinctrl, "pmx_ts_suspend");
        if (IS_ERR(ts->ts_pinset_state_suspend))
            LGTC_DBG("cannot get ts pinctrl active state\n");

        if (ts->ts_pinset_state_active) {
            DO_SAFE(pinctrl_select_state(ts->ts_pinctrl, ts->ts_pinset_state_active), error);
        } else {
            LGTC_DBG("pinctrl active == NULL \n");
        }
    }

    return NO_ERROR;
error:
    return ERROR;
}
Example #14
0
static void dummy_codec_device_init(void)
{
#ifdef CONFIG_USE_OF
	int ret;
	struct pinctrl_state *s;
	p = pinctrl_get(dummy_codec_dev);

	if (IS_ERR(p))
		return;
			
	s = pinctrl_lookup_state(p, "dummy_codec_audio");
	if (IS_ERR(s)) {
		pinctrl_put(p);
		return;
	}
		
	ret = pinctrl_select_state(p, s);
	if (ret < 0) {
		pinctrl_put(p);
		return;
	}
	printk("=%s==,dummy_codec_audio init done\n",__func__);
#else
    /* audio pinmux */
//    pinmux_set(&rt5631_pinmux_set);

    /* GPIOA_19 PULL_UP_REG0 bit19 */
//    aml_set_reg32_bits(P_PAD_PULL_UP_REG0, 1, 19, 1);
#endif
}
int msm_gpioset_activate(enum pinctrl_client client, char *keyword)
{
	int ret = 0;
	int gp_set = 0;
	int active_set = 0;

	gp_set = msm_get_gpioset_index(client, keyword);
	if (gp_set < 0) {
		pr_err("%s: gpio set name does not exist\n",
				__func__);
		return gp_set;
	}

	if (!gpioset_info[client].gpioset_state[gp_set]) {
		/*
		 * If pinctrl pointer is not valid,
		 * no need to proceed further
		 */
		active_set = pinctrl_info[client].active_set;
		if (IS_ERR(pinctrl_info[client].cdc_lines[active_set]))
			return 0;

		pinctrl_info[client].active_set |= (1 << gp_set);
		active_set = pinctrl_info[client].active_set;
		pr_debug("%s: pinctrl.active_set: %d\n", __func__, active_set);

		/* Select the appropriate pinctrl state */
		ret =  pinctrl_select_state(pinctrl_info[client].pinctrl,
			pinctrl_info[client].cdc_lines[active_set]);
	}
	gpioset_info[client].gpioset_state[gp_set]++;

	return ret;
}
static void htc_config_bt_off(void)
{
    int rc = 0;

    if (gpio_bt_reg_on < 0) {
        printk(KERN_INFO "[BT]bt_reg_on:%d !!\n", gpio_bt_reg_on);
    }


    bluesleep_set_bt_pwr_state(0);


    rc = gpio_direction_output(gpio_bt_reg_on, 0);
    if (rc) printk(KERN_INFO "[BT]set REG_ON 0 fail! %d\n", rc);


    rc = pinctrl_select_state(bt_pinctrl, bt_wake_host_set_state_off);
    if (rc) printk("[BT] cannot set BT pinctrl gpio state off\n");

    mdelay(2);


    msm_hs_uart_gpio_config_ext(0);

    printk(KERN_INFO "[BT]== R OFF ==\n");
}
Example #17
0
static int usdhi6_set_pinstates(struct usdhi6_host *host, int voltage)
{
	if (IS_ERR(host->pins_uhs))
		return 0;

	switch (voltage) {
	case MMC_SIGNAL_VOLTAGE_180:
	case MMC_SIGNAL_VOLTAGE_120:
		return pinctrl_select_state(host->pinctrl,
					    host->pins_uhs);

	default:
		return pinctrl_select_state(host->pinctrl,
					    host->pins_default);
	}
}
static int gpio_keys_pinctrl_configure(struct gpio_keys_drvdata *ddata,
							bool active)
{
	struct pinctrl_state *set_state;
	int retval;

	if (active) {
		set_state =
			pinctrl_lookup_state(ddata->key_pinctrl,
						"tlmm_gpio_key_active");
		if (IS_ERR(set_state)) {
			dev_err(&ddata->input->dev,
				"cannot get ts pinctrl active state\n");
			return PTR_ERR(set_state);
		}
	} else {
		set_state =
			pinctrl_lookup_state(ddata->key_pinctrl,
						"tlmm_gpio_key_suspend");
		if (IS_ERR(set_state)) {
			dev_err(&ddata->input->dev,
				"cannot get gpiokey pinctrl sleep state\n");
			return PTR_ERR(set_state);
		}
	}
	retval = pinctrl_select_state(ddata->key_pinctrl, set_state);
	if (retval) {
		dev_err(&ddata->input->dev,
				"cannot set ts pinctrl active state\n");
		return retval;
	}

	return 0;
}
static int aw2013_configure_gpio(struct aw2013_led *led, bool on)
{
	struct pinctrl *pinctrl;
	struct pinctrl_state *pinctrl_state;
	int rc;

	pinctrl = devm_pinctrl_get(&led->client->dev);
	if (IS_ERR_OR_NULL(pinctrl)) {
		dev_err(&led->client->dev,
				"Failed to get pinctrl\n");
		return -EFAULT;
	}
	pinctrl_state = pinctrl_lookup_state(pinctrl,
			on ? "aw2013_led_default" : "aw2013_led_suspend");
	if (IS_ERR_OR_NULL(pinctrl_state)) {
		dev_err(&led->client->dev,
				"Failed to look up pinctrl state\n");
		return -EFAULT;
	}
	rc = pinctrl_select_state(pinctrl, pinctrl_state);
	if (rc) {
		dev_err(&led->client->dev,
				"Failed to select pinctrl state\n");
		return -EIO;
	}

	return 0;
}
Example #20
0
static int mdss_dsi_pinctrl_set_state(
	struct mdss_dsi_ctrl_pdata *ctrl_pdata,
	bool active)
{
	struct pinctrl_state *pin_state;
	int rc = -EFAULT;

	if (IS_ERR_OR_NULL(ctrl_pdata->pin_res.pinctrl))
		return PTR_ERR(ctrl_pdata->pin_res.pinctrl);

	pin_state = active ? ctrl_pdata->pin_res.gpio_state_active
				: ctrl_pdata->pin_res.gpio_state_suspend;
	if (!IS_ERR_OR_NULL(pin_state)) {
		rc = pinctrl_select_state(ctrl_pdata->pin_res.pinctrl,
				pin_state);
		if (rc)
			pr_err("%s: can not set %s pins\n", __func__,
			       active ? MDSS_PINCTRL_STATE_DEFAULT
			       : MDSS_PINCTRL_STATE_SLEEP);
	} else {
		pr_err("%s: invalid '%s' pinstate\n", __func__,
		       active ? MDSS_PINCTRL_STATE_DEFAULT
		       : MDSS_PINCTRL_STATE_SLEEP);
	}
	return rc;
}
static int enable_msp(struct ux500_msp *msp, struct ux500_msp_config *config)
{
	int status = 0, retval = 0;
	u32 reg_val_DMACR, reg_val_GCR;
	unsigned long flags;

	/* Check msp state whether in RUN or CONFIGURED Mode */
	if (msp->msp_state == MSP_STATE_IDLE) {
		spin_lock_irqsave(&msp_rxtx_lock, flags);
		if (msp->pinctrl_rxtx_ref == 0 &&
			!(IS_ERR(msp->pinctrl_p) || IS_ERR(msp->pinctrl_def))) {
			retval = pinctrl_select_state(msp->pinctrl_p,
						msp->pinctrl_def);
			if (retval)
				pr_err("could not set MSP defstate\n");
		}
		if (!retval)
			msp->pinctrl_rxtx_ref++;
		spin_unlock_irqrestore(&msp_rxtx_lock, flags);
	}

	/* Configure msp with protocol dependent settings */
	configure_protocol(msp, config);
	setup_bitclk(msp, config);
	if (config->multichannel_configured == 1) {
		status = configure_multichannel(msp, config);
		if (status)
			dev_warn(msp->dev,
				"%s: WARN: configure_multichannel failed (%d)!\n",
				__func__, status);
	}

	/* Make sure the correct DMA-directions are configured */
	if ((config->direction & MSP_DIR_RX) && (!msp->dma_cfg_rx)) {
		dev_err(msp->dev, "%s: ERROR: MSP RX-mode is not configured!",
			__func__);
		return -EINVAL;
	}
	if ((config->direction == MSP_DIR_TX) && (!msp->dma_cfg_tx)) {
		dev_err(msp->dev, "%s: ERROR: MSP TX-mode is not configured!",
			__func__);
		return -EINVAL;
	}

	reg_val_DMACR = readl(msp->registers + MSP_DMACR);
	if (config->direction & MSP_DIR_RX)
		reg_val_DMACR |= RX_DMA_ENABLE;
	if (config->direction & MSP_DIR_TX)
		reg_val_DMACR |= TX_DMA_ENABLE;
	writel(reg_val_DMACR, msp->registers + MSP_DMACR);

	writel(config->iodelay, msp->registers + MSP_IODLY);

	/* Enable frame generation logic */
	reg_val_GCR = readl(msp->registers + MSP_GCR);
	writel(reg_val_GCR | FRAME_GEN_ENABLE, msp->registers + MSP_GCR);

	return status;
}
void s5p_v4l2_int_src_ext_hpd(struct hdmi_device *hdev)
{
    int ret = 0;

    ret = pinctrl_select_state(hdev->pinctrl, hdev->pin_ext);
    if (ret)
        dev_err(hdev->dev, "failed to set external hpd interrupt");
}
Example #23
0
static void IicPortDisable(UBYTE Port)
{
	PINHigh(Port, INPUT_PORT_BUF);
	PINInput(Port, INPUT_PORT_PIN6);

	pinctrl_select_state(Device1Lms2012Compat->pinctrl[Port],
			     Device1Lms2012Compat->pinctrl_default[Port]);
}
static int c55_ctrl_resume(struct platform_device *dev)
{
	struct c55_ctrl_data *cdata = dev_get_drvdata(&dev->dev);

	pinctrl_select_state(cdata->pctrl, cdata->states[C55_ON]);

	return 0;
}
Example #25
0
static void i2c_fsl_unprepare_recovery(struct i2c_adapter *adapter)
{
	int ret;

	ret = pinctrl_select_state(adapter->dev.parent, "default");
	if (ret)
		dev_err(adapter->dev.parent, "pinctrl failed: %s\n", strerror(-ret));
}
Example #26
0
static void IicPortEnable(UBYTE Port)
{
	pinctrl_select_state(Device1Lms2012Compat->pinctrl[Port],
			     Device1Lms2012Compat->pinctrl_i2c[Port]);

	PINLow(Port, INPUT_PORT_BUF);
	// PINHigh(Port, IIC_PORT_CLOCK);
	PINHigh(Port, INPUT_PORT_PIN6);
}
Example #27
0
int gf_pinctrl_set(struct gf_dev *gf_dev, bool active)
{
    int ret = 0;

    GF_LOG_INFO("start\n");

    if (active) {
        ret = pinctrl_select_state(gf_dev->gf_pctrl.pinctrl,
			gf_dev->gf_pctrl.gpio_state_active);
    } else {
        ret = pinctrl_select_state(gf_dev->gf_pctrl.pinctrl,
			gf_dev->gf_pctrl.gpio_state_suspend);
    }

    GF_LOG_INFO("set %s = %d\n", active? "avtive" : "suspend", ret);

    return ret;
}
Example #28
0
void gf_irq_enable(struct gf_dev *gf_dev)
{
	int ret = 0;

	gpio_direction_input(gf_dev->irq_gpio);
	ret = pinctrl_select_state(gf_dev->gf_pctrl.pinctrl,
		gf_dev->gf_pctrl.gpio_int_active);
	gf_irq_op(gf_dev->irq, GF_INT_ENABLE);
}
static void otg_int_init(void)
{
#ifdef ID_PIN_USE_EX_EINT
	int	ret = 0;
#ifndef CONFIG_MTK_FPGA
	#ifdef CONFIG_OF
	#if defined(CONFIG_MTK_LEGACY)
	mt_set_gpio_mode(iddig_pin, iddig_pin_mode);
	mt_set_gpio_dir(iddig_pin, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(iddig_pin, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(iddig_pin, GPIO_PULL_UP);
	#else
	pr_debug("****%s:%d before Init IDDIG KS!!!!!\n", __func__, __LINE__);

	pinctrl_iddig = pinctrl_lookup_state(pinctrl, "iddig_irq_init");
	if (IS_ERR(pinctrl_iddig)) {
		ret = PTR_ERR(pinctrl_iddig);
		dev_err(mtk_musb->controller, "Cannot find usb pinctrl iddig_irq_init\n");
	}

	pinctrl_select_state(pinctrl, pinctrl_iddig);

	pr_debug("****%s:%d end Init IDDIG KS!!!!!\n", __func__, __LINE__);
	#endif
	#else
	mt_set_gpio_mode(GPIO_OTG_IDDIG_EINT_PIN, GPIO_OTG_IDDIG_EINT_PIN_M_IDDIG);
	mt_set_gpio_dir(GPIO_OTG_IDDIG_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_OTG_IDDIG_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_OTG_IDDIG_EINT_PIN, GPIO_PULL_UP);
	#endif
#endif
	#if defined(CONFIG_MTK_LEGACY)
	mt_gpio_set_debounce(IDDIG_EINT_PIN, 64000);
	usb_iddig_number = mt_gpio_to_irq(IDDIG_EINT_PIN);
	pr_debug("USB IDDIG IRQ LINE %d, %d!!\n", IDDIG_EINT_PIN, mt_gpio_to_irq(IDDIG_EINT_PIN));
	ret = request_irq(usb_iddig_number, mt_usb_ext_iddig_int, IRQF_TRIGGER_LOW, "USB_IDDIG", NULL);
	#else
	/*gpio_request(iddig_pin, "USB_IDDIG");*/
	gpio_set_debounce(iddig_pin, 64000);
	usb_iddig_number = mt_gpio_to_irq(iddig_pin);
	ret = request_irq(usb_iddig_number, mt_usb_ext_iddig_int, IRQF_TRIGGER_LOW, "USB_IDDIG", NULL);
	#endif
	if (ret > 0)
		pr_err("USB IDDIG IRQ LINE not available!!\n");
	else
		pr_debug("USB IDDIG IRQ LINE available!!\n");
#else
	u32 phy_id_pull = 0;

	phy_id_pull = __raw_readl(U2PHYDTM1);
	phy_id_pull |= ID_PULL_UP;
	__raw_writel(phy_id_pull, U2PHYDTM1);

	musb_writel(mtk_musb->mregs, USB_L1INTM, IDDIG_INT_STATUS|musb_readl(mtk_musb->mregs, USB_L1INTM));
#endif
}
/*
 * use SEL_I2C2 to configure [email protected] to set/unset LS_OE and CT_HPD, and use
 * SEL_HDMI to read edid via the HDMI ddc lines
 */
static void hdmi_i2c2_hack_demux(struct device *dev, int sel)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct panel_drv_data *ddata = platform_get_drvdata(pdev);

	/*
	 * switch to I2C2 or HDMI DDC internal pinmux and drive MCASP8_AXR2
	 * to low or high to select I2C2 or HDMI path respectively
	 */
	if (sel == SEL_I2C2) {
		pinctrl_select_state(ddata->pins, ddata->pin_state_i2c);
		dra7_mcasp_hdmi_gpio_set(mcasp, false);
	} else {
		pinctrl_select_state(ddata->pins, ddata->pin_state_ddc);
		dra7_mcasp_hdmi_gpio_set(mcasp, true);
	}

	/* let it propogate */
	udelay(5);
}