|
| 1 | +# SMARC-sAM67 embedded controller |
| 2 | + |
| 3 | +This is the source code for the embedded controller on the Kontron SMARC-sAM67 |
| 4 | +board. It is powered from the standby domain and runs while the main SoC is |
| 5 | +powered-off and provides basic house keeping services and glue logic. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- TWI host interface which exposes the control registers |
| 10 | +- Watchdog and failsafe watchdog |
| 11 | +- Voltage sensors |
| 12 | +- Board settings stored in non-volatile memory |
| 13 | +- Debug UART and debug registers |
| 14 | + |
| 15 | +## Watchdog |
| 16 | + |
| 17 | +The watchdog is a software reimplementation of the SMARC-sAL28 [CPLD |
| 18 | +watchdog](https://github.com/mwalle/sl28cpld/). This way, the linux kernel |
| 19 | +driver can be reused. |
| 20 | + |
| 21 | +The watchdog actually consists of two watchdogs. The SMARC watchdog, which also |
| 22 | +feed the SMARC `WDT_TIME_OUT#` signal and a failsafe watchdog. The latter is |
| 23 | +responsible to keep the board accessible even if the main bootloader is broken. |
| 24 | + |
| 25 | +Both watchdogs share the same counter and the same counting frequency. The |
| 26 | +counting period is 1 second. As a register is 8 bit wide. The largest possible |
| 27 | +timeout is 255s. |
| 28 | + |
| 29 | +### Failsafe Mechanism |
| 30 | + |
| 31 | +If the failsafe watchdog is not disabled by the configuration it automatically |
| 32 | +starts when the board is powered-up or reset[^1]. The watchdog has to be stopped |
| 33 | +by the bootloader within the timeout period of 10s. If that is not the case, the |
| 34 | +bootsource is switched to the onboard SPI flash which contains a non-volatile |
| 35 | +failsafe bootloader and a SoC reset is issued. |
| 36 | + |
| 37 | +[^1]: While the failsafe watchdog is running a reset will *not* reset the |
| 38 | + watchdog itself. Thus, if you keep the board in reset after power is |
| 39 | + applied, the failsafe watchdog will bite after 10s. |
| 40 | + |
| 41 | +## Voltage Sensors |
| 42 | + |
| 43 | +The controller can measure (but not supervise) the board input and the RTC |
| 44 | +voltage. The latter is tricky to measure because a measurement will always draw |
| 45 | +a bit of power from the voltage rail. To minimize that effect, the voltage is |
| 46 | +measured only every 10s. Also because the ADC pins of the used microcontroller |
| 47 | +have quite a high input leakage current (compared to the nA of the RTC) it is |
| 48 | +gated by a FET. That FET needs a voltage larger than the RTC voltage. For that, |
| 49 | +the board features a charge pump using a simple voltage ladder. The controller |
| 50 | +takes care of the PWM for that ladder, too. |
| 51 | + |
| 52 | +## DEBUG UART And Debug Registers |
| 53 | + |
| 54 | +If enabled in the configuration, a debug UART will output some startup and |
| 55 | +runtime configuration. That UART is connected to the SoC (but shared with some |
| 56 | +bootmode pins) and to the JTAG connector (as `SWO`). Also, if debug is enabed, |
| 57 | +some more registers are accessible. |
| 58 | + |
| 59 | +## Configuration |
| 60 | + |
| 61 | +The configuration consists of at most 8 byte and is version controlled. That is, |
| 62 | +if in the future the configuration layout will change the version field can be |
| 63 | +increased and the controller can migrate the old configuration layout to the new |
| 64 | +one. |
| 65 | + |
| 66 | +### Configuration Layout v0 |
| 67 | + |
| 68 | +| Offset | Description | |
| 69 | +| --- | --- | |
| 70 | +| 0 | Version, must be 0 | |
| 71 | +| 1 | Flags LSB | |
| 72 | +| 2 | Flags MSB | |
| 73 | +| 3 | Bootmode LSB | |
| 74 | +| 4 | Bootmode MSB | |
| 75 | + |
| 76 | +The following flags are supported: |
| 77 | + |
| 78 | +| Bit | Description | |
| 79 | +| --- | --- | |
| 80 | +| 0 | Power-on inhibit | |
| 81 | +| 1 | Drive bootmode pins | |
| 82 | +| 2 | Enable watchdog by default | |
| 83 | +| 3 | Disable failsafe watchdog by default | |
| 84 | +| 15 | Debug enable | |
| 85 | + |
| 86 | +## Register Map |
0 commit comments