f_ changed the topic of ##raspberrypi-internals to: The inner workings of the Raspberry Pi (Low level VPU/HW) -- for general queries please visit #raspberrypi -- open firmware: https://librerpi.github.io/ -- VC4 VPU Programmers Manual: https://github.com/hermanhermitage/videocoreiv/wiki -- chat logs: https://libera.irclog.whitequark.org/~h~raspberrypi-internals -- bridged to matrix and discord
<f_ridge> <x​2x6_/D> having this as register values and 1000 as result of PLLC PER frequency, what do we get for emmc freq?
<f_ridge> <G​itHub Lines/D> ```h
<f_ridge> <G​itHub Lines/D> #define CM_EMMCDIV_DIV_BITS 15:4
<f_ridge> <G​itHub Lines/D> #define CM_EMMCDIV_DIV_SET 0x0000fff0
<f_ridge> <G​itHub Lines/D> ```
<f_ridge> <c​lever___/D> this says that the divisor is stored in bits 4-15
<f_ridge> <c​lever___/D> so we take your `00005000` and turn it into `0x500`
<f_ridge> <x​2x6_/D> yes, that I did , so we divide 1000 by 1280
<f_ridge> <c​lever___/D> then linux says that its a 4.8bit fixed-point int
<f_ridge> <c​lever___/D> so that 5 is the integer part, and the `00` is the fractional part
<f_ridge> <c​lever___/D> you can also use `0x500 / 256` to convert to floating point, which gives you plain old `5`
<f_ridge> <c​lever___/D> so now its `1000/5`
<f_ridge> <x​2x6_/D> Ahh, ok
<f_ridge> <x​2x6_/D> So its 250 MHz
<f_ridge> <c​lever___/D> ```
<f_ridge> <c​lever___/D> > 1000/5
<f_ridge> <c​lever___/D> 200
<f_ridge> <c​lever___/D> ```
<f_ridge> <x​2x6_/D> So its 200(edited)
<f_ridge> <x​2x6_/D> Yes.
<f_ridge> <x​2x6_/D> At least I saw this clock with my own eyes and now believe in clock)
<f_ridge> <G​itHub Lines/D> ```c
<f_ridge> <G​itHub Lines/D> int measure_clock(int mux) {
<f_ridge> <G​itHub Lines/D> int divisor = 1000;
<f_ridge> <G​itHub Lines/D> *REG32(CM_TCNTCTL) = CM_PASSWORD | CM_KILL;
<f_ridge> <G​itHub Lines/D> *REG32(CM_TCNTCTL) = CM_PASSWORD | (mux & CM_SRC_MASK) | (mux >> CM_SRC_BITS) << CM_TCNT_SRC1_SHIFT;
<f_ridge> <G​itHub Lines/D> *REG32(CM_OSCCOUNT) = CM_PASSWORD | (xtal_freq / divisor);
<f_ridge> <G​itHub Lines/D> udelay(1);
<f_ridge> <G​itHub Lines/D> while (*REG32(CM_OSCCOUNT)) {
<f_ridge> <G​itHub Lines/D> }
<f_ridge> <G​itHub Lines/D> while (*REG32(CM_TCNTCTL) & CM_BUSY) {
<f_ridge> <G​itHub Lines/D> }
<f_ridge> <G​itHub Lines/D> int count = *REG32(CM_TCNTCNT);
<f_ridge> <G​itHub Lines/D> *REG32(CM_TCNTCNT) = CM_PASSWORD | 0;
<f_ridge> <G​itHub Lines/D> return count * divisor;
<f_ridge> <G​itHub Lines/D> }
<f_ridge> <G​itHub Lines/D> ```
<f_ridge> <c​lever___/D> another thing that can be handy, is this function
<f_ridge> <c​lever___/D> basically, you can create a delay that will last for X clock cycles of the 19.2mhz crystal
<f_ridge> <c​lever___/D> and while doing that delay, you can count how many clock cycles occured on an arbitrary clock
<f_ridge> <c​lever___/D> it has a ~32 way input mux, to select nearly any clock in the system
<f_ridge> <c​lever___/D> with a bit of math, you can then find the ratio between the 19.2mhz clock and the measured clock, and then work out what rate its at
<f_ridge> <x​2x6_/D> nice
<f_ridge> <x​2x6_/D> That's already pretty internal)
<f_ridge> <x​2x6_/D> I have to sleep before work, see you later)
<f_ridge> <c​lever___/D> later
jcea has quit [Quit: jcea]
jcea has joined ##raspberrypi-internals
jcea has quit [Quit: jcea]
jcea has joined ##raspberrypi-internals
jcea has quit [Ping timeout: 246 seconds]
CompanionCube has quit [Quit: ZNC - http://znc.in]
CompanionCube has joined ##raspberrypi-internals
wael has quit [Ping timeout: 264 seconds]
Ad0 has quit [Ping timeout: 252 seconds]
Ad0 has joined ##raspberrypi-internals
wael has joined ##raspberrypi-internals
Stromeko has quit [Quit: Going… gone.]
Stromeko has joined ##raspberrypi-internals
jcea has joined ##raspberrypi-internals
jcea has quit [Ping timeout: 246 seconds]
jcea has joined ##raspberrypi-internals