at91sam9260.c (238390) | at91sam9260.c (238397) |
---|---|
1/*- 2 * Copyright (c) 2005 Olivier Houchard. All rights reserved. 3 * Copyright (c) 2010 Greg Ansley. 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 --- 11 unchanged lines hidden (view full) --- 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#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2005 Olivier Houchard. All rights reserved. 3 * Copyright (c) 2010 Greg Ansley. 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 --- 11 unchanged lines hidden (view full) --- 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#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/arm/at91/at91sam9260.c 238390 2012-07-12 04:23:11Z imp $"); | 28__FBSDID("$FreeBSD: head/sys/arm/at91/at91sam9260.c 238397 2012-07-12 13:45:58Z imp $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/kernel.h> 34#include <sys/malloc.h> 35#include <sys/module.h> 36 --- 5 unchanged lines hidden (view full) --- 42#include <arm/at91/at91soc.h> 43#include <arm/at91/at91_aicreg.h> 44#include <arm/at91/at91sam9260reg.h> 45#include <arm/at91/at91_pitreg.h> 46#include <arm/at91/at91_pmcreg.h> 47#include <arm/at91/at91_pmcvar.h> 48#include <arm/at91/at91_rstreg.h> 49 | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/kernel.h> 34#include <sys/malloc.h> 35#include <sys/module.h> 36 --- 5 unchanged lines hidden (view full) --- 42#include <arm/at91/at91soc.h> 43#include <arm/at91/at91_aicreg.h> 44#include <arm/at91/at91sam9260reg.h> 45#include <arm/at91/at91_pitreg.h> 46#include <arm/at91/at91_pmcreg.h> 47#include <arm/at91/at91_pmcvar.h> 48#include <arm/at91/at91_rstreg.h> 49 |
50struct at91sam9_softc { 51 bus_space_tag_t sc_st; 52 bus_space_handle_t sc_sh; 53 bus_space_handle_t sc_matrix_sh; 54}; 55 | |
56/* 57 * Standard priority levels for the system. 0 is lowest and 7 is highest. 58 * These values are the ones Atmel uses for its Linux port 59 */ 60static const int at91_irq_prio[32] = 61{ 62 7, /* Advanced Interrupt Controller */ 63 7, /* System Peripherals */ --- 77 unchanged lines hidden (view full) --- 141static uint32_t 142at91_pll_outb(int freq) 143{ 144 145 return (0x4000); 146} 147 148static void | 50/* 51 * Standard priority levels for the system. 0 is lowest and 7 is highest. 52 * These values are the ones Atmel uses for its Linux port 53 */ 54static const int at91_irq_prio[32] = 55{ 56 7, /* Advanced Interrupt Controller */ 57 7, /* System Peripherals */ --- 77 unchanged lines hidden (view full) --- 135static uint32_t 136at91_pll_outb(int freq) 137{ 138 139 return (0x4000); 140} 141 142static void |
149at91_identify(driver_t *drv, device_t parent) | 143at91_clock_init(void) |
150{ | 144{ |
151 152 if (soc_info.type == AT91_T_SAM9260) 153 at91_add_child(parent, 0, "at91sam9260", 0, 0, 0, -1, 0, 0); 154} 155 156static int 157at91_probe(device_t dev) 158{ 159 160 device_set_desc(dev, soc_info.name); 161 return (0); 162} 163 164static int 165at91_attach(device_t dev) 166{ | |
167 struct at91_pmc_clock *clk; | 145 struct at91_pmc_clock *clk; |
168 struct at91sam9_softc *sc = device_get_softc(dev); 169 struct at91_softc *at91sc = device_get_softc(device_get_parent(dev)); 170 uint32_t i; | |
171 | 146 |
172 sc->sc_st = at91sc->sc_st; 173 sc->sc_sh = at91sc->sc_sh; 174 175 if (bus_space_subregion(sc->sc_st, sc->sc_sh, 176 AT91SAM9260_MATRIX_BASE, AT91SAM9260_MATRIX_SIZE, 177 &sc->sc_matrix_sh) != 0) 178 panic("Enable to map matrix registers"); 179 180 /* activate NAND */ 181 i = bus_space_read_4(sc->sc_st, sc->sc_matrix_sh, 182 AT91SAM9260_EBICSA); 183 bus_space_write_4(sc->sc_st, sc->sc_matrix_sh, 184 AT91SAM9260_EBICSA, 185 i | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA); 186 | |
187 /* Update USB device port clock info */ 188 clk = at91_pmc_clock_ref("udpck"); 189 clk->pmc_mask = PMC_SCER_UDP_SAM9; 190 at91_pmc_clock_deref(clk); 191 192 /* Update USB host port clock info */ 193 clk = at91_pmc_clock_ref("uhpck"); 194 clk->pmc_mask = PMC_SCER_UHP_SAM9; --- 27 unchanged lines hidden (view full) --- 222 clk->pll_min_out = SAM9260_PLL_B_MIN_OUT_FREQ; /* 70 MHz */ 223 clk->pll_max_out = SAM9260_PLL_B_MAX_OUT_FREQ; /* 130 MHz */ 224 clk->pll_mul_shift = SAM9260_PLL_B_MUL_SHIFT; 225 clk->pll_mul_mask = SAM9260_PLL_B_MUL_MASK; 226 clk->pll_div_shift = SAM9260_PLL_B_DIV_SHIFT; 227 clk->pll_div_mask = SAM9260_PLL_B_DIV_MASK; 228 clk->set_outb = at91_pll_outb; 229 at91_pmc_clock_deref(clk); | 147 /* Update USB device port clock info */ 148 clk = at91_pmc_clock_ref("udpck"); 149 clk->pmc_mask = PMC_SCER_UDP_SAM9; 150 at91_pmc_clock_deref(clk); 151 152 /* Update USB host port clock info */ 153 clk = at91_pmc_clock_ref("uhpck"); 154 clk->pmc_mask = PMC_SCER_UHP_SAM9; --- 27 unchanged lines hidden (view full) --- 182 clk->pll_min_out = SAM9260_PLL_B_MIN_OUT_FREQ; /* 70 MHz */ 183 clk->pll_max_out = SAM9260_PLL_B_MAX_OUT_FREQ; /* 130 MHz */ 184 clk->pll_mul_shift = SAM9260_PLL_B_MUL_SHIFT; 185 clk->pll_mul_mask = SAM9260_PLL_B_MUL_MASK; 186 clk->pll_div_shift = SAM9260_PLL_B_DIV_SHIFT; 187 clk->pll_div_mask = SAM9260_PLL_B_DIV_MASK; 188 clk->set_outb = at91_pll_outb; 189 at91_pmc_clock_deref(clk); |
230 return (0); | |
231} 232 | 190} 191 |
233static device_method_t at91sam9260_methods[] = { 234 DEVMETHOD(device_probe, at91_probe), 235 DEVMETHOD(device_attach, at91_attach), 236 DEVMETHOD(device_identify, at91_identify), 237 DEVMETHOD_END 238}; 239 240static driver_t at91sam9260_driver = { 241 "at91sam9260", 242 at91sam9260_methods, 243 sizeof(struct at91sam9_softc), 244}; 245 246static devclass_t at91sam9260_devclass; 247 248DRIVER_MODULE(at91sam9260, atmelarm, at91sam9260_driver, at91sam9260_devclass, 249 NULL, NULL); 250 | |
251static struct at91_soc_data soc_data = { 252 .soc_delay = at91_pit_delay, 253 .soc_reset = at91_rst_cpu_reset, | 192static struct at91_soc_data soc_data = { 193 .soc_delay = at91_pit_delay, 194 .soc_reset = at91_rst_cpu_reset, |
195 .soc_clock_init = at91_clock_init, |
|
254 .soc_irq_prio = at91_irq_prio, 255 .soc_children = at91_devs, 256}; 257 258AT91_SOC(AT91_T_SAM9260, &soc_data); | 196 .soc_irq_prio = at91_irq_prio, 197 .soc_children = at91_devs, 198}; 199 200AT91_SOC(AT91_T_SAM9260, &soc_data); |