先日秋葉原で衝動買いした,M41T62が載ったRTCボードをRaspberry piにつないでみた.
データシートを見るとレジスタの仕様がDS1307と違っていてどうしたものかと思ったが,カーネルモジュールのリストを眺めてみたらm41txxが使えそう.
% ls /lib/modules/3.10.25+/kernel/drivers/rtc rtc-bq32k.ko rtc-ds3232.ko rtc-m41t80.ko rtc-pcf8523.ko rtc-rv3029c2.ko rtc-ds1305.ko rtc-ds3234.ko rtc-m41t93.ko rtc-pcf8563.ko rtc-rx4581.ko rtc-ds1307.ko rtc-em3027.ko rtc-m41t94.ko rtc-pcf8583.ko rtc-rx8025.ko rtc-ds1374.ko rtc-fm3130.ko rtc-max6900.ko rtc-r9701.ko rtc-rx8581.ko rtc-ds1390.ko rtc-isl12022.ko rtc-max6902.ko rtc-rs5c348.ko rtc-s35390a.ko rtc-ds1672.ko rtc-isl1208.ko rtc-pcf2123.ko rtc-rs5c372.ko rtc-x1205.ko
データシートを見ると,M41T93とM41T94はSPIで,M41T80はI2CでM41T62と時刻レジスタの仕様はほぼ同じ.
で,rtc-m41t80.koのソースコードを見るとM41T62もサポートされているようなので,さくっと使えそう.
72 static const struct i2c_device_id m41t80_id[] = {
73 { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT },
74 { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD },
75 { "m41t80", M41T80_FEATURE_SQ },
76 { "m41t81", M41T80_FEATURE_HT | M41T80_FEATURE_SQ},
77 { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
78 { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
79 { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
80 { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
81 { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
82 { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
83 { }
84 };
早速やってみた.
% sudo su # modprobe rtc-m41t80 # echo m41t62 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
これでM41T62が認識されてdmesgにログが出力される.
% dmesg | tail
[ 13.109501] i2c /dev entries driver
[ 13.378915] Driver for 1-wire Dallas network protocol.
[ 21.233753] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[ 21.234343] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 22.855768] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 22.857117] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1
[ 35.406699] Adding 102396k swap on /var/swap. Priority:-1 extents:1 across:102396k SSFS
[ 36.812102] rtc-m41t80 1-0068: chip found, driver version 0.05
[ 36.813680] rtc-m41t80 1-0068: rtc core: registered m41t62 as rtc0
[ 36.814748] i2c i2c-1: new_device: Instantiated device m41t62 at 0x68
時刻もしっかりとれる.
# hwclock -r; date Tue 06 May 2014 08:11:49 AM JST -0.906676 seconds Tue May 6 08:11:49 JST 2014