static int dhd_wlan_power(int onoff)
{
#ifdef CONFIG_MACH_A7LTE
	struct pinctrl *pinctrl = NULL;
#endif /* CONFIG_MACH_A7LTE */

	printk(KERN_INFO"------------------------------------------------");
	printk(KERN_INFO"------------------------------------------------\n");
	printk(KERN_INFO"%s Enter: power %s\n", __FUNCTION__, onoff ? "on" : "off");

#ifdef CONFIG_MACH_A7LTE
	if (onoff) {
		pinctrl = devm_pinctrl_get_select(mmc_dev_for_wlan, "sdio_wifi_on");
		if (IS_ERR(pinctrl))
			printk(KERN_INFO "%s WLAN SDIO GPIO control error\n", __FUNCTION__);
		msleep(PINCTL_DELAY);
	}
#endif /* CONFIG_MACH_A7LTE */

	if (gpio_direction_output(wlan_pwr_on, onoff)) {
		printk(KERN_ERR "%s failed to control WLAN_REG_ON to %s\n",
			__FUNCTION__, onoff ? "HIGH" : "LOW");
		return -EIO;
	}

#ifdef CONFIG_MACH_A7LTE
	if (!onoff) {
		pinctrl = devm_pinctrl_get_select(mmc_dev_for_wlan, "sdio_wifi_off");
		if (IS_ERR(pinctrl))
			printk(KERN_INFO "%s WLAN SDIO GPIO control error\n", __FUNCTION__);
	}
#endif /* CONFIG_MACH_A7LTE */

	return 0;
}
static int fimc_is_ois_i2c_config(struct i2c_client *client, bool onoff)
{
	struct pinctrl *pinctrl_i2c = NULL;
	struct device *i2c_dev = NULL;
	struct fimc_is_device_ois *ois_device;
	struct fimc_is_ois_gpio *gpio;

	if (!client) {
		pr_info("%s: client is null\n", __func__);
		return -ENODEV;
	}

	i2c_dev = client->dev.parent->parent;
	ois_device = i2c_get_clientdata(client);
	gpio = &ois_device->gpio;

	if (ois_device->ois_hsi2c_status != onoff) {
		info("%s : ois_hsi2c_stauts(%d),onoff(%d), use_i2c_pinctrl(%d)\n",
			__func__, ois_device->ois_hsi2c_status, onoff, gpio->use_i2c_pinctrl);
		if (onoff) {
			if(gpio->use_i2c_pinctrl) {
				pin_config_set(gpio->pinname, gpio->sda,
					PINCFG_PACK(PINCFG_TYPE_FUNC, gpio->pinfunc_on));
				pin_config_set(gpio->pinname, gpio->scl,
					PINCFG_PACK(PINCFG_TYPE_FUNC, gpio->pinfunc_on));
			}
			pinctrl_i2c = devm_pinctrl_get_select(i2c_dev, "on_i2c");
			if (IS_ERR_OR_NULL(pinctrl_i2c)) {
				printk(KERN_ERR "%s: Failed to configure i2c pin\n", __func__);
			} else {
				devm_pinctrl_put(pinctrl_i2c);
			}
		} else {
			pinctrl_i2c = devm_pinctrl_get_select(i2c_dev, "off_i2c");
			if (IS_ERR_OR_NULL(pinctrl_i2c)) {
				printk(KERN_ERR "%s: Failed to configure i2c pin\n", __func__);
			} else {
				devm_pinctrl_put(pinctrl_i2c);
			}
			if(gpio->use_i2c_pinctrl) {
				pin_config_set(gpio->pinname, gpio->sda,
					PINCFG_PACK(PINCFG_TYPE_FUNC, gpio->pinfunc_off));
				pin_config_set(gpio->pinname, gpio->scl,
					PINCFG_PACK(PINCFG_TYPE_FUNC, gpio->pinfunc_off));
			}
		}
		ois_device->ois_hsi2c_status = onoff;
	}

	return 0;
}
Exemple #3
0
static int hw_lm3642_init(struct hw_flash_ctrl_t *flash_ctrl)
{
	struct hw_lm3642_private_data_t *pdata;
	int rc = 0;

	cam_debug("%s ernter.\n", __func__);

	if (NULL == flash_ctrl) {
		cam_err("%s flash_ctrl is NULL.", __func__);
		return -1;
	}

	pdata = (struct hw_lm3642_private_data_t *)flash_ctrl->pdata;
#if 1
	flash_ctrl->pctrl = devm_pinctrl_get_select(flash_ctrl->dev,
						PINCTRL_STATE_DEFAULT);

	rc = gpio_request(pdata->strobe, "flash-strobe");
	if (rc < 0) {
		cam_err("%s failed to request strobe pin.", __func__);
		return -EIO;
	}
#endif
	return rc;
}
Exemple #4
0
static void aml_m8_pinmux_init(struct snd_soc_card *card)
{
    struct aml_audio_private_data *p_aml_audio;
    const char *str=NULL;
    int ret;
    p_aml_audio = snd_soc_card_get_drvdata(card);
    p_aml_audio->pin_ctl = devm_pinctrl_get_select(card->dev, "aml_snd_m8");



#if USE_EXTERNAL_DAC
#ifndef CONFIG_MESON_TRUSTZONE
    //aml_write_reg32(P_AO_SECURE_REG1,0x00000000);
    aml_clr_reg32_mask(P_AO_SECURE_REG1, ((1<<8) | (1<<1)));
#else
    /* Secure reg can only be accessed in Secure World if TrustZone enabled. */
    //meson_secure_reg_write(P_AO_SECURE_REG1, 0x00000000);
	meson_secure_reg_write(P_AO_SECURE_REG1, meson_secure_reg_read(P_AO_SECURE_REG1) & (~((1<<8) | (1<<1))));
#endif /* CONFIG_MESON_TRUSTZONE */
#endif
    ret = of_property_read_string(card->dev->of_node, "mute_gpio", &str);
    if (ret < 0) {
        printk("aml_snd_m8: faild to get mute_gpio!\n");
    }else{
        p_aml_audio->gpio_mute = amlogic_gpio_name_map_num(str);
        p_aml_audio->mute_inv = of_property_read_bool(card->dev->of_node,"mute_inv");
        amlogic_gpio_request_one(p_aml_audio->gpio_mute,GPIOF_OUT_INIT_HIGH,"mute_spk");
        amlogic_set_value(p_aml_audio->gpio_mute, 0, "mute_spk");

        spk_gpio_mute = p_aml_audio->gpio_mute;
        printk(KERN_INFO"pinmux set : spk_gpio_mute=%d\n",spk_gpio_mute);
    }

    printk("=%s==,aml_m8_pinmux_init done,---%d\n",__func__,p_aml_audio->det_pol_inv);
}
static int hw_lm3646_front_init(struct hw_flash_ctrl_t *flash_ctrl)
{
    struct hw_lm3646_front_private_data_t *pdata;
    int rc = 0;

    cam_debug("%s enter.\n", __func__);

    if (NULL == flash_ctrl) {
        cam_err("%s flash_ctrl is NULL.", __func__);
        return -1;
    }

    pdata = (struct hw_lm3646_front_private_data_t *)flash_ctrl->pdata;
    flash_ctrl->pctrl = devm_pinctrl_get_select(flash_ctrl->dev,
        PINCTRL_STATE_DEFAULT);
    if (NULL == flash_ctrl->pctrl) {
        cam_err("%s failed to set pin.", __func__);
        return -EIO;
    }

    rc = gpio_request(pdata->pin[RESET], "flash-reset");
    if (rc < 0) {
        cam_err("%s failed to request reset pin.", __func__);
        return -EIO;
    }

    hw_lm3646_front_set_pin_reset(flash_ctrl,LOW);
    msleep(LM3646_RESET_HOLD_TIME);

    return rc;
}
Exemple #6
0
int enable_display_driver_power(struct device *dev)
{
	struct display_gpio *gpio;
	struct display_driver *dispdrv;
#if defined(CONFIG_FB_I80_COMMAND_MODE) && !defined(CONFIG_FB_I80_SW_TRIGGER)
	struct pinctrl *pinctrl;
#endif
	int ret = 0;

	dispdrv = get_display_driver();

	gpio = dispdrv->dt_ops.get_display_dsi_reset_gpio();
	gpio_request_one(gpio->id[0], GPIOF_OUT_INIT_HIGH, "lcd_power");
	usleep_range(5000, 6000);
	gpio_free(gpio->id[0]);

	gpio_request_one(gpio->id[1], GPIOF_OUT_INIT_HIGH, "lcd_reset");
	usleep_range(5000, 6000);
	gpio_set_value(gpio->id[1], 0);
	usleep_range(5000, 6000);
	gpio_set_value(gpio->id[1], 1);
	usleep_range(5000, 6000);
	gpio_free(gpio->id[1]);

#if defined(CONFIG_FB_I80_COMMAND_MODE) && !defined(CONFIG_FB_I80_SW_TRIGGER)
	pinctrl = devm_pinctrl_get_select(dev, "turnon_tes");
	if (IS_ERR(pinctrl))
		pr_err("failed to get tes pinctrl - ON");
#endif
	return ret;
}
void s5p_v4l2_int_src_ext_hpd(struct hdmi_device *hdev)
{
	struct pinctrl *pinctrl;

	pinctrl = devm_pinctrl_get_select(hdev->dev, "hdmi_ext_hpd");
	if (IS_ERR(pinctrl))
		dev_err(hdev->dev, "failed to set external hpd interrupt");
}
Exemple #8
0
static void aml_pin_mux_switch(struct platform_device *pdev, unsigned int mode)
{
	struct pinctrl *pin_ctl;
	char *name[2] = {
		"i2s_aml_clk_pins",
		"clear_i2s_clk_pins",
	};
	pin_ctl = devm_pinctrl_get_select(&pdev->dev, name[mode]);
	if (IS_ERR(pin_ctl))
		printk(KERN_ERR"%s pinmux set error!\n",name[mode]);
}
Exemple #9
0
static void isdbt_set_config_poweron(void)
{
#if defined(CONFIG_SEC_GPIO_SETTINGS)
	struct pinctrl *isdbt_pinctrl;

	/* Get pinctrl if target uses pinctrl */
	isdbt_pinctrl = devm_pinctrl_get_select(isdbt_device, "isdbt_gpio_active");
	if (IS_ERR(isdbt_pinctrl)) {
		DPRINTK("Target does not use pinctrl\n");
		isdbt_pinctrl = NULL;
	}
#else
#if defined(CONFIG_MTV_QUALCOMM)
	if(msm_gpiomux_write(dt_pdata->isdbt_spi_mosi, GPIOMUX_ACTIVE, &spi_active_config, NULL) < 0)
		DPRINTK("spi_mosi Port request error!!!\n");
	if(msm_gpiomux_write(dt_pdata->isdbt_spi_miso, GPIOMUX_ACTIVE, &spi_active_config, NULL) < 0)
		DPRINTK("spi_miso Port request error!!!\n");
	if(msm_gpiomux_write(dt_pdata->isdbt_spi_cs, GPIOMUX_ACTIVE, &spi_active_config, NULL) < 0)
		DPRINTK("spi_cs Port request error!!!\n");
	if(msm_gpiomux_write(dt_pdata->isdbt_spi_clk, GPIOMUX_ACTIVE, &spi_active_config, NULL) < 0)
		DPRINTK("spi_clk Port request error!!!\n");

#elif defined(CONFIG_MTV_BROADCOM)

	struct pin_config SdioPinCfgs;

	SdioPinCfgs.name = dt_pdata->isdbt_irq;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.slew_rate_ctrl = 0;
	pinmux_set_pin_config(&SdioPinCfgs);

	SdioPinCfgs.name = dt_pdata->isdbt_rst;
	pinmux_get_pin_config(&SdioPinCfgs);
	SdioPinCfgs.reg.b.input_dis = 1;
	SdioPinCfgs.reg.b.drv_sth = 0;
	SdioPinCfgs.func = PF_GPIO00;
	SdioPinCfgs.reg.b.sel = 4;	
	pinmux_set_pin_config(&SdioPinCfgs);

#elif defined(CONFIG_MTV_SPREADTRUM)
	sprd_restore_spi_pin_cfg();
#endif
#endif

	gpio_direction_output(dt_pdata->isdbt_pwr_en, 0);
	if (gpio_is_valid(dt_pdata->isdbt_pwr_en2))
		gpio_direction_output(dt_pdata->isdbt_pwr_en2, 0);
	if (gpio_is_valid(dt_pdata->isdbt_ant_sel))
		gpio_direction_output(dt_pdata->isdbt_ant_sel, 0);
	if (gpio_is_valid(dt_pdata->isdbt_rst))
		gpio_direction_output(dt_pdata->isdbt_rst, 0);
	gpio_direction_input(dt_pdata->isdbt_irq);
}
Exemple #10
0
static void isdbt_set_config_poweroff(void)
{
#if defined(CONFIG_SEC_GPIO_SETTINGS)
	struct pinctrl *isdbt_pinctrl;
#endif

	gpio_direction_input(dt_pdata->isdbt_pwr_en);
	if (gpio_is_valid(dt_pdata->isdbt_pwr_en2))
		gpio_direction_input(dt_pdata->isdbt_pwr_en2);
	if (gpio_is_valid(dt_pdata->isdbt_ant_sel))
		gpio_direction_input(dt_pdata->isdbt_ant_sel);
	if (gpio_is_valid(dt_pdata->isdbt_rst))
		gpio_direction_input(dt_pdata->isdbt_rst);

#if defined(CONFIG_SEC_GPIO_SETTINGS)
	/* Get pinctrl if target uses pinctrl */
	isdbt_pinctrl = devm_pinctrl_get_select(isdbt_device, "isdbt_gpio_suspend");
	if (IS_ERR(isdbt_pinctrl)) {
		DPRINTK("Target does not use pinctrl\n");
		isdbt_pinctrl = NULL;
	}
#else
#if defined(CONFIG_MTV_QUALCOMM)
	if(msm_gpiomux_write(dt_pdata->isdbt_spi_mosi, GPIOMUX_SUSPENDED, &spi_suspend_config, NULL) < 0)
		DPRINTK("spi_mosi Port request error!!!\n");
	if(msm_gpiomux_write(dt_pdata->isdbt_spi_miso, GPIOMUX_SUSPENDED, &spi_suspend_config, NULL) < 0)
		DPRINTK("spi_miso Port request error!!!\n");
	if(msm_gpiomux_write(dt_pdata->isdbt_spi_cs, GPIOMUX_SUSPENDED, &spi_suspend_config, NULL) < 0)
		DPRINTK("spi_cs Port request error!!!\n");
	if(msm_gpiomux_write(dt_pdata->isdbt_spi_clk, GPIOMUX_SUSPENDED, &spi_suspend_config, NULL) < 0)
		DPRINTK("spi_clk Port request error!!!\n");

#elif defined(CONFIG_MTV_BROADCOM)
	// broadcom
#elif defined(CONFIG_MTV_SPREADTRUM)
	unsigned int reg, value;
	unsigned long flags;
	int i, regs_count;

	regs_count = sizeof(spi_pin_group)/sizeof(struct spi_pin_desc);

	for (i = 0; i < regs_count; i++) {
		reg = spi_pin_group[i].reg;

		local_irq_save(flags);
		value = ((__raw_readl(reg) & ~SPI_PIN_FUNC_MASK) | (SPI_PIN_FUNC_GPIO));
		__raw_writel(value, reg);
		local_irq_restore(flags);
	}
#endif
#endif
}
static void fimc_is_ois_i2c_config(struct i2c_client *client, bool onoff)
{
	struct pinctrl *pinctrl_i2c = NULL;
	struct device *i2c_dev = client->dev.parent->parent;
	struct fimc_is_device_ois *ois_device = i2c_get_clientdata(client);

	if (ois_device->ois_hsi2c_status != onoff) {
		info("%s : ois_hsi2c_stauts(%d),onoff(%d)\n",__func__,
			ois_device->ois_hsi2c_status, onoff);

		if (onoff) {
			pin_config_set(FIMC_IS_SPI_PINNAME, "gpc2-2",
				PINCFG_PACK(PINCFG_TYPE_FUNC, 0));
			pin_config_set(FIMC_IS_SPI_PINNAME, "gpc2-3",
				PINCFG_PACK(PINCFG_TYPE_FUNC, 0));

			pinctrl_i2c = devm_pinctrl_get_select(i2c_dev, "on_i2c");
			if (IS_ERR_OR_NULL(pinctrl_i2c)) {
				printk(KERN_ERR "%s: Failed to configure i2c pin\n", __func__);
			} else {
				devm_pinctrl_put(pinctrl_i2c);
			}
		} else {
			pinctrl_i2c = devm_pinctrl_get_select(i2c_dev, "off_i2c");
			if (IS_ERR_OR_NULL(pinctrl_i2c)) {
				printk(KERN_ERR "%s: Failed to configure i2c pin\n", __func__);
			} else {
				devm_pinctrl_put(pinctrl_i2c);
			}

			pin_config_set(FIMC_IS_SPI_PINNAME, "gpc2-2",
				PINCFG_PACK(PINCFG_TYPE_FUNC, 2));
			pin_config_set(FIMC_IS_SPI_PINNAME, "gpc2-3",
				PINCFG_PACK(PINCFG_TYPE_FUNC, 2));
		}
		ois_device->ois_hsi2c_status = onoff;
	}
}
static int tps61310_init(struct hisi_flash_ctrl_t *flash_ctrl)
{
	struct tps61310_private_data_t *pdata;
	int rc = -1;

	cam_debug("%s ernter.\n", __func__);

	if (NULL == flash_ctrl) {
		cam_err("%s flash_ctrl is NULL.", __func__);
		return -1;
	}

	pdata = (struct tps61310_private_data_t *)flash_ctrl->pdata;

	flash_ctrl->pctrl = devm_pinctrl_get_select(flash_ctrl->dev,
						PINCTRL_STATE_DEFAULT);
	if (NULL == flash_ctrl->pctrl) {
		cam_err("%s failed to set pin.", __func__);
		return -EIO;
	}

	rc = gpio_request(pdata->pin[RESET], "flash-reset");
	if (rc < 0) {
		cam_err("%s failed to request reset pin.", __func__);
		return -EIO;
	}

	rc = gpio_request(pdata->pin[STROBE0], "flash-strobe0");
	if (rc < 0) {
		cam_err("%s failed to request strobe0 pin.", __func__);
		goto err1;
	}

	rc = gpio_request(pdata->pin[STROBE1], "flash-strobe1");
	if (rc < 0) {
		cam_err("%s failed to request strobe1 pin.", __func__);
		goto err2;
	}

	return 0;

err2:
	gpio_free(pdata->pin[STROBE0]);
err1:
	gpio_free(pdata->pin[RESET]);

	return -EIO;
}
Exemple #13
0
static void aml_m6_pinmux_init(struct snd_soc_card *card)
{
    struct aml_audio_private_data *p_aml_audio;
    const char *str;
    int ret;
    p_aml_audio = snd_soc_card_get_drvdata(card);
    p_aml_audio->pin_ctl = devm_pinctrl_get_select(card->dev, "wm8960_audio");
#if HP_DET
    //p_aml_audio->gpio_hp_det = of_get_named_gpio(card->dev->of_node,"wm8960_gpio",0);
    ret = of_property_read_string(card->dev->of_node, "wm8960_gpio", &str);
    if (ret) {
        printk("wm8960: faild to get gpio!\n");
    }
    p_aml_audio->gpio_hp_det = amlogic_gpio_name_map_num(str);
    p_aml_audio->det_pol_inv = of_property_read_bool(card->dev->of_node,"hp_det_inv");
    amlogic_gpio_request_one(p_aml_audio->gpio_hp_det,GPIOF_IN,"wm8960");
#endif
    printk("=%s==,aml_m6_pinmux_init done,---%d\n",__func__,p_aml_audio->det_pol_inv);
}
Exemple #14
0
static int aml_resume_pre(struct snd_soc_card *card)
{
    printk(KERN_INFO "enter %s\n", __func__);
    struct aml_audio_private_data *p_aml_audio;
    p_aml_audio = snd_soc_card_get_drvdata(card);

    if(p_aml_audio->gpio_i2s_m)
        amlogic_gpio_free(p_aml_audio->gpio_i2s_m,"low_mclk");
    if(p_aml_audio->gpio_i2s_s)
        amlogic_gpio_free(p_aml_audio->gpio_i2s_s,"low_sclk");
    if(p_aml_audio->gpio_i2s_r)
        amlogic_gpio_free(p_aml_audio->gpio_i2s_r,"low_lrclk");
    if(p_aml_audio->gpio_i2s_o)
        amlogic_gpio_free(p_aml_audio->gpio_i2s_o,"low_odata");


    p_aml_audio->pin_ctl = devm_pinctrl_get_select(card->dev, "aml_snd_m8");
    return 0;
}
Exemple #15
0
static int hw_lm3642_exit(struct hw_flash_ctrl_t *flash_ctrl)
{
	struct hw_lm3642_private_data_t *pdata;

	cam_debug("%s ernter.\n", __func__);

	if (NULL == flash_ctrl) {
		cam_err("%s flash_ctrl is NULL.", __func__);
		return -1;
	}

	flash_ctrl->func_tbl->flash_off(flash_ctrl);

	pdata = (struct hw_lm3642_private_data_t *)flash_ctrl->pdata;

	gpio_free(pdata->strobe);
	flash_ctrl->pctrl = devm_pinctrl_get_select(flash_ctrl->dev,
						PINCTRL_STATE_IDLE);

	return 0;
}
static int tps61310_exit(struct hisi_flash_ctrl_t *flash_ctrl)
{
	struct tps61310_private_data_t *pdata;

	cam_debug("%s ernter.\n", __func__);

	if (NULL == flash_ctrl) {
		cam_err("%s flash_ctrl is NULL.", __func__);
		return -1;
	}

	pdata = (struct tps61310_private_data_t *)flash_ctrl->pdata;

	flash_ctrl->func_tbl->flash_off(flash_ctrl);

	gpio_free(pdata->pin[STROBE0]);
	gpio_free(pdata->pin[STROBE1]);
	gpio_free(pdata->pin[RESET]);

	flash_ctrl->pctrl = devm_pinctrl_get_select(flash_ctrl->dev,
						PINCTRL_STATE_IDLE);

	return 0;
}
static int max77849_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max77849_dev *max77849;
	struct max77849_platform_data *pdata;
	int ret = 0;
	struct pinctrl *muic_pinctrl;
	dev_info(&i2c->dev, "%s\n", __func__);


	msleep(500);
	max77849 = kzalloc(sizeof(struct max77849_dev), GFP_KERNEL);
	if (max77849 == NULL)
		return -ENOMEM;

	if (i2c->dev.of_node) {
		pdata = devm_kzalloc(&i2c->dev,
				sizeof(struct max77849_platform_data),
				GFP_KERNEL);

		if (!pdata) {
			dev_err(&i2c->dev, "Failed to allocate memory \n");
			ret = -ENOMEM;
			goto err;
		}

		ret = of_max77849_dt(&i2c->dev, pdata);
		if (ret < 0){
			dev_err(&i2c->dev, "Failed to get device of_node \n");
			return ret;
		}

		/*Filling the platform data*/
		pdata->muic_data = &max77849_muic;
#if defined(CONFIG_REGULATOR_MAX77849)
		pdata->num_regulators = MAX77849_REG_MAX;
		pdata->regulators = max77849_regulators,
#endif
		/*pdata update to other modules*/
		i2c->dev.platform_data = pdata;
		muic_pinctrl = devm_pinctrl_get_select(&i2c->dev,
			"muic_i2c_active");
		if (IS_ERR(muic_pinctrl)) {
			if (PTR_ERR(muic_pinctrl) == -EPROBE_DEFER)
				return -EPROBE_DEFER;

			pr_debug("Target does not use pinctrl\n");
			muic_pinctrl = NULL;
		}
	} else {
		pdata = i2c->dev.platform_data;
	}

	i2c_set_clientdata(i2c, max77849);
	max77849->dev = &i2c->dev;
	max77849->i2c = i2c;
	max77849->irq = i2c->irq;
	if (pdata) {
		max77849->irq_base = pdata->irq_base;
		max77849->irq_gpio = pdata->irq_gpio;
#ifdef CONFIG_MUIC_RESET_PIN_ENABLE
		if (muic_reset_pin)
		{
			max77849->irq_reset_gpio = pdata->irq_reset_gpio;
			gpio_tlmm_config(GPIO_CFG(max77849->irq_reset_gpio,  0, GPIO_CFG_INPUT,
				GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_DISABLE);
		}
#endif

	} else {
		goto err;
	}

	mutex_init(&max77849->iolock);

	/* No active discharge on safeout ldo 1,2 */
	max77849_update_reg(i2c, MAX77849_CHG_REG_SAFEOUT_CTRL, 0x00, 0x30);
	pr_info("%s: i2c->name=%s irq=%d   !!!\n",__func__, i2c->name, i2c->irq);

	max77849->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
	i2c_set_clientdata(max77849->muic, max77849);

	ret = max77849_irq_init(max77849);
	if (ret < 0)
		goto err_irq_init;

	ret = mfd_add_devices(max77849->dev, -1, max77849_devs,
			ARRAY_SIZE(max77849_devs), NULL, 0, NULL);
	if (ret < 0)
		goto err_mfd;

	device_init_wakeup(max77849->dev, 1);

#if defined(CONFIG_ADC_ONESHOT)
	/* Set oneshot mode */
	max77849_update_reg(max77849->muic, MAX77849_MUIC_REG_CTRL4,
			ADC_ONESHOT<<CTRL4_ADCMODE_SHIFT, CTRL4_ADCMODE_MASK);
#else
	/* Set continuous mode */
	max77849_update_reg(max77849->muic, MAX77849_MUIC_REG_CTRL4,
			ADC_ALWAYS<<CTRL4_ADCMODE_SHIFT, CTRL4_ADCMODE_MASK);
#endif
	return ret;

err_mfd:
	mfd_remove_devices(max77849->dev);
	max77849_irq_exit(max77849);
	pr_info("%s1\n", __func__);
err_irq_init:
	i2c_unregister_device(max77849->muic);
	pr_info("%s2\n", __func__);
err:
	kfree(max77849);
	pr_info("%s3\n", __func__);
	return ret;
}
Exemple #18
0
static int nuc970_pwm_probe(struct platform_device *pdev)
{

	struct nuc970_chip *nuc970;
	struct pinctrl *p;
	int ret;

	nuc970 = devm_kzalloc(&pdev->dev, sizeof(*nuc970), GFP_KERNEL);
	if (nuc970 == NULL) {
		dev_err(&pdev->dev, "failed to allocate memory for pwm_device\n");
		return -ENOMEM;
	}
	/* calculate base of control bits in TCON */

	nuc970->chip.dev = &pdev->dev;
	nuc970->chip.ops = &nuc970_pwm_ops;
	//nuc970->chip.of_xlate = of_pwm_xlate_with_flags;
	//nuc970->chip.of_pwm_n_cells = 3;
	nuc970->chip.base = pdev->id;
	nuc970->chip.npwm = 1;

	nuc970->clk = clk_get(NULL, "pwm");
	if (IS_ERR(nuc970->clk)) {
		dev_err(&pdev->dev, "failed to get pwm clock\n");
		ret = PTR_ERR(nuc970->clk);
		return ret;
	}

	clk_prepare(nuc970->clk);
	clk_enable(nuc970->clk);
	// all channel prescale output div by 1
	__raw_writel(0x4444, REG_PWM_CSR);

	if(pdev->id == 0) {
#if defined (CONFIG_NUC970_PWM0_PA12)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm0-PA");
#elif defined (CONFIG_NUC970_PWM0_PB2)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm0-PB");
#elif defined (CONFIG_NUC970_PWM0_PC14)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm0-PC");
#elif defined (CONFIG_NUC970_PWM0_PD12)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm0-PD");
#endif

#ifndef CONFIG_NUC970_PWM0_NONE
		if(IS_ERR(p)) {
			dev_err(&pdev->dev, "unable to reserve output pin\n");

		}
#endif
	}
	if(pdev->id == 1) {
#if defined (CONFIG_NUC970_PWM1_PA13)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm1-PA");
#elif defined (CONFIG_NUC970_PWM1_PB3)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm1-PB");
#elif defined (CONFIG_NUC970_PWM1_PD13)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm1-PD");
#endif

#ifndef CONFIG_NUC970_PWM1_NONE
		if(IS_ERR(p)) {
			dev_err(&pdev->dev, "unable to reserve output pin\n");
		}
#endif
	}
	if(pdev->id == 2) {
#if defined (CONFIG_NUC970_PWM2_PA14)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm2-PA");
#elif defined (CONFIG_NUC970_PWM2_PH2)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm2-PH");
#elif defined (CONFIG_NUC970_PWM2_PD14)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm2-PD");
#endif

#ifndef CONFIG_NUC970_PWM2_NONE
		if(IS_ERR(p)) {
			dev_err(&pdev->dev, "unable to reserve output pin\n");
		}
#endif
	}
	if(pdev->id == 3) {
#if defined (CONFIG_NUC970_PWM3_PA15)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm3-PA");
#elif defined (CONFIG_NUC970_PWM3_PH3)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm3-PH");
#elif defined (CONFIG_NUC970_PWM3_PD15)
		p = devm_pinctrl_get_select(&pdev->dev, "pwm3-PD");
#endif

#ifndef CONFIG_NUC970_PWM3_NONE
		if(IS_ERR(p)) {
			dev_err(&pdev->dev, "unable to reserve output pin\n");
		}
#endif
	}

	ret = pwmchip_add(&nuc970->chip);
	if (ret < 0) {
		dev_err(&pdev->dev, "failed to register pwm\n");
		goto err;
	}

	platform_set_drvdata(pdev, nuc970);

	return 0;

err:
	//clk_disable(nuc970->clk);
	return ret;
}
Exemple #19
0
static int nuc970_spi0_probe(struct platform_device *pdev)
{
	struct nuc970_spi *hw;
	struct spi_master *master;
	int err = 0;
	struct pinctrl *p;

	master = spi_alloc_master(&pdev->dev, sizeof(struct nuc970_spi));
	if (master == NULL) {
		dev_err(&pdev->dev, "No memory for spi_master\n");
		err = -ENOMEM;
		goto err_nomem;
	}

	hw = spi_master_get_devdata(master);
	hw->master = spi_master_get(master);
	hw->pdata  = pdev->dev.platform_data;
	hw->dev = &pdev->dev;

	if (hw->pdata == NULL) {
		dev_err(&pdev->dev, "No platform data supplied\n");
		err = -ENOENT;
		goto err_pdata;
	}

	platform_set_drvdata(pdev, hw);
	init_completion(&hw->done);

#if defined(CONFIG_SPI_NUC970_P0_NORMAL)
	master->mode_bits          = (SPI_MODE_0 | SPI_TX_DUAL | SPI_RX_DUAL | SPI_CS_HIGH | SPI_LSB_FIRST);
#elif defined(CONFIG_SPI_NUC970_P0_QUAD)
    master->mode_bits          = (SPI_MODE_0 | SPI_TX_DUAL | SPI_RX_DUAL | SPI_TX_QUAD | SPI_RX_QUAD | SPI_CS_HIGH | SPI_LSB_FIRST);
#endif
	master->num_chipselect     = hw->pdata->num_cs;
	master->bus_num            = hw->pdata->bus_num;
	hw->bitbang.master         = hw->master;
	hw->bitbang.setup_transfer = nuc970_spi0_setupxfer;
	hw->bitbang.chipselect     = nuc970_spi0_chipsel;
	hw->bitbang.txrx_bufs      = nuc970_spi0_txrx;
	hw->bitbang.master->setup  = nuc970_spi0_setup;

	hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (hw->res == NULL) {
		dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
		err = -ENOENT;
		goto err_pdata;
	}

	hw->ioarea = request_mem_region(hw->res->start,
					resource_size(hw->res), pdev->name);

	if (hw->ioarea == NULL) {
		dev_err(&pdev->dev, "Cannot reserve region\n");
		err = -ENXIO;
		goto err_pdata;
	}

	hw->regs = ioremap(hw->res->start, resource_size(hw->res));
	if (hw->regs == NULL) {
		dev_err(&pdev->dev, "Cannot map IO\n");
		err = -ENXIO;
		goto err_iomap;
	}

	hw->irq = platform_get_irq(pdev, 0);
	if (hw->irq < 0) {
		dev_err(&pdev->dev, "No IRQ specified\n");
		err = -ENOENT;
		goto err_irq;
	}

	err = request_irq(hw->irq, nuc970_spi0_irq, 0, pdev->name, hw);
	if (err) {
		dev_err(&pdev->dev, "Cannot claim IRQ\n");
		goto err_irq;
	}

	hw->clk = clk_get(NULL, "spi0");
	if (IS_ERR(hw->clk)) {
		dev_err(&pdev->dev, "No clock for device\n");
		err = PTR_ERR(hw->clk);
		goto err_clk;
	}
    
#if defined(CONFIG_SPI_NUC970_P0_NORMAL) && !defined(CONFIG_SPI_NUC970_P0_SS1)
    p = devm_pinctrl_get_select(&pdev->dev, "spi0");
#elif defined(CONFIG_SPI_NUC970_P0_NORMAL) && defined(CONFIG_SPI_NUC970_P0_SS1_PB0)
    p = devm_pinctrl_get_select(&pdev->dev, "spi0-ss1-PB");
#elif defined(CONFIG_SPI_NUC970_P0_NORMAL) && defined(CONFIG_SPI_NUC970_P0_SS1_PH12)
    p = devm_pinctrl_get_select(&pdev->dev, "spi0-ss1-PH");
#elif defined(CONFIG_SPI_NUC970_P0_QUAD) && !defined(CONFIG_SPI_NUC970_P0_SS1)
	p = devm_pinctrl_get_select(&pdev->dev, "spi0-quad");	
#elif defined(CONFIG_SPI_NUC970_P0_QUAD) && defined(CONFIG_SPI_NUC970_P0_SS1_PB0)
    p = devm_pinctrl_get_select(&pdev->dev, "spi0-quad-ss1-PB");
#elif defined(CONFIG_SPI_NUC970_P0_QUAD) && defined(CONFIG_SPI_NUC970_P0_SS1_PH12)
    p = devm_pinctrl_get_select(&pdev->dev, "spi0-quad-ss1-PB");
#endif
    if(IS_ERR(p)) { 
        dev_err(&pdev->dev, "unable to reserve spi pin by mode\n");
        err = PTR_ERR(p);
    }
    
	nuc970_init_spi(hw);

	err = spi_bitbang_start(&hw->bitbang);
	if (err) {
		dev_err(&pdev->dev, "Failed to register SPI master\n");
		goto err_register;
	}	
	
	return 0;

err_register:
	clk_disable(hw->clk);
	clk_put(hw->clk);
err_clk:
	free_irq(hw->irq, hw);
err_irq:
	iounmap(hw->regs);
err_iomap:
	release_mem_region(hw->res->start, resource_size(hw->res));
	kfree(hw->ioarea);
err_pdata:
	spi_master_put(hw->master);

err_nomem:
	return err;
}
static int sensor_imx219_power_setpin(struct device *dev)
{
	int gpio_none = 0, gpio_reset = 0, gpio_standby = 0;
	struct exynos_platform_fimc_is_sensor *pdata;
	struct device_node *dnode;
	struct pinctrl *pinctrl_ch = NULL;

	BUG_ON(!dev);
	BUG_ON(!dev->platform_data);

	dnode = dev->of_node;
	pdata = dev->platform_data;

	gpio_reset = of_get_named_gpio(dnode, "gpio_reset", 0);
	if (!gpio_is_valid(gpio_reset)) {
		dev_err(dev, "failed to get PIN_RESET\n");
		return -EINVAL;
	} else {
		gpio_request_one(gpio_reset, GPIOF_OUT_INIT_LOW, "CAM_GPIO_OUTPUT_LOW");
		gpio_free(gpio_reset);
	}

	gpio_standby = of_get_named_gpio(dnode, "gpio_standby", 0);
	if (!gpio_is_valid(gpio_standby)) {
		dev_err(dev, "failed to get gpio_standby\n");
	} else {
		gpio_request_one(gpio_standby, GPIOF_OUT_INIT_LOW, "CAM_GPIO_OUTPUT_LOW");
		gpio_free(gpio_standby);
	}

	/* initial - i2c off */
	pinctrl_ch = devm_pinctrl_get_select(dev, "off1");
	if (IS_ERR_OR_NULL(pinctrl_ch)) {
		pr_err("%s: cam %s pins are not configured\n", __func__, "off1");
	} else {
		devm_pinctrl_put(pinctrl_ch);
	}

	/* FRONT CAMERA  - POWER ON */
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 0, gpio_standby, 0, NULL, 0, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 1, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_ON);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 2, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_ON);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 3, gpio_none, 0, "VT_CAM_1.2V", 1000, PIN_REGULATOR_ON);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 4, gpio_reset, 0, NULL, 0, PIN_OUTPUT_HIGH);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 5, gpio_none, 0, "ch", 0, PIN_FUNCTION);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 6, gpio_none, 0, NULL, 0, PIN_END);

	/* FRONT CAMERA  - POWER OFF */
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 0, gpio_standby, 0, NULL, 0, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 1, gpio_none, 0, "off", 0, PIN_FUNCTION);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 2, gpio_reset, 0, NULL, 0, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 3, gpio_none, 0, "VT_CAM_1.2V", 0, PIN_REGULATOR_OFF);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 4, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_OFF);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 5, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_OFF);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 6, gpio_none, 0, NULL, 0, PIN_END);

	/* VISION CAMERA  - POWER ON */
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 0, gpio_reset, 0, NULL, 0, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 1, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_ON);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 2, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_ON);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 3, gpio_none, 0, "VT_CAM_1.2V", 1000, PIN_REGULATOR_ON);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 4, gpio_standby, 0, NULL, 0, PIN_OUTPUT_HIGH);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 5, gpio_none, 0, "ch", 0, PIN_FUNCTION);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 6, gpio_none, 0, NULL, 0, PIN_END);

	/* VISION CAMERA  - POWER OFF */
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 0, gpio_reset, 0, NULL, 0, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 1, gpio_none, 0, "off", 0, PIN_FUNCTION);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 2, gpio_standby, 0, NULL, 0, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 3, gpio_none, 0, "VT_CAM_1.2V", 0, PIN_REGULATOR_OFF);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 4, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_OFF);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 5, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_OFF);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 6, gpio_none, 0, NULL, 0, PIN_END);

	return 0;
}
int fimc_is_sensor_parse_dt_with_companion(struct platform_device *pdev)
{
	int ret = 0;
	u32 temp;
	char *pprop;
	struct exynos_platform_fimc_is_sensor *pdata;
	struct device_node *dnode;
	struct device *dev;
	int gpio_reset = 0, gpio_standby = 0;
#ifdef CONFIG_SOC_EXYNOS5422
	int gpios_cam_en = 0;
#endif
#if !defined(CONFIG_USE_VENDER_FEATURE) /* LSI Patch */
	int gpio_cam_en = 0;
	int gpio_comp_en, gpio_comp_rst;
#else
	const char *name;
#endif
#ifdef CONFIG_SOC_EXYNOS5433
	struct pinctrl *pinctrl_ch = NULL;
#endif
	int gpio_none = 0;
	u32 id;

	BUG_ON(!pdev);
	BUG_ON(!pdev->dev.of_node);

	dev = &pdev->dev;
	dnode = dev->of_node;

	pdata = kzalloc(sizeof(struct exynos_platform_fimc_is_sensor), GFP_KERNEL);
	if (!pdata) {
		pr_err("%s: no memory for platform data\n", __func__);
		return -ENOMEM;
	}

	pdata->gpio_cfg = exynos_fimc_is_sensor_pins_cfg;
	pdata->iclk_cfg = exynos_fimc_is_sensor_iclk_cfg;
	pdata->iclk_on = exynos_fimc_is_sensor_iclk_on;
	pdata->iclk_off = exynos_fimc_is_sensor_iclk_off;
	pdata->mclk_on = exynos_fimc_is_sensor_mclk_on;
	pdata->mclk_off = exynos_fimc_is_sensor_mclk_off;

	ret = of_property_read_u32(dnode, "scenario", &pdata->scenario);
	if (ret) {
		err("scenario read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "mclk_ch", &pdata->mclk_ch);
	if (ret) {
		err("mclk_ch read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "csi_ch", &pdata->csi_ch);
	if (ret) {
		err("csi_ch read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "flite_ch", &pdata->flite_ch);
	if (ret) {
		err("flite_ch read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "i2c_ch", &pdata->i2c_ch);
	if (ret) {
		err("i2c_ch read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "i2c_addr", &pdata->i2c_addr);
	if (ret) {
		err("i2c_addr read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "is_bns", &pdata->is_bns);
	if (ret) {
		err("is_bns read is fail(%d)", ret);
		goto p_err;
	}

	ret = of_property_read_u32(dnode, "id", &id);
	if (ret) {
		err("id read is fail(%d)", ret);
		goto p_err;
	}
	pdata->id = id;

	DT_READ_U32(dnode, "flash_first_gpio",   pdata->flash_first_gpio );
	DT_READ_U32(dnode, "flash_second_gpio",  pdata->flash_second_gpio);

#ifdef CONFIG_USE_VENDER_FEATURE
	ret = of_property_read_string(dnode, "sensor_name", &name);
	if (ret) {
		err("sensor_name read is fail(%d)", ret);
		goto p_err;
	}
	strcpy(pdata->sensor_name, name);

	ret = of_property_read_u32(dnode, "sensor_id", &pdata->sensor_id);
	if (ret) {
		err("sensor_id read is fail(%d)", ret);
		goto p_err;
	}
#endif
	gpio_reset = of_get_named_gpio(dnode, "gpio_reset", 0);
	if (!gpio_is_valid(gpio_reset)) {
		dev_err(dev, "failed to get PIN_RESET\n");
		ret = -EINVAL;
		goto p_err;
	} else {
		gpio_request_one(gpio_reset, GPIOF_OUT_INIT_LOW, "CAM_GPIO_OUTPUT_LOW");
		gpio_free(gpio_reset);
	}
#ifdef CONFIG_SOC_EXYNOS5422
	gpios_cam_en = of_get_named_gpio(dnode, "gpios_cam_en", 0);
	if (!gpio_is_valid(gpios_cam_en)) {
		dev_err(dev, "failed to get main/front cam en gpio\n");
	} else {
		gpio_request_one(gpios_cam_en, GPIOF_OUT_INIT_LOW, "CAM_GPIO_OUTPUT_LOW");
		gpio_free(gpios_cam_en);
	}
#endif

#if !defined(CONFIG_USE_VENDER_FEATURE) /* LSI Patch */
	/* Optional Feature */
	gpio_comp_en = of_get_named_gpio(dnode, "gpios_comp_en", 0);
	if (!gpio_is_valid(gpio_comp_en))
	dev_err(dev, "failed to get main comp en gpio\n");

	gpio_comp_rst = of_get_named_gpio(dnode, "gpios_comp_reset", 0);
	if (!gpio_is_valid(gpio_comp_rst))
	dev_err(dev, "failed to get main comp reset gpio\n");

	gpio_standby = of_get_named_gpio(dnode, "gpio_standby", 0);
	if (!gpio_is_valid(gpio_standby))
		dev_err(dev, "failed to get gpio_standby\n");

	gpio_cam_en = of_get_named_gpio(dnode, "gpios_cam_en", 0);
	if (!gpio_is_valid(gpio_cam_en))
		dev_err(dev, "failed to get gpio_cam_en\n");

	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 0, gpio_cam_en, 0, NULL, PIN_OUTPUT_HIGH);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 1, gpio_reset, 0, NULL, PIN_RESET);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 2, gpio_none, 0, "ch", PIN_FUNCTION);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 3, gpio_comp_en, 0, NULL, PIN_OUTPUT_HIGH);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 4, gpio_comp_rst, 0, NULL, PIN_RESET);
	if (id == SENSOR_POSITION_REAR) {
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 5, gpio_none, 0, "af", PIN_FUNCTION);
	}
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 6, gpio_none, 0, NULL, PIN_END);

	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 0, gpio_reset, 0, NULL, PIN_RESET);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 1, gpio_reset, 0, NULL, PIN_INPUT);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 2, gpio_comp_rst, 0, NULL, PIN_RESET);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 3, gpio_comp_rst, 0, NULL, PIN_INPUT);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 4, gpio_comp_en, 0, NULL, PIN_INPUT);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 5, gpio_cam_en, 0, NULL, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 6, gpio_none, 0, NULL, PIN_END);

	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 0, gpio_cam_en, 0, NULL, PIN_OUTPUT_HIGH);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 1, gpio_reset, 0, NULL, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 2, gpio_standby, 0, NULL, PIN_OUTPUT_HIGH);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 3, gpio_none, 0, NULL, PIN_END);

	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 0, gpio_reset, 0, NULL, PIN_RESET);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 1, gpio_reset, 0, NULL, PIN_INPUT);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 2, gpio_standby, 0, NULL, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 4, gpio_cam_en, 0, NULL, PIN_OUTPUT_LOW);
	SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 3, gpio_none, 0, NULL, PIN_END);

#else /* TN CODE */

	if (id == SENSOR_POSITION_FRONT) {
		gpio_standby = of_get_named_gpio(dnode, "gpio_standby", 0);
		if (!gpio_is_valid(gpio_standby)) {
			dev_err(dev, "failed to get gpio_standby\n");
		} else {
			gpio_request_one(gpio_standby, GPIOF_OUT_INIT_LOW, "CAM_GPIO_OUTPUT_LOW");
			gpio_free(gpio_standby);
		}
#ifdef CONFIG_SOC_EXYNOS5433
		/* initial - i2c off */
		pinctrl_ch = devm_pinctrl_get_select(&pdev->dev, "off1");
		if (IS_ERR_OR_NULL(pinctrl_ch)) {
			pr_err("%s: cam %s pins are not configured\n", __func__, "off1");
		} else {
			devm_pinctrl_put(pinctrl_ch);
		}
#endif
	}
#ifdef CONFIG_SOC_EXYNOS5422
	if (id == SENSOR_POSITION_REAR) {
		/* BACK CAMERA	- POWER ON */
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 0, gpio_none, 0, NULL, 0, PIN_END);

		/* BACK CAMERA	- POWER OFF */
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 0, gpio_none, 0, NULL, 0, PIN_END);
	} else {
		/* FRONT CAMERA  - POWER ON */
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 0, gpio_standby, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 1, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 2, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 3, gpios_cam_en, 0, NULL, 1000, PIN_OUTPUT_HIGH);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 4, gpio_reset, 0, NULL, 0, PIN_OUTPUT_HIGH);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 5, gpio_none, 0, "ch", 0, PIN_FUNCTION);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 6, gpio_none, 0, NULL, 0, PIN_END);

		/* FRONT CAMERA  - POWER OFF */
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 0, gpio_standby, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 1, gpio_none, 0, "off", 0, PIN_FUNCTION);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 2, gpio_reset, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 3, gpios_cam_en, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 4, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 5, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 6, gpio_none, 0, NULL, 0, PIN_END);

		/* VISION CAMERA  - POWER ON */
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 0, gpio_reset, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 1, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 2, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 3, gpios_cam_en, 0, NULL, 1000, PIN_OUTPUT_HIGH);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 4, gpio_standby, 0, NULL, 0, PIN_OUTPUT_HIGH);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 5, gpio_none, 0, "ch", 0, PIN_FUNCTION);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 6, gpio_none, 0, NULL, 0, PIN_END);

		/* VISION CAMERA  - POWER OFF */
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 0, gpio_reset, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 1, gpio_none, 0, "off", 0, PIN_FUNCTION);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 2, gpio_standby, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 3, gpios_cam_en, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 4, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 5, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 6, gpio_none, 0, NULL, 0, PIN_END);
	}
#else /*CONFIG_SOC_EXYNOS5430*/
	if (id == SENSOR_POSITION_REAR) {
		/* BACK CAMERA  - POWER ON */
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 0, gpio_none, 0, NULL, 0, PIN_END);

		/* BACK CAMERA  - POWER OFF */
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 0, gpio_none, 0, NULL, 0, PIN_END);
	} else {
		/* FRONT CAMERA  - POWER ON */
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 0, gpio_standby, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 1, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 2, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 3, gpio_none, 0, "VT_CAM_1.2V", 1000, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 4, gpio_reset, 0, NULL, 0, PIN_OUTPUT_HIGH);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 5, gpio_none, 0, "ch", 0, PIN_FUNCTION);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, 6, gpio_none, 0, NULL, 0, PIN_END);

		/* FRONT CAMERA  - POWER OFF */
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 0, gpio_standby, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 1, gpio_none, 0, "off", 0, PIN_FUNCTION);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 2, gpio_reset, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 3, gpio_none, 0, "VT_CAM_1.2V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 4, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 5, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, 6, gpio_none, 0, NULL, 0, PIN_END);

		/* VISION CAMERA  - POWER ON */
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 0, gpio_reset, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 1, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 2, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 3, gpio_none, 0, "VT_CAM_1.2V", 1000, PIN_REGULATOR_ON);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 4, gpio_standby, 0, NULL, 0, PIN_OUTPUT_HIGH);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 5, gpio_none, 0, "ch", 0, PIN_FUNCTION);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, 6, gpio_none, 0, NULL, 0, PIN_END);

		/* VISION CAMERA  - POWER OFF */
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 0, gpio_reset, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 1, gpio_none, 0, "off", 0, PIN_FUNCTION);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 2, gpio_standby, 0, NULL, 0, PIN_OUTPUT_LOW);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 3, gpio_none, 0, "VT_CAM_1.2V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 4, gpio_none, 0, "VT_CAM_2.8V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 5, gpio_none, 0, "VT_CAM_1.8V", 0, PIN_REGULATOR_OFF);
		SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, 6, gpio_none, 0, NULL, 0, PIN_END);
	}
#endif
#endif
	pdev->id = id;

	dev->platform_data = pdata;

	pdata->pinctrl = devm_pinctrl_get(dev);
	if (IS_ERR(pdata->pinctrl)) {
		err("devm_pinctrl_get is fail");
		goto p_err;
	} else {
		ret = get_pin_lookup_state(dev, pdata);
		if (ret < 0) {
			err("fimc_is_get_pin_lookup_state is fail");
			goto p_err;
		}
	}

	return ret;
p_err:
	kfree(pdata);
	return ret;
}
Exemple #22
0
static int isdbt_probe(struct platform_device *pdev)
{
	int ret = 0, i;
	int result = 0;
#if defined(CONFIG_SEC_GPIO_SETTINGS)
	struct pinctrl *isdbt_pinctrl;
#endif

	DPRINTK("isdbt_probe\n");

	result = get_isdbt_dt_pdata(&pdev->dev);
	if (!result) {
		DPRINTK("isdbt_dt_pdata is NULL.\n");
		return -ENODEV;
	}

	result = isdbt_gpio_request();
	if (result) {
		DPRINTK("can't request gpio. please check the isdbt_gpio_request()");
		return -ENODEV;
	}

#if defined(CONFIG_SEC_GPIO_SETTINGS)
	isdbt_device = &pdev->dev;

	/* Get pinctrl if target uses pinctrl */
	isdbt_pinctrl = devm_pinctrl_get_select(isdbt_device, "isdbt_gpio_suspend");
	if (IS_ERR(isdbt_pinctrl)) {
		if (PTR_ERR(isdbt_pinctrl) == -EPROBE_DEFER)
			return -EPROBE_DEFER;

		DPRINTK("Target does not use pinctrl\n");
		isdbt_pinctrl = NULL;
	}
#endif

	isdbt_spi_init();

	isdbtdrv_func = isdbt_get_drv_func();

	if (isdbtdrv_func->probe) {
		if ((*isdbtdrv_func->probe)() != 0) {
//			isdbt_exit_bus();
			ret = -EFAULT;
		}
	} else {
		pr_err("%s : isdbtdrv_func is NULL.\n", __func__);
//		isdbt_exit_bus();
		ret = -EFAULT;
	}

#ifdef ISDBT_WAKE_LOCK_ENABLE
#if defined(CONFIG_MTV_QUALCOMM)
	pm_qos_add_request(&isdbt_pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
				PM_QOS_DEFAULT_VALUE);
#endif
	wake_lock_init(&isdbt_wlock, WAKE_LOCK_SUSPEND, "isdbt_wlock");
#endif

	for (i = 0; i < sizeof(spi_pin_group)/sizeof(spi_pin_group[0]); i++)
		spi_pin_group[i].reg += CTL_PIN_BASE;
	for (i = 0; i < sizeof(isdbt_pwr_en_pin)/sizeof(isdbt_pwr_en_pin[0]); i++)
		isdbt_pwr_en_pin[i].reg += CTL_PIN_BASE;

	return ret;
}
static int s5p_cec_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct resource *res;
	struct pinctrl *pinctrl;
	int gpio;
	int ret;
	u8 *buffer;

	s5p_cec_mem_probe(pdev);

	if (misc_register(&cec_misc_device)) {
		printk(KERN_WARNING " Couldn't register device 10, %d.\n",
			CEC_MINOR);
		return -EBUSY;
	}

	if (of_get_property(dev->of_node, "gpios", NULL) != NULL) {
		gpio = of_get_gpio(dev->of_node, 0);
		if (gpio_request(gpio, "hdmi-cec")) {
			dev_err(dev, "failed to request cec gpio\n");
			return -ENODEV;
		} else {
			gpio_direction_input(gpio);
			pinctrl = devm_pinctrl_get_select(dev, "hdmi_cec");
			if (IS_ERR(pinctrl))
				dev_err(dev, "failed to set cec gpio");
			dev_info(dev, "success request GPIO for hdmi-cec");
		}
	}

	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
	if (!res) {
		dev_err(dev, "failed to get irq resource.\n");
		return -ENXIO;
	}
	ret = devm_request_irq(dev, res->start, s5p_cec_irq_handler,
			IRQF_DISABLED, "hdmi-cec", &pdev->id);
	if (ret) {
		dev_err(dev, "request int interrupt failed.\n");
		return ret;
	}

	init_waitqueue_head(&cec_rx_struct.waitq);
	spin_lock_init(&cec_rx_struct.lock);
	init_waitqueue_head(&cec_tx_struct.waitq);

	buffer = kmalloc(CEC_TX_BUFF_SIZE, GFP_KERNEL);

	if (!buffer) {
		printk(KERN_ERR " kmalloc() failed!\n");
		misc_deregister(&cec_misc_device);

		return -EIO;
	}

	cec_rx_struct.buffer = buffer;

	cec_rx_struct.size   = 0;
	TV_CLK_GET_WITH_ERR_CHECK(hdmi_cec_clk, pdev, "pclk_hdmi_cec");

	dev_info(dev, "probe successful\n");

	return 0;
}