Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] ppc32: add rtc hooks in PPC7D platform file

This patch adds the hooks into the PPC7D platforms file to support the DS1337
RTC device as the clock device for the PPC7D board.

Signed-off-by: Chris Elston <chris.elston@radstone.co.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Chris Elston and committed by
Linus Torvalds
a497aa20 630710e3

+42
+42
arch/ppc/platforms/radstone_ppc7d.c
··· 68 68 #define PPC7D_RST_PIN 17 /* GPP17 */ 69 69 70 70 extern u32 mv64360_irq_base; 71 + extern spinlock_t rtc_lock; 71 72 72 73 static struct mv64x60_handle bh; 73 74 static int ppc7d_has_alma; 74 75 75 76 extern void gen550_progress(char *, unsigned short); 76 77 extern void gen550_init(int, struct uart_port *); 78 + 79 + /* FIXME - move to h file */ 80 + extern int ds1337_do_command(int id, int cmd, void *arg); 81 + #define DS1337_GET_DATE 0 82 + #define DS1337_SET_DATE 1 77 83 78 84 /* residual data */ 79 85 unsigned char __res[sizeof(bd_t)]; ··· 1248 1242 printk(KERN_INFO "Radstone Technology PPC7D\n"); 1249 1243 if (ppc_md.progress) 1250 1244 ppc_md.progress("ppc7d_setup_arch: exit", 0); 1245 + 1246 + } 1247 + 1248 + /* Real Time Clock support. 1249 + * PPC7D has a DS1337 accessed by I2C. 1250 + */ 1251 + static ulong ppc7d_get_rtc_time(void) 1252 + { 1253 + struct rtc_time tm; 1254 + int result; 1255 + 1256 + spin_lock(&rtc_lock); 1257 + result = ds1337_do_command(0, DS1337_GET_DATE, &tm); 1258 + spin_unlock(&rtc_lock); 1259 + 1260 + if (result == 0) 1261 + result = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); 1262 + 1263 + return result; 1264 + } 1265 + 1266 + static int ppc7d_set_rtc_time(unsigned long nowtime) 1267 + { 1268 + struct rtc_time tm; 1269 + int result; 1270 + 1271 + spin_lock(&rtc_lock); 1272 + to_tm(nowtime, &tm); 1273 + result = ds1337_do_command(0, DS1337_SET_DATE, &tm); 1274 + spin_unlock(&rtc_lock); 1275 + 1276 + return result; 1251 1277 } 1252 1278 1253 1279 /* This kernel command line parameter can be used to have the target ··· 1336 1298 data8 &= ~0x08; 1337 1299 data8 |= 0x07; 1338 1300 outb(data8, PPC7D_CPLD_LEDS); 1301 + 1302 + /* Hook up RTC. We couldn't do this earlier because we need the I2C subsystem */ 1303 + ppc_md.set_rtc_time = ppc7d_set_rtc_time; 1304 + ppc_md.get_rtc_time = ppc7d_get_rtc_time; 1339 1305 1340 1306 pr_debug("%s: exit\n", __FUNCTION__); 1341 1307 }