Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Use fdt for device enumeration.
details: https://anonhg.NetBSD.org/src/rev/a66808f9a296
branches: trunk
changeset: 342237:a66808f9a296
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Dec 13 17:39:19 2015 +0000
description:
Use fdt for device enumeration.
diffstat:
sys/arch/arm/nvidia/files.tegra | 60 ++++----
sys/arch/arm/nvidia/tegra_ahcisata.c | 93 ++++++++++---
sys/arch/arm/nvidia/tegra_car.c | 45 ++++--
sys/arch/arm/nvidia/tegra_cec.c | 51 +++++--
sys/arch/arm/nvidia/tegra_com.c | 110 ++++++++++++----
sys/arch/arm/nvidia/tegra_drm.c | 90 ++++++++----
sys/arch/arm/nvidia/tegra_drm.h | 13 +-
sys/arch/arm/nvidia/tegra_drm_mode.c | 16 +-
sys/arch/arm/nvidia/tegra_ehci.c | 80 +++++++----
sys/arch/arm/nvidia/tegra_fdt.c | 95 ++++++++++++++
sys/arch/arm/nvidia/tegra_fuse.c | 31 +++-
sys/arch/arm/nvidia/tegra_gpio.c | 128 +++++++++++++++++-
sys/arch/arm/nvidia/tegra_hdaudio.c | 60 ++++++---
sys/arch/arm/nvidia/tegra_host1x.c | 81 ------------
sys/arch/arm/nvidia/tegra_i2c.c | 120 ++++++++++++++---
sys/arch/arm/nvidia/tegra_io.c | 225 ----------------------------------
sys/arch/arm/nvidia/tegra_lic.c | 199 ++++++++++++++++++++++++++++++
sys/arch/arm/nvidia/tegra_mc.c | 49 +++++--
sys/arch/arm/nvidia/tegra_mpio.c | 31 +++-
sys/arch/arm/nvidia/tegra_pcie.c | 81 ++++++++---
sys/arch/arm/nvidia/tegra_pmc.c | 33 +++-
sys/arch/arm/nvidia/tegra_rtc.c | 33 +++-
sys/arch/arm/nvidia/tegra_sdhc.c | 116 +++++++++++-----
sys/arch/arm/nvidia/tegra_soctherm.c | 33 +++-
sys/arch/arm/nvidia/tegra_timer.c | 31 +++-
sys/arch/arm/nvidia/tegra_usbphy.c | 78 ++++++++---
sys/arch/arm/nvidia/tegra_xusbpad.c | 35 +++-
sys/arch/evbarm/conf/JETSONTK1 | 97 +++++++-------
sys/arch/evbarm/conf/files.tegra | 6 +-
sys/arch/evbarm/conf/mk.tegra | 4 +-
sys/arch/evbarm/tegra/tegra_machdep.c | 137 ++++++++------------
sys/arch/evbarm/tegra/tegra_start.S | 20 +--
32 files changed, 1415 insertions(+), 866 deletions(-)
diffs (truncated from 3692 to 300 lines):
diff -r 3b17abc4857c -r a66808f9a296 sys/arch/arm/nvidia/files.tegra
--- a/sys/arch/arm/nvidia/files.tegra Sun Dec 13 17:30:40 2015 +0000
+++ b/sys/arch/arm/nvidia/files.tegra Sun Dec 13 17:39:19 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.tegra,v 1.24 2015/11/21 22:55:32 jmcneill Exp $
+# $NetBSD: files.tegra,v 1.25 2015/12/13 17:39:19 jmcneill Exp $
#
# Configuration info for NVIDIA Tegra ARM Peripherals
#
@@ -22,107 +22,109 @@
attach tegraio at mainbus with tegra_io
file arch/arm/nvidia/tegra_io.c tegra_io
+device tegrafdt : bus_space_generic, fdtbus
+attach tegrafdt at mainbus with tegra_fdt
+file arch/arm/nvidia/tegra_fdt.c tegra_fdt
+
+# Interrupt controller
+device tegralic
+attach tegralic at fdt with tegra_lic
+file arch/arm/nvidia/tegra_lic.c tegra_lic
+
# Memory controller
device tegramc
-attach tegramc at tegraio with tegra_mc
+attach tegramc at fdt with tegra_mc
file arch/arm/nvidia/tegra_mc.c tegra_mc
# Power management controller
device tegrapmc
-attach tegrapmc at tegraio with tegra_pmc
+attach tegrapmc at fdt with tegra_pmc
file arch/arm/nvidia/tegra_pmc.c tegra_pmc
# eFUSE
device tegrafuse
-attach tegrafuse at tegraio with tegra_fuse
+attach tegrafuse at fdt with tegra_fuse
file arch/arm/nvidia/tegra_fuse.c tegra_fuse
# Clock and Reset controller
device tegracar
-attach tegracar at tegraio with tegra_car
+attach tegracar at fdt with tegra_car
file arch/arm/nvidia/tegra_car.c tegra_car
# GPIO controller
device tegragpio: gpiobus
-attach tegragpio at tegraio with tegra_gpio
+attach tegragpio at fdt with tegra_gpio
file arch/arm/nvidia/tegra_gpio.c tegra_gpio
# Timers
device tegratimer: sysmon_wdog
-attach tegratimer at tegraio with tegra_timer
+attach tegratimer at fdt with tegra_timer
file arch/arm/nvidia/tegra_timer.c tegra_timer
# MPIO / Pinmux
device tegrampio
-attach tegrampio at tegraio with tegra_mpio
+attach tegrampio at fdt with tegra_mpio
file arch/arm/nvidia/tegra_mpio.c tegra_mpio
# XUSB PADCTL
device tegraxusbpad
-attach tegraxusbpad at tegraio with tegra_xusbpad
+attach tegraxusbpad at fdt with tegra_xusbpad
file arch/arm/nvidia/tegra_xusbpad.c tegra_xusbpad
# UART
-attach com at tegraio with tegra_com
+attach com at fdt with tegra_com
file arch/arm/nvidia/tegra_com.c tegra_com needs-flag
# I2C
device tegrai2c: i2cbus, i2cexec
-attach tegrai2c at tegraio with tegra_i2c
+attach tegrai2c at fdt with tegra_i2c
file arch/arm/nvidia/tegra_i2c.c tegra_i2c
# RTC
device tegrartc
-attach tegrartc at tegraio with tegra_rtc
+attach tegrartc at fdt with tegra_rtc
file arch/arm/nvidia/tegra_rtc.c tegra_rtc
# USB PHY
-define tegrausbphybus { }
device tegrausbphy
-attach tegrausbphy at tegrausbphybus with tegra_usbphy
+attach tegrausbphy at fdt with tegra_usbphy
file arch/arm/nvidia/tegra_usbphy.c tegra_usbphy
# USB 2.0
-device tegraehci: usbus, usbroothub, usb_dma, ehci, tegrausbphybus
-attach tegraehci at tegraio with tegra_ehci
+attach ehci at fdt with tegra_ehci
file arch/arm/nvidia/tegra_ehci.c tegra_ehci
# SDMMC
-attach sdhc at tegraio with tegra_sdhc
+attach sdhc at fdt with tegra_sdhc
file arch/arm/nvidia/tegra_sdhc.c tegra_sdhc
# Thermal throttling controller
device tegrasoctherm: sysmon_envsys
-attach tegrasoctherm at tegraio with tegra_soctherm
+attach tegrasoctherm at fdt with tegra_soctherm
file arch/arm/nvidia/tegra_soctherm.c tegra_soctherm
# PCIE
device tegrapcie: pcibus
-attach tegrapcie at tegraio with tegra_pcie
+attach tegrapcie at fdt with tegra_pcie
file arch/arm/nvidia/tegra_pcie.c tegra_pcie
# SATA
-attach ahcisata at tegraio with tegra_ahcisata
+attach ahcisata at fdt with tegra_ahcisata
file arch/arm/nvidia/tegra_ahcisata.c tegra_ahcisata
# HDA
-attach hdaudio at tegraio with tegra_hdaudio
+attach hdaudio at fdt with tegra_hdaudio
file arch/arm/nvidia/tegra_hdaudio.c tegra_hdaudio
-# Host1x subsystem
-device tegrahost1x
-attach tegrahost1x at tegraio with tegra_host1x
-file arch/arm/nvidia/tegra_host1x.c tegra_host1x
-
# HDMI CEC
device tegracec: hdmicecbus
-attach tegracec at tegraio with tegra_cec
+attach tegracec at fdt with tegra_cec
file arch/arm/nvidia/tegra_cec.c tegra_cec
# Display
define tegrafbbus { }
-device tegradrm: drmkms, tegrafbbus
-attach tegradrm at tegraio with tegra_drm
+device tegradrm: drmkms, ddc_read_edid, tegrafbbus
+attach tegradrm at fdt with tegra_drm
file arch/arm/nvidia/tegra_drm.c tegra_drm
file arch/arm/nvidia/tegra_drm_mode.c tegra_drm
file arch/arm/nvidia/tegra_drm_fb.c tegra_drm
diff -r 3b17abc4857c -r a66808f9a296 sys/arch/arm/nvidia/tegra_ahcisata.c
--- a/sys/arch/arm/nvidia/tegra_ahcisata.c Sun Dec 13 17:30:40 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_ahcisata.c Sun Dec 13 17:39:19 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_ahcisata.c,v 1.7 2015/10/15 09:04:35 jmcneill Exp $ */
+/* $NetBSD: tegra_ahcisata.c,v 1.8 2015/12/13 17:39:19 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,10 +26,8 @@
* SUCH DAMAGE.
*/
-#include "locators.h"
-
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_ahcisata.c,v 1.7 2015/10/15 09:04:35 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_ahcisata.c,v 1.8 2015/12/13 17:39:19 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -44,6 +42,8 @@
#include <arm/nvidia/tegra_var.h>
#include <arm/nvidia/tegra_ahcisatareg.h>
+#include <dev/fdt/fdtvar.h>
+
#define TEGRA_AHCISATA_OFFSET 0x7000
static int tegra_ahcisata_match(device_t, cfdata_t, void *);
@@ -58,6 +58,14 @@
struct tegra_gpio_pin *sc_pin_power;
};
+static const char * const tegra_ahcisata_supplies[] = {
+ "hvdd-supply",
+ "vddio-supply",
+ "avdd-supply",
+ "target-5v-supply",
+ "target-12v-supply"
+};
+
static void tegra_ahcisata_init(struct tegra_ahcisata_softc *);
CFATTACH_DECL_NEW(tegra_ahcisata, sizeof(struct tegra_ahcisata_softc),
@@ -66,38 +74,66 @@
static int
tegra_ahcisata_match(device_t parent, cfdata_t cf, void *aux)
{
- return 1;
+ const char * const compatible[] = { "nvidia,tegra124-ahci", NULL };
+ struct fdt_attach_args * const faa = aux;
+
+ return of_match_compatible(faa->faa_phandle, compatible);
}
static void
tegra_ahcisata_attach(device_t parent, device_t self, void *aux)
{
struct tegra_ahcisata_softc * const sc = device_private(self);
- struct tegraio_attach_args * const tio = aux;
- const struct tegra_locators * const loc = &tio->tio_loc;
- prop_dictionary_t prop = device_properties(self);
- const char *pin;
+ struct fdt_attach_args * const faa = aux;
+ const int phandle = faa->faa_phandle;
+ bus_addr_t ahci_addr, sata_addr;
+ bus_size_t ahci_size, sata_size;
+ struct fdtbus_regulator *reg;
+ char intrstr[128];
+ int error, n;
- sc->sc_bst = tio->tio_bst;
- bus_space_subregion(tio->tio_bst, tio->tio_bsh,
- loc->loc_offset, loc->loc_size, &sc->sc_bsh);
+ if (fdtbus_get_reg(phandle, 0, &ahci_addr, &ahci_size) != 0) {
+ aprint_error(": couldn't get ahci registers\n");
+ return;
+ }
+ if (fdtbus_get_reg(phandle, 1, &sata_addr, &sata_size) != 0) {
+ aprint_error(": couldn't get sata registers\n");
+ return;
+ }
+
+ sc->sc_bst = faa->faa_bst;
+ error = bus_space_map(sc->sc_bst, sata_addr, sata_size, 0, &sc->sc_bsh);
+ if (error) {
+ aprint_error(": couldn't map sata registers: %d\n", error);
+ return;
+ }
sc->sc.sc_atac.atac_dev = self;
- sc->sc.sc_dmat = tio->tio_dmat;
- sc->sc.sc_ahcit = tio->tio_bst;
- sc->sc.sc_ahcis = loc->loc_size - TEGRA_AHCISATA_OFFSET;
- bus_space_subregion(tio->tio_bst, tio->tio_bsh,
- loc->loc_offset + TEGRA_AHCISATA_OFFSET,
- loc->loc_size - TEGRA_AHCISATA_OFFSET, &sc->sc.sc_ahcih);
+ sc->sc.sc_dmat = faa->faa_dmat;
+ sc->sc.sc_ahcit = faa->faa_bst;
+ sc->sc.sc_ahcis = ahci_size;
+ error = bus_space_map(sc->sc.sc_ahcit, ahci_addr, ahci_size, 0,
+ &sc->sc.sc_ahcih);
+ if (error) {
+ aprint_error(": couldn't map ahci registers: %d\n", error);
+ return;
+ }
sc->sc.sc_ahci_quirks = AHCI_QUIRK_SKIP_RESET;
aprint_naive("\n");
aprint_normal(": SATA\n");
- if (prop_dictionary_get_cstring_nocopy(prop, "power-gpio", &pin)) {
- sc->sc_pin_power = tegra_gpio_acquire(pin, GPIO_PIN_OUTPUT);
- if (sc->sc_pin_power)
- tegra_gpio_write(sc->sc_pin_power, 1);
+ for (n = 0; n < __arraycount(tegra_ahcisata_supplies); n++) {
+ const char *supply = tegra_ahcisata_supplies[n];
+ reg = fdtbus_regulator_acquire(phandle, supply);
+ if (reg == NULL) {
+ aprint_error_dev(self, "couldn't acquire %s\n", supply);
+ continue;
+ }
+ if (fdtbus_regulator_enable(reg) != 0) {
+ aprint_error_dev(self, "couldn't enable %s\n", supply);
+ }
+ fdtbus_regulator_release(reg);
}
tegra_car_periph_sata_enable();
@@ -106,14 +142,19 @@
tegra_ahcisata_init(sc);
- sc->sc_ih = intr_establish(loc->loc_intr, IPL_BIO, IST_LEVEL,
+ if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
+ aprint_error_dev(self, "failed to decode interrupt\n");
+ return;
+ }
+
+ sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_BIO, 0,
ahci_intr, &sc->sc);
if (sc->sc_ih == NULL) {
- aprint_error_dev(self, "couldn't establish interrupt %d\n",
- loc->loc_intr);
+ aprint_error_dev(self, "failed to establish interrupt on %s\n",
+ intrstr);
return;
}
- aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr);
+ aprint_normal_dev(self, "interrupting on %s\n", intrstr);
ahci_attach(&sc->sc);
Home |
Main Index |
Thread Index |
Old Index