Exemplo n.º 1
0
static void pcf50633_event_callback(struct pcf50633 *_pcf, int _i)
{
	if(platform_get_drvdata(pcf50633->adc_pdev) == NULL || pcf50633_adc_async_read(pcf50633, PCF50633_ADCC1_MUX_BATSNS_RES, PCF50633_ADCC1_AVERAGE_16, &iphone_battery_update_status, NULL) < 0)
	{
		dev_err(pcf50633->dev, "failed to get battery level\n");
	}

	power_supply_changed(&iphone_battery);
}
Exemplo n.º 2
0
static void iphone_battery_work(struct work_struct* work)
{
	const int interval = msecs_to_jiffies(60 * 1000);

	if(platform_get_drvdata(pcf50633->adc_pdev) == NULL || pcf50633_adc_async_read(pcf50633, PCF50633_ADCC1_MUX_BATSNS_RES, PCF50633_ADCC1_AVERAGE_16, &iphone_battery_update_status, (void*)1) < 0)
	{
		dev_err(pcf50633->dev, "failed to get battery level\n");
		schedule_delayed_work(&iphone_battery_info.monitor_work, interval);
	}
}
int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg)
{
	struct pcf50633_adc_sync_request req;
	int ret;

	init_completion(&req.completion);

	ret = pcf50633_adc_async_read(pcf, mux, avg,
		pcf50633_adc_sync_read_callback, &req);
	if (ret)
		return ret;

	wait_for_completion(&req.completion);

	return req.result;
}
Exemplo n.º 4
0
static void gta02_charger_worker(struct work_struct *work)
{
	struct pcf50633 *pcf = gta02_pcf;

	if (gta02_usb_vbus_draw) {
		pcf50633_mbc_usb_curlim_set(pcf, gta02_usb_vbus_draw);
		return;
	} else {
#ifdef CONFIG_PCF50633_ADC
		pcf50633_adc_async_read(pcf,
			PCF50633_ADCC1_MUX_ADCIN1,
			PCF50633_ADCC1_AVERAGE_16,
			gta02_configure_pmu_for_charger, NULL);
#else
		/* If the PCF50633 ADC is disabled we fallback to a 100mA limit for safety. */
		pcf50633_mbc_usb_curlim_set(pcf, 100);
#endif
		return;
	}
}