| 1 | Around revision [900], MutekH got support for Flattened device trees. |
| 2 | |
| 3 | = Rationale = |
| 4 | |
| 5 | Flattened device trees (FDT) are useful to get a list of all available hardware where no hardware-based enumeration exists (aka PnP, like PCI, USB, ... provides). |
| 6 | |
| 7 | FDT provides normalized representation of the hardware platform without adding specific initialization code. |
| 8 | |
| 9 | The normalization comes from IEEE1275 (aka Open Firmware); while Open Firmware also defined heavy things (like a Forth interpreter), we only use the FDT information. |
| 10 | |
| 11 | Using FDT is mainstream, andis also used by Linux and BSD, supported is U-Boot and other bootloaders. |
| 12 | |
| 13 | = Implementation = |
| 14 | |
| 15 | In MutekH, FDT is handled through an hardware enumerator device driver, it behaves like the other enumerators (PCI, ISAPnP). |
| 16 | |
| 17 | Drivers may export themselves as FDT-aware, and define which device name string to match. For instance, the following subtree defines a tty device: |
| 18 | |
| 19 | {{{ |
| 20 | tty@0 { |
| 21 | device_type = "soclib:tty"; |
| 22 | tty_count = <1>; |
| 23 | reg = <0x90600000 0x10>; |
| 24 | icudev = &{/icu@0}; |
| 25 | irq = <1>; |
| 26 | }; |
| 27 | }}} |
| 28 | |
| 29 | In turn, the SoCLib tty driver declares itself (in source:trunk/mutekh/drivers/device/char/tty-soclib/tty-soclib.c#L146) as: |
| 30 | |
| 31 | {{{ |
| 32 | static const struct devenum_ident_s tty_soclib_ids[] = |
| 33 | { |
| 34 | DEVENUM_FDTNAME_ENTRY("soclib:tty", 0, 0), |
| 35 | { 0 } |
| 36 | }; |
| 37 | |
| 38 | const struct driver_s tty_soclib_drv = |
| 39 | { |
| 40 | .class = device_class_char, |
| 41 | .id_table = tty_soclib_ids, |
| 42 | .f_init = tty_soclib_init, |
| 43 | .f_cleanup = tty_soclib_cleanup, |
| 44 | .f_irq = tty_soclib_irq, |
| 45 | .f.chr = { |
| 46 | .f_request = tty_soclib_request, |
| 47 | } |
| 48 | }; |
| 49 | }}} |
| 50 | |
| 51 | This will make the FDT enumerator use the correct driver, matching `"soclib:tty"` |