]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1-RevB_FreedomStudio/bsp/install/include/metal/machine.h
Rename RISC-V_RV32_SiFive_HiFive1-FreedomStudio directory to RISC-V_RV32_SiFive_HiFiv...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1-RevB_FreedomStudio / bsp / install / include / metal / machine.h
1 /* Copyright 2019 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
3 /* ----------------------------------- */
4 /* ----------------------------------- */
5
6 #ifndef ASSEMBLY
7
8 #include <metal/machine/platform.h>
9
10 #ifdef __METAL_MACHINE_MACROS
11
12 #ifndef MACROS_IF_SIFIVE_HIFIVE1_REVB____METAL_H
13 #define MACROS_IF_SIFIVE_HIFIVE1_REVB____METAL_H
14
15 #define __METAL_CLINT_NUM_PARENTS 2
16
17 #ifndef __METAL_CLINT_NUM_PARENTS
18 #define __METAL_CLINT_NUM_PARENTS 0
19 #endif
20 #define __METAL_PLIC_SUBINTERRUPTS 27
21
22 #define __METAL_PLIC_NUM_PARENTS 1
23
24 #ifndef __METAL_PLIC_SUBINTERRUPTS
25 #define __METAL_PLIC_SUBINTERRUPTS 0
26 #endif
27 #ifndef __METAL_PLIC_NUM_PARENTS
28 #define __METAL_PLIC_NUM_PARENTS 0
29 #endif
30 #ifndef __METAL_CLIC_SUBINTERRUPTS
31 #define __METAL_CLIC_SUBINTERRUPTS 0
32 #endif
33
34 #endif /* MACROS_IF_SIFIVE_HIFIVE1_REVB____METAL_H*/
35
36 #else /* ! __METAL_MACHINE_MACROS */
37
38 #ifndef MACROS_ELSE_SIFIVE_HIFIVE1_REVB____METAL_H
39 #define MACROS_ELSE_SIFIVE_HIFIVE1_REVB____METAL_H
40
41 #define __METAL_CLINT_2000000_INTERRUPTS 2
42
43 #define METAL_MAX_CLINT_INTERRUPTS 2
44
45 #define __METAL_CLINT_NUM_PARENTS 2
46
47 #define __METAL_INTERRUPT_CONTROLLER_C000000_INTERRUPTS 1
48
49 #define __METAL_PLIC_SUBINTERRUPTS 27
50
51 #define METAL_MAX_PLIC_INTERRUPTS 1
52
53 #define __METAL_PLIC_NUM_PARENTS 1
54
55 #define __METAL_CLIC_SUBINTERRUPTS 0
56 #define METAL_MAX_CLIC_INTERRUPTS 0
57
58 #define __METAL_LOCAL_EXTERNAL_INTERRUPTS_0_INTERRUPTS 16
59
60 #define METAL_MAX_LOCAL_EXT_INTERRUPTS 16
61
62 #define METAL_MAX_GLOBAL_EXT_INTERRUPTS 0
63
64 #define __METAL_GPIO_10012000_INTERRUPTS 16
65
66 #define METAL_MAX_GPIO_INTERRUPTS 16
67
68 #define __METAL_SERIAL_10013000_INTERRUPTS 1
69
70 #define METAL_MAX_UART_INTERRUPTS 1
71
72
73 #include <metal/drivers/fixed-clock.h>
74 #include <metal/memory.h>
75 #include <metal/drivers/riscv_clint0.h>
76 #include <metal/drivers/riscv_cpu.h>
77 #include <metal/drivers/riscv_plic0.h>
78 #include <metal/pmp.h>
79 #include <metal/drivers/sifive_local-external-interrupts0.h>
80 #include <metal/drivers/sifive_gpio0.h>
81 #include <metal/drivers/sifive_gpio-leds.h>
82 #include <metal/drivers/sifive_spi0.h>
83 #include <metal/drivers/sifive_uart0.h>
84 #include <metal/drivers/sifive_fe310-g000_hfrosc.h>
85 #include <metal/drivers/sifive_fe310-g000_hfxosc.h>
86 #include <metal/drivers/sifive_fe310-g000_pll.h>
87 #include <metal/drivers/sifive_fe310-g000_prci.h>
88
89 /* From clock@0 */
90 struct __metal_driver_fixed_clock __metal_dt_clock_0;
91
92 /* From clock@2 */
93 struct __metal_driver_fixed_clock __metal_dt_clock_2;
94
95 /* From clock@5 */
96 struct __metal_driver_fixed_clock __metal_dt_clock_5;
97
98 struct metal_memory __metal_dt_mem_dtim_80000000;
99
100 struct metal_memory __metal_dt_mem_spi_10014000;
101
102 /* From clint@2000000 */
103 struct __metal_driver_riscv_clint0 __metal_dt_clint_2000000;
104
105 /* From cpu@0 */
106 struct __metal_driver_cpu __metal_dt_cpu_0;
107
108 struct __metal_driver_riscv_cpu_intc __metal_dt_cpu_0_interrupt_controller;
109
110 /* From interrupt_controller@c000000 */
111 struct __metal_driver_riscv_plic0 __metal_dt_interrupt_controller_c000000;
112
113 struct metal_pmp __metal_dt_pmp;
114
115 /* From local_external_interrupts_0 */
116 struct __metal_driver_sifive_local_external_interrupts0 __metal_dt_local_external_interrupts_0;
117
118 /* From gpio@10012000 */
119 struct __metal_driver_sifive_gpio0 __metal_dt_gpio_10012000;
120
121 /* From led@0red */
122 struct __metal_driver_sifive_gpio_led __metal_dt_led_0red;
123
124 /* From led@0green */
125 struct __metal_driver_sifive_gpio_led __metal_dt_led_0green;
126
127 /* From led@0blue */
128 struct __metal_driver_sifive_gpio_led __metal_dt_led_0blue;
129
130 /* From spi@10014000 */
131 struct __metal_driver_sifive_spi0 __metal_dt_spi_10014000;
132
133 /* From serial@10013000 */
134 struct __metal_driver_sifive_uart0 __metal_dt_serial_10013000;
135
136 /* From clock@3 */
137 struct __metal_driver_sifive_fe310_g000_hfrosc __metal_dt_clock_3;
138
139 /* From clock@1 */
140 struct __metal_driver_sifive_fe310_g000_hfxosc __metal_dt_clock_1;
141
142 /* From clock@4 */
143 struct __metal_driver_sifive_fe310_g000_pll __metal_dt_clock_4;
144
145 /* From prci@10008000 */
146 struct __metal_driver_sifive_fe310_g000_prci __metal_dt_prci_10008000;
147
148
149
150 /* --------------------- fixed_clock ------------ */
151 static inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock)
152 {
153         if ((uintptr_t)clock == (uintptr_t)&__metal_dt_clock_0) {
154                 return METAL_FIXED_CLOCK_0_CLOCK_FREQUENCY;
155         }
156         else if ((uintptr_t)clock == (uintptr_t)&__metal_dt_clock_2) {
157                 return METAL_FIXED_CLOCK_2_CLOCK_FREQUENCY;
158         }
159         else if ((uintptr_t)clock == (uintptr_t)&__metal_dt_clock_5) {
160                 return METAL_FIXED_CLOCK_5_CLOCK_FREQUENCY;
161         }
162         else {
163                 return 0;
164         }
165 }
166
167
168
169 /* --------------------- fixed_factor_clock ------------ */
170
171
172 /* --------------------- sifive_clint0 ------------ */
173 static inline unsigned long __metal_driver_sifive_clint0_control_base(struct metal_interrupt *controller)
174 {
175         if ((uintptr_t)controller == (uintptr_t)&__metal_dt_clint_2000000) {
176                 return METAL_RISCV_CLINT0_2000000_BASE_ADDRESS;
177         }
178         else {
179                 return 0;
180         }
181 }
182
183 static inline unsigned long __metal_driver_sifive_clint0_control_size(struct metal_interrupt *controller)
184 {
185         if ((uintptr_t)controller == (uintptr_t)&__metal_dt_clint_2000000) {
186                 return METAL_RISCV_CLINT0_2000000_SIZE;
187         }
188         else {
189                 return 0;
190         }
191 }
192
193 static inline int __metal_driver_sifive_clint0_num_interrupts(struct metal_interrupt *controller)
194 {
195         if ((uintptr_t)controller == (uintptr_t)&__metal_dt_clint_2000000) {
196                 return METAL_MAX_CLINT_INTERRUPTS;
197         }
198         else {
199                 return 0;
200         }
201 }
202
203 static inline struct metal_interrupt * __metal_driver_sifive_clint0_interrupt_parents(struct metal_interrupt *controller, int idx)
204 {
205         if (idx == 0) {
206                 return (struct metal_interrupt *)&__metal_dt_cpu_0_interrupt_controller.controller;
207         }
208         else if (idx == 1) {
209                 return (struct metal_interrupt *)&__metal_dt_cpu_0_interrupt_controller.controller;
210         }
211         else {
212                 return NULL;
213         }
214 }
215
216 static inline int __metal_driver_sifive_clint0_interrupt_lines(struct metal_interrupt *controller, int idx)
217 {
218         if (idx == 0) {
219                 return 3;
220         }
221         else if (idx == 1) {
222                 return 7;
223         }
224         else {
225                 return 0;
226         }
227 }
228
229
230
231 /* --------------------- cpu ------------ */
232 static inline int __metal_driver_cpu_hartid(struct metal_cpu *cpu)
233 {
234         if ((uintptr_t)cpu == (uintptr_t)&__metal_dt_cpu_0) {
235                 return 0;
236         }
237         else {
238                 return -1;
239         }
240 }
241
242 static inline int __metal_driver_cpu_timebase(struct metal_cpu *cpu)
243 {
244         if ((uintptr_t)cpu == (uintptr_t)&__metal_dt_cpu_0) {
245                 return 1000000;
246         }
247         else {
248                 return 0;
249         }
250 }
251
252 static inline struct metal_interrupt * __metal_driver_cpu_interrupt_controller(struct metal_cpu *cpu)
253 {
254         if ((uintptr_t)cpu == (uintptr_t)&__metal_dt_cpu_0) {
255                 return &__metal_dt_cpu_0_interrupt_controller.controller;
256         }
257         else {
258                 return NULL;
259         }
260 }
261
262 static inline int __metal_driver_cpu_num_pmp_regions(struct metal_cpu *cpu)
263 {
264         if ((uintptr_t)cpu == (uintptr_t)&__metal_dt_cpu_0) {
265                 return 8;
266         }
267         else {
268                 return 0;
269         }
270 }
271
272
273
274 /* --------------------- sifive_plic0 ------------ */
275 static inline unsigned long __metal_driver_sifive_plic0_control_base(struct metal_interrupt *controller)
276 {
277         if ((uintptr_t)controller == (uintptr_t)&__metal_dt_interrupt_controller_c000000) {
278                 return METAL_RISCV_PLIC0_C000000_BASE_ADDRESS;
279         }
280         else {
281                 return 0;
282         }
283 }
284
285 static inline unsigned long __metal_driver_sifive_plic0_control_size(struct metal_interrupt *controller)
286 {
287         if ((uintptr_t)controller == (uintptr_t)&__metal_dt_interrupt_controller_c000000) {
288                 return METAL_RISCV_PLIC0_C000000_SIZE;
289         }
290         else {
291                 return 0;
292         }
293 }
294
295 static inline int __metal_driver_sifive_plic0_num_interrupts(struct metal_interrupt *controller)
296 {
297         if ((uintptr_t)controller == (uintptr_t)&__metal_dt_interrupt_controller_c000000) {
298                 return METAL_RISCV_PLIC0_C000000_RISCV_NDEV;
299         }
300         else {
301                 return 0;
302         }
303 }
304
305 static inline int __metal_driver_sifive_plic0_max_priority(struct metal_interrupt *controller)
306 {
307         if ((uintptr_t)controller == (uintptr_t)&__metal_dt_interrupt_controller_c000000) {
308                 return METAL_RISCV_PLIC0_C000000_RISCV_MAX_PRIORITY;
309         }
310         else {
311                 return 0;
312         }
313 }
314
315 static inline struct metal_interrupt * __metal_driver_sifive_plic0_interrupt_parents(struct metal_interrupt *controller, int idx)
316 {
317         if (idx == 0) {
318                 return (struct metal_interrupt *)&__metal_dt_cpu_0_interrupt_controller.controller;
319         }
320         else if (idx == 0) {
321                 return (struct metal_interrupt *)&__metal_dt_cpu_0_interrupt_controller.controller;
322         }
323         else {
324                 return NULL;
325         }
326 }
327
328 static inline int __metal_driver_sifive_plic0_interrupt_lines(struct metal_interrupt *controller, int idx)
329 {
330         if (idx == 0) {
331                 return 11;
332         }
333         else if (idx == 0) {
334                 return 11;
335         }
336         else {
337                 return 0;
338         }
339 }
340
341
342
343 /* --------------------- sifive_clic0 ------------ */
344
345
346 /* --------------------- sifive_local_external_interrupts0 ------------ */
347 static inline struct metal_interrupt * __metal_driver_sifive_local_external_interrupts0_interrupt_parent(struct metal_interrupt *controller)
348 {
349         if ((uintptr_t)controller == (uintptr_t)&__metal_dt_local_external_interrupts_0) {
350                 return (struct metal_interrupt *)&__metal_dt_cpu_0_interrupt_controller.controller;
351         }
352         else {
353                 return NULL;
354         }
355 }
356
357 static inline int __metal_driver_sifive_local_external_interrupts0_num_interrupts(struct metal_interrupt *controller)
358 {
359         if ((uintptr_t)controller == (uintptr_t)&__metal_dt_local_external_interrupts_0) {
360                 return METAL_MAX_LOCAL_EXT_INTERRUPTS;
361         }
362         else {
363                 return 0;
364         }
365 }
366
367 static inline int __metal_driver_sifive_local_external_interrupts0_interrupt_lines(struct metal_interrupt *controller, int idx)
368 {
369         if (idx == 0) {
370                 return 16;
371         }
372         else if (idx == 1) {
373                 return 17;
374         }
375         else if (idx == 2) {
376                 return 18;
377         }
378         else if (idx == 3) {
379                 return 19;
380         }
381         else if (idx == 4) {
382                 return 20;
383         }
384         else if (idx == 5) {
385                 return 21;
386         }
387         else if (idx == 6) {
388                 return 22;
389         }
390         else if (idx == 7) {
391                 return 23;
392         }
393         else if (idx == 8) {
394                 return 24;
395         }
396         else if (idx == 9) {
397                 return 25;
398         }
399         else if (idx == 10) {
400                 return 26;
401         }
402         else if (idx == 11) {
403                 return 27;
404         }
405         else if (idx == 12) {
406                 return 28;
407         }
408         else if (idx == 13) {
409                 return 29;
410         }
411         else if (idx == 14) {
412                 return 30;
413         }
414         else if (idx == 15) {
415                 return 31;
416         }
417         else {
418                 return 0;
419         }
420 }
421
422
423
424 /* --------------------- sifive_global_external_interrupts0 ------------ */
425
426
427 /* --------------------- sifive_gpio0 ------------ */
428 static inline unsigned long __metal_driver_sifive_gpio0_base(struct metal_gpio *gpio)
429 {
430         if ((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) {
431                 return METAL_SIFIVE_GPIO0_10012000_BASE_ADDRESS;
432         }
433         else {
434                 return 0;
435         }
436 }
437
438 static inline unsigned long __metal_driver_sifive_gpio0_size(struct metal_gpio *gpio)
439 {
440         if ((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) {
441                 return METAL_SIFIVE_GPIO0_10012000_SIZE;
442         }
443         else {
444                 return 0;
445         }
446 }
447
448 static inline int __metal_driver_sifive_gpio0_num_interrupts(struct metal_gpio *gpio)
449 {
450         if ((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) {
451                 return METAL_MAX_GPIO_INTERRUPTS;
452         }
453         else {
454                 return 0;
455         }
456 }
457
458 static inline struct metal_interrupt * __metal_driver_sifive_gpio0_interrupt_parent(struct metal_gpio *gpio)
459 {
460         if ((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) {
461                 return (struct metal_interrupt *)&__metal_dt_interrupt_controller_c000000.controller;
462         }
463         else {
464                 return 0;
465         }
466 }
467
468 static inline int __metal_driver_sifive_gpio0_interrupt_lines(struct metal_gpio *gpio, int idx)
469 {
470         if (((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 0)) {
471                 return 7;
472         }
473         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 1))) {
474                 return 8;
475         }
476         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 2))) {
477                 return 9;
478         }
479         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 3))) {
480                 return 10;
481         }
482         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 4))) {
483                 return 11;
484         }
485         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 5))) {
486                 return 12;
487         }
488         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 6))) {
489                 return 13;
490         }
491         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 7))) {
492                 return 14;
493         }
494         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 8))) {
495                 return 15;
496         }
497         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 9))) {
498                 return 16;
499         }
500         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 10))) {
501                 return 17;
502         }
503         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 11))) {
504                 return 18;
505         }
506         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 12))) {
507                 return 19;
508         }
509         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 13))) {
510                 return 20;
511         }
512         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 14))) {
513                 return 21;
514         }
515         else if ((((uintptr_t)gpio == (uintptr_t)&__metal_dt_gpio_10012000) && (idx == 15))) {
516                 return 22;
517         }
518         else {
519                 return 0;
520         }
521 }
522
523
524
525 /* --------------------- sifive_gpio_button ------------ */
526
527
528 /* --------------------- sifive_gpio_led ------------ */
529 static inline struct metal_gpio * __metal_driver_sifive_gpio_led_gpio(struct metal_led *led)
530 {
531         if ((uintptr_t)led == (uintptr_t)&__metal_dt_led_0red) {
532                 return (struct metal_gpio *)&__metal_dt_gpio_10012000;
533         }
534         else if ((uintptr_t)led == (uintptr_t)&__metal_dt_led_0green) {
535                 return (struct metal_gpio *)&__metal_dt_gpio_10012000;
536         }
537         else if ((uintptr_t)led == (uintptr_t)&__metal_dt_led_0blue) {
538                 return (struct metal_gpio *)&__metal_dt_gpio_10012000;
539         }
540         else {
541                 return NULL;
542         }
543 }
544
545 static inline int __metal_driver_sifive_gpio_led_pin(struct metal_led *led)
546 {
547         if ((uintptr_t)led == (uintptr_t)&__metal_dt_led_0red) {
548                 return 22;
549         }
550         else if ((uintptr_t)led == (uintptr_t)&__metal_dt_led_0green) {
551                 return 19;
552         }
553         else if ((uintptr_t)led == (uintptr_t)&__metal_dt_led_0blue) {
554                 return 21;
555         }
556         else {
557                 return 0;
558         }
559 }
560
561 static inline char * __metal_driver_sifive_gpio_led_label(struct metal_led *led)
562 {
563         if ((uintptr_t)led == (uintptr_t)&__metal_dt_led_0red) {
564                 return "LD0red";
565         }
566         else if ((uintptr_t)led == (uintptr_t)&__metal_dt_led_0green) {
567                 return "LD0green";
568         }
569         else if ((uintptr_t)led == (uintptr_t)&__metal_dt_led_0blue) {
570                 return "LD0blue";
571         }
572         else {
573                 return "";
574         }
575 }
576
577
578
579 /* --------------------- sifive_gpio_switch ------------ */
580
581
582 /* --------------------- sifive_spi0 ------------ */
583 static inline unsigned long __metal_driver_sifive_spi0_control_base(struct metal_spi *spi)
584 {
585         if ((uintptr_t)spi == (uintptr_t)&__metal_dt_spi_10014000) {
586                 return METAL_SIFIVE_SPI0_10014000_BASE_ADDRESS;
587         }
588         else {
589                 return 0;
590         }
591 }
592
593 static inline unsigned long __metal_driver_sifive_spi0_control_size(struct metal_spi *spi)
594 {
595         if ((uintptr_t)spi == (uintptr_t)&__metal_dt_spi_10014000) {
596                 return METAL_SIFIVE_SPI0_10014000_SIZE;
597         }
598         else {
599                 return 0;
600         }
601 }
602
603 static inline struct metal_clock * __metal_driver_sifive_spi0_clock(struct metal_spi *spi)
604 {
605                 return (struct metal_clock *)&__metal_dt_clock_4.clock;
606 }
607
608 static inline struct __metal_driver_sifive_gpio0 * __metal_driver_sifive_spi0_pinmux(struct metal_spi *spi)
609 {
610                 return (struct __metal_driver_sifive_gpio0 *)&__metal_dt_gpio_10012000;
611 }
612
613 static inline unsigned long __metal_driver_sifive_spi0_pinmux_output_selector(struct metal_spi *spi)
614 {
615                 return 60;
616 }
617
618 static inline unsigned long __metal_driver_sifive_spi0_pinmux_source_selector(struct metal_spi *spi)
619 {
620                 return 60;
621 }
622
623
624
625 /* --------------------- sifive_test0 ------------ */
626
627
628 /* --------------------- sifive_uart0 ------------ */
629 static inline unsigned long __metal_driver_sifive_uart0_control_base(struct metal_uart *uart)
630 {
631         if ((uintptr_t)uart == (uintptr_t)&__metal_dt_serial_10013000) {
632                 return METAL_SIFIVE_UART0_10013000_BASE_ADDRESS;
633         }
634         else {
635                 return 0;
636         }
637 }
638
639 static inline unsigned long __metal_driver_sifive_uart0_control_size(struct metal_uart *uart)
640 {
641         if ((uintptr_t)uart == (uintptr_t)&__metal_dt_serial_10013000) {
642                 return METAL_SIFIVE_UART0_10013000_SIZE;
643         }
644         else {
645                 return 0;
646         }
647 }
648
649 static inline int __metal_driver_sifive_uart0_num_interrupts(struct metal_uart *uart)
650 {
651         if ((uintptr_t)uart == (uintptr_t)&__metal_dt_serial_10013000) {
652                 return METAL_MAX_UART_INTERRUPTS;
653         }
654         else {
655                 return 0;
656         }
657 }
658
659 static inline struct metal_interrupt * __metal_driver_sifive_uart0_interrupt_parent(struct metal_uart *uart)
660 {
661         if ((uintptr_t)uart == (uintptr_t)&__metal_dt_serial_10013000) {
662                 return (struct metal_interrupt *)&__metal_dt_interrupt_controller_c000000.controller;
663         }
664         else {
665                 return NULL;
666         }
667 }
668
669 static inline int __metal_driver_sifive_uart0_interrupt_line(struct metal_uart *uart)
670 {
671                 return 5;
672 }
673
674 static inline struct metal_clock * __metal_driver_sifive_uart0_clock(struct metal_uart *uart)
675 {
676                 return (struct metal_clock *)&__metal_dt_clock_4.clock;
677 }
678
679 static inline struct __metal_driver_sifive_gpio0 * __metal_driver_sifive_uart0_pinmux(struct metal_uart *uart)
680 {
681                 return (struct __metal_driver_sifive_gpio0 *)&__metal_dt_gpio_10012000;
682 }
683
684 static inline unsigned long __metal_driver_sifive_uart0_pinmux_output_selector(struct metal_uart *uart)
685 {
686                 return 196608;
687 }
688
689 static inline unsigned long __metal_driver_sifive_uart0_pinmux_source_selector(struct metal_uart *uart)
690 {
691                 return 196608;
692 }
693
694
695
696 /* --------------------- sifive_fe310_g000_hfrosc ------------ */
697 static inline struct metal_clock * __metal_driver_sifive_fe310_g000_hfrosc_ref(const struct metal_clock *clock)
698 {
699                 return (struct metal_clock *)&__metal_dt_clock_2.clock;
700 }
701
702 static inline struct __metal_driver_sifive_fe310_g000_prci * __metal_driver_sifive_fe310_g000_hfrosc_config_base(const struct metal_clock *clock)
703 {
704                 return (struct __metal_driver_sifive_fe310_g000_prci *)&__metal_dt_prci_10008000;
705 }
706
707 static inline const struct __metal_driver_vtable_sifive_fe310_g000_prci * __metal_driver_sifive_fe310_g000_hfrosc_config_vtable(struct metal_clock *clock)
708 {
709                 return &__metal_driver_vtable_sifive_fe310_g000_prci;
710 }
711
712 static inline long __metal_driver_sifive_fe310_g000_hfrosc_config_offset(const struct metal_clock *clock)
713 {
714                 return METAL_SIFIVE_FE310_G000_PRCI_HFROSCCFG;
715 }
716
717
718
719 /* --------------------- sifive_fe310_g000_hfxosc ------------ */
720 static inline struct metal_clock * __metal_driver_sifive_fe310_g000_hfxosc_ref(const struct metal_clock *clock)
721 {
722                 return (struct metal_clock *)&__metal_dt_clock_0.clock;
723 }
724
725 static inline struct __metal_driver_sifive_fe310_g000_prci * __metal_driver_sifive_fe310_g000_hfxosc_config_base(const struct metal_clock *clock)
726 {
727                 return (struct __metal_driver_sifive_fe310_g000_prci *)&__metal_dt_prci_10008000;
728 }
729
730 static inline long __metal_driver_sifive_fe310_g000_hfxosc_config_offset(const struct metal_clock *clock)
731 {
732                 return METAL_SIFIVE_FE310_G000_PRCI_HFXOSCCFG;
733 }
734
735
736
737 /* --------------------- sifive_fe310_g000_pll ------------ */
738 static inline struct metal_clock * __metal_driver_sifive_fe310_g000_pll_pllsel0(const struct metal_clock *clock)
739 {
740                 return (struct metal_clock *)&__metal_dt_clock_3.clock;
741 }
742
743 static inline struct metal_clock * __metal_driver_sifive_fe310_g000_pll_pllref(const struct metal_clock *clock)
744 {
745                 return (struct metal_clock *)&__metal_dt_clock_1.clock;
746 }
747
748 static inline struct __metal_driver_sifive_fe310_g000_prci * __metal_driver_sifive_fe310_g000_pll_divider_base(const struct metal_clock *clock)
749 {
750                 return (struct __metal_driver_sifive_fe310_g000_prci *)&__metal_dt_prci_10008000;
751 }
752
753 static inline long __metal_driver_sifive_fe310_g000_pll_divider_offset(const struct metal_clock *clock)
754 {
755                 return METAL_SIFIVE_FE310_G000_PRCI_PLLOUTDIV;
756 }
757
758 static inline struct __metal_driver_sifive_fe310_g000_prci * __metal_driver_sifive_fe310_g000_pll_config_base( )
759 {
760                 return (struct __metal_driver_sifive_fe310_g000_prci *)&__metal_dt_prci_10008000;
761 }
762
763 static inline long __metal_driver_sifive_fe310_g000_pll_config_offset( )
764 {
765                 return METAL_SIFIVE_FE310_G000_PRCI_PLLCFG;
766 }
767
768 static inline long __metal_driver_sifive_fe310_g000_pll_init_rate( )
769 {
770                 return 16000000;
771 }
772
773
774
775 /* --------------------- sifive_fe310_g000_prci ------------ */
776 static inline long __metal_driver_sifive_fe310_g000_prci_base( )
777 {
778                 return METAL_SIFIVE_FE310_G000_PRCI_10008000_BASE_ADDRESS;
779 }
780
781 static inline long __metal_driver_sifive_fe310_g000_prci_size( )
782 {
783                 return METAL_SIFIVE_FE310_G000_PRCI_10008000_SIZE;
784 }
785
786 static inline const struct __metal_driver_vtable_sifive_fe310_g000_prci * __metal_driver_sifive_fe310_g000_prci_vtable( )
787 {
788                 return &__metal_driver_vtable_sifive_fe310_g000_prci;
789 }
790
791
792
793 /* --------------------- sifive_fu540_c000_l2 ------------ */
794
795
796 #define __METAL_DT_MAX_MEMORIES 2
797
798 asm (".weak __metal_memory_table");
799 struct metal_memory *__metal_memory_table[] = {
800                                         &__metal_dt_mem_dtim_80000000,
801                                         &__metal_dt_mem_spi_10014000};
802
803 /* From serial@10013000 */
804 #define __METAL_DT_STDOUT_UART_HANDLE (&__metal_dt_serial_10013000.uart)
805
806 #define __METAL_DT_SERIAL_10013000_HANDLE (&__metal_dt_serial_10013000.uart)
807
808 #define __METAL_DT_STDOUT_UART_BAUD 115200
809
810 /* From clint@2000000 */
811 #define __METAL_DT_RISCV_CLINT0_HANDLE (&__metal_dt_clint_2000000.controller)
812
813 #define __METAL_DT_CLINT_2000000_HANDLE (&__metal_dt_clint_2000000.controller)
814
815 #define __METAL_DT_MAX_HARTS 1
816
817 asm (".weak __metal_cpu_table");
818 struct __metal_driver_cpu *__metal_cpu_table[] = {
819                                         &__metal_dt_cpu_0};
820
821 /* From interrupt_controller@c000000 */
822 #define __METAL_DT_RISCV_PLIC0_HANDLE (&__metal_dt_interrupt_controller_c000000.controller)
823
824 #define __METAL_DT_INTERRUPT_CONTROLLER_C000000_HANDLE (&__metal_dt_interrupt_controller_c000000.controller)
825
826 #define __METAL_DT_PMP_HANDLE (&__metal_dt_pmp)
827
828 /* From local_external_interrupts_0 */
829 #define __METAL_DT_SIFIVE_LOCAL_EXINTR0_HANDLE (&__metal_dt_local_external_interrupts_0.irc)
830
831 #define __METAL_DT_LOCAL_EXTERNAL_INTERRUPTS_0_HANDLE (&__metal_dt_local_external_interrupts_0.irc)
832
833 #define __MEE_DT_MAX_GPIOS 1
834
835 asm (".weak __metal_gpio_table");
836 struct __metal_driver_sifive_gpio0 *__metal_gpio_table[] = {
837                                         &__metal_dt_gpio_10012000};
838
839 #define __METAL_DT_MAX_BUTTONS 0
840
841 asm (".weak __metal_button_table");
842 struct __metal_driver_sifive_gpio_button *__metal_button_table[] = {
843                                         NULL };
844 #define __METAL_DT_MAX_LEDS 3
845
846 asm (".weak __metal_led_table");
847 struct __metal_driver_sifive_gpio_led *__metal_led_table[] = {
848                                         &__metal_dt_led_0red,
849                                         &__metal_dt_led_0green,
850                                         &__metal_dt_led_0blue};
851
852 #define __METAL_DT_MAX_SWITCHES 0
853
854 asm (".weak __metal_switch_table");
855 struct __metal_driver_sifive_gpio_switch *__metal_switch_table[] = {
856                                         NULL };
857 #define __METAL_DT_MAX_SPIS 1
858
859 asm (".weak __metal_spi_table");
860 struct __metal_driver_sifive_spi0 *__metal_spi_table[] = {
861                                         &__metal_dt_spi_10014000};
862
863 /* From clock@4 */
864 #define __METAL_DT_SIFIVE_FE310_G000_PLL_HANDLE (&__metal_dt_clock_4)
865
866 #define __METAL_DT_CLOCK_4_HANDLE (&__metal_dt_clock_4)
867
868 #endif /* MACROS_ELSE_SIFIVE_HIFIVE1_REVB____METAL_H*/
869
870 #endif /* ! __METAL_MACHINE_MACROS */
871
872 #endif /* ! ASSEMBLY */