summaryrefslogtreecommitdiffstats
path: root/sys/arm/ti
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2017-03-13 10:27:25 -0300
committerRenato Botelho <renato@netgate.com>2017-03-13 10:27:25 -0300
commitf391165890a47339ab36ad68ac2e8a7ac318a2f4 (patch)
treebb32a2782e69e28e5b16c4baa2891da7f2193c37 /sys/arm/ti
parent01a697b38d55406857d04f6b92d9aaf15e492384 (diff)
parentf5b4bf3db9bb31ce466c39af8ee4b81aa991c7a6 (diff)
downloadFreeBSD-src-f391165890a47339ab36ad68ac2e8a7ac318a2f4.zip
FreeBSD-src-f391165890a47339ab36ad68ac2e8a7ac318a2f4.tar.gz
Merge remote-tracking branch 'origin/stable/11' into devel-11
Diffstat (limited to 'sys/arm/ti')
-rw-r--r--sys/arm/ti/am335x/am335x_dmtpps.c14
-rw-r--r--sys/arm/ti/am335x/am335x_dmtreg.h2
-rw-r--r--sys/arm/ti/am335x/am335x_lcd.c4
-rw-r--r--sys/arm/ti/am335x/am335x_lcd_syscons.c12
-rw-r--r--sys/arm/ti/ti_adc.c20
-rw-r--r--sys/arm/ti/ti_common.c4
-rw-r--r--sys/arm/ti/ti_machdep.c15
-rw-r--r--sys/arm/ti/ti_sdhci.c60
8 files changed, 63 insertions, 68 deletions
diff --git a/sys/arm/ti/am335x/am335x_dmtpps.c b/sys/arm/ti/am335x/am335x_dmtpps.c
index 6ed9bd5..2c4e634 100644
--- a/sys/arm/ti/am335x/am335x_dmtpps.c
+++ b/sys/arm/ti/am335x/am335x_dmtpps.c
@@ -163,7 +163,7 @@ dmtpps_translate_nickname(const char *nick)
* fails that IS an error, return -1.
*/
static int
-dmtpps_find_tmr_num_by_tunable()
+dmtpps_find_tmr_num_by_tunable(void)
{
struct padinfo *pi;
char iname[20];
@@ -201,7 +201,7 @@ dmtpps_find_tmr_num_by_tunable()
* input pin. If so, return the timer number, if not return 0.
*/
static int
-dmtpps_find_tmr_num_by_padconf()
+dmtpps_find_tmr_num_by_padconf(void)
{
int err;
unsigned int padstate;
@@ -225,7 +225,7 @@ dmtpps_find_tmr_num_by_padconf()
* configuration. This is done just once, the first time probe() runs.
*/
static int
-dmtpps_find_tmr_num()
+dmtpps_find_tmr_num(void)
{
int tmr_num;
@@ -463,6 +463,14 @@ dmtpps_attach(device_t dev)
sc->tmr_num = ti_hwmods_get_unit(dev, "timer");
snprintf(sc->tmr_name, sizeof(sc->tmr_name), "DMTimer%d", sc->tmr_num);
+ /*
+ * Configure the timer pulse/capture pin to input/capture mode. This is
+ * required in addition to configuring the pin as input with the pinmux
+ * controller (which was done via fdt data or tunable at probe time).
+ */
+ sc->tclr = DMT_TCLR_GPO_CFG;
+ DMTIMER_WRITE4(sc, DMT_TCLR, sc->tclr);
+
/* Set up timecounter hardware, start it. */
DMTIMER_WRITE4(sc, DMT_TSICR, DMT_TSICR_RESET);
while (DMTIMER_READ4(sc, DMT_TIOCP_CFG) & DMT_TIOCP_RESET)
diff --git a/sys/arm/ti/am335x/am335x_dmtreg.h b/sys/arm/ti/am335x/am335x_dmtreg.h
index 8a9d637..f2ef54d 100644
--- a/sys/arm/ti/am335x/am335x_dmtreg.h
+++ b/sys/arm/ti/am335x/am335x_dmtreg.h
@@ -62,7 +62,7 @@
#define DMT_TCLR_TRGMODE_BOTH (2 << 10) /* Trigger on match + ovflow */
#define DMT_TCLR_PWM_PTOGGLE (1 << 12) /* PWM toggles */
#define DMT_TCLR_CAP_MODE_2ND (1 << 13) /* Capture second event mode */
-#define DMT_TCLR_GPO_CFG (1 << 14) /* (no descr in datasheet) */
+#define DMT_TCLR_GPO_CFG (1 << 14) /* Tmr pin conf, 0=out, 1=in */
#define DMT_TCRR 0x3C /* Counter Register */
#define DMT_TLDR 0x40 /* Load Reg */
#define DMT_TTGR 0x44 /* Trigger Reg */
diff --git a/sys/arm/ti/am335x/am335x_lcd.c b/sys/arm/ti/am335x/am335x_lcd.c
index 8121ef5..c23aa24 100644
--- a/sys/arm/ti/am335x/am335x_lcd.c
+++ b/sys/arm/ti/am335x/am335x_lcd.c
@@ -359,13 +359,13 @@ am335x_read_property(device_t dev, phandle_t node, const char *name, uint32_t *v
{
pcell_t cell;
- if ((OF_getprop(node, name, &cell, sizeof(cell))) <= 0) {
+ if ((OF_getencprop(node, name, &cell, sizeof(cell))) <= 0) {
device_printf(dev, "missing '%s' attribute in LCD panel info\n",
name);
return (ENXIO);
}
- *val = fdt32_to_cpu(cell);
+ *val = cell;
return (0);
}
diff --git a/sys/arm/ti/am335x/am335x_lcd_syscons.c b/sys/arm/ti/am335x/am335x_lcd_syscons.c
index 2cbf2fc..e8ab873 100644
--- a/sys/arm/ti/am335x/am335x_lcd_syscons.c
+++ b/sys/arm/ti/am335x/am335x_lcd_syscons.c
@@ -383,13 +383,13 @@ am335x_syscons_configure(int flags)
root = OF_finddevice("/");
if ((root != 0) &&
(display = am335x_syscons_find_panel_node(root))) {
- if ((OF_getprop(display, "panel_width",
- &cell, sizeof(cell))) > 0)
- va_sc->width = (int)fdt32_to_cpu(cell);
+ if ((OF_getencprop(display, "panel_width", &cell,
+ sizeof(cell))) > 0)
+ va_sc->width = cell;
- if ((OF_getprop(display, "panel_height",
- &cell, sizeof(cell))) > 0)
- va_sc->height = (int)fdt32_to_cpu(cell);
+ if ((OF_getencprop(display, "panel_height", &cell,
+ sizeof(cell))) > 0)
+ va_sc->height = cell;
}
if (va_sc->width == 0)
diff --git a/sys/arm/ti/ti_adc.c b/sys/arm/ti/ti_adc.c
index 154cd78..2b49789 100644
--- a/sys/arm/ti/ti_adc.c
+++ b/sys/arm/ti/ti_adc.c
@@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
-#include <dev/fdt/fdt_common.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -767,14 +766,17 @@ ti_adc_attach(device_t dev)
/* Read "tsc" node properties */
child = ofw_bus_find_child(node, "tsc");
if (child != 0 && OF_hasprop(child, "ti,wires")) {
- if ((OF_getprop(child, "ti,wires", &cell, sizeof(cell))) > 0)
- sc->sc_tsc_wires = fdt32_to_cpu(cell);
- if ((OF_getprop(child, "ti,coordinate-readouts", &cell, sizeof(cell))) > 0)
- sc->sc_coord_readouts = fdt32_to_cpu(cell);
- if ((OF_getprop(child, "ti,x-plate-resistance", &cell, sizeof(cell))) > 0)
- sc->sc_x_plate_resistance = fdt32_to_cpu(cell);
- if ((OF_getprop(child, "ti,charge-delay", &cell, sizeof(cell))) > 0)
- sc->sc_charge_delay = fdt32_to_cpu(cell);
+ if ((OF_getencprop(child, "ti,wires", &cell, sizeof(cell))) > 0)
+ sc->sc_tsc_wires = cell;
+ if ((OF_getencprop(child, "ti,coordinate-readouts", &cell,
+ sizeof(cell))) > 0)
+ sc->sc_coord_readouts = cell;
+ if ((OF_getencprop(child, "ti,x-plate-resistance", &cell,
+ sizeof(cell))) > 0)
+ sc->sc_x_plate_resistance = cell;
+ if ((OF_getencprop(child, "ti,charge-delay", &cell,
+ sizeof(cell))) > 0)
+ sc->sc_charge_delay = cell;
nwire_configs = OF_getencprop_alloc(child, "ti,wire-config",
sizeof(*wire_configs), (void **)&wire_configs);
if (nwire_configs != sc->sc_tsc_wires) {
diff --git a/sys/arm/ti/ti_common.c b/sys/arm/ti/ti_common.c
index 41c5a72..64a7830 100644
--- a/sys/arm/ti/ti_common.c
+++ b/sys/arm/ti/ti_common.c
@@ -49,10 +49,6 @@ __FBSDID("$FreeBSD$");
#include <machine/intr.h>
#include <machine/vmparam.h>
-struct fdt_fixup_entry fdt_fixup_table[] = {
- { NULL, NULL }
-};
-
#ifndef INTRNG
#ifdef SOC_TI_AM335X
static int
diff --git a/sys/arm/ti/ti_machdep.c b/sys/arm/ti/ti_machdep.c
index f8d5395..907b18b 100644
--- a/sys/arm/ti/ti_machdep.c
+++ b/sys/arm/ti/ti_machdep.c
@@ -40,7 +40,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#define _ARM32_BUS_DMA_PRIVATE
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
@@ -96,20 +95,6 @@ ti_am335x_devmap_init(platform_t plat)
}
#endif
-struct arm32_dma_range *
-bus_dma_get_range(void)
-{
-
- return (NULL);
-}
-
-int
-bus_dma_get_range_nb(void)
-{
-
- return (0);
-}
-
void
cpu_reset()
{
diff --git a/sys/arm/ti/ti_sdhci.c b/sys/arm/ti/ti_sdhci.c
index a24e693..16fa956 100644
--- a/sys/arm/ti/ti_sdhci.c
+++ b/sys/arm/ti/ti_sdhci.c
@@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <machine/intr.h>
-#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -53,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <dev/mmc/mmcbrvar.h>
#include <dev/sdhci/sdhci.h>
+#include <dev/sdhci/sdhci_fdt_gpio.h>
#include "sdhci_if.h"
#include <arm/ti/ti_cpuid.h>
@@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$");
struct ti_sdhci_softc {
device_t dev;
- device_t gpio_dev;
+ struct sdhci_fdt_gpio * gpio;
struct resource * mem_res;
struct resource * irq_res;
void * intr_cookie;
@@ -71,11 +71,11 @@ struct ti_sdhci_softc {
uint32_t mmchs_reg_off;
uint32_t sdhci_reg_off;
uint32_t baseclk_hz;
- uint32_t wp_gpio_pin;
uint32_t cmd_and_mode;
uint32_t sdhci_clkdiv;
boolean_t disable_highspeed;
boolean_t force_card_present;
+ boolean_t disable_readonly;
};
/*
@@ -363,20 +363,27 @@ static int
ti_sdhci_get_ro(device_t brdev, device_t reqdev)
{
struct ti_sdhci_softc *sc = device_get_softc(brdev);
- unsigned int readonly = 0;
- /* If a gpio pin is configured, read it. */
- if (sc->gpio_dev != NULL) {
- GPIO_PIN_GET(sc->gpio_dev, sc->wp_gpio_pin, &readonly);
- }
+ if (sc->disable_readonly)
+ return (0);
- return (readonly);
+ return (sdhci_fdt_gpio_get_readonly(sc->gpio));
+}
+
+static bool
+ti_sdhci_get_card_present(device_t dev, struct sdhci_slot *slot)
+{
+ struct ti_sdhci_softc *sc = device_get_softc(dev);
+
+ return (sdhci_fdt_gpio_get_present(sc->gpio));
}
static int
ti_sdhci_detach(device_t dev)
{
+ /* sdhci_fdt_gpio_teardown(sc->gpio); */
+
return (EBUSY);
}
@@ -503,25 +510,6 @@ ti_sdhci_attach(device_t dev)
}
/*
- * See if we've got a GPIO-based write detect pin. This is not the
- * standard documented property for this, we added it in freebsd.
- */
- if ((OF_getprop(node, "mmchs-wp-gpio-pin", &prop, sizeof(prop))) <= 0)
- sc->wp_gpio_pin = 0xffffffff;
- else
- sc->wp_gpio_pin = fdt32_to_cpu(prop);
-
- if (sc->wp_gpio_pin != 0xffffffff) {
- sc->gpio_dev = devclass_get_device(devclass_find("gpio"), 0);
- if (sc->gpio_dev == NULL)
- device_printf(dev, "Error: No GPIO device, "
- "Write Protect pin will not function\n");
- else
- GPIO_PIN_SETFLAGS(sc->gpio_dev, sc->wp_gpio_pin,
- GPIO_PIN_INPUT);
- }
-
- /*
* Set the offset from the device's memory start to the MMCHS registers.
* Also for OMAP4 disable high speed mode due to erratum ID i626.
*/
@@ -573,6 +561,21 @@ ti_sdhci_attach(device_t dev)
goto fail;
}
+ /*
+ * Set up handling of card-detect and write-protect gpio lines.
+ *
+ * If there is no write protect info in the fdt data, fall back to the
+ * historical practice of assuming that the card is writable. This
+ * works around bad fdt data from the upstream source. The alternative
+ * would be to trust the sdhci controller's PRESENT_STATE register WP
+ * bit, but it may say write protect is in effect when it's not if the
+ * pinmux setup doesn't route the WP signal into the sdchi block.
+ */
+ sc->gpio = sdhci_fdt_gpio_setup(sc->dev, &sc->slot);
+
+ if (!OF_hasprop(node, "wp-gpios") && !OF_hasprop(node, "wp-disable"))
+ sc->disable_readonly = true;
+
/* Initialise the MMCHS hardware. */
ti_sdhci_hw_init(dev);
@@ -707,6 +710,7 @@ static device_method_t ti_sdhci_methods[] = {
DEVMETHOD(sdhci_write_2, ti_sdhci_write_2),
DEVMETHOD(sdhci_write_4, ti_sdhci_write_4),
DEVMETHOD(sdhci_write_multi_4, ti_sdhci_write_multi_4),
+ DEVMETHOD(sdhci_get_card_present, ti_sdhci_get_card_present),
DEVMETHOD_END
};
OpenPOWER on IntegriCloud