]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/bcm/archbcm.c
merge
[plan9front.git] / sys / src / 9 / bcm / archbcm.c
index eb9c4c2d82ae2f2a694b1d163722ada405a87fd3..d2e13833029d32812bcffe0d549d519261c9eadf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * bcm2835 (e.g. raspberry pi) architecture-specific stuff
+ * bcm2835 (e.g. original raspberry pi) architecture-specific stuff
  */
 
 #include "u.h"
 
 #define        POWERREGS       (VIRTIO+0x100000)
 
+Soc soc = {
+       .dramsize       = 512*MiB,
+       .busdram        = 0x40000000,
+       .iosize         = 16*MiB,
+       .virtio         = VIRTIO,
+       .physio         = 0x20000000,
+       .busio          = 0x7E000000,
+       .armlocal       = 0,
+       .l1ptedramattrs = Cached | Buffered,
+       .l2ptedramattrs = Cached | Buffered,
+};
+
 enum {
        Wdogfreq        = 65536,
+       Wdogtime        = 10,   /* seconds, ≤ 15 */
 };
 
 /*
@@ -25,6 +38,7 @@ enum {
                Password        = 0x5A<<24,
                CfgMask         = 0x03<<4,
                CfgReset        = 0x02<<4,
+       Rsts            = 0x20>>2,
        Wdog            = 0x24>>2,
 };
 
@@ -47,14 +61,63 @@ archreboot(void)
                ;
 }
 
+void
+wdogfeed(void)
+{
+       u32int *r;
+
+       r = (u32int*)POWERREGS;
+       r[Wdog] = Password | (Wdogtime * Wdogfreq);
+       r[Rstc] = Password | (r[Rstc] & ~CfgMask) | CfgReset;
+}
+
+void
+wdogoff(void)
+{
+       u32int *r;
+
+       r = (u32int*)POWERREGS;
+       r[Rstc] = Password | (r[Rstc] & ~CfgMask);
+}
+       
+char *
+cputype2name(char *buf, int size)
+{
+       seprint(buf, buf + size, "1176JZF-S");
+       return buf;
+}
+
 void
 cpuidprint(void)
 {
-       print("cpu%d: %dMHz ARM1176JZF-S\n", m->machno, m->cpumhz);
+       char name[64];
+
+       cputype2name(name, sizeof name);
+       delay(50);                              /* let uart catch up */
+       print("cpu%d: %dMHz ARM %s\n", m->machno, m->cpumhz, name);
+}
+
+int
+getncpus(void)
+{
+       return 1;
+}
+
+int
+startcpus(uint)
+{
+       return 1;
 }
 
 void
 archbcmlink(void)
 {
+       addclock0link(wdogfeed, HZ);
+}
+
+int
+cmpswap(long *addr, long old, long new)
+{
+       return cas32(addr, old, new);
 }