This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x with external PCF8523 RTC WEEKDAY_ALARM write is not working properly

Hi,

We have following hardware setup am3352B series processor with external PCF8523 rtc chip, kernel version is linux-3.12.10-ti2013.12.01, and TI-SDK v7.

We are setting rtc alarm from an user space application using RTC_SET_ALARM ioctl. We could successfully set for MIN_ALARM, HOUR_ALARM and DAY_ALARM, and the these alarms works properly. But the WEEKDAY_ALARM is not working properly. We observe that the value we write for WEEK_ALARM does not reflects in the corresponding RTC register, on read back we get different value.

Probably we are missing something here as to what value needs to be passed from the user space to the driver for setting the week alarm (the valid values are 0 - 6). For example, to set alarm for 7hr 58min 3rd of current month, and for weekday Monday, we set the tm.tm_min=58, tm.tm_hour=7, tm.tm_mday=26 tm.tm_wday=1.

In this case, we could see the alarm registers are properly set for min, hour, and mday. But the wday register was not set with the value we gave, instead it was set to some other value, ex: 3.

Further debugging, we found the week_day alarm value was changed in the following function during the RTC_SET_ALARM ioctl processing.

void rtc_time_to_tm(unsigned long time, struct rtc_time *tm); //drivers/rtc/rtc-lib.c

----------

void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)

{

        unsigned int month, year;
        int days;
        days = time / 86400;
        time -= (unsigned int) days * 86400;
        /* day of the week, 1970-01-01 was a Thursday */
        tm->tm_wday = (days + 4) % 7

----------

Here we can observe the weekday value is different that what we are setting, and this value only set to the rtc register for weekday alarm field.

So we are not sure whether we are passing wrong value for setting the weekday alarm or if the weekday alarm itself is not supported in rtc alarm functionality.


Can you please clarify on this?

Thanks,

Venkat

  • Hi Venkat,

    I'm moving this thread over to AM335x forum for better support.

    Thanks,
    Siby
  • Hi,

    Venkat P said:
    So we are not sure whether we are passing wrong value for setting the weekday alarm or if the weekday alarm itself is not supported in rtc alarm functionality.

    Weekday alarm should be supported, see inlcude/linux/rtc.h for available ioctls. 

    Also quite detailed explanation of the rtc usage & example RTC program is given in Documentation/rtc. 

    Looking at the PCF8523 datasheet: http://cache.nxp.com/documents/data_sheet/PCF8523.pdf  I can see that WEEKDAY_ALARM is an 8bit register located at address 0Dh and its valid settings are 0 to 6.

    Can you share how you set the alarm (snippet of code that sets the WEEKDAY_ALARM register)? Also can you share the RTC & corresponding i2c dts nodes? 

    Best Regards, 
    Yordan