Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys Pull up following revision(s) (requested by jmcneill ...
details: https://anonhg.NetBSD.org/src/rev/562c8536595c
branches: netbsd-7
changeset: 798570:562c8536595c
user: martin <martin%NetBSD.org@localhost>
date: Fri Nov 14 13:26:46 2014 +0000
description:
Pull up following revision(s) (requested by jmcneill in ticket #210):
sys/arch/arm/allwinner/awin_board.c: revisions 1.26-1.27
sys/arch/arm/allwinner/awin_debe.c: revisions 1.1-1.6
sys/arch/arm/allwinner/awin_fb.c: revisions 1.1-1.4
sys/arch/arm/allwinner/awin_hdmi.c: revisions 1.3-1.6,1.9-1.12
sys/arch/arm/allwinner/awin_io.c: revision 1.27
sys/arch/arm/allwinner/awin_reg.h: revisions 1.46-1.47,1.49
sys/arch/arm/allwinner/awin_tcon.c: revisions 1.1-1.5
sys/arch/arm/allwinner/awin_var.h: revisions 1.20-1.22
sys/arch/arm/allwinner/files.awin: revisions 1.22-1.23,1.25
sys/arch/evbarm/awin/awin_machdep.c: revision 1.26
sys/arch/evbarm/conf/BPI: revision 1.10
sys/arch/evbarm/conf/CUBIEBOARD: revision 1.32
sys/arch/evbarm/conf/HUMMINGBIRD_A31: revisions 1.17-1.18
sys/dev/wscons/wsconsio.h: revision 1.109
HDMI framebuffer for Allwinner boards.
diffstat:
sys/arch/arm/allwinner/awin_board.c | 145 ++++++++++++-
sys/arch/arm/allwinner/awin_debe.c | 344 ++++++++++++++++++++++++++++++++
sys/arch/arm/allwinner/awin_fb.c | 200 ++++++++++++++++++
sys/arch/arm/allwinner/awin_hdmi.c | 375 +++++++++++++++++++++++++++-------
sys/arch/arm/allwinner/awin_io.c | 10 +-
sys/arch/arm/allwinner/awin_reg.h | 202 ++++++++++++++++++-
sys/arch/arm/allwinner/awin_tcon.c | 349 ++++++++++++++++++++++++++++++++
sys/arch/arm/allwinner/awin_var.h | 25 ++-
sys/arch/arm/allwinner/files.awin | 22 +-
sys/arch/evbarm/awin/awin_machdep.c | 23 +-
sys/arch/evbarm/conf/BPI | 43 ++-
sys/arch/evbarm/conf/CUBIEBOARD | 43 ++-
sys/arch/evbarm/conf/HUMMINGBIRD_A31 | 25 ++-
sys/dev/wscons/wsconsio.h | 3 +-
14 files changed, 1668 insertions(+), 141 deletions(-)
diffs (truncated from 2236 to 300 lines):
diff -r 29a5aeafbc2e -r 562c8536595c sys/arch/arm/allwinner/awin_board.c
--- a/sys/arch/arm/allwinner/awin_board.c Fri Nov 14 10:04:40 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_board.c Fri Nov 14 13:26:46 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_board.c,v 1.14.6.1 2014/11/09 14:42:33 martin Exp $ */
+/* $NetBSD: awin_board.c,v 1.14.6.2 2014/11/14 13:26:46 martin Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.14.6.1 2014/11/09 14:42:33 martin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.14.6.2 2014/11/14 13:26:46 martin Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -323,18 +323,25 @@
*/
const uint32_t ocfg = bus_space_read_4(bst, bsh,
AWIN_CCM_OFFSET + AWIN_PLL6_CFG_REG);
- const u_int k = __SHIFTOUT(ocfg, AWIN_PLL_CFG_FACTOR_K);
/*
* Output freq is 24MHz * n * k / m / 6.
* To get to 100MHz, k & m must be equal and n must be 25.
*/
uint32_t ncfg = ocfg;
- ncfg &= ~(AWIN_PLL_CFG_FACTOR_M|AWIN_PLL_CFG_FACTOR_N);
ncfg &= ~(AWIN_PLL_CFG_BYPASS);
- ncfg |= __SHIFTIN(k, AWIN_PLL_CFG_FACTOR_M);
- ncfg |= __SHIFTIN(25, AWIN_PLL_CFG_FACTOR_N);
- ncfg |= AWIN_PLL_CFG_ENABLE | AWIN_PLL6_CFG_SATA_CLK_EN;
+ if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+ ncfg &= ~(AWIN_PLL_CFG_FACTOR_N|AWIN_PLL_CFG_FACTOR_K);
+ ncfg |= __SHIFTIN(1, AWIN_PLL_CFG_FACTOR_K);
+ ncfg |= __SHIFTIN(24, AWIN_PLL_CFG_FACTOR_N);
+ } else {
+ const u_int k = __SHIFTOUT(ocfg, AWIN_PLL_CFG_FACTOR_K);
+ ncfg &= ~(AWIN_PLL_CFG_FACTOR_M|AWIN_PLL_CFG_FACTOR_N);
+ ncfg |= __SHIFTIN(k, AWIN_PLL_CFG_FACTOR_M);
+ ncfg |= __SHIFTIN(25, AWIN_PLL_CFG_FACTOR_N);
+ ncfg |= AWIN_PLL6_CFG_SATA_CLK_EN;
+ }
+ ncfg |= AWIN_PLL_CFG_ENABLE;
if (ncfg != ocfg) {
bus_space_write_4(bst, bsh,
AWIN_CCM_OFFSET + AWIN_PLL6_CFG_REG, ncfg);
@@ -387,6 +394,44 @@
}
void
+awin_pll3_enable(void)
+{
+ bus_space_tag_t bst = &awin_bs_tag;
+ bus_space_handle_t bsh = awin_core_bsh;
+
+ /*
+ * HDMI needs PLL3 to be 29700000 Hz
+ */
+ const uint32_t ocfg = bus_space_read_4(bst, bsh,
+ AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG);
+
+ uint32_t ncfg = ocfg;
+
+ if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+ ncfg &= ~AWIN_A31_PLL3_CFG_MODE;
+ ncfg &= ~AWIN_A31_PLL3_CFG_MODE_SEL;
+ ncfg |= AWIN_A31_PLL3_CFG_FRAC_CLK_OUT;
+ ncfg |= AWIN_PLL_CFG_ENABLE;
+ } else {
+ ncfg &= ~AWIN_PLL3_MODE_SEL;
+ ncfg |= AWIN_PLL3_FRAC_SET;
+ ncfg |= AWIN_PLL_CFG_ENABLE;
+ }
+
+ if (ncfg != ocfg) {
+ bus_space_write_4(bst, bsh,
+ AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG, ncfg);
+
+ if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+ do {
+ ncfg = bus_space_read_4(bst, bsh,
+ AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG);
+ } while ((ncfg & AWIN_A31_PLL3_CFG_LOCK) == 0);
+ }
+ }
+}
+
+void
awin_pll7_enable(void)
{
bus_space_tag_t bst = &awin_bs_tag;
@@ -401,6 +446,7 @@
uint32_t ncfg = ocfg;
if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+ ncfg &= ~AWIN_A31_PLL7_CFG_MODE;
ncfg &= ~AWIN_A31_PLL7_CFG_MODE_SEL;
ncfg |= AWIN_A31_PLL7_CFG_FRAC_CLK_OUT;
ncfg |= AWIN_PLL_CFG_ENABLE;
@@ -415,3 +461,88 @@
AWIN_CCM_OFFSET + AWIN_PLL7_CFG_REG, ncfg);
}
}
+
+void
+awin_pll3_set_rate(uint32_t rate)
+{
+ bus_space_tag_t bst = &awin_bs_tag;
+ bus_space_handle_t bsh = awin_core_bsh;
+
+ const uint32_t ocfg = bus_space_read_4(bst, bsh,
+ AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG);
+
+ uint32_t ncfg = ocfg;
+ if (rate == 0) {
+ ncfg &= ~AWIN_PLL_CFG_ENABLE;
+ } else {
+ if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+ unsigned int m = 8;
+ unsigned int n = rate / (AWIN_REF_FREQ / m);
+ ncfg |= AWIN_A31_PLL3_CFG_MODE_SEL;
+ ncfg &= ~AWIN_A31_PLL3_CFG_FACTOR_N;
+ ncfg |= __SHIFTIN(n - 1, AWIN_A31_PLL3_CFG_FACTOR_N);
+ ncfg &= ~AWIN_A31_PLL3_CFG_PREDIV_M;
+ ncfg |= __SHIFTIN(m - 1, AWIN_A31_PLL3_CFG_PREDIV_M);
+ } else {
+ unsigned int m = rate / 3000000;
+ ncfg |= AWIN_PLL3_MODE_SEL;
+ ncfg &= ~AWIN_PLL3_FACTOR_M;
+ ncfg |= __SHIFTIN(m, AWIN_PLL3_FACTOR_M);
+ }
+ ncfg |= AWIN_PLL_CFG_ENABLE;
+ }
+
+ if (ncfg != ocfg) {
+ bus_space_write_4(bst, bsh,
+ AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG, ncfg);
+
+ if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+ do {
+ ncfg = bus_space_read_4(bst, bsh,
+ AWIN_CCM_OFFSET + AWIN_PLL3_CFG_REG);
+ } while ((ncfg & AWIN_A31_PLL3_CFG_LOCK) == 0);
+ }
+ }
+}
+
+uint32_t
+awin_pll5x_get_rate(void)
+{
+ bus_space_tag_t bst = &awin_bs_tag;
+ bus_space_handle_t bsh = awin_core_bsh;
+ unsigned int n, k, p;
+
+ KASSERT(awin_chip_id() != AWIN_CHIP_ID_A31);
+
+ const uint32_t cfg = bus_space_read_4(bst, bsh,
+ AWIN_CCM_OFFSET + AWIN_PLL5_CFG_REG);
+
+ n = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_N);
+ k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K);
+ p = __SHIFTOUT(cfg, AWIN_PLL5_OUT_EXT_DIV_P);
+
+ return (AWIN_REF_FREQ * n * k) >> p;
+}
+
+uint32_t
+awin_pll6_get_rate(void)
+{
+ bus_space_tag_t bst = &awin_bs_tag;
+ bus_space_handle_t bsh = awin_core_bsh;
+ unsigned int n, k, m;
+
+ const uint32_t cfg = bus_space_read_4(bst, bsh,
+ AWIN_CCM_OFFSET + AWIN_PLL6_CFG_REG);
+
+ if (awin_chip_id() == AWIN_CHIP_ID_A31) {
+ n = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_N) + 1;
+ k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K) + 1;
+ m = 2;
+ } else {
+ n = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_N);
+ k = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_K) + 1;
+ m = __SHIFTOUT(cfg, AWIN_PLL_CFG_FACTOR_M) + 1;
+ }
+
+ return (AWIN_REF_FREQ * n * k) / m;
+}
diff -r 29a5aeafbc2e -r 562c8536595c sys/arch/arm/allwinner/awin_debe.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/allwinner/awin_debe.c Fri Nov 14 13:26:46 2014 +0000
@@ -0,0 +1,344 @@
+/* $NetBSD: awin_debe.c,v 1.6.2.2 2014/11/14 13:26:46 martin Exp $ */
+
+/*-
+ * Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "opt_allwinner.h"
+#include "genfb.h"
+
+#ifndef AWIN_DEBE_VIDEOMEM
+#define AWIN_DEBE_VIDEOMEM (16 * 1024 * 1024)
+#endif
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.6.2.2 2014/11/14 13:26:46 martin Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+
+#include <arm/allwinner/awin_reg.h>
+#include <arm/allwinner/awin_var.h>
+
+#include <dev/videomode/videomode.h>
+
+struct awin_debe_softc {
+ device_t sc_dev;
+ device_t sc_fbdev;
+ bus_space_tag_t sc_bst;
+ bus_space_handle_t sc_bsh;
+ bus_space_handle_t sc_ccm_bsh;
+ bus_dma_tag_t sc_dmat;
+ unsigned int sc_port;
+
+ bus_dma_segment_t sc_dmasegs[1];
+ bus_size_t sc_dmasize;
+ bus_dmamap_t sc_dmamap;
+ void *sc_dmap;
+};
+
+#define DEBE_READ(sc, reg) \
+ bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
+#define DEBE_WRITE(sc, reg, val) \
+ bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
+
+static int awin_debe_match(device_t, cfdata_t, void *);
+static void awin_debe_attach(device_t, device_t, void *);
+
+static int awin_debe_alloc_videomem(struct awin_debe_softc *);
+static void awin_debe_setup_fbdev(struct awin_debe_softc *,
+ const struct videomode *);
+
+CFATTACH_DECL_NEW(awin_debe, sizeof(struct awin_debe_softc),
+ awin_debe_match, awin_debe_attach, NULL, NULL);
+
+static int
+awin_debe_match(device_t parent, cfdata_t cf, void *aux)
+{
+ struct awinio_attach_args * const aio = aux;
+ const struct awin_locators * const loc = &aio->aio_loc;
+
+ if (strcmp(cf->cf_name, loc->loc_name))
+ return 0;
+
+ return 1;
+}
+
+static void
+awin_debe_attach(device_t parent, device_t self, void *aux)
+{
+ struct awin_debe_softc *sc = device_private(self);
+ struct awinio_attach_args * const aio = aux;
+ const struct awin_locators * const loc = &aio->aio_loc;
+ int error;
+
+ sc->sc_dev = self;
+ sc->sc_bst = aio->aio_core_bst;
+ sc->sc_dmat = aio->aio_dmat;
Home |
Main Index |
Thread Index |
Old Index