Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/nvidia Tegra HD audio support (untested as it i...
details: https://anonhg.NetBSD.org/src/rev/a18b221aa472
branches: trunk
changeset: 338101:a18b221aa472
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun May 10 11:04:59 2015 +0000
description:
Tegra HD audio support (untested as it is for HDMI output)
diffstat:
sys/arch/arm/nvidia/tegra_car.c | 34 +++++++++++++++++++++-
sys/arch/arm/nvidia/tegra_carreg.h | 39 +++++++++++++++++++++++++-
sys/arch/arm/nvidia/tegra_hdaudio.c | 50 +++++++++++++++++++++++++++++++--
sys/arch/arm/nvidia/tegra_hdaudioreg.h | 50 ++++++++++++++++++++++++++++++++++
sys/arch/arm/nvidia/tegra_var.h | 3 +-
5 files changed, 169 insertions(+), 7 deletions(-)
diffs (290 lines):
diff -r ce740060bd53 -r a18b221aa472 sys/arch/arm/nvidia/tegra_car.c
--- a/sys/arch/arm/nvidia/tegra_car.c Sun May 10 10:14:02 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_car.c Sun May 10 11:04:59 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_car.c,v 1.6 2015/05/09 18:56:51 jmcneill Exp $ */
+/* $NetBSD: tegra_car.c,v 1.7 2015/05/10 11:04:59 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_car.c,v 1.6 2015/05/09 18:56:51 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_car.c,v 1.7 2015/05/10 11:04:59 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -371,3 +371,33 @@
tegra_reg_set_clear(bst, bsh, CAR_UTMIP_PLL_CFG2_REG, 0, bit);
}
+
+void
+tegra_car_periph_hda_enable(void)
+{
+ bus_space_tag_t bst;
+ bus_space_handle_t bsh;
+
+ tegra_car_get_bs(&bst, &bsh);
+
+ /* HDA */
+ bus_space_write_4(bst, bsh, CAR_RST_DEV_V_SET_REG, CAR_DEV_V_HDA);
+ bus_space_write_4(bst, bsh, CAR_CLK_ENB_V_SET_REG, CAR_DEV_V_HDA);
+ bus_space_write_4(bst, bsh, CAR_RST_DEV_V_CLR_REG, CAR_DEV_V_HDA);
+
+ /* HDA2CODEC_2X */
+ bus_space_write_4(bst, bsh, CAR_RST_DEV_V_SET_REG,
+ CAR_DEV_V_HDA2CODEC_2X);
+ bus_space_write_4(bst, bsh, CAR_CLK_ENB_V_SET_REG,
+ CAR_DEV_V_HDA2CODEC_2X);
+ bus_space_write_4(bst, bsh, CAR_RST_DEV_V_CLR_REG,
+ CAR_DEV_V_HDA2CODEC_2X);
+
+ /* HDA2HDMICODEC */
+ bus_space_write_4(bst, bsh, CAR_RST_DEV_W_SET_REG,
+ CAR_DEV_W_HDA2HDMICODEC);
+ bus_space_write_4(bst, bsh, CAR_CLK_ENB_W_SET_REG,
+ CAR_DEV_W_HDA2HDMICODEC);
+ bus_space_write_4(bst, bsh, CAR_RST_DEV_W_CLR_REG,
+ CAR_DEV_W_HDA2HDMICODEC);
+}
diff -r ce740060bd53 -r a18b221aa472 sys/arch/arm/nvidia/tegra_carreg.h
--- a/sys/arch/arm/nvidia/tegra_carreg.h Sun May 10 10:14:02 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_carreg.h Sun May 10 11:04:59 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_carreg.h,v 1.7 2015/05/09 18:56:51 jmcneill Exp $ */
+/* $NetBSD: tegra_carreg.h,v 1.8 2015/05/10 11:04:59 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -125,6 +125,10 @@
#define CAR_RST_DEV_H_CLR_REG 0x30c
#define CAR_RST_DEV_U_SET_REG 0x310
#define CAR_RST_DEV_U_CLR_REG 0x314
+#define CAR_RST_DEV_V_SET_REG 0x430
+#define CAR_RST_DEV_V_CLR_REG 0x434
+#define CAR_RST_DEV_W_SET_REG 0x438
+#define CAR_RST_DEV_W_CLR_REG 0x43c
#define CAR_CLK_ENB_L_SET_REG 0x320
#define CAR_CLK_ENB_L_CLR_REG 0x324
@@ -132,6 +136,10 @@
#define CAR_CLK_ENB_H_CLR_REG 0x32c
#define CAR_CLK_ENB_U_SET_REG 0x330
#define CAR_CLK_ENB_U_CLR_REG 0x334
+#define CAR_CLK_ENB_V_SET_REG 0x440
+#define CAR_CLK_ENB_V_CLR_REG 0x444
+#define CAR_CLK_ENB_W_SET_REG 0x448
+#define CAR_CLK_ENB_W_CLR_REG 0x44c
#define CAR_DEV_L_CACHE2 __BIT(31)
#define CAR_DEV_L_I2S0 __BIT(30)
@@ -213,6 +221,35 @@
#define CAR_DEV_H_AHBDMA __BIT(1)
#define CAR_DEV_H_MEM __BIT(0)
+#define CAR_DEV_V_HDA __BIT(29)
+#define CAR_DEV_V_SATA __BIT(28)
+#define CAR_DEV_V_ACTMON __BIT(23)
+#define CAR_DEV_V_ATOMICS __BIT(16)
+#define CAR_DEV_V_HDA2CODEC_2X __BIT(15)
+#define CAR_DEV_V_DAM2 __BIT(14)
+#define CAR_DEV_V_DAM1 __BIT(13)
+#define CAR_DEV_V_DAM0 __BIT(12)
+#define CAR_DEV_V_APBIF __BIT(11)
+#define CAR_DEV_V_AUDIO __BIT(10)
+#define CAR_DEV_V_SPI6 __BIT(9)
+#define CAR_DEV_V_SPI5 __BIT(8)
+#define CAR_DEV_V_I2C4 __BIT(7)
+#define CAR_DEV_V_I2S4 __BIT(6)
+#define CAR_DEV_V_I2S3 __BIT(5)
+#define CAR_DEV_V_MSELECT __BIT(3)
+#define CAR_DEV_V_CPULP __BIT(1)
+#define CAR_DEV_V_CPUG __BIT(0)
+
+#define CAR_DEV_W_XUSB_SS __BIT(28)
+#define CAR_DEV_W_DVFS __BIT(27)
+#define CAR_DEV_W_ADX0 __BIT(26)
+#define CAR_DEV_W_AMX0 __BIT(25)
+#define CAR_DEV_W_ENTROPY __BIT(21)
+#define CAR_DEV_W_XUSB_PADCTL __BIT(14)
+#define CAR_DEV_W_CEC __BIT(8)
+#define CAR_DEV_W_SATACOLD __BIT(1)
+#define CAR_DEV_W_HDA2HDMICODEC __BIT(0)
+
#define CAR_UTMIP_PLL_CFG0_REG 0x480
#define CAR_UTMIP_PLL_CFG1_REG 0x484
diff -r ce740060bd53 -r a18b221aa472 sys/arch/arm/nvidia/tegra_hdaudio.c
--- a/sys/arch/arm/nvidia/tegra_hdaudio.c Sun May 10 10:14:02 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_hdaudio.c Sun May 10 11:04:59 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_hdaudio.c,v 1.2 2015/04/26 16:48:00 jmcneill Exp $ */
+/* $NetBSD: tegra_hdaudio.c,v 1.3 2015/05/10 11:04:59 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_hdaudio.c,v 1.2 2015/04/26 16:48:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_hdaudio.c,v 1.3 2015/05/10 11:04:59 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -42,6 +42,16 @@
#include <dev/hdaudio/hdaudiovar.h>
#include <arm/nvidia/tegra_var.h>
+#include <arm/nvidia/tegra_pmcreg.h>
+#include <arm/nvidia/tegra_hdaudioreg.h>
+
+#define TEGRA_HDAUDIO_OFFSET 0x8000
+
+#define TEGRA_HDA_IFPS_BAR0_REG 0x0080
+#define TEGRA_HDA_IFPS_CONFIG_REG 0x0180
+#define TEGRA_HDA_IFPS_INTR_REG 0x0188
+#define TEGRA_HDA_CFG_CMD_REG 0x1004
+#define TEGRA_HDA_CFG_BAR0_REG 0x1010
static int tegra_hdaudio_match(device_t, cfdata_t, void *);
static void tegra_hdaudio_attach(device_t, device_t, void *);
@@ -53,9 +63,13 @@
struct tegra_hdaudio_softc {
struct hdaudio_softc sc;
+ bus_space_tag_t sc_bst;
+ bus_space_handle_t sc_bsh;
void *sc_ih;
};
+static void tegra_hdaudio_init(struct tegra_hdaudio_softc *);
+
CFATTACH_DECL2_NEW(tegra_hdaudio, sizeof(struct tegra_hdaudio_softc),
tegra_hdaudio_match, tegra_hdaudio_attach, tegra_hdaudio_detach, NULL,
tegra_hdaudio_rescan, tegra_hdaudio_childdet);
@@ -73,9 +87,14 @@
struct tegraio_attach_args * const tio = aux;
const struct tegra_locators * const loc = &tio->tio_loc;
+ sc->sc_bst = tio->tio_bst;
+ bus_space_subregion(tio->tio_bst, tio->tio_bsh,
+ loc->loc_offset, loc->loc_size, &sc->sc_bsh);
+
sc->sc.sc_memt = tio->tio_bst;
bus_space_subregion(tio->tio_bst, tio->tio_bsh,
- loc->loc_offset, loc->loc_size, &sc->sc.sc_memh);
+ loc->loc_offset + TEGRA_HDAUDIO_OFFSET,
+ loc->loc_size - TEGRA_HDAUDIO_OFFSET, &sc->sc.sc_memh);
sc->sc.sc_memvalid = true;
sc->sc.sc_dmat = tio->tio_dmat;
@@ -91,9 +110,34 @@
}
aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr);
+ tegra_pmc_power(PMC_PARTID_DISB, true);
+ tegra_car_periph_hda_enable();
+ tegra_hdaudio_init(sc);
+
hdaudio_attach(self, &sc->sc);
}
+static void
+tegra_hdaudio_init(struct tegra_hdaudio_softc *sc)
+{
+ tegra_reg_set_clear(sc->sc_bst, sc->sc_bsh, TEGRA_HDA_IFPS_CONFIG_REG,
+ TEGRA_HDA_IFPS_CONFIG_FPCI_EN, 0);
+ tegra_reg_set_clear(sc->sc_bst, sc->sc_bsh, TEGRA_HDA_CFG_CMD_REG,
+ TEGRA_HDA_CFG_CMD_ENABLE_SERR |
+ TEGRA_HDA_CFG_CMD_BUS_MASTER |
+ TEGRA_HDA_CFG_CMD_MEM_SPACE |
+ TEGRA_HDA_CFG_CMD_IO_SPACE,
+ TEGRA_HDA_CFG_CMD_DISABLE_INTR);
+ bus_space_write_4(sc->sc_bst, sc->sc_bsh, TEGRA_HDA_CFG_BAR0_REG,
+ 0xffffffff);
+ bus_space_write_4(sc->sc_bst, sc->sc_bsh, TEGRA_HDA_CFG_BAR0_REG,
+ 0x00004000);
+ bus_space_write_4(sc->sc_bst, sc->sc_bsh, TEGRA_HDA_IFPS_BAR0_REG,
+ TEGRA_HDA_CFG_BAR0_START);
+ tegra_reg_set_clear(sc->sc_bst, sc->sc_bsh, TEGRA_HDA_IFPS_INTR_REG,
+ TEGRA_HDA_IFPS_INTR_EN, 0);
+}
+
static int
tegra_hdaudio_detach(device_t self, int flags)
{
diff -r ce740060bd53 -r a18b221aa472 sys/arch/arm/nvidia/tegra_hdaudioreg.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/nvidia/tegra_hdaudioreg.h Sun May 10 11:04:59 2015 +0000
@@ -0,0 +1,50 @@
+/* $NetBSD: tegra_hdaudioreg.h,v 1.1 2015/05/10 11:04:59 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2015 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.
+ */
+
+#ifndef _ARM_TEGRA_HDAUDIOREG_H
+#define _ARM_TEGRA_HDAUDIOREG_H
+
+#define TEGRA_HDA_IFPS_BAR0_REG 0x0080
+
+#define TEGRA_HDA_IFPS_CONFIG_REG 0x0180
+#define TEGRA_HDA_IFPS_CONFIG_FPCI_EN __BIT(0)
+
+#define TEGRA_HDA_IFPS_INTR_REG 0x0188
+#define TEGRA_HDA_IFPS_INTR_EN __BIT(16)
+
+#define TEGRA_HDA_CFG_CMD_REG 0x1004
+#define TEGRA_HDA_CFG_CMD_DISABLE_INTR __BIT(10)
+#define TEGRA_HDA_CFG_CMD_ENABLE_SERR __BIT(8)
+#define TEGRA_HDA_CFG_CMD_BUS_MASTER __BIT(2)
+#define TEGRA_HDA_CFG_CMD_MEM_SPACE __BIT(1)
+#define TEGRA_HDA_CFG_CMD_IO_SPACE __BIT(0)
+
+#define TEGRA_HDA_CFG_BAR0_REG 0x1010
+#define TEGRA_HDA_CFG_BAR0_START __BIT(6)
+
+#endif /* _ARM_TEGRA_HDAUDIOREG_H */
diff -r ce740060bd53 -r a18b221aa472 sys/arch/arm/nvidia/tegra_var.h
--- a/sys/arch/arm/nvidia/tegra_var.h Sun May 10 10:14:02 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_var.h Sun May 10 11:04:59 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_var.h,v 1.11 2015/05/09 18:56:51 jmcneill Exp $ */
+/* $NetBSD: tegra_var.h,v 1.12 2015/05/10 11:04:59 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -82,6 +82,7 @@
u_int tegra_car_periph_sdmmc_rate(u_int);
int tegra_car_periph_sdmmc_set_div(u_int, u_int);
int tegra_car_periph_usb_enable(u_int);
+void tegra_car_periph_hda_enable(void);
void tegra_car_utmip_init(void);
void tegra_car_utmip_enable(u_int);
Home |
Main Index |
Thread Index |
Old Index