Re: [uClinux-dev] [PATCH] Add rtc driver for Coldfire M5441x.
Hi Steven, On Sun, Jun 17, 2012 at 2:10 PM, Steven King wrote: > On Sunday 17 June 2012 4:50:27 am Geert Uytterhoeven wrote: >> On Sun, Jun 17, 2012 at 1:40 PM, Steven King wrote: >> > On Sunday 17 June 2012 4:15:03 am Geert Uytterhoeven wrote: >> >> On Sun, Jun 17, 2012 at 11:23 AM, Steven King wrote: >> >> > On Sunday 17 June 2012 2:09:51 am Geert Uytterhoeven wrote: >> >> >> On Sun, Jun 17, 2012 at 9:50 AM, Steven King wrote: >> >> >> > +config RTC_DRV_M5441x >> >> >> > + tristate "Freescale Coldfire M5441x RTC support" >> >> >> > + depends on M5441x >> >> >> > + help >> >> >> > + This enables support for the RTC on the Freescale >> >> >> > Coldfire 5441x + (54410/54415/54416/54417/54418). >> >> >> > + >> >> >> > + This driver can also be built as a module. If so, the >> >> >> > module + will be called rtc-m5441x. >> >> >> >> >> >> But the platform device is called differently: >> >> >> > +static struct platform_driver m5441x_rtc_driver = { >> >> >> > + .driver.name = "mcfrtc", >> >> >> > + .driver.owner = THIS_MODULE, >> >> >> > + .remove = __devexit_p(m5441x_rtc_remove), >> >> >> > +}; >> >> >> >> >> >> Is there a specific reason for that? >> >> > >> >> > You mean the "mcfrtc" bit? Thats the same as what we do for all of >> >> > the other >> >> >> >> That's what I meant. >> >> >> >> > Coldfire peripherals, ie "mcfqspi", "mcfuart", etc. >> >> >> >> So why not call the driver mcf-rtc? >> > >> > Because that rtc implementation is specific to the m5441x; should someone >> > implement a driver for the rtc on the 532x or 54455 which are somewhat >> > different than the m5441x, then they might well need a separate rtc-m532x >> > or rtc-m54455. >> >> At that point, you'll have to call the platform device rtc-m532x or >> rtc-m54455 as well, as mcfrtc is already taken for the m5441x, right? > > No. The others would still use mcfrtc as their device name. Thats the whole > point. The platform code in arch/m68k/platform/coldfire/device.c can have > single definition of an 'mcfrtc' device and which ever coldfire version is > selected determines which rtc would be availible. You cannot have 2 platform drivers with the same name driving different hardware, as that would cause conflicts if you build a kernel with both drivers. I see you have "config RTC_DRV_M5441x depends on M5441x" to enforce this limitation, but in general, it's encouraged to make drivers build on as many platforms as possible, as this tends to reveal bugs. >> So why not call the platform device rtc-m5441x now? > > Because that would be wrong. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] Add rtc driver for Coldfire M5441x.
On Sunday 17 June 2012 4:50:27 am Geert Uytterhoeven wrote: > Hi Steven, > > On Sun, Jun 17, 2012 at 1:40 PM, Steven King wrote: > > On Sunday 17 June 2012 4:15:03 am Geert Uytterhoeven wrote: > >> On Sun, Jun 17, 2012 at 11:23 AM, Steven King wrote: > >> > On Sunday 17 June 2012 2:09:51 am Geert Uytterhoeven wrote: > >> >> On Sun, Jun 17, 2012 at 9:50 AM, Steven King wrote: > >> >> > +config RTC_DRV_M5441x > >> >> > + tristate "Freescale Coldfire M5441x RTC support" > >> >> > + depends on M5441x > >> >> > + help > >> >> > + This enables support for the RTC on the Freescale > >> >> > Coldfire 5441x + (54410/54415/54416/54417/54418). > >> >> > + > >> >> > + This driver can also be built as a module. If so, the > >> >> > module + will be called rtc-m5441x. > >> >> > >> >> But the platform device is called differently: > >> >> > +static struct platform_driver m5441x_rtc_driver = { > >> >> > + .driver.name = "mcfrtc", > >> >> > + .driver.owner = THIS_MODULE, > >> >> > + .remove = __devexit_p(m5441x_rtc_remove), > >> >> > +}; > >> >> > >> >> Is there a specific reason for that? > >> > > >> > You mean the "mcfrtc" bit? Thats the same as what we do for all of > >> > the other > >> > >> That's what I meant. > >> > >> > Coldfire peripherals, ie "mcfqspi", "mcfuart", etc. > >> > >> So why not call the driver mcf-rtc? > > > > Because that rtc implementation is specific to the m5441x; should someone > > implement a driver for the rtc on the 532x or 54455 which are somewhat > > different than the m5441x, then they might well need a separate rtc-m532x > > or rtc-m54455. > > At that point, you'll have to call the platform device rtc-m532x or > rtc-m54455 as well, as mcfrtc is already taken for the m5441x, right? No. The others would still use mcfrtc as their device name. Thats the whole point. The platform code in arch/m68k/platform/coldfire/device.c can have single definition of an 'mcfrtc' device and which ever coldfire version is selected determines which rtc would be availible. > So why not call the platform device rtc-m5441x now? Because that would be wrong. ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] Add rtc driver for Coldfire M5441x.
Hi Steven, On Sun, Jun 17, 2012 at 1:40 PM, Steven King wrote: > On Sunday 17 June 2012 4:15:03 am Geert Uytterhoeven wrote: >> On Sun, Jun 17, 2012 at 11:23 AM, Steven King wrote: >> > On Sunday 17 June 2012 2:09:51 am Geert Uytterhoeven wrote: >> >> On Sun, Jun 17, 2012 at 9:50 AM, Steven King wrote: >> >> > +config RTC_DRV_M5441x >> >> > + tristate "Freescale Coldfire M5441x RTC support" >> >> > + depends on M5441x >> >> > + help >> >> > + This enables support for the RTC on the Freescale Coldfire >> >> > 5441x + (54410/54415/54416/54417/54418). >> >> > + >> >> > + This driver can also be built as a module. If so, the >> >> > module + will be called rtc-m5441x. >> >> >> >> But the platform device is called differently: >> >> > +static struct platform_driver m5441x_rtc_driver = { >> >> > + .driver.name = "mcfrtc", >> >> > + .driver.owner = THIS_MODULE, >> >> > + .remove = __devexit_p(m5441x_rtc_remove), >> >> > +}; >> >> >> >> Is there a specific reason for that? >> > >> > You mean the "mcfrtc" bit? Thats the same as what we do for all of the >> > other >> >> That's what I meant. >> >> > Coldfire peripherals, ie "mcfqspi", "mcfuart", etc. >> >> So why not call the driver mcf-rtc? > > Because that rtc implementation is specific to the m5441x; should someone > implement a driver for the rtc on the 532x or 54455 which are somewhat > different than the m5441x, then they might well need a separate rtc-m532x or > rtc-m54455. At that point, you'll have to call the platform device rtc-m532x or rtc-m54455 as well, as mcfrtc is already taken for the m5441x, right? So why not call the platform device rtc-m5441x now? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] Add rtc driver for Coldfire M5441x.
On Sunday 17 June 2012 4:15:03 am Geert Uytterhoeven wrote: > On Sun, Jun 17, 2012 at 11:23 AM, Steven King wrote: > > On Sunday 17 June 2012 2:09:51 am Geert Uytterhoeven wrote: > >> On Sun, Jun 17, 2012 at 9:50 AM, Steven King wrote: > >> > +config RTC_DRV_M5441x > >> > + tristate "Freescale Coldfire M5441x RTC support" > >> > + depends on M5441x > >> > + help > >> > + This enables support for the RTC on the Freescale Coldfire > >> > 5441x + (54410/54415/54416/54417/54418). > >> > + > >> > + This driver can also be built as a module. If so, the > >> > module + will be called rtc-m5441x. > >> > >> But the platform device is called differently: > >> > +static struct platform_driver m5441x_rtc_driver = { > >> > + .driver.name = "mcfrtc", > >> > + .driver.owner = THIS_MODULE, > >> > + .remove = __devexit_p(m5441x_rtc_remove), > >> > +}; > >> > >> Is there a specific reason for that? > > > > You mean the "mcfrtc" bit? Thats the same as what we do for all of the > > other > > That's what I meant. > > > Coldfire peripherals, ie "mcfqspi", "mcfuart", etc. > > So why not call the driver mcf-rtc? Because that rtc implementation is specific to the m5441x; should someone implement a driver for the rtc on the 532x or 54455 which are somewhat different than the m5441x, then they might well need a separate rtc-m532x or rtc-m54455. ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] Add rtc driver for Coldfire M5441x.
On Sun, Jun 17, 2012 at 11:23 AM, Steven King wrote: > On Sunday 17 June 2012 2:09:51 am Geert Uytterhoeven wrote: >> On Sun, Jun 17, 2012 at 9:50 AM, Steven King wrote: >> > +config RTC_DRV_M5441x >> > + tristate "Freescale Coldfire M5441x RTC support" >> > + depends on M5441x >> > + help >> > + This enables support for the RTC on the Freescale Coldfire >> > 5441x + (54410/54415/54416/54417/54418). >> > + >> > + This driver can also be built as a module. If so, the module >> > + will be called rtc-m5441x. >> >> But the platform device is called differently: >> > +static struct platform_driver m5441x_rtc_driver = { >> > + .driver.name = "mcfrtc", >> > + .driver.owner = THIS_MODULE, >> > + .remove = __devexit_p(m5441x_rtc_remove), >> > +}; >> >> Is there a specific reason for that? > > You mean the "mcfrtc" bit? Thats the same as what we do for all of the other That's what I meant. > Coldfire peripherals, ie "mcfqspi", "mcfuart", etc. So why not call the driver mcf-rtc? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] Add rtc driver for Coldfire M5441x.
On Sunday 17 June 2012 12:50:45 am Steven King wrote: > Add support for the Coldfire m5441x on-chip rtc. > > Signed-off-by: Stven King D'oh! that should be Steven not Stven. ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] Add rtc driver for Coldfire M5441x.
On Sun, Jun 17, 2012 at 9:50 AM, Steven King wrote: > +config RTC_DRV_M5441x > + tristate "Freescale Coldfire M5441x RTC support" > + depends on M5441x > + help > + This enables support for the RTC on the Freescale Coldfire 5441x > + (54410/54415/54416/54417/54418). > + > + This driver can also be built as a module. If so, the module > + will be called rtc-m5441x. But the platform device is called differently: > +static struct platform_driver m5441x_rtc_driver = { > + .driver.name= "mcfrtc", > + .driver.owner = THIS_MODULE, > + .remove = __devexit_p(m5441x_rtc_remove), > +}; Is there a specific reason for that? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
[uClinux-dev] [PATCH] Add rtc driver for Coldfire M5441x.
Add support for the Coldfire m5441x on-chip rtc. Signed-off-by: Stven King --- drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile |1 + drivers/rtc/rtc-m5441x.c | 363 ++ 3 files changed, 374 insertions(+) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 08cbdb9..da2b3c4 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1087,4 +1087,14 @@ config RTC_DRV_MXC This driver can also be built as a module, if so, the module will be called "rtc-mxc". +config RTC_DRV_M5441x + tristate "Freescale Coldfire M5441x RTC support" + depends on M5441x + help + This enables support for the RTC on the Freescale Coldfire 5441x + (54410/54415/54416/54417/54418). + + This driver can also be built as a module. If so, the module + will be called rtc-m5441x. + endif # RTC_CLASS diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 2973921..a9ded2c 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -61,6 +61,7 @@ obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o obj-$(CONFIG_RTC_DRV_M48T35) += rtc-m48t35.o obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o +obj-$(CONFIG_RTC_DRV_M5441x) += rtc-m5441x.o obj-$(CONFIG_RTC_DRV_MXC) += rtc-mxc.o obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o obj-$(CONFIG_RTC_DRV_MAX8925) += rtc-max8925.o diff --git a/drivers/rtc/rtc-m5441x.c b/drivers/rtc/rtc-m5441x.c new file mode 100644 index 000..ba677f3 --- /dev/null +++ b/drivers/rtc/rtc-m5441x.c @@ -0,0 +1,363 @@ +/* + * RTC driver for the Freescale Coldfire 5441x SoCs. + * + * Copyright(C) 2012, Steven King + */ + +#include +#include +#include +#include +#include +#include +#include + +static void __iomem *m5441x_rtc_base; +static int m5441x_rtc_irq; +static struct clk *m5441x_rtc_clk; + +#define M5441X_RTC_YEARMON (m5441x_rtc_base + 0x00) +#define M5441X_RTC_DAYS(m5441x_rtc_base + 0x02) +#define M5441X_RTC_HOURMIN (m5441x_rtc_base + 0x04) +#define M5441X_RTC_SECONDS (m5441x_rtc_base + 0x06) +#define M5441X_RTC_ALM_YRMON (m5441x_rtc_base + 0x08) +#define M5441X_RTC_ALM_DAYS(m5441x_rtc_base + 0x0a) +#define M5441X_RTC_ALM_HM (m5441x_rtc_base + 0x0c) +#define M5441X_RTC_ALM_SEC (m5441x_rtc_base + 0x0e) +#define M5441X_RTC_CR (m5441x_rtc_base + 0x10) +#define M5441X_RTC_CR_AM0 (0 << 2)/* secs/mins/hrs */ +#define M5441X_RTC_CR_AM1 (1 << 2)/* secs/mins/days */ +#define M5441X_RTC_CR_AM2 (2 << 2)/* secs/mins/days/mons */ +#define M5441X_RTC_CR_AM3 (3 << 2)/* alarm match all */ +#define M5441X_RTC_CR_DTDEN(1 << 6)/* DST enable */ +#define M5441X_RTC_CR_BCDEN(1 << 7)/* BCD enable */ +#define M5441X_RTC_CR_SWR (1 << 8)/* software reset */ +#define M5441X_RTC_SR (m5441x_rtc_base + 0x12) +#define M5441X_RTC_SR_INVAL(1 << 0)/* time invalid */ +#define M5441X_RTC_SR_CDON (1 << 1)/* Compensation done */ +#define M5441X_RTC_SR_BERR (1 << 2)/* Bus err */ +#define M5441X_RTC_SR_WPE (1 << 4)/* write protect enabled */ +#define M5441X_RTC_SR_PORB (1 << 6)/* power on reset boot */ +#define M5441X_RTC_ISR (m5441x_rtc_base + 0x14) +#define M5441X_RTC_ISR_STW (1 << 1)/* Stop watch */ +#define M5441X_RTC_ISR_ALM (1 << 2)/* Alarm */ +#define M5441X_RTC_ISR_DAY (1 << 3)/* day counter inc */ +#define M5441X_RTC_ISR_HR (1 << 4)/* hour counter inc */ +#define M5441X_RTC_ISR_MIN (1 << 5)/* minute counter inc */ +#define M5441X_RTC_ISR_1HZ (1 << 6)/* second counter inc */ +#define M5441X_RTC_ISR_2HZ (1 << 7)/* 2Hz counter inc */ +#define M5441X_RTC_IER (m5441x_rtc_base + 0x16) +#define M5441X_RTC_IER_STW (1 << 1)/* Stop watch */ +#define M5441X_RTC_IER_ALM (1 << 2)/* Alarm */ +#define M5441X_RTC_IER_DAY (1 << 3)/* day counter inc */ +#define M5441X_RTC_IER_HR (1 << 4)/* hour counter inc */ +#define M5441X_RTC_IER_MIN (1 << 5)/* minute counter inc */ +#define M5441X_RTC_IER_1HZ (1 << 6)/* second counter inc */ +#define M5441X_RTC_IER_2HZ (1 << 7)/* 2Hz counter inc */ +#define M5441X_RTC_COUNT_DN(m5441x_rtc_base + 0x18) +#define M5441X_RTC_CFG_DATA(m5441x_rtc_base + 0x20) +#define M5441X_RTC_DST_HOUR(m5441x_rtc_base + 0x22) +#define M5441X_RTC_DST_MON (m5441x_rtc_base + 0x24) +#define M5441X_RTC_DST_DAY (m5441x_rtc_base + 0x26) +#define M5441X_RTC_RTC_COMPEN (m5441x_rtc_base + 0x28) +#define M5441X_RTC_UP_CNTRH(m5441x_rtc_base + 0x32) +#define M5441X_RTC_UP_CNTRL(m5441x_rtc_base + 0x24) +#define M5441X_RTC_Standy_RAM (m5441x_rtc_base + 0x40) + +static int m5441x_rtc_read_time(struct device *dev, struct rtc_time