svn commit: r243620 - in user/andre/tcp_workqueue/sys: arm/arm arm/at91 arm/broadcom/bcm2835 arm/conf arm/include arm/mv arm/ti arm/ti/am335x boot/fdt/dts boot/uboot/lib cam/ata cddl/compat/opensol...
Andre Oppermann
andre at FreeBSD.org
Tue Nov 27 19:00:45 UTC 2012
Author: andre
Date: Tue Nov 27 19:00:44 2012
New Revision: 243620
URL: http://svnweb.freebsd.org/changeset/base/243620
Log:
Integrate from HEAD @243619.
Added:
user/andre/tcp_workqueue/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
- copied unchanged from r243613, head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
user/andre/tcp_workqueue/sys/arm/conf/Makefile
- copied unchanged from r243613, head/sys/arm/conf/Makefile
user/andre/tcp_workqueue/sys/arm/conf/NOTES
- copied unchanged from r243613, head/sys/arm/conf/NOTES
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c
- copied unchanged from r243613, head/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c
user/andre/tcp_workqueue/sys/powerpc/wii/locore.S
- copied unchanged from r243613, head/sys/powerpc/wii/locore.S
Modified:
user/andre/tcp_workqueue/sys/arm/arm/cpufunc.c
user/andre/tcp_workqueue/sys/arm/arm/locore.S
user/andre/tcp_workqueue/sys/arm/arm/machdep.c
user/andre/tcp_workqueue/sys/arm/arm/mpcore_timer.c
user/andre/tcp_workqueue/sys/arm/arm/pl310.c
user/andre/tcp_workqueue/sys/arm/at91/files.at91
user/andre/tcp_workqueue/sys/arm/broadcom/bcm2835/bcm2835_fb.c
user/andre/tcp_workqueue/sys/arm/broadcom/bcm2835/bcm2835_systimer.c
user/andre/tcp_workqueue/sys/arm/broadcom/bcm2835/files.bcm2835
user/andre/tcp_workqueue/sys/arm/conf/RPI-B
user/andre/tcp_workqueue/sys/arm/include/cpufunc.h
user/andre/tcp_workqueue/sys/arm/mv/mvreg.h
user/andre/tcp_workqueue/sys/arm/ti/am335x/am335x_dmtimer.c
user/andre/tcp_workqueue/sys/arm/ti/ti_machdep.c
user/andre/tcp_workqueue/sys/boot/fdt/dts/bcm2835-rpi-b.dts
user/andre/tcp_workqueue/sys/boot/uboot/lib/elf_freebsd.c
user/andre/tcp_workqueue/sys/cam/ata/ata_xpt.c
user/andre/tcp_workqueue/sys/cddl/compat/opensolaris/kern/opensolaris_cmn_err.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
user/andre/tcp_workqueue/sys/compat/linux/linux_ioctl.c
user/andre/tcp_workqueue/sys/conf/Makefile.arm
user/andre/tcp_workqueue/sys/conf/NOTES
user/andre/tcp_workqueue/sys/conf/files
user/andre/tcp_workqueue/sys/conf/options.mips
user/andre/tcp_workqueue/sys/contrib/dev/acpica/changes.txt (contents, props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/common/adfile.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/common/adisasm.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/common/dmextern.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/common/dmrestag.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/aslcompile.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/aslcompiler.h
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/aslerror.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/aslfiles.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/aslglobal.h
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/asllisting.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/asllookup.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/aslmain.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/aslstartup.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/dttemplate.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/prutils.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/debugger/dbfileio.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/debugger/dbinput.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/debugger/dbmethod.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/disassembler/dmopcode.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/disassembler/dmresrc.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/executer/exregion.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/namespace/nsutils.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/namespace/nsxfname.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/resources/rscalc.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/resources/rscreate.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/resources/rsdump.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/resources/rslist.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/resources/rsmisc.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/resources/rsxface.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/utilities/utdelete.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/utilities/utresrc.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/utilities/utstate.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/utilities/uttrack.c
user/andre/tcp_workqueue/sys/contrib/dev/acpica/include/acdisasm.h
user/andre/tcp_workqueue/sys/contrib/dev/acpica/include/acmacros.h
user/andre/tcp_workqueue/sys/contrib/dev/acpica/include/acpixf.h
user/andre/tcp_workqueue/sys/contrib/dev/acpica/include/acrestyp.h
user/andre/tcp_workqueue/sys/contrib/dev/acpica/include/acutils.h
user/andre/tcp_workqueue/sys/contrib/octeon-sdk/cvmx-dma-engine.c
user/andre/tcp_workqueue/sys/contrib/octeon-sdk/cvmx-pow.h
user/andre/tcp_workqueue/sys/contrib/octeon-sdk/cvmx-spi.c
user/andre/tcp_workqueue/sys/contrib/octeon-sdk/cvmx-utils.h
user/andre/tcp_workqueue/sys/contrib/octeon-sdk/cvmx-warn.c
user/andre/tcp_workqueue/sys/contrib/octeon-sdk/cvmx.h
user/andre/tcp_workqueue/sys/contrib/octeon-sdk/octeon-model.c
user/andre/tcp_workqueue/sys/contrib/octeon-sdk/octeon-model.h
user/andre/tcp_workqueue/sys/dev/acpica/acpi_cpu.c
user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ah.h
user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c
user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5212/ar5212_beacon.c
user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c
user/andre/tcp_workqueue/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c
user/andre/tcp_workqueue/sys/dev/ath/if_ath_alq.h
user/andre/tcp_workqueue/sys/dev/ath/if_ath_tdma.c
user/andre/tcp_workqueue/sys/dev/ath/if_athvar.h
user/andre/tcp_workqueue/sys/dev/e1000/if_igb.c
user/andre/tcp_workqueue/sys/dev/gpio/gpiobus.c
user/andre/tcp_workqueue/sys/dev/gxemul/cons/gxemul_cons.c
user/andre/tcp_workqueue/sys/dev/md/md.c
user/andre/tcp_workqueue/sys/dev/mmc/mmc.c
user/andre/tcp_workqueue/sys/dev/sound/pci/hda/hdaa.c
user/andre/tcp_workqueue/sys/dev/sound/pcm/buffer.c
user/andre/tcp_workqueue/sys/dev/sound/pcm/sound.c
user/andre/tcp_workqueue/sys/dev/usb/net/if_smsc.c
user/andre/tcp_workqueue/sys/dev/usb/quirk/usb_quirk.c
user/andre/tcp_workqueue/sys/dev/usb/quirk/usb_quirk.h
user/andre/tcp_workqueue/sys/dev/usb/serial/uplcom.c
user/andre/tcp_workqueue/sys/fs/smbfs/smbfs.h
user/andre/tcp_workqueue/sys/fs/smbfs/smbfs_io.c
user/andre/tcp_workqueue/sys/fs/smbfs/smbfs_node.c
user/andre/tcp_workqueue/sys/fs/smbfs/smbfs_node.h
user/andre/tcp_workqueue/sys/fs/smbfs/smbfs_subr.c
user/andre/tcp_workqueue/sys/fs/smbfs/smbfs_vfsops.c
user/andre/tcp_workqueue/sys/fs/smbfs/smbfs_vnops.c
user/andre/tcp_workqueue/sys/kern/capabilities.conf
user/andre/tcp_workqueue/sys/kern/init_sysent.c
user/andre/tcp_workqueue/sys/kern/kern_proc.c
user/andre/tcp_workqueue/sys/kern/kern_shutdown.c
user/andre/tcp_workqueue/sys/kern/kern_sig.c
user/andre/tcp_workqueue/sys/kern/vfs_lookup.c
user/andre/tcp_workqueue/sys/kern/vfs_subr.c
user/andre/tcp_workqueue/sys/kern/vfs_vnops.c
user/andre/tcp_workqueue/sys/kern/vnode_if.src
user/andre/tcp_workqueue/sys/mips/cavium/octeon_machdep.c
user/andre/tcp_workqueue/sys/mips/conf/OCTEON1
user/andre/tcp_workqueue/sys/modules/acpi/acpi/Makefile
user/andre/tcp_workqueue/sys/net/if_ethersubr.c
user/andre/tcp_workqueue/sys/net80211/ieee80211_freebsd.h
user/andre/tcp_workqueue/sys/netinet/sctp_pcb.c
user/andre/tcp_workqueue/sys/netinet/sctp_peeloff.c
user/andre/tcp_workqueue/sys/netinet/sctp_peeloff.h
user/andre/tcp_workqueue/sys/netinet/sctp_usrreq.c
user/andre/tcp_workqueue/sys/netinet/tcp_timer.c
user/andre/tcp_workqueue/sys/powerpc/aim/locore32.S
user/andre/tcp_workqueue/sys/powerpc/aim/mmu_oea.c
user/andre/tcp_workqueue/sys/sys/namei.h
user/andre/tcp_workqueue/sys/sys/param.h
user/andre/tcp_workqueue/sys/sys/vnode.h
user/andre/tcp_workqueue/sys/vm/vm_map.c
user/andre/tcp_workqueue/sys/vm/vm_page.c
Directory Properties:
user/andre/tcp_workqueue/sys/ (props changed)
user/andre/tcp_workqueue/sys/boot/ (props changed)
user/andre/tcp_workqueue/sys/cddl/contrib/opensolaris/ (props changed)
user/andre/tcp_workqueue/sys/conf/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/common/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/compiler/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/debugger/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/disassembler/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/dispatcher/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/executer/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/namespace/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/resources/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/components/utilities/ (props changed)
user/andre/tcp_workqueue/sys/contrib/dev/acpica/include/ (props changed)
user/andre/tcp_workqueue/sys/contrib/octeon-sdk/ (props changed)
Modified: user/andre/tcp_workqueue/sys/arm/arm/cpufunc.c
==============================================================================
--- user/andre/tcp_workqueue/sys/arm/arm/cpufunc.c Tue Nov 27 18:38:50 2012 (r243619)
+++ user/andre/tcp_workqueue/sys/arm/arm/cpufunc.c Tue Nov 27 19:00:44 2012 (r243620)
@@ -74,7 +74,13 @@ __FBSDID("$FreeBSD$");
#include <arm/xscale/i80321/i80321var.h>
#endif
-#if defined(CPU_XSCALE_81342)
+/*
+ * Some definitions in i81342reg.h clash with i80321reg.h.
+ * This only happens for the LINT kernel. As it happens,
+ * we don't need anything from i81342reg.h that we already
+ * got from somewhere else during a LINT compile.
+ */
+#if defined(CPU_XSCALE_81342) && !defined(COMPILING_LINT)
#include <arm/xscale/i8134x/i81342reg.h>
#endif
Modified: user/andre/tcp_workqueue/sys/arm/arm/locore.S
==============================================================================
--- user/andre/tcp_workqueue/sys/arm/arm/locore.S Tue Nov 27 18:38:50 2012 (r243619)
+++ user/andre/tcp_workqueue/sys/arm/arm/locore.S Tue Nov 27 19:00:44 2012 (r243620)
@@ -181,7 +181,7 @@ Lunmapped:
#if defined(CPU_ARM11) || defined(CPU_CORTEXA) || defined(CPU_MV_PJ4B)
orr r0, r0, #CPU_CONTROL_V6_EXTPAGE
#endif
- orr r0, r0, #(CPU_CONTROL_MMU_ENABLE | CPU_CONTROL_DC_ENABLE)
+ orr r0, r0, #(CPU_CONTROL_MMU_ENABLE)
mcr p15, 0, r0, c1, c0, 0
nop
nop
Modified: user/andre/tcp_workqueue/sys/arm/arm/machdep.c
==============================================================================
--- user/andre/tcp_workqueue/sys/arm/arm/machdep.c Tue Nov 27 18:38:50 2012 (r243619)
+++ user/andre/tcp_workqueue/sys/arm/arm/machdep.c Tue Nov 27 19:00:44 2012 (r243620)
@@ -1038,18 +1038,6 @@ print_kenv(void)
}
static void
-print_kernel_section_addr(void)
-{
-
- debugf("kernel image addresses:\n");
- debugf(" kernbase = 0x%08x\n", (uint32_t)kernbase);
- debugf(" _etext (sdata) = 0x%08x\n", (uint32_t)_etext);
- debugf(" _edata = 0x%08x\n", (uint32_t)_edata);
- debugf(" __bss_start = 0x%08x\n", (uint32_t)__bss_start);
- debugf(" _end = 0x%08x\n", (uint32_t)_end);
-}
-
-static void
physmap_init(struct mem_region *availmem_regions, int availmem_regions_sz)
{
int i, j, cnt;
@@ -1344,7 +1332,6 @@ initarm(struct arm_boot_params *abp)
debugf(" arg1 kmdp = 0x%08x\n", (uint32_t)kmdp);
debugf(" boothowto = 0x%08x\n", boothowto);
debugf(" dtbp = 0x%08x\n", (uint32_t)dtbp);
- print_kernel_section_addr();
print_kenv();
env = getenv("kernelname");
Modified: user/andre/tcp_workqueue/sys/arm/arm/mpcore_timer.c
==============================================================================
--- user/andre/tcp_workqueue/sys/arm/arm/mpcore_timer.c Tue Nov 27 18:38:50 2012 (r243619)
+++ user/andre/tcp_workqueue/sys/arm/arm/mpcore_timer.c Tue Nov 27 19:00:44 2012 (r243620)
@@ -128,7 +128,7 @@ static struct arm_tmr_softc *arm_tmr_sc
static timecounter_get_t arm_tmr_get_timecount;
static struct timecounter arm_tmr_timecount = {
- .tc_name = "ARM MPCore Timecouter",
+ .tc_name = "ARM MPCore Timecounter",
.tc_get_timecount = arm_tmr_get_timecount,
.tc_poll_pps = NULL,
.tc_counter_mask = ~0u,
Modified: user/andre/tcp_workqueue/sys/arm/arm/pl310.c
==============================================================================
--- user/andre/tcp_workqueue/sys/arm/arm/pl310.c Tue Nov 27 18:38:50 2012 (r243619)
+++ user/andre/tcp_workqueue/sys/arm/arm/pl310.c Tue Nov 27 19:00:44 2012 (r243620)
@@ -180,9 +180,13 @@ static void
pl310_wbinv_range(vm_paddr_t start, vm_size_t size)
{
+ if (start & g_l2cache_align_mask) {
+ size += start & g_l2cache_align_mask;
+ start &= ~g_l2cache_align_mask;
+ }
if (size & g_l2cache_align_mask) {
size &= ~g_l2cache_align_mask;
- size += g_l2cache_line_size;
+ size += g_l2cache_line_size;
}
#if 1
@@ -217,6 +221,10 @@ static void
pl310_wb_range(vm_paddr_t start, vm_size_t size)
{
+ if (start & g_l2cache_align_mask) {
+ size += start & g_l2cache_align_mask;
+ start &= ~g_l2cache_align_mask;
+ }
if (size & g_l2cache_align_mask) {
size &= ~g_l2cache_align_mask;
size += g_l2cache_line_size;
@@ -235,6 +243,10 @@ static void
pl310_inv_range(vm_paddr_t start, vm_size_t size)
{
+ if (start & g_l2cache_align_mask) {
+ size += start & g_l2cache_align_mask;
+ start &= ~g_l2cache_align_mask;
+ }
if (size & g_l2cache_align_mask) {
size &= ~g_l2cache_align_mask;
size += g_l2cache_line_size;
Modified: user/andre/tcp_workqueue/sys/arm/at91/files.at91
==============================================================================
--- user/andre/tcp_workqueue/sys/arm/at91/files.at91 Tue Nov 27 18:38:50 2012 (r243619)
+++ user/andre/tcp_workqueue/sys/arm/at91/files.at91 Tue Nov 27 19:00:44 2012 (r243620)
@@ -55,4 +55,3 @@ arm/at91/board_tsc4370.c optional at91_b
dev/usb/controller/at91dci.c optional at91_dci
dev/usb/controller/at91dci_atmelarm.c optional at91_dci
dev/usb/controller/ohci_atmelarm.c optional ohci
-dev/usb/controller/ehci_atmelarm.c optional ehci
Modified: user/andre/tcp_workqueue/sys/arm/broadcom/bcm2835/bcm2835_fb.c
==============================================================================
--- user/andre/tcp_workqueue/sys/arm/broadcom/bcm2835/bcm2835_fb.c Tue Nov 27 18:38:50 2012 (r243619)
+++ user/andre/tcp_workqueue/sys/arm/broadcom/bcm2835/bcm2835_fb.c Tue Nov 27 19:00:44 2012 (r243620)
@@ -68,8 +68,35 @@ __FBSDID("$FreeBSD$");
#define BCMFB_FONT_HEIGHT 16
+struct argb {
+ uint8_t a;
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
+};
+
+static struct argb bcmfb_palette[16] = {
+ {0x00, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0xaa},
+ {0x00, 0x00, 0xaa, 0x00},
+ {0x00, 0x00, 0xaa, 0xaa},
+ {0x00, 0xaa, 0x00, 0x00},
+ {0x00, 0xaa, 0x00, 0xaa},
+ {0x00, 0xaa, 0x55, 0x00},
+ {0x00, 0xaa, 0xaa, 0xaa},
+ {0x00, 0x55, 0x55, 0x55},
+ {0x00, 0x55, 0x55, 0xff},
+ {0x00, 0x55, 0xff, 0x55},
+ {0x00, 0x55, 0xff, 0xff},
+ {0x00, 0xff, 0x55, 0x55},
+ {0x00, 0xff, 0x55, 0xff},
+ {0x00, 0xff, 0xff, 0x55},
+ {0x00, 0xff, 0xff, 0xff}
+};
+
#define FB_WIDTH 640
#define FB_HEIGHT 480
+#define FB_DEPTH 24
struct bcm_fb_config {
uint32_t xres;
@@ -107,6 +134,7 @@ struct video_adapter_softc {
unsigned int height;
unsigned int width;
+ unsigned int depth;
unsigned int stride;
unsigned int xmargin;
@@ -126,6 +154,8 @@ static struct video_adapter_softc va_sof
static int bcm_fb_probe(device_t);
static int bcm_fb_attach(device_t);
static void bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err);
+static void bcmfb_update_margins(video_adapter_t *adp);
+static int bcmfb_configure(int);
static void
bcm_fb_init(void *arg)
@@ -134,15 +164,34 @@ bcm_fb_init(void *arg)
struct video_adapter_softc *va_sc = &va_softc;
int err;
volatile struct bcm_fb_config* fb_config = sc->fb_config;
+ phandle_t node;
+ pcell_t cell;
+
+ node = ofw_bus_get_node(sc->dev);
+
+ fb_config->xres = 0;
+ fb_config->yres = 0;
+ fb_config->bpp = 0;
+
+ if ((OF_getprop(node, "broadcom,width", &cell, sizeof(cell))) > 0)
+ fb_config->xres = (int)fdt32_to_cpu(cell);
+ if (fb_config->xres == 0)
+ fb_config->xres = FB_WIDTH;
+
+ if ((OF_getprop(node, "broadcom,height", &cell, sizeof(cell))) > 0)
+ fb_config->yres = (uint32_t)fdt32_to_cpu(cell);
+ if (fb_config->yres == 0)
+ fb_config->yres = FB_HEIGHT;
+
+ if ((OF_getprop(node, "broadcom,depth", &cell, sizeof(cell))) > 0)
+ fb_config->bpp = (uint32_t)fdt32_to_cpu(cell);
+ if (fb_config->bpp == 0)
+ fb_config->bpp = FB_DEPTH;
- /* TODO: replace it with FDT stuff */
- fb_config->xres = FB_WIDTH;
- fb_config->yres = FB_HEIGHT;
fb_config->vxres = 0;
fb_config->vyres = 0;
fb_config->xoffset = 0;
fb_config->yoffset = 0;
- fb_config->bpp = 24;
fb_config->base = 0;
fb_config->pitch = 0;
fb_config->screen_size = 0;
@@ -154,7 +203,7 @@ bcm_fb_init(void *arg)
bus_dmamap_sync(sc->dma_tag, sc->dma_map,
BUS_DMASYNC_POSTREAD);
- if (err == 0) {
+ if (fb_config->base != 0) {
device_printf(sc->dev, "%dx%d(%dx%d@%d,%d) %dbpp\n",
fb_config->xres, fb_config->yres,
fb_config->vxres, fb_config->vyres,
@@ -166,14 +215,19 @@ bcm_fb_init(void *arg)
fb_config->pitch, fb_config->base,
fb_config->screen_size);
- if (fb_config->base) {
- va_sc->fb_addr = (intptr_t)pmap_mapdev(fb_config->base, fb_config->screen_size);
- va_sc->fb_size = fb_config->screen_size;
- va_sc->stride = fb_config->pitch;
- }
+ va_sc->fb_addr = (intptr_t)pmap_mapdev(fb_config->base, fb_config->screen_size);
+ va_sc->fb_size = fb_config->screen_size;
+ va_sc->depth = fb_config->bpp;
+ va_sc->stride = fb_config->pitch;
+
+ va_sc->width = fb_config->xres;
+ va_sc->height = fb_config->yres;
+ bcmfb_update_margins(&va_sc->va);
}
- else
+ else {
device_printf(sc->dev, "Failed to set framebuffer info\n");
+ return;
+ }
config_intrhook_disestablish(&sc->init_hook);
}
@@ -181,7 +235,7 @@ bcm_fb_init(void *arg)
static int
bcm_fb_probe(device_t dev)
{
- int error;
+ int error = 0;
if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-fb"))
return (ENXIO);
@@ -190,10 +244,10 @@ bcm_fb_probe(device_t dev)
error = sc_probe_unit(device_get_unit(dev),
device_get_flags(dev) | SC_AUTODETECT_KBD);
-
if (error != 0)
return (error);
+
return (BUS_PROBE_DEFAULT);
}
@@ -293,12 +347,11 @@ static driver_t bcm_fb_driver = {
sizeof(struct bcmsc_softc),
};
-DRIVER_MODULE(bcm2835fb, simplebus, bcm_fb_driver, bcm_fb_devclass, 0, 0);
+DRIVER_MODULE(bcm2835fb, fdtbus, bcm_fb_driver, bcm_fb_devclass, 0, 0);
/*
* Video driver routines and glue.
*/
-static int bcmfb_configure(int);
static vi_probe_t bcmfb_probe;
static vi_init_t bcmfb_init;
static vi_get_info_t bcmfb_get_info;
@@ -374,22 +427,62 @@ RENDERER_MODULE(bcmfb, gfb_set);
static uint16_t bcmfb_static_window[ROW*COL];
extern u_char dflt_font_16[];
+/*
+ * Update videoadapter settings after changing resolution
+ */
+static void
+bcmfb_update_margins(video_adapter_t *adp)
+{
+ struct video_adapter_softc *sc;
+ video_info_t *vi;
+
+ sc = (struct video_adapter_softc *)adp;
+ vi = &adp->va_info;
+
+ sc->xmargin = (sc->width - (vi->vi_width * vi->vi_cwidth)) / 2;
+ sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight))/2;
+}
+
static int
bcmfb_configure(int flags)
{
- struct video_adapter_softc *sc;
+ struct video_adapter_softc *va_sc;
+
+ va_sc = &va_softc;
+ phandle_t display, root;
+ pcell_t cell;
- sc = &va_softc;
+ if (va_sc->initialized)
+ return (0);
- if (sc->initialized)
- return 0;
+ va_sc->width = 0;
+ va_sc->height = 0;
+
+ /*
+ * It seems there is no way to let syscons framework know
+ * that framebuffer resolution has changed. So just try
+ * to fetch data from FDT and go with defaults if failed
+ */
+ root = OF_finddevice("/");
+ if ((root != 0) &&
+ (display = fdt_find_compatible(root, "broadcom,bcm2835-fb", 1))) {
+ if ((OF_getprop(display, "broadcom,width",
+ &cell, sizeof(cell))) > 0)
+ va_sc->width = (int)fdt32_to_cpu(cell);
+
+ if ((OF_getprop(display, "broadcom,height",
+ &cell, sizeof(cell))) > 0)
+ va_sc->height = (int)fdt32_to_cpu(cell);
+ }
- sc->height = FB_HEIGHT;
- sc->width = FB_WIDTH;
+ if (va_sc->width == 0)
+ va_sc->width = FB_WIDTH;
+ if (va_sc->height == 0)
+ va_sc->height = FB_HEIGHT;
- bcmfb_init(0, &sc->va, 0);
+ bcmfb_init(0, &va_sc->va, 0);
- sc->initialized = 1;
+ va_sc->initialized = 1;
return (0);
}
@@ -415,6 +508,7 @@ bcmfb_init(int unit, video_adapter_t *ad
sc->font = dflt_font_16;
vi->vi_cheight = BCMFB_FONT_HEIGHT;
vi->vi_cwidth = 8;
+
vi->vi_width = sc->width/8;
vi->vi_height = sc->height/vi->vi_cheight;
@@ -429,6 +523,7 @@ bcmfb_init(int unit, video_adapter_t *ad
sc->xmargin = (sc->width - (vi->vi_width * vi->vi_cwidth)) / 2;
sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight))/2;
+
adp->va_window = (vm_offset_t) bcmfb_static_window;
adp->va_flags |= V_ADP_FONT /* | V_ADP_COLOR | V_ADP_MODECHANGE */;
@@ -541,6 +636,12 @@ static int
bcmfb_blank_display(video_adapter_t *adp, int mode)
{
+ struct video_adapter_softc *sc;
+
+ sc = (struct video_adapter_softc *)adp;
+ if (sc && sc->fb_addr)
+ memset((void*)sc->fb_addr, 0, sc->fb_size);
+
return (0);
}
@@ -638,6 +739,7 @@ bcmfb_putc(video_adapter_t *adp, vm_offs
uint8_t *addr;
u_char *p;
uint8_t fg, bg, color;
+ uint16_t rgb;
sc = (struct video_adapter_softc *)adp;
@@ -651,11 +753,8 @@ bcmfb_putc(video_adapter_t *adp, vm_offs
+ (row + sc->ymargin)*(sc->stride)
+ 3 * (col + sc->xmargin);
- /*
- * FIXME: hardcoded
- */
- bg = 0x00;
- fg = 0x80;
+ fg = a & 0xf ;
+ bg = (a >> 8) & 0xf;
for (i = 0; i < BCMFB_FONT_HEIGHT; i++) {
for (j = 0, k = 7; j < 8; j++, k--) {
@@ -664,9 +763,28 @@ bcmfb_putc(video_adapter_t *adp, vm_offs
else
color = fg;
- addr[3*j] = color;
- addr[3*j+1] = color;
- addr[3*j+2] = color;
+ switch (sc->depth) {
+ case 32:
+ addr[4*j+0] = bcmfb_palette[color].r;
+ addr[4*j+1] = bcmfb_palette[color].g;
+ addr[4*j+2] = bcmfb_palette[color].b;
+ addr[4*j+3] = bcmfb_palette[color].a;
+ break;
+ case 24:
+ addr[3*j] = bcmfb_palette[color].r;
+ addr[3*j+1] = bcmfb_palette[color].g;
+ addr[3*j+2] = bcmfb_palette[color].b;
+ break;
+ case 16:
+ rgb = (bcmfb_palette[color].r >> 3) << 10;
+ rgb |= (bcmfb_palette[color].g >> 3) << 5;
+ rgb |= (bcmfb_palette[color].b >> 3);
+ addr[2*j] = (rgb >> 8) & 0xff;
+ addr[2*j + 1] = rgb & 0xff;
+ default:
+ /* Not supported yet */
+ break;
+ }
}
addr += (sc->stride);
Copied: user/andre/tcp_workqueue/sys/arm/broadcom/bcm2835/bcm2835_gpio.c (from r243613, head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/andre/tcp_workqueue/sys/arm/broadcom/bcm2835/bcm2835_gpio.c Tue Nov 27 19:00:44 2012 (r243620, copy of r243613, head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c)
@@ -0,0 +1,656 @@
+/*-
+ * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo at freebsd.org>
+ * Copyright (c) 2012 Luiz Otavio O Souza.
+ * 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 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.
+ *
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/rman.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/gpio.h>
+
+#include <machine/bus.h>
+#include <machine/cpu.h>
+#include <machine/cpufunc.h>
+#include <machine/resource.h>
+#include <machine/fdt.h>
+#include <machine/frame.h>
+#include <machine/intr.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include "gpio_if.h"
+
+#undef DEBUG
+
+#ifdef DEBUG
+#define dprintf(fmt, args...) do { printf("%s(): ", __func__); \
+ printf(fmt,##args); } while (0)
+#else
+#define dprintf(fmt, args...)
+#endif
+
+#define BCM_GPIO_PINS 54
+#define BCM_GPIO_DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT | \
+ GPIO_PIN_PULLUP | GPIO_PIN_PULLDOWN)
+
+struct bcm_gpio_softc {
+ device_t sc_dev;
+ struct mtx sc_mtx;
+ struct resource * sc_mem_res;
+ struct resource * sc_irq_res;
+ bus_space_tag_t sc_bst;
+ bus_space_handle_t sc_bsh;
+ void * sc_intrhand;
+ int sc_gpio_npins;
+ int sc_ro_npins;
+ int sc_ro_pins[BCM_GPIO_PINS];
+ struct gpio_pin sc_gpio_pins[BCM_GPIO_PINS];
+};
+
+enum bcm_gpio_fsel {
+ BCM_GPIO_INPUT,
+ BCM_GPIO_OUTPUT,
+ BCM_GPIO_ALT5,
+ BCM_GPIO_ALT4,
+ BCM_GPIO_ALT0,
+ BCM_GPIO_ALT1,
+ BCM_GPIO_ALT2,
+ BCM_GPIO_ALT3,
+};
+
+enum bcm_gpio_pud {
+ BCM_GPIO_NONE,
+ BCM_GPIO_PULLDOWN,
+ BCM_GPIO_PULLUP,
+};
+
+#define BCM_GPIO_LOCK(_sc) mtx_lock(&_sc->sc_mtx)
+#define BCM_GPIO_UNLOCK(_sc) mtx_unlock(&_sc->sc_mtx)
+
+#define BCM_GPIO_GPFSEL(_bank) 0x00 + _bank * 4
+#define BCM_GPIO_GPSET(_bank) 0x1c + _bank * 4
+#define BCM_GPIO_GPCLR(_bank) 0x28 + _bank * 4
+#define BCM_GPIO_GPLEV(_bank) 0x34 + _bank * 4
+#define BCM_GPIO_GPPUD(_bank) 0x94
+#define BCM_GPIO_GPPUDCLK(_bank) 0x98 + _bank * 4
+
+#define BCM_GPIO_WRITE(_sc, _off, _val) \
+ bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val)
+#define BCM_GPIO_READ(_sc, _off) \
+ bus_space_read_4(_sc->sc_bst, _sc->sc_bsh, _off)
+
+static int
+bcm_gpio_pin_is_ro(struct bcm_gpio_softc *sc, int pin)
+{
+ int i;
+
+ for (i = 0; i < sc->sc_ro_npins; i++)
+ if (pin == sc->sc_ro_pins[i])
+ return (1);
+ return (0);
+}
+
+static uint32_t
+bcm_gpio_get_function(struct bcm_gpio_softc *sc, uint32_t pin)
+{
+ uint32_t bank, data, offset;
+
+ /* Five banks, 10 pins per bank, 3 bits per pin. */
+ bank = pin / 10;
+ offset = (pin - bank * 10) * 3;
+
+ BCM_GPIO_LOCK(sc);
+ data = (BCM_GPIO_READ(sc, BCM_GPIO_GPFSEL(bank)) >> offset) & 7;
+ BCM_GPIO_UNLOCK(sc);
+
+#ifdef DEBUG
+ device_printf(sc->sc_dev, "pin %d function: ", pin);
+ switch (data) {
+ case BCM_GPIO_INPUT:
+ printf("input\n");
+ break;
+ case BCM_GPIO_OUTPUT:
+ printf("output\n");
+ break;
+ case BCM_GPIO_ALT0:
+ printf("alt0\n");
+ break;
+ case BCM_GPIO_ALT1:
+ printf("alt1\n");
+ break;
+ case BCM_GPIO_ALT2:
+ printf("alt2\n");
+ break;
+ case BCM_GPIO_ALT3:
+ printf("alt3\n");
+ break;
+ case BCM_GPIO_ALT4:
+ printf("alt4\n");
+ break;
+ case BCM_GPIO_ALT5:
+ printf("alt5\n");
+ break;
+ }
+#endif
+
+ switch (data) {
+ case BCM_GPIO_INPUT:
+ return (GPIO_PIN_INPUT);
+ case BCM_GPIO_OUTPUT:
+ return (GPIO_PIN_OUTPUT);
+ }
+
+ return (0);
+}
+
+static void
+bcm_gpio_set_function(struct bcm_gpio_softc *sc, uint32_t pin, uint32_t f)
+{
+ uint32_t bank, data, offset;
+
+ /* Five banks, 10 pins per bank, 3 bits per pin. */
+ bank = pin / 10;
+ offset = (pin - bank * 10) * 3;
+
+ BCM_GPIO_LOCK(sc);
+ data = BCM_GPIO_READ(sc, BCM_GPIO_GPFSEL(bank));
+ data &= ~(7 << offset);
+ data |= (f << offset);
+ BCM_GPIO_WRITE(sc, BCM_GPIO_GPFSEL(bank), data);
+ BCM_GPIO_UNLOCK(sc);
+}
+
+static void
+bcm_gpio_set_pud(struct bcm_gpio_softc *sc, uint32_t pin, uint32_t state)
+{
+ uint32_t bank, offset;
+
+ bank = pin / 32;
+ offset = pin - 32 * bank;
+
+ BCM_GPIO_LOCK(sc);
+ BCM_GPIO_WRITE(sc, BCM_GPIO_GPPUD(0), state);
+ DELAY(10);
+ BCM_GPIO_WRITE(sc, BCM_GPIO_GPPUDCLK(bank), (1 << offset));
+ DELAY(10);
+ BCM_GPIO_WRITE(sc, BCM_GPIO_GPPUD(0), 0);
+ BCM_GPIO_WRITE(sc, BCM_GPIO_GPPUDCLK(bank), 0);
+ BCM_GPIO_UNLOCK(sc);
+}
+
+static void
+bcm_gpio_pin_configure(struct bcm_gpio_softc *sc, struct gpio_pin *pin,
+ unsigned int flags)
+{
+
+ /*
+ * Manage input/output.
+ */
+ if (flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) {
+ pin->gp_flags &= ~(GPIO_PIN_INPUT|GPIO_PIN_OUTPUT);
+ if (flags & GPIO_PIN_OUTPUT) {
+ pin->gp_flags |= GPIO_PIN_OUTPUT;
+ bcm_gpio_set_function(sc, pin->gp_pin,
+ BCM_GPIO_OUTPUT);
+ } else {
+ pin->gp_flags |= GPIO_PIN_INPUT;
+ bcm_gpio_set_function(sc, pin->gp_pin,
+ BCM_GPIO_INPUT);
+ }
+ }
+
+ /* Manage Pull-up/pull-down. */
+ pin->gp_flags &= ~(GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN);
+ if (flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) {
+ if (flags & GPIO_PIN_PULLUP) {
+ pin->gp_flags |= GPIO_PIN_PULLUP;
+ bcm_gpio_set_pud(sc, pin->gp_pin, BCM_GPIO_PULLUP);
+ } else {
+ pin->gp_flags |= GPIO_PIN_PULLDOWN;
+ bcm_gpio_set_pud(sc, pin->gp_pin, BCM_GPIO_PULLDOWN);
+ }
+ } else
+ bcm_gpio_set_pud(sc, pin->gp_pin, BCM_GPIO_NONE);
+}
+
+static int
+bcm_gpio_pin_max(device_t dev, int *maxpin)
+{
+
+ *maxpin = BCM_GPIO_PINS - 1;
+ return (0);
+}
+
+static int
+bcm_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps)
+{
+ struct bcm_gpio_softc *sc = device_get_softc(dev);
+ int i;
+
+ for (i = 0; i < sc->sc_gpio_npins; i++) {
+ if (sc->sc_gpio_pins[i].gp_pin == pin)
+ break;
+ }
+
+ if (i >= sc->sc_gpio_npins)
+ return (EINVAL);
+
+ BCM_GPIO_LOCK(sc);
+ *caps = sc->sc_gpio_pins[i].gp_caps;
+ BCM_GPIO_UNLOCK(sc);
+
+ return (0);
+}
+
+static int
+bcm_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags)
+{
+ struct bcm_gpio_softc *sc = device_get_softc(dev);
+ int i;
+
+ for (i = 0; i < sc->sc_gpio_npins; i++) {
+ if (sc->sc_gpio_pins[i].gp_pin == pin)
+ break;
+ }
+
+ if (i >= sc->sc_gpio_npins)
+ return (EINVAL);
+
+ BCM_GPIO_LOCK(sc);
+ *flags = sc->sc_gpio_pins[i].gp_flags;
+ BCM_GPIO_UNLOCK(sc);
+
+ return (0);
+}
+
+static int
+bcm_gpio_pin_getname(device_t dev, uint32_t pin, char *name)
+{
+ struct bcm_gpio_softc *sc = device_get_softc(dev);
+ int i;
+
+ for (i = 0; i < sc->sc_gpio_npins; i++) {
+ if (sc->sc_gpio_pins[i].gp_pin == pin)
+ break;
+ }
+
+ if (i >= sc->sc_gpio_npins)
+ return (EINVAL);
+
+ BCM_GPIO_LOCK(sc);
+ memcpy(name, sc->sc_gpio_pins[i].gp_name, GPIOMAXNAME);
+ BCM_GPIO_UNLOCK(sc);
+
+ return (0);
+}
+
+static int
+bcm_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
+{
+ struct bcm_gpio_softc *sc = device_get_softc(dev);
+ int i;
+
+ for (i = 0; i < sc->sc_gpio_npins; i++) {
+ if (sc->sc_gpio_pins[i].gp_pin == pin)
+ break;
+ }
+
+ if (i >= sc->sc_gpio_npins)
+ return (EINVAL);
+
+ /* We never touch on read-only/reserved pins. */
+ if (bcm_gpio_pin_is_ro(sc, pin))
+ return (EINVAL);
+
+ /* Filter out unwanted flags. */
+ if ((flags &= sc->sc_gpio_pins[i].gp_caps) != flags)
+ return (EINVAL);
+
+ /* Can't mix input/output together. */
+ if ((flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) ==
+ (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT))
+ return (EINVAL);
+
+ /* Can't mix pull-up/pull-down together. */
+ if ((flags & (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN)) ==
+ (GPIO_PIN_PULLUP|GPIO_PIN_PULLDOWN))
+ return (EINVAL);
+
+ bcm_gpio_pin_configure(sc, &sc->sc_gpio_pins[i], flags);
+
+ return (0);
+}
+
+static int
+bcm_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value)
+{
+ struct bcm_gpio_softc *sc = device_get_softc(dev);
+ uint32_t bank, offset;
+ int i;
+
+ for (i = 0; i < sc->sc_gpio_npins; i++) {
+ if (sc->sc_gpio_pins[i].gp_pin == pin)
+ break;
+ }
+
+ if (i >= sc->sc_gpio_npins)
+ return (EINVAL);
+
+ /* We never write to read-only/reserved pins. */
+ if (bcm_gpio_pin_is_ro(sc, pin))
+ return (EINVAL);
+
+ bank = pin / 32;
+ offset = pin - 32 * bank;
+
+ BCM_GPIO_LOCK(sc);
+ if (value)
+ BCM_GPIO_WRITE(sc, BCM_GPIO_GPSET(bank), (1 << offset));
+ else
+ BCM_GPIO_WRITE(sc, BCM_GPIO_GPCLR(bank), (1 << offset));
+ BCM_GPIO_UNLOCK(sc);
+
+ return (0);
+}
+
+static int
+bcm_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val)
+{
+ struct bcm_gpio_softc *sc = device_get_softc(dev);
+ uint32_t bank, offset, reg_data;
+ int i;
+
+ for (i = 0; i < sc->sc_gpio_npins; i++) {
+ if (sc->sc_gpio_pins[i].gp_pin == pin)
+ break;
+ }
+
+ if (i >= sc->sc_gpio_npins)
+ return (EINVAL);
+
+ bank = pin / 32;
+ offset = pin - 32 * bank;
+
+ BCM_GPIO_LOCK(sc);
+ reg_data = BCM_GPIO_READ(sc, BCM_GPIO_GPLEV(bank));
+ BCM_GPIO_UNLOCK(sc);
+ *val = (reg_data & (1 << offset)) ? 1 : 0;
+
+ return (0);
+}
+
+static int
+bcm_gpio_pin_toggle(device_t dev, uint32_t pin)
+{
+ struct bcm_gpio_softc *sc = device_get_softc(dev);
+ uint32_t bank, data, offset;
+ int i;
+
+ for (i = 0; i < sc->sc_gpio_npins; i++) {
+ if (sc->sc_gpio_pins[i].gp_pin == pin)
+ break;
+ }
+
+ if (i >= sc->sc_gpio_npins)
+ return (EINVAL);
+
+ /* We never write to read-only/reserved pins. */
+ if (bcm_gpio_pin_is_ro(sc, pin))
+ return (EINVAL);
+
+ bank = pin / 32;
+ offset = pin - 32 * bank;
+
+ BCM_GPIO_LOCK(sc);
+ data = BCM_GPIO_READ(sc, BCM_GPIO_GPLEV(bank));
+ if (data & (1 << offset))
+ BCM_GPIO_WRITE(sc, BCM_GPIO_GPCLR(bank), (1 << offset));
+ else
+ BCM_GPIO_WRITE(sc, BCM_GPIO_GPSET(bank), (1 << offset));
+ BCM_GPIO_UNLOCK(sc);
+
+ return (0);
+}
+
+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_get_reserved_pins(struct bcm_gpio_softc *sc)
+{
+ int i, j, len, npins;
+ pcell_t pins[BCM_GPIO_PINS];
+ phandle_t gpio, node, reserved;
+ char name[32];
+
+ /* 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
+ */
+ reserved = 0;
+ while ((node != 0) && (reserved == 0)) {
+ len = OF_getprop(node, "name", name,
+ sizeof(name) - 1);
+ name[len] = 0;
+ if (strcmp(name, "reserved") == 0)
+ reserved = node;
+ 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)
+ 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);
+}
+
+static int
+bcm_gpio_probe(device_t dev)
+{
+ if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-gpio"))
+ return (ENXIO);
+
+ device_set_desc(dev, "BCM2708/2835 GPIO controller");
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+bcm_gpio_attach(device_t dev)
+{
+ struct bcm_gpio_softc *sc = device_get_softc(dev);
+ int i, j, rid;
+ phandle_t gpio;
+
+ 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);
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-user
mailing list