[rtems-libbsd commit] arm/lpc: Add option to customize device probes

Sebastian Huber sebh at rtems.org
Tue Sep 6 11:13:38 UTC 2022


Module:    rtems-libbsd
Branch:    6-freebsd-12
Commit:    a0d36f58fd7587c14b82044f49735ee5aca152f2
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=a0d36f58fd7587c14b82044f49735ee5aca152f2

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jun 30 10:29:02 2022 +0200

arm/lpc: Add option to customize device probes

---

 rtemsbsd/arm/include/arm/lpc/probe.h           | 43 ++++++++++++++++++++++++++
 rtemsbsd/sys/arm/lpc/if_lpe.c                  | 16 +++++++---
 rtemsbsd/sys/dev/usb/controller/ohci_lpc32xx.c | 17 +++++++---
 3 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/rtemsbsd/arm/include/arm/lpc/probe.h b/rtemsbsd/arm/include/arm/lpc/probe.h
new file mode 100644
index 00000000..54f9ebda
--- /dev/null
+++ b/rtemsbsd/arm/include/arm/lpc/probe.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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_LPC_PROBE_H
+#define _ARM_LPC_PROBE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int lpc_eth_probe(int unit);
+
+int lpc_ohci_probe(int unit);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ARM_LPC_PROBE_H */
diff --git a/rtemsbsd/sys/arm/lpc/if_lpe.c b/rtemsbsd/sys/arm/lpc/if_lpe.c
index 901cd6f0..87ca9ff7 100755
--- a/rtemsbsd/sys/arm/lpc/if_lpe.c
+++ b/rtemsbsd/sys/arm/lpc/if_lpe.c
@@ -43,6 +43,8 @@
 
 #include <rtems/bsd/bsd.h>
 
+#include <arm/lpc/probe.h>
+
 #include <bsp.h>
 #include <bsp/irq.h>
 #include <bsp/lpc-ethernet-config.h>
@@ -1603,15 +1605,19 @@ static void lpc_eth_media_status(struct ifnet *ifp, struct ifmediareq *imr)
   }
 }
 
-int lpc_eth_probe(device_t dev)
+__weak_symbol int lpc_eth_probe(int unit)
 {
-  int unit = device_get_unit(dev);
-
   if (unit != 0) {
     return ENXIO;
   }
 
-  return 0;
+  return BUS_PROBE_DEFAULT;
+}
+
+static int lpc_eth_do_probe(device_t dev)
+{
+  device_set_desc(dev, "LPC32x0 Ethernet controller");
+  return lpc_eth_probe(device_get_unit(dev));
 }
 
 static int lpc_eth_attach(device_t dev)
@@ -1743,7 +1749,7 @@ static int lpc_eth_detach(device_t dev)
 }
 
 static device_method_t lpe_methods[] = {
-  DEVMETHOD(device_probe, lpc_eth_probe),
+  DEVMETHOD(device_probe, lpc_eth_do_probe),
   DEVMETHOD(device_attach, lpc_eth_attach),
   DEVMETHOD(device_detach, lpc_eth_detach),
   DEVMETHOD_END
diff --git a/rtemsbsd/sys/dev/usb/controller/ohci_lpc32xx.c b/rtemsbsd/sys/dev/usb/controller/ohci_lpc32xx.c
index c7c09bb4..d02bba98 100755
--- a/rtemsbsd/sys/dev/usb/controller/ohci_lpc32xx.c
+++ b/rtemsbsd/sys/dev/usb/controller/ohci_lpc32xx.c
@@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/usb/controller/ohci.h>
 #include <dev/usb/controller/ohcireg.h>
 
+#include <arm/lpc/probe.h>
 #include <arm/lpc/lpcreg.h>
 #include <arm/lpc/lpcvar.h>
 
@@ -90,7 +91,7 @@ __FBSDID("$FreeBSD$");
     	while ((lpc_otg_read_4(_sc, _sreg) & _value) != _value);    	\
     } while (0);
 
-static int lpc_ohci_probe(device_t dev);
+static int lpc_ohci_do_probe(device_t dev);
 static int lpc_ohci_attach(device_t dev);
 static int lpc_ohci_detach(device_t dev);
 
@@ -107,12 +108,20 @@ static int lpc_otg_i2c_wait_for_transaction_done(struct ohci_softc *sc);
 static int lpc_otg_i2c_read(const struct usb_otg_transceiver *self, uint8_t reg_addr, uint8_t *value);
 static int lpc_otg_i2c_write(const struct usb_otg_transceiver *self, uint8_t reg_addr, uint8_t value);
 
+__weak_symbol int
+lpc_ohci_probe(int unit)
+{
+
+	(void)unit;
+	return (BUS_PROBE_DEFAULT);
+}
+
 static int
-lpc_ohci_probe(device_t dev)
+lpc_ohci_do_probe(device_t dev)
 {
 
 	device_set_desc(dev, "LPC32x0 USB OHCI controller");
-	return (BUS_PROBE_DEFAULT);
+	return (lpc_ohci_probe(device_get_unit(dev)));
 }
 
 static int
@@ -473,7 +482,7 @@ lpc_ohci_resume(device_t dev)
 
 static device_method_t lpc_ohci_methods[] = {
 	/* Device interface */
-	DEVMETHOD(device_probe,		lpc_ohci_probe),
+	DEVMETHOD(device_probe,		lpc_ohci_do_probe),
 	DEVMETHOD(device_attach,	lpc_ohci_attach),
 	DEVMETHOD(device_detach,	lpc_ohci_detach),
   DEVMETHOD(device_suspend, bus_generic_suspend),



More information about the vc mailing list