Module Name:    src
Committed By:   ahoka
Date:           Sat Aug 28 13:02:33 UTC 2010

Modified Files:
        src/sys/arch/arm/omap: files.omap2 omap2_reg.h
        src/sys/arch/evbarm/beagle: beagle_machdep.c
        src/sys/arch/evbarm/conf: BEAGLEBOARD
Added Files:
        src/sys/arch/arm/omap: omap2_prcm.c omap2_prcm.h

Log Message:
Add basic support for PRCM in omap devices, and use it to cold reset
the cpu in cpu_reboot();

Note: the driver only supports the cold reset action at the moment.

Enable it in BEAGLEBOARD


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/omap/files.omap2
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/omap/omap2_prcm.c \
    src/sys/arch/arm/omap/omap2_prcm.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/omap/omap2_reg.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbarm/beagle/beagle_machdep.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/evbarm/conf/BEAGLEBOARD

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/omap/files.omap2
diff -u src/sys/arch/arm/omap/files.omap2:1.4 src/sys/arch/arm/omap/files.omap2:1.5
--- src/sys/arch/arm/omap/files.omap2:1.4	Wed Jul  7 22:53:44 2010
+++ src/sys/arch/arm/omap/files.omap2	Sat Aug 28 13:02:32 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: files.omap2,v 1.4 2010/07/07 22:53:44 macallan Exp $
+#	$NetBSD: files.omap2,v 1.5 2010/08/28 13:02:32 ahoka Exp $
 #
 # Configuration info for Texas Instruments OMAP2/OMAP3 CPU support
 # Based on xscale/files.pxa2x0
@@ -79,6 +79,11 @@
 attach gpmc at mainbus
 file	arch/arm/omap/omap2_gpmc.c		gpmc
 
+# PRCM interface
+device	prcm
+attach	prcm at obio
+file	arch/arm/omap/omap2_prcm.c		prcm needs-flag
+
 # OHCI USB controller
 ##attach	ohci at obio with obioohci:		omapgpio
 attach	ohci at obio with obioohci

Index: src/sys/arch/arm/omap/omap2_reg.h
diff -u src/sys/arch/arm/omap/omap2_reg.h:1.2 src/sys/arch/arm/omap/omap2_reg.h:1.3
--- src/sys/arch/arm/omap/omap2_reg.h:1.2	Wed Jun 16 22:06:54 2010
+++ src/sys/arch/arm/omap/omap2_reg.h	Sat Aug 28 13:02:32 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: omap2_reg.h,v 1.2 2010/06/16 22:06:54 jmcneill Exp $ */
+/* $NetBSD: omap2_reg.h,v 1.3 2010/08/28 13:02:32 ahoka Exp $ */
 
 /*
  * Copyright (c) 2007 Microsoft
@@ -231,6 +231,51 @@
 
 
 /*
+ * Power Management registers base, offsets, and size
+ */
+#ifdef OMAP_3530
+#define	OMAP2_PRM_BASE			0x48306000
+#endif
+
+#define OMAP2_PRM_SIZE			0x00002000 /* 8k */
+
+/* module offsets */
+#define OCP_MOD		0x0800
+#define MPU_MOD		0x0900
+#define CORE_MOD	0x0a00
+#define GFX_MOD		0x0b00
+#define WKUP_MOD	0x0c00
+#define PLL_MOD		0x0d00
+
+/* module offsets specific to chip */
+#define OMAP24XX_GR_MOD		OCP_MOD
+#define OMAP24XX_DSP_MOD	0x1000
+#define OMAP2430_MDM_MOD	0x1400
+#define OMAP3430_IVA2_MOD	0x0000 /* IVA2 before base! */
+#define OMAP3430ES2_SGX_MOD	GFX_MOD
+#define OMAP3430_CCR_MOD	PLL_MOD
+#define OMAP3430_DSS_MOD	0x0e00
+#define OMAP3430_CAM_MOD	0x0f00
+#define OMAP3430_PER_MOD	0x1000
+#define OMAP3430_EMU_MOD	0x1100
+#define OMAP3430_GR_MOD		0x1200
+#define OMAP3430_NEON_MOD	0x1300
+#define OMAP3430ES2_USBHOST_MOD	0x1400
+
+#define OMAP2_RM_RSTCTRL	0x50
+#define OMAP2_RM_RSTTIME	0x54
+#define OMAP2_RM_RSTST		0x58
+#define OMAP2_PM_WKDEP		0xc8
+#define OMAP2_PM_PWSTCTRL	0xe0
+#define OMAP2_PM_PWSTST		0xe4
+#define OMAP2_PM_PREPWSTST	0xe8
+#define OMAP2_PRM_IRQSTATUS	0xf8
+#define OMAP2_PRM_IRQENABLE	0xfc
+
+#define OMAP_RST_DPLL3		__BIT(2)
+#define OMAP_RST_GS		__BIT(1)
+
+/*
  * L3 Interconnect Target Agent Common Registers
  */
 #define OMAP2_TA_GPMC		0x68002400

Index: src/sys/arch/evbarm/beagle/beagle_machdep.c
diff -u src/sys/arch/evbarm/beagle/beagle_machdep.c:1.8 src/sys/arch/evbarm/beagle/beagle_machdep.c:1.9
--- src/sys/arch/evbarm/beagle/beagle_machdep.c:1.8	Wed Jun 16 22:06:54 2010
+++ src/sys/arch/evbarm/beagle/beagle_machdep.c	Sat Aug 28 13:02:32 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: beagle_machdep.c,v 1.8 2010/06/16 22:06:54 jmcneill Exp $ */
+/*	$NetBSD: beagle_machdep.c,v 1.9 2010/08/28 13:02:32 ahoka Exp $ */
 
 /*
  * Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.8 2010/06/16 22:06:54 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.9 2010/08/28 13:02:32 ahoka Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -172,6 +172,7 @@
 #include <arm/omap/omap_com.h>
 #include <arm/omap/omap_var.h>
 #include <arm/omap/omap_wdtvar.h>
+#include <arm/omap/omap2_prcm.h>
 
 #include <evbarm/beagle/beagle.h>
 
@@ -298,6 +299,9 @@
 #if NOMAPWDT32K > 0
 		omapwdt32k_reboot();
 #endif
+#if NPRCM > 0
+		prcm_cold_reset();
+#endif
 		cpu_reset();
 		/*NOTREACHED*/
 	}
@@ -340,6 +344,9 @@
 #if NOMAPWDT32K > 0
 	omapwdt32k_reboot();
 #endif
+#if NPRCM > 0
+	prcm_cold_reset();
+#endif
 	cpu_reset();
 	/*NOTREACHED*/
 }

Index: src/sys/arch/evbarm/conf/BEAGLEBOARD
diff -u src/sys/arch/evbarm/conf/BEAGLEBOARD:1.9 src/sys/arch/evbarm/conf/BEAGLEBOARD:1.10
--- src/sys/arch/evbarm/conf/BEAGLEBOARD:1.9	Sat Jun 19 19:44:58 2010
+++ src/sys/arch/evbarm/conf/BEAGLEBOARD	Sat Aug 28 13:02:32 2010
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: BEAGLEBOARD,v 1.9 2010/06/19 19:44:58 matt Exp $
+#	$NetBSD: BEAGLEBOARD,v 1.10 2010/08/28 13:02:32 ahoka Exp $
 #
 #	BEAGLEBOARD -- TI OMAP 3530 Eval Board Kernel
 #
@@ -220,6 +220,9 @@
 #omapwdt32k*	at obio1 addr 0x4830c000 size 2048	# WDT1
 #omapwdt32k*	at obio1 addr 0x48314000 size 2048	# WDT2
 
+# Power, Reset and Clock Management
+prcm*		at obio1 addr 0x48306000 size 0x2000	# PRM Module
+
 # On-board USB
 #ehci*		at obio0 addr 0x48064800 size 0x0400 intr 77
 #ohci*		at obio0 addr 0x48064400 size 0x0400 intr 76

Added files:

Index: src/sys/arch/arm/omap/omap2_prcm.c
diff -u /dev/null src/sys/arch/arm/omap/omap2_prcm.c:1.1
--- /dev/null	Sat Aug 28 13:02:33 2010
+++ src/sys/arch/arm/omap/omap2_prcm.c	Sat Aug 28 13:02:32 2010
@@ -0,0 +1,122 @@
+/*	$NetBSD: omap2_prcm.c,v 1.1 2010/08/28 13:02:32 ahoka Exp $	*/
+
+/*-
+ * 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 <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: omap2_prcm.c,v 1.1 2010/08/28 13:02:32 ahoka Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+
+#include <arm/omap/omap_var.h>
+
+#include <arm/omap/omap2_obiovar.h>
+#include <arm/omap/omap2_reg.h>
+#include <arm/omap/omap2_prcm.h>
+
+#include "locators.h"
+
+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)
+{
+	struct obio_attach_args *obio = aux;
+
+	if (obio->obio_addr != OBIOCF_ADDR_DEFAULT)
+		return 1;
+	return 0;
+}
+
+static void
+prcm_attach(device_t parent, device_t self, void *aux)
+{
+	struct obio_attach_args *obio = aux;
+
+	prcm_sc = device_private(self);
+
+	prcm_sc->sc_dev = self;
+	prcm_sc->sc_iot = &omap_bs_tag;
+
+	prcm_sc->sc_base = obio->obio_addr;
+	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: src/sys/arch/arm/omap/omap2_prcm.h
diff -u /dev/null src/sys/arch/arm/omap/omap2_prcm.h:1.1
--- /dev/null	Sat Aug 28 13:02:33 2010
+++ src/sys/arch/arm/omap/omap2_prcm.h	Sat Aug 28 13:02:32 2010
@@ -0,0 +1,34 @@
+/*	$NetBSD: omap2_prcm.h,v 1.1 2010/08/28 13:02:32 ahoka Exp $	*/
+
+/*-
+ * 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

Reply via email to