Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/conf i.MX support merged into GENERIC kernel.
details: https://anonhg.NetBSD.org/src/rev/699d66b36d06
branches: trunk
changeset: 933162:699d66b36d06
user: hkenken <hkenken%NetBSD.org@localhost>
date: Wed May 20 09:18:25 2020 +0000
description:
i.MX support merged into GENERIC kernel.
diffstat:
sys/arch/arm/imx/fdt/files.imx6 | 21 +-
sys/arch/arm/imx/fdt/imx6_dwhdmi.c | 285 +++++++++++++++++++++++++++++++++++++
sys/arch/arm/imx/fdt/imx6_pwm.c | 142 ++++++++++++++++++
sys/arch/arm/imx/fdt/imx6_spi.c | 6 +-
sys/arch/arm/imx/imxuart.c | 10 +-
sys/arch/evbarm/conf/GENERIC | 21 ++-
sys/arch/evbarm/conf/IMX | 140 ------------------
sys/arch/evbarm/conf/files.generic | 3 +-
sys/arch/evbarm/conf/files.imx | 20 --
sys/arch/evbarm/conf/mk.imx | 34 ----
sys/arch/evbarm/conf/std.imx | 32 ----
sys/conf/files | 4 +-
12 files changed, 470 insertions(+), 248 deletions(-)
diffs (truncated from 992 to 300 lines):
diff -r c6cd52fa5978 -r 699d66b36d06 sys/arch/arm/imx/fdt/files.imx6
--- a/sys/arch/arm/imx/fdt/files.imx6 Wed May 20 08:15:26 2020 +0000
+++ b/sys/arch/arm/imx/fdt/files.imx6 Wed May 20 09:18:25 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.imx6,v 1.8 2020/01/15 01:09:56 jmcneill Exp $
+# $NetBSD: files.imx6,v 1.9 2020/05/20 09:18:25 hkenken Exp $
#
# Configuration info for the Freescale i.MX6
#
@@ -10,12 +10,11 @@
defflag opt_soc.h SOC_IMX6QDL: SOC_IMX
# Clock
-device imxccm : clk
+device imxccm: clk
attach imxccm at fdt
file arch/arm/imx/imx6_ccm.c imxccm
file arch/arm/imx/fdt/imx6_clk.c imxccm
-
# Common FDT clock framework
define imx_ccm
file arch/arm/imx/fdt/imx_ccm.c imx_ccm
@@ -51,7 +50,7 @@
file arch/arm/imx/fdt/imx6_gpio.c imxgpio
# UART
-device imxuart { } : bus_space_generic
+device imxuart: tty
attach imxuart at fdt with imx6_com
file arch/arm/imx/imxuart.c imxuart needs-flag
file arch/arm/imx/fdt/imx6_com.c imx6_com needs-flag
@@ -84,7 +83,6 @@
attach imx8mqusbphy at fdt
file arch/arm/imx/fdt/imx8mq_usbphy.c imx8mqusbphy
-
# SDMMC
attach sdhc at fdt with imx6_sdhc
file arch/arm/imx/fdt/imx6_sdhc.c imx6_sdhc
@@ -102,9 +100,18 @@
file arch/arm/imx/fdt/imx6_i2c.c imxi2c
# SPI bus controller
-device imxspi : spibus
+device imxspi: spibus
attach imxspi at fdt with imxspi_fdt
-file arch/arm/imx/imxspi.c imxspi
+file arch/arm/imx/imxspi.c imxspi
file arch/arm/imx/fdt/imx6_spi.c imxspi_fdt
defparam opt_imxspi.h IMXSPINSLAVES
+# PWM
+device imxpwm: pwm
+attach imxpwm at fdt with imxpwm_fdt
+file arch/arm/imx/imxpwm.c imxpwm
+file arch/arm/imx/fdt/imx6_pwm.c imxpwm_fdt
+
+# HDMI TX (Designware based)
+attach dwhdmi at fdt with imx6_dwhdmi
+file arch/arm/imx/fdt/imx6_dwhdmi.c imx6_dwhdmi
diff -r c6cd52fa5978 -r 699d66b36d06 sys/arch/arm/imx/fdt/imx6_dwhdmi.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/imx/fdt/imx6_dwhdmi.c Wed May 20 09:18:25 2020 +0000
@@ -0,0 +1,285 @@
+/* $NetBSD: imx6_dwhdmi.c,v 1.1 2020/05/20 09:18:25 hkenken Exp $ */
+/*-
+ * Copyright (c) 2020 Genetec Corporation. All rights reserved.
+ * Written by Hashimoto Kenichi for Genetec Corporation.
+ *
+ * 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 <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: imx6_dwhdmi.c,v 1.1 2020/05/20 09:18:25 hkenken 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/conf.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc_helper.h>
+
+#include <dev/fdt/fdtvar.h>
+#include <dev/fdt/fdt_port.h>
+#include <dev/fdt/syscon.h>
+
+#include <dev/ic/dw_hdmi.h>
+
+static const struct dwhdmi_mpll_config imx6_dwhdmi_mpll_config[] = {
+ { 45250, 0x01e0, 0x0000, 0x091c },
+ { 92500, 0x0072, 0x0001, 0x06dc },
+ { 148500, 0x0051, 0x0002, 0x091c },
+ { 216000, 0x00a0, 0x000a, 0x06dc },
+ { 0, 0x0000, 0x0000, 0x0000 },
+};
+
+static const struct dwhdmi_phy_config imx6_dwhdmi_phy_config[] = {
+ { 216000, 0x800d, 0x000a, 0x01ad },
+ { 0, 0x0000, 0x0000, 0x0000 }
+};
+
+enum {
+ DWHDMI_PORT_INPUT = 0,
+ DWHDMI_PORT_OUTPUT = 1,
+};
+
+static const char * const compatible[] = {
+ "fsl,imx6dl-hdmi",
+ "fsl,imx6q-hdmi",
+ NULL
+};
+
+struct imx6_dwhdmi_softc {
+ struct dwhdmi_softc sc_base;
+ int sc_phandle;
+
+ struct fdt_device_ports sc_ports;
+ struct drm_display_mode sc_curmode;
+ struct drm_encoder sc_encoder;
+
+ bool sc_activated;
+};
+
+#define to_imx6_dwhdmi_softc(x) container_of(x, struct imx6_dwhdmi_softc, sc_base)
+#define to_imx6_dwhdmi_encoder(x) container_of(x, struct imx6_dwhdmi_softc, sc_encoder)
+
+static bool
+imx6_dwhdmi_encoder_mode_fixup(struct drm_encoder *encoder,
+ const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode)
+{
+ return true;
+}
+
+static void
+imx6_dwhdmi_encoder_mode_set(struct drm_encoder *encoder,
+ struct drm_display_mode *mode, struct drm_display_mode *adjusted)
+{
+}
+
+static void
+imx6_dwhdmi_encoder_enable(struct drm_encoder *encoder)
+{
+}
+
+static void
+imx6_dwhdmi_encoder_disable(struct drm_encoder *encoder)
+{
+}
+
+static void
+imx6_dwhdmi_encoder_prepare(struct drm_encoder *encoder)
+{
+}
+
+static void
+imx6_dwhdmi_encoder_commit(struct drm_encoder *encoder)
+{
+}
+
+static const struct drm_encoder_funcs imx6_dwhdmi_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
+static const struct drm_encoder_helper_funcs imx6_dwhdmi_encoder_helper_funcs = {
+ .prepare = imx6_dwhdmi_encoder_prepare,
+ .mode_fixup = imx6_dwhdmi_encoder_mode_fixup,
+ .mode_set = imx6_dwhdmi_encoder_mode_set,
+ .enable = imx6_dwhdmi_encoder_enable,
+ .disable = imx6_dwhdmi_encoder_disable,
+ .commit = imx6_dwhdmi_encoder_commit,
+};
+
+static int
+imx6_dwhdmi_ep_activate(device_t dev, struct fdt_endpoint *ep, bool activate)
+{
+ struct imx6_dwhdmi_softc * const sc = device_private(dev);
+ struct fdt_endpoint *in_ep = fdt_endpoint_remote(ep);
+ struct fdt_endpoint *out_ep, *out_rep;
+ struct drm_crtc *crtc;
+ int error;
+
+ if (sc->sc_activated != false) {
+ return 0;
+ }
+
+ if (!activate)
+ return EINVAL;
+
+ if (fdt_endpoint_port_index(ep) != DWHDMI_PORT_INPUT)
+ return EINVAL;
+
+ switch (fdt_endpoint_type(in_ep)) {
+ case EP_DRM_CRTC:
+ crtc = fdt_endpoint_get_data(in_ep);
+ break;
+ default:
+ crtc = NULL;
+ break;
+ }
+
+ if (crtc == NULL)
+ return EINVAL;
+
+ sc->sc_encoder.possible_crtcs = 3; // 1U << drm_crtc_index(crtc); /* XXX */
+ drm_encoder_init(crtc->dev, &sc->sc_encoder, &imx6_dwhdmi_encoder_funcs,
+ DRM_MODE_ENCODER_TMDS);
+ drm_encoder_helper_add(&sc->sc_encoder, &imx6_dwhdmi_encoder_helper_funcs);
+
+ sc->sc_base.sc_connector.base.connector_type = DRM_MODE_CONNECTOR_HDMIA;
+ error = dwhdmi_bind(&sc->sc_base, &sc->sc_encoder);
+ if (error != 0)
+ return error;
+ sc->sc_activated = true;
+
+ out_ep = fdt_endpoint_get_from_index(&sc->sc_ports, DWHDMI_PORT_OUTPUT, 0);
+ if (out_ep != NULL) {
+ /* Ignore downstream connectors, we have our own. */
+ out_rep = fdt_endpoint_remote(out_ep);
+ if (out_rep != NULL && fdt_endpoint_type(out_rep) == EP_DRM_CONNECTOR)
+ return 0;
+
+ error = fdt_endpoint_activate(out_ep, activate);
+ if (error != 0)
+ return error;
+ }
+
+ return 0;
+}
+
+static void *
+imx6_dwhdmi_ep_get_data(device_t dev, struct fdt_endpoint *ep)
+{
+ struct imx6_dwhdmi_softc * const sc = device_private(dev);
+
+ return &sc->sc_encoder;
+}
+
+static audio_dai_tag_t
+imx6_dwhdmi_dai_get_tag(device_t dev, const void *data, size_t len)
+{
+ struct imx6_dwhdmi_softc * const sc = device_private(dev);
+
+ if (len != 4)
+ return NULL;
+
+ return &sc->sc_base.sc_dai;
+}
+
+static struct fdtbus_dai_controller_func imx6_dwhdmi_dai_funcs = {
+ .get_tag = imx6_dwhdmi_dai_get_tag
+};
+
+static int
+imx6_dwhdmi_match(device_t parent, cfdata_t cf, void *aux)
+{
+ struct fdt_attach_args * const faa = aux;
+
+ return of_match_compatible(faa->faa_phandle, compatible);
+}
+
+static void
+imx6_dwhdmi_attach(device_t parent, device_t self, void *aux)
+{
+ struct imx6_dwhdmi_softc * const sc = device_private(self);
+ struct fdt_attach_args * const faa = aux;
+ const int phandle = faa->faa_phandle;
+ bus_addr_t addr;
+ bus_size_t size;
+
+ if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
+ aprint_error(": couldn't get registers\n");
+ return;
+ }
+
+ /* Required */
+ if (fdtbus_clock_enable(phandle, "iahb", true) != 0) {
Home |
Main Index |
Thread Index |
Old Index