25 | | |
26 | | Drivers may export themselves as FDT-aware, and define which device name string to match. For instance, the following subtree defines a tty device: |
27 | | |
28 | | {{{ |
29 | | tty@0 { |
30 | | device_type = "soclib:tty"; |
31 | | tty_count = <1>; |
32 | | reg = <0x90600000 0x10>; |
33 | | icudev = &{/icu@0}; |
34 | | irq = <1>; |
35 | | }; |
36 | | }}} |
37 | | |
38 | | In turn, the SoCLib tty driver declares itself (in source:trunk/mutekh/drivers/device/char/tty-soclib/tty-soclib.c#L146) as: |
39 | | |
40 | | {{{ |
41 | | static const struct devenum_ident_s tty_soclib_ids[] = |
42 | | { |
43 | | DEVENUM_FDTNAME_ENTRY("soclib:tty", 0, 0), |
44 | | { 0 } |
45 | | }; |
46 | | |
47 | | const struct driver_s tty_soclib_drv = |
48 | | { |
49 | | .class = device_class_char, |
50 | | .id_table = tty_soclib_ids, |
51 | | .f_init = tty_soclib_init, |
52 | | .f_cleanup = tty_soclib_cleanup, |
53 | | .f_irq = tty_soclib_irq, |
54 | | .f.chr = { |
55 | | .f_request = tty_soclib_request, |
56 | | } |
57 | | }; |
58 | | }}} |
59 | | |
60 | | This will make the FDT enumerator use the correct driver, matching `"soclib:tty"` |
| 114 | |
| 115 | = Example = |
| 116 | |
| 117 | Drivers may export themselves as FDT-aware, and define which device name string to match. For instance, the following subtree defines a tty device: |
| 118 | |
| 119 | {{{ |
| 120 | tty@0 { |
| 121 | device_type = "soclib:tty"; |
| 122 | tty_count = <1>; |
| 123 | reg = <0x90600000 0x10>; |
| 124 | icudev = &{/icu@0}; |
| 125 | irq = <1>; |
| 126 | }; |
| 127 | }}} |
| 128 | |
| 129 | In turn, the SoCLib tty driver declares itself (in source:trunk/mutekh/drivers/device/char/tty-soclib/tty-soclib.c#L146) as: |
| 130 | |
| 131 | {{{ |
| 132 | static const struct devenum_ident_s tty_soclib_ids[] = |
| 133 | { |
| 134 | DEVENUM_FDTNAME_ENTRY("soclib:tty", 0, 0), |
| 135 | { 0 } |
| 136 | }; |
| 137 | |
| 138 | const struct driver_s tty_soclib_drv = |
| 139 | { |
| 140 | .class = device_class_char, |
| 141 | .id_table = tty_soclib_ids, |
| 142 | .f_init = tty_soclib_init, |
| 143 | .f_cleanup = tty_soclib_cleanup, |
| 144 | .f_irq = tty_soclib_irq, |
| 145 | .f.chr = { |
| 146 | .f_request = tty_soclib_request, |
| 147 | } |
| 148 | }; |
| 149 | }}} |
| 150 | |
| 151 | This will make the FDT enumerator use the correct driver, matching `"soclib:tty"` |