Index: arm/omap/files.omap2 =================================================================== RCS file: /cvsroot/src/sys/arch/arm/omap/files.omap2,v retrieving revision 1.4 diff -u -u -r1.4 files.omap2 --- arm/omap/files.omap2 7 Jul 2010 22:53:44 -0000 1.4 +++ arm/omap/files.omap2 27 Aug 2010 07:19:09 -0000 @@ -79,6 +79,11 @@ attach gpmc at mainbus file arch/arm/omap/omap2_gpmc.c gpmc +# PRCM interface +device prcm +attach prcm at mainbus +file arch/arm/omap/omap2_prcm.c prcm + # OHCI USB controller ##attach ohci at obio with obioohci: omapgpio attach ohci at obio with obioohci Index: arm/omap/omap2_prcm.c =================================================================== RCS file: arm/omap/omap2_prcm.c diff -N arm/omap/omap2_prcm.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ arm/omap/omap2_prcm.c 27 Aug 2010 07:19:09 -0000 @@ -0,0 +1,115 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2010 Adam Hoka + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "opt_omap.h" +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include + +#include + +#include +#include + +#include +#include + +struct prcm_softc { + device_t sc_dev; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + bus_addr_t sc_base; + bus_size_t sc_size; +}; + +/* for external access to prcm operations */ +struct prcm_softc *prcm_sc; + +/* prototypes */ +static int prcm_match(device_t, cfdata_t, void *); +static void prcm_attach(device_t, device_t, void *); + +/* attach structures */ +CFATTACH_DECL_NEW(prcm, sizeof(struct prcm_softc), + prcm_match, prcm_attach, NULL, NULL); + +static int +prcm_match(device_t parent, cfdata_t match, void *aux) +{ + /* always attach */ + return 1; +} + +static void +prcm_attach(device_t parent, device_t self, void *aux) +{ + prcm_sc = device_private(self); + + prcm_sc->sc_dev = self; + prcm_sc->sc_iot = &omap_bs_tag; + + prcm_sc->sc_base = OMAP2_PRM_BASE; + prcm_sc->sc_size = OMAP2_PRM_SIZE; + + /* map i/o space for PRM */ + if (bus_space_map(prcm_sc->sc_iot, prcm_sc->sc_base, prcm_sc->sc_size, + 0, &prcm_sc->sc_ioh) != 0) { + aprint_error("prcm_attach: can't map i/o space for prm"); + return; + } + + aprint_normal(": Power Reset and Clock Management\n"); +} + +static uint32_t +prcm_read(bus_addr_t module, bus_addr_t reg) +{ + return bus_space_read_4(prcm_sc->sc_iot, prcm_sc->sc_ioh, + module + reg); +} + +static void +prcm_write(bus_addr_t module, bus_addr_t reg, uint32_t data) +{ + bus_space_write_4(prcm_sc->sc_iot, prcm_sc->sc_ioh, + module + reg, data); +} + +void +prcm_cold_reset() +{ + uint32_t val; + + val = prcm_read(OMAP3430_GR_MOD, OMAP2_RM_RSTCTRL); + + val |= OMAP_RST_DPLL3; + + prcm_write(OMAP3430_GR_MOD, OMAP2_RM_RSTCTRL, val); +} Index: arm/omap/omap2_prcm.h =================================================================== RCS file: arm/omap/omap2_prcm.h diff -N arm/omap/omap2_prcm.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ arm/omap/omap2_prcm.h 27 Aug 2010 07:19:09 -0000 @@ -0,0 +1,34 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2010 Adam Hoka + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _OMAP2_PRCM_H_ +#define _OMAP2_PRCM_H_ + +void prcm_cold_reset(void); + +#endif Index: arm/omap/omap2_reg.h =================================================================== RCS file: /cvsroot/src/sys/arch/arm/omap/omap2_reg.h,v retrieving revision 1.2 diff -u -u -r1.2 omap2_reg.h --- arm/omap/omap2_reg.h 16 Jun 2010 22:06:54 -0000 1.2 +++ arm/omap/omap2_reg.h 27 Aug 2010 07:19:09 -0000 @@ -231,6 +231,47 @@ /* + * Power Management registers base, offsets, and size + */ +#ifdef OMAP_3530 +#define OMAP2_PRM_BASE 0x48306800 +#endif + +#define OMAP2_PRM_SIZE 0x00002000 /* 8k */ + +/* module offsets */ +#define OCP_MOD 0x000 +#define MPU_MOD 0x100 +#define CORE_MOD 0x200 +#define GFX_MOD 0x300 +#define WKUP_MOD 0x400 +#define PLL_MOD 0x500 + +/* module offsets specific to chip */ +#define OMAP24XX_GR_MOD OCP_MOD +#define OMAP24XX_DSP_MOD 0x800 +#define OMAP2430_MDM_MOD 0xc00 +#define OMAP3430_IVA2_MOD -0x800 /* IVA2 before base! */ +#define OMAP3430ES2_SGX_MOD GFX_MOD +#define OMAP3430_CCR_MOD PLL_MOD +#define OMAP3430_DSS_MOD 0x600 +#define OMAP3430_CAM_MOD 0x700 +#define OMAP3430_PER_MOD 0x800 +#define OMAP3430_EMU_MOD 0x900 +#define OMAP3430_GR_MOD 0xa00 +#define OMAP3430_NEON_MOD 0xb00 +#define OMAP3430ES2_USBHOST_MOD 0xc00 + +#define OMAP2_RM_RSTCTRL 0x0050 +#define OMAP2_RM_RSTTIME 0x0054 +#define OMAP2_RM_RSTST 0x0058 +#define OMAP2_PM_PWSTCTRL 0x00e0 +#define OMAP2_PM_PWSTST 0x00e4 + +#define OMAP_RST_DPLL3 __BIT(2) +#define OMAP_RST_GS __BIT(1) + +/* * L3 Interconnect Target Agent Common Registers */ #define OMAP2_TA_GPMC 0x68002400