Android4.4 pcf8563无法保存设置时间的问题

Android4.4 使用外部rtc pcf8563无法保存设置时间的问题需要对原有驱动进行如下修改

首先在struct rtc_class_ops中增加set_alarm接口如下:

static const struct rtc_class_ops pcf8563_rtc_ops = {
	.read_time	= pcf8563_rtc_read_time,
	.set_time	= pcf8563_rtc_set_time,
	.set_alarm	= pcf8563_rtc_set_alarm,//add by hclydao
};
具体函数实现如下:

static int pcf8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
	struct rtc_time *tm = &alrm->time;
	return pcf8563_set_datetime(to_i2c_client(dev), tm);
}
Android4.4以后是使用rtc驱动中的set_alarm进行设置时间,所以需要增加上面的接口.

同时在probe函数中增加唤醒的设置,部分代码如下

	dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");

	i2c_set_clientdata(client, pcf8563);

	/* cpu init code should really have flagged this device as
	 * being wake-capable; if it didn't, do that here.
	 */
	if (!device_can_wakeup(&client->dev)) { //add by hclydao
		device_init_wakeup(&client->dev, 1);
	}

	pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name,
				&client->dev, &pcf8563_rtc_ops, THIS_MODULE);

======================================
作者:hclydao
http://blog.csdn.net/hclydao
版权没有,但是转载请保留此段声明

===========================================

你可能感兴趣的:(android系统)