uart_bus_fdt.c (281204) | uart_bus_fdt.c (281438) |
---|---|
1/*- 2 * Copyright (c) 2009-2010 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Semihalf under sponsorship from 6 * the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009-2010 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Semihalf under sponsorship from 6 * the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/uart/uart_bus_fdt.c 281204 2015-04-07 15:12:03Z andrew $"); | 31__FBSDID("$FreeBSD: head/sys/dev/uart/uart_bus_fdt.c 281438 2015-04-11 17:16:23Z andrew $"); |
32 33#include "opt_platform.h" 34 35#include <sys/param.h> 36#include <sys/bus.h> 37#include <sys/kernel.h> 38#include <sys/module.h> 39 --- 38 unchanged lines hidden (view full) --- 78 } 79 80 return (0); 81} 82 83int 84uart_fdt_get_shift(phandle_t node, pcell_t *cell) 85{ | 32 33#include "opt_platform.h" 34 35#include <sys/param.h> 36#include <sys/bus.h> 37#include <sys/kernel.h> 38#include <sys/module.h> 39 --- 38 unchanged lines hidden (view full) --- 78 } 79 80 return (0); 81} 82 83int 84uart_fdt_get_shift(phandle_t node, pcell_t *cell) 85{ |
86#ifdef __aarch64__ 87#define DEFAULT_SHIFT 2 88#else 89#define DEFAULT_SHIFT 0 90#endif | |
91 92 if ((OF_getencprop(node, "reg-shift", cell, sizeof(*cell))) <= 0) | 86 87 if ((OF_getencprop(node, "reg-shift", cell, sizeof(*cell))) <= 0) |
93 *cell = DEFAULT_SHIFT; | 88 return (-1); |
94 return (0); | 89 return (0); |
95#undef DEFAULT_SHIFT | |
96} 97 98static uintptr_t 99uart_fdt_find_device(device_t dev) 100{ 101 struct ofw_compat_data **cd; 102 const struct ofw_compat_data *ocd; 103 --- 21 unchanged lines hidden (view full) --- 125 sc->sc_class = (struct uart_class *)uart_fdt_find_device(dev); 126 if (sc->sc_class == NULL) 127 return (ENXIO); 128 129 node = ofw_bus_get_node(dev); 130 131 if ((err = uart_fdt_get_clock(node, &clock)) != 0) 132 return (err); | 90} 91 92static uintptr_t 93uart_fdt_find_device(device_t dev) 94{ 95 struct ofw_compat_data **cd; 96 const struct ofw_compat_data *ocd; 97 --- 21 unchanged lines hidden (view full) --- 119 sc->sc_class = (struct uart_class *)uart_fdt_find_device(dev); 120 if (sc->sc_class == NULL) 121 return (ENXIO); 122 123 node = ofw_bus_get_node(dev); 124 125 if ((err = uart_fdt_get_clock(node, &clock)) != 0) 126 return (err); |
133 uart_fdt_get_shift(node, &shift); | 127 if (uart_fdt_get_shift(node, &shift) != 0) 128 shift = uart_getregshift(sc->sc_class); |
134 135 return (uart_bus_probe(dev, (int)shift, (int)clock, 0, 0)); 136} 137 138DRIVER_MODULE(uart, simplebus, uart_fdt_driver, uart_devclass, 0, 0); 139DRIVER_MODULE(uart, ofwbus, uart_fdt_driver, uart_devclass, 0, 0); | 129 130 return (uart_bus_probe(dev, (int)shift, (int)clock, 0, 0)); 131} 132 133DRIVER_MODULE(uart, simplebus, uart_fdt_driver, uart_devclass, 0, 0); 134DRIVER_MODULE(uart, ofwbus, uart_fdt_driver, uart_devclass, 0, 0); |