uart_bus_ar71xx.c (191840) | uart_bus_ar71xx.c (192656) |
---|---|
1/*- 2 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 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 --- 53 unchanged lines hidden (view full) --- 62}; 63 64extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; 65 66static int 67uart_ar71xx_probe(device_t dev) 68{ 69 struct uart_softc *sc; | 1/*- 2 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 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 --- 53 unchanged lines hidden (view full) --- 62}; 63 64extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; 65 66static int 67uart_ar71xx_probe(device_t dev) 68{ 69 struct uart_softc *sc; |
70 uint32_t pll_config, div; 71 uint64_t freq; |
|
70 | 72 |
73 /* PLL freq */ 74 pll_config = ATH_READ_REG(AR71XX_PLL_CPU_CONFIG); 75 div = ((pll_config >> PLL_FB_SHIFT) & PLL_FB_MASK) + 1; 76 freq = div * AR71XX_BASE_FREQ; 77 /* CPU freq */ 78 div = ((pll_config >> PLL_CPU_DIV_SEL_SHIFT) & PLL_CPU_DIV_SEL_MASK) 79 + 1; 80 freq = freq / div; 81 /* AHB freq */ 82 div = (((pll_config >> PLL_AHB_DIV_SHIFT) & PLL_AHB_DIV_MASK) + 1) * 2; 83 freq = freq / div; 84 |
|
71 sc = device_get_softc(dev); 72 sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); 73 sc->sc_class = &uart_ns8250_class; 74 bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); 75 sc->sc_sysdev->bas.regshft = 2; 76 sc->sc_sysdev->bas.bst = mips_bus_space_generic; 77 sc->sc_sysdev->bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR) + 3; 78 sc->sc_bas.regshft = 2; 79 sc->sc_bas.bst = mips_bus_space_generic; 80 sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR) + 3; 81 | 85 sc = device_get_softc(dev); 86 sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); 87 sc->sc_class = &uart_ns8250_class; 88 bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); 89 sc->sc_sysdev->bas.regshft = 2; 90 sc->sc_sysdev->bas.bst = mips_bus_space_generic; 91 sc->sc_sysdev->bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR) + 3; 92 sc->sc_bas.regshft = 2; 93 sc->sc_bas.bst = mips_bus_space_generic; 94 sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR) + 3; 95 |
82 return (uart_bus_probe(dev, 2, 85000000, 0, 0)); | 96 return (uart_bus_probe(dev, 2, freq, 0, 0)); |
83} 84 85DRIVER_MODULE(uart, apb, uart_ar71xx_driver, uart_devclass, 0, 0); | 97} 98 99DRIVER_MODULE(uart, apb, uart_ar71xx_driver, uart_devclass, 0, 0); |