xref: /freebsd/sys/dev/uart/uart_cpu_fdt.h (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1 /*-
2  * Copyright 2015 Michal Meloun
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 
27 #ifndef _DEV_UART_CPU_FDT_H_
28 #define _DEV_UART_CPU_FDT_H_
29 
30 #include <sys/linker_set.h>
31 
32 #include <dev/ofw/ofw_bus_subr.h>
33 
34 /*
35  * If your UART driver implements only uart_class and uses uart_cpu_fdt.c
36  * for device instantiation, then use UART_FDT_CLASS_AND_DEVICE for its
37  * declaration
38  */
39 SET_DECLARE(uart_fdt_class_and_device_set, struct ofw_compat_data );
40 #define UART_FDT_CLASS_AND_DEVICE(data)				\
41 	DATA_SET(uart_fdt_class_and_device_set, data)
42 
43 /*
44  * If your UART driver implements uart_class and custom device layer,
45  * then use UART_FDT_CLASS for its declaration
46  */
47 SET_DECLARE(uart_fdt_class_set, struct ofw_compat_data );
48 #define UART_FDT_CLASS(data)				\
49 	DATA_SET(uart_fdt_class_set, data)
50 
51 int uart_cpu_fdt_probe(struct uart_class **, bus_space_tag_t *,
52     bus_space_handle_t *, int *, u_int *, u_int *, u_int *, const int);
53 int uart_fdt_get_clock(phandle_t node, pcell_t *cell);
54 int uart_fdt_get_shift(phandle_t node, pcell_t *cell);
55 int uart_fdt_get_io_width(phandle_t node, pcell_t *cell);
56 
57 #endif /* _DEV_UART_CPU_FDT_H_ */
58