diff --git a/host/rpi/rpi.go b/host/rpi/rpi.go index 5277a434c..3cd4adbec 100644 --- a/host/rpi/rpi.go +++ b/host/rpi/rpi.go @@ -431,52 +431,74 @@ type features struct { } func (f *features) init(v uint32) error { - /* - r, err := parseRevision(v) - if err != nil { - return err - } - */ - r := v + r, err := parseRevision(v) + if err != nil { + return err + } // Ignore the overclock bit. - r &= 0xFFFFFF - switch r { - case 0x2, 0x3: // B v1.0 + r &^= warrantyVoid + switch r & boardMask { + case board1A: f.hdrP1P26 = true f.hdrAudio = true - case 0x4, 0x5, 0x6, // B v2.0 - 0x7, 0x8, 0x9, // A v2.0 - 0xd, 0xe, 0xf: // B v2.0 + // Only the v2 PCB has the P5 header. + if r&revisionMask == 2 { + f.hdrP5 = true + f.hdrHDMI = true + } + case board1B: f.hdrP1P26 = true + f.hdrAudio = true // Only the v2 PCB has the P5 header. - f.hdrP5 = true + if r&revisionMask == 2 { + f.hdrP5 = true + f.hdrHDMI = true + } + case board1APlus: + f.hdrP1P40 = true + f.hdrAudio = true + f.hdrHDMI = true + case board1BPlus: + f.hdrP1P40 = true + f.hdrAudio = true + f.hdrHDMI = true + case board2B: + f.hdrP1P40 = true f.hdrAudio = true f.hdrHDMI = true - case 0x10, // B+ v1.0 - 0x12, // A+ v1.1 - 0x13, // B+ v1.2 - 0x15, // A+ v1.1 - 0x90021, // A+ v1.1 - 0x90032, // B+ v1.2 - 0xa01040, // 2 Model B v1.0 - 0xa01041, 0xa21041, // 2 Model B v1.1 - 0xa22042: // 2 Model B v1.2 + case boardAlpha: + case boardCM1: + // TODO: define CM1 SODIMM header if anyone ever needs it. Please file an + // issue at https://github.com/google/periph/issues/new/choose + case board3B: f.hdrP1P40 = true f.hdrAudio = true + f.audioLeft41 = true + f.hdrHDMI = true + case boardZero: + f.hdrP1P40 = true + f.hdrHDMI = true + case boardCM3: + // Tell CM3 and CM3-Lite apart, if possible. + f.hdrSODIMM = true + case boardZeroW: + f.hdrP1P40 = true f.hdrHDMI = true - case 0x900092, // Zero v1.2 - 0x900093, // Zero v1.3 - 0x920093, // Zero v1.3 - 0x9000c1: // Zero W v1.1 + case board3BPlus: f.hdrP1P40 = true + f.hdrAudio = true + f.audioLeft41 = true + f.hdrHDMI = true + case board3APlus: + f.hdrP1P40 = true + f.hdrAudio = true + f.audioLeft41 = true f.hdrHDMI = true - case 0x11, // Compute Module 1 - 0x14: // Compute Module 1 - // SODIMM not defined - case 0xa020a0: // Compute Module 3 v1.0 + case boardReserved: + case boardCM3Plus: + // Tell CM3 and CM3-Lite apart, if possible. f.hdrSODIMM = true - // tell CM3 and CM3-Lite apart, if possible - case 0xa02082, 0xa22082, 0xa32082, 0xa020d3: // 3 Model B v1.2, B+ + case board4B: f.hdrP1P40 = true f.hdrAudio = true f.audioLeft41 = true diff --git a/host/rpi/rpi_test.go b/host/rpi/rpi_test.go index e7186cea8..8a2721490 100644 --- a/host/rpi/rpi_test.go +++ b/host/rpi/rpi_test.go @@ -117,6 +117,18 @@ func TestFeaturesInit(t *testing.T) { {0xa22042, features{hdrP1P40: true, hdrAudio: true, hdrHDMI: true}}, // board2B {0xa22082, features{hdrP1P40: true, hdrAudio: true, audioLeft41: true, hdrHDMI: true}}, // board3B {0xa32082, features{hdrP1P40: true, hdrAudio: true, audioLeft41: true, hdrHDMI: true}}, // board3B + {0x900021, features{hdrP1P40: true, hdrAudio: true, hdrHDMI: true}}, // board1APlus + {0x900032, features{hdrP1P40: true, hdrAudio: true, hdrHDMI: true}}, // board1BPlus + {0x9020e0, features{hdrP1P40: true, hdrAudio: true, audioLeft41: true, hdrHDMI: true}}, // board3APlus + {0x920092, features{hdrP1P40: true, hdrHDMI: true}}, // boardZero + {0x900061, features{}}, // boardCM1 + {0xa220a0, features{hdrSODIMM: true}}, // boardCM3 + {0xa52082, features{hdrP1P40: true, hdrAudio: true, audioLeft41: true, hdrHDMI: true}}, // board3B + {0xa22083, features{hdrP1P40: true, hdrAudio: true, audioLeft41: true, hdrHDMI: true}}, // board3B + {0xa02100, features{hdrSODIMM: true}}, // boardCM3Plus + {0xa03111, features{hdrP1P40: true, hdrAudio: true, audioLeft41: true, hdrHDMI: true}}, // board4B + {0xb03111, features{hdrP1P40: true, hdrAudio: true, audioLeft41: true, hdrHDMI: true}}, // board4B + {0xc03111, features{hdrP1P40: true, hdrAudio: true, audioLeft41: true, hdrHDMI: true}}, // board4B } for i, line := range data { f := features{} @@ -134,18 +146,6 @@ func TestFeaturesInitErr(t *testing.T) { 0x0, 0x1, 0x16, - 0x900021, // board1APlus - 0x900032, // board1BPlus - 0x9020e0, // board3APlus - 0x920092, // boardZero - 0x900061, // boardCM1 - 0xa220a0, // boardCM3 - 0xa52082, // board3B - 0xa22083, // board3B - 0xa02100, // boardCM3Plus - 0xa03111, // board4B - 0xb03111, // board4B - 0xc03111, // board4B } for i, v := range data { f := features{}