Date: Thu, 6 Aug 2015 19:39:51 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 1212545 for review Message-ID: <201508061939.t76Jdpjq053615@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@1212545?ac=10 Change 1212545 by jhb@jhb_ralph on 2015/08/06 19:39:12 IFC @1212544 Affected files ... .. //depot/projects/smpng/sys/boot/efi/loader/Makefile#13 branch .. //depot/projects/smpng/sys/boot/efi/loader/conf.c#10 branch .. //depot/projects/smpng/sys/boot/efi/loader/main.c#16 branch .. //depot/projects/smpng/sys/boot/efi/loader/version#6 branch .. //depot/projects/smpng/sys/dev/usb/serial/uftdi.c#34 integrate .. //depot/projects/smpng/sys/dev/usb/serial/uftdi_reg.h#7 integrate .. //depot/projects/smpng/sys/dev/usb/uftdiio.h#2 integrate .. //depot/projects/smpng/sys/powerpc/powerpc/interrupt.c#7 branch .. //depot/projects/smpng/sys/powerpc/powerpc/machdep.c#76 branch .. //depot/projects/smpng/sys/powerpc/powerpc/trap.c#63 branch .. //depot/projects/smpng/sys/powerpc/powerpc/uma_machdep.c#5 branch .. //depot/projects/smpng/sys/x86/x86/mp_x86.c#2 integrate Differences ... ==== //depot/projects/smpng/sys/dev/usb/serial/uftdi.c#34 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uftdi.c 282505 2015-05-05 19:34:23Z hselasky $"); +__FBSDID("$FreeBSD: head/sys/dev/usb/serial/uftdi.c 286382 2015-08-06 19:29:26Z ian $"); /* * NOTE: all function names beginning like "uftdi_cfg_" can only @@ -1791,6 +1791,82 @@ } static int +uftdi_read_eeprom(struct ucom_softc *ucom, struct uftdi_eeio *eeio) +{ + struct uftdi_softc *sc = ucom->sc_parent; + usb_device_request_t req; + usb_error_t err; + uint16_t widx, wlength, woffset; + + /* Offset and length must both be evenly divisible by two. */ + if ((eeio->offset | eeio->length) & 0x01) + return (EINVAL); + + woffset = eeio->offset / 2U; + wlength = eeio->length / 2U; + for (widx = 0; widx < wlength; widx++) { + req.bmRequestType = UT_READ_VENDOR_DEVICE; + req.bRequest = FTDI_SIO_READ_EEPROM; + USETW(req.wIndex, widx + woffset); + USETW(req.wLength, 2); + USETW(req.wValue, 0); + err = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, + &eeio->data[widx]); + if (err != USB_ERR_NORMAL_COMPLETION) + return (err); + } + return (USB_ERR_NORMAL_COMPLETION); +} + +static int +uftdi_write_eeprom(struct ucom_softc *ucom, struct uftdi_eeio *eeio) +{ + struct uftdi_softc *sc = ucom->sc_parent; + usb_device_request_t req; + usb_error_t err; + uint16_t widx, wlength, woffset; + + /* Offset and length must both be evenly divisible by two. */ + if ((eeio->offset | eeio->length) & 0x01) + return (EINVAL); + + woffset = eeio->offset / 2U; + wlength = eeio->length / 2U; + for (widx = 0; widx < wlength; widx++) { + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = FTDI_SIO_WRITE_EEPROM; + USETW(req.wIndex, widx + woffset); + USETW(req.wLength, 0); + USETW(req.wValue, eeio->data[widx]); + err = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL); + if (err != USB_ERR_NORMAL_COMPLETION) + return (err); + } + return (USB_ERR_NORMAL_COMPLETION); +} + +static int +uftdi_erase_eeprom(struct ucom_softc *ucom, int confirmation) +{ + struct uftdi_softc *sc = ucom->sc_parent; + usb_device_request_t req; + usb_error_t err; + + /* Small effort to prevent accidental erasure. */ + if (confirmation != UFTDI_CONFIRM_ERASE) + return (EINVAL); + + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = FTDI_SIO_ERASE_EEPROM; + USETW(req.wIndex, 0); + USETW(req.wLength, 0); + USETW(req.wValue, 0); + err = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL); + + return (err); +} + +static int uftdi_ioctl(struct ucom_softc *ucom, uint32_t cmd, caddr_t data, int flag, struct thread *td) { @@ -1833,6 +1909,15 @@ *(int *)data = sc->sc_bcdDevice; err = 0; break; + case UFTDIIOC_READ_EEPROM: + err = uftdi_read_eeprom(ucom, (struct uftdi_eeio *)data); + break; + case UFTDIIOC_WRITE_EEPROM: + err = uftdi_write_eeprom(ucom, (struct uftdi_eeio *)data); + break; + case UFTDIIOC_ERASE_EEPROM: + err = uftdi_erase_eeprom(ucom, *(int *)data); + break; default: return (ENOIOCTL); } ==== //depot/projects/smpng/sys/dev/usb/serial/uftdi_reg.h#7 (text+ko) ==== @@ -1,5 +1,5 @@ /* $NetBSD: uftdireg.h,v 1.6 2002/07/11 21:14:28 augustss Exp $ */ -/* $FreeBSD: head/sys/dev/usb/serial/uftdi_reg.h 264923 2014-04-25 19:13:57Z ian $ */ +/* $FreeBSD: head/sys/dev/usb/serial/uftdi_reg.h 286382 2015-08-06 19:29:26Z ian $ */ /* * Definitions for the FTDI USB Single Port Serial Converter - @@ -31,7 +31,10 @@ #define FTDI_SIO_SET_LATENCY 9 /* Set the latency timer */ #define FTDI_SIO_GET_LATENCY 10 /* Read the latency timer */ #define FTDI_SIO_SET_BITMODE 11 /* Set the bit bang I/O mode */ -#define FTDI_SIO_GET_BITMODE 12 /* Read pin states in bit bang mode */ +#define FTDI_SIO_GET_BITMODE 12 /* Read pin states from any mode */ +#define FTDI_SIO_READ_EEPROM 144 /* Read eeprom word */ +#define FTDI_SIO_WRITE_EEPROM 145 /* Write eeprom word */ +#define FTDI_SIO_ERASE_EEPROM 146 /* Erase entire eeprom */ /* Port Identifier Table */ #define FTDI_PIT_DEFAULT 0 /* SIOA */ ==== //depot/projects/smpng/sys/dev/usb/uftdiio.h#2 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/dev/usb/uftdiio.h 264149 2014-04-05 16:08:13Z ian $ + * $FreeBSD: head/sys/dev/usb/uftdiio.h 286382 2015-08-06 19:29:26Z ian $ */ /* @@ -61,6 +61,26 @@ uint8_t iomask; }; +/* + * For UFTDIIOC_READ_EEPROM, UFTDIIOC_WRITE_EEPROM: + * + * IO is done in 16-bit words at the chip level; offset and length are in bytes, + * but must each be evenly divisible by two. + * + * It is not necessary to erase before writing. For the FT232R device (only) + * you must set the latency timer to 0x77 before doing a series of eeprom writes + * (and restore it to the prior value when done). + */ +struct uftdi_eeio +{ + uint16_t offset; + uint16_t length; + uint16_t data[64]; +}; + +/* Pass this value to confirm that eeprom erase request is not accidental. */ +#define UFTDI_CONFIRM_ERASE 0x26139108 + #define UFTDIIOC_RESET_IO _IO('c', 0) /* Reset config, flush fifos.*/ #define UFTDIIOC_RESET_RX _IO('c', 1) /* Flush input fifo. */ #define UFTDIIOC_RESET_TX _IO('c', 2) /* Flush output fifo. */ @@ -71,5 +91,8 @@ #define UFTDIIOC_SET_LATENCY _IOW('c', 7, int) /* 1-255 ms */ #define UFTDIIOC_GET_LATENCY _IOR('c', 8, int) #define UFTDIIOC_GET_HWREV _IOR('c', 9, int) +#define UFTDIIOC_READ_EEPROM _IOWR('c', 10, struct uftdi_eeio) +#define UFTDIIOC_WRITE_EEPROM _IOW('c', 11, struct uftdi_eeio) +#define UFTDIIOC_ERASE_EEPROM _IOW('c', 12, int) #endif ==== //depot/projects/smpng/sys/x86/x86/mp_x86.c#2 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/x86/x86/mp_x86.c 281940 2015-04-24 16:20:56Z kib $"); +__FBSDID("$FreeBSD: head/sys/x86/x86/mp_x86.c 286374 2015-08-06 18:02:54Z kib $"); #ifdef __i386__ #include "opt_apic.h" @@ -602,7 +602,7 @@ mtx_unlock_spin(&ap_boot_mtx); /* Wait until all the AP's are up. */ - while (smp_started == 0) + while (atomic_load_acq_int(&smp_started) == 0) ia32_pause(); /* Start per-CPU event timers. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508061939.t76Jdpjq053615>