| 13 | | = Implementation = |
| | 13 | = References = |
| | 14 | |
| | 15 | * You may learn many things [http://www.google.com/search?q=flattened%20device%20tree googling] for "flattened device tree". |
| | 16 | * The `dtc` utility used to compile `.dts` files in MutekH is mainteained at http://git.jdl.com/. You may: |
| | 17 | * Browse the git there http://git.jdl.com/gitweb/ |
| | 18 | * Download a snapshot http://git.jdl.com/software/ |
| | 19 | This repository also includes some documentation and a reference library for handling FDTs. |
| | 20 | * The Linux kernel documentation tree contains [http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=blob;f=Documentation/powerpc/booting-without-of.txt;h=79f533f38c6112d64bed9398c44d31cf3b552f6b;hb=HEAD an useful document] about device trees (`Documentation/powerpc/booting-without-of.txt`) |
| | 21 | |
| | 22 | = Implementation and example = |
| | 61 | |
| | 62 | = MutekH-Specific Node syntax quick reference = |
| | 63 | |
| | 64 | == Processors == |
| | 65 | |
| | 66 | Processor nodes look like: |
| | 67 | {{{ |
| | 68 | Mips,32@0 { |
| | 69 | name = "Mips,32"; |
| | 70 | device_type = "cpu"; |
| | 71 | reg = <0>; |
| | 72 | }; |
| | 73 | }}} |
| | 74 | |
| | 75 | `reg`:: |
| | 76 | This is the CPU identification number |
| | 77 | `device_type`:: |
| | 78 | must be `"cpu"` |
| | 79 | |
| | 80 | == Memories == |
| | 81 | |
| | 82 | Memory nodes look like: |
| | 83 | {{{ |
| | 84 | memory@0 { |
| | 85 | device_type = "memory"; |
| | 86 | cached; |
| | 87 | reg = <0x61100000 0x00100000>; |
| | 88 | }; |
| | 89 | }}} |
| | 90 | |
| | 91 | `device_type`:: |
| | 92 | must be "memory" |
| | 93 | `reg`:: |
| | 94 | must be a couple of <address size> with both the values respecting `#address-cells` and `#size-cells`. |
| | 95 | |
| | 96 | There are two optional attributes: |
| | 97 | |
| | 98 | `cached`:: |
| | 99 | The memory is cacheable |
| | 100 | `coherent`:: |
| | 101 | The memory is cached and coherent (`cached` is implied, setting it is optional) |
| | 102 | |
| | 103 | == References to interrupt controllers == |
| | 104 | |
| | 105 | Interrupts controller are referenced from one node to another in order to describe the interrupt tree. References are handled through the following properties: |
| | 106 | `icudev`:: |
| | 107 | Must be a path to an existing ICU device, enclosing in `&{}` is syntactic |
| | 108 | `irq`:: |
| | 109 | Is the irq number in `icudev`. |
| | 110 | |
| | 111 | == Parameter structure construction for calling `_init` functions == |
| | 112 | |
| | 113 | Some devices require a structure containing parameters in order to correctly initialize them. This case is handled in the FDT description. Let's see the example of the `soclib:xicu` component. It needs a structure containing: |
| | 114 | |
| | 115 | {{{ |
| | 116 | struct soclib_xicu_param_s |
| | 117 | { |
| | 118 | size_t output_line_no; |
| | 119 | }; |
| | 120 | }}} |
| | 121 | |
| | 122 | In the driver, the id definition is: |
| | 123 | {{{ |
| | 124 | static const struct driver_param_binder_s xicu_param_binder[] = |
| | 125 | { |
| | 126 | PARAM_BIND(struct soclib_xicu_param_s, output_line_no, PARAM_DATATYPE_INT), |
| | 127 | { 0 } |
| | 128 | }; |
| | 129 | |
| | 130 | static const struct devenum_ident_s xicu_soclib_ids[] = |
| | 131 | { |
| | 132 | DEVENUM_FDTNAME_ENTRY("soclib:xicu", sizeof(struct soclib_xicu_param_s), xicu_param_binder), |
| | 133 | { 0 } |
| | 134 | }; |
| | 135 | }}} |
| | 136 | |
| | 137 | This informs the FDT parser this device will need a parameter structure, with the parameters described in the `xicu_param_binder` correctly filled-in. |
| | 138 | |
| | 139 | In this table, there is one entry telling the `output_line_no` parameter is an integer. |
| | 140 | |
| | 141 | Available data types are: |
| | 142 | `PARAM_DATATYPE_INT`:: |
| | 143 | a simple integer |
| | 144 | `PARAM_DATATYPE_DEVICE_PTR`:: |
| | 145 | a device reference (`&{/node/path}` in the device tree source), which will be transparently translated to a `struct device_s *` before filling the structure. Device must exist in the tree. |
| | 146 | `PARAM_DATATYPE_ADDR`:: |
| | 147 | an address, `#address-cells` will be honored |
| | 148 | `PARAM_DATATYPE_BOOL`:: |
| | 149 | a simple boolean, i.e. a property with no value, if present it is true, if absent it is false (like the `cached` attribute in memory nodes) |