Hi, Previously I found OpenBSD-6.6, 6.7 and -current did not work on my Orange Pi PC (Allwinner H3).
For these days I was looking for what caused this problem, and finally I found the M field of H3_PLL_CPUX_CTRL_REG (@0x01c20000) made thing worse. This, M value should be 2. If this is 1, system will be hang. Here is easy test method that writing value 0x90001431 (default) and 0x90001410, they produce same clock frequency 1008MHz. But there is a mystery why OpenBSD-6.5 worked on Orange Pi PC. CPU Clock setting code was introduced at 6.4 so there was a time that code made no problem. Anyway there is a diff to work Orange Pi PC again. (over 1536MHz setting is not tested, maybe CPU will be overclocked.) Index: sxiccmu.c =================================================================== RCS file: /cvs/src/sys/dev/fdt/sxiccmu.c,v retrieving revision 1.27 diff -u -p -r1.27 sxiccmu.c --- sxiccmu.c 28 Mar 2020 12:32:53 -0000 1.27 +++ sxiccmu.c 28 Jun 2020 05:58:15 -0000 @@ -1633,16 +1633,22 @@ sxiccmu_h3_set_frequency(struct sxiccmu_ struct sxiccmu_clock clock; uint32_t parent, parent_freq; uint32_t reg; - int k, n; + int k, m, n; int error; switch (idx) { case H3_CLK_PLL_CPUX: - k = 1; n = 32; - while (k <= 4 && (24000000 * n * k) < freq) - k++; - while (n >= 1 && (24000000 * n * k) > freq) - n--; + if (freq >= 1584000000) { /* (n = 33) * 24MHz * 2 */ + m = 1; + k = 4; + } else if (freq >= 792000000) { /* (n = 33) * 24MHz */ + m = 2; + k = 4; + } else { + m = 2; + k = 2; + } + n = (freq / 24000000) * m / k; /* n should be 1 to 32 */ reg = SXIREAD4(sc, H3_PLL_CPUX_CTRL_REG); reg &= ~H3_PLL_CPUX_OUT_EXT_DIVP_MASK; @@ -1651,6 +1657,7 @@ sxiccmu_h3_set_frequency(struct sxiccmu_ reg &= ~H3_PLL_CPUX_FACTOR_M_MASK; reg |= ((n - 1) << H3_PLL_CPUX_FACTOR_N_SHIFT); reg |= ((k - 1) << H3_PLL_CPUX_FACTOR_K_SHIFT); + reg |= ((m - 1) << H3_PLL_CPUX_FACTOR_M_SHIFT); SXIWRITE4(sc, H3_PLL_CPUX_CTRL_REG, reg); /* Wait for PLL to lock. */ -- SASANO Takayoshi (JG1UAA) <u...@cvs.openbsd.org>