svn commit: r278015 - in projects/powernv: amd64/amd64 amd64/conf amd64/ia32 arm/allwinner arm/altera/socfpga arm/arm arm/broadcom/bcm2835 arm/freescale/imx arm/freescale/vybrid arm/include arm/lpc...

Nathan Whitehorn nwhitehorn at FreeBSD.org
Sat Jan 31 23:24:30 UTC 2015


Author: nwhitehorn
Date: Sat Jan 31 23:24:25 2015
New Revision: 278015
URL: https://svnweb.freebsd.org/changeset/base/278015

Log:
  IFC @ 278014
  
  This brings in all the relocatable kernel infrastructure, which is critical
  for this branch.

Added:
  projects/powernv/arm/arm/pmu.c
     - copied unchanged from r278014, head/sys/arm/arm/pmu.c
  projects/powernv/arm/freescale/imx/imx6_audmux.c
     - copied unchanged from r278014, head/sys/arm/freescale/imx/imx6_audmux.c
  projects/powernv/arm/freescale/imx/imx6_sdma.c
     - copied unchanged from r278014, head/sys/arm/freescale/imx/imx6_sdma.c
  projects/powernv/arm/freescale/imx/imx6_sdma.h
     - copied unchanged from r278014, head/sys/arm/freescale/imx/imx6_sdma.h
  projects/powernv/arm/freescale/imx/imx6_ssi.c
     - copied unchanged from r278014, head/sys/arm/freescale/imx/imx6_ssi.c
  projects/powernv/dev/hwpmc/hwpmc_armv7.c
     - copied unchanged from r278014, head/sys/dev/hwpmc/hwpmc_armv7.c
  projects/powernv/dev/hwpmc/hwpmc_armv7.h
     - copied unchanged from r278014, head/sys/dev/hwpmc/hwpmc_armv7.h
  projects/powernv/dev/iscsi/icl_conn_if.m
     - copied unchanged from r278014, head/sys/dev/iscsi/icl_conn_if.m
  projects/powernv/dev/iscsi/icl_soft.c
     - copied unchanged from r278014, head/sys/dev/iscsi/icl_soft.c
  projects/powernv/dev/iscsi/icl_wrappers.h
     - copied unchanged from r278014, head/sys/dev/iscsi/icl_wrappers.h
Replaced:
  projects/powernv/dev/iscsi/icl.c
     - copied unchanged from r278014, head/sys/dev/iscsi/icl.c
Modified:
  projects/powernv/amd64/amd64/machdep.c
  projects/powernv/amd64/conf/GENERIC
  projects/powernv/amd64/ia32/ia32_signal.c
  projects/powernv/arm/allwinner/a10_gpio.c
  projects/powernv/arm/altera/socfpga/socfpga_gpio.c
  projects/powernv/arm/arm/intr.c
  projects/powernv/arm/arm/machdep.c
  projects/powernv/arm/arm/mem.c
  projects/powernv/arm/broadcom/bcm2835/bcm2835_gpio.c
  projects/powernv/arm/freescale/imx/files.imx6
  projects/powernv/arm/freescale/imx/imx6_anatop.c
  projects/powernv/arm/freescale/imx/imx6_anatopreg.h
  projects/powernv/arm/freescale/imx/imx6_anatopvar.h
  projects/powernv/arm/freescale/imx/imx6_ccm.c
  projects/powernv/arm/freescale/imx/imx6_ccmreg.h
  projects/powernv/arm/freescale/imx/imx_ccmvar.h
  projects/powernv/arm/freescale/imx/imx_gpio.c
  projects/powernv/arm/freescale/vybrid/vf_gpio.c
  projects/powernv/arm/include/pmc_mdep.h
  projects/powernv/arm/include/profile.h
  projects/powernv/arm/lpc/lpc_gpio.c
  projects/powernv/arm/rockchip/rk30xx_gpio.c
  projects/powernv/arm/samsung/exynos/exynos5_pad.c
  projects/powernv/arm/ti/am335x/am335x_lcd.c
  projects/powernv/arm/ti/am335x/am335x_prcm.c
  projects/powernv/arm/ti/am335x/files.am335x
  projects/powernv/arm/ti/files.ti
  projects/powernv/arm/ti/ti_gpio.c
  projects/powernv/arm/ti/ti_gpio.h
  projects/powernv/arm/ti/ti_i2c.c
  projects/powernv/arm/ti/ti_pruss.c
  projects/powernv/arm/xilinx/zy7_gpio.c
  projects/powernv/arm/xscale/ixp425/avila_gpio.c
  projects/powernv/arm/xscale/ixp425/cambria_gpio.c
  projects/powernv/boot/common/load_elf.c
  projects/powernv/boot/efi/libefi/efinet.c
  projects/powernv/boot/fdt/dts/arm/am335x.dtsi
  projects/powernv/boot/fdt/dts/arm/apalis-imx6.dts
  projects/powernv/boot/fdt/dts/arm/imx6.dtsi
  projects/powernv/boot/forth/beastie.4th
  projects/powernv/boot/forth/brand.4th
  projects/powernv/boot/i386/libi386/libi386.h
  projects/powernv/boot/i386/libi386/smbios.c
  projects/powernv/boot/powerpc/kboot/conf.c
  projects/powernv/boot/powerpc/kboot/kbootfdt.c
  projects/powernv/boot/powerpc/kboot/kerneltramp.S
  projects/powernv/boot/powerpc/kboot/main.c
  projects/powernv/boot/powerpc/kboot/ppc64_elf_freebsd.c
  projects/powernv/cam/ctl/ctl.c
  projects/powernv/cam/ctl/ctl_frontend_iscsi.c
  projects/powernv/cam/ctl/ctl_tpc.c
  projects/powernv/cam/scsi/scsi_all.h
  projects/powernv/cam/scsi/scsi_da.c
  projects/powernv/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
  projects/powernv/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  projects/powernv/conf/files
  projects/powernv/conf/files.amd64
  projects/powernv/conf/files.arm
  projects/powernv/conf/kern.mk
  projects/powernv/conf/kern.opts.mk
  projects/powernv/dev/acpica/acpi.c
  projects/powernv/dev/alc/if_alc.c
  projects/powernv/dev/ath/ath_hal/ah_internal.h
  projects/powernv/dev/ath/ath_rate/sample/sample.c
  projects/powernv/dev/ath/ath_rate/sample/sample.h
  projects/powernv/dev/cxgbe/t4_main.c
  projects/powernv/dev/cxgbe/tom/t4_ddp.c
  projects/powernv/dev/drm2/i915/intel_display.c
  projects/powernv/dev/drm2/radeon/ni.c
  projects/powernv/dev/drm2/radeon/si.c
  projects/powernv/dev/fb/fbd.c
  projects/powernv/dev/fdt/fdt_clock.c
  projects/powernv/dev/gpio/gpio_if.m
  projects/powernv/dev/gpio/gpiobus.c
  projects/powernv/dev/gpio/gpiobusvar.h
  projects/powernv/dev/hwpmc/hwpmc_arm.c
  projects/powernv/dev/hwpmc/pmc_events.h
  projects/powernv/dev/iscsi/icl.h
  projects/powernv/dev/iscsi/iscsi.c
  projects/powernv/dev/mem/memdev.c
  projects/powernv/dev/mps/mps.c
  projects/powernv/dev/mps/mps_user.c
  projects/powernv/dev/netmap/netmap.c
  projects/powernv/dev/ofw/openfirm.c
  projects/powernv/dev/pci/pci_pci.c
  projects/powernv/dev/sfxge/common/efsys.h
  projects/powernv/dev/sfxge/common/efx_ev.c
  projects/powernv/dev/sfxge/common/efx_tx.c
  projects/powernv/dev/sfxge/sfxge.c
  projects/powernv/dev/sfxge/sfxge.h
  projects/powernv/dev/sfxge/sfxge_dma.c
  projects/powernv/dev/sfxge/sfxge_ev.c
  projects/powernv/dev/sfxge/sfxge_intr.c
  projects/powernv/dev/sfxge/sfxge_port.c
  projects/powernv/dev/sfxge/sfxge_tx.c
  projects/powernv/dev/sfxge/sfxge_tx.h
  projects/powernv/dev/syscons/syscons.c
  projects/powernv/dev/usb/input/uhid.c
  projects/powernv/dev/virtio/block/virtio_blk.c
  projects/powernv/dev/vt/hw/fb/vt_fb.c
  projects/powernv/dev/vt/hw/fb/vt_fb.h
  projects/powernv/dev/vt/vt.h
  projects/powernv/dev/vt/vt_core.c
  projects/powernv/fs/cd9660/cd9660_util.c
  projects/powernv/fs/fdescfs/fdesc_vfsops.c
  projects/powernv/fs/msdosfs/msdosfs_conv.c
  projects/powernv/fs/smbfs/smbfs_subr.c
  projects/powernv/fs/tmpfs/tmpfs.h
  projects/powernv/fs/tmpfs/tmpfs_subr.c
  projects/powernv/fs/tmpfs/tmpfs_vfsops.c
  projects/powernv/fs/tmpfs/tmpfs_vnops.c
  projects/powernv/fs/udf/udf_vnops.c
  projects/powernv/i386/i386/machdep.c
  projects/powernv/i386/i386/mem.c
  projects/powernv/kern/kern_jail.c
  projects/powernv/kern/kern_timeout.c
  projects/powernv/kern/kern_umtx.c
  projects/powernv/kern/subr_sglist.c
  projects/powernv/kern/vfs_subr.c
  projects/powernv/libkern/strtol.c
  projects/powernv/libkern/strtoq.c
  projects/powernv/libkern/strtoul.c
  projects/powernv/libkern/strtouq.c
  projects/powernv/mips/atheros/ar71xx_gpio.c
  projects/powernv/mips/atheros/ar71xx_gpiovar.h
  projects/powernv/mips/cavium/octeon_gpio.c
  projects/powernv/mips/cavium/octeon_gpiovar.h
  projects/powernv/mips/mips/freebsd32_machdep.c
  projects/powernv/mips/mips/mem.c
  projects/powernv/mips/mips/pm_machdep.c
  projects/powernv/mips/rt305x/rt305x_gpio.c
  projects/powernv/mips/rt305x/rt305x_gpiovar.h
  projects/powernv/modules/Makefile
  projects/powernv/modules/aesni/Makefile
  projects/powernv/modules/ctl/Makefile
  projects/powernv/modules/cxgbe/if_cxgbe/Makefile
  projects/powernv/modules/geom/Makefile
  projects/powernv/modules/iscsi/Makefile
  projects/powernv/netgraph/ng_parse.c
  projects/powernv/netinet/sctp_input.c
  projects/powernv/netinet/sctp_usrreq.c
  projects/powernv/netinet/tcp_hostcache.c
  projects/powernv/netinet/tcp_syncache.c
  projects/powernv/netipsec/key.c
  projects/powernv/powerpc/ofw/ofw_machdep.c
  projects/powernv/powerpc/powerpc/exec_machdep.c
  projects/powernv/powerpc/pseries/plpar_iommu.c
  projects/powernv/sparc64/sparc64/machdep.c
  projects/powernv/sparc64/sparc64/mem.c
  projects/powernv/sys/cdefs.h
  projects/powernv/sys/conf.h
  projects/powernv/sys/eventhandler.h
  projects/powernv/sys/jail.h
  projects/powernv/sys/param.h
  projects/powernv/sys/pmc.h
  projects/powernv/sys/proc.h
  projects/powernv/sys/tree.h
  projects/powernv/sys/ucontext.h
  projects/powernv/ufs/ffs/ffs_softdep.c
  projects/powernv/ufs/ffs/softdep.h
  projects/powernv/ufs/ufs/ufs_quota.c
  projects/powernv/ufs/ufs/ufs_vfsops.c
  projects/powernv/vm/vm_fault.c
  projects/powernv/vm/vm_map.c
  projects/powernv/vm/vm_object.c
  projects/powernv/vm/vm_object.h
  projects/powernv/vm/vm_pageout.c
  projects/powernv/x86/x86/tsc.c
Directory Properties:
  projects/powernv/   (props changed)
  projects/powernv/boot/   (props changed)
  projects/powernv/boot/powerpc/kboot/   (props changed)
  projects/powernv/cddl/contrib/opensolaris/   (props changed)
  projects/powernv/conf/   (props changed)

Modified: projects/powernv/amd64/amd64/machdep.c
==============================================================================
--- projects/powernv/amd64/amd64/machdep.c	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/amd64/amd64/machdep.c	Sat Jan 31 23:24:25 2015	(r278015)
@@ -157,7 +157,7 @@ extern u_int64_t hammer_time(u_int64_t, 
 static void cpu_startup(void *);
 static void get_fpcontext(struct thread *td, mcontext_t *mcp,
     char *xfpusave, size_t xfpusave_len);
-static int  set_fpcontext(struct thread *td, const mcontext_t *mcp,
+static int  set_fpcontext(struct thread *td, mcontext_t *mcp,
     char *xfpustate, size_t xfpustate_len);
 SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
 
@@ -1355,8 +1355,10 @@ add_physmap_entry(uint64_t base, uint64_
 	/*
 	 * Find insertion point while checking for overlap.  Start off by
 	 * assuming the new entry will be added to the end.
+	 *
+	 * NB: physmap_idx points to the next free slot.
 	 */
-	insert_idx = physmap_idx + 2;
+	insert_idx = physmap_idx;
 	for (i = 0; i <= physmap_idx; i += 2) {
 		if (base < physmap[i + 1]) {
 			if (base + length <= physmap[i]) {
@@ -1394,7 +1396,7 @@ add_physmap_entry(uint64_t base, uint64_
 	 * Move the last 'N' entries down to make room for the new
 	 * entry if needed.
 	 */
-	for (i = physmap_idx; i > insert_idx; i -= 2) {
+	for (i = (physmap_idx - 2); i > insert_idx; i -= 2) {
 		physmap[i] = physmap[i - 2];
 		physmap[i + 1] = physmap[i - 1];
 	}
@@ -1557,6 +1559,8 @@ native_parse_memmap(caddr_t kmdp, vm_pad
 	}
 }
 
+#define	PAGES_PER_GB	(1024 * 1024 * 1024 / PAGE_SIZE)
+
 /*
  * Populate the (physmap) array with base/bound pairs describing the
  * available physical memory in the system, then test this memory and
@@ -1575,25 +1579,30 @@ getmemsize(caddr_t kmdp, u_int64_t first
 	u_long physmem_start, physmem_tunable, memtest;
 	pt_entry_t *pte;
 	quad_t dcons_addr, dcons_size;
+	int page_counter;
 
 	bzero(physmap, sizeof(physmap));
-	basemem = 0;
 	physmap_idx = 0;
 
 	init_ops.parse_memmap(kmdp, physmap, &physmap_idx);
+	physmap_idx -= 2;
 
 	/*
 	 * Find the 'base memory' segment for SMP
 	 */
 	basemem = 0;
 	for (i = 0; i <= physmap_idx; i += 2) {
-		if (physmap[i] == 0x00000000) {
+		if (physmap[i] <= 0xA0000) {
 			basemem = physmap[i + 1] / 1024;
 			break;
 		}
 	}
-	if (basemem == 0)
-		panic("BIOS smap did not include a basemem segment!");
+	if (basemem == 0 || basemem > 640) {
+		if (bootverbose)
+			printf(
+		"Memory map doesn't contain a basemem segment, faking it");
+		basemem = 640;
+	}
 
 	/*
 	 * Make hole for "AP -> long mode" bootstrap code.  The
@@ -1601,8 +1610,12 @@ getmemsize(caddr_t kmdp, u_int64_t first
 	 * is configured to support APs and APs for the system start
 	 * in 32bit mode (e.g. SMP bare metal).
 	 */
-	if (init_ops.mp_bootaddress)
+	if (init_ops.mp_bootaddress) {
+		if (physmap[1] >= 0x100000000)
+			panic(
+	"Basemem segment is not suitable for AP bootstrap code!");
 		physmap[1] = init_ops.mp_bootaddress(physmap[1] / 1024);
+	}
 
 	/*
 	 * Maxmem isn't the "maximum memory", it's one larger than the
@@ -1654,12 +1667,14 @@ getmemsize(caddr_t kmdp, u_int64_t first
 	 */
 	physmem_start = (vm_guest > VM_GUEST_NO ? 1 : 16) << PAGE_SHIFT;
 	TUNABLE_ULONG_FETCH("hw.physmem.start", &physmem_start);
-	if (physmem_start < PAGE_SIZE)
-		physmap[0] = PAGE_SIZE;
-	else if (physmem_start >= physmap[1])
-		physmap[0] = round_page(physmap[1] - PAGE_SIZE);
-	else
-		physmap[0] = round_page(physmem_start);
+	if (physmap[0] < physmem_start) {
+		if (physmem_start < PAGE_SIZE)
+			physmap[0] = PAGE_SIZE;
+		else if (physmem_start >= physmap[1])
+			physmap[0] = round_page(physmap[1] - PAGE_SIZE);
+		else
+			physmap[0] = round_page(physmem_start);
+	}
 	pa_indx = 0;
 	da_indx = 1;
 	phys_avail[pa_indx++] = physmap[0];
@@ -1678,6 +1693,9 @@ getmemsize(caddr_t kmdp, u_int64_t first
 	 * physmap is in bytes, so when converting to page boundaries,
 	 * round up the start address and round down the end address.
 	 */
+	page_counter = 0;
+	if (memtest != 0)
+		printf("Testing system memory");
 	for (i = 0; i <= physmap_idx; i += 2) {
 		vm_paddr_t end;
 
@@ -1708,6 +1726,14 @@ getmemsize(caddr_t kmdp, u_int64_t first
 				goto skip_memtest;
 
 			/*
+			 * Print a "." every GB to show we're making
+			 * progress.
+			 */
+			page_counter++;
+			if ((page_counter % PAGES_PER_GB) == 0)
+				printf(".");
+
+			/*
 			 * map page into kernel: valid, read/write,non-cacheable
 			 */
 			*pte = pa | PG_V | PG_RW | PG_NC_PWT | PG_NC_PCD;
@@ -1794,6 +1820,8 @@ do_next:
 	}
 	*pte = 0;
 	invltlb();
+	if (memtest != 0)
+		printf("\n");
 
 	/*
 	 * XXX
@@ -2452,7 +2480,7 @@ get_mcontext(struct thread *td, mcontext
  * touch the cs selector.
  */
 int
-set_mcontext(struct thread *td, const mcontext_t *mcp)
+set_mcontext(struct thread *td, mcontext_t *mcp)
 {
 	struct pcb *pcb;
 	struct trapframe *tp;
@@ -2539,7 +2567,7 @@ get_fpcontext(struct thread *td, mcontex
 }
 
 static int
-set_fpcontext(struct thread *td, const mcontext_t *mcp, char *xfpustate,
+set_fpcontext(struct thread *td, mcontext_t *mcp, char *xfpustate,
     size_t xfpustate_len)
 {
 	struct savefpu *fpstate;

Modified: projects/powernv/amd64/conf/GENERIC
==============================================================================
--- projects/powernv/amd64/conf/GENERIC	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/amd64/conf/GENERIC	Sat Jan 31 23:24:25 2015	(r278015)
@@ -260,16 +260,6 @@ device		vr			# VIA Rhine, Rhine II
 device		wb			# Winbond W89C840F
 device		xl			# 3Com 3c90x (``Boomerang'', ``Cyclone'')
 
-# ISA Ethernet NICs.  pccard NICs included.
-device		cs			# Crystal Semiconductor CS89x0 NIC
-# 'device ed' requires 'device miibus'
-device		ed			# NE[12]000, SMC Ultra, 3c503, DS8390 cards
-device		ex			# Intel EtherExpress Pro/10 and Pro/10+
-device		ep			# Etherlink III based cards
-device		fe			# Fujitsu MB8696x based cards
-device		sn			# SMC's 9000 series of Ethernet chips
-device		xe			# Xircom pccard Ethernet
-
 # Wireless NIC cards
 device		wlan			# 802.11 support
 options 	IEEE80211_DEBUG		# enable debug msgs

Modified: projects/powernv/amd64/ia32/ia32_signal.c
==============================================================================
--- projects/powernv/amd64/ia32/ia32_signal.c	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/amd64/ia32/ia32_signal.c	Sat Jan 31 23:24:25 2015	(r278015)
@@ -118,7 +118,7 @@ ia32_get_fpcontext(struct thread *td, st
 }
 
 static int
-ia32_set_fpcontext(struct thread *td, const struct ia32_mcontext *mcp,
+ia32_set_fpcontext(struct thread *td, struct ia32_mcontext *mcp,
     char *xfpustate, size_t xfpustate_len)
 {
 	int error;
@@ -197,7 +197,7 @@ ia32_get_mcontext(struct thread *td, str
  * touch the cs selector.
  */
 static int
-ia32_set_mcontext(struct thread *td, const struct ia32_mcontext *mcp)
+ia32_set_mcontext(struct thread *td, struct ia32_mcontext *mcp)
 {
 	struct trapframe *tp;
 	char *xfpustate;

Modified: projects/powernv/arm/allwinner/a10_gpio.c
==============================================================================
--- projects/powernv/arm/allwinner/a10_gpio.c	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/arm/allwinner/a10_gpio.c	Sat Jan 31 23:24:25 2015	(r278015)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr.h>
 
 #include <dev/fdt/fdt_common.h>
+#include <dev/gpio/gpiobusvar.h>
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
 
@@ -75,6 +76,7 @@ __FBSDID("$FreeBSD$");
 
 struct a10_gpio_softc {
 	device_t		sc_dev;
+	device_t		sc_busdev;
 	struct mtx		sc_mtx;
 	struct resource *	sc_mem_res;
 	struct resource *	sc_irq_res;
@@ -217,6 +219,16 @@ a10_gpio_pin_configure(struct a10_gpio_s
 	A10_GPIO_UNLOCK(sc);
 }
 
+static device_t
+a10_gpio_get_bus(device_t dev)
+{
+	struct a10_gpio_softc *sc;
+
+	sc = device_get_softc(dev);
+
+	return (sc->sc_busdev);
+}
+
 static int
 a10_gpio_pin_max(device_t dev, int *maxpin)
 {
@@ -427,7 +439,7 @@ a10_gpio_attach(device_t dev)
 	    RF_ACTIVE);
 	if (!sc->sc_mem_res) {
 		device_printf(dev, "cannot allocate memory window\n");
-		return (ENXIO);
+		goto fail;
 	}
 
 	sc->sc_bst = rman_get_bustag(sc->sc_mem_res);
@@ -437,9 +449,8 @@ a10_gpio_attach(device_t dev)
 	sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
 	    RF_ACTIVE);
 	if (!sc->sc_irq_res) {
-		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
 		device_printf(dev, "cannot allocate interrupt\n");
-		return (ENXIO);
+		goto fail;
 	}
 
 	/* Find our node. */
@@ -459,19 +470,20 @@ a10_gpio_attach(device_t dev)
 		sc->sc_gpio_pins[i].gp_flags = a10_gpio_func_flag(func);
 	}
 	sc->sc_gpio_npins = i;
-
-	device_add_child(dev, "gpioc", -1);
-	device_add_child(dev, "gpiobus", -1);
-
 	a10_gpio_sc = sc;
+	sc->sc_busdev = gpiobus_attach_bus(dev);
+	if (sc->sc_busdev == NULL)
+		goto fail;
 
-	return (bus_generic_attach(dev));
+	return (0);
 
 fail:
 	if (sc->sc_irq_res)
 		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
 	if (sc->sc_mem_res)
 		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
+	mtx_destroy(&sc->sc_mtx);
+
 	return (ENXIO);
 }
 
@@ -489,6 +501,7 @@ static device_method_t a10_gpio_methods[
 	DEVMETHOD(device_detach,	a10_gpio_detach),
 
 	/* GPIO protocol */
+	DEVMETHOD(gpio_get_bus,		a10_gpio_get_bus),
 	DEVMETHOD(gpio_pin_max,		a10_gpio_pin_max),
 	DEVMETHOD(gpio_pin_getname,	a10_gpio_pin_getname),
 	DEVMETHOD(gpio_pin_getflags,	a10_gpio_pin_getflags),

Modified: projects/powernv/arm/altera/socfpga/socfpga_gpio.c
==============================================================================
--- projects/powernv/arm/altera/socfpga/socfpga_gpio.c	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/arm/altera/socfpga/socfpga_gpio.c	Sat Jan 31 23:24:25 2015	(r278015)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/gpio.h>
 
 #include <dev/fdt/fdt_common.h>
+#include <dev/gpio/gpiobusvar.h>
 #include <dev/ofw/openfirm.h>
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
@@ -107,6 +108,7 @@ enum port_no {
 /*
  * GPIO interface
  */
+static device_t socfpga_gpio_get_bus(device_t);
 static int socfpga_gpio_pin_max(device_t, int *);
 static int socfpga_gpio_pin_getcaps(device_t, uint32_t, uint32_t *);
 static int socfpga_gpio_pin_getname(device_t, uint32_t, char *);
@@ -122,6 +124,7 @@ struct socfpga_gpio_softc {
 	bus_space_handle_t	bsh;
 
 	device_t		dev;
+	device_t		busdev;
 	struct mtx		sc_mtx;
 	int			gpio_npins;
 	struct gpio_pin		gpio_pins[NR_GPIO_MAX];
@@ -163,6 +166,7 @@ socfpga_gpio_attach(device_t dev)
 
 	if (bus_alloc_resources(dev, socfpga_gpio_spec, sc->res)) {
 		device_printf(dev, "could not allocate resources\n");
+		mtx_destroy(&sc->sc_mtx);
 		return (ENXIO);
 	}
 
@@ -195,11 +199,24 @@ socfpga_gpio_attach(device_t dev)
 		snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,
 		    "socfpga_gpio%d.%d", device_get_unit(dev), i);
 	}
+	sc->busdev = gpiobus_attach_bus(dev);
+	if (sc->busdev == NULL) {
+		bus_release_resources(dev, socfpga_gpio_spec, sc->res);
+		mtx_destroy(&sc->sc_mtx);
+		return (ENXIO);
+	}
+
+	return (0);
+}
 
-	device_add_child(dev, "gpioc", -1);
-	device_add_child(dev, "gpiobus", -1);
+static device_t
+socfpga_gpio_get_bus(device_t dev)
+{
+	struct socfpga_gpio_softc *sc;
+
+	sc = device_get_softc(dev);
 
-	return (bus_generic_attach(dev));
+	return (sc->busdev);
 }
 
 static int
@@ -414,6 +431,7 @@ static device_method_t socfpga_gpio_meth
 	DEVMETHOD(device_attach,	socfpga_gpio_attach),
 
 	/* GPIO protocol */
+	DEVMETHOD(gpio_get_bus,		socfpga_gpio_get_bus),
 	DEVMETHOD(gpio_pin_max,		socfpga_gpio_pin_max),
 	DEVMETHOD(gpio_pin_getname,	socfpga_gpio_pin_getname),
 	DEVMETHOD(gpio_pin_getcaps,	socfpga_gpio_pin_getcaps),

Modified: projects/powernv/arm/arm/intr.c
==============================================================================
--- projects/powernv/arm/arm/intr.c	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/arm/arm/intr.c	Sat Jan 31 23:24:25 2015	(r278015)
@@ -37,6 +37,7 @@
  */
 
 #include "opt_platform.h"
+#include "opt_hwpmc_hooks.h"
 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
@@ -50,6 +51,8 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/interrupt.h>
 #include <sys/conf.h>
+#include <sys/pmc.h>
+#include <sys/pmckern.h>
 
 #include <machine/atomic.h>
 #include <machine/intr.h>
@@ -190,6 +193,10 @@ arm_irq_handler(struct trapframe *frame)
 			arm_mask_irq(i);
 		}
 	}
+#ifdef HWPMC_HOOKS
+	if (pmc_hook && (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN))
+		pmc_hook(PCPU_GET(curthread), PMC_FN_USER_CALLCHAIN, frame);
+#endif
 }
 
 /*

Modified: projects/powernv/arm/arm/machdep.c
==============================================================================
--- projects/powernv/arm/arm/machdep.c	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/arm/arm/machdep.c	Sat Jan 31 23:24:25 2015	(r278015)
@@ -700,7 +700,7 @@ get_mcontext(struct thread *td, mcontext
  * touch the cs selector.
  */
 int
-set_mcontext(struct thread *td, const mcontext_t *mcp)
+set_mcontext(struct thread *td, mcontext_t *mcp)
 {
 	struct trapframe *tf = td->td_frame;
 	const __greg_t *gr = mcp->__gregs;

Modified: projects/powernv/arm/arm/mem.c
==============================================================================
--- projects/powernv/arm/arm/mem.c	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/arm/arm/mem.c	Sat Jan 31 23:24:25 2015	(r278015)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/proc.h>
 #include <sys/signalvar.h>
+#include <sys/sx.h>
 #include <sys/systm.h>
 #include <sys/uio.h>
 
@@ -72,6 +73,9 @@ MALLOC_DEFINE(M_MEMDESC, "memdesc", "mem
 
 struct mem_range_softc mem_range_softc;
 
+static struct sx tmppt_lock;
+SX_SYSINIT(tmppt, &tmppt_lock, "mem4map");
+
 /* ARGSUSED */
 int
 memrw(struct cdev *dev, struct uio *uio, int flags)
@@ -82,8 +86,6 @@ memrw(struct cdev *dev, struct uio *uio,
 	int error = 0;
 	vm_offset_t addr, eaddr;
 
-	GIANT_REQUIRED;
-
 	while (uio->uio_resid > 0 && error == 0) {
 		iov = uio->uio_iov;
 		if (iov->iov_len == 0) {
@@ -109,6 +111,7 @@ memrw(struct cdev *dev, struct uio *uio,
 			}
 			if (!address_valid)
 				return (EINVAL);
+			sx_xlock(&tmppt_lock);
 			pmap_kenter((vm_offset_t)_tmppt, v);
 			o = (int)uio->uio_offset & PAGE_MASK;
 			c = (u_int)(PAGE_SIZE - ((int)iov->iov_base & PAGE_MASK));
@@ -116,6 +119,7 @@ memrw(struct cdev *dev, struct uio *uio,
 			c = min(c, (u_int)iov->iov_len);
 			error = uiomove((caddr_t)&_tmppt[o], (int)c, uio);
 			pmap_qremove((vm_offset_t)_tmppt, 1);
+			sx_xunlock(&tmppt_lock);
 			continue;
 		}
 		else if (dev2unit(dev) == CDEV_MINOR_KMEM) {

Copied: projects/powernv/arm/arm/pmu.c (from r278014, head/sys/arm/arm/pmu.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/powernv/arm/arm/pmu.c	Sat Jan 31 23:24:25 2015	(r278015, copy of r278014, head/sys/arm/arm/pmu.c)
@@ -0,0 +1,157 @@
+/*-
+ * Copyright (c) 2015 Ruslan Bukin <br at bsdpad.com>
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ */
+
+/*
+ * Performance Monitoring Unit
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_hwpmc_hooks.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/malloc.h>
+#include <sys/rman.h>
+#include <sys/timeet.h>
+#include <sys/timetc.h>
+#include <sys/pmc.h>
+#include <sys/pmckern.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <machine/bus.h>
+#include <machine/fdt.h>
+#include <machine/cpu.h>
+#include <machine/intr.h>
+
+struct pmu_softc {
+	struct resource		*res[1];
+	device_t		dev;
+	void			*ih;
+};
+
+static struct ofw_compat_data compat_data[] = {
+	{"arm,cortex-a17-pmu",	1},
+	{"arm,cortex-a15-pmu",	1},
+	{"arm,cortex-a12-pmu",	1},
+	{"arm,cortex-a9-pmu",	1},
+	{"arm,cortex-a8-pmu",	1},
+	{"arm,cortex-a7-pmu",	1},
+	{"arm,cortex-a5-pmu",	1},
+	{"arm,arm11mpcore-pmu",	1},
+	{"arm,arm1176-pmu",	1},
+	{"arm,arm1136-pmu",	1},
+	{"qcom,krait-pmu",	1},
+	{NULL,			0}
+};
+
+static struct resource_spec pmu_spec[] = {
+	{ SYS_RES_IRQ,		0,	RF_ACTIVE },
+	{ -1, 0 }
+};
+
+static int
+pmu_intr(void *arg)
+{
+	struct trapframe *tf;
+
+	tf = arg;
+
+#ifdef HWPMC_HOOKS
+	if (pmc_intr)
+		(*pmc_intr)(PCPU_GET(cpuid), tf);
+#endif
+
+	return (FILTER_HANDLED);
+}
+
+static int
+pmu_probe(device_t dev)
+{
+
+	if (!ofw_bus_status_okay(dev))
+		return (ENXIO);
+
+	if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) {
+		device_set_desc(dev, "Performance Monitoring Unit");
+		return (BUS_PROBE_DEFAULT);
+	}
+
+	return (ENXIO);
+}
+
+static int
+pmu_attach(device_t dev)
+{
+	struct pmu_softc *sc;
+	int err;
+
+	sc = device_get_softc(dev);
+	sc->dev = dev;
+
+	if (bus_alloc_resources(dev, pmu_spec, sc->res)) {
+		device_printf(dev, "could not allocate resources\n");
+		return (ENXIO);
+	}
+
+	/* Setup interrupt handler */
+	err = bus_setup_intr(dev, sc->res[0], INTR_MPSAFE | INTR_TYPE_MISC,
+	    pmu_intr, NULL, NULL, &sc->ih);
+	if (err) {
+		device_printf(dev, "Unable to setup interrupt handler.\n");
+		return (ENXIO);
+	}
+
+	return (0);
+}
+
+static device_method_t pmu_methods[] = {
+	DEVMETHOD(device_probe,		pmu_probe),
+	DEVMETHOD(device_attach,	pmu_attach),
+	{ 0, 0 }
+};
+
+static driver_t pmu_driver = {
+	"pmu",
+	pmu_methods,
+	sizeof(struct pmu_softc),
+};
+
+static devclass_t pmu_devclass;
+
+DRIVER_MODULE(pmu, simplebus, pmu_driver, pmu_devclass, 0, 0);

Modified: projects/powernv/arm/broadcom/bcm2835/bcm2835_gpio.c
==============================================================================
--- projects/powernv/arm/broadcom/bcm2835/bcm2835_gpio.c	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/arm/broadcom/bcm2835/bcm2835_gpio.c	Sat Jan 31 23:24:25 2015	(r278015)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr.h>
 
 #include <dev/fdt/fdt_common.h>
+#include <dev/gpio/gpiobusvar.h>
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
 
@@ -62,10 +63,20 @@ __FBSDID("$FreeBSD$");
 #define dprintf(fmt, args...)
 #endif
 
+#define	BCM_GPIO_IRQS		4
 #define	BCM_GPIO_PINS		54
 #define	BCM_GPIO_DEFAULT_CAPS	(GPIO_PIN_INPUT | GPIO_PIN_OUTPUT |	\
     GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN)
 
+static struct resource_spec bcm_gpio_res_spec[] = {
+	{ SYS_RES_MEMORY, 0, RF_ACTIVE },
+	{ SYS_RES_IRQ, 0, RF_ACTIVE },
+	{ SYS_RES_IRQ, 1, RF_ACTIVE },
+	{ SYS_RES_IRQ, 2, RF_ACTIVE },
+	{ SYS_RES_IRQ, 3, RF_ACTIVE },
+	{ -1, 0, 0 }
+};
+
 struct bcm_gpio_sysctl {
 	struct bcm_gpio_softc	*sc;
 	uint32_t		pin;
@@ -73,9 +84,9 @@ struct bcm_gpio_sysctl {
 
 struct bcm_gpio_softc {
 	device_t		sc_dev;
+	device_t		sc_busdev;
 	struct mtx		sc_mtx;
-	struct resource *	sc_mem_res;
-	struct resource *	sc_irq_res;
+	struct resource *	sc_res[BCM_GPIO_IRQS + 1];
 	bus_space_tag_t		sc_bst;
 	bus_space_handle_t	sc_bsh;
 	void *			sc_intrhand;
@@ -308,6 +319,16 @@ bcm_gpio_pin_configure(struct bcm_gpio_s
 	BCM_GPIO_UNLOCK(sc);
 }
 
+static device_t
+bcm_gpio_get_bus(device_t dev)
+{
+	struct bcm_gpio_softc *sc;
+
+	sc = device_get_softc(dev);
+
+	return (sc->sc_busdev);
+}
+
 static int
 bcm_gpio_pin_max(device_t dev, int *maxpin)
 {
@@ -494,39 +515,6 @@ bcm_gpio_pin_toggle(device_t dev, uint32
 }
 
 static int
-bcm_gpio_get_ro_pins(struct bcm_gpio_softc *sc)
-{
-	int i, len;
-	pcell_t pins[BCM_GPIO_PINS];
-	phandle_t gpio;
-
-	/* Find the gpio node to start. */
-	gpio = ofw_bus_get_node(sc->sc_dev);
-
-	len = OF_getproplen(gpio, "broadcom,read-only");
-	if (len < 0 || len > sizeof(pins))
-		return (-1);
-
-	if (OF_getprop(gpio, "broadcom,read-only", &pins, len) < 0)
-		return (-1);
-
-	sc->sc_ro_npins = len / sizeof(pcell_t);
-
-	device_printf(sc->sc_dev, "read-only pins: ");
-	for (i = 0; i < sc->sc_ro_npins; i++) {
-		sc->sc_ro_pins[i] = fdt32_to_cpu(pins[i]);
-		if (i > 0)
-			printf(",");
-		printf("%d", sc->sc_ro_pins[i]);
-	}
-	if (i > 0)
-		printf(".");
-	printf("\n");
-
-	return (0);
-}
-
-static int
 bcm_gpio_func_proc(SYSCTL_HANDLER_ARGS)
 {
 	char buf[16];
@@ -545,7 +533,9 @@ bcm_gpio_func_proc(SYSCTL_HANDLER_ARGS)
 	error = sysctl_handle_string(oidp, buf, sizeof(buf), req);
 	if (error != 0 || req->newptr == NULL)
 		return (error);
-
+	/* Ignore changes on read-only pins. */
+	if (bcm_gpio_pin_is_ro(sc, sc_sysctl->pin))
+		return (0);
 	/* Parse the user supplied string and check for a valid pin function. */
 	if (bcm_gpio_str_func(buf, &nfunc) != 0)
 		return (EINVAL);
@@ -595,63 +585,82 @@ bcm_gpio_sysctl_init(struct bcm_gpio_sof
 }
 
 static int
+bcm_gpio_get_ro_pins(struct bcm_gpio_softc *sc, phandle_t node,
+	const char *propname, const char *label)
+{
+	int i, need_comma, npins, range_start, range_stop;
+	pcell_t *pins;
+
+	/* Get the property data. */
+	npins = OF_getencprop_alloc(node, propname, sizeof(*pins),
+	    (void **)&pins);
+	if (npins < 0)
+		return (-1);
+	if (npins == 0) {
+		free(pins, M_OFWPROP);
+		return (0);
+	}
+	for (i = 0; i < npins; i++)
+		sc->sc_ro_pins[i + sc->sc_ro_npins] = pins[i];
+	sc->sc_ro_npins += npins;
+	need_comma = 0;
+	device_printf(sc->sc_dev, "%s pins: ", label);
+	range_start = range_stop = pins[0];
+	for (i = 1; i < npins; i++) {
+		if (pins[i] != range_stop + 1) {
+			if (need_comma)
+				printf(",");
+			if (range_start != range_stop)
+				printf("%d-%d", range_start, range_stop);
+			else
+				printf("%d", range_start);
+			range_start = range_stop = pins[i];
+			need_comma = 1;
+		} else
+			range_stop++;
+	}
+	if (need_comma)
+		printf(",");
+	if (range_start != range_stop)
+		printf("%d-%d.\n", range_start, range_stop);
+	else
+		printf("%d.\n", range_start);
+	free(pins, M_OFWPROP);
+
+	return (0);
+}
+
+static int
 bcm_gpio_get_reserved_pins(struct bcm_gpio_softc *sc)
 {
-	int i, j, len, npins;
-	pcell_t pins[BCM_GPIO_PINS];
+	char *name;
 	phandle_t gpio, node, reserved;
-	char name[32];
+	ssize_t len;
 
 	/* Get read-only pins. */
-	if (bcm_gpio_get_ro_pins(sc) != 0)
-		return (-1);
-
-	/* Find the gpio/reserved pins node to start. */
 	gpio = ofw_bus_get_node(sc->sc_dev);
-	node = OF_child(gpio);
-	
-	/*
-	 * Find reserved node
-	 */
+	if (bcm_gpio_get_ro_pins(sc, gpio, "broadcom,read-only",
+	    "read-only") != 0)
+		return (-1);
+	/* Traverse the GPIO subnodes to find the reserved pins node. */
 	reserved = 0;
+	node = OF_child(gpio);
 	while ((node != 0) && (reserved == 0)) {
-		len = OF_getprop(node, "name", name,
-		    sizeof(name) - 1);
-		name[len] = 0;
+		len = OF_getprop_alloc(node, "name", 1, (void **)&name);
+		if (len == -1)
+			return (-1);
 		if (strcmp(name, "reserved") == 0)
 			reserved = node;
+		free(name, M_OFWPROP);
 		node = OF_peer(node);
 	}
-
 	if (reserved == 0)
 		return (-1);
-
 	/* Get the reserved pins. */
-	len = OF_getproplen(reserved, "broadcom,pins");
-	if (len < 0 || len > sizeof(pins))
-		return (-1);
-
-	if (OF_getprop(reserved, "broadcom,pins", &pins, len) < 0)
+	if (bcm_gpio_get_ro_pins(sc, reserved, "broadcom,pins",
+	    "reserved") != 0)
 		return (-1);
 
-	npins = len / sizeof(pcell_t);
-
-	j = 0;
-	device_printf(sc->sc_dev, "reserved pins: ");
-	for (i = 0; i < npins; i++) {
-		if (i > 0)
-			printf(",");
-		printf("%d", fdt32_to_cpu(pins[i]));
-		/* Some pins maybe already on the list of read-only pins. */
-		if (bcm_gpio_pin_is_ro(sc, fdt32_to_cpu(pins[i])))
-			continue;
-		sc->sc_ro_pins[j++ + sc->sc_ro_npins] = fdt32_to_cpu(pins[i]);
-	}
-	sc->sc_ro_npins += j;
-	if (i > 0)
-		printf(".");
-	printf("\n");
-
 	return (0);
 }
 
@@ -672,34 +681,20 @@ bcm_gpio_probe(device_t dev)
 static int
 bcm_gpio_attach(device_t dev)
 {
-	struct bcm_gpio_softc *sc = device_get_softc(dev);
-	uint32_t func;
-	int i, j, rid;
+	int i, j;
 	phandle_t gpio;
+	struct bcm_gpio_softc *sc;
+	uint32_t func;
 
+ 	sc = device_get_softc(dev);
 	sc->sc_dev = dev;
-
 	mtx_init(&sc->sc_mtx, "bcm gpio", "gpio", MTX_DEF);
-
-	rid = 0;
-	sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
-	    RF_ACTIVE);
-	if (!sc->sc_mem_res) {
-		device_printf(dev, "cannot allocate memory window\n");
-		return (ENXIO);
-	}
-
-	sc->sc_bst = rman_get_bustag(sc->sc_mem_res);
-	sc->sc_bsh = rman_get_bushandle(sc->sc_mem_res);
-
-	rid = 0;
-	sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
-	    RF_ACTIVE);
-	if (!sc->sc_irq_res) {
-		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
-		device_printf(dev, "cannot allocate interrupt\n");
-		return (ENXIO);
+	if (bus_alloc_resources(dev, bcm_gpio_res_spec, sc->sc_res) != 0) {
+		device_printf(dev, "cannot allocate resources\n");
+		goto fail;
 	}
+	sc->sc_bst = rman_get_bustag(sc->sc_res[0]);
+	sc->sc_bsh = rman_get_bushandle(sc->sc_res[0]);
 
 	/* Find our node. */
 	gpio = ofw_bus_get_node(sc->sc_dev);
@@ -717,8 +712,6 @@ bcm_gpio_attach(device_t dev)
 
 	/* Initialize the software controlled pins. */
 	for (i = 0, j = 0; j < BCM_GPIO_PINS; j++) {
-		if (bcm_gpio_pin_is_ro(sc, j))
-			continue;
 		snprintf(sc->sc_gpio_pins[i].gp_name, GPIOMAXNAME,
 		    "pin %d", j);
 		func = bcm_gpio_get_function(sc, j);
@@ -728,19 +721,17 @@ bcm_gpio_attach(device_t dev)
 		i++;
 	}
 	sc->sc_gpio_npins = i;
-
 	bcm_gpio_sysctl_init(sc);
+	sc->sc_busdev = gpiobus_attach_bus(dev);
+	if (sc->sc_busdev == NULL)
+		goto fail;
 
-	device_add_child(dev, "gpioc", -1);
-	device_add_child(dev, "gpiobus", -1);
-
-	return (bus_generic_attach(dev));
+	return (0);
 
 fail:
-	if (sc->sc_irq_res)
-		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
-	if (sc->sc_mem_res)
-		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
+	bus_release_resources(dev, bcm_gpio_res_spec, sc->sc_res);
+	mtx_destroy(&sc->sc_mtx);
+
 	return (ENXIO);
 }
 
@@ -766,6 +757,7 @@ static device_method_t bcm_gpio_methods[
 	DEVMETHOD(device_detach,	bcm_gpio_detach),
 
 	/* GPIO protocol */
+	DEVMETHOD(gpio_get_bus,		bcm_gpio_get_bus),
 	DEVMETHOD(gpio_pin_max,		bcm_gpio_pin_max),
 	DEVMETHOD(gpio_pin_getname,	bcm_gpio_pin_getname),
 	DEVMETHOD(gpio_pin_getflags,	bcm_gpio_pin_getflags),

Modified: projects/powernv/arm/freescale/imx/files.imx6
==============================================================================
--- projects/powernv/arm/freescale/imx/files.imx6	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/arm/freescale/imx/files.imx6	Sat Jan 31 23:24:25 2015	(r278015)
@@ -28,6 +28,9 @@ arm/freescale/imx/imx_machdep.c		standar
 arm/freescale/imx/imx_gpt.c		standard
 arm/freescale/imx/imx_gpio.c		optional gpio
 arm/freescale/imx/imx_i2c.c		optional fsliic
+arm/freescale/imx/imx6_sdma.c		optional sdma
+arm/freescale/imx/imx6_audmux.c		optional sound
+arm/freescale/imx/imx6_ssi.c		optional sound
 
 #
 # Optional devices.
@@ -52,3 +55,19 @@ arm/freescale/imx/imx6_usbphy.c		optiona
 # Not ready yet...
 #
 #arm/freescale/imx/imx51_ipuv3.c  	optional sc
+
+# SDMA firmware
+sdma_fw.c				optional sdma_fw		\
+	compile-with	"${AWK} -f $S/tools/fw_stub.awk sdma-imx6q-to1.bin:sdma_fw -msdma -c${.TARGET}" \
+	no-implicit-rule before-depend local				\
+	clean		"sdma_fw.c"
+sdma-imx6q-to1.fwo			optional sdma_fw		\
+	dependency	"sdma-imx6q-to1.bin"				\
+	compile-with	"${LD} -b binary -d -warn-common -r -d -o ${.TARGET} sdma-imx6q-to1.bin" \
+	no-implicit-rule						\
+	clean		"sdma-imx6q-to1.fwo"
+sdma-imx6q-to1.bin			optional sdma_fw		\
+	dependency	"$S/contrib/dev/imx/sdma-imx6q-to1.bin.uu"	\
+	compile-with	"uudecode < $S/contrib/dev/imx/sdma-imx6q-to1.bin.uu" \
+	no-obj no-implicit-rule						\
+	clean		"sdma-imx6q-to1.bin"

Modified: projects/powernv/arm/freescale/imx/imx6_anatop.c
==============================================================================
--- projects/powernv/arm/freescale/imx/imx6_anatop.c	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/arm/freescale/imx/imx6_anatop.c	Sat Jan 31 23:24:25 2015	(r278015)
@@ -710,6 +710,27 @@ out:
 	return (err);
 }
 
+uint32_t
+pll4_configure_output(uint32_t mfi, uint32_t mfn, uint32_t mfd)
+{
+	int reg;
+
+	/*
+	 * Audio PLL (PLL4).
+	 * PLL output frequency = Fref * (DIV_SELECT + NUM/DENOM)
+	 */
+
+	reg = (IMX6_ANALOG_CCM_PLL_AUDIO_ENABLE);
+	reg &= ~(IMX6_ANALOG_CCM_PLL_AUDIO_DIV_SELECT_MASK << \
+		IMX6_ANALOG_CCM_PLL_AUDIO_DIV_SELECT_SHIFT);
+	reg |= (mfi << IMX6_ANALOG_CCM_PLL_AUDIO_DIV_SELECT_SHIFT);
+	imx6_anatop_write_4(IMX6_ANALOG_CCM_PLL_AUDIO, reg);
+	imx6_anatop_write_4(IMX6_ANALOG_CCM_PLL_AUDIO_NUM, mfn);
+	imx6_anatop_write_4(IMX6_ANALOG_CCM_PLL_AUDIO_DENOM, mfd);
+
+	return (0);
+}
+
 static int
 imx6_anatop_probe(device_t dev)
 {

Modified: projects/powernv/arm/freescale/imx/imx6_anatopreg.h
==============================================================================
--- projects/powernv/arm/freescale/imx/imx6_anatopreg.h	Sat Jan 31 23:16:11 2015	(r278014)
+++ projects/powernv/arm/freescale/imx/imx6_anatopreg.h	Sat Jan 31 23:24:25 2015	(r278015)
@@ -58,6 +58,9 @@
 #define	IMX6_ANALOG_CCM_PLL_SYS_NUM			0x050
 #define	IMX6_ANALOG_CCM_PLL_SYS_DENOM			0x060
 #define	IMX6_ANALOG_CCM_PLL_AUDIO			0x070
+#define	   IMX6_ANALOG_CCM_PLL_AUDIO_ENABLE		  (1 << 13)
+#define	   IMX6_ANALOG_CCM_PLL_AUDIO_DIV_SELECT_SHIFT	  0
+#define	   IMX6_ANALOG_CCM_PLL_AUDIO_DIV_SELECT_MASK	  0x7f

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list