On Mon, Jan 23 2023, Mark Kettenis <mark.kette...@xs4all.nl> wrote:
>> From: Jeremie Courreges-Anglas <j...@wxcvbn.org>
>> Date: Mon, 23 Jan 2023 13:43:15 +0100
>> 
>> I wanted to cross-connect the serial ports of my armv7 and riscv64
>> machines.  Problem on riscv64: no uftdi driver.  It looks like a lot of
>> other USB drivers are missing in GENERIC, both generic drivers and
>> hw-specific drivers: umodem, ugen, ulpt, uvideo, umb, uplcom etc.
>> Feels like it would make sense to sync those devices from arm64/GENERIC
>> instead of adding only what I need.  Thoughts?
>
> Yes, that makes sense.

So here's a diff that enables most of what is found in arm64/GENERIC.
I stripped onewire(4) attached at uow(4) because uow(4) looks designed
for niche devices but 1. I can be convinced otherwise 2. I didn't try to
judge the usefulness of all new entries.

>> One glitch: usbdevs(8) isn't usable since usb(4) isn't wired in conf.c.
>> With the diffbelow I can use usbdevs(8) on my hifive.  ok for the
>> usb.h/cdev_usb_init addition?
>
> You probably should copy the ugen and ulpt entries from arm64 as well.

Yes, same for ujoy(4).  Here's the whole diff for GENERIC, conf.c and
MAKEDEV.  The GENERIC diff is better reviewed with diff -w since there
are whitespace differences between arm64 and riscv64.  Of all the
additions in conf.c, only ujoy(4) was missing from MAKEDEV.

With this, ucom(4) at uftdi(4) and usbdevs(8) work fine for my use case.
ok?


diff --git a/etc/etc.riscv64/MAKEDEV b/etc/etc.riscv64/MAKEDEV
index 7adf702e7ea..bad9f6a84c1 100644
--- a/etc/etc.riscv64/MAKEDEV
+++ b/etc/etc.riscv64/MAKEDEV
@@ -4,7 +4,7 @@
 # generated from:
 #
 #      OpenBSD: etc.riscv64/MAKEDEV.md,v 1.4 2021/11/11 09:47:34 claudio Exp 
-#      OpenBSD: MAKEDEV.common,v 1.118 2022/11/10 09:50:00 krw Exp 
+#      OpenBSD: MAKEDEV.common,v 1.119 2023/01/14 12:15:12 kettenis Exp 
 #      OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp 
 #      OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp 
 #
@@ -57,6 +57,7 @@
 #      ugen*   Generic USB devices
 #      uhid*   Generic HID devices
 #      fido    fido/* nodes
+#      ujoy    ujoy/* nodes
 #      ulpt*   Printer devices
 #      usb*    Bus control devices used by usbd for attach/detach
 # Special purpose devices:
@@ -365,6 +366,12 @@ ulpt*)
        M ulpt$U c 64 $U 600
        ;;
 
+ujoy)
+       RMlist[${#RMlist[*]}]=";mkdir -p ujoy;rm -f" n=0
+       while [ $n -lt 4 ];do M ujoy/$n c 100 $n 444;n=$(($n+1));done
+       MKlist[${#MKlist[*]}]=";chmod 555 ujoy"
+       ;;
+
 fido)
        RMlist[${#RMlist[*]}]=";mkdir -p fido;rm -f" n=0
        while [ $n -lt 4 ];do M fido/$n c 98 $n 666;n=$(($n+1));done
@@ -385,8 +392,9 @@ ugen*)
 
 uall)
        R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ugen2 ugen3 ugen4 ugen5
-       R ugen6 ugen7 ulpt0 ulpt1 fido uhid0 uhid1 uhid2 uhid3 uhid4
-       R uhid5 uhid6 uhid7 usb0 usb1 usb2 usb3 usb4 usb5 usb6 usb7
+       R ugen6 ugen7 ulpt0 ulpt1 ujoy fido uhid0 uhid1 uhid2 uhid3
+       R uhid4 uhid5 uhid6 uhid7 usb0 usb1 usb2 usb3 usb4 usb5 usb6
+       R usb7
        ;;
 
 ttyU[0-9a-zA-Z])
diff --git a/etc/etc.riscv64/MAKEDEV.md b/etc/etc.riscv64/MAKEDEV.md
index 4aece1f961f..c31c8a5d373 100644
--- a/etc/etc.riscv64/MAKEDEV.md
+++ b/etc/etc.riscv64/MAKEDEV.md
@@ -52,6 +52,7 @@ _DEV(uall)
 _DEV(ugen, 63)
 _DEV(uhid, 62)
 _DEV(fido, 98)
+_DEV(ujoy, 100)
 _DEV(ulpt, 64)
 _DEV(usb, 61)
 _TITLE(spec)
diff --git a/sys/arch/riscv64/conf/GENERIC b/sys/arch/riscv64/conf/GENERIC
index cd27318b503..a213f2a90d6 100644
--- a/sys/arch/riscv64/conf/GENERIC
+++ b/sys/arch/riscv64/conf/GENERIC
@@ -136,56 +136,124 @@ xhci*            at pci?
 usb*           at xhci?
 
 # USB devices
-uhub*          at usb?
-uhub*          at uhub?
-uhidev*                at uhub?
+uhub*          at usb?                 # USB Hubs
+uhub*          at uhub?                # USB Hubs
+urng*          at uhub?                # USB Random Number Generator
+uonerng*       at uhub?                # Moonbase Otago OneRNG
+umodem*                at uhub?                # USB Modems/Serial
+ucom*          at umodem?
+uvisor*                at uhub?                # Handspring Visor
+ucom*          at uvisor?
+uvscom*                at uhub?                # SUNTAC Slipper U VS-10U serial
+ucom*          at uvscom?
+ubsa*          at uhub?                # Belkin serial adapter
+ucom*          at ubsa?
+uftdi*         at uhub?                # FTDI FT8U100AX serial adapter
+ucom*          at uftdi?
+uplcom*                at uhub?                # I/O DATA USB-RSAQ2 serial 
adapter
+ucom*          at uplcom?
+umct*          at uhub?                # MCT USB-RS232 serial adapter
+ucom*          at umct?
+uslcom*                at uhub?                # Silicon Laboratories CP210x 
serial
+ucom*          at uslcom?
+uscom*         at uhub?                # Simple USB serial adapters
+ucom*          at uscom?
+ucrcom*                at uhub?                # Chromebook serial
+ucom*          at ucrcom?
+uark*          at uhub?                # Arkmicro ARK3116 serial
+ucom*          at uark?
+moscom*                at uhub?                # MosChip MCS7703 serial
+ucom*          at moscom?
+umcs*          at uhub?                # MosChip MCS78x0 serial
+ucom*          at umcs?
+uipaq*         at uhub?                # iPAQ serial adapter
+ucom*          at uipaq?
+umsm*          at uhub?                # Qualcomm MSM EVDO
+ucom*          at umsm?
+uchcom*                at uhub?                # WinChipHead CH341/340 serial
+ucom*          at uchcom?
+uticom*                at uhub?                # TI serial
+ucom*          at uticom?
+uxrcom*                at uhub?                # Exar XR21V1410 serial
+ucom*          at uxrcom?
 uaudio*                at uhub?                # USB Audio
 audio*         at uaudio?
 umidi*         at uhub?                # USB MIDI
 midi*          at umidi?
+ulpt*          at uhub?                # USB Printers
+umass*         at uhub?                # USB Mass Storage devices
+uhidev*                at uhub?                # Human Interface Devices
 ums*           at uhidev?              # USB mouse
-wsmouse*       at ums? mux 0
+wsmouse*       at ums? mux 0
 umt*           at uhidev?              # USB multitouch touchpad
-wsmouse*       at umt? mux 0
+wsmouse*       at umt? mux 0
 uts*           at uhub?                # USB touchscreen
-wsmouse*       at uts? mux 0
+wsmouse*       at uts? mux 0
 uwacom*                at uhidev?              # USB Wacom tablet
-wsmouse*       at uwacom? mux 0
-ukbd*          at uhidev?
+wsmouse*       at uwacom? mux 0
+ukbd*          at uhidev?              # USB keyboard
 wskbd*         at ukbd? mux 1
+ucycom*                at uhidev?              # Cypress serial
+ucom*          at ucycom?
+uslhcom*       at uhidev?              # Silicon Labs CP2110 USB HID UART
+ucom*          at uslhcom?
 uhid*          at uhidev?              # USB generic HID support
 fido*          at uhidev?              # FIDO/U2F security key support
+ucc*           at uhidev?              # Consumer Control keyboards
+wskbd*         at ucc? mux 1
+ujoy*          at uhidev?              # USB joystick/gamecontroller support
+uhidpp*                at uhidev?              # Logitech HID++ Devices
+upd*           at uhidev?              # USB Power Devices sensors
+aue*           at uhub?                # ADMtek AN986 Pegasus Ethernet
+atu*           at uhub?                # Atmel AT76c50x based 802.11b
+axe*           at uhub?                # ASIX Electronics AX88172 USB Ethernet
+axen*          at uhub?                # ASIX Electronics AX88179 USB Ethernet
+cue*           at uhub?                # CATC USB-EL1201A based Ethernet
+kue*           at uhub?                # Kawasaki KL5KUSB101B based Ethernet
+smsc*          at uhub?                # SMSC LAN95xx Ethernet
+cdce*          at uhub?                # CDC Ethernet
+urndis*                at uhub?                # Remote NDIS Ethernet
+upl*           at uhub?                # Prolific PL2301/PL2302 host-to-host 
`network'
+ugl*           at uhub?                # Genesys Logic GL620USB-A host-to-host 
`network'
+udav*          at uhub?                # Davicom DM9601 based Ethernet
+mos*           at uhub?                # MOSCHIP MCS7730/7830 10/100 Ethernet
+mue*           at uhub?                # Microchip LAN75xx/LAN78xx Ethernet
+url*           at uhub?                # Realtek RTL8150L based adapters
+ure*           at uhub?                # Realtek RTL8152 based adapters
+wi*            at uhub?                # WaveLAN IEEE 802.11DS
+udsbr*         at uhub?                # D-Link DSB-R100 radio
+radio*         at udsbr?               # USB radio
+uberry*                at uhub?                # Research In Motion BlackBerry
+ugen*          at uhub?                # USB Generic driver
+uath*          at uhub?                # Atheros AR5005UG/AR5005UX
+ural*          at uhub?                # Ralink RT2500USB
+rum*           at uhub?                # Ralink RT2501USB/RT2601USB
+run*           at uhub?                # Ralink RT2700U/RT2800U/RT3000U
+mtw*           at uhub?                # MediaTek MT7601U
+otus*          at uhub?                # Atheros AR9001U
+athn*          at uhub?                # Atheros AR9002U
+zyd*           at uhub?                # Zydas ZD1211
+upgt*          at uhub?                # Conexant/Intersil PrismGT SoftMAC USB
+urtw*          at uhub?                # Realtek 8187
+rsu*           at uhub?                # Realtek RTL8188SU/RTL8191SU/RTL8192SU
+urtwn*         at uhub?                # Realtek RTL8188CU/RTL8192CU
+udcf*          at uhub?                # Gude Expert mouseCLOCK
+umb*           at uhub?                # Mobile Broadband Interface Model
+uthum*         at uhidev?              # TEMPerHUM sensor
+ugold*         at uhidev?              # gold TEMPer sensor
+utrh*          at uhidev?              # USBRH sensor
+utwitch*       at uhidev?              # YUREX BBU sensor
+uoakrh*                at uhidev?              # Toradex OAK temp and rel 
humidity
+uoaklux*       at uhidev?              # Toradex OAK LUX
+uoakv*         at uhidev?              # Toradex OAK 10V sensor
+uvideo*                at uhub?                # USB Video
+video*         at uvideo?
+utvfu*         at uhub?                # Fushicai Audio-Video Grabber
+video*         at utvfu?
+audio*         at utvfu?
 udl*           at uhub?                # DisplayLink USB displays
-wsdisplay*     at udl?
-umass*         at uhub?
-aue*           at uhub?        # ADMtek AN986 Pegasus Ethernet
-atu*           at uhub?        # Atmel AT76c50x based 802.11b
-axe*           at uhub?        # ASIX Electronics AX88172 USB Ethernet
-axen*          at uhub?        # ASIX Electronics AX88179 USB Ethernet
-cue*           at uhub?        # CATC USB-EL1201A based Ethernet
-kue*           at uhub?        # Kawasaki KL5KUSB101B based Ethernet
-smsc*          at uhub?        # SMSC LAN95xx Ethernet
-cdce*          at uhub?        # CDC Ethernet
-udav*          at uhub?        # Davicom DM9601 based Ethernet
-mos*           at uhub?        # MOSCHIP MCS7730/7830 10/100 Ethernet
-mue*           at uhub?        # Microchip LAN75xx/LAN78xx Ethernet
-url*           at uhub?        # Realtek RTL8150L based adapters
-ure*           at uhub?        # Realtek RTL8152 based adapters
-wi*            at uhub?        # WaveLAN IEEE 802.11DS
-upl*           at uhub?        # Prolific PL2301/PL2302 host-to-host
-ugl*           at uhub?        # Genesys Logic GL620USB-A host-to-host
-ural*          at uhub?        # Ralink RT2500
-rum*           at uhub?        # Ralink RT2501USB/RT2601USB
-run*           at uhub?        # Ralink RT2700U/RT2800U/RT3000U
-zyd*           at uhub?        # Zydas ZD1211
-upgt*          at uhub?        # Conexant/Intersil PrismGT SoftMAC USB
-urtw*          at uhub?        # Realtek 8187
-urtwn*         at uhub?        # Realtek RTL8188CU/RTL8192CU
-rsu*           at uhub?        # Realtek RTL8188SU/RTL8191SU/RTL8192SU
-uath*          at uhub?        # Atheros AR5005UG/AR5005UX
-otus*          at uhub?        # Atheros AR9001U
-athn*          at uhub?        # Atheros AR9002U
-bwfm*          at uhub?        # Broadcom FullMAC
+wsdisplay*     at udl?
+bwfm*          at uhub?                # Broadcom FullMAC
 
 acphy*         at mii?         # Altima AC101 PHYs
 amphy*         at mii?         # AMD 79C873 PHYs
diff --git a/sys/arch/riscv64/riscv64/conf.c b/sys/arch/riscv64/riscv64/conf.c
index 5256251a3a3..1a55d2242ac 100644
--- a/sys/arch/riscv64/riscv64/conf.c
+++ b/sys/arch/riscv64/riscv64/conf.c
@@ -88,11 +88,16 @@ cdev_decl(lpt);
 #include "midi.h"
 #include "ksyms.h"
 #include "kstat.h"
+#include "usb.h"
+#include "uhid.h"
+#include "fido.h"
+#include "ujoy.h"
+#include "ugen.h"
+#include "ulpt.h"
+#include "ucom.h"
 #include "radio.h"
 #include "drm.h"
 cdev_decl(drm);
-#include "uhid.h"
-#include "fido.h"
 
 #include "wsdisplay.h"
 #include "wskbd.h"
@@ -180,12 +185,12 @@ struct cdevsw     cdevsw[] =
        cdev_notdef(),                  /* 59: i4b trace device */
        cdev_notdef(),                  /* 60: i4b phone device */
        /* End of reserved slots for isdn4bsd. */
-       cdev_notdef(),                  /* 61: USB controller */
+       cdev_usb_init(NUSB,usb),        /* 61: USB controller */
        cdev_usbdev_init(NUHID,uhid),   /* 62: USB generic HID */
-       cdev_notdef(),                  /* 63: USB generic driver */
-       cdev_notdef(),                  /* 64: USB printers */
+       cdev_usbdev_init(NUGEN,ugen),   /* 63: USB generic driver */
+       cdev_ulpt_init(NULPT,ulpt),     /* 64: USB printers */
        cdev_notdef(),                  /* 65: urio */
-       cdev_notdef(),                  /* 66: USB tty */
+       cdev_tty_init(NUCOM,ucom),      /* 66: USB tty */
        cdev_mouse_init(NWSKBD, wskbd), /* 67: keyboards */
        cdev_mouse_init(NWSMOUSE,       /* 68: mice */
            wsmouse),
@@ -224,7 +229,7 @@ struct cdevsw       cdevsw[] =
        cdev_notdef(),                  /* 97: was switch(4) */
        cdev_fido_init(NFIDO,fido),     /* 98: FIDO/U2F security key */
        cdev_pppx_init(NPPPX,pppac),    /* 99: PPP Access Concentrator */
-       cdev_notdef(),                  /* 100: USB joystick/gamecontroller */
+       cdev_ujoy_init(NUJOY,ujoy),     /* 100: USB joystick/gamecontroller */
 };
 int    nchrdev = nitems(cdevsw);
 


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to