From b9f80455984b93a8f99824e376671d5a1c8a8361 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Sun, 24 Feb 2019 23:16:33 +0000 Subject: [PATCH] Add support for probing/attaching on FDT-based systems. --- sys/dev/flash/at45d.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/sys/dev/flash/at45d.c b/sys/dev/flash/at45d.c index fb6935a22561..d0ce40eedb8b 100644 --- a/sys/dev/flash/at45d.c +++ b/sys/dev/flash/at45d.c @@ -47,6 +47,21 @@ __FBSDID("$FreeBSD$"); #include #include "spibus_if.h" +#include "opt_platform.h" + +#ifdef FDT +#include +#include +#include + +static struct ofw_compat_data compat_data[] = { + { "atmel,at45", 1 }, + { "atmel,dataflash", 1 }, + { NULL, 0 }, +}; +SPIBUS_PNP_INFO(compat_data); +#endif + struct at45d_flash_ident { const char *name; @@ -187,9 +202,22 @@ at45d_wait_ready(device_t dev, uint8_t *status) static int at45d_probe(device_t dev) { + int rv; + +#ifdef FDT + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + rv = BUS_PROBE_DEFAULT; +#else + rv = BUS_PROBE_NOWILDCARD; +#endif device_set_desc(dev, "AT45D Flash Family"); - return (0); + return (rv); } static int