Sat Mar 21 01:17:00 2015 UTC ()
Basic framebuffer console support. Work in progress.


(jmcneill)
diff -r0 -r1.1 src/sys/arch/arm/amlogic/amlogic_canvasreg.h
diff -r0 -r1.1 src/sys/arch/arm/amlogic/amlogic_genfb.c
diff -r0 -r1.1 src/sys/arch/arm/amlogic/amlogic_hdmireg.h
diff -r0 -r1.1 src/sys/arch/arm/amlogic/amlogic_vpureg.h
diff -r1.6 -r1.7 src/sys/arch/arm/amlogic/amlogic_io.c
diff -r1.8 -r1.9 src/sys/arch/arm/amlogic/amlogic_reg.h
diff -r1.7 -r1.8 src/sys/arch/arm/amlogic/amlogic_var.h
diff -r1.7 -r1.8 src/sys/arch/arm/amlogic/files.amlogic
diff -r1.16 -r1.17 src/sys/arch/evbarm/amlogic/amlogic_machdep.c
diff -r1.11 -r1.12 src/sys/arch/evbarm/conf/ODROID-C1

File Added: src/sys/arch/arm/amlogic/Attic/amlogic_canvasreg.h
/* $NetBSD: amlogic_canvasreg.h,v 1.1 2015/03/21 01:17:00 jmcneill Exp $ */

/*-
 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
 * 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 _ARM_AMLOGIC_CANVASREG_H
#define _ARM_AMLOGIC_CANVASREG_H

#define CANVAS_REG(n)	((n) << 2)

#define DC_CAV_LUT_DATAL_REG	CANVAS_REG(0x12)
#define DC_CAV_LUT_DATAH_REG	CANVAS_REG(0x13)
#define DC_CAV_LUT_ADDR_REG	CANVAS_REG(0x14)

#define DC_CAV_LUT_DATAL_FBADDR		__BITS(28,0)
#define DC_CAV_LUT_DATAL_WIDTH_L	__BITS(31,29)

#define DC_CAV_LUT_DATAH_BLKMODE	__BITS(25,24)
#define DC_CAV_LUT_DATAH_BLKMODE_LINEAR	0
#define DC_CAV_LUT_DATAH_BLKMODE_32X32	1
#define DC_CAV_LUT_DATAH_BLKMODE_64X64	2
#define DC_CAV_LUT_DATAH_YWRAP		__BIT(23)
#define DC_CAV_LUT_DATAH_XWRAP		__BIT(22)
#define DC_CAV_LUT_DATAH_HEIGHT		__BITS(21,9)
#define DC_CAV_LUT_DATAH_WIDTH_H	__BITS(8,0)

#define DC_CAV_LUT_ADDR_WR_EN		__BIT(9)
#define DC_CAV_LUT_ADDR_RD_EN		__BIT(8)
#define DC_CAV_LUT_ADDR_INDEX		__BITS(2,0)

#endif /* _ARM_AMLOGIC_CANVASREG_H */

File Added: src/sys/arch/arm/amlogic/Attic/amlogic_genfb.c
/* $NetBSD: amlogic_genfb.c,v 1.1 2015/03/21 01:17:00 jmcneill Exp $ */

/*-
 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
 * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
 */

/*
 * Generic framebuffer console driver
 */

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: amlogic_genfb.c,v 1.1 2015/03/21 01:17:00 jmcneill Exp $");

#include <sys/param.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/bus.h>
#include <sys/kmem.h>

#include <arm/amlogic/amlogic_reg.h>
#include <arm/amlogic/amlogic_var.h>
#include <arm/amlogic/amlogic_canvasreg.h>
#include <arm/amlogic/amlogic_vpureg.h>
#include <arm/amlogic/amlogic_hdmireg.h>

#include <dev/wsfb/genfbvar.h>

/* Map CEA-861-D video code (VIC) to framebuffer dimensions */
static const struct amlogic_genfb_vic2mode {
	u_int vic;
	u_int width;
	u_int height;
} amlogic_genfb_modes[] = {
	{ 1, 640, 480 },
	{ 2, 720, 480 },
	{ 3, 720, 480 },
	{ 4, 1280, 720 },
	{ 5, 1920, 1080 },
	{ 16, 1920, 1080 },
	{ 17, 720, 576 },
	{ 18, 720, 576 },
	{ 19, 1280, 720 },
	{ 20, 1920, 1080 },
	{ 31, 1920, 1080 },
	{ 32, 1920, 1080 },
	{ 33, 1920, 1080 },
	{ 34, 1920, 1080 },
	{ 39, 1920, 1080 },
};

struct amlogic_genfb_softc {
	struct genfb_softc	sc_gen;
	bus_space_tag_t		sc_bst;
	bus_space_handle_t	sc_bsh;
	bus_space_handle_t	sc_hdmi_bsh;
	bus_space_handle_t	sc_vpu_bsh;
	bus_dma_tag_t		sc_dmat;

	bus_dma_segment_t	sc_dmasegs[1];
	bus_size_t		sc_dmasize;
	bus_dmamap_t		sc_dmamap;
	void			*sc_dmap;

	uint32_t		sc_wstype;
};

static int	amlogic_genfb_match(device_t, cfdata_t, void *);
static void	amlogic_genfb_attach(device_t, device_t, void *);

static int	amlogic_genfb_ioctl(void *, void *, u_long, void *, int, lwp_t *);
static paddr_t	amlogic_genfb_mmap(void *, void *, off_t, int);
static bool	amlogic_genfb_shutdown(device_t, int);

static void	amlogic_genfb_probe(struct amlogic_genfb_softc *);
static int	amlogic_genfb_alloc_videomem(struct amlogic_genfb_softc *);

void		amlogic_genfb_set_console_dev(device_t);
void		amlogic_genfb_ddb_trap_callback(int);

static device_t amlogic_genfb_console_dev = NULL;

CFATTACH_DECL_NEW(amlogic_genfb, sizeof(struct amlogic_genfb_softc),
    amlogic_genfb_match, amlogic_genfb_attach, NULL, NULL);

static inline uint32_t
amlogic_genfb_hdmi_read_4(struct amlogic_genfb_softc *sc, uint32_t addr)
{
	bus_space_write_4(sc->sc_bst, sc->sc_hdmi_bsh, HDMI_ADDR_REG, addr);
	bus_space_write_4(sc->sc_bst, sc->sc_hdmi_bsh, HDMI_ADDR_REG, addr);
	return bus_space_read_4(sc->sc_bst, sc->sc_hdmi_bsh, HDMI_DATA_REG);
}

static inline void
amlogic_genfb_hdmi_write_4(struct amlogic_genfb_softc *sc, uint32_t addr,
    uint32_t data)
{
	bus_space_write_4(sc->sc_bst, sc->sc_hdmi_bsh, HDMI_ADDR_REG, addr);
	bus_space_write_4(sc->sc_bst, sc->sc_hdmi_bsh, HDMI_ADDR_REG, addr);
	bus_space_write_4(sc->sc_bst, sc->sc_hdmi_bsh, HDMI_DATA_REG, data);
}

#define HDMI_READ	amlogic_genfb_hdmi_read_4
#define HDMI_WRITE	amlogic_genfb_hdmi_write_4

#define VPU_READ(sc, reg) \
    bus_space_read_4((sc)->sc_bst, (sc)->sc_vpu_bsh, (reg))
#define VPU_WRITE(sc, reg, val) \
    bus_space_write_4((sc)->sc_bst, (sc)->sc_vpu_bsh, (reg), (val))

static int
amlogic_genfb_match(device_t parent, cfdata_t match, void *aux)
{
	return 1;
}

static void
amlogic_genfb_attach(device_t parent, device_t self, void *aux)
{
	struct amlogic_genfb_softc *sc = device_private(self);
	struct amlogicio_attach_args * const aio = aux;
	const struct amlogic_locators * const loc = &aio->aio_loc;
	prop_dictionary_t dict = device_properties(self);
	static const struct genfb_ops zero_ops;
	struct genfb_ops ops = zero_ops;
	bool is_console = false;

	sc->sc_gen.sc_dev = self;
	sc->sc_bst = aio->aio_core_bst;
	sc->sc_dmat = aio->aio_dmat;
	bus_space_subregion(aio->aio_core_bst, aio->aio_bsh,
	    loc->loc_offset, loc->loc_size, &sc->sc_bsh);
	bus_space_subregion(aio->aio_core_bst, aio->aio_bsh,
	    AMLOGIC_HDMI_OFFSET, AMLOGIC_HDMI_SIZE, &sc->sc_hdmi_bsh);
	bus_space_subregion(aio->aio_core_bst, aio->aio_bsh,
	    AMLOGIC_VPU_OFFSET, AMLOGIC_VPU_SIZE, &sc->sc_vpu_bsh);

	amlogic_genfb_probe(sc);

	sc->sc_wstype = WSDISPLAY_TYPE_MESON;
	prop_dictionary_get_bool(dict, "is_console", &is_console);

	genfb_init(&sc->sc_gen);

	if (sc->sc_gen.sc_width == 0 ||
	    sc->sc_gen.sc_fbsize == 0) {
		aprint_normal(": disabled\n");
		return;
	}

	pmf_device_register1(self, NULL, NULL, amlogic_genfb_shutdown);

	memset(&ops, 0, sizeof(ops));
	ops.genfb_ioctl = amlogic_genfb_ioctl;
	ops.genfb_mmap = amlogic_genfb_mmap;

	aprint_naive("\n");

	if (is_console)
		aprint_normal(": switching to framebuffer console\n");
	else
		aprint_normal("\n");

	genfb_attach(&sc->sc_gen, &ops);
}

static int
amlogic_genfb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l)
{
	struct amlogic_genfb_softc *sc = v;
	struct wsdisplayio_bus_id *busid;

	switch (cmd) {
	case WSDISPLAYIO_GTYPE:
		*(u_int *)data = sc->sc_wstype;
		return 0;
	case WSDISPLAYIO_GET_BUSID:
		busid = data;
		busid->bus_type = WSDISPLAYIO_BUS_SOC;
		return 0;
	case WSDISPLAYIO_GET_FBINFO:
		{
			struct wsdisplayio_fbinfo *fbi = data;
			struct rasops_info *ri = &sc->sc_gen.vd.active->scr_ri;
			int ret;

			ret = wsdisplayio_get_fbinfo(ri, fbi);
			fbi->fbi_flags |= WSFB_VRAM_IS_RAM;
			return ret;
		}
	default:
		return EPASSTHROUGH;
	}
}

static paddr_t
amlogic_genfb_mmap(void *v, void *vs, off_t offset, int prot)
{
	struct amlogic_genfb_softc *sc = v;

	if (offset < 0 || offset >= sc->sc_dmasegs[0].ds_len)
		return -1;

	return bus_dmamem_mmap(sc->sc_dmat, sc->sc_dmasegs, 1,
	    offset, prot, BUS_DMA_PREFETCHABLE);
}

static bool
amlogic_genfb_shutdown(device_t self, int flags)
{
	genfb_enable_polling(self);
	return true;
}

static void
amlogic_genfb_probe(struct amlogic_genfb_softc *sc)
{
	prop_dictionary_t cfg = device_properties(sc->sc_gen.sc_dev);
	u_int width = 0, height = 0, i;
	uint32_t datal, datah, addr;
	uint32_t w1, w2, w3, w4;
	int error;

	datal = bus_space_read_4(sc->sc_bst, sc->sc_bsh, DC_CAV_LUT_DATAL_REG);
	datah = bus_space_read_4(sc->sc_bst, sc->sc_bsh, DC_CAV_LUT_DATAH_REG);
	addr = bus_space_read_4(sc->sc_bst, sc->sc_bsh, DC_CAV_LUT_ADDR_REG);

	w1 = VPU_READ(sc, VIU_OSD2_BLK0_CFG_W1_REG);
	w2 = VPU_READ(sc, VIU_OSD2_BLK0_CFG_W2_REG);
	w3 = VPU_READ(sc, VIU_OSD2_BLK0_CFG_W3_REG);
	w4 = VPU_READ(sc, VIU_OSD2_BLK0_CFG_W4_REG);

#if 0
	const u_int w = (__SHIFTOUT(datal, DC_CAV_LUT_DATAL_WIDTH_L) |
	    (__SHIFTOUT(datah, DC_CAV_LUT_DATAH_WIDTH_H) << 3)) << 3;
	const u_int h = __SHIFTOUT(datah, DC_CAV_LUT_DATAH_HEIGHT);
#endif

	/* VIC is in AVI InfoFrame PB4. */
	const uint32_t vic = HDMI_READ(sc, HDMITX_AVI_INFO_ADDR + 4) & 0x7f;

	for (i = 0; i < __arraycount(amlogic_genfb_modes); i++) {
		if (amlogic_genfb_modes[i].vic == vic) {
			aprint_debug(" [HDMI VIC %d]", vic);
			width = amlogic_genfb_modes[i].width;
			height = amlogic_genfb_modes[i].height;
		}
	}

	if (width == 0 || height == 0) {
		aprint_error(" [UNSUPPORTED HDMI VIC %d]", vic);
		return;
	}

	const uint32_t fbsize = width * height * 3;
	sc->sc_dmasize = (fbsize + 3) & ~3;

	error = amlogic_genfb_alloc_videomem(sc);
	if (error == 0) {
		const paddr_t pa = sc->sc_dmamap->dm_segs[0].ds_addr;
		const uint32_t w = width * 3;
		const uint32_t h = height;

		datal &= ~DC_CAV_LUT_DATAL_WIDTH_L;
		datal |= __SHIFTIN(w >> 3, DC_CAV_LUT_DATAL_WIDTH_L);
		datal &= ~DC_CAV_LUT_DATAL_FBADDR;
		datal |= __SHIFTIN(pa >> 3, DC_CAV_LUT_DATAL_FBADDR);
		bus_space_write_4(sc->sc_bst, sc->sc_bsh, DC_CAV_LUT_DATAL_REG,
		    datal);

		datah &= ~DC_CAV_LUT_DATAH_BLKMODE;
		datah |= __SHIFTIN(DC_CAV_LUT_DATAH_BLKMODE_LINEAR,
				   DC_CAV_LUT_DATAH_BLKMODE);
		datah &= ~DC_CAV_LUT_DATAH_WIDTH_H;
		datah |= __SHIFTIN(w >> 6, DC_CAV_LUT_DATAH_WIDTH_H);
		datah &= ~DC_CAV_LUT_DATAH_HEIGHT;
		datah |= __SHIFTIN(h, DC_CAV_LUT_DATAH_HEIGHT);
		bus_space_write_4(sc->sc_bst, sc->sc_bsh, DC_CAV_LUT_DATAH_REG,
		    datah);

		addr |= DC_CAV_LUT_ADDR_WR_EN;
		bus_space_write_4(sc->sc_bst, sc->sc_bsh, DC_CAV_LUT_ADDR_REG,
		    addr);

		w1 = __SHIFTIN(width - 1, VIU_OSD_BLK_CFG_W1_X_END);
		w2 = __SHIFTIN(height - 1, VIU_OSD_BLK_CFG_W2_Y_END);
		w3 = __SHIFTIN(width - 1, VIU_OSD_BLK_CFG_W3_H_END);
		w4 = __SHIFTIN(height - 1, VIU_OSD_BLK_CFG_W4_V_END);

		VPU_WRITE(sc, VIU_OSD2_BLK0_CFG_W1_REG, w1);
		VPU_WRITE(sc, VIU_OSD2_BLK0_CFG_W2_REG, w2);
		VPU_WRITE(sc, VIU_OSD2_BLK0_CFG_W3_REG, w3);
		VPU_WRITE(sc, VIU_OSD2_BLK0_CFG_W4_REG, w4);

		prop_dictionary_set_uint32(cfg, "width", width);
		prop_dictionary_set_uint32(cfg, "height", height);
		prop_dictionary_set_uint8(cfg, "depth", 24);
		prop_dictionary_set_uint16(cfg, "linebytes", width * 3);
		prop_dictionary_set_uint32(cfg, "address", 0);
		prop_dictionary_set_uint32(cfg, "virtual_address",
		    (uintptr_t)sc->sc_dmap);
	} else {
		aprint_error_dev(sc->sc_gen.sc_dev,
		    "failed to allocate %u bytes of video memory: %d\n",
		    (u_int)sc->sc_dmasize, error);
	}
}

static int
amlogic_genfb_alloc_videomem(struct amlogic_genfb_softc *sc)
{
	int error, nsegs;

	error = bus_dmamem_alloc(sc->sc_dmat, sc->sc_dmasize, 0x1000, 0,
	    sc->sc_dmasegs, 1, &nsegs, BUS_DMA_WAITOK);
	if (error)
		return error;
	error = bus_dmamem_map(sc->sc_dmat, sc->sc_dmasegs, nsegs,
	    sc->sc_dmasize, &sc->sc_dmap, BUS_DMA_WAITOK | BUS_DMA_COHERENT);
	if (error)
		goto free;
	error = bus_dmamap_create(sc->sc_dmat, sc->sc_dmasize, 1,
	    sc->sc_dmasize, 0, BUS_DMA_WAITOK, &sc->sc_dmamap);
	if (error)
		goto unmap;
	error = bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap, sc->sc_dmap,
	    sc->sc_dmasize, NULL, BUS_DMA_WAITOK);
	if (error)
		goto destroy;

	memset(sc->sc_dmap, 0, sc->sc_dmasize);

	return 0;

destroy:
	bus_dmamap_destroy(sc->sc_dmat, sc->sc_dmamap);
unmap:
	bus_dmamem_unmap(sc->sc_dmat, sc->sc_dmap, sc->sc_dmasize);
free:
	bus_dmamem_free(sc->sc_dmat, sc->sc_dmasegs, nsegs);

	sc->sc_dmasize = 0;
	sc->sc_dmap = NULL;

	return error;
}

void
amlogic_genfb_set_console_dev(device_t dev)
{
	KASSERT(amlogic_genfb_console_dev == NULL);
	amlogic_genfb_console_dev = dev;
}

void
amlogic_genfb_ddb_trap_callback(int where)
{
	if (amlogic_genfb_console_dev == NULL)
		return;

	if (where) {
		genfb_enable_polling(amlogic_genfb_console_dev);
	} else {
		genfb_disable_polling(amlogic_genfb_console_dev);
	}
}

File Added: src/sys/arch/arm/amlogic/Attic/amlogic_hdmireg.h
/* $NetBSD: amlogic_hdmireg.h,v 1.1 2015/03/21 01:17:00 jmcneill Exp $ */

/*-
 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
 * 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 _ARM_AMLOGIC_HDMIREG_H
#define _ARM_AMLOGIC_HDMIREG_H

#define HDMI_ADDR_REG		0x2000
#define HDMI_DATA_REG		0x2004
#define HDMI_CTRL_REG		0x2008

#define HDMITX_AVI_INFO_ADDR	0x260

#endif /* _ARM_AMLOGIC_HDMIREG_H */

File Added: src/sys/arch/arm/amlogic/Attic/amlogic_vpureg.h
/* $NetBSD: amlogic_vpureg.h,v 1.1 2015/03/21 01:17:00 jmcneill Exp $ */

/*-
 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
 * 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 _ARM_AMLOGIC_VPUREG_H
#define _ARM_AMLOGIC_VPUREG_H

#define VPU_REG(n)	((n) << 2)

#define VIU_OSD2_CTRL_STAT_REG		VPU_REG(0x1a30)
#define VIU_OSD2_BLK0_CFG_W0_REG	VPU_REG(0x1a3b)
#define VIU_OSD2_BLK0_CFG_W1_REG	VPU_REG(0x1a3c)
#define VIU_OSD2_BLK0_CFG_W2_REG	VPU_REG(0x1a3d)
#define VIU_OSD2_BLK0_CFG_W3_REG	VPU_REG(0x1a3e)
#define VIU_OSD2_BLK0_CFG_W4_REG	VPU_REG(0x1a64)
#define VPP_MISC_REG			VPU_REG(0x1d26)

#define VIU_OSD_CTRL_STAT_ENABLE	__BIT(21)
#define VIU_OSD_CTRL_STAT_BLK3_ENABLE	__BIT(3)
#define VIU_OSD_CTRL_STAT_BLK2_ENABLE	__BIT(2)
#define VIU_OSD_CTRL_STAT_BLK1_ENABLE	__BIT(1)
#define VIU_OSD_CTRL_STAT_BLK0_ENABLE	__BIT(0)

#define VIU_OSD_BLK_CFG_W0_TBL_ADDR	__BITS(23,16)
#define VIU_OSD_BLK_CFG_W0_LITTLE_ENDIAN __BIT(15)
#define VIU_OSD_BLK_CFG_W0_RPT_Y	__BIT(14)
#define VIU_OSD_BLK_CFG_W0_INTERP_CTRL	__BITS(13,12)
#define VIU_OSD_BLK_CFG_W0_OSD_BLK_MODE	__BITS(11,8)
#define VIU_OSD_BLK_CFG_W0_RGB_EN	__BIT(7)
#define VIU_OSD_BLK_CFG_W0_TC_ALPHA_EN	__BIT(6)
#define VIU_OSD_BLK_CFG_W0_COLOR_MATRIX	__BITS(5,2)
#define VIU_OSD_BLK_CFG_W0_INTERLACE_EN	__BIT(1)
#define VIU_OSD_BLK_CFG_W0_INTERLACE_SEL_ODD __BIT(0)

#define VIU_OSD_BLK_CFG_W1_X_END	__BITS(28,16)
#define VIU_OSD_BLK_CFG_W1_X_START	__BITS(12,0)

#define VIU_OSD_BLK_CFG_W2_Y_END	__BITS(28,16)
#define VIU_OSD_BLK_CFG_W2_Y_START	__BITS(12,0)

#define VIU_OSD_BLK_CFG_W3_H_END	__BITS(27,16)
#define VIU_OSD_BLK_CFG_W3_H_START	__BITS(11,0)

#define VIU_OSD_BLK_CFG_W4_V_END	__BITS(27,16)
#define VIU_OSD_BLK_CFG_W4_V_START	__BITS(11,0)

#define VPP_MISC_POSTBLEND		__BIT(7)

#endif /* _ARM_AMLOGIC_VPUREG_H */

cvs diff -r1.6 -r1.7 src/sys/arch/arm/amlogic/Attic/amlogic_io.c (expand / switch to unified diff)

--- src/sys/arch/arm/amlogic/Attic/amlogic_io.c 2015/03/08 12:44:55 1.6
+++ src/sys/arch/arm/amlogic/Attic/amlogic_io.c 2015/03/21 01:17:00 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: amlogic_io.c,v 1.6 2015/03/08 12:44:55 jmcneill Exp $ */ 1/* $NetBSD: amlogic_io.c,v 1.7 2015/03/21 01:17:00 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include "opt_amlogic.h" 29#include "opt_amlogic.h"
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.6 2015/03/08 12:44:55 jmcneill Exp $"); 32__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.7 2015/03/21 01:17:00 jmcneill Exp $");
33 33
34#include <sys/param.h> 34#include <sys/param.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/device.h> 36#include <sys/device.h>
37 37
38#include <machine/cpu.h> 38#include <machine/cpu.h>
39#include <sys/bus.h> 39#include <sys/bus.h>
40 40
41#include <arm/mainbus/mainbus.h> 41#include <arm/mainbus/mainbus.h>
42#include <arm/amlogic/amlogic_reg.h> 42#include <arm/amlogic/amlogic_reg.h>
43#include <arm/amlogic/amlogic_var.h> 43#include <arm/amlogic/amlogic_var.h>
44 44
45#include "locators.h" 45#include "locators.h"
@@ -53,30 +53,28 @@ CFATTACH_DECL_NEW(amlogic_io, 0, @@ -53,30 +53,28 @@ CFATTACH_DECL_NEW(amlogic_io, 0,
53static int amlogicio_print(void *, const char *); 53static int amlogicio_print(void *, const char *);
54static int amlogicio_find(device_t, cfdata_t, const int *, void *); 54static int amlogicio_find(device_t, cfdata_t, const int *, void *);
55 55
56static bool amlogicio_found = false; 56static bool amlogicio_found = false;
57 57
58#define NOPORT AMLOGICIOCF_PORT_DEFAULT 58#define NOPORT AMLOGICIOCF_PORT_DEFAULT
59#define NOINTR AMLOGICIO_INTR_DEFAULT 59#define NOINTR AMLOGICIO_INTR_DEFAULT
60 60
61static const struct amlogic_locators amlogic_locators[] = { 61static const struct amlogic_locators amlogic_locators[] = {
62 { "amlogiccom", 62 { "amlogiccom",
63 AMLOGIC_UART0AO_OFFSET, AMLOGIC_UART_SIZE, 0, AMLOGIC_INTR_UART0AO }, 63 AMLOGIC_UART0AO_OFFSET, AMLOGIC_UART_SIZE, 0, AMLOGIC_INTR_UART0AO },
64 { "amlogiccom", 64 { "amlogiccom",
65 AMLOGIC_UART2AO_OFFSET, AMLOGIC_UART_SIZE, 2, AMLOGIC_INTR_UART2AO }, 65 AMLOGIC_UART2AO_OFFSET, AMLOGIC_UART_SIZE, 2, AMLOGIC_INTR_UART2AO },
66#if notyet 
67 { "genfb", 66 { "genfb",
68 AMLOGIC_DMC_OFFSET, AMLOGIC_DMC_SIZE, NOPORT, NOINTR }, 67 AMLOGIC_DMC_OFFSET, AMLOGIC_DMC_SIZE, NOPORT, NOINTR },
69#endif 
70 { "amlogicrng", 68 { "amlogicrng",
71 AMLOGIC_RAND_OFFSET, AMLOGIC_RAND_SIZE, NOPORT, NOINTR }, 69 AMLOGIC_RAND_OFFSET, AMLOGIC_RAND_SIZE, NOPORT, NOINTR },
72 { "dwctwo", 70 { "dwctwo",
73 AMLOGIC_USB0_OFFSET, AMLOGIC_USB_SIZE, 0, AMLOGIC_INTR_USB0 }, 71 AMLOGIC_USB0_OFFSET, AMLOGIC_USB_SIZE, 0, AMLOGIC_INTR_USB0 },
74 { "dwctwo", 72 { "dwctwo",
75 AMLOGIC_USB1_OFFSET, AMLOGIC_USB_SIZE, 1, AMLOGIC_INTR_USB1 }, 73 AMLOGIC_USB1_OFFSET, AMLOGIC_USB_SIZE, 1, AMLOGIC_INTR_USB1 },
76 { "awge", 74 { "awge",
77 AMLOGIC_GMAC_OFFSET, AMLOGIC_GMAC_SIZE, NOPORT, AMLOGIC_INTR_GMAC }, 75 AMLOGIC_GMAC_OFFSET, AMLOGIC_GMAC_SIZE, NOPORT, AMLOGIC_INTR_GMAC },
78 { "amlogicsdhc", 76 { "amlogicsdhc",
79 AMLOGIC_SDHC_OFFSET, AMLOGIC_SDHC_SIZE, 1, AMLOGIC_INTR_SDHC }, 77 AMLOGIC_SDHC_OFFSET, AMLOGIC_SDHC_SIZE, 1, AMLOGIC_INTR_SDHC },
80 { "amlogicsdhc", 78 { "amlogicsdhc",
81 AMLOGIC_SDHC_OFFSET, AMLOGIC_SDHC_SIZE, 2, AMLOGIC_INTR_SDHC }, 79 AMLOGIC_SDHC_OFFSET, AMLOGIC_SDHC_SIZE, 2, AMLOGIC_INTR_SDHC },
82}; 80};

cvs diff -r1.8 -r1.9 src/sys/arch/arm/amlogic/Attic/amlogic_reg.h (expand / switch to unified diff)

--- src/sys/arch/arm/amlogic/Attic/amlogic_reg.h 2015/03/08 12:44:55 1.8
+++ src/sys/arch/arm/amlogic/Attic/amlogic_reg.h 2015/03/21 01:17:00 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: amlogic_reg.h,v 1.8 2015/03/08 12:44:55 jmcneill Exp $ */ 1/* $NetBSD: amlogic_reg.h,v 1.9 2015/03/21 01:17:00 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -60,26 +60,32 @@ @@ -60,26 +60,32 @@
60 60
61#define AMLOGIC_UART0AO_OFFSET 0x081004c0 61#define AMLOGIC_UART0AO_OFFSET 0x081004c0
62#define AMLOGIC_UART2AO_OFFSET 0x081004e0 62#define AMLOGIC_UART2AO_OFFSET 0x081004e0
63#define AMLOGIC_UART_SIZE 0x20 63#define AMLOGIC_UART_SIZE 0x20
64#define AMLOGIC_UART_FREQ AMLOGIC_REF_FREQ 64#define AMLOGIC_UART_FREQ AMLOGIC_REF_FREQ
65 65
66#define AMLOGIC_USB0_OFFSET 0x09040000 66#define AMLOGIC_USB0_OFFSET 0x09040000
67#define AMLOGIC_USB1_OFFSET 0x090c0000 67#define AMLOGIC_USB1_OFFSET 0x090c0000
68#define AMLOGIC_USB_SIZE 0x40000 68#define AMLOGIC_USB_SIZE 0x40000
69 69
70#define AMLOGIC_GMAC_OFFSET 0x09410000 70#define AMLOGIC_GMAC_OFFSET 0x09410000
71#define AMLOGIC_GMAC_SIZE 0x10000 71#define AMLOGIC_GMAC_SIZE 0x10000
72 72
 73#define AMLOGIC_HDMI_OFFSET 0x10040000
 74#define AMLOGIC_HDMI_SIZE 0x10000 /* ? */
 75
 76#define AMLOGIC_VPU_OFFSET 0x10100000
 77#define AMLOGIC_VPU_SIZE 0x100000 /* ? */
 78
73#define AMLOGIC_SRAM_OFFSET 0x19000000 79#define AMLOGIC_SRAM_OFFSET 0x19000000
74 80
75#define AMLOGIC_CPUCONF_OFFSET 0x1901ff80 81#define AMLOGIC_CPUCONF_OFFSET 0x1901ff80
76 82
77#define AMLOGIC_CBUS_CPU_CLK_CNTL_REG 0x419c 83#define AMLOGIC_CBUS_CPU_CLK_CNTL_REG 0x419c
78 84
79#define AMLOGIC_AOBUS_PWR_CTRL0_REG 0xe0 85#define AMLOGIC_AOBUS_PWR_CTRL0_REG 0xe0
80#define AMLOGIC_AOBUS_PWR_CTRL1_REG 0xe4 86#define AMLOGIC_AOBUS_PWR_CTRL1_REG 0xe4
81#define AMLOGIC_AOBUS_PWR_MEM_PD0_REG 0xf4 87#define AMLOGIC_AOBUS_PWR_MEM_PD0_REG 0xf4
82 88
83#define AMLOGIC_CPUCONF_CTRL_REG 0x00 89#define AMLOGIC_CPUCONF_CTRL_REG 0x00
84#define AMLOGIC_CPUCONF_CPU_ADDR_REG(n) (0x04 * (n)) 90#define AMLOGIC_CPUCONF_CPU_ADDR_REG(n) (0x04 * (n))
85 91

cvs diff -r1.7 -r1.8 src/sys/arch/arm/amlogic/Attic/amlogic_var.h (expand / switch to unified diff)

--- src/sys/arch/arm/amlogic/Attic/amlogic_var.h 2015/03/17 22:29:40 1.7
+++ src/sys/arch/arm/amlogic/Attic/amlogic_var.h 2015/03/21 01:17:00 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: amlogic_var.h,v 1.7 2015/03/17 22:29:40 jmcneill Exp $ */ 1/* $NetBSD: amlogic_var.h,v 1.8 2015/03/21 01:17:00 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -64,25 +64,28 @@ void amlogic_eth_init(void); @@ -64,25 +64,28 @@ void amlogic_eth_init(void);
64void amlogic_rng_init(void); 64void amlogic_rng_init(void);
65void amlogic_sdhc_init(void); 65void amlogic_sdhc_init(void);
66 66
67int amlogic_sdhc_select_port(int); 67int amlogic_sdhc_select_port(int);
68#define AMLOGIC_SDHC_PORT_B 1 68#define AMLOGIC_SDHC_PORT_B 1
69#define AMLOGIC_SDHC_PORT_C 2 69#define AMLOGIC_SDHC_PORT_C 2
70 70
71uint32_t amlogic_get_rate_xtal(void); 71uint32_t amlogic_get_rate_xtal(void);
72uint32_t amlogic_get_rate_sys(void); 72uint32_t amlogic_get_rate_sys(void);
73uint32_t amlogic_get_rate_fixed(void); 73uint32_t amlogic_get_rate_fixed(void);
74uint32_t amlogic_get_rate_a9(void); 74uint32_t amlogic_get_rate_a9(void);
75uint32_t amlogic_get_rate_a9periph(void); 75uint32_t amlogic_get_rate_a9periph(void);
76 76
 77void amlogic_genfb_ddb_trap_callback(int);
 78void amlogic_genfb_set_console_dev(device_t);
 79
77static void inline 80static void inline
78amlogic_reg_set_clear(bus_space_tag_t bst, bus_space_handle_t bsh, 81amlogic_reg_set_clear(bus_space_tag_t bst, bus_space_handle_t bsh,
79 bus_size_t o, uint32_t set_mask, uint32_t clr_mask) 82 bus_size_t o, uint32_t set_mask, uint32_t clr_mask)
80{ 83{
81 const uint32_t old = bus_space_read_4(bst, bsh, o); 84 const uint32_t old = bus_space_read_4(bst, bsh, o);
82 const uint32_t new = set_mask | (old & ~clr_mask); 85 const uint32_t new = set_mask | (old & ~clr_mask);
83 if (old != new) { 86 if (old != new) {
84 bus_space_write_4(bst, bsh, o, new); 87 bus_space_write_4(bst, bsh, o, new);
85 } 88 }
86} 89}
87 90
88#endif /* _ARM_AMLOGIC_VAR_H */ 91#endif /* _ARM_AMLOGIC_VAR_H */

cvs diff -r1.7 -r1.8 src/sys/arch/arm/amlogic/Attic/files.amlogic (expand / switch to unified diff)

--- src/sys/arch/arm/amlogic/Attic/files.amlogic 2015/03/17 22:29:40 1.7
+++ src/sys/arch/arm/amlogic/Attic/files.amlogic 2015/03/21 01:17:00 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files.amlogic,v 1.7 2015/03/17 22:29:40 jmcneill Exp $ 1# $NetBSD: files.amlogic,v 1.8 2015/03/21 01:17:00 jmcneill Exp $
2# 2#
3# Configuration info for Amlogic ARM Peripherals 3# Configuration info for Amlogic ARM Peripherals
4# 4#
5 5
6include "arch/arm/pic/files.pic" 6include "arch/arm/pic/files.pic"
7include "arch/arm/cortex/files.cortex" 7include "arch/arm/cortex/files.cortex"
8 8
9file arch/arm/arm32/arm32_boot.c 9file arch/arm/arm32/arm32_boot.c
10file arch/arm/arm32/arm32_kvminit.c 10file arch/arm/arm32/arm32_kvminit.c
11file arch/arm/arm32/arm32_reboot.c 11file arch/arm/arm32/arm32_reboot.c
12file arch/arm/arm32/irq_dispatch.S 12file arch/arm/arm32/irq_dispatch.S
13 13
14file arch/arm/amlogic/amlogic_board.c 14file arch/arm/amlogic/amlogic_board.c
@@ -16,26 +16,30 @@ file arch/arm/amlogic/amlogic_cpufreq.c @@ -16,26 +16,30 @@ file arch/arm/amlogic/amlogic_cpufreq.c
16file arch/arm/amlogic/amlogic_space.c 16file arch/arm/amlogic/amlogic_space.c
17file arch/arm/arm/bus_space_a4x.S 17file arch/arm/arm/bus_space_a4x.S
18 18
19# On-board I/O 19# On-board I/O
20device amlogicio { [port=-1] } : bus_space_generic 20device amlogicio { [port=-1] } : bus_space_generic
21attach amlogicio at mainbus with amlogic_io 21attach amlogicio at mainbus with amlogic_io
22file arch/arm/amlogic/amlogic_io.c amlogic_io 22file arch/arm/amlogic/amlogic_io.c amlogic_io
23 23
24# UART 24# UART
25device amlogiccom 25device amlogiccom
26attach amlogiccom at amlogicio with amlogic_com 26attach amlogiccom at amlogicio with amlogic_com
27file arch/arm/amlogic/amlogic_com.c amlogic_com needs-flag 27file arch/arm/amlogic/amlogic_com.c amlogic_com needs-flag
28 28
 29# Framebuffer console
 30attach genfb at amlogicio with amlogic_genfb
 31file arch/arm/amlogic/amlogic_genfb.c amlogic_genfb needs-flag
 32
29# SDHC 33# SDHC
30device amlogicsdhc: sdmmcbus 34device amlogicsdhc: sdmmcbus
31attach amlogicsdhc at amlogicio with amlogic_sdhc 35attach amlogicsdhc at amlogicio with amlogic_sdhc
32file arch/arm/amlogic/amlogic_sdhc.c amlogic_sdhc 36file arch/arm/amlogic/amlogic_sdhc.c amlogic_sdhc
33 37
34# usb otg 38# usb otg
35attach dwctwo at amlogicio with amlogic_dwctwo 39attach dwctwo at amlogicio with amlogic_dwctwo
36file arch/arm/amlogic/amlogic_dwctwo.c amlogic_dwctwo 40file arch/arm/amlogic/amlogic_dwctwo.c amlogic_dwctwo
37 41
38# ethernet mac 42# ethernet mac
39attach awge at amlogicio with amlogic_gmac 43attach awge at amlogicio with amlogic_gmac
40file arch/arm/amlogic/amlogic_gmac.c amlogic_gmac 44file arch/arm/amlogic/amlogic_gmac.c amlogic_gmac
41 45

cvs diff -r1.16 -r1.17 src/sys/arch/evbarm/amlogic/Attic/amlogic_machdep.c (expand / switch to unified diff)

--- src/sys/arch/evbarm/amlogic/Attic/amlogic_machdep.c 2015/03/17 22:29:40 1.16
+++ src/sys/arch/evbarm/amlogic/Attic/amlogic_machdep.c 2015/03/21 01:17:00 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: amlogic_machdep.c,v 1.16 2015/03/17 22:29:40 jmcneill Exp $ */ 1/* $NetBSD: amlogic_machdep.c,v 1.17 2015/03/21 01:17:00 jmcneill Exp $ */
2 2
3/* 3/*
4 * Machine dependent functions for kernel setup for TI OSK5912 board. 4 * Machine dependent functions for kernel setup for TI OSK5912 board.
5 * Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c 5 * Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c
6 * 6 *
7 * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. 7 * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
8 * Written by Hiroyuki Bessho for Genetec Corporation. 8 * Written by Hiroyuki Bessho for Genetec Corporation.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -115,37 +115,39 @@ @@ -115,37 +115,39 @@
115 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 115 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
116 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 116 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
117 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT, 117 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
118 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 118 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
119 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 119 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
120 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 120 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
121 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 121 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
122 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 122 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
123 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 123 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
124 * SUCH DAMAGE. 124 * SUCH DAMAGE.
125 */ 125 */
126 126
127#include <sys/cdefs.h> 127#include <sys/cdefs.h>
128__KERNEL_RCSID(0, "$NetBSD: amlogic_machdep.c,v 1.16 2015/03/17 22:29:40 jmcneill Exp $"); 128__KERNEL_RCSID(0, "$NetBSD: amlogic_machdep.c,v 1.17 2015/03/21 01:17:00 jmcneill Exp $");
129 129
130#include "opt_machdep.h" 130#include "opt_machdep.h"
131#include "opt_ddb.h" 131#include "opt_ddb.h"
132#include "opt_md.h" 132#include "opt_md.h"
133#include "opt_amlogic.h" 133#include "opt_amlogic.h"
134#include "opt_arm_debug.h" 134#include "opt_arm_debug.h"
135#include "opt_multiprocessor.h" 135#include "opt_multiprocessor.h"
136 136
137#include "amlogic_com.h" 137#include "amlogic_com.h"
138#include "arml2cc.h" 138#include "arml2cc.h"
 139#include "ukbd.h"
 140#include "genfb.h"
139#include "ether.h" 141#include "ether.h"
140 142
141#include <sys/param.h> 143#include <sys/param.h>
142#include <sys/systm.h> 144#include <sys/systm.h>
143#include <sys/bus.h> 145#include <sys/bus.h>
144#include <sys/atomic.h> 146#include <sys/atomic.h>
145#include <sys/cpu.h> 147#include <sys/cpu.h>
146#include <sys/device.h> 148#include <sys/device.h>
147#include <sys/exec.h> 149#include <sys/exec.h>
148#include <sys/kernel.h> 150#include <sys/kernel.h>
149#include <sys/ksyms.h> 151#include <sys/ksyms.h>
150#include <sys/msgbuf.h> 152#include <sys/msgbuf.h>
151#include <sys/proc.h> 153#include <sys/proc.h>
@@ -462,30 +464,28 @@ void @@ -462,30 +464,28 @@ void
462consinit(void) 464consinit(void)
463{ 465{
464 static int consinit_called = 0; 466 static int consinit_called = 0;
465 467
466 if (consinit_called != 0) 468 if (consinit_called != 0)
467 return; 469 return;
468 470
469 consinit_called = 1; 471 consinit_called = 1;
470 472
471#if NAMLOGIC_COM > 0 473#if NAMLOGIC_COM > 0
472 const bus_space_handle_t bsh = 474 const bus_space_handle_t bsh =
473 AMLOGIC_CORE_VBASE + (consaddr - AMLOGIC_CORE_BASE); 475 AMLOGIC_CORE_VBASE + (consaddr - AMLOGIC_CORE_BASE);
474 amlogic_com_cnattach(&amlogic_bs_tag, bsh, conspeed, conmode); 476 amlogic_com_cnattach(&amlogic_bs_tag, bsh, conspeed, conmode);
475#endif 477#else
476 478#error only UART console is supported
477#if NUKBD > 0 
478 ukbd_cnattach(); /* allow USB keyboard to become console */ 
479#endif 479#endif
480} 480}
481 481
482void 482void
483amlogic_reset(void) 483amlogic_reset(void)
484{ 484{
485 bus_space_tag_t bst = &amlogic_bs_tag; 485 bus_space_tag_t bst = &amlogic_bs_tag;
486 bus_space_handle_t bsh = amlogic_core_bsh; 486 bus_space_handle_t bsh = amlogic_core_bsh;
487 bus_size_t off = AMLOGIC_CBUS_OFFSET; 487 bus_size_t off = AMLOGIC_CBUS_OFFSET;
488 488
489 bus_space_write_4(bst, bsh, off + WATCHDOG_TC_REG, 489 bus_space_write_4(bst, bsh, off + WATCHDOG_TC_REG,
490 WATCHDOG_TC_CPUS | WATCHDOG_TC_ENABLE | 0xfff); 490 WATCHDOG_TC_CPUS | WATCHDOG_TC_ENABLE | 0xfff);
491 bus_space_write_4(bst, bsh, off + WATCHDOG_RESET_REG, 0); 491 bus_space_write_4(bst, bsh, off + WATCHDOG_RESET_REG, 0);
@@ -531,26 +531,45 @@ amlogic_device_register(device_t self, v @@ -531,26 +531,45 @@ amlogic_device_register(device_t self, v
531 prop_dictionary_set_uint32(dict, "offset", 0xfff00000); 531 prop_dictionary_set_uint32(dict, "offset", 0xfff00000);
532 } 532 }
533 533
534 if (device_is_a(self, "awge") && device_unit(self) == 0) { 534 if (device_is_a(self, "awge") && device_unit(self) == 0) {
535 uint8_t enaddr[ETHER_ADDR_LEN]; 535 uint8_t enaddr[ETHER_ADDR_LEN];
536 if (get_bootconf_option(boot_args, "awge0.mac-address", 536 if (get_bootconf_option(boot_args, "awge0.mac-address",
537 BOOTOPT_TYPE_MACADDR, enaddr)) { 537 BOOTOPT_TYPE_MACADDR, enaddr)) {
538 prop_data_t pd = prop_data_create_data(enaddr, 538 prop_data_t pd = prop_data_create_data(enaddr,
539 sizeof(enaddr)); 539 sizeof(enaddr));
540 prop_dictionary_set(dict, "mac-address", pd); 540 prop_dictionary_set(dict, "mac-address", pd);
541 prop_object_release(pd); 541 prop_object_release(pd);
542 } 542 }
543 } 543 }
 544
 545#if NGENFB > 0
 546 if (device_is_a(self, "genfb")) {
 547 char *ptr;
 548 amlogic_genfb_set_console_dev(self);
 549#ifdef DDB
 550 db_trap_callback = amlogic_genfb_ddb_trap_callback;
 551#endif
 552 if (get_bootconf_option(boot_args, "console",
 553 BOOTOPT_TYPE_STRING, &ptr) && strncmp(ptr, "fb", 2) == 0) {
 554 prop_dictionary_set_bool(dict, "is_console", true);
 555#if NUKBD > 0
 556 ukbd_cnattach();
 557#endif
 558 } else {
 559 prop_dictionary_set_bool(dict, "is_console", false);
 560 }
 561 }
 562#endif
544} 563}
545 564
546#if defined(MULTIPROCESSOR) 565#if defined(MULTIPROCESSOR)
547void amlogic_mpinit(uint32_t); 566void amlogic_mpinit(uint32_t);
548 567
549static void 568static void
550amlogic_mpinit_delay(u_int n) 569amlogic_mpinit_delay(u_int n)
551{ 570{
552 for (volatile int i = 0; i < n; i++) 571 for (volatile int i = 0; i < n; i++)
553 ; 572 ;
554} 573}
555 574
556static void 575static void

cvs diff -r1.11 -r1.12 src/sys/arch/evbarm/conf/Attic/ODROID-C1 (expand / switch to unified diff)

--- src/sys/arch/evbarm/conf/Attic/ODROID-C1 2015/03/18 23:03:06 1.11
+++ src/sys/arch/evbarm/conf/Attic/ODROID-C1 2015/03/21 01:17:00 1.12
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1# 1#
2# $NetBSD: ODROID-C1,v 1.11 2015/03/18 23:03:06 jmcneill Exp $ 2# $NetBSD: ODROID-C1,v 1.12 2015/03/21 01:17:00 jmcneill Exp $
3# 3#
4# Odroid-C1 (Amlogic S805) based SBC (Single Board Computer) 4# Odroid-C1 (Amlogic S805) based SBC (Single Board Computer)
5# 5#
6 6
7include "arch/evbarm/conf/std.amlogic" 7include "arch/evbarm/conf/std.amlogic"
8 8
9# estimated number of users 9# estimated number of users
10 10
11maxusers 32 11maxusers 32
12 12
13# Standard system options 13# Standard system options
14 14
15options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT 15options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT
@@ -167,39 +167,41 @@ a9tmr0 at armperiph? # Global Timer @@ -167,39 +167,41 @@ a9tmr0 at armperiph? # Global Timer
167a9wdt0 at armperiph? # Watchdog 167a9wdt0 at armperiph? # Watchdog
168 168
169# Specify the memory size in megabytes. 169# Specify the memory size in megabytes.
170#options MEMSIZE=1024 170#options MEMSIZE=1024
171 171
172# On-board I/O 172# On-board I/O
173amlogicio0 at mainbus? 173amlogicio0 at mainbus?
174 174
175# On-board UARTs 175# On-board UARTs
176amlogiccom0 at amlogicio0 port 0 176amlogiccom0 at amlogicio0 port 0
177options CONSADDR=0xc81004c0, CONSPEED=115200 177options CONSADDR=0xc81004c0, CONSPEED=115200
178 178
179# Framebuffer 179# Framebuffer
180#genfb0 at amlogicio0 180genfb0 at amlogicio0
181#wsdisplay* at genfb? 181wsdisplay* at genfb?
182#options VCONS_DRAW_INTR 182options VCONS_DRAW_INTR
183#options WSEMUL_VT100 183options WSEMUL_VT100
184#options WS_DEFAULT_FG=WSCOL_WHITE 184options WS_DEFAULT_FG=WSCOL_WHITE
185#options WS_DEFAULT_BG=WSCOL_BLACK 185options WS_DEFAULT_BG=WSCOL_BLACK
186#options WS_KERNEL_FG=WSCOL_GREEN 186options WS_KERNEL_FG=WSCOL_GREEN
187#options WS_KERNEL_BG=WSCOL_BLACK 187options WS_KERNEL_BG=WSCOL_BLACK
188#options WSDISPLAY_COMPAT_PCVT 188options WSDISPLAY_COMPAT_PCVT
189#options WSDISPLAY_COMPAT_SYSCONS 189options WSDISPLAY_COMPAT_SYSCONS
190#options WSDISPLAY_COMPAT_USL 190options WSDISPLAY_COMPAT_USL
191#options WSDISPLAY_COMPAT_RAWKBD 191options WSDISPLAY_COMPAT_RAWKBD
192#options WSDISPLAY_DEFAULTSCREENS=4 192options WSDISPLAY_DEFAULTSCREENS=4
 193pseudo-device wsmux
 194pseudo-device wsfont
193 195
194# Hardware random number generator 196# Hardware random number generator
195amlogicrng0 at amlogicio0 197amlogicrng0 at amlogicio0
196 198
197# SDHC controller 199# SDHC controller
198amlogicsdhc0 at amlogicio0 200amlogicsdhc0 at amlogicio0
199sdmmc* at amlogicsdhc? 201sdmmc* at amlogicsdhc?
200ld* at sdmmc? 202ld* at sdmmc?
201 203
202# Gigabit ethernet 204# Gigabit ethernet
203awge0 at amlogicio0 205awge0 at amlogicio0
204rgephy* at mii? phy ? 206rgephy* at mii? phy ?
205ukphy* at mii? phy ? 207ukphy* at mii? phy ?