From 656c7bf8cbdc426d5744e4a39b8e92dc1d1d6c29 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Wed, 5 Jan 2011 20:30:13 +0800 Subject: [PATCH] rtc: hym8563: fix initialize --- arch/arm/mach-rk29/board-rk29sdk.c | 2 +- drivers/rtc/rtc-HYM8563.c | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-rk29/board-rk29sdk.c b/arch/arm/mach-rk29/board-rk29sdk.c index f4f484771b39..344270dd8912 100755 --- a/arch/arm/mach-rk29/board-rk29sdk.c +++ b/arch/arm/mach-rk29/board-rk29sdk.c @@ -516,7 +516,7 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = { .type = "rtc_hym8563", .addr = 0x51, .flags = 0, - ///.irq = RK2818_PIN_PA4, + .irq = RK29_PIN0_PA1, }, #endif #if defined (CONFIG_GS_MMA8452) diff --git a/drivers/rtc/rtc-HYM8563.c b/drivers/rtc/rtc-HYM8563.c index ab2500de8b31..1604836aff4b 100644 --- a/drivers/rtc/rtc-HYM8563.c +++ b/drivers/rtc/rtc-HYM8563.c @@ -108,6 +108,7 @@ static int hym8563_read_datetime(struct i2c_client *client, struct rtc_time *tm) if(tm->tm_year < 0) tm->tm_year = 0; tm->tm_isdst = 0; + DBG("%s [%d]tm_wday=%d \n",__FUNCTION__,__LINE__,tm->tm_wday); DBG("%s [%d]tm_sec=%d \n",__FUNCTION__,__LINE__,tm->tm_sec); DBG("%s [%d]tm_min=%d \n",__FUNCTION__,__LINE__,tm->tm_min); DBG("%s [%d]tm_hour=%d \n",__FUNCTION__,__LINE__,tm->tm_hour); @@ -128,6 +129,7 @@ static int hym8563_set_time(struct i2c_client *client, struct rtc_time *tm) u8 mon_day,i; u8 ret = 0; + DBG("%s [%d]tm_wday=%d \n",__FUNCTION__,__LINE__,tm->tm_wday); DBG("%s [%d]tm_sec=%d \n",__FUNCTION__,__LINE__,tm->tm_sec); DBG("%s [%d]tm_min=%d \n",__FUNCTION__,__LINE__,tm->tm_min); DBG("%s [%d]tm_hour=%d \n",__FUNCTION__,__LINE__,tm->tm_hour); @@ -324,13 +326,13 @@ static int __devinit hym8563_probe(struct i2c_client *client,const struct i2c_d struct hym8563 *hym8563; struct rtc_device *rtc = NULL; struct rtc_time tm_read, tm = { - .tm_wday = 4, - .tm_year = 109, - .tm_mon = 9, - .tm_mday = 1, - .tm_hour = 12, - .tm_min = 10, - .tm_sec = 58 + .tm_wday = 6, + .tm_year = 111, + .tm_mon = 0, + .tm_mday = 1, + .tm_hour = 12, + .tm_min = 0, + .tm_sec = 0, }; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) @@ -352,7 +354,7 @@ static int __devinit hym8563_probe(struct i2c_client *client,const struct i2c_d hym8563_init_device(client); hym8563_read_datetime(client, &tm_read); //read time from hym8563 - if(((tm_read.tm_year < 70) | (tm_read.tm_year > 137 )) | (tm_read.tm_mon == -1)) //if the hym8563 haven't initialized + if(((tm_read.tm_year < 70) | (tm_read.tm_year > 137 )) | (tm_read.tm_mon == -1) | (rtc_valid_tm(&tm_read) != 0)) //if the hym8563 haven't initialized { hym8563_set_time(client, &tm); //initialize the hym8563 } @@ -366,7 +368,7 @@ static int __devinit hym8563_probe(struct i2c_client *client,const struct i2c_d hym8563->irq_num = gpio_to_irq(client->irq); gpio_pull_updown(client->irq,GPIOPullUp); - if(request_irq(hym8563->irq_num, hym8563_wakeup_irq,IRQF_TRIGGER_FALLING,NULL,hym8563) <0) + if (request_irq(hym8563->irq_num, hym8563_wakeup_irq, IRQF_TRIGGER_FALLING, client->dev.driver->name, hym8563) < 0) { printk("unable to request rtc irq\n"); goto exit; -- 2.34.1