diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2019-01-13 16:45:45 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2019-01-13 16:45:45 +0000 |
commit | 485da8275a0399385d6e71d2f63e582827cd4ec9 (patch) | |
tree | 1a805bbf23d724b146cda62729f85e9221b839a4 /sys | |
parent | a1ec21dca947b68f70f6cbdd544cdaf8ca9b2684 (diff) |
Handle card detect GPIO.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/octeon/dev/octmmc.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/arch/octeon/dev/octmmc.c b/sys/arch/octeon/dev/octmmc.c index e4f1fea2901..b013e46275d 100644 --- a/sys/arch/octeon/dev/octmmc.c +++ b/sys/arch/octeon/dev/octmmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octmmc.c,v 1.12 2019/01/13 16:38:43 visa Exp $ */ +/* $OpenBSD: octmmc.c,v 1.13 2019/01/13 16:45:44 visa Exp $ */ /* * Copyright (c) 2016, 2017 Visa Hankala @@ -28,6 +28,7 @@ #include <sys/kernel.h> #include <dev/ofw/fdt.h> +#include <dev/ofw/ofw_gpio.h> #include <dev/ofw/openfirm.h> #include <dev/sdmmc/sdmmcchip.h> #include <dev/sdmmc/sdmmcvar.h> @@ -78,6 +79,7 @@ struct octmmc_bus { uint64_t bus_switch; uint64_t bus_rca; uint64_t bus_wdog; + uint32_t bus_cd_gpio[3]; }; struct octmmc_softc { @@ -286,6 +288,12 @@ octmmc_attach(struct device *parent, struct device *self, void *aux) bus_width = OF_getpropint(node, "cavium,bus-max-width", 8); + OF_getpropintarray(node, "cd-gpios", bus->bus_cd_gpio, + sizeof(bus->bus_cd_gpio)); + if (bus->bus_cd_gpio[0] != 0) + gpio_controller_config_pin(bus->bus_cd_gpio, + GPIO_CONFIG_INPUT); + if (octmmc_init_bus(bus)) { printf("%s: could not init bus %d\n", DEVNAME(sc), bus_id); @@ -498,6 +506,11 @@ octmmc_host_maxblklen(sdmmc_chipset_handle_t sch) int octmmc_card_detect(sdmmc_chipset_handle_t sch) { + struct octmmc_bus *bus = sch; + + if (bus->bus_cd_gpio[0] != 0) + return gpio_controller_get_pin(bus->bus_cd_gpio); + return 1; } |