/*
 **************************************************************************
 * FunctionName: ispv1_io_hw_init;
 * Description : ispio & csi init;
 * Input       : pdev: used to get resource
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
int ispv1_io_hw_init(struct platform_device *pdev)
{
	int ret = 0;

	print_debug("enter %s, pdev[%p]", __func__, pdev);

	ispv1_io_set_default();

	ispv1_io.pdev = pdev;


    /* pinctrl enable */
	ispv1_io.isp_pinctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR(ispv1_io.isp_pinctrl)) {
	    print_error("%s :could not get pinctrl\n",__FUNCTION__);
		return ret;
	}

	ispv1_io.pinctrl_def = pinctrl_lookup_state(ispv1_io.isp_pinctrl,PINCTRL_STATE_DEFAULT);
    if (IS_ERR(ispv1_io.pinctrl_def)) {
        print_error("%s : could not get def state\n", __FUNCTION__);
    }
	ispv1_io.pinctrl_idle = pinctrl_lookup_state(ispv1_io.isp_pinctrl,PINCTRL_STATE_IDLE);
	if (IS_ERR(ispv1_io.pinctrl_idle)) {
        print_error("%s : could not get idle state\n", __FUNCTION__);
    }


	return ret;
}
static int nfc_pinctrl_init(struct device *dev)
{
	bcm2079x_pctrl.pinctrl = devm_pinctrl_get(dev);

	if (IS_ERR_OR_NULL(bcm2079x_pctrl.pinctrl)) {
		pr_err("%s:%d Getting pinctrl handle failed\n",
			__func__, __LINE__);
		return -EINVAL;
	}
	bcm2079x_pctrl.nfc_gpio_state_active = pinctrl_lookup_state(
					       bcm2079x_pctrl.pinctrl,
					       BCM2079X_STATE_ACTIVE);

	if (IS_ERR_OR_NULL(bcm2079x_pctrl.nfc_gpio_state_active)) {
		pr_err("%s:%d Failed to get the active state pinctrl handle\n",
			__func__, __LINE__);
		return -EINVAL;
	}
	bcm2079x_pctrl.nfc_gpio_state_suspend = pinctrl_lookup_state(
						 bcm2079x_pctrl.pinctrl,
						BCM2079X_STATE_SUSPEND);

	if (IS_ERR_OR_NULL(bcm2079x_pctrl.nfc_gpio_state_active)) {
		pr_err("%s:%d Failed to get the suspend state pinctrl handle\n",
				__func__, __LINE__);
		return -EINVAL;
	}
	return 0;
}
static int mdss_dsi_pinctrl_init(struct platform_device *pdev)
{
	struct mdss_dsi_ctrl_pdata *ctrl_pdata;

	ctrl_pdata = platform_get_drvdata(pdev);
	ctrl_pdata->pin_res.pinctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR_OR_NULL(ctrl_pdata->pin_res.pinctrl)) {
		pr_err("%s: failed to get pinctrl\n", __func__);
		return PTR_ERR(ctrl_pdata->pin_res.pinctrl);
	}

	ctrl_pdata->pin_res.gpio_state_active
		= pinctrl_lookup_state(ctrl_pdata->pin_res.pinctrl,
				MDSS_PINCTRL_STATE_DEFAULT);
	if (IS_ERR_OR_NULL(ctrl_pdata->pin_res.gpio_state_active))
		pr_warn("%s: can not get default pinstate\n", __func__);

	ctrl_pdata->pin_res.gpio_state_suspend
		= pinctrl_lookup_state(ctrl_pdata->pin_res.pinctrl,
				MDSS_PINCTRL_STATE_SLEEP);
	if (IS_ERR_OR_NULL(ctrl_pdata->pin_res.gpio_state_suspend))
		pr_warn("%s: can not get sleep pinstate\n", __func__);

	return 0;
}
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;
}
Beispiel #5
0
int gf_init_pinctrl(struct gf_dev *gf_dev, struct device *dev)
{
    GF_LOG_INFO("start\n");

	gf_dev->gf_pctrl.pinctrl= devm_pinctrl_get(dev);
	if (IS_ERR_OR_NULL(gf_dev->gf_pctrl.pinctrl)) {
        GF_LOG_ERROR("failed to get pinctrl handle\n");
        return -EINVAL;
    }

	gf_dev->gf_pctrl.gpio_state_active = pinctrl_lookup_state(gf_dev->gf_pctrl.pinctrl,
		"gf_active");
	if (IS_ERR_OR_NULL(gf_dev->gf_pctrl.gpio_state_active)) {
		GF_LOG_ERROR("failed to get active state pinctrl handle\n");
		return -EINVAL;
	}

	gf_dev->gf_pctrl.gpio_state_suspend = pinctrl_lookup_state(gf_dev->gf_pctrl.pinctrl,
		"gf_suspend");
	if (IS_ERR_OR_NULL(gf_dev->gf_pctrl.gpio_state_suspend)) {
		GF_LOG_ERROR("failed to get suspend state pinctrl handle\n");
		return -EINVAL;
	}

	gf_dev->gf_pctrl.gpio_int_active = pinctrl_lookup_state(gf_dev->gf_pctrl.pinctrl,
		"gf_int_active");
	if (IS_ERR_OR_NULL(gf_dev->gf_pctrl.gpio_int_active)) {
		GF_LOG_ERROR("failed to get int active state pinctrl handle\n");
		return -EINVAL;
	}

    GF_LOG_INFO("success\n");

	return 0;
}
static int cod3022x_i2c_probe(struct i2c_client *i2c,
		const struct i2c_device_id *id)
{
	struct cod3022x_priv *cod3022x;
	struct pinctrl *pinctrl;
	int ret;

	cod3022x = kzalloc(sizeof(struct cod3022x_priv), GFP_KERNEL);
	if (cod3022x == NULL)
		return -ENOMEM;
	cod3022x->dev = &i2c->dev;

	cod3022x->regmap = devm_regmap_init_i2c(i2c, &cod3022x_regmap);
	if (IS_ERR(cod3022x->regmap)) {
		dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
		return PTR_ERR(cod3022x->regmap);
	}

	pinctrl = devm_pinctrl_get(&i2c->dev);
	if (IS_ERR(pinctrl)) {
		dev_warn(&i2c->dev, "did not get pins for codec: %li\n",
							PTR_ERR(pinctrl));
	} else {
		cod3022x->pinctrl = pinctrl;
	}

	i2c_set_clientdata(i2c, cod3022x);

	ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_cod3022x,
			cod3022x_dai, ARRAY_SIZE(cod3022x_dai));
	if (ret < 0)
		dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);

	return ret;
}
Beispiel #7
0
static int tegra_sdhci_init_pinctrl_info(struct device *dev,
					 struct sdhci_tegra *tegra_host)
{
	tegra_host->pinctrl_sdmmc = devm_pinctrl_get(dev);
	if (IS_ERR(tegra_host->pinctrl_sdmmc)) {
		dev_dbg(dev, "No pinctrl info, err: %ld\n",
			PTR_ERR(tegra_host->pinctrl_sdmmc));
		return -1;
	}

	tegra_host->pinctrl_state_3v3 =
		pinctrl_lookup_state(tegra_host->pinctrl_sdmmc, "sdmmc-3v3");
	if (IS_ERR(tegra_host->pinctrl_state_3v3)) {
		dev_warn(dev, "Missing 3.3V pad state, err: %ld\n",
			 PTR_ERR(tegra_host->pinctrl_state_3v3));
		return -1;
	}

	tegra_host->pinctrl_state_1v8 =
		pinctrl_lookup_state(tegra_host->pinctrl_sdmmc, "sdmmc-1v8");
	if (IS_ERR(tegra_host->pinctrl_state_1v8)) {
		dev_warn(dev, "Missing 1.8V pad state, err: %ld\n",
			 PTR_ERR(tegra_host->pinctrl_state_1v8));
		return -1;
	}

	tegra_host->pad_control_available = true;

	return 0;
}
static int msm_flash_pinctrl_init(struct msm_led_flash_ctrl_t *ctrl)
{
    struct msm_pinctrl_info *flash_pctrl = NULL;

    flash_pctrl = &ctrl->pinctrl_info;
    flash_pctrl->pinctrl = devm_pinctrl_get(&ctrl->flash_i2c_client->client->dev);

    if (IS_ERR_OR_NULL(flash_pctrl->pinctrl)) {
        pr_err("%s:%d Getting pinctrl handle failed\n",
               __func__, __LINE__);
        return -EINVAL;
    }
    flash_pctrl->gpio_state_active = pinctrl_lookup_state(
                                         flash_pctrl->pinctrl,
                                         CAM_FLASH_PINCTRL_STATE_DEFAULT);

    if (IS_ERR_OR_NULL(flash_pctrl->gpio_state_active)) {
        pr_err("%s:%d Failed to get the active state pinctrl handle\n",
               __func__, __LINE__);
        return -EINVAL;
    }
    flash_pctrl->gpio_state_suspend = pinctrl_lookup_state(
                                          flash_pctrl->pinctrl,
                                          CAM_FLASH_PINCTRL_STATE_SLEEP);

    if (IS_ERR_OR_NULL(flash_pctrl->gpio_state_suspend)) {
        pr_err("%s:%d Failed to get the suspend state pinctrl handle\n",
               __func__, __LINE__);
        return -EINVAL;
    }
    return 0;
}
Beispiel #9
0
static int cyttsp4_pinctrl_init(struct cyttsp4_core_platform_data *data, int on, struct device *dev)
{
	if (!on) {
		goto pinctrl_put;
	}

	data->pinctrl = devm_pinctrl_get(dev->parent);
	if (IS_ERR_OR_NULL(data->pinctrl)) {
		dev_err(dev, "%s:failed to get pinctrl!\n", __func__);
		return PTR_ERR(data->pinctrl);
	}

	data->gpio_state_active = pinctrl_lookup_state(data->pinctrl, "pmx_ts_active");
	if (IS_ERR_OR_NULL(data->gpio_state_active)) {
		dev_err(dev, "%s:failed to look up pmx_ts_active state!\n", __func__);
		return PTR_ERR(data->gpio_state_active);
	}

	data->gpio_state_suspend = pinctrl_lookup_state(data->pinctrl, "pmx_ts_suspend");
	if (IS_ERR_OR_NULL(data->gpio_state_suspend)) {
		dev_err(dev, "%s:failed to look up pmx_ts_suspend state!\n", __func__);
		return PTR_ERR(data->gpio_state_suspend);
	}

	return 0;

pinctrl_put:
	devm_pinctrl_put(data->pinctrl);
	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;
}
Beispiel #11
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;
}
static int sms_power_ctrl_of_get_pinctrl(struct device *dev)
{
	pr_info("sms_power_ctrl_of_get_pinctrl\n");
	pinctrl_info.pinctrl = devm_pinctrl_get(dev);
	if (IS_ERR(pinctrl_info.pinctrl)) {
		pr_err("%s:failed to get pinctrl\n", __func__);
		return PTR_ERR(pinctrl_info.pinctrl);
	}
#if  0
	pinctrl_info.sms_pins_active = pinctrl_lookup_state(pinctrl_info.pinctrl,
					PINCTRL_STATE_ACTIVE);
	if (IS_ERR(pinctrl_info.sms_pins_active)) {
		pr_err("%s Can not get sms power control gpio default pinstate\n", __func__);
		return PTR_ERR(pinctrl_info.sms_pins_active);
	}

	pinctrl_info.sms_pins_suspend = pinctrl_lookup_state(pinctrl_info.pinctrl,
					PINCTRL_STATE_SUSPEND);
	if (IS_ERR(pinctrl_info.sms_pins_suspend)) {
		pr_err("%s Can not get sms power control gpio suspend pinstate\n", __func__);
		return PTR_ERR(pinctrl_info.sms_pins_suspend);
	}
#endif
	return 0;
}
static void get_pintctrl(struct device *dev)
{
	if (!pins) {
		pins = devm_pinctrl_get(dev);
		if (!pins)
			pr_err("%s: failed to get pinctrl\n", __func__);
	}

	if (!state_default) {
		state_default = pinctrl_lookup_state(pins, "default");
		if (!state_default)
			pr_err("%s: failed to get default pinctrl\n", __func__);
	}

#if defined(CONFIG_FB_I80_COMMAND_MODE) && !defined(CONFIG_FB_I80_SW_TRIGGER)
	if (!state_turnon_tes) {
		state_turnon_tes = pinctrl_lookup_state(pins, "turnon_tes");
		if (!state_turnon_tes)
			pr_err("%s: failed to get default pinctrl\n", __func__);
	}

	if (!state_turnoff_tes) {
		state_turnoff_tes = pinctrl_lookup_state(pins, "turnoff_tes");
		if (!state_turnoff_tes)
			pr_err("%s: failed to get default pinctrl\n", __func__);
	}
#endif
}
static int tpd_init_pins(struct platform_device *pdev)
{
	struct panel_drv_data *ddata = platform_get_drvdata(pdev);
	struct device_node *node;

	ddata->pins = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR(ddata->pins))
		return PTR_ERR(ddata->pins);

	ddata->pin_state_i2c = pinctrl_lookup_state(ddata->pins, "i2c");
	if (IS_ERR(ddata->pin_state_i2c))
		return PTR_ERR(ddata->pin_state_i2c);

	ddata->pin_state_ddc = pinctrl_lookup_state(ddata->pins, "ddc");
	if (IS_ERR(ddata->pin_state_ddc))
		return PTR_ERR(ddata->pin_state_ddc);

	node = of_parse_phandle(pdev->dev.of_node, "ddc-i2c-bus", 0);
	if (!node)
		return -ENODEV;

	ddata->ddc_i2c_adapter = of_find_i2c_adapter_by_node(node);
	if (!ddata->ddc_i2c_adapter)
		return -ENODEV;

	return 0;
}
Beispiel #16
0
static int cyttsp3_pinctrl_init(struct device *dev)
{
	cyttsp3_pctrl.pinctrl = devm_pinctrl_get(dev);

	if (IS_ERR_OR_NULL(cyttsp3_pctrl.pinctrl)) {
		pr_err("%s:%d Getting pinctrl handle failed\n",
			__func__, __LINE__);
		return -EINVAL;
	}
	cyttsp3_pctrl.gpio_state_active = pinctrl_lookup_state(
					       cyttsp3_pctrl.pinctrl,
					       CY_PINCTRL_STATE_DEFAULT);

	if (IS_ERR_OR_NULL(cyttsp3_pctrl.gpio_state_active)) {
		pr_err("%s:%d Failed to get the active state pinctrl handle\n",
			__func__, __LINE__);
		return -EINVAL;
	}
	cyttsp3_pctrl.gpio_state_suspend = pinctrl_lookup_state(
						cyttsp3_pctrl.pinctrl,
						CY_PINCTRL_STATE_SLEEP);

	if (IS_ERR_OR_NULL(cyttsp3_pctrl.gpio_state_suspend)) {
		pr_err("%s:%d Failed to get the suspend state pinctrl handle\n",
				__func__, __LINE__);
		return -EINVAL;
	}
	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;
}
static int msm_camera_pinctrl_init(struct msm_camera_power_ctrl_t *ctrl)
{
	struct msm_pinctrl_info *sensor_pctrl = NULL;

	sensor_pctrl = &ctrl->pinctrl_info;
	sensor_pctrl->pinctrl = devm_pinctrl_get(ctrl->dev);
	if (IS_ERR_OR_NULL(sensor_pctrl->pinctrl)) {
		pr_err("%s:%d Getting pinctrl handle failed\n",
			__func__, __LINE__);
		return -EINVAL;
	}
	sensor_pctrl->gpio_state_active =
		pinctrl_lookup_state(sensor_pctrl->pinctrl,
				CAM_SENSOR_PINCTRL_STATE_DEFAULT);
	if (IS_ERR_OR_NULL(sensor_pctrl->gpio_state_active)) {
		pr_err("%s:%d Failed to get the active state pinctrl handle\n",
			__func__, __LINE__);
		return -EINVAL;
	}
	sensor_pctrl->gpio_state_suspend
		= pinctrl_lookup_state(sensor_pctrl->pinctrl,
				CAM_SENSOR_PINCTRL_STATE_SLEEP);
	if (IS_ERR_OR_NULL(sensor_pctrl->gpio_state_suspend)) {
		pr_err("%s:%d Failed to get the suspend state pinctrl handle\n",
				__func__, __LINE__);
		return -EINVAL;
	}
	return 0;
}
int mtkcam_gpio_init(struct platform_device *pdev)
{
	int ret = 0;
	camctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR(camctrl)) {
		dev_err(&pdev->dev, "Cannot find camera pinctrl!");
		ret = PTR_ERR(camctrl);
	}

	cam0_rst_h = pinctrl_lookup_state(camctrl, "cam0_rst1");
	if (IS_ERR(cam0_rst_h)) {
		ret = PTR_ERR(cam0_rst_h);
		pr_debug("%s : pinctrl err, cam0_rst_h\n", __func__);
	}

	cam0_rst_l = pinctrl_lookup_state(camctrl, "cam0_rst0");
	if (IS_ERR(cam0_rst_l)) {
		ret = PTR_ERR(cam0_rst_l);
		pr_debug("%s : pinctrl err, cam0_rst_l\n", __func__);
	}

	cam1_rst_h = pinctrl_lookup_state(camctrl, "cam1_rst1");
	if (IS_ERR(cam1_rst_h)) {
		ret = PTR_ERR(cam1_rst_h);
		pr_debug("%s : pinctrl err, cam1_rst_h\n", __func__);
	}

	cam1_rst_l = pinctrl_lookup_state(camctrl, "cam1_rst0");
	if (IS_ERR(cam1_rst_l)) {
		ret = PTR_ERR(cam1_rst_l);
		pr_debug("%s : pinctrl err, cam1_rst_l\n", __func__);
	}
	return ret;
}
static int si47xx_get_pinctrl_configs(struct si47xx_platform_data *pdata, struct device *dev)
{
	pdata->si47xx_pinctrl = devm_pinctrl_get(dev);
	if (IS_ERR_OR_NULL(pdata->si47xx_pinctrl)) {
		if (PTR_ERR(pdata->si47xx_pinctrl) == -EPROBE_DEFER)
			return -EPROBE_DEFER;

		pr_err("%s: Target does not use pinctrl\n", __func__);
		return -EINVAL;
	}

	pdata->si47xx_rst_default = pinctrl_lookup_state(pdata->si47xx_pinctrl, 
		"si4705_rst_pins_default");
	if (IS_ERR(pdata->si47xx_rst_default)) {
		pr_err("%s: could not get default pinstate\n", __func__);
		goto pinctrl_fail;
	}
	
	pdata->si47xx_rst_active = pinctrl_lookup_state(pdata->si47xx_pinctrl, 
		"si4705_rst_pins_active");
	if (IS_ERR(pdata->si47xx_rst_active)) {
		pr_err("%s: could not get active pinstate\n", __func__);
		goto pinctrl_fail;
	}

	pdata->si47xx_rst_suspend = pinctrl_lookup_state(pdata->si47xx_pinctrl, 
		"si4705_rst_pins_suspend");
	if (IS_ERR(pdata->si47xx_rst_suspend)) {
		pr_err("%s: could not get suspend pinstate\n", __func__);
		goto pinctrl_fail;
	}

	pdata->si47xx_int_default = pinctrl_lookup_state(pdata->si47xx_pinctrl, 
		"si4705_int_pins_default");
	if (IS_ERR(pdata->si47xx_int_default)) {
		pr_err("%s: could not get default pinstate\n", __func__);
		goto pinctrl_fail;
	}
	
	pdata->si47xx_int_active = pinctrl_lookup_state(pdata->si47xx_pinctrl, 
		"si4705_int_pins_active");
	if (IS_ERR(pdata->si47xx_int_active)) {
		pr_err("%s: could not get active pinstate\n", __func__);
		goto pinctrl_fail;
	}

	pdata->si47xx_int_suspend = pinctrl_lookup_state(pdata->si47xx_pinctrl, 
		"si4705_int_pins_suspend");
	if (IS_ERR(pdata->si47xx_int_suspend)) {
		pr_err("%s: could not get suspend pinstate\n", __func__);
		goto pinctrl_fail;
	}

	return 0;

pinctrl_fail:
	pdata->si47xx_pinctrl = NULL;
	return -EINVAL;
}
Beispiel #21
0
static int apb_ctrl_get_devtree_data(struct platform_device *pdev,
		struct arche_apb_ctrl_drvdata *apb)
{
	struct device *dev = &pdev->dev;
	struct device_node *np = dev->of_node;

	apb->resetn_gpio = of_get_named_gpio(np, "reset-gpios", 0);
	if (apb->resetn_gpio < 0) {
		dev_err(dev, "failed to get reset gpio\n");
		return apb->resetn_gpio;
	}

	apb->boot_ret_gpio = of_get_named_gpio(np, "boot-ret-gpios", 0);
	if (apb->boot_ret_gpio < 0) {
		dev_err(dev, "failed to get boot retention gpio\n");
		return apb->boot_ret_gpio;
	}

	/* It's not mandatory to support power management interface */
	apb->pwroff_gpio = of_get_named_gpio(np, "pwr-off-gpios", 0);
	if (apb->pwroff_gpio < 0) {
		dev_err(dev, "failed to get power off gpio\n");
		return apb->pwroff_gpio;
	}

	/* Do not make clock mandatory as of now (for DB3) */
	apb->clk_en_gpio = of_get_named_gpio(np, "clock-en-gpio", 0);
	if (apb->clk_en_gpio < 0)
		dev_warn(dev, "failed to get clock en gpio\n");

	apb->pwrdn_gpio = of_get_named_gpio(np, "pwr-down-gpios", 0);
	if (apb->pwrdn_gpio < 0)
		dev_warn(dev, "failed to get power down gpio\n");

	/* Regulators are optional, as we may have fixed supply coming in */
	apb->vcore = devm_regulator_get(dev, "vcore");
	if (IS_ERR(apb->vcore))
		dev_warn(dev, "no core regulator found\n");

	apb->vio = devm_regulator_get(dev, "vio");
	if (IS_ERR(apb->vio))
		dev_warn(dev, "no IO regulator found\n");

	apb->pinctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR(apb->pinctrl)) {
		dev_err(&pdev->dev, "could not get pinctrl handle\n");
		return PTR_ERR(apb->pinctrl);
	}
	apb->pin_default = pinctrl_lookup_state(apb->pinctrl, "default");
	if (IS_ERR(apb->pin_default)) {
		dev_err(&pdev->dev, "could not get default pin state\n");
		return PTR_ERR(apb->pin_default);
	}

	return 0;
}
Beispiel #22
0
static int asc_init_port(struct asc_port *ascport,
			  struct platform_device *pdev)
{
	struct uart_port *port = &ascport->port;
	struct resource *res;
	int ret;

	port->iotype	= UPIO_MEM;
	port->flags	= UPF_BOOT_AUTOCONF;
	port->ops	= &asc_uart_ops;
	port->fifosize	= ASC_FIFO_SIZE;
	port->dev	= &pdev->dev;
	port->irq	= platform_get_irq(pdev, 0);

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	port->membase = devm_ioremap_resource(&pdev->dev, res);
	if (IS_ERR(port->membase))
		return PTR_ERR(port->membase);
	port->mapbase = res->start;

	spin_lock_init(&port->lock);

	ascport->clk = devm_clk_get(&pdev->dev, NULL);

	if (WARN_ON(IS_ERR(ascport->clk)))
		return -EINVAL;
	/* ensure that clk rate is correct by enabling the clk */
	clk_prepare_enable(ascport->clk);
	ascport->port.uartclk = clk_get_rate(ascport->clk);
	WARN_ON(ascport->port.uartclk == 0);
	clk_disable_unprepare(ascport->clk);

	ascport->pinctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR(ascport->pinctrl)) {
		ret = PTR_ERR(ascport->pinctrl);
		dev_err(&pdev->dev, "Failed to get Pinctrl: %d\n", ret);
		return ret;
	}

	ascport->states[DEFAULT] =
		pinctrl_lookup_state(ascport->pinctrl, "default");
	if (IS_ERR(ascport->states[DEFAULT])) {
		ret = PTR_ERR(ascport->states[DEFAULT]);
		dev_err(&pdev->dev,
			"Failed to look up Pinctrl state 'default': %d\n", ret);
		return ret;
	}

	/* "no-hw-flowctrl" state is optional */
	ascport->states[NO_HW_FLOWCTRL] =
		pinctrl_lookup_state(ascport->pinctrl, "no-hw-flowctrl");
	if (IS_ERR(ascport->states[NO_HW_FLOWCTRL]))
		ascport->states[NO_HW_FLOWCTRL] = NULL;

	return 0;
}
static int sim_state_init(struct hisi_sim_hotplug_info *info, struct device *dev)
{
	int err = 0;

	info->pctrl = devm_pinctrl_get(dev);
	if (IS_ERR(info->pctrl)) {
		dev_err(dev, "failed to devm pinctrl get\n");
		err = -EINVAL;
		return err;
	}

	info->sim_default = pinctrl_lookup_state(info->pctrl, PINCTRL_STATE_DEFAULT);
	if (IS_ERR(info->sim_default)) {
		dev_err(dev, "failed to pinctrl lookup state default\n");
		err = -EINVAL;
		return err;
	}

	info->sim_idle = pinctrl_lookup_state(info->pctrl, PINCTRL_STATE_IDLE);
	if (IS_ERR(info->sim_idle)) {
		dev_err(dev, "failed to pinctrl lookup state idle\n");
		err = -EINVAL;
		return err;
	}

	if (!gpio_get_value(info->det_gpio)) {
		info->old_det_gpio_state = 0;
		if (NORMAL_CLOSE == info->det_direction) {
			info->sim_pluged = SIM_CARD_OUT;
			sim_set_inactive(info);
			set_sim_status(info, info->sim_id, info->sim_pluged, 3, NO_NOTIFY);
		} else {
			info->sim_pluged = SIM_CARD_IN;
			sim_set_active(info);
			set_sim_status(info, info->sim_id, info->sim_pluged, 2, NO_NOTIFY);
		}
	} else {
		info->old_det_gpio_state = 1;
		if (NORMAL_CLOSE == info->det_direction) {
			info->sim_pluged = SIM_CARD_IN;
			sim_set_active(info);
			set_sim_status(info, info->sim_id, info->sim_pluged, 2, NO_NOTIFY);
		} else {
			info->sim_pluged = SIM_CARD_OUT;
			sim_set_inactive(info);
			set_sim_status(info, info->sim_id, info->sim_pluged, 3, NO_NOTIFY);
		}
	}

	mutex_init(&(info->sim_hotplug_lock));
	wake_lock_init(&info->sim_hotplug_wklock, WAKE_LOCK_SUSPEND, "android-simhotplug");

	return 0;
}
void mt_usb_otg_init(struct musb *musb)
{
#ifdef CONFIG_OF
	usb_node = of_find_compatible_node(NULL, NULL, "mediatek,mt6735-usb20");
	if (usb_node == NULL) {
		pr_err("USB OTG - get USB0 node failed\n");
	} else {
		if (of_property_read_u32_index(usb_node, "iddig_gpio", 0, &iddig_pin)) {
			iddig_if_config = 0;
			pr_err("get dtsi iddig_pin fail\n");
		}
		if (of_property_read_u32_index(usb_node, "iddig_gpio", 1, &iddig_pin_mode))
			pr_err("get dtsi iddig_pin_mode fail\n");
		if (of_property_read_u32_index(usb_node, "drvvbus_gpio", 0, &drvvbus_pin)) {
			drvvbus_if_config = 0;
			pr_err("get dtsi drvvbus_pin fail\n");
		}
		if (of_property_read_u32_index(usb_node, "drvvbus_gpio", 1, &drvvbus_pin_mode))
			pr_err("get dtsi drvvbus_pin_mode fail\n");
		#if defined(CONFIG_MTK_LEGACY)
		iddig_pin |= 0x80000000;
		drvvbus_pin |= 0x80000000;
		#endif
	}

	#if !defined(CONFIG_MTK_LEGACY)
	pinctrl = devm_pinctrl_get(mtk_musb->controller);
	if (IS_ERR(pinctrl)) {
		dev_err(mtk_musb->controller, "Cannot find usb pinctrl!\n");
	}
	#endif
#endif
	/*init drrvbus*/
	mt_usb_init_drvvbus();

	/* init idpin interrupt */
	INIT_DELAYED_WORK(&musb->id_pin_work, musb_id_pin_work);
	otg_int_init();

	/* EP table */
	musb->fifo_cfg_host = fifo_cfg_host;
	musb->fifo_cfg_host_size = ARRAY_SIZE(fifo_cfg_host);

	otg_state.name = "otg_state";
	otg_state.index = 0;
	otg_state.state = 0;

	if (switch_dev_register(&otg_state))
		pr_err("switch_dev_register fail\n");
	else
		pr_debug("switch_dev register success\n");
}
Beispiel #25
0
static int fih_hwid_probe(struct platform_device *pdev)
{

  struct device *dev = &pdev->dev;
  struct pinctrl *hwid_pinctrl;
  struct pinctrl_state *init_state;
  int i,rc=0;

  hwid_pinctrl=devm_pinctrl_get(dev);
  rc = IS_ERR(hwid_pinctrl);
  if(rc)
  {
    if (PTR_ERR(hwid_pinctrl) == -EPROBE_DEFER)
    {
      rc = -EPROBE_DEFER;
    }
    pr_debug("FIH HWID does not use pinctrl\n");
    hwid_pinctrl = NULL;
    goto fail;
  }

  if (hwid_pinctrl)
  {
    init_state=pinctrl_lookup_state(hwid_pinctrl,"init");
    if(IS_ERR(init_state))
    {
      pr_debug("FIH HWID pinctrl can't get init state\n");
      rc = PTR_ERR(init_state);
      goto fail;
    }
  }

  rc = pinctrl_select_state(hwid_pinctrl, init_state);

  if(rc)
  {
    pr_debug("FIH HWID pinctrl can't set init state\n");
    goto fail;
  }

  for (i=0; i<ARRAY_SIZE(HWID_GPIO); i++)
  {
    HWID_GPIO[i].gpio=of_get_named_gpio(dev->of_node, "gpios", i);
  }

  fih_hwid_get();

fail:
  return rc;
};
int ZD550KL_Project_ID_Pin_Pinctrl_Configure(struct device *dev, bool active)
{
	struct pinctrl_state *set_state;
	int retval = 0;
	if (active) {
		set_state =	pinctrl_lookup_state(devm_pinctrl_get(dev), "Project_ID_Pin_active");
		if (IS_ERR(set_state)) {
			printk("cannot get project id pin pinctrl active state\n");
			return PTR_ERR(set_state);
		}
	} else {
		set_state = pinctrl_lookup_state(devm_pinctrl_get(dev), "Project_ID_Pin_suspend");
		if (IS_ERR(set_state)) {
			printk("cannot get project id pin pinctrl sleep state\n");
			return PTR_ERR(set_state);
		}
	}
	retval = pinctrl_select_state(devm_pinctrl_get(dev), set_state);
	if (retval) {
		printk("cannot set project id pin pinctrl active state\n");
		return retval;
	}
	return retval;
}
int bt_enable_pinctrl_init(struct device *dev, struct bluetooth_pm_device_info *bdev)
{
	int ret = 0;

	bdev->gpio_state_active = bdev->gpio_state_suspend = 0;
	bdev->bt_pinctrl = devm_pinctrl_get(dev);
	if (IS_ERR_OR_NULL(bdev->bt_pinctrl)) {
		pr_err("%s: target does not use pinctrl for bt enable\n", __func__);
		return -ENODEV;
	}


	bdev->gpio_state_active = pinctrl_lookup_state(bdev->bt_pinctrl, "bt_enable_active");
	if (IS_ERR_OR_NULL(bdev->gpio_state_active)) {
		pr_err("%s: can't get gpio_state_active for bt enable\n", __func__);
		ret = -ENODEV;
		goto err_active_state;
	}

	bdev->gpio_state_suspend = pinctrl_lookup_state(bdev->bt_pinctrl, "bt_enable_suspend");
	if (IS_ERR_OR_NULL(bdev->gpio_state_suspend)) {
		pr_err("%s: can't get gpio_state_suspend for bt enable\n", __func__);
		ret = -ENODEV;
		goto err_suspend_state;
	}

	if (pinctrl_select_state(bdev->bt_pinctrl, bdev->gpio_state_suspend)) { 
		pr_err("%s: error on pinctrl_select_state for bt enable\n", __func__);
		ret = -ENODEV;
		goto err_suspend_state;
	} else {
	 	printk("%s: success to set pinctrl_select_state for bt enable\n", __func__);
	}
	pr_err("%s: bdev->gpio_bt_reset = %d		bsi->bt_reset = %d	 \n",__func__,bdev->gpio_bt_reset,bsi->bt_reset);
err_suspend_state:
	bdev->gpio_state_suspend = 0;

err_active_state:
	bdev->gpio_state_active = 0;
	devm_pinctrl_put(bdev->bt_pinctrl);
	bdev->bt_pinctrl = 0;
	
	return ret;	

}
static INT32 mtk_wmt_probe(struct platform_device *pdev)
{
#if !defined(CONFIG_MTK_CLKMGR)
	clk_scp_conn_main = devm_clk_get(&pdev->dev, "conn");
	if (IS_ERR(clk_scp_conn_main)) {
		WMT_PLAT_ERR_FUNC("[CCF]cannot get clk_scp_conn_main clock.\n");
		return PTR_ERR(clk_scp_conn_main);
	}
	WMT_PLAT_DBG_FUNC("[CCF]clk_scp_conn_main=%p\n", clk_scp_conn_main);

	clk_infra_conn_main = devm_clk_get(&pdev->dev, "bus");
	if (IS_ERR(clk_infra_conn_main)) {
		WMT_PLAT_ERR_FUNC("[CCF]cannot get clk_infra_conn_main clock.\n");
		return PTR_ERR(clk_infra_conn_main);
	}
	WMT_PLAT_DBG_FUNC("[CCF]clk_infra_conn_main=%p\n", clk_infra_conn_main);
#endif /* !defined(CONFIG_MTK_CLKMGR) */

#if CONSYS_PMIC_CTRL_ENABLE
#if !defined(CONFIG_MTK_PMIC_LEGACY)
	reg_VCN18 = regulator_get(&pdev->dev, "vcn18");
	if (!reg_VCN18)
		WMT_PLAT_ERR_FUNC("Regulator_get VCN_1V8 fail\n");
	reg_VCN28 = regulator_get(&pdev->dev, "vcn28");
	if (!reg_VCN28)
		WMT_PLAT_ERR_FUNC("Regulator_get VCN_2V8 fail\n");
	reg_VCN33_BT = regulator_get(&pdev->dev, "vcn33_bt");
	if (!reg_VCN33_BT)
		WMT_PLAT_ERR_FUNC("Regulator_get VCN33_BT fail\n");
	reg_VCN33_WIFI = regulator_get(&pdev->dev, "vcn33_wifi");
	if (!reg_VCN33_WIFI)
		WMT_PLAT_ERR_FUNC("Regulator_get VCN33_WIFI fail\n");
#endif
#endif

#if !defined(CONFIG_MTK_GPIO_LEGACY)
	consys_pinctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR(consys_pinctrl)) {
		WMT_PLAT_ERR_FUNC("cannot find consys pinctrl.\n");
		return PTR_ERR(consys_pinctrl);
	}
#endif /* !defined(CONFIG_MTK_GPIO_LEGACY) */

	return 0;
}
static int cw_bat_pinctrl_init(struct cw_battery *cw_bat)
{
	int retval;

	/* Get pinctrl if target uses pinctrl */
	cw_bat->ts_pinctrl = devm_pinctrl_get(&(cw_bat->client->dev));
	if (IS_ERR_OR_NULL(cw_bat->ts_pinctrl)) {
		retval = PTR_ERR(cw_bat->ts_pinctrl);
		dev_dbg(&cw_bat->client->dev,
			"%s Target does not use pinctrl  %d\n", __func__, retval);
		goto err_pinctrl_get;
	}

	cw_bat->pinctrl_state_active
		= pinctrl_lookup_state(cw_bat->ts_pinctrl,
				PINCTRL_STATE_ACTIVE);
	if (IS_ERR_OR_NULL(cw_bat->pinctrl_state_active)) {
		retval = PTR_ERR(cw_bat->pinctrl_state_active);
		dev_err(&cw_bat->client->dev,
			"%s Can not lookup %s pinstate %d\n",
			__func__, PINCTRL_STATE_ACTIVE, retval);
		goto err_pinctrl_lookup;
	}

	cw_bat->pinctrl_state_suspend
		= pinctrl_lookup_state(cw_bat->ts_pinctrl,
				PINCTRL_STATE_SUSPEND);
	if (IS_ERR_OR_NULL(cw_bat->pinctrl_state_suspend)) {
		retval = PTR_ERR(cw_bat->pinctrl_state_suspend);
		dev_err(&cw_bat->client->dev,
				"%s Can not lookup %s pinstate %d\n",
				__func__, PINCTRL_STATE_SUSPEND, retval);
		goto err_pinctrl_lookup;
	}

	return 0;

err_pinctrl_lookup:
	devm_pinctrl_put(cw_bat->ts_pinctrl);
err_pinctrl_get:
	cw_bat->ts_pinctrl = NULL;
	return retval;
}
int pinctrl_bind_pins(struct device *dev)
{
	int ret;

	dev->pins = devm_kzalloc(dev, sizeof(*(dev->pins)), GFP_KERNEL);
	if (!dev->pins)
		return -ENOMEM;

	dev->pins->p = devm_pinctrl_get(dev);
	if (IS_ERR(dev->pins->p)) {
		dev_dbg(dev, "no pinctrl handle\n");
		ret = PTR_ERR(dev->pins->p);
		goto cleanup_alloc;
	}

	dev->pins->default_state = pinctrl_lookup_state(dev->pins->p,
					PINCTRL_STATE_DEFAULT);
	if (IS_ERR(dev->pins->default_state)) {
		dev_dbg(dev, "no default pinctrl state\n");
		ret = 0;
		goto cleanup_get;
	}

	ret = pinctrl_select_state(dev->pins->p, dev->pins->default_state);
	if (ret) {
		dev_dbg(dev, "failed to activate default pinctrl state\n");
		goto cleanup_get;
	}

	return 0;

cleanup_get:
	devm_pinctrl_put(dev->pins->p);
cleanup_alloc:
	devm_kfree(dev, dev->pins);
	dev->pins = NULL;

	
	if (ret != -EPROBE_DEFER)
		ret = 0;

	return ret;
}