LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-13-2009, 11:36 PM   #1
anniedeepa
LQ Newbie
 
Registered: Nov 2009
Posts: 4

Rep: Reputation: 0
Help On RTC !


Is it possible to turn on periodic interrupt for RTC from a kernel module ? We can do it from user space using 'RTC_IRQP_SET' and 'RTC_PIE_ON' options. But what about turning it on from kernel module?
 
Old 11-14-2009, 10:37 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,961
Blog Entries: 46

Rep: Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188Reputation: 3188
Hi,

You should read the rest of the 'man rtc'.

'RTC' management is very important so the use of handler/API are preferred;

Quote:
excerpt 'man rtc';

FILES
/dev/rtc, /dev/rtc0, /dev/rtc1, etc: RTC special character device files.

/proc/driver/rtc: status of the (first) RTC.

NOTES
When the kernel's system time is synchronized with an external reference using adjtimex(2) it
will update a designated RTC periodically every 11 minutes. To do so, the kernel has to briefly
turn off periodic interrupts; this might affect programs using that RTC.

An RTC's Epoch has nothing to do with the POSIX Epoch which is only used for the system clock.

If the year according to the RTC's Epoch and the year register is less than 1970 it is assumed to
be 100 years later, that is, between 2000 and 2069.

Some RTCs support "wildcard" values in alarm fields, to support scenarios like periodic alarms at
fifteen minutes after every hour, or on the first day of each month. Such usage is non-portable;
portable user space code only expects a single alarm interrupt, and will either disable or reini-
tialize the alarm after receiving it.

Some RTCs support periodic interrupts with periods that are multiples of a second rather than
fractions of a second; multiple alarms; programmable output clock signals; non-volatile memory;
and other hardware capabilities that are not currently exposed by this API.

SEE ALSO
date(1), adjtimex(2), gettimeofday(2), settimeofday(2), stime(2), time(2), gmtime(3), time(7),
hwclock(8), /usr/src/linux/Documentation/rtc.txt
You should look at '/usr/src/linux/Documentation/rtc.txt' to gain some insight. If you want to work at the kernel level then I suggest that you look at 'Linux Kernel Parameters' & 'Linux Device Drivers, Third Edition'.




The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
 
Old 11-21-2009, 12:26 AM   #3
anniedeepa
LQ Newbie
 
Registered: Nov 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Hi there..........,

Thanks Gary !

I turned on periodic interrupt from user space and loaded a kernel module with my ISR for RTC interrupt. What i need exactly is to execute my ISR on each RTC interrupt. But i couldnt find it working. I am attaching the code herewith. Any suggestions on what went wrong ?

---------------
irqreturn_t my_irq_handler(int irq, void *dev_id, struct pt_regs *regs)

{
printk("Inside ISR for IRQ 8,\n");

}

int init_module(void)
{
printk("<1>Hello World\n");


request_irq(8, my_irq_handler, IRQF_SHARED,"test", NULL);

return 0;

}

void cleanup_module(void)
{
printk("<1>GoodBye World\n");
free_irq(8, NULL);
}

MODULE_LICENSE("GPL");

--------------


*******************
int main()
{
int fd,retval,freq,i=1;
unsigned long temp,data;
fd=open("/dev/rtc0",O_RDONLY);

freq= 2;
ioctl(fd, RTC_IRQP_SET, freq);
fflush(stderr);

/* Enable periodic interrupts */
ioctl(fd, RTC_PIE_ON, 0);

while(1)
{
/* This blocks */
retval = read(fd, &data, sizeof(unsigned long));
if (retval == -1)
{
perror("read");
exit(errno);
}
fprintf(stderr, " %d",i);

i++;
}
}
*******************
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help On RTC ! anniedeepa LinuxQuestions.org Member Intro 0 11-13-2009 11:02 PM
RTC . raajeshjt Linux - Embedded & Single-board computer 1 11-05-2009 08:39 PM
RTC . raajeshjt Linux - Embedded & Single-board computer 1 11-03-2009 03:22 PM
RTC Alarm wakes up, even while BIOS has RTC alarm disabled mastermind2501 Linux - Newbie 2 12-22-2008 04:32 PM
Problem with rtc rogerscuall Linux - Software 0 08-09-2007 11:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration