Kernel->rtc:add scheduled boot
This commit is contained in:
@ -36,6 +36,7 @@ struct hym8563 {
|
||||
struct wake_lock wake_lock;
|
||||
};
|
||||
static struct i2c_client *gClient = NULL;
|
||||
static struct hym8563 *g_hym8563 = NULL;
|
||||
|
||||
static int i2c_master_reg8_send(const struct i2c_client *client, const char reg, const char *buf, int count, int scl_rate)
|
||||
{
|
||||
@ -227,6 +228,7 @@ static int hym8563_read_datetime(struct i2c_client *client, struct rtc_time *tm)
|
||||
else
|
||||
tm->tm_year += 2000;
|
||||
|
||||
tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
|
||||
tm->tm_year -= 1900; //inorder to cooperate the systerm time
|
||||
if(tm->tm_year < 0)
|
||||
tm->tm_year = 0;
|
||||
@ -542,6 +544,7 @@ static int hym8563_probe(struct i2c_client *client, const struct i2c_device_id
|
||||
int rc = 0;
|
||||
u8 reg = 0;
|
||||
struct hym8563 *hym8563;
|
||||
struct rtc_wkalrm alarm ;
|
||||
struct rtc_device *rtc = NULL;
|
||||
struct rtc_time tm_read, tm = {
|
||||
.tm_wday = 6,
|
||||
@ -611,6 +614,9 @@ static int hym8563_probe(struct i2c_client *client, const struct i2c_device_id
|
||||
goto exit;
|
||||
}
|
||||
hym8563->rtc = rtc;
|
||||
|
||||
g_hym8563 = hym8563;
|
||||
hym8563_rtc_read_alarm(&gClient->dev,&alarm);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -630,15 +636,26 @@ static int hym8563_remove(struct i2c_client *client)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hym8563_shutdown(struct i2c_client * client)
|
||||
{
|
||||
struct device *pdev = &client->dev;
|
||||
struct rtc_wkalrm alarm ;
|
||||
struct rtc_device *rtc_dev=g_hym8563->rtc;
|
||||
u8 regs[4];
|
||||
|
||||
rtc_read_alarm(rtc_dev,&alarm);
|
||||
|
||||
if(alarm.enabled == 1){
|
||||
printk("%s this in shutdowm,the alarm.enabled =1 \n",__func__);
|
||||
}
|
||||
hym8563_i2c_read_regs(client, RTC_CTL2, regs, 1);
|
||||
regs[0] |= AIE;
|
||||
hym8563_i2c_set_regs(client, RTC_CTL2, regs, 1);
|
||||
hym8563_i2c_read_regs(client, RTC_CTL2, regs, 1);
|
||||
|
||||
void hym8563_shutdown(struct i2c_client * client)
|
||||
{ u8 regs[2];
|
||||
int ret;
|
||||
//disable clkout
|
||||
regs[0] = 0x00;
|
||||
ret=hym8563_i2c_set_regs(client, RTC_CLKOUT, regs, 1);
|
||||
if(ret<0)
|
||||
printk("rtc shutdown is error\n");
|
||||
regs[0] |= TIE;
|
||||
hym8563_i2c_set_regs(client, RTC_CTL2, regs, 1);
|
||||
hym8563_i2c_read_regs(client, RTC_CTL2, regs, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -662,7 +679,7 @@ struct i2c_driver hym8563_driver = {
|
||||
},
|
||||
.probe = hym8563_probe,
|
||||
.remove = hym8563_remove,
|
||||
//.shutdown=hym8563_shutdown,
|
||||
.shutdown=hym8563_shutdown,
|
||||
.id_table = hym8563_id,
|
||||
};
|
||||
|
||||
|
||||
@ -115,6 +115,9 @@ static void alarm_set(enum android_alarm_type alarm_type,
|
||||
{
|
||||
uint32_t alarm_type_mask = 1U << alarm_type;
|
||||
unsigned long flags;
|
||||
struct rtc_time time;
|
||||
struct rtc_device *rtc_dev;
|
||||
struct rtc_wkalrm alarm;
|
||||
|
||||
spin_lock_irqsave(&alarm_slock, flags);
|
||||
alarm_dbg(IO, "alarm %d set %ld.%09ld\n",
|
||||
@ -122,6 +125,19 @@ static void alarm_set(enum android_alarm_type alarm_type,
|
||||
alarm_enabled |= alarm_type_mask;
|
||||
devalarm_start(&alarms[alarm_type], timespec_to_ktime(*ts));
|
||||
spin_unlock_irqrestore(&alarm_slock, flags);
|
||||
if(alarm_type == 4){
|
||||
rtc_time_to_tm(ts->tv_sec,&time);
|
||||
rtc_dev = alarmtimer_get_rtcdev();
|
||||
alarm.time.tm_year = time.tm_year;
|
||||
alarm.time.tm_mon = time.tm_mon;
|
||||
alarm.time.tm_mday = time.tm_mday;
|
||||
alarm.time.tm_wday = time.tm_wday;
|
||||
alarm.time.tm_hour = time.tm_hour;
|
||||
alarm.time.tm_min = time.tm_min;
|
||||
alarm.time.tm_sec = time.tm_sec;
|
||||
alarm.enabled = 1;
|
||||
rtc_set_alarm(rtc_dev,&alarm);
|
||||
}
|
||||
}
|
||||
|
||||
static int alarm_wait(void)
|
||||
|
||||
Reference in New Issue
Block a user