コード例 #1
0
static void lm3630_set_main_current_level(struct i2c_client *client, int level)
{
	struct lm3630_device *dev = i2c_get_clientdata(client);
	int min_brightness = dev->min_brightness;
	int max_brightness = dev->max_brightness;

	if (level == -BOOT_BRIGHTNESS)
		level = dev->default_brightness;

	cur_main_lcd_level = level;
	dev->bl_dev->props.brightness = cur_main_lcd_level;

	store_level_used = 0;

	mutex_lock(&dev->bl_mutex);
	if (level != 0) {
		if (level > 0 && level <= min_brightness)
			level = min_brightness;
		else if (level > max_brightness)
			level = max_brightness;

		if (dev->blmap) {
			if (level < dev->blmap_size) {
				cal_value = dev->blmap[level];
#ifdef CONFIG_MACH_MSM8974_VU3_KR
					if(lge_get_boot_mode() == LGE_BOOT_MODE_FACTORY2||lge_get_boot_mode() == LGE_BOOT_MODE_PIFBOOT||lge_get_boot_mode() == LGE_BOOT_MODE_PIFBOOT2)
						cal_value = dev->blmap[130];
#endif
				lm3630_write_reg(client, 0x03,
						cal_value);
			} else
				dev_warn(&client->dev, "invalid index %d:%d\n",
						dev->blmap_size,
						level);
		} else {
			cal_value = level;
			lm3630_write_reg(client, 0x03, cal_value);
		}
	} else
		lm3630_write_reg(client, 0x00, 0x00);

	mutex_unlock(&dev->bl_mutex);

	#ifdef CONFIG_MACH_MSM8974_VU3_KR
		pr_info("[LCD][DEBUG] %s : backlight level=%d, cal_value=%d \n",
				__func__, level, cal_value);
	#else
		pr_debug("[LCD][DEBUG] %s : backlight level=%d, cal_value=%d \n",
				__func__, level, cal_value);
	#endif

}
コード例 #2
0
static ssize_t set_pattern(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
	ssize_t ret = -EINVAL;
	int pattern_num = 0;

	if (sscanf(buf, "%d", &pattern_num) != 1) {
		printk("[RGB LED] bad arguments ");
	}
	ret = size;

	if (zw_no_charger_in_zwait())
		return ret;

	if(lge_get_boot_mode() <= LGE_BOOT_MODE_CHARGERLOGO) {
		printk("[RGB LED] pattern_num=%d\n", pattern_num);
#if !(defined(CONFIG_MACH_MSM8974_B1_KR) || defined(CONFIG_MACH_MSM8974_B1W))
		if (!pattern_num || pattern_num == 35 || pattern_num == 36 || pattern_num == 1035)
			set_kpdbl_pattern(pattern_num);
#endif
		if ((pattern_num != 35)&&(pattern_num != 36))
			change_led_pattern(pattern_num);
	}

	return ret;
}
コード例 #3
0
ファイル: led-class.c プロジェクト: Vagelis1608/-V-_Kernel_2
static ssize_t led_brightness_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	struct led_classdev *led_cdev = dev_get_drvdata(dev);
	ssize_t ret = -EINVAL;
	char *after;
	unsigned long state = simple_strtoul(buf, &after, 10);
	size_t count = after - buf;

#ifdef CONFIG_LEDS_PM8226_EMOTIONAL
	if(lge_get_boot_mode() != LGE_BOOT_MODE_CHARGERLOGO) {
		if (!strncmp(led_cdev->name, "red", 3)){
			change_led_mode();
		}
	}
#endif

	if (isspace(*after))
		count++;

	if (count == size) {
		ret = count;

		if (state == LED_OFF)
			led_trigger_remove(led_cdev);
		led_set_brightness(led_cdev, state);
	}

	return ret;
}
コード例 #4
0
int touch_boot_mode(void)
{
	int ret = 0;
	if (lge_get_boot_mode() == LGE_BOOT_MODE_CHARGERLOGO)
		ret = TOUCH_CHARGER_MODE;

	return ret;
}
コード例 #5
0
ファイル: siw_touch_sys.c プロジェクト: siw-touch/touch
int siw_touch_boot_mode_tc_check(struct device *dev)
{
	int ret = 0;

#if defined(CONFIG_SIW_GET_BOOT_MODE)
	if (sys_get_boot_mode() == BOOT_MODE_CHARGERLOGO) {
		return 1;
	}
#elif defined(CONFIG_TOUCHSCREEN_SIW_LG4895_F650)
	if ((lge_get_boot_mode() == LGE_BOOT_MODE_QEM_910K) ||
		(lge_get_boot_mode() == LGE_BOOT_MODE_PIF_910K)) {
		return 1;
	}
#endif

	return ret;
}
コード例 #6
0
static ssize_t set_pattern(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
	ssize_t ret = -EINVAL;
	int pattern_num = 0;
	struct power_supply *chg_psy;
	union power_supply_propval chg_online;
#if defined(CONFIG_MACH_MSM8974_G3_KDDI_EVB) || defined(CONFIG_MACH_MSM8974_G3_KDDI)
	union power_supply_propval usb_chg_online;
#endif

	if (sscanf(buf, "%d", &pattern_num) != 1) {
		printk("[RGB LED] bad arguments ");
	}
	ret = size;

	chg_psy = power_supply_get_by_name("ac");
	if (chg_psy) {
		chg_psy->get_property(chg_psy, POWER_SUPPLY_PROP_PRESENT, &chg_online);
	} else {
		printk("[RGB LED] Cannot get power supply property.\n");
		chg_online.intval = 0;
	}
#if defined(CONFIG_MACH_MSM8974_G3_KDDI_EVB) || defined(CONFIG_MACH_MSM8974_G3_KDDI)
	chg_psy = power_supply_get_by_name("usb");
	if (chg_psy) {
		chg_psy->get_property(chg_psy, POWER_SUPPLY_PROP_PRESENT, &usb_chg_online);
	} else {
		printk("[RGB LED] Cannot get (USB) power supply property.\n");
		usb_chg_online.intval = 0;
	}
#endif

#if defined(CONFIG_MACH_MSM8974_G3_KDDI_EVB) || defined(CONFIG_MACH_MSM8974_G3_KDDI)
	printk("[RGB LED] chg_online.intval = %d usb_chg_online.intval = %d\n",
		chg_online.intval, usb_chg_online.intval);
	if (!(chg_online.intval || usb_chg_online.intval) && pattern_num == 3)
		return ret;
#else
	printk("[RGB LED] chg_online.intval = %d\n", chg_online.intval);
	if (!chg_online.intval && pattern_num == 3)
		return ret;
#endif
	if (lge_get_boot_mode() <= LGE_BOOT_MODE_CHARGERLOGO) {
		printk("[RGB LED] pattern_num = %d\n", pattern_num);
#if !(defined(CONFIG_MACH_MSM8974_G3_LGU) || defined(CONFIG_MACH_MSM8974_G3_SKT) || defined(CONFIG_MACH_MSM8974_G3_KT) || defined(CONFIG_MACH_MSM8974_G3_ATT) || defined(CONFIG_MACH_MSM8974_G3_VZW) || defined(CONFIG_MACH_MSM8974_G3_SPR_US) || defined(CONFIG_MACH_MSM8974_G3_USC_US) || defined(CONFIG_MACH_MSM8974_G3_TMO_US) || defined(CONFIG_MACH_MSM8974_G3_GLOBAL_COM) || defined(CONFIG_MACH_MSM8974_G3_CN) || defined(CONFIG_MACH_MSM8974_G3_CA) || defined(CONFIG_MACH_MSM8974_G3_LRA))

		if (!pattern_num || pattern_num == 35 || pattern_num == 36 || pattern_num == 1035)
			set_kpdbl_pattern(pattern_num);
#endif
		if ((pattern_num != 35) && (pattern_num != 36))
			change_led_pattern(pattern_num);
	}

	return ret;
}
コード例 #7
0
bool pn544_validate_boot_mode(void) {
    enum lge_boot_mode_type boot_mode;
    boot_mode = lge_get_boot_mode();
	printk("pn544_probe() boot_mode : %d\n",boot_mode);
    if (boot_mode == LGE_BOOT_MODE_FACTORY || boot_mode == LGE_BOOT_MODE_FACTORY2 || boot_mode == LGE_BOOT_MODE_MINIOS)
    {
        printk("boot_mode :LGE_BOOT_MODE_FACTORY or LGE_BOOT_MODE_FACTORY2 or LGE_BOOT_MODE_MINIOS\n");
        return true;
    }
    return false;
}
コード例 #8
0
ファイル: siw_touch_sys.c プロジェクト: siw-touch/touch
int siw_touch_get_boot_mode(void)
{
#if defined(CONFIG_SIW_GET_BOOT_MODE)
	if (sys_get_boot_mode() == BOOT_MODE_CHARGERLOGO) {
		return SIW_TOUCH_CHARGER_MODE;
	}
#elif defined(CONFIG_TOUCHSCREEN_SIW_LG4895_F650) ||	\
	defined(CONFIG_TOUCHSCREEN_SIW_LG4946_F700)
	if (lge_get_boot_mode() == LGE_BOOT_MODE_CHARGERLOGO) {
		return SIW_TOUCH_CHARGER_MODE;
	}
#endif

	return 0;
}
コード例 #9
0
static int get_factory_cable(void)
{
	struct chg_cable_info info;
	enum lge_boot_mode_type boot_mode;
	int res;

	/* get cable infomation */
	res = lge_pm_get_cable_info(&info);
	if (res < 0) {
		pr_err("Error get cable information from PMIC %d\n", res);
		return 0;
	}

	switch(info.cable_type) {
	/* It is factory cable */
	case CABLE_56K:
		res = LGEUSB_FACTORY_56K;
		break;
	case CABLE_130K:
		res = LGEUSB_FACTORY_130K;
		break;
	case CABLE_910K:
		res = LGEUSB_FACTORY_910K;
		break;
	/* It is normal cable */
	default:
		res = 0;
		break;
	}

	/* if boot mode is factory,
	 * cable must be factory cable.
	 */
	boot_mode = lge_get_boot_mode();
	switch(boot_mode) {
	case LGE_BOOT_MODE_FACTORY:
		res = LGEUSB_FACTORY_130K;
		break;
	case LGE_BOOT_MODE_FACTORY2:
	case LGE_BOOT_MODE_PIFBOOT:
		res = LGEUSB_FACTORY_56K;
		break;
	default:
		break;
	}

	return res;
}
コード例 #10
0
ファイル: led-class.c プロジェクト: Vagelis1608/-V-_Kernel_2
static ssize_t set_pattern(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
	ssize_t ret = -EINVAL;
	int pattern_num = 0;

	if (sscanf(buf, "%d", &pattern_num) != 1) {
		printk("[RGB LED] bad arguments ");
	}
	ret = size;

	if(lge_get_boot_mode() <= LGE_BOOT_MODE_CHARGERLOGO) {
		printk("[RGB LED] pattern_num=%d\n", pattern_num);
		if (pattern_num != 35)
			change_led_pattern(pattern_num);
	}

	return ret;
}
コード例 #11
0
static void lm3533_set_main_current_level(struct i2c_client *client, int level)
{
	struct lm3533_device *dev;
	enum lge_boot_mode_type bootmode = lge_get_boot_mode();
	dev = (struct lm3533_device *)i2c_get_clientdata(client);

	if(bootmode == LGE_BOOT_MODE_FACTORY2 || bootmode == LGE_BOOT_MODE_PIFBOOT)
		level = dev->factory_brightness;

	if (level == -1)
		level = dev->default_brightness;

	cur_main_lcd_level = level;
	dev->bl_dev->props.brightness = cur_main_lcd_level;

	mutex_lock(&main_lm3533_dev->bl_mutex);
	if (level != 0) {
		cal_value = mapped_value[level];
		lm3533_write_reg(main_lm3533_dev->client, 0x40, cal_value);
	} else {
		lm3533_write_reg(client, 0x27, 0x00);
	}
	mutex_unlock(&main_lm3533_dev->bl_mutex);
}
コード例 #12
0
ファイル: lm3630_bl.c プロジェクト: jdongyun/Zeta-Chromium-N5
static int lm3630_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct lm3630_platform_data *pdata;
	struct lm3630_device *dev;
	struct backlight_device *bl_dev;
	struct backlight_properties props;
	struct device_node *dev_node = client->dev.of_node;
	int ret = 0;

	dev = kzalloc(sizeof(struct lm3630_device), GFP_KERNEL);
	if (!dev) {
		pr_err("%s: failed to allocate lm3630_device\n", __func__);
		return -ENOMEM;
	}

	if (dev_node) {
		ret = lm3630_parse_dt(dev_node, dev);
		if (ret) {
			pr_err("%s: failed to parse dt\n", __func__);
			goto err_parse_dt;
		}
	} else {
		pdata = client->dev.platform_data;
		if (pdata == NULL) {
			pr_err("%s: no platform data\n", __func__);
			goto err_parse_dt;
		}

		dev->en_gpio = pdata->en_gpio;
		dev->boost_ctrl_reg = pdata->boost_ctrl_reg;
		dev->bank_sel = pdata->bank_sel;
		dev->linear_map = pdata->linear_map;
		dev->max_current = pdata->max_current;
		dev->min_brightness = pdata->min_brightness;
		dev->default_brightness = pdata->default_brightness;
		dev->max_brightness = pdata->max_brightness;
		dev->pwm_enable = pdata->pwm_enable;
		dev->blmap_size = pdata->blmap_size;
		if (dev->blmap_size)
			dev->blmap = pdata->blmap;
	}

	/* initialize register values for hw reset */
	lm3630_set_init_values(dev);

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = dev->max_brightness;

	bl_dev = backlight_device_register(I2C_BL_NAME, &client->dev,
			NULL, &lm3630_bl_ops, &props);
	if (IS_ERR(bl_dev)) {
		pr_err("%s: failed to register backlight\n", __func__);
		ret = PTR_ERR(bl_dev);
		goto err_bl_dev_reg;
	}

#ifdef CONFIG_MACH_LGE
	/* HACK: disable fb notifier unless off-mode charge */
	if (lge_get_boot_mode() != LGE_BOOT_MODE_CHARGER)
		fb_unregister_client(&bl_dev->fb_notif);
#endif

	bl_dev->props.max_brightness = dev->max_brightness;
	bl_dev->props.brightness = dev->default_brightness;
	bl_dev->props.power = FB_BLANK_UNBLANK;
	dev->bl_dev = bl_dev;
	dev->client = client;
	i2c_set_clientdata(client, dev);

	if (gpio_is_valid(dev->en_gpio)) {
		ret = gpio_request_one(dev->en_gpio, GPIOF_OUT_INIT_HIGH,
					"lm3630_en");
		if (ret) {
			pr_err("%s: failed to request en_gpio\n", __func__);
			goto err_gpio_request;
		}
	}

	ret = device_create_file(&client->dev,
			&dev_attr_lm3630_level);
	if (ret) {
		pr_err("%s: failed to create sysfs level\n", __func__);
		goto err_create_sysfs_level;
	}

	ret = lm3630_create_debugfs_entries(dev);
	if (ret) {
		pr_err("%s: lm3630_create_debugfs_entries failed\n", __func__);
		goto err_create_debugfs;
	}

	lm3630_dev = dev;

	pr_info("%s: lm3630 probed\n", __func__);
	return 0;

err_create_debugfs:
	device_remove_file(&client->dev, &dev_attr_lm3630_level);
err_create_sysfs_level:
	if (gpio_is_valid(dev->en_gpio))
		gpio_free(dev->en_gpio);
err_gpio_request:
	backlight_device_unregister(bl_dev);
err_bl_dev_reg:
	if (dev_node && dev->blmap)
		kfree(dev->blmap);
err_parse_dt:
	kfree(dev);
	return ret;
}
コード例 #13
0
ファイル: dwc3_otg.c プロジェクト: Fechinator/FechdaKernel
static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA)
{
	static int power_supply_type;
	struct dwc3_otg *dotg = container_of(phy->otg, struct dwc3_otg, otg);
#if defined(CONFIG_DWC3_MSM_BC_12_VZW_SUPPORT) && defined(CONFIG_LGE_PM)
	static bool chglogo_check = false;
#endif

	if (!dotg->psy || !dotg->charger) {
		dev_err(phy->dev, "no usb power supply/charger registered\n");
		return 0;
	}

	if (dotg->charger->charging_disabled)
		return 0;

#ifdef CONFIG_LGE_PM
	if (dotg->charger->chg_type == DWC3_SDP_CHARGER ||
			dotg->charger->chg_type == DWC3_FLOATED_CHARGER)
#else
	if (dotg->charger->chg_type == DWC3_SDP_CHARGER)
#endif
		power_supply_type = POWER_SUPPLY_TYPE_USB;
	else if (dotg->charger->chg_type == DWC3_CDP_CHARGER)
		power_supply_type = POWER_SUPPLY_TYPE_USB_CDP;
	else if (dotg->charger->chg_type == DWC3_DCP_CHARGER ||
			dotg->charger->chg_type == DWC3_PROPRIETARY_CHARGER)
		power_supply_type = POWER_SUPPLY_TYPE_USB_DCP;
	else
#ifdef CONFIG_LGE_PM
		/* [email protected]
		 * healthd get battery psy type at init only.
		 * If cable detach before healthd init,
		 * healthd recognize usb psy as battery type.
		 */
		power_supply_type = POWER_SUPPLY_TYPE_UNKNOWN;
#else
		power_supply_type = POWER_SUPPLY_TYPE_BATTERY;
#endif

#ifndef CONFIG_LGE_PM
	power_supply_set_supply_type(dotg->psy, power_supply_type);
#endif

#if defined (CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4)
	update_status(1, dotg->charger->chg_type);
#endif

#if defined(CONFIG_DWC3_MSM_BC_12_VZW_SUPPORT) && defined(CONFIG_LGE_PM)
	if (!chglogo_check && lge_get_boot_mode() == LGE_BOOT_MODE_CHARGERLOGO &&
			dotg->charger->chg_type == DWC3_SDP_CHARGER) {
		if (mA > IUNIT)
			chglogo_check = true;
		else if (mA <= 2) {
			dotg->charger->max_power = mA;
			return 0;
		}
	}

	if (mA > 2 && lge_pm_get_cable_type() != NO_INIT_CABLE) {
		if (dotg->charger->chg_type == DWC3_DCP_CHARGER)
			mA = lge_pm_get_ta_current();
	}
#elif defined(CONFIG_LGE_PM)
	if (mA > 2 && lge_pm_get_cable_type() != NO_INIT_CABLE) {
		if (dotg->charger->chg_type == DWC3_SDP_CHARGER) {
			if (dotg->dwc->gadget.speed == USB_SPEED_SUPER) {
				if (dotg->charger->max_power > 2)
					dotg->charger->max_power = 0;
				mA = DWC3_USB30_CHG_CURRENT;
			} else {
				mA = lge_pm_get_usb_current();
			}
#ifdef CONFIG_QPNP_CHARGER
			/* For MST, boost current up over 900mA in spite of USB */
			if (pseudo_batt_info.mode && mA == 500 )
				mA = DWC3_USB30_CHG_CURRENT;
#endif
		} else if (dotg->charger->chg_type == DWC3_DCP_CHARGER) {
			mA = lge_pm_get_ta_current();
		} else if (dotg->charger->chg_type == DWC3_FLOATED_CHARGER) {
			mA = lge_pm_get_usb_current();
		}
	}
#endif

	if (dotg->charger->chg_type == DWC3_CDP_CHARGER)
		mA = DWC3_IDEV_CHG_MAX;

	if (dotg->charger->max_power == mA)
		return 0;

	dev_info(phy->dev, "Avail curr from USB = %u\n", mA);

/* [email protected] make psy getter and move it above power_supply_type setter. 2014-02-06 */
#ifdef CONFIG_LGE_PM
#ifndef CONFIG_USB_DWC3_LGE_SINGLE_PSY
	if (dwc3_otg_get_psy(phy) < 0)
		goto psy_error;
#else
	if (strcmp(dotg->psy->name, "usb")) {
		pr_info("%s psy name is %s, so change psy to usb.\n", __func__, dotg->psy->name);
		dotg->psy = power_supply_get_by_name("usb");
		if (!dotg->psy)
			goto psy_error;
	}
#endif
	power_supply_set_supply_type(dotg->psy, power_supply_type);
#endif

	if (dotg->charger->max_power <= 2 && mA > 2) {
		/* Enable charging */
		if (power_supply_set_online(dotg->psy, true))
			goto psy_error;
		if (power_supply_set_current_limit(dotg->psy, 1000*mA))
			goto psy_error;
#ifdef CONFIG_QPNP_CHARGER
		if (!strncmp(dotg->psy->name, "ac", 2)) {
			dotg->psy = power_supply_get_by_name("usb");
			if (!dotg->psy)
				goto psy_error;

			if (power_supply_set_online(dotg->psy, true))
				goto psy_error;

			if (power_supply_set_supply_type(dotg->psy, power_supply_type))
				goto psy_error;

			if (power_supply_set_current_limit(dotg->psy, 1000*mA))
				goto psy_error;

			dotg->psy = power_supply_get_by_name("ac");
			if (!dotg->psy)
				goto psy_error;
		}
#endif
	} else if (dotg->charger->max_power > 0 && (mA == 0 || mA == 2)) {
		/* Disable charging */
		if (power_supply_set_online(dotg->psy, false))
			goto psy_error;
		/* Set max current limit */
		if (power_supply_set_current_limit(dotg->psy, 0))
			goto psy_error;

#ifdef CONFIG_QPNP_CHARGER
		if (!strncmp(dotg->psy->name, "ac", 2)) {
			dotg->psy = power_supply_get_by_name("usb");
			if (!dotg->psy)
				goto psy_error;

			if (power_supply_set_online(dotg->psy, false))
				goto psy_error;

			if (power_supply_set_supply_type(dotg->psy, power_supply_type))
				goto psy_error;

			if (power_supply_set_current_limit(dotg->psy, 0))
				goto psy_error;

			dotg->psy = power_supply_get_by_name("ac");
			if (!dotg->psy)
				goto psy_error;
		}
#endif
	}

	power_supply_changed(dotg->psy);

	dotg->charger->max_power = mA;

	return 0;

psy_error:
	dev_dbg(phy->dev, "power supply error when setting property\n");
	return -ENXIO;
}
コード例 #14
0
static int rt8542_probe(struct i2c_client *i2c_dev,
		const struct i2c_device_id *id)
{
	struct backlight_platform_data *pdata;
	struct rt8542_device *dev;
	struct backlight_device *bl_dev;
	struct backlight_properties props;
	int err;

	printk(">> %s START\n", __func__);

#ifdef CONFIG_OF
	if (&i2c_dev->dev.of_node) {
		pdata = devm_kzalloc(&i2c_dev->dev,
				sizeof(struct backlight_platform_data),
				GFP_KERNEL);
		if (!pdata) {
			pr_err("%s: Failed to allocate memory\n", __func__);

			pr_debug("<< %s END (error#1: -ENOMEM)\n", __func__);
			return -ENOMEM;
		}
		err = rt8542_parse_dt(&i2c_dev->dev, pdata);
		if (err != 0) {
			pr_debug("<< %s END (error#2: %d)\n", __func__, err);
			return err;
		}
	} else {
		pdata = i2c_dev->dev.platform_data;
	}
#else
	pdata = i2c_dev->dev.platform_data;
#endif

	pr_err("[CHECK] pdata->gpio:%d", pdata->gpio);
	if (pdata->gpio && gpio_request(pdata->gpio, "rt8542 reset") != 0) {
		pr_err("%s: Faild to request gpio", __func__);
		pr_debug("<< %s END (error#3: -ENODEV)\n", __func__);
		return -ENODEV;
	}

	rt8542_i2c_client = i2c_dev;

	dev = kzalloc(sizeof(struct rt8542_device), GFP_KERNEL);
	if (dev == NULL) {
		dev_err(&i2c_dev->dev, "fail alloc for rt8542_device\n");
		pr_debug("<< %s END (error#4)\n", __func__);
		return 0;
	}
	main_rt8542_dev = dev;

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;

	props.max_brightness = MAX_BRIGHTNESS_RT8542;
	bl_dev = backlight_device_register(I2C_BL_NAME, &i2c_dev->dev,
			NULL, &rt8542_bl_ops, &props);

#if defined(CONFIG_MACH_MSM8916_C30_TRF_US) || defined(CONFIG_MACH_MSM8916_C30C_TRF_US)
		if(get_lcd_id())
		{
			pr_err("<< %s TIANMA\n", __func__);
			bl_dev->props.max_brightness = MAX_BRIGHTNESS_RT8542 + 1; /* TIANMA PANEL needs max brightness value to 0x7E */
		}
		else
		{
			pr_err("<< %s BYD\n", __func__);
			bl_dev->props.max_brightness = MAX_BRIGHTNESS_RT8542;
		}
#else
	bl_dev->props.max_brightness = MAX_BRIGHTNESS_RT8542;
#endif

	bl_dev->props.brightness = DEFAULT_BRIGHTNESS;
	bl_dev->props.power = FB_BLANK_UNBLANK;

	dev->bl_dev = bl_dev;
	dev->client = i2c_dev;

	dev->gpio = pdata->gpio;
	dev->max_current = pdata->max_current;
	dev->min_brightness = pdata->min_brightness;
	dev->default_brightness = pdata->default_brightness;
#if defined(CONFIG_MACH_MSM8916_C30_TRF_US) || defined(CONFIG_MACH_MSM8916_C30C_TRF_US)
	if(get_lcd_id())
	{
		pr_err("<< %s TIANMA\n", __func__);
		dev->max_brightness = pdata->max_brightness + 1;  /* TIANMA PANEL needs max brightness value to 0x7E */
	}
	else
	{
		pr_err("<< %s BYD\n", __func__);
		dev->max_brightness = pdata->max_brightness;
	}
#else
	dev->max_brightness = pdata->max_brightness;
#endif
	dev->blmap_size = pdata->blmap_size;
	dev->factory_brightness = pdata->factory_brightness;

	if (dev->blmap_size) {
		dev->blmap =
			kzalloc(sizeof(char) * dev->blmap_size, GFP_KERNEL);
		if (!dev->blmap) {
			pr_err("%s: Failed to allocate memory\n", __func__);
			pr_debug("<< %s END (error#5: -ENOMEM)\n", __func__);
			return -ENOMEM;
		}
		memcpy(dev->blmap, pdata->blmap, dev->blmap_size);
	} else {
		dev->blmap = NULL;
	}

	if (gpio_get_value(dev->gpio))
		backlight_status = BL_ON;
	else
		backlight_status = POWER_OFF;

	i2c_set_clientdata(i2c_dev, dev);

	mutex_init(&dev->bl_mutex);

	err = device_create_file(&i2c_dev->dev,
			&dev_attr_rt8542_level);
	err = device_create_file(&i2c_dev->dev,
			&dev_attr_rt8542_backlight_on_off);
	err = device_create_file(&i2c_dev->dev,
			&dev_attr_rt8542_exp_min_value);
#if defined(CONFIG_BACKLIGHT_CABC_DEBUG_ENABLE)
	err = device_create_file(&i2c_dev->dev,
			&dev_attr_rt8542_pwm);
#endif

#if defined(CONFIG_BL_CURVE)
	err = device_create_file(&i2c_dev->dev, &dev_attr_i2c_bl_blmap);
#endif
	/* To reduce current consumption during booting,
	  decrease the backlight level to boot well. */
#if defined(RT8542_FLED_EN)

#ifdef FLASH_PORTING_TEMP
	//Porting Temp: build error -> comment out
	//if (lge_get_boot_mode() >= LGE_BOOT_MODE_QEM_56K)
	//	dev->default_brightness = dev->factory_brightness;
#else
	if (lge_get_boot_mode() >= LGE_BOOT_MODE_QEM_56K)
		dev->default_brightness = dev->factory_brightness;
#endif

#endif
	rt8542_backlight_on(dev->default_brightness);

#if defined(RT8542_FLED_EN)
if (!id) {
		pr_err("rt8542_probe: id is NULL");
		id = rt8542_bl_id;
	}
	return msm_flash_i2c_probe(i2c_dev, id);
#endif

	pr_debug("<< %s END (OK)\n", __func__);
	return 0;
}
コード例 #15
0
static void rt8542_set_main_current_level(struct i2c_client *client, int level)
{
	struct rt8542_device *dev = i2c_get_clientdata(client);
	int min_brightness = dev->min_brightness;
	int max_brightness = dev->max_brightness;

	if (level == -BOOT_BRIGHTNESS)
		level = dev->default_brightness;

	cur_main_lcd_level = level;
	dev->bl_dev->props.brightness = cur_main_lcd_level;

	store_level_used = 0;

	mutex_lock(&dev->bl_mutex);

#ifdef CONFIG_LGE_PM_FACTORY_CABLE
	if ( ( LGE_BOOT_MODE_QEM_910K == lge_get_boot_mode() || LGE_BOOT_MODE_PIF_910K == lge_get_boot_mode() ) && ( BATT_ID_UNKNOWN == read_lge_battery_id()) ){
			pr_err("Set LCD brightness minimum, No Battery or No proper Battery with 910K Cable\n");
			rt8542_write_reg(client, 0x05, 0x05);
	} else{
		if (level != 0) {
			if (level > 0 && level <= min_brightness)
				level = min_brightness;
			else if (level > max_brightness)
				level = max_brightness;

			if (dev->blmap) {
				if (level < dev->blmap_size) {
					cal_value = dev->blmap[level];
					rt8542_write_reg(client, 0x05, cal_value);
				} else
					dev_warn(&client->dev, "invalid index %d:%d\n",
							dev->blmap_size,
							level);
			} else {
				cal_value = level;
				rt8542_write_reg(client, 0x05, cal_value);
			}
		} else{
			rt8542_write_reg(client, 0x05, 0x00);
			bl_ctrl = 0;
			rt8542_read_reg(main_rt8542_dev->client, 0x0A, &bl_ctrl);
			bl_ctrl &= 0xE6;
			rt8542_write_reg(main_rt8542_dev->client, 0x0A, bl_ctrl);
		}
	}
#else
	if (level != 0) {
		if (level > 0 && level <= min_brightness)
			level = min_brightness;
		else if (level > max_brightness)
			level = max_brightness;

		if (dev->blmap) {
			if (level < dev->blmap_size) {
				cal_value = dev->blmap[level];
				rt8542_write_reg(client, 0x05, cal_value);
			} else
				dev_warn(&client->dev, "invalid index %d:%d\n",
						dev->blmap_size,
						level);
		} else {
			cal_value = level;
			rt8542_write_reg(client, 0x05, cal_value);
		}
	} else{
		rt8542_write_reg(client, 0x05, 0x00);
		bl_ctrl = 0;
		rt8542_read_reg(main_rt8542_dev->client, 0x0A, &bl_ctrl);
		bl_ctrl &= 0xE6;
		rt8542_write_reg(main_rt8542_dev->client, 0x0A, bl_ctrl);
	}
#endif
	mutex_unlock(&dev->bl_mutex);

	pr_debug("%s : backlight level=%d, cal_value=%d\n",
		__func__, level, cal_value);
}
コード例 #16
0
ファイル: dwc3_otg.c プロジェクト: Defector/Defkernel_F320
static int dwc3_otg_set_power(struct usb_phy *phy, unsigned mA)
{
	static int power_supply_type;
	struct dwc3_otg *dotg = container_of(phy->otg, struct dwc3_otg, otg);
#if defined(CONFIG_DWC3_MSM_BC_12_VZW_SUPPORT) && defined(CONFIG_LGE_PM)
	static bool chglogo_check = false;
#endif

	if (!dotg->psy || !dotg->charger) {
		dev_err(phy->dev, "no usb power supply/charger registered\n");
		return 0;
	}

	if (dotg->charger->charging_disabled)
		return 0;

#ifdef CONFIG_LGE_PM
	if (dotg->charger->chg_type == DWC3_SDP_CHARGER ||
			dotg->charger->chg_type == DWC3_FLOATED_CHARGER)
#else
	if (dotg->charger->chg_type == DWC3_SDP_CHARGER)
#endif
		power_supply_type = POWER_SUPPLY_TYPE_USB;
	else if (dotg->charger->chg_type == DWC3_CDP_CHARGER)
		power_supply_type = POWER_SUPPLY_TYPE_USB_CDP;
	else if (dotg->charger->chg_type == DWC3_DCP_CHARGER ||
			dotg->charger->chg_type == DWC3_PROPRIETARY_CHARGER)
		power_supply_type = POWER_SUPPLY_TYPE_USB_DCP;
	else
		power_supply_type = POWER_SUPPLY_TYPE_UNKNOWN;

#ifndef CONFIG_LGE_PM
	power_supply_set_supply_type(dotg->psy, power_supply_type);
#endif

#if defined (CONFIG_TOUCHSCREEN_SYNAPTICS_G3) && defined (CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4)
	update_status(1, dotg->charger->chg_type);
#endif

#if defined(CONFIG_DWC3_MSM_BC_12_VZW_SUPPORT) && defined(CONFIG_LGE_PM)
	if (!chglogo_check && lge_get_boot_mode() == LGE_BOOT_MODE_CHARGERLOGO &&
			dotg->charger->chg_type == DWC3_SDP_CHARGER) {
		if (mA > IUNIT)
			chglogo_check = true;
		else if (mA <= 2) {
			dotg->charger->max_power = mA;
			return 0;
		}
	}

	if (mA > 2 && lge_pm_get_cable_type() != NO_INIT_CABLE) {
		if (dotg->charger->chg_type == DWC3_DCP_CHARGER)
			mA = lge_pm_get_ta_current();
	}
#elif defined(CONFIG_LGE_PM)
	if (mA > 2 && lge_pm_get_cable_type() != NO_INIT_CABLE) {
		if (dotg->charger->chg_type == DWC3_SDP_CHARGER) {
			if (dotg->dwc->gadget.speed == USB_SPEED_SUPER) {
				if (dotg->charger->max_power > 2)
					dotg->charger->max_power = 0;
				mA = DWC3_USB30_CHG_CURRENT;
			} else {
				mA = lge_pm_get_usb_current();
			}
#ifdef CONFIG_QPNP_CHARGER
			/* For MST, boost current up over 900mA in spite of USB */
			if (pseudo_batt_info.mode && mA == 500 )
				mA = DWC3_USB30_CHG_CURRENT;
#endif
		} else if (dotg->charger->chg_type == DWC3_DCP_CHARGER) {
			mA = lge_pm_get_ta_current();
		} else if (dotg->charger->chg_type == DWC3_FLOATED_CHARGER) {
			mA = lge_pm_get_usb_current();
		}
	}
#endif

	if (dotg->charger->chg_type == DWC3_CDP_CHARGER)
		mA = DWC3_IDEV_CHG_MAX;

	if (dotg->charger->max_power == mA)
		return 0;

	dev_info(phy->dev, "Avail curr from USB = %u\n", mA);

/*                                                                                           */
#ifdef CONFIG_LGE_PM
#ifndef CONFIG_USB_DWC3_LGE_SINGLE_PSY
	if (dwc3_otg_get_psy(phy) < 0)
		goto psy_error;
#else
	if (strcmp(dotg->psy->name, "usb")) {
		pr_info("%s psy name is %s, so change psy to usb.\n", __func__, dotg->psy->name);
		dotg->psy = power_supply_get_by_name("usb");
		if (!dotg->psy)
			goto psy_error;
	}
#endif
	power_supply_set_supply_type(dotg->psy, power_supply_type);
#endif

#if defined(CONFIG_DWC3_MSM_BC_12_VZW_SUPPORT) && defined(CONFIG_LGE_PM)
	if (dotg->charger->max_power <= IUNIT && mA > 2) {
#else
	if (dotg->charger->max_power <= 2 && mA > 2) {
#endif
		/* Enable charging */
		if (power_supply_set_online(dotg->psy, true))
			goto psy_error;
		if (power_supply_set_current_limit(dotg->psy, 1000*mA))
			goto psy_error;
#ifdef CONFIG_QPNP_CHARGER
		if (!strncmp(dotg->psy->name, "ac", 2)) {
			dotg->psy = power_supply_get_by_name("usb");
			if (!dotg->psy)
				goto psy_error;

			if (power_supply_set_online(dotg->psy, true))
				goto psy_error;

			if (power_supply_set_supply_type(dotg->psy, power_supply_type))
				goto psy_error;

			if (power_supply_set_current_limit(dotg->psy, 1000*mA))
				goto psy_error;

			dotg->psy = power_supply_get_by_name("ac");
			if (!dotg->psy)
				goto psy_error;
		}
#endif
	} else if (dotg->charger->max_power > 0 && (mA == 0 || mA == 2)) {
		/* Disable charging */
		if (power_supply_set_online(dotg->psy, false))
			goto psy_error;
		/* Set max current limit */
		if (power_supply_set_current_limit(dotg->psy, 0))
			goto psy_error;

#ifdef CONFIG_QPNP_CHARGER
		if (!strncmp(dotg->psy->name, "ac", 2)) {
			dotg->psy = power_supply_get_by_name("usb");
			if (!dotg->psy)
				goto psy_error;

			if (power_supply_set_online(dotg->psy, false))
				goto psy_error;

			if (power_supply_set_supply_type(dotg->psy, power_supply_type))
				goto psy_error;

			if (power_supply_set_current_limit(dotg->psy, 0))
				goto psy_error;

			dotg->psy = power_supply_get_by_name("ac");
			if (!dotg->psy)
				goto psy_error;
		}
#endif
#ifndef CONFIG_USB_DWC3_LGE_SINGLE_PSY
		dotg->charger->chg_type = DWC3_INVALID_CHARGER;
#endif
	}

	power_supply_changed(dotg->psy);

	dotg->charger->max_power = mA;

#if defined (CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4)
#if defined (CONFIG_TOUCHSCREEN_SYNAPTICS_G2) || defined (CONFIG_MACH_MSM8974_TIGERS)
	queue_work(touch_otg_wq, &dotg->touch_work);
#endif
#endif

	return 0;

psy_error:
	dev_dbg(phy->dev, "power supply error when setting property\n");
	return -ENXIO;
}

/* IRQs which OTG driver is interested in handling */
#define DWC3_OEVT_MASK		(DWC3_OEVTEN_OTGCONIDSTSCHNGEVNT | \
				 DWC3_OEVTEN_OTGBDEVVBUSCHNGEVNT)

/**
 * dwc3_otg_interrupt - interrupt handler for dwc3 otg events.
 * @_dotg: Pointer to out controller context structure
 *
 * Returns IRQ_HANDLED on success otherwise IRQ_NONE.
 */
static irqreturn_t dwc3_otg_interrupt(int irq, void *_dotg)
{
	struct dwc3_otg *dotg = (struct dwc3_otg *)_dotg;
	u32 osts, oevt_reg;
	int ret = IRQ_NONE;
	int handled_irqs = 0;
	struct usb_phy *phy = dotg->otg.phy;

	oevt_reg = dwc3_readl(dotg->regs, DWC3_OEVT);

	if (!(oevt_reg & DWC3_OEVT_MASK))
		return IRQ_NONE;

	osts = dwc3_readl(dotg->regs, DWC3_OSTS);

	if ((oevt_reg & DWC3_OEVTEN_OTGCONIDSTSCHNGEVNT) ||
	    (oevt_reg & DWC3_OEVTEN_OTGBDEVVBUSCHNGEVNT)) {
		/*
		 * ID sts has changed, set inputs later, in the workqueue
		 * function, switch from A to B or from B to A.
		 */

		if (oevt_reg & DWC3_OEVTEN_OTGCONIDSTSCHNGEVNT) {
			if (osts & DWC3_OTG_OSTS_CONIDSTS) {
				dev_dbg(phy->dev, "ID set\n");
				set_bit(ID, &dotg->inputs);
			} else {
				dev_dbg(phy->dev, "ID clear\n");
				clear_bit(ID, &dotg->inputs);
			}
			handled_irqs |= DWC3_OEVTEN_OTGCONIDSTSCHNGEVNT;
		}

		if (oevt_reg & DWC3_OEVTEN_OTGBDEVVBUSCHNGEVNT) {
			if (osts & DWC3_OTG_OSTS_BSESVALID) {
				dev_dbg(phy->dev, "BSV set\n");
				set_bit(B_SESS_VLD, &dotg->inputs);
			} else {
				dev_dbg(phy->dev, "BSV clear\n");
				clear_bit(B_SESS_VLD, &dotg->inputs);
			}
			handled_irqs |= DWC3_OEVTEN_OTGBDEVVBUSCHNGEVNT;
		}

		queue_delayed_work(system_nrt_wq, &dotg->sm_work, 0);

		ret = IRQ_HANDLED;

		/* Clear the interrupts we handled */
		dwc3_writel(dotg->regs, DWC3_OEVT, handled_irqs);
	}

	return ret;
}

/**
 * dwc3_otg_init_sm - initialize OTG statemachine input
 * @dotg: Pointer to the dwc3_otg structure
 *
 */
void dwc3_otg_init_sm(struct dwc3_otg *dotg)
{
	u32 osts = dwc3_readl(dotg->regs, DWC3_OSTS);
	struct usb_phy *phy = dotg->otg.phy;
	struct dwc3_ext_xceiv *ext_xceiv;
	int ret;

	dev_dbg(phy->dev, "Initialize OTG inputs, osts: 0x%x\n", osts);

	/*
	 * VBUS initial state is reported after PMIC
	 * driver initialization. Wait for it.
	 */
	ret = wait_for_completion_timeout(&dotg->dwc3_xcvr_vbus_init, HZ * 5);
	if (!ret) {
		dev_err(phy->dev, "%s: completion timeout\n", __func__);
		/* We can safely assume no cable connected */
		set_bit(ID, &dotg->inputs);
	}

	ext_xceiv = dotg->ext_xceiv;
	dwc3_otg_reset(dotg);
	if (ext_xceiv && !ext_xceiv->otg_capability) {
		if (osts & DWC3_OTG_OSTS_CONIDSTS)
			set_bit(ID, &dotg->inputs);
		else
			clear_bit(ID, &dotg->inputs);

		if (osts & DWC3_OTG_OSTS_BSESVALID)
			set_bit(B_SESS_VLD, &dotg->inputs);
		else
			clear_bit(B_SESS_VLD, &dotg->inputs);
	}
}
コード例 #17
0
static int lm3630_probe(struct i2c_client *i2c_dev,
		const struct i2c_device_id *id)
{
	struct backlight_platform_data *pdata;
	struct lm3630_device *dev;
	struct backlight_device *bl_dev;
	struct backlight_properties props;
	int err;

	pr_info(" %s: i2c probe start\n", __func__);

#ifdef CONFIG_OF
	if (&i2c_dev->dev.of_node) {
		pdata = devm_kzalloc(&i2c_dev->dev,
				sizeof(struct backlight_platform_data),
				GFP_KERNEL);
		if (!pdata) {
			pr_err("%s: Failed to allocate memory\n", __func__);
			return -ENOMEM;
		}
		err = lm3630_parse_dt(&i2c_dev->dev, pdata);
		if (err != 0)
			return err;
	} else {
		pdata = i2c_dev->dev.platform_data;
	}
#else
	pdata = i2c_dev->dev.platform_data;
#endif
	pr_info("%s: gpio = %d\n", __func__, pdata->gpio);
	if (pdata->gpio && gpio_request(pdata->gpio, "lm3630 reset") != 0) {
		return -ENODEV;
	}

	lm3630_i2c_client = i2c_dev;

	dev = kzalloc(sizeof(struct lm3630_device), GFP_KERNEL);
	if (dev == NULL) {
		dev_err(&i2c_dev->dev, "fail alloc for lm3630_device\n");
		return 0;
	}
	main_lm3630_dev = dev;

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;

	props.max_brightness = MAX_BRIGHTNESS_LM3630;
	bl_dev = backlight_device_register(I2C_BL_NAME, &i2c_dev->dev,
			NULL, &lm3630_bl_ops, &props);
	bl_dev->props.max_brightness = MAX_BRIGHTNESS_LM3630;
#if defined(CONFIG_B1_LGD_PANEL)
	if(lge_get_boot_mode() == LGE_BOOT_MODE_CHARGERLOGO)
		bl_dev->props.brightness = 0x99; // same to LK
	else if(lge_get_boot_mode() == LGE_BOOT_MODE_FACTORY
			|| lge_get_boot_mode() == LGE_BOOT_MODE_FACTORY2
			|| lge_get_boot_mode() == LGE_BOOT_MODE_FACTORY3
			|| lge_get_boot_mode() == LGE_BOOT_MODE_PIFBOOT
			|| lge_get_boot_mode() == LGE_BOOT_MODE_PIFBOOT2
			|| lge_get_boot_mode() == LGE_BOOT_MODE_PIFBOOT3)
		factory_boot = 1;
	else
		bl_dev->props.brightness = DEFAULT_BRIGHTNESS;
#else
	bl_dev->props.brightness = pdata->default_brightness;
#endif
	bl_dev->props.power = FB_BLANK_UNBLANK;

	dev->bl_dev = bl_dev;
	dev->client = i2c_dev;

	dev->gpio = pdata->gpio;
	dev->max_current = pdata->max_current;
	dev->min_brightness = pdata->min_brightness;
	dev->max_brightness = pdata->max_brightness;
	dev->blmap_size = pdata->blmap_size;

	if (dev->blmap_size) {
		dev->blmap = kzalloc(sizeof(char) * dev->blmap_size, GFP_KERNEL);
		if (!dev->blmap) {
			pr_err("%s: Failed to allocate memory\n", __func__);
			return -ENOMEM;
		}
		memcpy(dev->blmap, pdata->blmap, dev->blmap_size);
	} else {
		dev->blmap = NULL;
	}

#ifdef CONFIG_LGE_LCD_OFF_DIMMING
	if ((lge_get_bootreason() == 0x77665560) || (lge_get_bootreason() == 0x77665561)) {
		dev->bl_dev->props.brightness = 50;
		pr_info("%s : fota reboot - backlight set 50\n", __func__);
	}
#endif
	if (gpio_get_value(dev->gpio))
		backlight_status = BL_ON;
	else
		backlight_status = BL_OFF;

	i2c_set_clientdata(i2c_dev, dev);

	mutex_init(&dev->bl_mutex);

	err = device_create_file(&i2c_dev->dev,
			&dev_attr_lm3630_level);
	err = device_create_file(&i2c_dev->dev,
			&dev_attr_lm3630_backlight_on_off);
	err = device_create_file(&i2c_dev->dev,
			&dev_attr_lm3630_exp_min_value);
#if defined(CONFIG_BACKLIGHT_CABC_DEBUG_ENABLE)
	err = device_create_file(&i2c_dev->dev,
			&dev_attr_lm3630_pwm);
#endif

	pr_info("%s: i2c probe done\n", __func__);
	return 0;
}
コード例 #18
0
/*
int anx7816_get_sbl_cable_type(void)
{
	int cable_type = 0;
	unsigned int *p_cable_type = (unsigned int *)
		(smem_get_entry(SMEM_ID_VENDOR1, &cable_smem_size));

	if (p_cable_type)
		cable_type = *p_cable_type;
	else
		cable_type = 0;

	return cable_type;
}
*/
static int anx7816_i2c_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{

	struct anx7816_data *anx7816;
	struct anx7816_platform_data *pdata;
	int ret = 0;
	//int sbl_cable_type = 0;

	pr_err("%s %s start\n", LOG_TAG, __func__);

#ifdef SP_REGISTER_SET_TEST
	val_SP_TX_LT_CTRL_REG0 = 0x01;
	val_SP_TX_LT_CTRL_REG1 = 0x03;
	val_SP_TX_LT_CTRL_REG2 = 0x57;
	val_SP_TX_LT_CTRL_REG3 = 0x7f;
	val_SP_TX_LT_CTRL_REG4 = 0x71;
	val_SP_TX_LT_CTRL_REG5 = 0x6b;
	val_SP_TX_LT_CTRL_REG6 = 0x7f;
	val_SP_TX_LT_CTRL_REG7 = 0x73;
	val_SP_TX_LT_CTRL_REG8 = 0x7f;
	val_SP_TX_LT_CTRL_REG9 = 0x7f;
	val_SP_TX_LT_CTRL_REG10 = 0x00;
	val_SP_TX_LT_CTRL_REG11 = 0x00;
	val_SP_TX_LT_CTRL_REG12 = 0x02;
	val_SP_TX_LT_CTRL_REG13 = 0x00;
	val_SP_TX_LT_CTRL_REG14 = 0x0c;
	val_SP_TX_LT_CTRL_REG15 = 0x42;
	val_SP_TX_LT_CTRL_REG16 = 0x2f;
	val_SP_TX_LT_CTRL_REG17 = 0x3e;
	val_SP_TX_LT_CTRL_REG18 = 0x77;
	val_SP_TX_LT_CTRL_REG19 = 0x7e;
#endif
	if (!i2c_check_functionality(client->adapter,
		I2C_FUNC_SMBUS_I2C_BLOCK)) {
		pr_err("%s: i2c bus does not support the anx7816\n", __func__);
		ret = -ENODEV;
		goto exit;
	}

	anx7816 = kzalloc(sizeof(struct anx7816_data), GFP_KERNEL);
	if (!anx7816) {
		pr_err("%s: failed to allocate driver data\n", __func__);
		ret = -ENOMEM;
		goto exit;
	}

	if (client->dev.of_node) {
		pdata = devm_kzalloc(&client->dev,
							 sizeof(struct anx7816_platform_data),
							 GFP_KERNEL);
		if (!pdata) {
			pr_err("%s: Failed to allocate memory\n", __func__);
			ret = -ENOMEM;
			goto err0;
		}
		client->dev.platform_data = pdata;
	/* device tree parsing function call */
		ret = anx7816_parse_dt(&client->dev, pdata);
		if (ret != 0) /* if occurs error */
			goto err0;

		anx7816->pdata = pdata;
	} else {
		anx7816->pdata = client->dev.platform_data;
	}

	/* to access global platform data */
	g_pdata = anx7816->pdata;

	anx7816_client = client;

	mutex_init(&anx7816->lock);

	if (!anx7816->pdata) {
		ret = -EINVAL;
		goto err0;
	}

	ret = anx7816_init_gpio(anx7816);
	if (ret) {
		pr_err("%s: failed to initialize gpio\n", __func__);
		goto err0;
	}

	INIT_DELAYED_WORK(&anx7816->work, anx7816_work_func);
/*	INIT_DELAYED_WORK(&anx7816->dwc3_ref_clk_work, dwc3_ref_clk_work_func); */

	anx7816->workqueue = create_singlethread_workqueue("anx7816_work");
	if (anx7816->workqueue == NULL) {
		pr_err("%s: failed to create work queue\n", __func__);
		ret = -ENOMEM;
		goto err1;
	}

	//anx7816->pdata->avdd_power(1);
	//anx7816->pdata->dvdd_power(1);

	ret = anx7816_system_init();
	if (ret) {
		pr_err("%s: failed to initialize anx7816\n", __func__);
		goto err2;
	}

	client->irq = gpio_to_irq(anx7816->pdata->gpio_cbl_det);
	if (client->irq < 0) {
		pr_err("%s : failed to get gpio irq\n", __func__);
		goto err2;
	}

	wake_lock_init(&anx7816->slimport_lock,
				WAKE_LOCK_SUSPEND,
				"slimport_wake_lock");

#if 0
	sbl_cable_type = anx7816_get_sbl_cable_type();

	if ((lge_get_laf_mode() != LGE_LAF_MODE_LAF) &&
	(sbl_cable_type != CBL_910K)) {
#else
	if ((lge_get_boot_mode() != LGE_BOOT_MODE_QEM_910K) &&
	(lge_get_boot_mode() != LGE_BOOT_MODE_PIF_910K)) {
#endif
		ret = request_threaded_irq(client->irq, NULL, anx7816_cbl_det_isr,
						IRQF_TRIGGER_RISING
						| IRQF_TRIGGER_FALLING
						| IRQF_ONESHOT,
						"anx7816", anx7816);
		if (ret  < 0) {
			pr_err("%s : failed to request irq\n", __func__);
			goto err2;
		}

		ret = irq_set_irq_wake(client->irq, 1);
		if (ret  < 0) {
			pr_err("%s : Request irq for cable detect", __func__);
			pr_err("interrupt wake set fail\n");
			goto err3;
		}

		ret = enable_irq_wake(client->irq);
		if (ret  < 0) {
			pr_err("%s : Enable irq for cable detect", __func__);
			pr_err("interrupt wake enable fail\n");
			goto err3;
		}
	} else {
#if 0
		pr_err("%s %s : %s, Disable cbl det irq!!\n", LOG_TAG, __func__,
			sbl_cable_type == CBL_910K ? "910K Cable Connected" : "Laf Mode");
#else
		pr_err("%s %s: 910K Cable Connected. Disable cbl det irq!!\n", LOG_TAG, __func__);
#endif
	}

	ret = create_sysfs_interfaces(&client->dev);
	if (ret < 0) {
		pr_err("%s : sysfs register failed", __func__);
		goto err3;
	}
#ifdef CONFIG_SLIMPORT_DYNAMIC_HPD
	hdmi_slimport_ops = devm_kzalloc(&client->dev,
				    sizeof(struct msm_hdmi_slimport_ops),
				    GFP_KERNEL);
	if (!hdmi_slimport_ops) {
		pr_err("%s: alloc hdmi slimport ops failed\n", __func__);
		ret = -ENOMEM;
		goto err3;
	}

	if (anx7816->pdata->hdmi_pdev) {
		ret = msm_hdmi_register_slimport(anx7816->pdata->hdmi_pdev,
					   hdmi_slimport_ops, anx7816);
		if (ret) {
			pr_err("%s: register with hdmi failed\n", __func__);
			ret = -EPROBE_DEFER;
			goto err3;
		}
	}
#endif
	pr_info("%s %s end\n", LOG_TAG, __func__);
	goto exit;

err3:
	free_irq(client->irq, anx7816);
err2:
	destroy_workqueue(anx7816->workqueue);
err1:
	anx7816_free_gpio(anx7816);
err0:
	anx7816_client = NULL;
	kfree(anx7816);
exit:
	return ret;
}

static int anx7816_i2c_remove(struct i2c_client *client)
{
	struct anx7816_data *anx7816 = i2c_get_clientdata(client);
	int i = 0;
	for (i = 0; i < ARRAY_SIZE(slimport_device_attrs); i++)
		device_remove_file(&client->dev, &slimport_device_attrs[i]);
	pr_err("anx7816_i2c_remove\n");
	sp_tx_clean_state_machine();
	destroy_workqueue(anx7816->workqueue);
	sp_tx_hardware_powerdown();
	free_irq(client->irq, anx7816);
	anx7816_free_gpio(anx7816);
	wake_lock_destroy(&anx7816->slimport_lock);
	kfree(anx7816);
	return 0;
}

bool is_slimport_vga(void)
{
	return ((sp_tx_cur_cable_type() == DWN_STRM_IS_VGA_9832)
		|| (sp_tx_cur_cable_type() == DWN_STRM_IS_ANALOG)) ? 1 : 0;
}
/* 0x01: hdmi device is attached
    0x02: DP device is attached
    0x03: Old VGA device is attached // RX_VGA_9832
    0x04: new combo VGA device is attached // RX_VGA_GEN
    0x00: unknow device            */
EXPORT_SYMBOL(is_slimport_vga);
bool is_slimport_dp(void)
{
	return (sp_tx_cur_cable_type() == DWN_STRM_IS_DIGITAL) ? TRUE : FALSE;
}
EXPORT_SYMBOL(is_slimport_dp);
unchar sp_get_link_bw(void)
{
	return sp_tx_cur_bw();
}
EXPORT_SYMBOL(sp_get_link_bw);
void sp_set_link_bw(unchar link_bw)
{
	sp_tx_set_bw(link_bw);
}
コード例 #19
0
static int pn544_probe(struct i2c_client *client,
        const struct i2c_device_id *id)
{
    int ret;
    struct pn544_i2c_platform_data *platform_data;
    struct pn544_dev *pn544_dev = NULL;

    dprintk(PN544_DRV_NAME ": pn544_probe() start\n");

    pn544_client = client;
    platform_data = client->dev.platform_data;

    if (platform_data == NULL) {
        pr_err("%s : nfc probe fail\n", __func__);
        return  -ENODEV;
    }

    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        pr_err("%s : need I2C_FUNC_I2C\n", __func__);
        return  -ENODEV;
    }

    ret = gpio_request(platform_data->irq_gpio, "nfc_int");
    if (ret) {
        dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_int request failed!\n");
        goto err_int;
    }
    ret = gpio_request(platform_data->ven_gpio, "nfc_ven");
    if (ret) {
        dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_ven request failed!\n");
        goto err_ven;
    }
    ret = gpio_request(platform_data->firm_gpio, "nfc_firm");
    if (ret) {
        dprintk(PN544_DRV_NAME ":pn544_probe() : nfc_firm request failed!\n");
        goto err_firm;
    }

    pn544_dev = kzalloc(sizeof(*pn544_dev), GFP_KERNEL);
    if (pn544_dev == NULL) {
        dev_err(&client->dev,
                "failed to allocate memory for module data\n");
        ret = -ENOMEM;
        goto err_exit;
    }

    pn544_dev->irq_gpio = platform_data->irq_gpio;
    pn544_dev->ven_gpio  = platform_data->ven_gpio;
    pn544_dev->firm_gpio  = platform_data->firm_gpio;
    pn544_dev->client   = client;
    dprintk(PN544_DRV_NAME ":IRQ : %d\nVEN : %d\nFIRM : %d\n",
            pn544_dev->irq_gpio, pn544_dev->ven_gpio, pn544_dev->firm_gpio);

    pn544_gpio_enable(pn544_dev);

    ret = gpio_direction_output(platform_data->ven_gpio,1);
    ret = gpio_direction_output(platform_data->firm_gpio,0);
    //[START] For pull down IRQ pin
    gpio_tlmm_config(GPIO_CFG(NFC_GPIO_IRQ, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),GPIO_CFG_ENABLE);
    pr_info("%s : NFC_GPIO_IRQ GPIO_CFG_PULL_DOWN \n", __func__);
    //[END] For pull down IRQ pin
    ret = gpio_direction_input(platform_data->irq_gpio);

    /* init mutex and queues */
    init_waitqueue_head(&pn544_dev->read_wq);
    mutex_init(&pn544_dev->read_mutex);
    spin_lock_init(&pn544_dev->irq_enabled_lock);

    pn544_dev->pn544_device.minor = MISC_DYNAMIC_MINOR;
    pn544_dev->pn544_device.name = PN544_DRV_NAME;
    pn544_dev->pn544_device.fops = &pn544_dev_fops;

    ret = misc_register(&pn544_dev->pn544_device);
    if (ret) {
        pr_err("%s : misc_register failed\n", __FILE__);
        goto err_misc_register;
    }

    /* request irq.  the irq is set whenever the chip has data available
     * for reading.  it is cleared when all data has been read.
     */
    pr_info("%s : requesting IRQ %d\n", __func__, client->irq);
    pn544_dev->irq_enabled = true;
    ret = request_irq(pn544_gpio_to_irq(pn544_dev), pn544_dev_irq_handler,
              IRQF_TRIGGER_HIGH, client->name, pn544_dev);
    if (ret) {
        dev_err(&client->dev, "request_irq failed\n");
        goto err_request_irq_failed;
    }
//                                                                             
//  enable_irq_wake(pn544_get_irq_pin(pn544_dev));
//#endif
    pn544_disable_irq(pn544_dev);
    i2c_set_clientdata(client, pn544_dev);
    dprintk(PN544_DRV_NAME ": pn544_probe() dprintk\n");
/*             
  
                                  
                                    
                                   
  
                                  
 */
 //                                                        
     boot_mode = lge_get_boot_mode();

    dprintk("pn544_probe() boot_mode : %d\n", boot_mode);
    if (boot_mode == LGE_BOOT_MODE_FACTORY || boot_mode == LGE_BOOT_MODE_FACTORY2) {
#ifdef CONFIG_LGE_NFC_MULTICORE_FASTBOOT
    {
        struct task_struct *th;
        th = kthread_create(pn544_factory_standby_set_thread, NULL, "pn544_factory_standby");
        if (IS_ERR(th)) {
            ret = PTR_ERR(th);
            goto err_request_irq_failed;
        }
        wake_up_process(th);
    }
#else
    pn544_factory_standby_set();
#endif
/*              */
        }
//                                                      
        return 0;

err_request_irq_failed:
    misc_deregister(&pn544_dev->pn544_device);

err_misc_register:
    mutex_destroy(&pn544_dev->read_mutex);

err_firm:
    gpio_free(platform_data->ven_gpio);

err_ven:
    gpio_free(platform_data->irq_gpio);

err_int:
    kfree(platform_data);

err_exit:
    pr_err(PN544_DRV_NAME ": pn544_dev is null\n");

    pr_err(PN544_DRV_NAME ": pn544_probe() end with error!\n");

    return ret;
}
コード例 #20
0
/*
* Description :
* Input :
* Output :
*/
static long snfc_uart_control_ioctl(struct file *flip, unsigned int cmd, unsigned long arg)
{
    //ioctl_buf *k_buf;
    //int i,err;
    int size;
    _e_snfc_uart_status current_status;
       int break_cnt;
    int autopoll_wait_cnt;
    unsigned char write_buf = 0x00/*, read_buf = 0x00*/;
    int rc =0;
    int snfcbootmode;

    size = _IOC_SIZE(cmd);
    SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] snfc_uart_control_ioctl - start,cmd =%d\n", cmd);

    if(cmd == IOCTL_SNFC_READ_BOOTMODE){
            snfcbootmode = lge_get_boot_mode();
            SNFC_DEBUG_MSG("[snfc_uart_control] read boot mode %d \n",snfcbootmode);
             // 0 : NORMAL, 1 : CHARGER, 2 : CHARGERLOGO, 3 : FACTORY, 4 : FACTORY2, 5 : PIFBOOT, 6 : PIFBOOT2, 7 : MINIOS
            return snfcbootmode;
    }
    current_status = __snfc_uart_control_get_uart_status();
    if( current_status == UART_STATUS_FOR_FELICA )
    {
        SNFC_DEBUG_MSG("[snfc_uart_control] snfc_uart_control_ioctl, UART is used to FeliCa\n");
        return -1;
    }

    __snfc_uart_control_set_uart_status(UART_STATUS_FOR_NFC);

    switch(cmd)
    {
        case IOCTL_SNFC_START_SETTING :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_SETTING - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
                  SNFC_DEBUG_MSG_LOW("[snfc_uart_control] hsel %d, pon %d\n",
                    snfc_gpios.gpio_hsel,snfc_gpios.gpio_pon);
                  SNFC_DEBUG_MSG_LOW("[snfc_driver] GPIO_SNFC_PON = %d, GPIO_SNFC_HSEL = %d, GPIO_SNFC_HBDD = %d\n",
                    snfc_gpio_read(snfc_gpios.gpio_pon),snfc_gpio_read(snfc_gpios.gpio_hsel),snfc_gpio_read(snfc_gpios.gpio_hvdd)  );
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_SETTING - end\n");
            break;

        case IOCTL_SNFC_START_AUTOPOLL :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_AUTOPOLL - start\n");
            autopoll_wait_cnt = 0;
            break_cnt = 0;
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
            autopoll_status = 1;
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_AUTOPOLL - end\n");
            break;

        case IOCTL_SNFC_START_RW :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_RW - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_RW - end\n");
            break;

        case IOCTL_SNFC_START_TARGET :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_TARGET - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            if(GPIO_HIGH_VALUE == snfc_gpio_read(snfc_gpios.gpio_rfs))
                mdelay(10);
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_TARGET - end\n");
            break;

        case IOCTL_SNFC_START_INTU :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_INTU - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            //mdelay(10);
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_INTU - end\n");
            break;

        case IOCTL_SNFC_START_WAITSIMBOOT:
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_WAITSIMBOOT - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_WAITSIMBOOT - end\n");
            break;

        case IOCTL_SNFC_HSEL_UP:
            forced_hsel_up_flag = 1;
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_hsel_up\n");
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            break;

        case IOCTL_SNFC_HSEL_DOWN:
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_hsel_down\n");
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_LOW_VALUE);
            forced_hsel_up_flag = 0;
            if(forced_pon_up_flag == 0 && forced_hsel_up_flag == 0)
                __snfc_uart_control_set_uart_status(UART_STATUS_READY);
            break;

        case IOCTL_SNFC_PON_UP:
            forced_pon_up_flag = 1;
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_pon_up\n");
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
            break;

        case IOCTL_SNFC_PON_DOWN:
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_pon_down\n");
            forced_pon_up_flag = 0;
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_LOW_VALUE);
            if(forced_pon_up_flag == 0 && forced_hsel_up_flag == 0)
                __snfc_uart_control_set_uart_status(UART_STATUS_READY);
            break;

        case IOCTL_SNFC_BOOT_CEN_HI:        //Kernel init only
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_boot_hi\n");
            SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] CEN = High (UNLOCK) \n");
            write_buf = 0x81; // set unlock
            //mutex_lock(&nfc_cen_mutex);
            rc = snfc_i2c_write(0x02, &write_buf, 1, snfc_i2c_dev.client);
            //mutex_unlock(&nfc_cen_mutex);
            break;

        case IOCTL_SNFC_BOOT_CEN_LO:    //Kernel init only
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_boot_low\n");
            SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] CEN = Low (LOCK) \n");
            write_buf = 0x80; // set lock
            //mutex_lock(&nfc_cen_mutex);
            rc = snfc_i2c_write(0x02, &write_buf, 1, snfc_i2c_dev.client);
            //mutex_unlock(&nfc_cen_mutex);
            break;

           case IOCTL_SNFC_HVDD_DOWN_SET:
                 SNFC_DEBUG_MSG("snfc_uart_control] before HVDD Down\n");
                 snfc_hvdd_wait_rfs_low();
                 break;

        case IOCTL_SNFC_END :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_END - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
            {
                SNFC_DEBUG_MSG("[snfc_uart_control] pon & hsel forced up!! pon and/or sel will keep high\n");
                break;
            }
            if(current_status != UART_STATUS_FOR_NFC)
            {
                SNFC_DEBUG_MSG("[snfc_uart_control] IOCTL_SNFC_END, UART is not used to NFC\n");
                //return -2;
            }
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_LOW_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_LOW_VALUE);
            __snfc_uart_control_set_uart_status(UART_STATUS_READY);

            autopoll_status = 0;
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_END - end (hsel low)(pon low)\n");
            break;

    }
    SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_ioctl - end\n");

    return 0;
}