Ejemplo n.º 1
0
static int exynos_parse_gpio(struct device *dev)
{
	int gpio = -1;
	struct device_node *np = dev->of_node;
	enum of_gpio_flags flags;
	u32 value;
	int ret = -1;

	if (!of_find_property(np, "lcd_bl_gpio", &value)) {
                dev_err(dev, "no bl gpio property found\n");
		return -1;
        }

	gpio = of_get_named_gpio_flags(np, "lcd_bl_gpio", 0, &flags);
        if (gpio_is_valid(gpio)) {
                ret = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "exynos4-fb");
                if (ret < 0) {
                        return ret;
		}
        }
	gpio_set_value(gpio, 1);

	if (!of_find_property(np, "lcd_en_gpio", &value)) {
                dev_err(dev, "no bl gpio property found\n");
		return -1;
        }
        gpio = of_get_named_gpio_flags(np, "lcd_en_gpio", 0, &flags);
        if (gpio_is_valid(gpio)) {
                ret = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "exynos4-fb");
                if (ret < 0) {
                        return ret;
		}
        }
	gpio_set_value(gpio, 1);

	return 0;
}
Ejemplo n.º 2
0
static int serial_omap_probe_rs485(struct uart_omap_port *up,
				   struct device_node *np)
{
	struct serial_rs485 *rs485conf = &up->port.rs485;
	u32 rs485_delay[2];
	enum of_gpio_flags flags;
	int ret;

	rs485conf->flags = 0;
	up->rts_gpio = -EINVAL;

	if (!np)
		return 0;

	if (of_property_read_bool(np, "rs485-rts-active-high"))
		rs485conf->flags |= SER_RS485_RTS_ON_SEND;
	else
		rs485conf->flags |= SER_RS485_RTS_AFTER_SEND;

	/* check for tx enable gpio */
	up->rts_gpio = of_get_named_gpio_flags(np, "rts-gpio", 0, &flags);
	if (gpio_is_valid(up->rts_gpio)) {
		ret = devm_gpio_request(up->dev, up->rts_gpio, "omap-serial");
		if (ret < 0)
			return ret;
		ret = gpio_direction_output(up->rts_gpio,
					    flags & SER_RS485_RTS_AFTER_SEND);
		if (ret < 0)
			return ret;
	} else if (up->rts_gpio == -EPROBE_DEFER) {
		return -EPROBE_DEFER;
	} else {
		up->rts_gpio = -EINVAL;
	}

	if (of_property_read_u32_array(np, "rs485-rts-delay",
				    rs485_delay, 2) == 0) {
		rs485conf->delay_rts_before_send = rs485_delay[0];
		rs485conf->delay_rts_after_send = rs485_delay[1];
	}

	if (of_property_read_bool(np, "rs485-rx-during-tx"))
		rs485conf->flags |= SER_RS485_RX_DURING_TX;

	if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time"))
		rs485conf->flags |= SER_RS485_ENABLED;

	return 0;
}
Ejemplo n.º 3
0
static int pn547_parse_dt(struct device *dev,
	struct pn547_i2c_platform_data *pdata)
{
	struct device_node *np = dev->of_node;

	pdata->irq_gpio = of_get_named_gpio_flags(np, "pn547,irq-gpio",
		0, &pdata->irq_gpio_flags);

	pdata->ven_gpio = of_get_named_gpio_flags(np, "pn547,ven-gpio",
		0, &pdata->ven_gpio_flags);

	pdata->firm_gpio = of_get_named_gpio_flags(np, "pn547,firm-gpio",
		0, &pdata->firm_gpio_flags);
#ifdef CONFIG_NFC_PN547_8916_USE_BBCLK2
	pdata->nfc_clock = clk_get(dev, "nfc_clock");
	if (IS_ERR(pdata->nfc_clock)) {
		pr_err("[NFC] %s: Couldn't get D1)\n",
					__func__);
	} else {
		clk_put(pdata->nfc_clock);
#ifndef CONFIG_NFC_PN547_8916_CLK_CTL
		if (clk_prepare_enable(pdata->nfc_clock))
			pr_err("[NFC] %s: Couldn't prepare D1\n",
					__func__);
#endif
	}
#endif
	if (pdata->firm_gpio < 0)
		of_property_read_u32(np, "pn547,firm-expander-gpio",
			&pdata->firm_gpio);

	pr_info("%s: irq : %u, ven : %u, firm : %u\n",
			__func__, pdata->irq_gpio, pdata->ven_gpio,
			pdata->firm_gpio);
	return 0;
}
static int backlight_parse_dt(struct device *dev,
			struct backlight_platform_data *pdata)
{
	struct device_node *np = dev->of_node;

	pdata->gpio_scl = of_get_named_gpio_flags(np, "backlight,scl-gpio",
				0, &pdata->scl_gpio_flags);
	pdata->gpio_sda = of_get_named_gpio_flags(np, "backlight,sda-gpio",
				0, &pdata->sda_gpio_flags);
	pdata->gpio_backlight_en = of_get_named_gpio_flags(np, "backlight-en-gpio",
				0, &pdata->en_gpio_flags);
	pdata->gpio_backlight_pwm= of_get_named_gpio_flags(np, "backlight-pwm-gpio",
				0, &pdata->en_gpio_flags);

	bl_ic_name = of_get_property(np, "backlight-ic-name", NULL);
	if (!bl_ic_name) {
		pr_info("%s:%d, backlight IC name not specified\n",__func__, __LINE__);
	} else {
		pr_info("%s: Backlight IC Name = %s\n", __func__,bl_ic_name);
	}

	pr_err("%s gpio_scl : %d , gpio_sda : %d en : %d pwm:%d\n", __func__, pdata->gpio_scl, pdata->gpio_sda, pdata->gpio_backlight_en, pdata->gpio_backlight_en);
	return 0;
}
Ejemplo n.º 5
0
static void i2c_fsl_init_recovery(struct fsl_i2c_struct *i2c_fsl, struct device_d *dev)
{
	if (!dev->device_node)
		return;

	i2c_fsl->rinfo.sda_gpio = of_get_named_gpio_flags(dev->device_node,
			"sda-gpios", 0, NULL);
	i2c_fsl->rinfo.scl_gpio = of_get_named_gpio_flags(dev->device_node,
			"scl-gpios", 0, NULL);

	if (!gpio_is_valid(i2c_fsl->rinfo.sda_gpio) ||
	    !gpio_is_valid(i2c_fsl->rinfo.scl_gpio))
		return;

	i2c_fsl->rinfo.get_scl = i2c_get_scl_gpio_value;
	i2c_fsl->rinfo.get_sda = i2c_get_sda_gpio_value;
	i2c_fsl->rinfo.set_scl = i2c_set_scl_gpio_value;
	i2c_fsl->rinfo.prepare_recovery = i2c_fsl_prepare_recovery;
	i2c_fsl->rinfo.unprepare_recovery = i2c_fsl_unprepare_recovery;
	i2c_fsl->rinfo.recover_bus = i2c_generic_gpio_recovery;
	i2c_fsl->adapter.bus_recovery_info = &i2c_fsl->rinfo;

	dev_dbg(dev, "initialized recovery info\n");
}
Ejemplo n.º 6
0
static int of_max77804k_dt(struct device *dev, struct max77804k_platform_data *pdata)
{
	struct device_node *np = dev->of_node;
//	int retval = 0;

#ifdef CONFIG_VIBETONZ
	struct max77804k_haptic_platform_data *haptic_data;
#endif
	if(!np)
		return -EINVAL;

#ifdef CONFIG_VIBETONZ
	haptic_data = kzalloc(sizeof(struct max77804k_haptic_platform_data), GFP_KERNEL);
	if (haptic_data == NULL)
		return -ENOMEM;
#endif

	pdata->irq_gpio = of_get_named_gpio_flags(np, "max77804k,irq-gpio",
				0, &pdata->irq_gpio_flags);
	pdata->wakeup = of_property_read_bool(np, "max77804k,wakeup");
#if 0
	pdata->irq_base = irq_alloc_descs(-1, 0, MAX77804K_IRQ_NR, -1);
	if (pdata->irq_base < 0) {
		pr_info("%s irq_alloc_descs is failed! irq_base:%d\n", __func__, pdata->irq_base);
		/* getting a predefined irq_base on dt file	*/
		of_property_read_u32(np, "max77804k,irq-base", &pdata->irq_base);
	}
	retval = of_get_named_gpio(np, "max77804k,wc-irq-gpio", 0);
	if (retval < 0)
		pdata->wc_irq_gpio = 0;
	else
		pdata->wc_irq_gpio = retval;
#endif
	pr_info("%s: irq-gpio: %u \n", __func__, pdata->irq_gpio);
#ifdef CONFIG_VIBETONZ
	of_property_read_u32(np, "haptic,max_timeout", &haptic_data->max_timeout);
	of_property_read_u32(np, "haptic,duty", &haptic_data->duty);
	of_property_read_u32(np, "haptic,period", &haptic_data->period);
	of_property_read_u32(np, "haptic,pwm_id", &haptic_data->pwm_id);
	pr_info("%s: timeout: %u \n", __func__, haptic_data->max_timeout);
	pr_info("%s: duty: %u \n", __func__, haptic_data->duty);
	pr_info("%s: period: %u \n", __func__, haptic_data->period);
	pr_info("%s: pwm_id: %u \n", __func__, haptic_data->pwm_id);
	pdata->haptic_data = haptic_data;
	kfree(haptic_data);
#endif
	return 0;
}
static int hall_sensor_parse_dt(struct device *dev,
						struct hall_sensor_data *hsdata)
{
	struct device_node *np = dev->of_node;
	u32 gpio_flag;

	hsdata->irq_gpio = of_get_named_gpio_flags(np, "Seiko,irq-gpio",
							0, &gpio_flag);
	if (gpio_is_valid(hsdata->irq_gpio))
		hsdata->irq_gpio_flags = gpio_flag;
	else
		return -EINVAL;

	hsdata->irq = gpio_to_irq(hsdata->irq_gpio);
	return 0;
}
Ejemplo n.º 8
0
static int yas_parse_dt(struct device *dev,
			struct yas_acc_platform_data *pdata) {
	struct property *prop = NULL;
	struct device_node *dt = dev->of_node;
	u32 buf = 0;
	uint32_t irq_gpio_flags = 0;
	struct device_node *offset = NULL;
	int cali_size;
	unsigned char *cali_data;
	int i;

	prop = of_find_property(dt, "g_sensor_kxtj2,placement", NULL);
	if (prop) {
		of_property_read_u32(dt, "g_sensor_kxtj2,placement", &buf);
		pdata->placement = buf;
		I("%s: placement = %d\n", __func__, pdata->placement);
	} else
		E("%s: g_sensor_kxtj2,placement not found\n", __func__);

#ifdef CONFIG_CIR_ALWAYS_READY
	pdata->intr = of_get_named_gpio_flags(dt,
					      "g_sensor_kxtj2,intr",
					      0,
					      &irq_gpio_flags);
	if (pdata->intr < 0) {
		E("%s: of_get_named_gpio_flags fails: pdata->intr\n", __func__);
		return -EINVAL;
	}
#endif

	pdata->gs_kvalue = 0;
	offset = of_find_node_by_path(CALIBRATION_DATA_PATH);
	if (offset) {
		cali_data = (unsigned char *)of_get_property(offset,
							G_SENSOR_FLASH_DATA,
							&cali_size);
		if (cali_data) {
			for (i = 0; (i < cali_size) && (i < 4); i++) {
				I("cali_data[%d] = 0x%02x\n", i, cali_data[i]);
				pdata->gs_kvalue |= (cali_data[i] << (i * 8));
			}
		}
	} else
		I("%s: Calibration data offset not found\n", __func__);

	return 0;
}
Ejemplo n.º 9
0
 static int apds_parse_dt(struct device *dev,
			 struct apds9900_platform_data *pdata)
 {
	 //int rc;
	 struct device_node *np = dev->of_node;
	 pdata->int_pin = of_get_named_gpio_flags(np, "apds,irq-gpio",
				 0, &pdata->int_flags);
	 if (pdata->int_pin < 0) {
		 dev_err(dev, "Unable to read irq-gpio\n");
		 return pdata->int_pin;
	 }
 

	 pdata->use_fir = of_property_read_bool(np, "apds,use-fir");
 
	 return 0;
 }
Ejemplo n.º 10
0
static int fan53555_of_init(struct device_node *node,
			struct fan53555_device_info *di)
{
	int ret, gpio;
	enum of_gpio_flags flags;

	if (of_property_read_bool(node, "fairchild,restore-reg")) {
		ret = fan53555_restore_working_reg(node, di);
		if (ret)
			return ret;
	}

	if (of_find_property(node, "fairchild,vsel-gpio", NULL)) {
		gpio = of_get_named_gpio_flags(node, "fairchild,vsel-gpio", 0,
						&flags);

		if (!gpio_is_valid(gpio)) {
			if (gpio != -EPROBE_DEFER)
				dev_err(di->dev, "Could not get vsel, ret = %d\n",
					gpio);
			return gpio;
		}

		ret = devm_gpio_request(di->dev, gpio, "fan53555_vsel");
		if (ret) {
			dev_err(di->dev, "Failed to obtain gpio %d ret = %d\n",
				gpio, ret);
			return ret;
		}

		ret = gpio_direction_output(gpio, flags & OF_GPIO_ACTIVE_LOW ?
							0 : 1);
		if (ret) {
			dev_err(di->dev,
				"Failed to set GPIO %d to: %s, ret = %d",
				gpio, flags & OF_GPIO_ACTIVE_LOW ?
				"GPIO_LOW" : "GPIO_HIGH", ret);
			return ret;
		}
	}

	di->disable_suspend = of_property_read_bool(node,
				"fairchild,disable-suspend");

	return 0;
}
Ejemplo n.º 11
0
static int siw_touch_of_gpio(struct device *dev, void *np,
					void *string, enum of_gpio_flags *flags)
{
	int gpio = 0;

	gpio = of_get_named_gpio_flags(np, string, 0, flags);
	if (gpio_is_valid(gpio)) {
		if (flags)
			t_dev_info(dev, "of gpio  : %s(0x%X), %d\n",
					(char *)string, (*flags), gpio);
		else
			t_dev_info(dev, "of gpio  : %s, %d\n",
					(char *)string, gpio);
	}

	return gpio;
}
Ejemplo n.º 12
0
static int bma255_parse_dt(struct bma255_p *data, struct device *dev)
{
	struct device_node *dNode = dev->of_node;
	enum of_gpio_flags flags;

	if (dNode == NULL)
		return -ENODEV;


	/*scl,sda and irq */
	data->i2c_pull_up = of_property_read_bool(dNode, "bma255-i2c,i2c-pull-up");

	data->str_l6 = of_get_property(dNode,"bma255-i2c,reg_vdd", NULL);
	data->str_lvs1 = of_get_property(dNode,"bma255-i2c,reg_vio", NULL);
	data->used_chip = of_property_read_u32(dNode,"bma255-i2c,used_chip", &data->used_chip_flags);


	printk(KERN_INFO "%s pull-up:%d  \n", __func__, data->i2c_pull_up);

	data->acc_int1 = of_get_named_gpio(dNode,
		"bma255-i2c,acc_int1-gpio", 0);
	if (data->acc_int1 < 0) {
		pr_err("[SENSOR]: %s - get acc_int1 error\n", __func__);
		return -ENODEV;
	}

	data->acc_int2 = of_get_named_gpio_flags(dNode,
		"bma255-i2c,acc_int2-gpio", 0, &flags);
	if (data->acc_int2 < 0) {
		pr_err("[SENSOR]: %s - acc_int2 error\n", __func__);
		//return -ENODEV;
	}

	if (of_property_read_u32(dNode,
			"bma255-i2c,chip_pos", &data->chip_pos) < 0)
		data->chip_pos = BMA255_TOP_LOWER_RIGHT;

#if defined(CONFIG_MACH_MS01_LTE_KOR)
	data->chip_pos = BMA255_BOTTOM_UPPER_LEFT;
#elif defined(CONFIG_MACH_BAFFIN2_CHN_CMCC)
	data->chip_pos = BMA255_BOTTOM_UPPER_LEFT;
#endif

	return 0;
}
Ejemplo n.º 13
0
static int p3_parse_dt(struct device *dev,
	struct p3_dev *data)
{
	struct device_node *np = dev->of_node;
	enum of_gpio_flags flags;
	int errorno = 0;
	//int gpio;

#if 0//def ENABLE_SENSORS_FPRINT_SECURE
	if (of_property_read_u32(np, "p3-mosipin", &data->mosipin))
		data->mosipin = 0;
	if (of_property_read_u32(np, "p3-misopin", &data->misopin))
		data->misopin = 0;
	if (of_property_read_u32(np, "p3-cspin", &data->cspin))
		data->cspin = 0;
	if (of_property_read_u32(np, "p3-clkpin", &data->clkpin))
		data->clkpin = 0;

	//data->tz_mode = true;
#endif
	data->cs_gpio = of_get_named_gpio_flags(np,
		"p3-cs-gpio", 0, &flags);
	if (data->cs_gpio < 0) {
		P3_ERR_MSG("%s - get cs_gpio error\n", __func__);
		//return -ENODEV;
	}
	else {
		errorno = gpio_request(data->cs_gpio, "ese_cs");
		if (errorno) {
			P3_ERR_MSG("%s - failed to request ese_cs\n", __func__);
			//sreturn errorno;
		}
#if 1 /* Keep CS up*/
		gpio_direction_output(data->cs_gpio, 1);
#else /*CS down for later power up */
		gpio_direction_output(data->cs_gpio, 0);
#endif
	}

	P3_DBG_MSG("%s: mosipin=%d, %d, %d, %d cs_gpio:%d\n", __func__,
		data->mosipin, data->misopin, data->cspin, data->clkpin, data->cs_gpio);
//dt_exit:
	return errorno;
}
Ejemplo n.º 14
0
static int of_hall_data_parsing_dt(struct hall_drvdata *ddata)
{
	struct device_node *np_haptic;
	int gpio;
	enum of_gpio_flags flags;
#ifdef CONFIG_SENSORS_HALL_IRQ_CTRL
	u32 temp;
	int ret;
#endif

	np_haptic = of_find_node_by_path("/hall");
	if (np_haptic == NULL) {
		printk("%s : error to get dt node\n", __func__);
		return -EINVAL;
	}

	gpio = of_get_named_gpio_flags(np_haptic, "hall,gpio_flip_cover", 0, &flags);
	if (gpio < 0) {
		pr_info("%s: fail to get flip_cover \n", __func__ );
		return -EINVAL;
	}
	ddata->gpio_flip_cover = gpio;

	gpio = gpio_to_irq(gpio);
	if (gpio < 0) {
		pr_info("%s: fail to return irq corresponding gpio \n", __func__ );
		return -EINVAL;
	}
	ddata->irq_flip_cover = gpio;

#ifdef CONFIG_SENSORS_HALL_IRQ_CTRL
	ret = of_property_read_u32(np_haptic, "hall,gsm_wa", &temp);
	if (ret) {
		pr_info("%s: No property about WA\n", __func__);
		ddata->wa_enable = false;
	} else {
		pr_info("%s: get the wa property\n", __func__);
		ddata->wa_enable = temp;
	}
#endif

	return 0;
}
int snfc_intu_probe(struct device_node *np)
{
    int rc;
	/* register the device file */
	rc = misc_register(&snfc_intu_device);
	if (rc < 0)
	{
		SNFC_DEBUG_MSG("[snfc_intu_poll] FAIL!! can not register snfc_intu_poll_init \n");
		return rc;
	}
    snfc_gpios.gpio_intu = of_get_named_gpio_flags(np, "sony,intu-gpio", 0, NULL);

	rc = gpio_request(snfc_gpios.gpio_intu, "snfc_intu");
	
	if (rc)
	{
		SNFC_DEBUG_MSG("[snfc_intu_poll] gpio_request snfc_intu fail (rc = %d)\n",rc);
	}
	
	rc = request_irq(gpio_to_irq(snfc_gpios.gpio_intu), snfc_int_low_isr,IRQF_TRIGGER_FALLING | IRQF_DISABLED , "snfc_intu", NULL);

	if (rc)
	{
		SNFC_DEBUG_MSG("[snfc_intu_poll] request_irq fail (rc = %d )\n",rc);
		return rc;
	}

	disable_irq_nosync(gpio_to_irq(snfc_gpios.gpio_intu));

	init_waitqueue_head(&intuwq);

	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] GPIO_SNFC_INTU =%d\n",snfc_gpios.gpio_intu);

	rc = gpio_direction_input((unsigned)snfc_gpios.gpio_intu);
	if(rc)
	{
		SNFC_DEBUG_MSG("[snfc] ERROR -  gpio_direction_input \n");
		return rc;
	}
	SNFC_DEBUG_MSG_LOW("[snfc] set gpio %d input \n",snfc_gpios.gpio_intu);	

    return rc;
}
Ejemplo n.º 16
0
static int of_hall_data_parsing_dt(struct hall_drvdata *ddata)
{
	struct device_node *np_haptic;
	int gpio;
	enum of_gpio_flags flags;

	np_haptic = of_find_node_by_path("/hall");
	if (np_haptic == NULL) {
		printk("%s : error to get dt node\n", __func__);
		return -EINVAL;
	}

	gpio = of_get_named_gpio_flags(np_haptic, "hall,gpio_flip_cover", 0, &flags);
	ddata->gpio_flip_cover = gpio;

	gpio = gpio_to_irq(gpio);
	ddata->irq_flip_cover = gpio;

	return 0;
}
Ejemplo n.º 17
0
static int of_max77804k_dt(struct device *dev, struct max77804k_platform_data *pdata)
{
	struct device_node *np = dev->of_node;
	struct max77804k_haptic_platform_data *haptic_data;
	int retval = 0;
	
	haptic_data = kzalloc(sizeof(struct max77804k_haptic_platform_data), GFP_KERNEL);
	if (haptic_data == NULL)
		return -ENOMEM;
	if(!np) {
		kfree(haptic_data);
		return -EINVAL;
	}

	pdata->irq_gpio = of_get_named_gpio_flags(np, "max77804k,irq-gpio", 
				0, &pdata->irq_gpio_flags);
	of_property_read_u32(np, "max77804k,irq-base", &pdata->irq_base);
	pdata->wakeup = of_property_read_bool(np, "max77804k,wakeup");
	retval = of_get_named_gpio(np, "max77804k,wc-irq-gpio", 0);
	if (retval < 0)
		pdata->wc_irq_gpio = 0;
	else
		pdata->wc_irq_gpio = retval;
	
	pr_info("%s: irq-gpio: %u \n", __func__, pdata->irq_gpio);
	pr_info("%s: irq-base: %u \n", __func__, pdata->irq_base);
	pr_info("%s: wc-irq-gpio: %u \n", __func__, pdata->wc_irq_gpio);
#ifdef CONFIG_VIBETONZ
	of_property_read_u32(np, "haptic,max_timeout", &haptic_data->max_timeout);
	of_property_read_u32(np, "haptic,duty", &haptic_data->duty);
	of_property_read_u32(np, "haptic,period", &haptic_data->period);
	of_property_read_u32(np, "haptic,pwm_id", &haptic_data->pwm_id);
	pr_info("%s: timeout: %u \n", __func__, haptic_data->max_timeout);
	pr_info("%s: duty: %u \n", __func__, haptic_data->duty);
	pr_info("%s: period: %u \n", __func__, haptic_data->period);
	pr_info("%s: pwm_id: %u \n", __func__, haptic_data->pwm_id);
	pdata->haptic_data = haptic_data;
#endif
	kfree(haptic_data);
	return 0;
}
Ejemplo n.º 18
0
static int of_max77828_dt(struct device *dev, struct max77828_platform_data *pdata)
{
	struct device_node *np = dev->of_node;
	int retval = 0;
	struct max77828_haptic_platform_data  *haptic_data;
	
	haptic_data = kzalloc(sizeof(struct max77828_haptic_platform_data), GFP_KERNEL);
	if (haptic_data == NULL)
		return -ENOMEM;
	if(!np)
		return -EINVAL;

	pdata->irq_gpio = of_get_named_gpio_flags(np, "max77828,irq-gpio", 
				0, &pdata->irq_gpio_flags);
	of_property_read_u32(np, "max77828,irq-base", &pdata->irq_base);
	pdata->wakeup = of_property_read_bool(np, "max77828,wakeup");
	retval = of_get_named_gpio(np, "max77828,wc-irq-gpio", 0);
	if (retval < 0)
		pdata->wc_irq_gpio = 0;
	else
		pdata->wc_irq_gpio = retval;
	
	pr_info("%s: irq-gpio: %u \n", __func__, pdata->irq_gpio);
	pr_info("%s: irq-base: %u \n", __func__, pdata->irq_base);
	pr_info("%s: wc-irq-gpio: %u \n", __func__, pdata->wc_irq_gpio);

#ifdef CONFIG_SS_VIBRATOR
	if (!of_property_read_u32(np, "haptic,mode", &haptic_data->mode))
		haptic_data->mode = 0;

	if (!of_property_read_u32(np, "haptic,divisor", &haptic_data->divisor))
		haptic_data->divisor = 128;

	pr_info("%s: mode: %u \n", __func__, haptic_data->mode);
	pr_info("%s: divisor: %u \n", __func__, haptic_data->divisor);

	pdata->haptic_data = haptic_data;
#endif

	return 0;
}
Ejemplo n.º 19
0
int snfc_rfs_probe(struct device_node *np)
{
    int rc = 0;

        /* register the device file */
    rc = misc_register(&snfc_rfs_device);
    if (rc < 0)
    {
        SNFC_DEBUG_MSG("[snfc_rfs] FAIL!! can not register snfc_rfs \n");
        return rc;
    }

    snfc_gpios.gpio_rfs = of_get_named_gpio_flags(np, "sony,rfs-gpio", 0, NULL);
    rc = gpio_request_one(snfc_gpios.gpio_rfs, GPIOF_IN, "snfc_rfs");
    if (rc)
    {
        SNFC_DEBUG_MSG("[snfc_rfs] gpio_request snfc_rfs fail\n");
    }

    return rc;
}
Ejemplo n.º 20
0
static int ak09911c_parse_dt(struct ak09911c_p *data, struct device *dev)
{
	struct device_node *dNode = dev->of_node;
	enum of_gpio_flags flags;

	if (dNode == NULL)
		return -ENODEV;

	data->m_rst_n = of_get_named_gpio_flags(dNode,
		"ak09911c-i2c,m_rst_n-gpio", 0, &flags);
	if (data->m_rst_n < 0) {
		pr_err("[SENSOR]: %s - m_rst_n error\n", __func__);
		return -ENODEV;
	}

	if (of_property_read_u32(dNode,
			"ak09911c-i2c,chip_pos", &data->chip_pos) < 0)
		data->chip_pos = AK09911C_TOP_LOWER_RIGHT;

	return 0;
}
Ejemplo n.º 21
0
static int tpa2028d_parse_dt(struct device *dev,
		struct audio_amp_platform_data *pdata)
{
	int ret =0;
	u32 value;
	struct device_node *np = dev->of_node;

	ret = of_property_read_u32(np, "tpa2028d,agc_compression_rate",
			&value);
	pdata->agc_compression_rate = (char)value;
	ret = of_property_read_u32(np, "tpa2028d,agc_output_limiter_disable",
			&value);
	pdata->agc_output_limiter_disable = (char)value;
	ret = of_property_read_u32(np, "tpa2028d,agc_fixed_gain",
			&value);
	pdata->agc_fixed_gain = (char)value;
	pdata->enable_gpio = of_get_named_gpio_flags(np,
			"tpa2028d,enable_gpio", 0, NULL);
	pdata->enable = amp_enable;
	return ret;
}
Ejemplo n.º 22
0
static struct clk *of_clk_gpio_delayed_register_get(
		struct of_phandle_args *clkspec, void *_data)
{
	struct clk_gpio_delayed_register_data *data = _data;
	struct clk *clk;
	int gpio;
	enum of_gpio_flags of_flags;

	mutex_lock(&data->lock);

	if (data->clk) {
		mutex_unlock(&data->lock);
		return data->clk;
	}

	gpio = of_get_named_gpio_flags(data->node, data->gpio_name, 0,
			&of_flags);
	if (gpio < 0) {
		mutex_unlock(&data->lock);
		if (gpio == -EPROBE_DEFER)
			pr_debug("%s: %s: GPIOs not yet available, retry later\n",
					data->node->name, __func__);
		else
			pr_err("%s: %s: Can't get '%s' DT property\n",
					data->node->name, __func__,
					data->gpio_name);
		return ERR_PTR(gpio);
	}

	clk = data->clk_register_get(data->node->name, data->parent_names,
			data->num_parents, gpio, of_flags & OF_GPIO_ACTIVE_LOW);
	if (IS_ERR(clk))
		goto out;

	data->clk = clk;
out:
	mutex_unlock(&data->lock);

	return clk;
}
Ejemplo n.º 23
0
static int bq51221_chg_parse_dt(struct device *dev,
		bq51221_charger_platform_data_t *pdata)
{
	int ret = 0;
	struct device_node *np = dev->of_node;

	if (!np) {
		pr_info("%s: np NULL\n", __func__);
		return 1;
	}

	np = of_find_node_by_name(NULL, "battery");
	if (!np) {
		pr_err("%s np NULL\n", __func__);
	} else {
		ret = of_property_read_u32(np,
			"battery,wireless_cc_cv", &pdata->wireless_cc_cv);

		ret = of_property_read_string(np,
			"battery,wirelss_charger_name", (char const **)&pdata->wireless_charger_name);
		if (ret)
			pr_info("%s: Vendor is Empty\n", __func__);
	}


	return ret;

#if 0 /* this part is for bq51221s */
	ret = pdata->irq_gpio = of_get_named_gpio_flags(np, "bq51221-charger,irq-gpio",
			0, &irq_gpio_flags);
	if (ret < 0) {
		dev_err(dev, "%s : can't get irq-gpio\r\n", __FUNCTION__);
		return ret;
	}
	pr_info("%s irq_gpio = %d \n",__func__, pdata->irq_gpio);
	pdata->irq_base = gpio_to_irq(pdata->irq_gpio);

	return 0;
#endif
}
Ejemplo n.º 24
0
static int fbtft_request_one_gpio(struct fbtft_par *par,
                                  const char *name, int index, int *gpiop)
{
    struct device *dev = par->info->device;
    struct device_node *node = dev->of_node;
    int gpio, flags, ret = 0;
    enum of_gpio_flags of_flags;

    if (of_find_property(node, name, NULL)) {
        gpio = of_get_named_gpio_flags(node, name, index, &of_flags);
        if (gpio == -ENOENT)
            return 0;
        if (gpio == -EPROBE_DEFER)
            return gpio;
        if (gpio < 0) {
            dev_err(dev,
                    "failed to get '%s' from DT\n", name);
            return gpio;
        }

        /* active low translates to initially low */
        flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                GPIOF_OUT_INIT_HIGH;
        ret = devm_gpio_request_one(dev, gpio, flags,
                                    dev->driver->name);
        if (ret) {
            dev_err(dev,
                    "gpio_request_one('%s'=%d) failed with %d\n",
                    name, gpio, ret);
            return ret;
        }
        if (gpiop)
            *gpiop = gpio;
        fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
                      __func__, name, gpio);
    }

    return ret;
}
Ejemplo n.º 25
0
static int  ist30xx_parse_dt(struct device *dev, struct ist30xx_tsi_platform_data *pdata)
{
	struct device_node *np = dev->of_node;
	//struct property *prop;
	u32 temp_val;//, num_buttons;
//	u32 button_map[MAX_NUM_OF_BUTTON];
	int rc;
	char propname[128];

	strcpy(propname, "imagis,i2c-pull-up");
	pdata->i2c_pull_up = of_property_read_bool(np, propname);
	tsp_debug("%s : %d \n", propname, pdata->i2c_pull_up);

	// x,y cordination
	strcpy(propname, "imagis,panel-x");
	rc = of_property_read_u32(np, propname, &temp_val);
	if (rc && (rc != -EINVAL)) {
		return rc;
	} else {
		pdata->x_max = temp_val;
	}
	tsp_debug("%s :rc=%d val=%d \n", propname, rc, pdata->x_max);
	
	strcpy(propname, "imagis,panel-y");
	rc = of_property_read_u32(np, propname, &temp_val);
	if (rc && (rc != -EINVAL)) {
		return rc;
	} else {
		pdata->y_max = temp_val;
	}
	tsp_debug("%s :rc=%d val=%d \n", propname, rc, pdata->y_max);

	strcpy(propname, "imagis,i2c_int_gpio");
	pdata->i2c_int_gpio = of_get_named_gpio_flags(np, propname, 0, &pdata->irq_flag); //irq_flag active low or high
	tsp_debug("%s : i2c_int_gpio=%d flag=%d \n", propname, pdata->i2c_int_gpio, pdata->irq_flag);

	return 0;
	
}
Ejemplo n.º 26
0
static int cm32131_parse_dt(struct device *dev, struct cm32131_platform_data *pdata)
{
	int i, ret;
	u32 value;
	u32 array[16];
	enum of_gpio_flags flags;
	struct device_node *np = dev->of_node;
	
	/* parse irq and request gpio */
	value = of_get_named_gpio_flags(np, "capella,intr", 0, &flags);
	pdata->intr = value;
	dev_info(dev, "%s: irq gpio num is %d\n", __func__, pdata->intr);
	if (pdata->intr < 0) {
		return -EINVAL;
	}
	gpio_request(pdata->intr, "gpio_cm32131_intr");
	gpio_direction_input(pdata->intr);
	
	/* general_reg */
	ret = cm32131_get_configs(dev, "capella,configs", array);
	if (ret) {
		dev_err(dev, "Looking up %s property in node %s failed", "capella,configs", np->full_name);
		return -ENODEV;
	}
	for (i = 0; i < 10; i++) {
		pdata->levels[i] = array[i];
	}
	pdata->ALS_slave_address = array[10];
	pdata->check_interrupt_add = array[11];
	pdata->is_cmd = array[12];
#if 0
	ret = of_property_read_string(np, "atmel,vcc_i2c_supply", &pdata->ts_vcc_i2c);
	ret = of_property_read_string(np, "atmel,vdd_ana_supply", &pdata->ts_vdd_ana);
	printk("pwr_en=%d, sleep_pwr_en=%d, vcc_i2c=%s, vdd_ana=%s\n", pdata->pwr_en,
			pdata->sleep_pwr_en, pdata->ts_vcc_i2c, pdata->ts_vdd_ana);
#endif
	return 0;	
}
Ejemplo n.º 27
0
static int of_max77693_dt(struct device *dev, struct max77693_platform_data *pdata)
{
//        int retval = 0;
    struct device_node *np = dev->of_node;
    if(!np)
        return -EINVAL;
    pdata->irq_gpio = of_get_named_gpio_flags(np, "max77693,irq-gpio",
                      0, &pdata->irq_gpio_flags);
    printk(KERN_CRIT "[@@MAX77693@@]%s called, gpio_base = %d",__func__,gpio_to_irq(pdata->irq_gpio));
    of_property_read_u32(np, "max77693,irq-base", &pdata->irq_base);
    pdata->wakeup = of_property_read_bool(np, "max77693,wakeup");
//        retval = of_get_named_gpio(np, "max77693,wc-irq-gpio", 0);
//        if (retval < 0)
//                pdata->wc_irq_gpio = 0;
//        else
//                pdata->wc_irq_gpio = retval;

    pr_info("%s: irq-gpio: %u \n", __func__, pdata->irq_gpio);
    pr_info("%s: irq-base: %u \n", __func__, pdata->irq_base);
//        pr_info("%s: wc-irq-gpio: %u \n", __func__, pdata->wc_irq_gpio);

    return 0;
}
Ejemplo n.º 28
0
static int __devinit chromeos_arm_probe(struct platform_device *pdev)
{
	int gpio, err, active_low;
	enum of_gpio_flags flags;
	struct device_node *np = pdev->dev.of_node;

	if (!np) {
		err = -ENODEV;
		goto err;
	}

	gpio = of_get_named_gpio_flags(np, "write-protect-gpio", 0, &flags);
	if (!gpio_is_valid(gpio)) {
		dev_err(&pdev->dev, "invalid write-protect gpio descriptor\n");
		err = -EINVAL;
		goto err;
	}

	active_low = !!(flags & OF_GPIO_ACTIVE_LOW);

	err = gpio_request_one(gpio, GPIOF_DIR_IN, "firmware-write-protect");
	if (err)
		goto err;
	err = gpio_sysfs_set_active_low(gpio, active_low);
	if (err)
		goto err;
	gpio_export(gpio, 0);
	gpio_export_link(&pdev->dev, "write-protect", gpio);

	dev_info(&pdev->dev, "chromeos system detected\n");

	err = 0;
err:
	of_node_put(np);

	return err;
}
static int ncp6335d_parse_gpio(struct device_node *node,
					struct ncp6335d_info *dd)
{
	int ret = 0, gpio;
	enum of_gpio_flags flags;

	if (!of_find_property(node, "onnn,vsel-gpio", NULL))
		return ret;

	/* Get GPIO connected to vsel and set its output */
	gpio = of_get_named_gpio_flags(node,
			"onnn,vsel-gpio", 0, &flags);
	if (!gpio_is_valid(gpio)) {
		if (gpio != -EPROBE_DEFER)
			dev_err(dd->dev, "Could not get vsel, ret = %d\n",
				gpio);
		return gpio;
	}

	ret = devm_gpio_request(dd->dev, gpio, "ncp6335d_vsel");
	if (ret) {
		dev_err(dd->dev, "Failed to obtain gpio %d ret = %d\n",
				gpio, ret);
			return ret;
	}

	ret = gpio_direction_output(gpio, flags & OF_GPIO_ACTIVE_LOW ? 0 : 1);
	if (ret) {
		dev_err(dd->dev, "Failed to set GPIO %d to: %s, ret = %d",
				gpio, flags & OF_GPIO_ACTIVE_LOW ?
				"GPIO_LOW" : "GPIO_HIGH", ret);
		return ret;
	}

	return ret;
}
/* Fail if any of the required gpios is absent. */
static int mdm_dt_parse_gpios(struct mdm_ctrl *mdm)
{
	int i, val, rc = 0;
	struct device_node *node = mdm->dev->of_node;
//	enum of_gpio_flags flags = OF_GPIO_ACTIVE_LOW;

	for (i = 0; i < NUM_GPIOS; i++)
		mdm->gpios[i] = INVALID_GPIO;

	for (i = 0; i < ARRAY_SIZE(gpio_map); i++) {
		val = of_get_named_gpio(node, gpio_map[i].name, 0);
		if (val >= 0) {
			MDM_GPIO(mdm, gpio_map[i].index) = val;
			pr_info("[MIF] %s, gpio : %s\n", __func__, gpio_map[i].name);
		}
	}
#if 0
	/* These two are special because they can be inverted. */
	val = of_get_named_gpio_flags(node, "qcom,ap2mdm-soft-reset-gpio",
						0, &flags);
	if (val >= 0) {
		MDM_GPIO(mdm, AP2MDM_SOFT_RESET) = val;
		if (flags & OF_GPIO_ACTIVE_LOW)
			mdm->soft_reset_inverted = 1;
	}
#endif
	/* Verify that the required gpios have valid values */
	for (i = 0; i < ARRAY_SIZE(required_gpios); i++) {
		if (MDM_GPIO(mdm, required_gpios[i]) == INVALID_GPIO) {
			rc = -ENXIO;
			break;
		}
	}
	mdm_debug_gpio_show(mdm);
	return rc;
}