add support for ST M41T94 SPI RTC (patch rev. 3)
PATCH 1/1 add support for ST M41T94 SPI RTC (patch rev. 3)
This patch adds kernel driver for M41T94 RTC chip connected via SPI. I've tested it on two different AT91-based hardwares.
This is third revision of the patch: some comments made by Alessandro Zummo fixed.
Revision two added support for century bit and fixes.
drivers/rtc/Kconfig +9 -0
@@ -266,6 +266,15 @@ if SPI_MASTER +config RTC_DRV_M41T94 + tristate "ST M41T94" + help + If you say yes here you will get support for the + ST M41T94 SPI RTC chip. + + This driver can also be built as a module. If so, the module + will be called rtc-m41t94. + config RTC_DRV_MAX6902 tristate "Maxim MAX6902" help
drivers/rtc/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o +obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o
drivers/rtc/rtc-m41t94.c +173 -0
173 lines not on this page · raw message
[ I sent a few private messages to Kim, but I'll sumarize my problem here ]
Hi all,
I have AT91SAM9260-based board, kernel is 2.6.26.3. M41T94 is connected on SPI channel 1, chip select 0. I've applied Kim's patch and added SPI device in board-sam9260ek.c:
#if defined(CONFIG_RTC_DRV_M41T94) || defined(CONFIG_RTC_DRV_M41T94_MODULE)
{ /* External RTC */
.modalias = "rtc-m41t94",
.chip_select = 0,
.max_speed_hz = 2 * 1000 * 1000,
.bus_num = 1,
},#endif
During booting up everything seems fine (M41T94 is found etc), but it is not working. Here is some output:
rtc-m41t94: dev (254:0)
rtc-m41t94 spi1.0: rtc core: registered rtc-m41t94 as rtc0 rtc-m41t94 spi1.0: read secs=0, mins=0, hours=0, mday=0, mon=-1, year=100, wday=-1
rtc-m41t94 spi1.0: hctosys: unable to read the hardware clock [..]
# hwclock -r;dmesg hwclock: RTC_RD_TIME: Invalid argument rtc-m41t94 spi1.0: read secs=0, mins=0, hours=0, mday=0, mon=-1, year=100, wday=-1
#hwclock -w;dmesg
rtc-m41t94 spi1.0: write secs=15, mins=0, hours=0, mday=1, mon=0, year=70, wday=4
I've tried both SPIMODE0 and SPIMODE3 (according to m41t94 datasheet) but no improvements.
Thanks
Quoted 1 line
I have AT91SAM9260-based board, kernel is 2.6.26.3.
I'm using my RTC-patch with the same CPU. Custom AT91SAM9260 board, external RTC because of AT's errata...
Quoted 9 lines
M41T94 is connected on SPI channel 1, chip select 0. I've applied Kim's patch and added SPI device in
board-sam9260ek.c{ /* External RTC */ .modalias = "rtc-m41t94", .chip_select = 0, .max_speed_hz = 2 * 1000 * 1000, .bus_num = 1, },
I'm using it with ".max_speed_hz = 1 * 1000 * 1000," instead of 2 MHz. Can you try with slower speed? My patch (rev 3) and this small ek_spi_devices[] modification should be enough.
I have it on bus = 0, chip_select = 1, so I've also removed dataflash parts from ek_spi_devices[] (we're using NOR flash). But for you this is not needed.
I also have a patch to add support for M41T94's watchdog timer. It's not clean enough to be submitted upstreams yet. If you need it I can email it to you.