svn commit: r368366 - head/sys/dev/ichiic
Author: wulf Date: Sat Dec 5 10:57:15 2020 New Revision: 368366 URL: https://svnweb.freebsd.org/changeset/base/368366 Log: ig4(4): Add PCI IDs for Intel Tiger Lake Submitted by: Neel Chauhan Differential Revision:https://reviews.freebsd.org/D27483 Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_pci.c head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sat Dec 5 10:55:14 2020 (r368365) +++ head/sys/dev/ichiic/ig4_iic.c Sat Dec 5 10:57:15 2020 (r368366) @@ -119,6 +119,12 @@ static const struct ig4_hw ig4iic_hw[] = { .ic_clock_rate = 216, .sda_hold_time = 230, }, + [IG4_TIGERLAKE] = { + .ic_clock_rate = 133, + .sda_fall_time = 171, + .scl_fall_time = 208, + .sda_hold_time = 42, + }, }; static int ig4iic_set_config(ig4iic_softc_t *sc, bool reset); Modified: head/sys/dev/ichiic/ig4_pci.c == --- head/sys/dev/ichiic/ig4_pci.c Sat Dec 5 10:55:14 2020 (r368365) +++ head/sys/dev/ichiic/ig4_pci.c Sat Dec 5 10:57:15 2020 (r368366) @@ -121,6 +121,21 @@ static int ig4iic_pci_detach(device_t dev); #define PCI_CHIP_COMETLAKE_V_I2C_1 0xa3e18086 #define PCI_CHIP_COMETLAKE_V_I2C_2 0xa3e28086 #define PCI_CHIP_COMETLAKE_V_I2C_3 0xa3e38086 +#define PCI_CHIP_TIGERLAKE_H_I2C_0 0x43d88086 +#define PCI_CHIP_TIGERLAKE_H_I2C_1 0x43e88086 +#define PCI_CHIP_TIGERLAKE_H_I2C_2 0x43e98086 +#define PCI_CHIP_TIGERLAKE_H_I2C_3 0x43ea8086 +#define PCI_CHIP_TIGERLAKE_H_I2C_4 0x43eb8086 +#define PCI_CHIP_TIGERLAKE_H_I2C_5 0x43ad8086 +#define PCI_CHIP_TIGERLAKE_H_I2C_6 0x43ae8086 +#define PCI_CHIP_TIGERLAKE_LP_I2C_00xa0c58086 +#define PCI_CHIP_TIGERLAKE_LP_I2C_10xa0c68086 +#define PCI_CHIP_TIGERLAKE_LP_I2C_20xa0d88086 +#define PCI_CHIP_TIGERLAKE_LP_I2C_30xa0d98086 +#define PCI_CHIP_TIGERLAKE_LP_I2C_40xa0e88086 +#define PCI_CHIP_TIGERLAKE_LP_I2C_50xa0e98086 +#define PCI_CHIP_TIGERLAKE_LP_I2C_60xa0ea8086 +#define PCI_CHIP_TIGERLAKE_LP_I2C_70xa0eb8086 struct ig4iic_pci_device { uint32_tdevid; @@ -184,6 +199,21 @@ static struct ig4iic_pci_device ig4iic_pci_devices[] = { PCI_CHIP_COMETLAKE_V_I2C_1, "Intel Comet Lake-V I2C Controller-1", IG4_CANNONLAKE}, { PCI_CHIP_COMETLAKE_V_I2C_2, "Intel Comet Lake-V I2C Controller-2", IG4_CANNONLAKE}, { PCI_CHIP_COMETLAKE_V_I2C_3, "Intel Comet Lake-V I2C Controller-3", IG4_CANNONLAKE}, + { PCI_CHIP_TIGERLAKE_H_I2C_0, "Intel Tiger Lake-H I2C Controller-0", IG4_TIGERLAKE}, + { PCI_CHIP_TIGERLAKE_H_I2C_1, "Intel Tiger Lake-H I2C Controller-1", IG4_TIGERLAKE}, + { PCI_CHIP_TIGERLAKE_H_I2C_2, "Intel Tiger Lake-H I2C Controller-2", IG4_TIGERLAKE}, + { PCI_CHIP_TIGERLAKE_H_I2C_3, "Intel Tiger Lake-H I2C Controller-3", IG4_TIGERLAKE}, + { PCI_CHIP_TIGERLAKE_H_I2C_4, "Intel Tiger Lake-H I2C Controller-4", IG4_TIGERLAKE}, + { PCI_CHIP_TIGERLAKE_H_I2C_5, "Intel Tiger Lake-H I2C Controller-5", IG4_TIGERLAKE}, + { PCI_CHIP_TIGERLAKE_H_I2C_6, "Intel Tiger Lake-H I2C Controller-6", IG4_TIGERLAKE}, + { PCI_CHIP_TIGERLAKE_LP_I2C_0, "Intel Tiger Lake-LP I2C Controller-0", IG4_SKYLAKE}, + { PCI_CHIP_TIGERLAKE_LP_I2C_1, "Intel Tiger Lake-LP I2C Controller-1", IG4_SKYLAKE}, + { PCI_CHIP_TIGERLAKE_LP_I2C_2, "Intel Tiger Lake-LP I2C Controller-2", IG4_SKYLAKE}, + { PCI_CHIP_TIGERLAKE_LP_I2C_3, "Intel Tiger Lake-LP I2C Controller-3", IG4_SKYLAKE}, + { PCI_CHIP_TIGERLAKE_LP_I2C_4, "Intel Tiger Lake-LP I2C Controller-4", IG4_SKYLAKE}, + { PCI_CHIP_TIGERLAKE_LP_I2C_5, "Intel Tiger Lake-LP I2C Controller-5", IG4_SKYLAKE}, + { PCI_CHIP_TIGERLAKE_LP_I2C_6, "Intel Tiger Lake-LP I2C Controller-6", IG4_SKYLAKE}, + { PCI_CHIP_TIGERLAKE_LP_I2C_7, "Intel Tiger Lake-LP I2C Controller-7", IG4_SKYLAKE}, }; static int Modified: head/sys/dev/ichiic/ig4_var.h == --- head/sys/dev/ichiic/ig4_var.h Sat Dec 5 10:55:14 2020 (r368365) +++ head/sys/dev/ichiic/ig4_var.h Sat Dec 5 10:57:15 2020 (r368366) @@ -43,10 +43,17 @@ #include "pci_if.h" #include "iicbus_if.h" -enum ig4_vers { IG4_HASWELL, IG4_ATOM, IG4_SKYLAKE, IG4_APL, IG4_CANNONLAKE }; +enum ig4_vers { + IG4_HASWELL, + IG4_ATOM, + IG4_SKYLAKE, + IG4_APL, + IG4_CANNONLAKE, + IG4_TIGERLAKE +}; + /* Controller has additional registers */ -#defineIG4_HAS_ADDREGS(vers) ((vers) == IG4_SKYLAKE || \ - (vers) == IG4_APL || (vers) == IG4_CANNONLAKE) +#defineIG4_HAS_ADDREGS(vers) ((vers) >= IG4_SKYLAKE)
svn commit: r368365 - head/sys/dev/atkbdc
Author: wulf Date: Sat Dec 5 10:55:14 2020 New Revision: 368365 URL: https://svnweb.freebsd.org/changeset/base/368365 Log: atkbd(4): Change quirk table end-of-list marker to NULL vendor/maker/product This fixes regression introduced in r367349 which effectively resulted in truncation of quirk table. PR: 250711 Submitted by: grembo Reported by: Matthias Apitz X-MFC with: r367349 Modified: head/sys/dev/atkbdc/atkbdc.c Modified: head/sys/dev/atkbdc/atkbdc.c == --- head/sys/dev/atkbdc/atkbdc.cSat Dec 5 10:55:09 2020 (r368364) +++ head/sys/dev/atkbdc/atkbdc.cSat Dec 5 10:55:14 2020 (r368365) @@ -133,7 +133,8 @@ atkbdc_getquirks(void) char* maker = kern_getenv("smbios.system.maker"); char* product = kern_getenv("smbios.system.product"); -for (i=0; quirks[i].quirk != 0; ++i) +for (i=0; quirks[i].bios_vendor != NULL || quirks[i].maker != NULL || + quirks[i].product != NULL; ++i) if (QUIRK_STR_MATCH(quirks[i].bios_vendor, bios_vendor) && QUIRK_STR_MATCH(quirks[i].maker, maker) && QUIRK_STR_MATCH(quirks[i].product, product)) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367854 - head/sys/dev/atkbdc
Author: wulf Date: Fri Nov 20 00:13:30 2020 New Revision: 367854 URL: https://svnweb.freebsd.org/changeset/base/367854 Log: psm(4): Disable AUX multiplexer probing on all Lenovo laptops. Rudimentary AUX multiplexing support was added to kernel to make possible touchpad initialization on some HP EliteBook laptops with trackpoint. Disable multiplexer probing on all Lenovo laptops now as they use touchpad pass-through port rather than AUX multiplexer to connect trackpoint and at least two model (X120e and X121e) is known for getting PS/2 AUX port dysfunctional after switching back to hidden multiplexing mode. AUX MUX probing can be reenabled with setting of hw.psm.mux_disabled loader tunable to 0. PR: 249987 Reported by: jwb MFC after:2 weeks Modified: head/sys/dev/atkbdc/atkbdc.c head/sys/dev/atkbdc/atkbdcreg.h head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/atkbdc.c == --- head/sys/dev/atkbdc/atkbdc.cThu Nov 19 21:10:36 2020 (r367853) +++ head/sys/dev/atkbdc/atkbdc.cFri Nov 20 00:13:30 2020 (r367854) @@ -117,6 +117,8 @@ static struct atkbdc_quirks quirks[] = { {"coreboot", NULL, NULL, KBDC_QUIRK_KEEP_ACTIVATED | KBDC_QUIRK_IGNORE_PROBE_RESULT | KBDC_QUIRK_RESET_AFTER_PROBE | KBDC_QUIRK_SETLEDS_ON_INIT}, +/* KBDC hangs on Lenovo X120e and X121e after disabling AUX MUX */ +{NULL, "LENOVO", NULL, KBDC_QUIRK_DISABLE_MUX_PROBE}, {NULL, NULL, NULL, 0} }; Modified: head/sys/dev/atkbdc/atkbdcreg.h == --- head/sys/dev/atkbdc/atkbdcreg.h Thu Nov 19 21:10:36 2020 (r367853) +++ head/sys/dev/atkbdc/atkbdcreg.h Fri Nov 20 00:13:30 2020 (r367854) @@ -211,6 +211,7 @@ typedef struct atkbdc_softc { #define KBDC_QUIRK_IGNORE_PROBE_RESULT (1 << 1) #define KBDC_QUIRK_RESET_AFTER_PROBE (1 << 2) #define KBDC_QUIRK_SETLEDS_ON_INIT (1 << 3) +#define KBDC_QUIRK_DISABLE_MUX_PROBE (1 << 4) int aux_mux_enabled; /* active PS/2 multiplexing is enabled */ int aux_mux_port; /* current aux mux port */ } atkbdc_softc_t; Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Thu Nov 19 21:10:36 2020(r367853) +++ head/sys/dev/atkbdc/psm.c Fri Nov 20 00:13:30 2020(r367854) @@ -517,7 +517,7 @@ static int verbose = PSM_DEBUG; static int synaptics_support = 1; static int trackpoint_support = 1; static int elantech_support = 1; -static int mux_disabled = 0; +static int mux_disabled = -1; /* for backward compatibility */ #defineOLD_MOUSE_GETHWINFO _IOR('M', 1, old_mousehw_t) @@ -6292,7 +6292,8 @@ enable_synaptics_mux(struct psm_softc *sc, enum probea int active_ports_count = 0; int active_ports_mask = 0; - if (mux_disabled != 0) + if (mux_disabled == 1 || (mux_disabled == -1 && + (kbdc->quirks & KBDC_QUIRK_DISABLE_MUX_PROBE) != 0)) return (FALSE); version = enable_aux_mux(kbdc); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367673 - head/sys/compat/linuxkpi/common/include/linux
Author: wulf Date: Sat Nov 14 10:34:18 2020 New Revision: 367673 URL: https://svnweb.freebsd.org/changeset/base/367673 Log: LinuxKPI: Exclude linux/acpi.h content on non-ACPI archs. LinuxKPI ACPI support is based on FreeBSD import of ACPICA which can be compiled only on aarch64, amd64 and i386. Ifdef-out broken parts on our side to avoid patching of vendor code. This fixes drm-devel-kmod build on powerpc64(le). Reported by: pkubaj Modified: head/sys/compat/linuxkpi/common/include/linux/acpi.h Modified: head/sys/compat/linuxkpi/common/include/linux/acpi.h == --- head/sys/compat/linuxkpi/common/include/linux/acpi.hSat Nov 14 05:30:10 2020(r367672) +++ head/sys/compat/linuxkpi/common/include/linux/acpi.hSat Nov 14 10:34:18 2020(r367673) @@ -33,10 +33,14 @@ #include +#if defined(__aarch64__) || defined(__amd64__) || defined(__i386__) + #include #include #defineACPI_HANDLE(dev)\ ((dev)->bsddev != NULL ? bsd_acpi_get_handle((dev)->bsddev) : NULL) + +#endif #endif /* _LINUX_ACPI_H_ */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367349 - head/sys/dev/atkbdc
Author: wulf Date: Wed Nov 4 21:52:10 2020 New Revision: 367349 URL: https://svnweb.freebsd.org/changeset/base/367349 Log: atkbdc(4): Add quirk for "System76 lemur Pro" laptops. Currently atkbdc(4) assumes all coreboot BIOSes belonging to Chromebooks and unconditionally sets a number of quirks to workaround known issues. Exclude "System76" laptops from this set as they appeared to be a traditional hardware ("lemur Pro" is a rebranded Clevo chassis) with coreboot firmware on board. KBDC_QUIRK_KEEP_ACTIVATED quirk activated for Chromebook platform makes keyboard on this devices inoperable. "Purism Librem" laptops may require the same exclusion too. PR: 250711 Reported by: nick.l...@gmail.com MFC after:2 weeks Modified: head/sys/dev/atkbdc/atkbdc.c Modified: head/sys/dev/atkbdc/atkbdc.c == --- head/sys/dev/atkbdc/atkbdc.cWed Nov 4 21:39:04 2020 (r367348) +++ head/sys/dev/atkbdc/atkbdc.cWed Nov 4 21:52:10 2020 (r367349) @@ -113,6 +113,7 @@ struct atkbdc_quirks { }; static struct atkbdc_quirks quirks[] = { +{"coreboot", "System76", NULL, 0}, {"coreboot", NULL, NULL, KBDC_QUIRK_KEEP_ACTIVATED | KBDC_QUIRK_IGNORE_PROBE_RESULT | KBDC_QUIRK_RESET_AFTER_PROBE | KBDC_QUIRK_SETLEDS_ON_INIT}, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367241 - head/sys/dev/acpica
Author: wulf Date: Sat Oct 31 22:20:42 2020 New Revision: 367241 URL: https://svnweb.freebsd.org/changeset/base/367241 Log: acpi_dock(4): Add ACPI_PNP_INFO MFC after:2 weeks Modified: head/sys/dev/acpica/acpi_dock.c Modified: head/sys/dev/acpica/acpi_dock.c == --- head/sys/dev/acpica/acpi_dock.c Sat Oct 31 22:19:39 2020 (r367240) +++ head/sys/dev/acpica/acpi_dock.c Sat Oct 31 22:20:42 2020 (r367241) @@ -64,6 +64,8 @@ struct acpi_dock_softc { ACPI_SERIAL_DECL(dock, "ACPI Docking Station"); +static char *acpi_dock_pnp_ids[] = {"PNP0C15", NULL}; + /* * Utility functions */ @@ -545,3 +547,4 @@ static devclass_t acpi_dock_devclass; DRIVER_MODULE(acpi_dock, acpi, acpi_dock_driver, acpi_dock_devclass, 0, 0); MODULE_DEPEND(acpi_dock, acpi, 1, 1, 1); +ACPI_PNP_INFO(acpi_dock_pnp_ids); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367240 - head/sys/dev/acpi_support
Author: wulf Date: Sat Oct 31 22:19:39 2020 New Revision: 367240 URL: https://svnweb.freebsd.org/changeset/base/367240 Log: acpi_wmi(4): Add ACPI_PNP_INFO MFC after:2 weeks Modified: head/sys/dev/acpi_support/acpi_wmi.c Modified: head/sys/dev/acpi_support/acpi_wmi.c == --- head/sys/dev/acpi_support/acpi_wmi.cSat Oct 31 22:15:59 2020 (r367239) +++ head/sys/dev/acpi_support/acpi_wmi.cSat Oct 31 22:19:39 2020 (r367240) @@ -201,6 +201,7 @@ DRIVER_MODULE(acpi_wmi, acpi, acpi_wmi_driver, acpi_wm MODULE_VERSION(acpi_wmi, 1); MODULE_DEPEND(acpi_wmi, acpi, 1, 1, 1); static char *wmi_ids[] = {"PNP0C14", NULL}; +ACPI_PNP_INFO(wmi_ids); /* * Probe for the PNP0C14 ACPI node ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367239 - in head/sys/dev: acpica iicbus
Author: wulf Date: Sat Oct 31 22:15:59 2020 New Revision: 367239 URL: https://svnweb.freebsd.org/changeset/base/367239 Log: Add plug and play information macroses for ACPI and I2C buses. Matching table format is compatible with ACPI_ID_PROBE bus method. Note that while ACPI_ID_PROBE matches against _HID and all _CIDs, current acpi_pnpinfo_str() exports only _HID and first _CID. That means second and further _CIDs should be added to both acpi_pnpinfo_str() and ACPICOMPAT_PNP_INFO if device matching against them is required. Reviewed by: imp MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D26824 Modified: head/sys/dev/acpica/acpivar.h head/sys/dev/iicbus/iicbus.h Modified: head/sys/dev/acpica/acpivar.h == --- head/sys/dev/acpica/acpivar.h Sat Oct 31 22:14:37 2020 (r367238) +++ head/sys/dev/acpica/acpivar.h Sat Oct 31 22:15:59 2020 (r367239) @@ -232,6 +232,20 @@ extern int acpi_quirks; #define ACPI_Q_MADT_IRQ0 (1 << 2) /* + * Plug and play information for device matching. Matching table format + * is compatible with ids parameter of ACPI_ID_PROBE bus method. + * + * XXX: While ACPI_ID_PROBE matches against _HID and all _CIDs, current + * acpi_pnpinfo_str() exports only _HID and first _CID. That means second + * and further _CIDs should be added to both acpi_pnpinfo_str() and + * ACPICOMPAT_PNP_INFO if device matching against them is required. + */ +#defineACPICOMPAT_PNP_INFO(t, busname) \ + MODULE_PNP_INFO("Z:_HID", busname, t##hid, t, nitems(t)-1); \ + MODULE_PNP_INFO("Z:_CID", busname, t##cid, t, nitems(t)-1); +#defineACPI_PNP_INFO(t)ACPICOMPAT_PNP_INFO(t, acpi) + +/* * Note that the low ivar values are reserved to provide * interface compatibility with ISA drivers which can also * attach to ACPI. Modified: head/sys/dev/iicbus/iicbus.h == --- head/sys/dev/iicbus/iicbus.hSat Oct 31 22:14:37 2020 (r367238) +++ head/sys/dev/iicbus/iicbus.hSat Oct 31 22:15:59 2020 (r367239) @@ -77,6 +77,12 @@ IICBUS_ACCESSOR(addr,ADDR, uint32_t) #defineIICBUS_FDT_PNP_INFO(t) #endif +#ifdef DEV_ACPI +#defineIICBUS_ACPI_PNP_INFO(t) ACPICOMPAT_PNP_INFO(t, iicbus) +#else +#defineIICBUS_ACPI_PNP_INFO(t) +#endif + int iicbus_generic_intr(device_t dev, int event, char *buf); void iicbus_init_frequency(device_t dev, u_int bus_freq); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367237 - head/sbin/devmatch
Author: wulf Date: Sat Oct 31 22:04:13 2020 New Revision: 367237 URL: https://svnweb.freebsd.org/changeset/base/367237 Log: devmatch(8): Respect mask field when matching strings of Z type. While here, add debug output for this action. Reviewed by: imp MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D26823 Modified: head/sbin/devmatch/devmatch.c Modified: head/sbin/devmatch/devmatch.c == --- head/sbin/devmatch/devmatch.c Sat Oct 31 21:53:23 2020 (r367236) +++ head/sbin/devmatch/devmatch.c Sat Oct 31 22:04:13 2020 (r367237) @@ -349,7 +349,12 @@ search_hints(const char *bus, const char *dev, const c } if (*cp == 'D') break; + if (bit >= 0 && ((1 << bit) & mask) == 0) + break; s = pnpval_as_str(cp + 2, pnpinfo); + if (verbose_flag) + printf("Matching %s (%c) table=%s tomatch=%s\n", + cp + 2, *cp, s, val1); if (strcmp(s, val1) != 0) notme++; break; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367234 - head/sys/dev/acpica
Author: wulf Date: Sat Oct 31 20:28:13 2020 New Revision: 367234 URL: https://svnweb.freebsd.org/changeset/base/367234 Log: acpi_video(4): Put display device in to D3 state on "Display off" event. As required by ACPI specs 6.3, appendix A.6, table B-8. Modified: head/sys/dev/acpica/acpi_video.c Modified: head/sys/dev/acpica/acpi_video.c == --- head/sys/dev/acpica/acpi_video.cSat Oct 31 20:25:55 2020 (r367233) +++ head/sys/dev/acpica/acpi_video.cSat Oct 31 20:28:13 2020 (r367234) @@ -846,6 +846,9 @@ acpi_video_vo_notify_handler(ACPI_HANDLE handle, UINT3 break; } break; + case VID_NOTIFY_DISP_OFF: + acpi_pwr_switch_consumer(handle, ACPI_STATE_D3); + break; } if (new_level != level) { vo_set_brightness(vo, new_level); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367233 - head/sys/dev/acpica
Author: wulf Date: Sat Oct 31 20:25:55 2020 New Revision: 367233 URL: https://svnweb.freebsd.org/changeset/base/367233 Log: acpi_video(4): Add evdev support for reporting of video events. Modified: head/sys/dev/acpica/acpi_video.c Modified: head/sys/dev/acpica/acpi_video.c == --- head/sys/dev/acpica/acpi_video.cSat Oct 31 20:14:28 2020 (r367232) +++ head/sys/dev/acpica/acpi_video.cSat Oct 31 20:25:55 2020 (r367233) @@ -29,6 +29,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_evdev.h" + #include #include #include @@ -43,6 +45,11 @@ __FBSDID("$FreeBSD$"); #include +#ifdef EVDEV_SUPPORT +#include +#include +#endif + /* ACPI video extension driver. */ struct acpi_video_output { ACPI_HANDLE handle; @@ -61,6 +68,9 @@ struct acpi_video_output { int *vo_levels; struct sysctl_ctx_list vo_sysctl_ctx; struct sysctl_oid *vo_sysctl_tree; +#ifdef EVDEV_SUPPORT + struct evdev_dev *evdev; +#endif }; STAILQ_HEAD(acpi_video_output_queue, acpi_video_output); @@ -70,6 +80,9 @@ struct acpi_video_softc { ACPI_HANDLE handle; struct acpi_video_output_queue vid_outputs; eventhandler_tagvid_pwr_evh; +#ifdef EVDEV_SUPPORT + struct evdev_dev*evdev; +#endif }; /* interfaces */ @@ -107,10 +120,14 @@ static void vo_set_device_state(ACPI_HANDLE, UINT32); /* events */ #defineVID_NOTIFY_SWITCHED 0x80 #defineVID_NOTIFY_REPROBE 0x81 +#defineVID_NOTIFY_CYCLE_OUT0x82 +#defineVID_NOTIFY_NEXT_OUT 0x83 +#defineVID_NOTIFY_PREV_OUT 0x84 #defineVID_NOTIFY_CYCLE_BRN0x85 #defineVID_NOTIFY_INC_BRN 0x86 #defineVID_NOTIFY_DEC_BRN 0x87 #defineVID_NOTIFY_ZERO_BRN 0x88 +#defineVID_NOTIFY_DISP_OFF 0x89 /* _DOS (Enable/Disable Output Switching) argument bits */ #defineDOS_SWITCH_MASK 3 @@ -175,6 +192,9 @@ static devclass_t acpi_video_devclass; DRIVER_MODULE(acpi_video, vgapci, acpi_video_driver, acpi_video_devclass, acpi_video_modevent, NULL); MODULE_DEPEND(acpi_video, acpi, 1, 1, 1); +#ifdef EVDEV_SUPPORT +MODULE_DEPEND(acpi_video, evdev, 1, 1, 1); +#endif static struct sysctl_ctx_list acpi_video_sysctl_ctx; static struct sysctl_oid *acpi_video_sysctl_tree; @@ -190,6 +210,45 @@ ACPI_SERIAL_DECL(video, "ACPI video"); ACPI_SERIAL_DECL(video_output, "ACPI video output"); static MALLOC_DEFINE(M_ACPIVIDEO, "acpivideo", "ACPI video extension"); +#ifdef EVDEV_SUPPORT +static const struct { + UINT32 notify; + uint16_tkey; +} acpi_video_evdev_map[] = { + { VID_NOTIFY_SWITCHED, KEY_SWITCHVIDEOMODE }, + { VID_NOTIFY_REPROBE, KEY_SWITCHVIDEOMODE }, + { VID_NOTIFY_CYCLE_OUT, KEY_SWITCHVIDEOMODE }, + { VID_NOTIFY_NEXT_OUT, KEY_VIDEO_NEXT }, + { VID_NOTIFY_PREV_OUT, KEY_VIDEO_PREV }, + { VID_NOTIFY_CYCLE_BRN, KEY_BRIGHTNESS_CYCLE }, + { VID_NOTIFY_INC_BRN, KEY_BRIGHTNESSUP }, + { VID_NOTIFY_DEC_BRN, KEY_BRIGHTNESSDOWN }, + { VID_NOTIFY_ZERO_BRN, KEY_BRIGHTNESS_ZERO }, + { VID_NOTIFY_DISP_OFF, KEY_DISPLAY_OFF }, +}; + +static void +acpi_video_push_evdev_event(struct evdev_dev *evdev, UINT32 notify) +{ + int i; + uint16_t key; + + /* Do not allow to execute 2 instances this routine concurently */ + ACPI_SERIAL_ASSERT(video_output); + + for (i = 0; i < nitems(acpi_video_evdev_map); i++) { + if (acpi_video_evdev_map[i].notify == notify) { + key = acpi_video_evdev_map[i].key; + evdev_push_key(evdev, key, 1); + evdev_sync(evdev); + evdev_push_key(evdev, key, 0); + evdev_sync(evdev); + break; + } + } +} +#endif + static int acpi_video_modevent(struct module *mod __unused, int evt, void *cookie __unused) { @@ -247,12 +306,30 @@ acpi_video_attach(device_t dev) { struct acpi_softc *acpi_sc; struct acpi_video_softc *sc; +#ifdef EVDEV_SUPPORT + int i; +#endif sc = device_get_softc(dev); acpi_sc = devclass_get_softc(devclass_find("acpi"), 0); if (acpi_sc == NULL) return (ENXIO); + +#ifdef EVDEV_SUPPORT + sc->evdev = evdev_alloc(); + evdev_set_name(sc->evdev, device_get_desc(dev)); + evdev_set_phys(sc->evdev, device_get_nameunit(dev)); + evdev_set_id(sc->evdev, BUS_HOST, 0, 0, 1); + evdev_support_event(sc->evdev, EV_SYN); + evdev_support_event(sc->evdev, EV_KEY); + for (i = 0; i < nitems(acpi_video_evdev_map); i++) + evdev_support_key(sc->evdev, acpi_video_evdev_map[i].key); + + if (evdev_register(sc->evdev) != 0) + retu
svn commit: r367232 - head/sys/dev/acpica
Author: wulf Date: Sat Oct 31 20:14:28 2020 New Revision: 367232 URL: https://svnweb.freebsd.org/changeset/base/367232 Log: acpi(9): Add EVENTHANDLERs for video and AC adapter events. They are required for coming ACPI support in LinuxKPI. Reviewed by: hselasky, manu (as part of D26603) Modified: head/sys/dev/acpica/acpi_acad.c head/sys/dev/acpica/acpi_video.c head/sys/dev/acpica/acpivar.h Modified: head/sys/dev/acpica/acpi_acad.c == --- head/sys/dev/acpica/acpi_acad.c Sat Oct 31 19:47:34 2020 (r367231) +++ head/sys/dev/acpica/acpi_acad.c Sat Oct 31 20:14:28 2020 (r367232) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -115,6 +116,7 @@ acpi_acad_get_status(void *context) ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev), "%s Line\n", newstatus ? "On" : "Off"); acpi_UserNotify("ACAD", h, newstatus); + EVENTHANDLER_INVOKE(acpi_acad_event, newstatus); } else ACPI_SERIAL_END(acad); } Modified: head/sys/dev/acpica/acpi_video.c == --- head/sys/dev/acpica/acpi_video.cSat Oct 31 19:47:34 2020 (r367231) +++ head/sys/dev/acpica/acpi_video.cSat Oct 31 20:14:28 2020 (r367232) @@ -351,6 +351,12 @@ acpi_video_shutdown(device_t dev) } static void +acpi_video_invoke_event_handler(void *context) +{ + EVENTHANDLER_INVOKE(acpi_video_event, (int)(intptr_t)context); +} + +static void acpi_video_notify_handler(ACPI_HANDLE handle, UINT32 notify, void *context) { struct acpi_video_softc *sc; @@ -402,6 +408,8 @@ acpi_video_notify_handler(ACPI_HANDLE handle, UINT32 n device_printf(sc->device, "unknown notify event 0x%x\n", notify); } + AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_video_invoke_event_handler, + (void *)(uintptr_t)notify); } static void @@ -752,6 +760,9 @@ acpi_video_vo_notify_handler(ACPI_HANDLE handle, UINT3 out: ACPI_SERIAL_END(video_output); + + AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_video_invoke_event_handler, + (void *)(uintptr_t)notify); } /* ARGSUSED */ Modified: head/sys/dev/acpica/acpivar.h == --- head/sys/dev/acpica/acpivar.h Sat Oct 31 19:47:34 2020 (r367231) +++ head/sys/dev/acpica/acpivar.h Sat Oct 31 20:14:28 2020 (r367232) @@ -433,6 +433,8 @@ typedef void (*acpi_event_handler_t)(void *, int); EVENTHANDLER_DECLARE(acpi_sleep_event, acpi_event_handler_t); EVENTHANDLER_DECLARE(acpi_wakeup_event, acpi_event_handler_t); +EVENTHANDLER_DECLARE(acpi_acad_event, acpi_event_handler_t); +EVENTHANDLER_DECLARE(acpi_video_event, acpi_event_handler_t); /* Device power control. */ ACPI_STATUSacpi_pwr_wake_enable(ACPI_HANDLE consumer, int enable); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367231 - head/sys/dev/acpica
Author: wulf Date: Sat Oct 31 19:47:34 2020 New Revision: 367231 URL: https://svnweb.freebsd.org/changeset/base/367231 Log: acpi: Tweak _DSM method evaluation helpers. - Use ACPI style for _DSM evaluation helper parameter types. - Constify UUID parameter. - Increase size of returned DSM function bitmap by acpi_DSMQuery() up to 64 items. Old limit of 8 functions is not sufficient for JEDEC JESD245 NVDIMMs. - Add new acpi_EvaluateDSMTyped() helper which performs additional return value type check as compared with acpi_EvaluateDSM(). - Reimplement acpi_EvaluateDSM() on top of the acpi_EvaluateDSMTyped() call. Reviewed by: scottph, manu Differential Revision:https://reviews.freebsd.org/D26602 Modified: head/sys/dev/acpica/acpi.c head/sys/dev/acpica/acpivar.h Modified: head/sys/dev/acpica/acpi.c == --- head/sys/dev/acpica/acpi.c Sat Oct 31 19:30:23 2020(r367230) +++ head/sys/dev/acpica/acpi.c Sat Oct 31 19:47:34 2020(r367231) @@ -2632,8 +2632,8 @@ acpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOU return (AE_OK); } -UINT8 -acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revision) +UINT64 +acpi_DSMQuery(ACPI_HANDLE h, const uint8_t *uuid, int revision) { /* * ACPI spec 9.1.1 defines this. @@ -2645,7 +2645,8 @@ acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revisi */ ACPI_BUFFER buf; ACPI_OBJECT *obj; -UINT8 ret = 0; +UINT64 ret = 0; +int i; if (!ACPI_SUCCESS(acpi_EvaluateDSM(h, uuid, revision, 0, NULL, &buf))) { ACPI_INFO(("Failed to enumerate DSM functions\n")); @@ -2663,12 +2664,13 @@ acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revisi */ switch (obj->Type) { case ACPI_TYPE_BUFFER: - ret = *(uint8_t *)obj->Buffer.Pointer; + for (i = 0; i < MIN(obj->Buffer.Length, sizeof(ret)); i++) + ret |= (((uint64_t)obj->Buffer.Pointer[i]) << (i * 8)); break; case ACPI_TYPE_INTEGER: ACPI_BIOS_WARNING((AE_INFO, "Possibly buggy BIOS with ACPI_TYPE_INTEGER for function enumeration\n")); - ret = obj->Integer.Value & 0xFF; + ret = obj->Integer.Value; break; default: ACPI_WARNING((AE_INFO, "Unexpected return type %u\n", obj->Type)); @@ -2684,9 +2686,18 @@ acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revisi * check the type of the returned object. */ ACPI_STATUS -acpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid, int revision, -uint64_t function, union acpi_object *package, ACPI_BUFFER *out_buf) +acpi_EvaluateDSM(ACPI_HANDLE handle, const uint8_t *uuid, int revision, +UINT64 function, ACPI_OBJECT *package, ACPI_BUFFER *out_buf) { + return (acpi_EvaluateDSMTyped(handle, uuid, revision, function, + package, out_buf, ACPI_TYPE_ANY)); +} + +ACPI_STATUS +acpi_EvaluateDSMTyped(ACPI_HANDLE handle, const uint8_t *uuid, int revision, +UINT64 function, ACPI_OBJECT *package, ACPI_BUFFER *out_buf, +ACPI_OBJECT_TYPE type) +{ ACPI_OBJECT arg[4]; ACPI_OBJECT_LIST arglist; ACPI_BUFFER buf; @@ -2697,7 +2708,7 @@ acpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid, in arg[0].Type = ACPI_TYPE_BUFFER; arg[0].Buffer.Length = ACPI_UUID_LENGTH; -arg[0].Buffer.Pointer = uuid; +arg[0].Buffer.Pointer = __DECONST(uint8_t *, uuid); arg[1].Type = ACPI_TYPE_INTEGER; arg[1].Integer.Value = revision; arg[2].Type = ACPI_TYPE_INTEGER; @@ -2714,7 +2725,7 @@ acpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid, in arglist.Count = 4; buf.Pointer = NULL; buf.Length = ACPI_ALLOCATE_BUFFER; -status = AcpiEvaluateObject(handle, "_DSM", &arglist, &buf); +status = AcpiEvaluateObjectTyped(handle, "_DSM", &arglist, &buf, type); if (ACPI_FAILURE(status)) return (status); Modified: head/sys/dev/acpica/acpivar.h == --- head/sys/dev/acpica/acpivar.h Sat Oct 31 19:30:23 2020 (r367230) +++ head/sys/dev/acpica/acpivar.h Sat Oct 31 19:47:34 2020 (r367231) @@ -349,10 +349,15 @@ ACPI_STATUS acpi_FindIndexedResource(ACPI_BUFFER *buf, ACPI_RESOURCE **resp); ACPI_STATUSacpi_AppendBufferResource(ACPI_BUFFER *buf, ACPI_RESOURCE *res); -UINT8 acpi_DSMQuery(ACPI_HANDLE h, uint8_t *uuid, int revision); -ACPI_STATUSacpi_EvaluateDSM(ACPI_HANDLE handle, uint8_t *uuid, - int revision, uint64_t function, union acpi_object *package, +UINT64 acpi_DSMQuery(ACPI_HANDLE h, const uint8_t *uuid, + int revision); +ACPI_STATUSacpi_EvaluateDSM(ACPI_HANDLE handle, const uint8_t *uuid, + int revision, UINT64 function, ACPI_OBJECT *package, ACPI_BUFFER *out_buf); +ACPI_STATUSacpi_EvaluateDSMTyped(ACPI_HANDLE handle, +
svn commit: r367230 - head/sys/dev/ichiic
Author: wulf Date: Sat Oct 31 19:30:23 2020 New Revision: 367230 URL: https://svnweb.freebsd.org/changeset/base/367230 Log: ig4(4): Add PCI IDs for Intel Comit Lake I2C controllers. MFC after:2 weeks Modified: head/sys/dev/ichiic/ig4_pci.c Modified: head/sys/dev/ichiic/ig4_pci.c == --- head/sys/dev/ichiic/ig4_pci.c Sat Oct 31 19:07:32 2020 (r367229) +++ head/sys/dev/ichiic/ig4_pci.c Sat Oct 31 19:30:23 2020 (r367230) @@ -107,6 +107,20 @@ static int ig4iic_pci_detach(device_t dev); #define PCI_CHIP_CANNONLAKE_H_I2C_10xa3698086 #define PCI_CHIP_CANNONLAKE_H_I2C_20xa36a8086 #define PCI_CHIP_CANNONLAKE_H_I2C_30xa36b8086 +#define PCI_CHIP_COMETLAKE_LP_I2C_00x02e88086 +#define PCI_CHIP_COMETLAKE_LP_I2C_10x02e98086 +#define PCI_CHIP_COMETLAKE_LP_I2C_20x02ea8086 +#define PCI_CHIP_COMETLAKE_LP_I2C_30x02eb8086 +#define PCI_CHIP_COMETLAKE_LP_I2C_40x02c58086 +#define PCI_CHIP_COMETLAKE_LP_I2C_50x02c68086 +#define PCI_CHIP_COMETLAKE_H_I2C_0 0x06e88086 +#define PCI_CHIP_COMETLAKE_H_I2C_1 0x06e98086 +#define PCI_CHIP_COMETLAKE_H_I2C_2 0x06ea8086 +#define PCI_CHIP_COMETLAKE_H_I2C_3 0x06eb8086 +#define PCI_CHIP_COMETLAKE_V_I2C_0 0xa3e08086 +#define PCI_CHIP_COMETLAKE_V_I2C_1 0xa3e18086 +#define PCI_CHIP_COMETLAKE_V_I2C_2 0xa3e28086 +#define PCI_CHIP_COMETLAKE_V_I2C_3 0xa3e38086 struct ig4iic_pci_device { uint32_tdevid; @@ -156,6 +170,20 @@ static struct ig4iic_pci_device ig4iic_pci_devices[] = { PCI_CHIP_CANNONLAKE_H_I2C_1, "Intel Cannon Lake-H I2C Controller-1", IG4_CANNONLAKE}, { PCI_CHIP_CANNONLAKE_H_I2C_2, "Intel Cannon Lake-H I2C Controller-2", IG4_CANNONLAKE}, { PCI_CHIP_CANNONLAKE_H_I2C_3, "Intel Cannon Lake-H I2C Controller-3", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_LP_I2C_0, "Intel Comet Lake-LP I2C Controller-0", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_LP_I2C_1, "Intel Comet Lake-LP I2C Controller-1", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_LP_I2C_2, "Intel Comet Lake-LP I2C Controller-2", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_LP_I2C_3, "Intel Comet Lake-LP I2C Controller-3", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_LP_I2C_4, "Intel Comet Lake-LP I2C Controller-4", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_LP_I2C_5, "Intel Comet Lake-LP I2C Controller-5", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_H_I2C_0, "Intel Comet Lake-H I2C Controller-0", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_H_I2C_1, "Intel Comet Lake-H I2C Controller-1", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_H_I2C_2, "Intel Comet Lake-H I2C Controller-2", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_H_I2C_3, "Intel Comet Lake-H I2C Controller-3", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_V_I2C_0, "Intel Comet Lake-V I2C Controller-0", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_V_I2C_1, "Intel Comet Lake-V I2C Controller-1", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_V_I2C_2, "Intel Comet Lake-V I2C Controller-2", IG4_CANNONLAKE}, + { PCI_CHIP_COMETLAKE_V_I2C_3, "Intel Comet Lake-V I2C Controller-3", IG4_CANNONLAKE}, }; static int ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r364964 - in head: share/man/man9 sys/compat/linuxkpi/common/include/linux sys/kern sys/sys sys/vm
Author: wulf Date: Sat Aug 29 19:26:31 2020 New Revision: 364964 URL: https://svnweb.freebsd.org/changeset/base/364964 Log: LinuxKPI: Implement ksize() function. In Linux, ksize() gets the actual amount of memory allocated for a given object. This commit adds malloc_usable_size() to FreeBSD KPI which does the same. It also maps LinuxKPI ksize() to newly created function. ksize() function is used by drm-kmod. Reviewed by: hselasky, kib MFC after:1 week Differential Revision:https://reviews.freebsd.org/D26215 Modified: head/share/man/man9/malloc.9 head/sys/compat/linuxkpi/common/include/linux/slab.h head/sys/kern/kern_malloc.c head/sys/sys/malloc.h head/sys/vm/memguard.c head/sys/vm/memguard.h Modified: head/share/man/man9/malloc.9 == --- head/share/man/man9/malloc.9Sat Aug 29 18:11:37 2020 (r364963) +++ head/share/man/man9/malloc.9Sat Aug 29 19:26:31 2020 (r364964) @@ -29,7 +29,7 @@ .\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $ .\" $FreeBSD$ .\" -.Dd August 3, 2020 +.Dd August 28, 2020 .Dt MALLOC 9 .Os .Sh NAME @@ -55,6 +55,8 @@ .Fn realloc "void *addr" "size_t size" "struct malloc_type *type" "int flags" .Ft void * .Fn reallocf "void *addr" "size_t size" "struct malloc_type *type" "int flags" +.Ft size_t +.Fn malloc_usable_size "const void *addr" .Fn MALLOC_DECLARE type .In sys/param.h .In sys/malloc.h @@ -149,6 +151,13 @@ function is identical to .Fn realloc except that it will free the passed pointer when the requested memory cannot be allocated. +.Pp +The +.Fn malloc_usable_size +function returns the usable size of the allocation pointed to by +.Fa addr . +The return value may be larger than the size that was requested during +allocation. .Pp Unlike its standard C library counterpart .Pq Xr malloc 3 , Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h == --- head/sys/compat/linuxkpi/common/include/linux/slab.hSat Aug 29 18:11:37 2020(r364963) +++ head/sys/compat/linuxkpi/common/include/linux/slab.hSat Aug 29 19:26:31 2020(r364964) @@ -154,6 +154,12 @@ kfree(const void *ptr) free(__DECONST(void *, ptr), M_KMALLOC); } +static inline size_t +ksize(const void *ptr) +{ + return (malloc_usable_size(ptr)); +} + extern struct linux_kmem_cache *linux_kmem_cache_create(const char *name, size_t size, size_t align, unsigned flags, linux_kmem_ctor_t *ctor); Modified: head/sys/kern/kern_malloc.c == --- head/sys/kern/kern_malloc.c Sat Aug 29 18:11:37 2020(r364963) +++ head/sys/kern/kern_malloc.c Sat Aug 29 19:26:31 2020(r364964) @@ -938,6 +938,42 @@ reallocf(void *addr, size_t size, struct malloc_type * return (mem); } +/* + * malloc_usable_size: returns the usable size of the allocation. + */ +size_t +malloc_usable_size(const void *addr) +{ +#ifndef DEBUG_REDZONE + uma_zone_t zone; + uma_slab_t slab; +#endif + u_long size; + + if (addr == NULL) + return (0); + +#ifdef DEBUG_MEMGUARD + if (is_memguard_addr(__DECONST(void *, addr))) + return (memguard_get_req_size(addr)); +#endif + +#ifdef DEBUG_REDZONE + size = redzone_get_size(__DECONST(void *, addr)); +#else + vtozoneslab((vm_offset_t)addr & (~UMA_SLAB_MASK), &zone, &slab); + if (slab == NULL) + panic("malloc_usable_size: address %p(%p) is not allocated.\n", + addr, (void *)((u_long)addr & (~UMA_SLAB_MASK))); + + if (!malloc_large_slab(slab)) + size = zone->uz_size; + else + size = malloc_large_size(slab); +#endif + return (size); +} + CTASSERT(VM_KMEM_SIZE_SCALE >= 1); /* Modified: head/sys/sys/malloc.h == --- head/sys/sys/malloc.h Sat Aug 29 18:11:37 2020(r364963) +++ head/sys/sys/malloc.h Sat Aug 29 19:26:31 2020(r364964) @@ -244,6 +244,7 @@ voidmalloc_type_allocated(struct malloc_type *type, u void malloc_type_freed(struct malloc_type *type, unsigned long size); void malloc_type_list(malloc_type_list_func_t *, void *); void malloc_uninit(void *); +size_t malloc_usable_size(const void *); void *realloc(void *addr, size_t size, struct malloc_type *type, int flags) __result_use_check __alloc_size(2); void *reallocf(void *addr, size_t size, struct malloc_type *type, int flags) Modified: head/sys/vm/memguard.c == --- head/sys/vm/memguard.c Sat Aug 29 18:11:37 2020(r364963) +++ head/sys/vm/memguard.c Sat Aug 29 19:26:31 2020(r364964)
svn commit: r363205 - head/sys/compat/linuxkpi/common/include/linux
Author: wulf Date: Tue Jul 14 21:56:59 2020 New Revision: 363205 URL: https://svnweb.freebsd.org/changeset/base/363205 Log: linuxkpi: Ignore NULL pointers passed to string parameter of kstr(n)dup That follows Linux and fixes related drm-kmod-5.3 panic. Reviewed by: imp, hselasky MFC after:1 week Differential Revision:https://reviews.freebsd.org/D25657 Modified: head/sys/compat/linuxkpi/common/include/linux/string.h Modified: head/sys/compat/linuxkpi/common/include/linux/string.h == --- head/sys/compat/linuxkpi/common/include/linux/string.h Tue Jul 14 21:43:57 2020(r363204) +++ head/sys/compat/linuxkpi/common/include/linux/string.h Tue Jul 14 21:56:59 2020(r363205) @@ -103,6 +103,8 @@ kstrdup(const char *string, gfp_t gfp) char *retval; size_t len; + if (string == NULL) + return (NULL); len = strlen(string) + 1; retval = kmalloc(len, gfp); if (retval != NULL) @@ -115,6 +117,8 @@ kstrndup(const char *string, size_t len, gfp_t gfp) { char *retval; + if (string == NULL) + return (NULL); retval = kmalloc(len + 1, gfp); if (retval != NULL) strncpy(retval, string, len); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r362599 - head/sys/dev/evdev
Author: wulf Date: Thu Jun 25 00:09:43 2020 New Revision: 362599 URL: https://svnweb.freebsd.org/changeset/base/362599 Log: atkbd/evdev: recognize the Chromebook menu key as F13 like Linux does. This is the key on the right side of the function keys, with the "hamburger menu" icon on it. Submitted by: GregV MFC after:1 week Differential Revision:https://reviews.freebsd.org/D25390 Modified: head/sys/dev/evdev/evdev_utils.c Modified: head/sys/dev/evdev/evdev_utils.c == --- head/sys/dev/evdev/evdev_utils.cThu Jun 25 00:01:24 2020 (r362598) +++ head/sys/dev/evdev/evdev_utils.cThu Jun 25 00:09:43 2020 (r362599) @@ -140,7 +140,7 @@ static uint16_t evdev_at_set1_scancodes[] = { KEY_KP2,KEY_KP3,KEY_KP0,KEY_KPDOT, NONE, NONE, KEY_102ND, KEY_F11, KEY_F12,NONE, NONE, NONE, - NONE, NONE, NONE, NONE, + NONE, KEY_F13,NONE, NONE, /* 0x60 - 0x7f */ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r362260 - head/sys/dev/evdev
Author: wulf Date: Wed Jun 17 08:35:35 2020 New Revision: 362260 URL: https://svnweb.freebsd.org/changeset/base/362260 Log: evdev: Add AT translated set1 scancodes for 'Eisu' & 'Kana' keys. PR: 247292 Submitted by: Yuichiro NAITO MFC after:1 week Modified: head/sys/dev/evdev/evdev_utils.c Modified: head/sys/dev/evdev/evdev_utils.c == --- head/sys/dev/evdev/evdev_utils.cWed Jun 17 08:08:57 2020 (r362259) +++ head/sys/dev/evdev/evdev_utils.cWed Jun 17 08:35:35 2020 (r362260) @@ -146,7 +146,7 @@ static uint16_t evdev_at_set1_scancodes[] = { NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, - KEY_KATAKANAHIRAGANA, NONE, NONE, KEY_RO, + KEY_KATAKANAHIRAGANA, KEY_HANGEUL,KEY_HANJA, KEY_RO, NONE, NONE, KEY_ZENKAKUHANKAKU, KEY_HIRAGANA, KEY_KATAKANA, KEY_HENKAN, NONE, KEY_MUHENKAN, NONE, KEY_YEN,KEY_KPCOMMA,NONE, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361718 - in head: share/man/man4 sys/dev/atkbdc
Author: wulf Date: Tue Jun 2 01:04:49 2020 New Revision: 361718 URL: https://svnweb.freebsd.org/changeset/base/361718 Log: [psm] Workaround active PS/2 multiplexor hang which happens on some laptops after returning to legacy multiplexing mode at initialization stage. PR: 242542 Reported by: Felix Palmen MFC after:1 week Modified: head/share/man/man4/psm.4 head/sys/dev/atkbdc/psm.c Modified: head/share/man/man4/psm.4 == --- head/share/man/man4/psm.4 Tue Jun 2 00:57:48 2020(r361717) +++ head/share/man/man4/psm.4 Tue Jun 2 01:04:49 2020(r361718) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 26, 2016 +.Dd June 2, 2020 .Dt PSM 4 .Os .Sh NAME @@ -361,6 +361,15 @@ the sysctl with the same name and by restarting .Xr moused 8 using .Pa /etc/rc.d/moused . +.Pp +Active multiplexing support can be disabled by setting +.Va hw.psm.mux_disabled +to +.Em 1 +at boot-time. +This will prevent +.Nm +from enabling active multiplexing mode needed for some Synaptics touchpads. .Sh IOCTLS There are a few .Xr ioctl 2 Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Tue Jun 2 00:57:48 2020(r361717) +++ head/sys/dev/atkbdc/psm.c Tue Jun 2 01:04:49 2020(r361718) @@ -517,6 +517,7 @@ static int verbose = PSM_DEBUG; static int synaptics_support = 1; static int trackpoint_support = 1; static int elantech_support = 1; +static int mux_disabled = 0; /* for backward compatibility */ #defineOLD_MOUSE_GETHWINFO _IOR('M', 1, old_mousehw_t) @@ -2989,6 +2990,9 @@ SYSCTL_INT(_hw_psm, OID_AUTO, trackpoint_support, CTLF SYSCTL_INT(_hw_psm, OID_AUTO, elantech_support, CTLFLAG_RDTUN, &elantech_support, 0, "Enable support for Elantech touchpads"); +SYSCTL_INT(_hw_psm, OID_AUTO, mux_disabled, CTLFLAG_RDTUN, +&mux_disabled, 0, "Disable active multiplexing"); + static void psmintr(void *arg) { @@ -6293,6 +6297,9 @@ enable_synaptics_mux(struct psm_softc *sc, enum probea int active_ports_count = 0; int active_ports_mask = 0; + if (mux_disabled != 0) + return (FALSE); + version = enable_aux_mux(kbdc); if (version == -1) return (FALSE); @@ -6329,6 +6336,21 @@ enable_synaptics_mux(struct psm_softc *sc, enum probea /* IRQ handler does not support active multiplexing mode */ disable_aux_mux(kbdc); + + /* Is MUX still alive after switching back to legacy mode? */ + if (!enable_aux_dev(kbdc) || !disable_aux_dev(kbdc)) { + /* +* On some laptops e.g. Lenovo X121e dead AUX MUX can be +* brought back to life with resetting of keyboard. +*/ + reset_kbd(kbdc); + if (!enable_aux_dev(kbdc) || !disable_aux_dev(kbdc)) { + printf("psm%d: AUX MUX hang detected!\n", sc->unit); + printf("Consider adding hw.psm.mux_disabled=1 to " + "loader tunables\n"); + } + } + empty_both_buffers(kbdc, 10); /* remove stray data if any */ return (probe); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r361715 - head/sys/dev/atkbdc
Author: wulf Date: Tue Jun 2 00:53:39 2020 New Revision: 361715 URL: https://svnweb.freebsd.org/changeset/base/361715 Log: [psm] Do not disable trackpoint when hw.psm.elantech.touchpad_off is enabled PR: 246117 Reported by: Alexander Sieg MFC after:1 week Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Tue Jun 2 00:49:13 2020(r361714) +++ head/sys/dev/atkbdc/psm.c Tue Jun 2 00:53:39 2020(r361715) @@ -4441,7 +4441,7 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m *x = *y = *z = 0; ms->button = ms->obutton; - if (sc->syninfo.touchpad_off) + if (sc->syninfo.touchpad_off && pkt != ELANTECH_PKT_TRACKPOINT) return (0); /* Common legend ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r360625 - head/sys/dev/evdev
Author: wulf Date: Mon May 4 11:00:24 2020 New Revision: 360625 URL: https://svnweb.freebsd.org/changeset/base/360625 Log: [evdev] Sync event codes with Linux kernel 5.6 MFC after:2 weeks Modified: head/sys/dev/evdev/input-event-codes.h head/sys/dev/evdev/input.h Modified: head/sys/dev/evdev/input-event-codes.h == --- head/sys/dev/evdev/input-event-codes.h Mon May 4 10:59:17 2020 (r360624) +++ head/sys/dev/evdev/input-event-codes.h Mon May 4 11:00:24 2020 (r360625) @@ -453,10 +453,12 @@ #defineKEY_TITLE 0x171 #defineKEY_SUBTITLE0x172 #defineKEY_ANGLE 0x173 -#defineKEY_ZOOM0x174 +#defineKEY_FULL_SCREEN 0x174 /* AC View Toggle */ +#defineKEY_ZOOMKEY_FULL_SCREEN #defineKEY_MODE0x175 #defineKEY_KEYBOARD0x176 -#defineKEY_SCREEN 0x177 +#defineKEY_ASPECT_RATIO0x177 /* HUTRR37: Aspect */ +#defineKEY_SCREEN KEY_ASPECT_RATIO #defineKEY_PC 0x178 /* Media Select Computer */ #defineKEY_TV 0x179 /* Media Select TV */ #defineKEY_TV2 0x17a /* Media Select Cable */ @@ -618,6 +620,7 @@ #defineKEY_SCREENSAVER 0x245 /* AL Screen Saver */ #defineKEY_VOICECOMMAND0x246 /* Listening Voice Command */ #defineKEY_ASSISTANT 0x247 /* AL Context-aware desktop assistant */ +#defineKEY_KBD_LAYOUT_NEXT 0x248 /* AC Next Keyboard Layout Select */ #defineKEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ #defineKEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ @@ -660,7 +663,87 @@ */ #defineKEY_DATA0x277 #defineKEY_ONSCREEN_KEYBOARD 0x278 +/* Electronic privacy screen control */ +#defineKEY_PRIVACY_SCREEN_TOGGLE 0x279 +/* Select an area of screen to be copied */ +#defineKEY_SELECTIVE_SCREENSHOT0x27a + +/* + * Some keyboards have keys which do not have a defined meaning, these keys + * are intended to be programmed / bound to macros by the user. For most + * keyboards with these macro-keys the key-sequence to inject, or action to + * take, is all handled by software on the host side. So from the kernel's + * point of view these are just normal keys. + * + * The KEY_MACRO# codes below are intended for such keys, which may be labeled + * e.g. G1-G18, or S1 - S30. The KEY_MACRO# codes MUST NOT be used for keys + * where the marking on the key does indicate a defined meaning / purpose. + * + * The KEY_MACRO# codes MUST also NOT be used as fallback for when no existing + * KEY_FOO define matches the marking / purpose. In this case a new KEY_FOO + * define MUST be added. + */ +#defineKEY_MACRO1 0x290 +#defineKEY_MACRO2 0x291 +#defineKEY_MACRO3 0x292 +#defineKEY_MACRO4 0x293 +#defineKEY_MACRO5 0x294 +#defineKEY_MACRO6 0x295 +#defineKEY_MACRO7 0x296 +#defineKEY_MACRO8 0x297 +#defineKEY_MACRO9 0x298 +#defineKEY_MACRO10 0x299 +#defineKEY_MACRO11 0x29a +#defineKEY_MACRO12 0x29b +#defineKEY_MACRO13 0x29c +#defineKEY_MACRO14 0x29d +#defineKEY_MACRO15 0x29e +#defineKEY_MACRO16 0x29f +#defineKEY_MACRO17 0x2a0 +#defineKEY_MACRO18 0x2a1 +#defineKEY_MACRO19 0x2a2 +#defineKEY_MACRO20 0x2a3 +#defineKEY_MACRO21 0x2a4 +#defineKEY_MACRO22 0x2a5 +#defineKEY_MACRO23 0x2a6 +#defineKEY_MACRO24 0x2a7 +#defineKEY_MACRO25 0x2a8 +#defineKEY_MACRO26 0x2a9 +#defineKEY_MACRO27 0x2aa +#defineKEY_MACRO28 0x2ab +#defineKEY_MACRO29 0x2ac +#defineKEY_MACRO30 0x2ad + +/* + * Some keyboards with the macro-keys described above have some extra keys + * for controlling the host-side software responsible for the macro handling: + * -A macro recording start/stop key. Note that not all keyboards which emit + * KEY_MACRO_RECORD_START will also emit KEY_MACRO_RECORD_STOP if + * KEY_MACRO_R
svn commit: r360624 - head/sys/dev/evdev
Author: wulf Date: Mon May 4 10:59:17 2020 New Revision: 360624 URL: https://svnweb.freebsd.org/changeset/base/360624 Log: [evdev] Add AT translated set1 scancodes for F-unlocked F1-12 keys. "F lock" is a switch between two sets of scancodes for function keys F1-F12 found on some Logitech and Microsoft PS/2 keyboards [1]. When "F lock" is pressed, then F1-F12 act as function keys and produce usual keyscans for these keys. When "F lock" is depressed, F1-F12 produced the same keyscans but prefixed with E0. Some laptops use [2] E0-prefixed F1-F12 scancodes for non-standard keys. [1] https://www.win.tue.nl/~aeb/linux/kbd/scancodes-6.html [2] https://reviews.freebsd.org/D21565 MFC after:2 weeks Modified: head/sys/dev/evdev/evdev_utils.c Modified: head/sys/dev/evdev/evdev_utils.c == --- head/sys/dev/evdev/evdev_utils.cMon May 4 10:10:07 2020 (r360623) +++ head/sys/dev/evdev/evdev_utils.cMon May 4 10:59:17 2020 (r360624) @@ -166,16 +166,16 @@ static uint16_t evdev_at_set1_scancodes[] = { NONE, NONE, KEY_VOLUMEDOWN, NONE, KEY_VOLUMEUP, NONE, KEY_HOMEPAGE, NONE, NONE, KEY_KPSLASH,NONE, KEY_SYSRQ, - KEY_RIGHTALT, NONE, NONE, NONE, - NONE, NONE, NONE, NONE, + KEY_RIGHTALT, NONE, NONE, KEY_F13, + KEY_F14,KEY_F15,KEY_F16,KEY_F17, /* 0x40 - 0x5f. 0xE0 prefixed */ - NONE, NONE, NONE, NONE, - NONE, NONE, KEY_PAUSE, KEY_HOME, + KEY_F18,KEY_F19,KEY_F20,KEY_F21, + KEY_F22,NONE, KEY_PAUSE, KEY_HOME, KEY_UP, KEY_PAGEUP, NONE, KEY_LEFT, NONE, KEY_RIGHT, NONE, KEY_END, KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, - NONE, NONE, NONE, NONE, - NONE, NONE, NONE, KEY_LEFTMETA, + NONE, NONE, NONE, KEY_F23, + KEY_F24,NONE, NONE, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_MENU, KEY_POWER, KEY_SLEEP, /* 0x60 - 0x7f. 0xE0 prefixed */ NONE, NONE, NONE, KEY_WAKEUP, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r360355 - head/sys/dev/ichiic
Author: wulf Date: Sun Apr 26 20:16:18 2020 New Revision: 360355 URL: https://svnweb.freebsd.org/changeset/base/360355 Log: ig4(4): Add PCI IDs for Intel Bay Trail I2C controllers. PR: 245654 Reported by: MFC after:1 week Modified: head/sys/dev/ichiic/ig4_pci.c Modified: head/sys/dev/ichiic/ig4_pci.c == --- head/sys/dev/ichiic/ig4_pci.c Sun Apr 26 20:08:57 2020 (r360354) +++ head/sys/dev/ichiic/ig4_pci.c Sun Apr 26 20:16:18 2020 (r360355) @@ -66,6 +66,13 @@ __FBSDID("$FreeBSD$"); static int ig4iic_pci_detach(device_t dev); +#define PCI_CHIP_BAYTRAIL_I2C_10x0f418086 +#define PCI_CHIP_BAYTRAIL_I2C_20x0f428086 +#define PCI_CHIP_BAYTRAIL_I2C_30x0f438086 +#define PCI_CHIP_BAYTRAIL_I2C_40x0f448086 +#define PCI_CHIP_BAYTRAIL_I2C_50x0f458086 +#define PCI_CHIP_BAYTRAIL_I2C_60x0f468086 +#define PCI_CHIP_BAYTRAIL_I2C_70x0f478086 #define PCI_CHIP_LYNXPT_LP_I2C_1 0x9c618086 #define PCI_CHIP_LYNXPT_LP_I2C_2 0x9c628086 #define PCI_CHIP_BRASWELL_I2C_10x22c18086 @@ -108,6 +115,13 @@ struct ig4iic_pci_device { }; static struct ig4iic_pci_device ig4iic_pci_devices[] = { + { PCI_CHIP_BAYTRAIL_I2C_1, "Intel BayTrail Serial I/O I2C Port 1", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_2, "Intel BayTrail Serial I/O I2C Port 2", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_3, "Intel BayTrail Serial I/O I2C Port 3", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_4, "Intel BayTrail Serial I/O I2C Port 4", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_5, "Intel BayTrail Serial I/O I2C Port 5", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_6, "Intel BayTrail Serial I/O I2C Port 6", IG4_ATOM}, + { PCI_CHIP_BAYTRAIL_I2C_7, "Intel BayTrail Serial I/O I2C Port 7", IG4_ATOM}, { PCI_CHIP_LYNXPT_LP_I2C_1, "Intel Lynx Point-LP I2C Controller-1", IG4_HASWELL}, { PCI_CHIP_LYNXPT_LP_I2C_2, "Intel Lynx Point-LP I2C Controller-2", IG4_HASWELL}, { PCI_CHIP_BRASWELL_I2C_1, "Intel Braswell Serial I/O I2C Port 1", IG4_ATOM}, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r360353 - head/sys/dev/atkbdc
Author: wulf Date: Sun Apr 26 20:06:08 2020 New Revision: 360353 URL: https://svnweb.freebsd.org/changeset/base/360353 Log: psm(4): Fix wrong key-release event occuring after trackpoint use. Some models of laptops e.g. "X1 Carbon 3rd Gen Thinkpad" have LRM buttons wired as so called "Synaptic touchpads extended buttons" rather thah real trackpoint buttons. Handle this case with merging of events from both sources. PR: 245877 Reported by: Raichoo MFC after:1 week Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sun Apr 26 19:43:27 2020(r360352) +++ head/sys/dev/atkbdc/psm.c Sun Apr 26 20:06:08 2020(r360353) @@ -3371,7 +3371,7 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, evdev_push_rel(sc->evdev_r, REL_X, *x); evdev_push_rel(sc->evdev_r, REL_Y, -*y); evdev_push_mouse_btn(sc->evdev_r, - guest_buttons); + guest_buttons | sc->extended_buttons); evdev_sync(sc->evdev_r); } #endif ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r360126 - head/sys/dev/evdev
On 20.04.2020 19:39, Justin Hibbits wrote: > But I'm curious, why not attach to sysmouse(4) and kbdmux(4)? What > breakage does that cause? I could maybe see not attaching to > sysmouse(4) by default, if the protocol isn't expressive enough, but > kbdmux(4) should be sufficient. > > - Justin kbdmux(4) is pretty good for standard 102-104-keys keyboards found at common desktops. But it does not work that good with some laptop ones. There are no "Flight mode on/off", "Touchpad on/off" e.t.c. events defined in AT-keyset but they exist in evdev-keyset. Unfortunately, we do not support keymap uploading in our drivers yet to make utilization of this advantage easy but IMO its better to switch to direct key-event reporting earlier rather than later. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r359905 - head/sys/dev/evdev
Author: wulf Date: Mon Apr 13 22:06:28 2020 New Revision: 359905 URL: https://svnweb.freebsd.org/changeset/base/359905 Log: [evdev] Use proper mutex reference in autorepeat callout initialization. This fixes panic occuring when evdev key autorepeat is enabled by driver which initializes evdev with external mutex. Modified: head/sys/dev/evdev/evdev.c Modified: head/sys/dev/evdev/evdev.c == --- head/sys/dev/evdev/evdev.c Mon Apr 13 21:23:39 2020(r359904) +++ head/sys/dev/evdev/evdev.c Mon Apr 13 22:06:28 2020(r359905) @@ -295,7 +295,7 @@ evdev_register_common(struct evdev_dev *evdev) if (evdev_event_supported(evdev, EV_REP) && bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT)) { /* Initialize callout */ - callout_init_mtx(&evdev->ev_rep_callout, &evdev->ev_mtx, 0); + callout_init_mtx(&evdev->ev_rep_callout, evdev->ev_lock, 0); if (evdev->ev_rep[REP_DELAY] == 0 && evdev->ev_rep[REP_PERIOD] == 0) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r359429 - head/sys/dev/evdev
Author: wulf Date: Sun Mar 29 23:01:36 2020 New Revision: 359429 URL: https://svnweb.freebsd.org/changeset/base/359429 Log: evdev: return error rather than zero-length data on blocked read() if blocked process has been woken up by evdev device destruction. MFC after:2 weeks Modified: head/sys/dev/evdev/cdev.c Modified: head/sys/dev/evdev/cdev.c == --- head/sys/dev/evdev/cdev.c Sun Mar 29 23:00:33 2020(r359428) +++ head/sys/dev/evdev/cdev.c Sun Mar 29 23:01:36 2020(r359429) @@ -217,6 +217,8 @@ evdev_read(struct cdev *dev, struct uio *uio, int iofl client->ec_blocked = true; ret = mtx_sleep(client, &client->ec_buffer_mtx, PCATCH, "evread", 0); + if (ret == 0 && client->ec_revoked) + ret = ENODEV; } } } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r359428 - head/sys/dev/evdev
Author: wulf Date: Sun Mar 29 23:00:33 2020 New Revision: 359428 URL: https://svnweb.freebsd.org/changeset/base/359428 Log: evdev: Add COMPAT_FREEBSD32 support for amd64 arch Incompatibility between i386 and amd64 evdev ABIs was caused by presence of 'struct timeval' in evdev protocol. Replace it with 'struct timeval32' for 32 bit binaries. Big-endian platforms may require additional work due to bitstr_t (array of unsigned longs) usage in ioctl interface. MFC after:2 weeks Modified: head/sys/dev/evdev/cdev.c Modified: head/sys/dev/evdev/cdev.c == --- head/sys/dev/evdev/cdev.c Sun Mar 29 20:03:46 2020(r359427) +++ head/sys/dev/evdev/cdev.c Sun Mar 29 23:00:33 2020(r359428) @@ -47,6 +47,18 @@ #include #include +#ifdef COMPAT_FREEBSD32 +#include +#include +#include +struct input_event32 { + struct timeval32time; + uint16_ttype; + uint16_tcode; + int32_t value; +}; +#endif + #ifdef EVDEV_DEBUG #definedebugf(client, fmt, args...)printf("evdev cdev: "fmt"\n", ##args) #else @@ -161,7 +173,14 @@ static int evdev_read(struct cdev *dev, struct uio *uio, int ioflag) { struct evdev_client *client; - struct input_event event; + union { + struct input_event t; +#ifdef COMPAT_FREEBSD32 + struct input_event32 t32; +#endif + } event; + struct input_event *head; + size_t evsize; int ret = 0; int remaining; @@ -175,11 +194,18 @@ evdev_read(struct cdev *dev, struct uio *uio, int iofl if (client->ec_revoked) return (ENODEV); +#ifdef COMPAT_FREEBSD32 + if (SV_CURPROC_FLAG(SV_ILP32)) + evsize = sizeof(struct input_event32); + else +#endif + evsize = sizeof(struct input_event); + /* Zero-sized reads are allowed for error checking */ - if (uio->uio_resid != 0 && uio->uio_resid < sizeof(struct input_event)) + if (uio->uio_resid != 0 && uio->uio_resid < evsize) return (EINVAL); - remaining = uio->uio_resid / sizeof(struct input_event); + remaining = uio->uio_resid / evsize; EVDEV_CLIENT_LOCKQ(client); @@ -196,14 +222,24 @@ evdev_read(struct cdev *dev, struct uio *uio, int iofl } while (ret == 0 && !EVDEV_CLIENT_EMPTYQ(client) && remaining > 0) { - memcpy(&event, &client->ec_buffer[client->ec_buffer_head], - sizeof(struct input_event)); + head = client->ec_buffer + client->ec_buffer_head; +#ifdef COMPAT_FREEBSD32 + if (SV_CURPROC_FLAG(SV_ILP32)) { + bzero(&event.t32, sizeof(struct input_event32)); + TV_CP(*head, event.t32, time); + CP(*head, event.t32, type); + CP(*head, event.t32, code); + CP(*head, event.t32, value); + } else +#endif + bcopy(head, &event.t, evsize); + client->ec_buffer_head = (client->ec_buffer_head + 1) % client->ec_buffer_size; remaining--; EVDEV_CLIENT_UNLOCKQ(client); - ret = uiomove(&event, sizeof(struct input_event), uio); + ret = uiomove(&event, evsize, uio); EVDEV_CLIENT_LOCKQ(client); } @@ -217,7 +253,13 @@ evdev_write(struct cdev *dev, struct uio *uio, int iof { struct evdev_dev *evdev = dev->si_drv1; struct evdev_client *client; - struct input_event event; + union { + struct input_event t; +#ifdef COMPAT_FREEBSD32 + struct input_event32 t32; +#endif + } event; + size_t evsize; int ret = 0; ret = devfs_get_cdevpriv((void **)&client); @@ -230,16 +272,30 @@ evdev_write(struct cdev *dev, struct uio *uio, int iof if (client->ec_revoked || evdev == NULL) return (ENODEV); - if (uio->uio_resid % sizeof(struct input_event) != 0) { +#ifdef COMPAT_FREEBSD32 + if (SV_CURPROC_FLAG(SV_ILP32)) + evsize = sizeof(struct input_event32); + else +#endif + evsize = sizeof(struct input_event); + + if (uio->uio_resid % evsize != 0) { debugf(client, "write size not multiple of input_event size"); return (EINVAL); } while (uio->uio_resid > 0 && ret == 0) { - ret = uiomove(&event, sizeof(struct input_event), uio); - if (ret == 0) - ret = evdev_inject_event(evdev, event.type, event.code, - event.value); + ret = uiomove(&event, evsize, uio); + if (ret == 0) { +#ifdef COMPAT_FREEBSD32 + if (SV_CURPROC_FLAG(SV_ILP32)) +
svn commit: r358895 - head/sys/dev/usb/input
Author: wulf Date: Wed Mar 11 20:05:49 2020 New Revision: 358895 URL: https://svnweb.freebsd.org/changeset/base/358895 Log: wmt(4): Reapply r358872 (by hselasky) modified to use maximal input report size instead of wMaxPacketSize. If the USB frame length is set to 1024 bytes, WMT_BSIZE, the EETI controller will pack multiple touch events in the packet and the current code will only process the first touch event. As a result some important events are lost like releasing the finger from the touchscreen. Use the maximal input report size as buffer size instead. PR: 244718 Tested by:Oskar Holmlund , wulf MFC after:3 days Discussed with: hselasky Modified: head/sys/dev/usb/input/wmt.c Modified: head/sys/dev/usb/input/wmt.c == --- head/sys/dev/usb/input/wmt.cWed Mar 11 20:05:06 2020 (r358894) +++ head/sys/dev/usb/input/wmt.cWed Mar 11 20:05:49 2020 (r358895) @@ -201,6 +201,7 @@ struct wmt_softc uint32_tcaps; uint32_tisize; uint32_tnconts_max; + uint32_treport_len; uint8_t report_id; struct hid_location cont_max_loc; @@ -492,10 +493,11 @@ wmt_intr_callback(struct usb_xfer *xfer, usb_error_t e DPRINTFN(6, "sc=%p actlen=%d\n", sc, len); - if (len >= (int)sc->isize || (len > 0 && sc->report_id != 0)) { + if (len >= (int)sc->report_len || + (len > 0 && sc->report_id != 0)) { /* Limit report length to the maximum */ - if (len > (int)sc->isize) - len = sc->isize; + if (len > (int)sc->report_len) + len = sc->report_len; usbd_copy_out(pc, 0, buf, len); @@ -504,8 +506,8 @@ wmt_intr_callback(struct usb_xfer *xfer, usb_error_t e goto tr_ignore; /* Make sure we don't process old data */ - if (len < sc->isize) - bzero(buf + len, sc->isize - len); + if (len < sc->report_len) + bzero(buf + len, sc->report_len - len); /* Strip leading "report ID" byte */ if (sc->report_id) { @@ -521,7 +523,7 @@ tr_ignore: case USB_ST_SETUP: tr_setup: - usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); + usbd_xfer_set_frame_len(xfer, 0, sc->isize); usbd_transfer_submit(xfer); break; default: @@ -807,7 +809,9 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, sc->ai[WMT_ORIENTATION].max = 1; } - sc->isize = wmt_hid_report_size(d_ptr, d_len, hid_input, report_id); + sc->isize = hid_report_size(d_ptr, d_len, hid_input, NULL); + sc->report_len = wmt_hid_report_size(d_ptr, d_len, hid_input, + report_id); sc->cont_max_rlen = wmt_hid_report_size(d_ptr, d_len, hid_feature, cont_max_rid); if (thqa_cert_rid > 0) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r358892 - head/sys/dev/usb/input
Author: wulf Date: Wed Mar 11 19:57:43 2020 New Revision: 358892 URL: https://svnweb.freebsd.org/changeset/base/358892 Log: wmt(4): revert r358872 (by hselasky) Limiting frame size to maximum packet size breaks devices which have input report size larger than wMaxPacketSize. Maximal input report size should be used instead. Revert the commit as it have not been MFC-ed yet. Discussed with: hselasky Modified: head/sys/dev/usb/input/wmt.c Modified: head/sys/dev/usb/input/wmt.c == --- head/sys/dev/usb/input/wmt.cWed Mar 11 18:15:18 2020 (r358891) +++ head/sys/dev/usb/input/wmt.cWed Mar 11 19:57:43 2020 (r358892) @@ -251,7 +251,7 @@ static const struct usb_config wmt_config[WMT_N_TRANSF .endpoint = UE_ADDR_ANY, .direction = UE_DIR_IN, .flags = { .pipe_bof = 1, .short_xfer_ok = 1 }, - .bufsize = 0, /* use wMaxPacketSize */ + .bufsize = WMT_BSIZE, .callback = &wmt_intr_callback, }, }; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r358824 - head/sys/dev/usb/input
Author: wulf Date: Mon Mar 9 21:01:22 2020 New Revision: 358824 URL: https://svnweb.freebsd.org/changeset/base/358824 Log: wmt(4): Fix Synaptics Touch Digitizer V04 attachment Touch Digitizer V04 report descriptor declares 'Contact Count Maximum' usage as constant. That was not supported by descriptor parser. PR: 232040 Reported by: Sergei Akhmatdinov MFC after:1 week Modified: head/sys/dev/usb/input/wmt.c Modified: head/sys/dev/usb/input/wmt.c == --- head/sys/dev/usb/input/wmt.cMon Mar 9 20:49:59 2020 (r358823) +++ head/sys/dev/usb/input/wmt.cMon Mar 9 21:01:22 2020 (r358824) @@ -655,9 +655,8 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, thqa_cert_rid = hi.report_ID; break; } - if (hi.collevel == 1 && touch_coll && - WMT_HI_ABSOLUTE(hi) && hi.usage == - HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACT_MAX)) { + if (hi.collevel == 1 && touch_coll && hi.usage == + HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACT_MAX)) { cont_count_max = hi.logical_maximum; cont_max_rid = hi.report_ID; if (sc != NULL) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r358820 - in head/sys: conf dev/ichiic dev/iicbus modules/i2c/iicbus
Author: wulf Date: Mon Mar 9 20:31:38 2020 New Revision: 358820 URL: https://svnweb.freebsd.org/changeset/base/358820 Log: iicbus(4): Add support for ACPI-based children enumeration When iicbus is attached as child of Designware I2C controller it scans all ACPI nodes for "I2C Serial Bus Connection Resource Descriptor" described in section 19.6.57 of ACPI specs. If such a descriptor is found, I2C child is added to iicbus, it's I2C address, IRQ resource and ACPI handle are added to ivars. Existing ACPI bus-hosted child is deleted afterwards. The driver also installs so called "I2C address space handler" which is disabled by default as nontested. Set hw.iicbus.enable_acpi_space_handler loader tunable to 1 to enable it. Reviewed by: markj MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D22901 Added: head/sys/dev/iicbus/acpi_iicbus.c (contents, props changed) Modified: head/sys/conf/files head/sys/dev/ichiic/ig4_iic.c head/sys/dev/iicbus/iicbus.c head/sys/dev/iicbus/iicbus.h head/sys/modules/i2c/iicbus/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Mon Mar 9 20:28:45 2020(r358819) +++ head/sys/conf/files Mon Mar 9 20:31:38 2020(r358820) @@ -1773,6 +1773,7 @@ dev/ichsmb/ichsmb_pci.c optional ichsmb pci dev/ida/ida.c optional ida dev/ida/ida_disk.c optional ida dev/ida/ida_pci.c optional ida pci +dev/iicbus/acpi_iicbus.c optional acpi iicbus dev/iicbus/ad7418.coptional ad7418 dev/iicbus/ads111x.c optional ads111x dev/iicbus/ds1307.coptional ds1307 Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Mon Mar 9 20:28:45 2020 (r358819) +++ head/sys/dev/ichiic/ig4_iic.c Mon Mar 9 20:31:38 2020 (r358820) @@ -1201,5 +1201,9 @@ ig4iic_dump(ig4iic_softc_t *sc) devclass_t ig4iic_devclass; DRIVER_MODULE(iicbus, ig4iic, iicbus_driver, iicbus_devclass, NULL, NULL); +#ifdef DEV_ACPI +DRIVER_MODULE(acpi_iicbus, ig4iic, acpi_iicbus_driver, iicbus_devclass, NULL, +NULL); +#endif MODULE_DEPEND(ig4iic, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); MODULE_VERSION(ig4iic, 1); Added: head/sys/dev/iicbus/acpi_iicbus.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/iicbus/acpi_iicbus.c Mon Mar 9 20:31:38 2020 (r358820) @@ -0,0 +1,789 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019-2020 Vladimir Kondratyev + * + * 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 AUTHOR 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 AUTHOR 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#defineACPI_IICBUS_LOCAL_BUFSIZE 32 /* Fits max SMBUS block size */ + +/* + * Make a copy of ACPI_RESOURCE_I2C_SERIALBUS type and replace "pointer to ACPI + * object name string" field with pointer to ACPI object itself. + * This saves us extra strdup()/free() pair on acpi_iicbus_get_i2cres call. + */ +typedefACPI_RESOURCE_I2C_SERIALBUS ACPI_IICBUS_RESOURCE_I2C_SERIALBUS; +#defineResourceSource_Handle ResourceSource.StringPtr + +/* Hooks for the ACPI CA debugging infrastructure. */ +#define_COMPONENT ACPI_BUS +ACPI_
svn commit: r358819 - head/sys/dev/acpica
Author: wulf Date: Mon Mar 9 20:28:45 2020 New Revision: 358819 URL: https://svnweb.freebsd.org/changeset/base/358819 Log: acpi: Export functions required by upcoming acpi_iicbus driver. Modified: head/sys/dev/acpica/acpi.c head/sys/dev/acpica/acpivar.h Modified: head/sys/dev/acpica/acpi.c == --- head/sys/dev/acpica/acpi.c Mon Mar 9 20:27:25 2020(r358818) +++ head/sys/dev/acpica/acpi.c Mon Mar 9 20:28:45 2020(r358819) @@ -150,7 +150,6 @@ static ACPI_STATUS acpi_device_scan_cb(ACPI_HANDLE h, void *context, void **retval); static ACPI_STATUS acpi_device_scan_children(device_t bus, device_t dev, int max_depth, acpi_scan_cb_t user_fn, void *arg); -static int acpi_set_powerstate(device_t child, int state); static int acpi_isa_pnp_probe(device_t bus, device_t child, struct isa_pnp_id *ids); static voidacpi_probe_children(device_t bus); @@ -162,7 +161,6 @@ static ACPI_STATUS acpi_sleep_disable(struct acpi_soft static ACPI_STATUS acpi_EnterSleepState(struct acpi_softc *sc, int state); static voidacpi_shutdown_final(void *arg, int howto); static voidacpi_enable_fixed_events(struct acpi_softc *sc); -static BOOLEAN acpi_has_hid(ACPI_HANDLE handle); static voidacpi_resync_clock(struct acpi_softc *sc); static int acpi_wake_sleep_prep(ACPI_HANDLE handle, int sstate); static int acpi_wake_run_prep(ACPI_HANDLE handle, int sstate); @@ -883,14 +881,12 @@ acpi_child_location_str_method(device_t cbdev, device_ } /* PnP information for devctl(8) */ -static int -acpi_child_pnpinfo_str_method(device_t cbdev, device_t child, char *buf, -size_t buflen) +int +acpi_pnpinfo_str(ACPI_HANDLE handle, char *buf, size_t buflen) { -struct acpi_device *dinfo = device_get_ivars(child); ACPI_DEVICE_INFO *adinfo; -if (ACPI_FAILURE(AcpiGetObjectInfo(dinfo->ad_handle, &adinfo))) { +if (ACPI_FAILURE(AcpiGetObjectInfo(handle, &adinfo))) { snprintf(buf, buflen, "unknown"); return (0); } @@ -908,6 +904,15 @@ acpi_child_pnpinfo_str_method(device_t cbdev, device_t return (0); } +static int +acpi_child_pnpinfo_str_method(device_t cbdev, device_t child, char *buf, +size_t buflen) +{ +struct acpi_device *dinfo = device_get_ivars(child); + +return (acpi_pnpinfo_str(dinfo->ad_handle, buf, buflen)); +} + /* * Handle device deletion. */ @@ -1840,7 +1845,7 @@ acpi_device_scan_children(device_t bus, device_t dev, * Even though ACPI devices are not PCI, we use the PCI approach for setting * device power states since it's close enough to ACPI. */ -static int +int acpi_set_powerstate(device_t child, int state) { ACPI_HANDLE h; @@ -2285,7 +2290,7 @@ acpi_BatteryIsPresent(device_t dev) /* * Returns true if a device has at least one valid device ID. */ -static BOOLEAN +BOOLEAN acpi_has_hid(ACPI_HANDLE h) { ACPI_DEVICE_INFO *devinfo; Modified: head/sys/dev/acpica/acpivar.h == --- head/sys/dev/acpica/acpivar.h Mon Mar 9 20:27:25 2020 (r358818) +++ head/sys/dev/acpica/acpivar.h Mon Mar 9 20:28:45 2020 (r358819) @@ -371,6 +371,7 @@ int acpi_bus_alloc_gas(device_t dev, int *type, int * u_int flags); void acpi_walk_subtables(void *first, void *end, acpi_subtable_handler *handler, void *arg); +BOOLEANacpi_has_hid(ACPI_HANDLE handle); intacpi_MatchHid(ACPI_HANDLE h, const char *hid); #define ACPI_MATCHHID_NOMATCH 0 #define ACPI_MATCHHID_HID 1 @@ -434,6 +435,7 @@ ACPI_STATUS acpi_pwr_wake_enable(ACPI_HANDLE consumer, ACPI_STATUSacpi_pwr_switch_consumer(ACPI_HANDLE consumer, int state); intacpi_device_pwr_for_sleep(device_t bus, device_t dev, int *dstate); +intacpi_set_powerstate(device_t child, int state); /* APM emulation */ void acpi_apm_init(struct acpi_softc *); @@ -468,6 +470,7 @@ int acpi_wakeup_machdep(struct acpi_softc *sc, int st int sleep_result, int intr_enabled); intacpi_table_quirks(int *quirks); intacpi_machdep_quirks(int *quirks); +intacpi_pnpinfo_str(ACPI_HANDLE handle, char *buf, size_t buflen); uint32_t hpet_get_uid(device_t dev); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r358818 - head/sys/dev/acpica
Author: wulf Date: Mon Mar 9 20:27:25 2020 New Revision: 358818 URL: https://svnweb.freebsd.org/changeset/base/358818 Log: acpi: Fix stalled value returned by acpi_get_device() after device deletion Newbus device reference attached to ACPI handle is not cleared when newbus device is deleted with devctl(8) delete command. Fix that with calling of AcpiDetachData() from "child_deleted" bus method like acpi_pci driver does. MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D22902 Modified: head/sys/dev/acpica/acpi.c Modified: head/sys/dev/acpica/acpi.c == --- head/sys/dev/acpica/acpi.c Mon Mar 9 19:55:13 2020(r358817) +++ head/sys/dev/acpica/acpi.c Mon Mar 9 20:27:25 2020(r358818) @@ -121,6 +121,7 @@ static device_t acpi_add_child(device_t bus, u_int ord static int acpi_print_child(device_t bus, device_t child); static voidacpi_probe_nomatch(device_t bus, device_t child); static voidacpi_driver_added(device_t dev, driver_t *driver); +static voidacpi_child_deleted(device_t dev, device_t child); static int acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result); static int acpi_write_ivar(device_t dev, device_t child, int index, @@ -199,6 +200,7 @@ static device_method_t acpi_methods[] = { DEVMETHOD(bus_print_child, acpi_print_child), DEVMETHOD(bus_probe_nomatch, acpi_probe_nomatch), DEVMETHOD(bus_driver_added,acpi_driver_added), +DEVMETHOD(bus_child_deleted, acpi_child_deleted), DEVMETHOD(bus_read_ivar, acpi_read_ivar), DEVMETHOD(bus_write_ivar, acpi_write_ivar), DEVMETHOD(bus_get_resource_list, acpi_get_rlist), @@ -907,6 +909,18 @@ acpi_child_pnpinfo_str_method(device_t cbdev, device_t } /* + * Handle device deletion. + */ +static void +acpi_child_deleted(device_t dev, device_t child) +{ +struct acpi_device *dinfo = device_get_ivars(child); + +if (acpi_get_device(dinfo->ad_handle) == child) + AcpiDetachData(dinfo->ad_handle, acpi_fake_objhandler); +} + +/* * Handle per-device ivars */ static int @@ -1791,10 +1805,8 @@ acpi_device_scan_cb(ACPI_HANDLE h, UINT32 level, void return (status); /* Remove the old child and its connection to the handle. */ -if (old_dev != NULL) { +if (old_dev != NULL) device_delete_child(device_get_parent(old_dev), old_dev); - AcpiDetachData(h, acpi_fake_objhandler); -} /* Recreate the handle association if the user created a device. */ if (dev != NULL) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r355596 - head/sys/dev/ichiic
Author: wulf Date: Tue Dec 10 20:23:05 2019 New Revision: 355596 URL: https://svnweb.freebsd.org/changeset/base/355596 Log: [ig4] Remove unused methods from bus interface bus_get/set_resource methods are implemented in child device (iicbus). As their implementation with bus_generic_rl_get/set calls do not recurse up the tree, the versions in ig4 are never called. Suggested by: jhb Modified: head/sys/dev/ichiic/ig4_acpi.c head/sys/dev/ichiic/ig4_pci.c Modified: head/sys/dev/ichiic/ig4_acpi.c == --- head/sys/dev/ichiic/ig4_acpi.c Tue Dec 10 20:12:21 2019 (r355595) +++ head/sys/dev/ichiic/ig4_acpi.c Tue Dec 10 20:23:05 2019 (r355596) @@ -177,8 +177,6 @@ static device_method_t ig4iic_acpi_methods[] = { DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), - DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), /* iicbus interface */ DEVMETHOD(iicbus_transfer, ig4iic_transfer), Modified: head/sys/dev/ichiic/ig4_pci.c == --- head/sys/dev/ichiic/ig4_pci.c Tue Dec 10 20:12:21 2019 (r355595) +++ head/sys/dev/ichiic/ig4_pci.c Tue Dec 10 20:23:05 2019 (r355596) @@ -258,8 +258,6 @@ static device_method_t ig4iic_pci_methods[] = { DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), - DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), /* iicbus interface */ DEVMETHOD(iicbus_transfer, ig4iic_transfer), ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r355068 - head/sys/compat/linux
Author: wulf Date: Sun Nov 24 20:51:09 2019 New Revision: 355068 URL: https://svnweb.freebsd.org/changeset/base/355068 Log: Linux epoll: Allow passing of any negative timeout value to epoll_wait Linux epoll allow passing of any negative timeout value to epoll_wait() to cause unbound blocking Reviewed by: emaste MFC after:1 week Differential Revision:https://reviews.freebsd.org/D22517 Modified: head/sys/compat/linux/linux_event.c Modified: head/sys/compat/linux/linux_event.c == --- head/sys/compat/linux/linux_event.c Sun Nov 24 20:47:40 2019 (r355067) +++ head/sys/compat/linux/linux_event.c Sun Nov 24 20:51:09 2019 (r355068) @@ -557,13 +557,13 @@ linux_epoll_wait_common(struct thread *td, int epfd, s return (error); if (epfp->f_type != DTYPE_KQUEUE) { error = EINVAL; - goto leave1; + goto leave; } if (uset != NULL) { error = kern_sigprocmask(td, SIG_SETMASK, uset, &omask, 0); if (error != 0) - goto leave1; + goto leave; td->td_pflags |= TDP_OLDMASK; /* * Make sure that ast() is called on return to @@ -581,11 +581,12 @@ linux_epoll_wait_common(struct thread *td, int epfd, s coargs.count = 0; coargs.error = 0; - if (timeout != -1) { - if (timeout < 0) { - error = EINVAL; - goto leave0; - } + /* +* Linux epoll_wait(2) man page states that timeout of -1 causes caller +* to block indefinitely. Real implementation does it if any negative +* timeout value is passed. +*/ + if (timeout >= 0) { /* Convert from milliseconds to timespec. */ ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 100; @@ -605,11 +606,10 @@ linux_epoll_wait_common(struct thread *td, int epfd, s if (error == 0) td->td_retval[0] = coargs.count; -leave0: if (uset != NULL) error = kern_sigprocmask(td, SIG_SETMASK, &omask, NULL, 0); -leave1: +leave: fdrop(epfp, td); return (error); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r355067 - head/sys/compat/linux
Author: wulf Date: Sun Nov 24 20:47:40 2019 New Revision: 355067 URL: https://svnweb.freebsd.org/changeset/base/355067 Log: Linux epoll: Register events with zero event mask Such an events are legal and should be interpreted as EPOLLERR | EPOLLHUP. Register a disabled kqueue event in that case as we do not support EPOLLHUP yet. Required by Linux Steam client. PR: 240590 Reported by: Alex S Reviewed by: emaste MFC after:1 week Differential Revision:https://reviews.freebsd.org/D22516 Modified: head/sys/compat/linux/linux_event.c head/sys/compat/linux/linux_event.h Modified: head/sys/compat/linux/linux_event.c == --- head/sys/compat/linux/linux_event.c Sun Nov 24 20:44:14 2019 (r355066) +++ head/sys/compat/linux/linux_event.c Sun Nov 24 20:47:40 2019 (r355067) @@ -325,6 +325,11 @@ epoll_to_kevent(struct thread *td, int fd, struct epol EV_SET(kevent++, fd, EVFILT_WRITE, kev_flags, 0, 0, 0); ++(*nkevents); } + /* zero event mask is legal */ + if ((levents & (LINUX_EPOLL_EVRD | LINUX_EPOLL_EVWR)) == 0) { + EV_SET(kevent++, fd, EVFILT_READ, EV_ADD|EV_DISABLE, 0, 0, 0); + ++(*nkevents); + } if ((levents & ~(LINUX_EPOLL_EVSUP)) != 0) { p = td->td_proc; Modified: head/sys/compat/linux/linux_event.h == --- head/sys/compat/linux/linux_event.h Sun Nov 24 20:44:14 2019 (r355066) +++ head/sys/compat/linux/linux_event.h Sun Nov 24 20:47:40 2019 (r355067) @@ -45,10 +45,10 @@ #defineLINUX_EPOLLONESHOT 1u<<30 #defineLINUX_EPOLLET 1u<<31 -#defineLINUX_EPOLL_EVRD(LINUX_EPOLLIN|LINUX_EPOLLRDNORM \ - |LINUX_EPOLLHUP|LINUX_EPOLLERR|LINUX_EPOLLPRI) +#defineLINUX_EPOLL_EVRD(LINUX_EPOLLIN|LINUX_EPOLLRDNORM) #defineLINUX_EPOLL_EVWR(LINUX_EPOLLOUT|LINUX_EPOLLWRNORM) #defineLINUX_EPOLL_EVSUP (LINUX_EPOLLET|LINUX_EPOLLONESHOT \ + |LINUX_EPOLLHUP|LINUX_EPOLLERR|LINUX_EPOLLPRI \ |LINUX_EPOLL_EVRD|LINUX_EPOLL_EVWR|LINUX_EPOLLRDHUP) #defineLINUX_EPOLL_CTL_ADD 1 ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r355066 - head/sys/compat/linux
Author: wulf Date: Sun Nov 24 20:44:14 2019 New Revision: 355066 URL: https://svnweb.freebsd.org/changeset/base/355066 Log: Linux epoll: Check both read and write kqueue events existence in EPOLL_CTL_ADD Linux epoll EPOLL_CTL_ADD op handler should always check registration of both EVFILT_READ and EVFILT_WRITE kevents to deceide if supplied file descriptor fd is already registered with epoll instance. Reviewed by: emaste MFC after:1 week Differential Revision:https://reviews.freebsd.org/D22515 Modified: head/sys/compat/linux/linux_event.c Modified: head/sys/compat/linux/linux_event.c == --- head/sys/compat/linux/linux_event.c Sun Nov 24 20:41:47 2019 (r355065) +++ head/sys/compat/linux/linux_event.c Sun Nov 24 20:44:14 2019 (r355066) @@ -98,14 +98,16 @@ __attribute__((packed)) #defineLINUX_MAX_EVENTS(INT_MAX / sizeof(struct epoll_event)) static voidepoll_fd_install(struct thread *td, int fd, epoll_udata_t udata); -static int epoll_to_kevent(struct thread *td, struct file *epfp, - int fd, struct epoll_event *l_event, int *kev_flags, - struct kevent *kevent, int *nkevents); +static int epoll_to_kevent(struct thread *td, int fd, + struct epoll_event *l_event, struct kevent *kevent, + int *nkevents); static voidkevent_to_epoll(struct kevent *kevent, struct epoll_event *l_event); static int epoll_kev_copyout(void *arg, struct kevent *kevp, int count); static int epoll_kev_copyin(void *arg, struct kevent *kevp, int count); -static int epoll_delete_event(struct thread *td, struct file *epfp, - int fd, int filter); +static int epoll_register_kevent(struct thread *td, struct file *epfp, + int fd, int filter, unsigned int flags); +static int epoll_fd_registered(struct thread *td, struct file *epfp, + int fd); static int epoll_delete_all_events(struct thread *td, struct file *epfp, int fd); @@ -296,31 +298,31 @@ linux_epoll_create1(struct thread *td, struct linux_ep /* Structure converting function from epoll to kevent. */ static int -epoll_to_kevent(struct thread *td, struct file *epfp, -int fd, struct epoll_event *l_event, int *kev_flags, +epoll_to_kevent(struct thread *td, int fd, struct epoll_event *l_event, struct kevent *kevent, int *nkevents) { uint32_t levents = l_event->events; struct linux_pemuldata *pem; struct proc *p; + unsigned short kev_flags = EV_ADD | EV_ENABLE; /* flags related to how event is registered */ if ((levents & LINUX_EPOLLONESHOT) != 0) - *kev_flags |= EV_DISPATCH; + kev_flags |= EV_DISPATCH; if ((levents & LINUX_EPOLLET) != 0) - *kev_flags |= EV_CLEAR; + kev_flags |= EV_CLEAR; if ((levents & LINUX_EPOLLERR) != 0) - *kev_flags |= EV_ERROR; + kev_flags |= EV_ERROR; if ((levents & LINUX_EPOLLRDHUP) != 0) - *kev_flags |= EV_EOF; + kev_flags |= EV_EOF; /* flags related to what event is registered */ if ((levents & LINUX_EPOLL_EVRD) != 0) { - EV_SET(kevent++, fd, EVFILT_READ, *kev_flags, 0, 0, 0); + EV_SET(kevent++, fd, EVFILT_READ, kev_flags, 0, 0, 0); ++(*nkevents); } if ((levents & LINUX_EPOLL_EVWR) != 0) { - EV_SET(kevent++, fd, EVFILT_WRITE, *kev_flags, 0, 0, 0); + EV_SET(kevent++, fd, EVFILT_WRITE, kev_flags, 0, 0, 0); ++(*nkevents); } @@ -451,7 +453,6 @@ linux_epoll_ctl(struct thread *td, struct linux_epoll_ epoll_kev_copyin}; struct epoll_event le; cap_rights_t rights; - int kev_flags; int nchanges = 0; int error; @@ -484,9 +485,7 @@ linux_epoll_ctl(struct thread *td, struct linux_epoll_ ciargs.changelist = kev; if (args->op != LINUX_EPOLL_CTL_DEL) { - kev_flags = EV_ADD | EV_ENABLE; - error = epoll_to_kevent(td, epfp, args->fd, &le, - &kev_flags, kev, &nchanges); + error = epoll_to_kevent(td, args->fd, &le, kev, &nchanges); if (error != 0) goto leave0; } @@ -499,19 +498,10 @@ linux_epoll_ctl(struct thread *td, struct linux_epoll_ break; case LINUX_EPOLL_CTL_ADD: - /* -* kqueue_register() return ENOENT if event does not exists -* and the EV_ADD flag is not set. Reset EV_ENABLE flag to -* avoid accidental activation of fired oneshot events. -*/ - kev[0].flags &= ~(EV_ADD | EV_ENABLE); - error =
svn commit: r355065 - head/sys/compat/linux
Author: wulf Date: Sun Nov 24 20:41:47 2019 New Revision: 355065 URL: https://svnweb.freebsd.org/changeset/base/355065 Log: Linux epoll: Don't deregister file descriptor after EPOLLONESHOT is fired Linux epoll does not remove descriptor after one-shot event has been triggered. Set EV_DISPATCH kqueue flag rather then EV_ONESHOT to get the same behavior. Required by Linux Steam client. PR: 240590 Reported by: Alex S Reviewed by: emaste, imp MFC after:1 week Differential Revision:https://reviews.freebsd.org/D22513 Modified: head/sys/compat/linux/linux_event.c Modified: head/sys/compat/linux/linux_event.c == --- head/sys/compat/linux/linux_event.c Sun Nov 24 19:18:12 2019 (r355064) +++ head/sys/compat/linux/linux_event.c Sun Nov 24 20:41:47 2019 (r355065) @@ -306,7 +306,7 @@ epoll_to_kevent(struct thread *td, struct file *epfp, /* flags related to how event is registered */ if ((levents & LINUX_EPOLLONESHOT) != 0) - *kev_flags |= EV_ONESHOT; + *kev_flags |= EV_DISPATCH; if ((levents & LINUX_EPOLLET) != 0) *kev_flags |= EV_CLEAR; if ((levents & LINUX_EPOLLERR) != 0) @@ -501,16 +501,17 @@ linux_epoll_ctl(struct thread *td, struct linux_epoll_ case LINUX_EPOLL_CTL_ADD: /* * kqueue_register() return ENOENT if event does not exists -* and the EV_ADD flag is not set. +* and the EV_ADD flag is not set. Reset EV_ENABLE flag to +* avoid accidental activation of fired oneshot events. */ - kev[0].flags &= ~EV_ADD; + kev[0].flags &= ~(EV_ADD | EV_ENABLE); error = kqfd_register(args->epfd, &kev[0], td, M_WAITOK); if (error != ENOENT) { error = EEXIST; goto leave0; } error = 0; - kev[0].flags |= EV_ADD; + kev[0].flags |= (EV_ADD | EV_ENABLE); break; case LINUX_EPOLL_CTL_DEL: ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354327 - head/sys/dev/ichiic
Author: wulf Date: Mon Nov 4 02:29:58 2019 New Revision: 354327 URL: https://svnweb.freebsd.org/changeset/base/354327 Log: [ig4] Try to workaround MIPS namespace pollution issue Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Mon Nov 4 00:35:40 2019 (r354326) +++ head/sys/dev/ichiic/ig4_iic.c Mon Nov 4 02:29:58 2019 (r354327) @@ -161,7 +161,7 @@ reg_read(ig4iic_softc_t *sc, uint32_t reg) } static void -set_intr_mask(ig4iic_softc_t *sc, uint32_t val) +ig4iic_set_intr_mask(ig4iic_softc_t *sc, uint32_t val) { if (sc->intr_mask != val) { reg_write(sc, IG4_REG_INTR_MASK, val); @@ -233,7 +233,7 @@ set_controller(ig4iic_softc_t *sc, uint32_t ctl) * When the controller is enabled, interrupt on STOP detect * or receive character ready and clear pending interrupts. */ - set_intr_mask(sc, 0); + ig4iic_set_intr_mask(sc, 0); if (ctl & IG4_I2C_ENABLE) reg_read(sc, IG4_REG_CLR_INTR); @@ -298,10 +298,10 @@ wait_intr(ig4iic_softc_t *sc, uint32_t intr) */ if (!DO_POLL(sc)) { mtx_lock_spin(&sc->io_lock); - set_intr_mask(sc, intr | IG4_INTR_ERR_MASK); + ig4iic_set_intr_mask(sc, intr | IG4_INTR_ERR_MASK); msleep_spin(sc, &sc->io_lock, "i2cwait", (hz + 99) / 100); /* sleep up to 10ms */ - set_intr_mask(sc, 0); + ig4iic_set_intr_mask(sc, 0); mtx_unlock_spin(&sc->io_lock); count_us += 1; } else { @@ -1137,7 +1137,7 @@ ig4iic_intr(void *cookie) /* Ignore stray interrupts */ if (sc->intr_mask != 0 && reg_read(sc, IG4_REG_INTR_STAT) != 0) { /* Interrupt bits are cleared in wait_intr() loop */ - set_intr_mask(sc, 0); + ig4iic_set_intr_mask(sc, 0); wakeup(sc); retval = FILTER_HANDLED; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r354322 - head/sys/dev/ichiic
On 04.11.2019 01:02, Konstantin Belousov wrote: > On Sun, Nov 03, 2019 at 09:17:51PM +0000, Vladimir Kondratyev wrote: >> Author: wulf >> Date: Sun Nov 3 21:17:50 2019 >> New Revision: 354322 >> URL: https://svnweb.freebsd.org/changeset/base/354322 >> >> Log: >> [ig4] Convert ithread interrupt handler to filter based one. > And why ? > > You need some reason to use filters/spinlocks, otherwise it only > taxes system latency. The only thing ig4 interrupt handler does is a waking up the user thread, so postponing it to ithread looks like a wasting of CPU cycles. Spinlock here is acting as condition variable not as a data protection lock. It is taken around msleep(). I can replace it with cv_* calls if current usage confuses someone Ig4 access is serialized with sx lock so it is impossible to get any congestion on spinlock ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354317 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:12:59 2019 New Revision: 354317 URL: https://svnweb.freebsd.org/changeset/base/354317 Log: [ig4] wait for bus stop condition after stop command issued It gives better error detection and ig4 driver's lock coverage in a pipelined write case Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:10:47 2019 (r354316) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:12:59 2019 (r354317) @@ -362,7 +362,8 @@ ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave, if (!repeated_start) { /* -* Clear any previous TX/RX FIFOs overflow/underflow bits. +* Clear any previous TX/RX FIFOs overflow/underflow bits +* and I2C bus STOP condition. */ reg_read(sc, IG4_REG_CLR_INTR); } @@ -613,6 +614,13 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui else error = ig4iic_write(sc, msgs[i].buf, msgs[i].len, rpstart, stop); + + /* Wait for error or stop condition occurred on the I2C bus */ + if (stop && error == 0) { + error = wait_intr(sc, IG4_INTR_STOP_DET); + if (error == 0) + reg_read(sc, IG4_REG_CLR_INTR); + } if (error != 0) { /* ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354309 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:01:53 2019 New Revision: 354309 URL: https://svnweb.freebsd.org/changeset/base/354309 Log: [ig4] Remove dead code inherited from DragonflyBSD Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:00:55 2019 (r354308) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:01:53 2019 (r354309) @@ -68,18 +68,12 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include #include #include #include #include -#define TRANS_NORMAL 1 -#define TRANS_PCALL2 -#define TRANS_BLOCK3 - #define DO_POLL(sc)(cold || kdb_active || SCHEDULER_STOPPED() || sc->poll) /* @@ -290,21 +284,7 @@ set_slave_addr(ig4iic_softc_t *sc, uint8_t slave) /* * Wait for TXFIFO to drain before disabling the controller. -* -* If a write message has not been completed it's really a -* programming error, but for now in that case issue an extra -* byte + STOP. -* -* If a read message has not been completed it's also a programming -* error, for now just ignore it. */ - wait_status(sc, IG4_STATUS_TX_NOTFULL); - if (sc->write_started) { - reg_write(sc, IG4_REG_DATA_CMD, IG4_DATA_STOP); - sc->write_started = 0; - } - if (sc->read_started) - sc->read_started = 0; wait_status(sc, IG4_STATUS_TX_EMPTY); set_controller(sc, 0); Modified: head/sys/dev/ichiic/ig4_var.h == --- head/sys/dev/ichiic/ig4_var.h Sun Nov 3 21:00:55 2019 (r354308) +++ head/sys/dev/ichiic/ig4_var.h Sun Nov 3 21:01:53 2019 (r354309) @@ -43,7 +43,6 @@ #include "pci_if.h" #include "iicbus_if.h" -enum ig4_op { IG4_IDLE, IG4_READ, IG4_WRITE }; enum ig4_vers { IG4_HASWELL, IG4_ATOM, IG4_SKYLAKE, IG4_APL }; struct ig4_hw { @@ -78,17 +77,12 @@ struct ig4iic_softc { void*intr_handle; int intr_type; enum ig4_vers version; - enum ig4_op op; struct ig4_cfg cfg; - int cmd; uint32_tintr_mask; - int error; uint8_t last_slave; int platform_attached : 1; int use_10bit : 1; int slave_valid : 1; - int read_started : 1; - int write_started : 1; int poll: 1; /* ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354298 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:47:49 2019 New Revision: 354298 URL: https://svnweb.freebsd.org/changeset/base/354298 Log: [ig4] We actually need to set the Rx threshold register one smaller. Setting the IG4_REG_RX_TL register to 1 was actually generating an interrupt after 2 bytes were available in the Rx fifo. We need to set the register to 0 to get an interrupt for 1 byte already. Obtained from:DragonflyBSD (02f0bf2) Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:46:20 2019 (r354297) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:47:49 2019 (r354298) @@ -567,7 +567,7 @@ ig4iic_attach(ig4iic_softc_t *sc) * * See ig4_var.h for details on interrupt handler synchronization. */ - reg_write(sc, IG4_REG_RX_TL, 1); + reg_write(sc, IG4_REG_RX_TL, 0); reg_write(sc, IG4_REG_CTL, IG4_CTL_MASTER | ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354294 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:43:02 2019 New Revision: 354294 URL: https://svnweb.freebsd.org/changeset/base/354294 Log: [ig4] Drop driver's internal RX FIFO There is no need to read all controller's RX FIFO data to clear RX_FULL bit in interrupt handler as interrupts are masked permanently since previous commit. Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:42:04 2019 (r354293) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:43:02 2019 (r354294) @@ -168,17 +168,6 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) } /* -* When waiting for receive data break-out if the interrupt -* loaded data into the FIFO. -*/ - if (status & IG4_STATUS_RX_NOTEMPTY) { - if (sc->rpos != sc->rnext) { - error = 0; - break; - } - } - - /* * When waiting for the transmit FIFO to become empty, * reset the timeout if we see a change in the transmit * FIFO level as progress is being made. @@ -217,25 +206,6 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) } /* - * Read I2C data. The data might have already been read by - * the interrupt code, otherwise it is sitting in the data - * register. - */ -static uint8_t -data_read(ig4iic_softc_t *sc) -{ - uint8_t c; - - if (sc->rpos == sc->rnext) { - c = (uint8_t)reg_read(sc, IG4_REG_DATA_CMD); - } else { - c = sc->rbuf[sc->rpos & IG4_RBUFMASK]; - ++sc->rpos; - } - return (c); -} - -/* * Set the slave address. The controller must be disabled when * changing the address. * @@ -334,7 +304,7 @@ ig4iic_read(ig4iic_softc_t *sc, uint8_t *buf, uint16_t error = wait_status(sc, IG4_STATUS_RX_NOTEMPTY); if (error) break; - buf[i] = data_read(sc); + buf[i] = (uint8_t)reg_read(sc, IG4_REG_DATA_CMD); } (void)reg_read(sc, IG4_REG_TX_ABRT_SOURCE); @@ -455,16 +425,6 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui */ reg_read(sc, IG4_REG_CLR_TX_ABORT); - /* -* Clean out any previously received data. -*/ - if (sc->rpos != sc->rnext && bootverbose) { - device_printf(sc->dev, "discarding %d bytes of spurious data\n", - sc->rnext - sc->rpos); - } - sc->rpos = 0; - sc->rnext = 0; - rpstart = false; error = 0; for (i = 0; i < nmsgs; i++) { @@ -734,19 +694,10 @@ static void ig4iic_intr(void *cookie) { ig4iic_softc_t *sc = cookie; - uint32_t status; mtx_lock(&sc->io_lock); set_intr_mask(sc, 0); reg_read(sc, IG4_REG_CLR_INTR); - status = reg_read(sc, IG4_REG_I2C_STA); - while (status & IG4_STATUS_RX_NOTEMPTY) { - sc->rbuf[sc->rnext & IG4_RBUFMASK] = - (uint8_t)reg_read(sc, IG4_REG_DATA_CMD); - ++sc->rnext; - status = reg_read(sc, IG4_REG_I2C_STA); - } - wakeup(sc); mtx_unlock(&sc->io_lock); } Modified: head/sys/dev/ichiic/ig4_var.h == --- head/sys/dev/ichiic/ig4_var.h Sun Nov 3 20:42:04 2019 (r354293) +++ head/sys/dev/ichiic/ig4_var.h Sun Nov 3 20:43:02 2019 (r354294) @@ -43,9 +43,6 @@ #include "pci_if.h" #include "iicbus_if.h" -#define IG4_RBUFSIZE 128 -#define IG4_RBUFMASK (IG4_RBUFSIZE - 1) - enum ig4_op { IG4_IDLE, IG4_READ, IG4_WRITE }; enum ig4_vers { IG4_HASWELL, IG4_ATOM, IG4_SKYLAKE, IG4_APL }; @@ -62,9 +59,6 @@ struct ig4iic_softc { enum ig4_vers version; enum ig4_op op; int cmd; - int rnext; - int rpos; - charrbuf[IG4_RBUFSIZE]; uint32_tintr_mask; int error; uint8_t last_slave; @@ -81,19 +75,6 @@ struct ig4iic_softc { * with the controller acquire an exclusive lock on call_lock * to prevent interleaving of calls to the interface and a lock on * io_lock right afterwards, to synchronize controller I/O activity. -* -* The interrupt handler can only read data while no iicbus call -* is in progress or while io_lock is dropped during mtx_sleep in -* wait_status and set_controller. It is safe to drop io_lock in those -* places, because the interrupt handler only accesses those registers: -* -* - IG4_REG_I2C_ST
svn commit: r354318 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:14:08 2019 New Revision: 354318 URL: https://svnweb.freebsd.org/changeset/base/354318 Log: [ig4] Minor improvement of write pipelining With leaving some data queued in the TX FIFO at the end of write cycle. Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:12:59 2019 (r354317) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:14:08 2019 (r354318) @@ -471,6 +471,7 @@ ig4iic_write(ig4iic_softc_t *sc, uint8_t *buf, uint16_ int sent = 0; int burst, target; int error; + bool lowat_set = false; if (len == 0) return (0); @@ -479,6 +480,11 @@ ig4iic_write(ig4iic_softc_t *sc, uint8_t *buf, uint16_ burst = sc->cfg.txfifo_depth - (reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK); target = MIN(sent + burst, (int)len); + /* Leave some data queued to maintain the hardware pipeline */ + if (!lowat_set && target != len) { + lowat_set = true; + reg_write(sc, IG4_REG_TX_TL, IG4_FIFO_LOWAT); + } while(sent < target) { cmd = buf[sent]; if (repeated_start && sent == 0) @@ -494,6 +500,8 @@ ig4iic_write(ig4iic_softc_t *sc, uint8_t *buf, uint16_ break; } } + if (lowat_set) + reg_write(sc, IG4_REG_TX_TL, 0); return (error); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354315 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:08:26 2019 New Revision: 354315 URL: https://svnweb.freebsd.org/changeset/base/354315 Log: [ig4] Set STOP condition and flush TX/RX FIFOs on error if controller has not it done for us yet. Reset controller when transfer abort is failed. Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_reg.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:07:12 2019 (r354314) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:08:26 2019 (r354315) @@ -117,6 +117,7 @@ static const struct ig4_hw ig4iic_hw[] = { }, }; +static int ig4iic_set_config(ig4iic_softc_t *sc, bool reset); static void ig4iic_intr(void *cookie); static void ig4iic_dump(ig4iic_softc_t *sc); @@ -272,7 +273,7 @@ wait_intr(ig4iic_softc_t *sc, uint32_t intr) * reset the timeout if we see a change in the transmit * FIFO level as progress is being made. */ - if (intr & IG4_INTR_TX_EMPTY) { + if (intr & (IG4_INTR_TX_EMPTY | IG4_INTR_STOP_DET)) { v = reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK; if (txlvl != v) { txlvl = v; @@ -369,6 +370,34 @@ ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave, return (0); } +static bool +ig4iic_xfer_is_started(ig4iic_softc_t *sc) +{ + /* +* It requires that no IG4_REG_CLR_INTR or IG4_REG_CLR_START/STOP_DET +* register reads is issued after START condition. +*/ + return ((reg_read(sc, IG4_REG_RAW_INTR_STAT) & + (IG4_INTR_START_DET | IG4_INTR_STOP_DET)) == IG4_INTR_START_DET); +} + +static int +ig4iic_xfer_abort(ig4iic_softc_t *sc) +{ + int error; + + /* Request send of STOP condition and flush of TX FIFO */ + set_controller(sc, IG4_I2C_ABORT | IG4_I2C_ENABLE); + /* +* Wait for the TX_ABRT interrupt with ABRTSRC_TRANSFER +* bit set in TX_ABRT_SOURCE register. +*/ + error = wait_intr(sc, IG4_INTR_STOP_DET); + set_controller(sc, IG4_I2C_ENABLE); + + return (error == IIC_ESTATUS ? 0 : error); +} + /* * Amount of unread data before next burst to get better I2C bus utilization. * 2 bytes is enough in FAST mode. 8 bytes is better in FAST+ and HIGH modes. @@ -584,8 +613,27 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui else error = ig4iic_write(sc, msgs[i].buf, msgs[i].len, rpstart, stop); - if (error != 0) + + if (error != 0) { + /* +* Send STOP condition if it's not done yet and flush +* both FIFOs. Do a controller soft reset if transfer +* abort is failed. +*/ + if (ig4iic_xfer_is_started(sc) && + ig4iic_xfer_abort(sc) != 0) { + device_printf(sc->dev, "Failed to abort " + "transfer. Do the controller reset.\n"); + ig4iic_set_config(sc, true); + } else { + while (reg_read(sc, IG4_REG_I2C_STA) & + IG4_STATUS_RX_NOTEMPTY) + reg_read(sc, IG4_REG_DATA_CMD); + reg_read(sc, IG4_REG_TX_ABRT_SOURCE); + reg_read(sc, IG4_REG_CLR_INTR); + } break; + } rpstart = !stop; } @@ -843,7 +891,7 @@ ig4iic_get_config(ig4iic_softc_t *sc) } static int -ig4iic_set_config(ig4iic_softc_t *sc) +ig4iic_set_config(ig4iic_softc_t *sc, bool reset) { uint32_t v; @@ -851,10 +899,16 @@ ig4iic_set_config(ig4iic_softc_t *sc) if (sc->version == IG4_SKYLAKE && (v & IG4_RESTORE_REQUIRED) ) { reg_write(sc, IG4_REG_DEVIDLE_CTRL, IG4_DEVICE_IDLE | IG4_RESTORE_REQUIRED); reg_write(sc, IG4_REG_DEVIDLE_CTRL, 0); + pause("i2crst", 1); + reset = true; + } + if ((sc->version == IG4_HASWELL || sc->version == IG4_ATOM) && reset) { + reg_write(sc, IG4_REG_RESETS_HSW, IG4_RESETS_ASSERT_HSW); + reg_write(sc, IG4_REG_RESETS_HSW, IG4_RESETS_DEASSERT_HSW); + } else if (sc->version == IG4_SKYLAKE && reset) { reg_write(sc, IG4_REG_RESETS_SKL, IG4_RESETS_ASSERT_SKL); reg_write(sc, IG4_REG_RESETS_SKL, IG4_RESETS_DEASSERT_SKL); - DELAY(1000); } if (sc->version == IG4_ATOM) @@ -922,6 +976,9 @@ ig4iic_set_config(ig4iic_softc_t *sc) IG4_CTL_RESTARTEN |
svn commit: r354322 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:17:50 2019 New Revision: 354322 URL: https://svnweb.freebsd.org/changeset/base/354322 Log: [ig4] Convert ithread interrupt handler to filter based one. Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:17:01 2019 (r354321) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:17:50 2019 (r354322) @@ -122,7 +122,7 @@ static const struct ig4_hw ig4iic_hw[] = { }; static int ig4iic_set_config(ig4iic_softc_t *sc, bool reset); -static void ig4iic_intr(void *cookie); +static driver_filter_t ig4iic_intr; static void ig4iic_dump(ig4iic_softc_t *sc); static int ig4_dump; @@ -297,12 +297,12 @@ wait_intr(ig4iic_softc_t *sc, uint32_t intr) * When polling is not requested let the interrupt do its work. */ if (!DO_POLL(sc)) { - mtx_lock(&sc->io_lock); + mtx_lock_spin(&sc->io_lock); set_intr_mask(sc, intr | IG4_INTR_ERR_MASK); - mtx_sleep(sc, &sc->io_lock, 0, "i2cwait", + msleep_spin(sc, &sc->io_lock, "i2cwait", (hz + 99) / 100); /* sleep up to 10ms */ set_intr_mask(sc, 0); - mtx_unlock(&sc->io_lock); + mtx_unlock_spin(&sc->io_lock); count_us += 1; } else { DELAY(25); @@ -1010,7 +1010,7 @@ ig4iic_attach(ig4iic_softc_t *sc) { int error; - mtx_init(&sc->io_lock, "IG4 I/O lock", NULL, MTX_DEF); + mtx_init(&sc->io_lock, "IG4 I/O lock", NULL, MTX_SPIN); sx_init(&sc->call_lock, "IG4 call lock"); ig4iic_get_config(sc); @@ -1037,7 +1037,7 @@ ig4iic_attach(ig4iic_softc_t *sc) goto done; } error = bus_setup_intr(sc->dev, sc->intr_res, INTR_TYPE_MISC | INTR_MPSAFE, - NULL, ig4iic_intr, sc, &sc->intr_handle); + ig4iic_intr, NULL, sc, &sc->intr_handle); if (error) { device_printf(sc->dev, "Unable to setup irq: error %d\n", error); @@ -1127,19 +1127,23 @@ int ig4iic_resume(ig4iic_softc_t *sc) /* * Interrupt Operation, see ig4_var.h for locking semantics. */ -static void +static int ig4iic_intr(void *cookie) { ig4iic_softc_t *sc = cookie; + int retval = FILTER_STRAY; - mtx_lock(&sc->io_lock); + mtx_lock_spin(&sc->io_lock); /* Ignore stray interrupts */ if (sc->intr_mask != 0 && reg_read(sc, IG4_REG_INTR_STAT) != 0) { /* Interrupt bits are cleared in wait_intr() loop */ set_intr_mask(sc, 0); wakeup(sc); + retval = FILTER_HANDLED; } - mtx_unlock(&sc->io_lock); + mtx_unlock_spin(&sc->io_lock); + + return (retval); } #define REGDUMP(sc, reg) \ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354292 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:40:55 2019 New Revision: 354292 URL: https://svnweb.freebsd.org/changeset/base/354292 Log: [ig4] Handle controller startup errors Fail the attach on controller startup errors. For some reason the dell xps 13 says there's I2C controller, but the controller appears to be permanente disabled and will refuse to enable. Obtained from:DragonflyBSD (509820b) Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:39:46 2019 (r354291) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:40:55 2019 (r354292) @@ -629,10 +629,18 @@ ig4iic_attach(ig4iic_softc_t *sc) #endif mtx_lock(&sc->io_lock); - if (set_controller(sc, 0)) + if (set_controller(sc, 0)) { device_printf(sc->dev, "controller error during attach-1\n"); - if (set_controller(sc, IG4_I2C_ENABLE)) + mtx_unlock(&sc->io_lock); + error = ENXIO; + goto done; + } + if (set_controller(sc, IG4_I2C_ENABLE)) { device_printf(sc->dev, "controller error during attach-2\n"); + mtx_unlock(&sc->io_lock); + error = ENXIO; + goto done; + } mtx_unlock(&sc->io_lock); error = bus_setup_intr(sc->dev, sc->intr_res, INTR_TYPE_MISC | INTR_MPSAFE, NULL, ig4iic_intr, sc, &sc->intr_handle); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354297 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:46:20 2019 New Revision: 354297 URL: https://svnweb.freebsd.org/changeset/base/354297 Log: [ig4] Ignore stray interrupts Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:45:25 2019 (r354296) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:46:20 2019 (r354297) @@ -685,9 +685,12 @@ ig4iic_intr(void *cookie) ig4iic_softc_t *sc = cookie; mtx_lock(&sc->io_lock); - set_intr_mask(sc, 0); - reg_read(sc, IG4_REG_CLR_INTR); - wakeup(sc); + /* Ignore stray interrupts */ + if (sc->intr_mask != 0 && reg_read(sc, IG4_REG_INTR_STAT) != 0) { + set_intr_mask(sc, 0); + reg_read(sc, IG4_REG_CLR_INTR); + wakeup(sc); + } mtx_unlock(&sc->io_lock); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354320 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:16:06 2019 New Revision: 354320 URL: https://svnweb.freebsd.org/changeset/base/354320 Log: [ig4] Add support for CannonLake controllers They are clocked at 216MHz rate, much higher than previous models. PR: 240485 Submitted by: Neel Chauhan Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_pci.c head/sys/dev/ichiic/ig4_reg.h head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:15:01 2019 (r354319) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:16:06 2019 (r354320) @@ -115,6 +115,10 @@ static const struct ig4_hw ig4iic_hw[] = { .scl_fall_time = 208, .sda_hold_time = 207, }, + [IG4_CANNONLAKE] = { + .ic_clock_rate = 216, + .sda_hold_time = 230, + }, }; static int ig4iic_set_config(ig4iic_softc_t *sc, bool reset); @@ -912,7 +916,7 @@ ig4iic_set_config(ig4iic_softc_t *sc, bool reset) uint32_t v; v = reg_read(sc, IG4_REG_DEVIDLE_CTRL); - if (sc->version == IG4_SKYLAKE && (v & IG4_RESTORE_REQUIRED) ) { + if (IG4_HAS_ADDREGS(sc->version) && (v & IG4_RESTORE_REQUIRED)) { reg_write(sc, IG4_REG_DEVIDLE_CTRL, IG4_DEVICE_IDLE | IG4_RESTORE_REQUIRED); reg_write(sc, IG4_REG_DEVIDLE_CTRL, 0); pause("i2crst", 1); @@ -922,7 +926,7 @@ ig4iic_set_config(ig4iic_softc_t *sc, bool reset) if ((sc->version == IG4_HASWELL || sc->version == IG4_ATOM) && reset) { reg_write(sc, IG4_REG_RESETS_HSW, IG4_RESETS_ASSERT_HSW); reg_write(sc, IG4_REG_RESETS_HSW, IG4_RESETS_DEASSERT_HSW); - } else if (sc->version == IG4_SKYLAKE && reset) { + } else if (IG4_HAS_ADDREGS(sc->version) && reset) { reg_write(sc, IG4_REG_RESETS_SKL, IG4_RESETS_ASSERT_SKL); reg_write(sc, IG4_REG_RESETS_SKL, IG4_RESETS_DEASSERT_SKL); } @@ -948,7 +952,7 @@ ig4iic_set_config(ig4iic_softc_t *sc, bool reset) if (sc->version == IG4_HASWELL) { v = reg_read(sc, IG4_REG_SW_LTR_VALUE); v = reg_read(sc, IG4_REG_AUTO_LTR_VALUE); - } else if (sc->version == IG4_SKYLAKE) { + } else if (IG4_HAS_ADDREGS(sc->version)) { v = reg_read(sc, IG4_REG_ACTIVE_LTR_VALUE); v = reg_read(sc, IG4_REG_IDLE_LTR_VALUE); } @@ -1011,7 +1015,7 @@ ig4iic_attach(ig4iic_softc_t *sc) ig4iic_get_config(sc); - error = ig4iic_set_config(sc, sc->version == IG4_SKYLAKE); + error = ig4iic_set_config(sc, IG4_HAS_ADDREGS(sc->version)); if (error) goto done; @@ -1089,7 +1093,7 @@ ig4iic_suspend(ig4iic_softc_t *sc) sx_xlock(&sc->call_lock); set_controller(sc, 0); - if (sc->version == IG4_SKYLAKE) { + if (IG4_HAS_ADDREGS(sc->version)) { /* * Place the device in the idle state, just to be safe */ @@ -,7 +1115,7 @@ int ig4iic_resume(ig4iic_softc_t *sc) int error; sx_xlock(&sc->call_lock); - if (ig4iic_set_config(sc, sc->version == IG4_SKYLAKE)) + if (ig4iic_set_config(sc, IG4_HAS_ADDREGS(sc->version))) device_printf(sc->dev, "controller error during resume\n"); sx_xunlock(&sc->call_lock); @@ -1183,7 +1187,7 @@ ig4iic_dump(ig4iic_softc_t *sc) if (sc->version == IG4_HASWELL) { REGDUMP(sc, IG4_REG_SW_LTR_VALUE); REGDUMP(sc, IG4_REG_AUTO_LTR_VALUE); - } else if (sc->version == IG4_SKYLAKE) { + } else if (IG4_HAS_ADDREGS(sc->version)) { REGDUMP(sc, IG4_REG_ACTIVE_LTR_VALUE); REGDUMP(sc, IG4_REG_IDLE_LTR_VALUE); } Modified: head/sys/dev/ichiic/ig4_pci.c == --- head/sys/dev/ichiic/ig4_pci.c Sun Nov 3 21:15:01 2019 (r354319) +++ head/sys/dev/ichiic/ig4_pci.c Sun Nov 3 21:16:06 2019 (r354320) @@ -90,6 +90,16 @@ static int ig4iic_pci_detach(device_t dev); #define PCI_CHIP_APL_I2C_5 0x5ab68086 #define PCI_CHIP_APL_I2C_6 0x5ab88086 #define PCI_CHIP_APL_I2C_7 0x5aba8086 +#define PCI_CHIP_CANNONLAKE_LP_I2C_0 0x9dc58086 +#define PCI_CHIP_CANNONLAKE_LP_I2C_1 0x9dc68086 +#define PCI_CHIP_CANNONLAKE_LP_I2C_2 0x9de88086 +#define PCI_CHIP_CANNONLAKE_LP_I2C_3 0x9de98086 +#define PCI_CHIP_CANNONLAKE_LP_I2C_4 0x9dea8086 +#define PCI_CHIP_CANNONLAKE_LP_I2C_5 0x9deb8086 +#define PCI_CHIP_CANNONLAKE_H_I2C_00xa3688086 +#define PCI_CHIP_CANNONLAKE_H_I2C_10xa3698086 +#define PCI_CHIP_CANNONLAKE_H_I2C_20xa36a8086 +#define PCI_CHIP_CANNONLAKE_H_I2C_30xa36b8086 struct ig4iic_pci_device { uint32_t
svn commit: r354291 - in head/sys/dev: chromebook_platform ichiic
Author: wulf Date: Sun Nov 3 20:39:46 2019 New Revision: 354291 URL: https://svnweb.freebsd.org/changeset/base/354291 Log: [ig4] Give common name to PCI and ACPI device drivers They share common device driver code with different bus attachments This commit starts a bunch of changes which have following properties: Reviewed by: imp (previous version) MFC after:1 month Differential Revision:https://reviews.freebsd.org/D22016 Modified: head/sys/dev/chromebook_platform/chromebook_platform.c head/sys/dev/ichiic/ig4_acpi.c head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_pci.c head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/chromebook_platform/chromebook_platform.c == --- head/sys/dev/chromebook_platform/chromebook_platform.c Sun Nov 3 19:36:34 2019(r354290) +++ head/sys/dev/chromebook_platform/chromebook_platform.c Sun Nov 3 20:39:46 2019(r354291) @@ -69,7 +69,7 @@ chromebook_i2c_identify(driver_t *driver, device_t bus * See http://lxr.free-electrons.com/source/drivers/platform/chrome/chromeos_laptop.c */ controller = device_get_parent(bus); - if (strcmp(device_get_name(controller), "ig4iic_pci") != 0) + if (strcmp(device_get_name(controller), "ig4iic") != 0) return; for (i = 0; i < nitems(slaves); i++) { Modified: head/sys/dev/ichiic/ig4_acpi.c == --- head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 19:36:34 2019 (r354290) +++ head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 20:39:46 2019 (r354291) @@ -163,15 +163,10 @@ static device_method_t ig4iic_acpi_methods[] = { }; static driver_t ig4iic_acpi_driver = { - "ig4iic_acpi", + "ig4iic", ig4iic_acpi_methods, sizeof(struct ig4iic_softc), }; -static devclass_t ig4iic_acpi_devclass; -DRIVER_MODULE(ig4iic_acpi, acpi, ig4iic_acpi_driver, ig4iic_acpi_devclass, 0, 0); - -MODULE_DEPEND(ig4iic_acpi, acpi, 1, 1, 1); -MODULE_DEPEND(ig4iic_acpi, pci, 1, 1, 1); -MODULE_DEPEND(ig4iic_acpi, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); -MODULE_VERSION(ig4iic_acpi, 1); +DRIVER_MODULE(ig4iic, acpi, ig4iic_acpi_driver, ig4iic_devclass, 0, 0); +MODULE_DEPEND(ig4iic, acpi, 1, 1, 1); Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 19:36:34 2019 (r354290) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:39:46 2019 (r354291) @@ -797,5 +797,8 @@ ig4iic_dump(ig4iic_softc_t *sc) } #undef REGDUMP -DRIVER_MODULE(iicbus, ig4iic_acpi, iicbus_driver, iicbus_devclass, NULL, NULL); -DRIVER_MODULE(iicbus, ig4iic_pci, iicbus_driver, iicbus_devclass, NULL, NULL); +devclass_t ig4iic_devclass; + +DRIVER_MODULE(iicbus, ig4iic, iicbus_driver, iicbus_devclass, NULL, NULL); +MODULE_DEPEND(ig4iic, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); +MODULE_VERSION(ig4iic, 1); Modified: head/sys/dev/ichiic/ig4_pci.c == --- head/sys/dev/ichiic/ig4_pci.c Sun Nov 3 19:36:34 2019 (r354290) +++ head/sys/dev/ichiic/ig4_pci.c Sun Nov 3 20:39:46 2019 (r354291) @@ -220,17 +220,13 @@ static device_method_t ig4iic_pci_methods[] = { }; static driver_t ig4iic_pci_driver = { - "ig4iic_pci", + "ig4iic", ig4iic_pci_methods, sizeof(struct ig4iic_softc) }; -static devclass_t ig4iic_pci_devclass; - -DRIVER_MODULE_ORDERED(ig4iic_pci, pci, ig4iic_pci_driver, ig4iic_pci_devclass, 0, 0, +DRIVER_MODULE_ORDERED(ig4iic, pci, ig4iic_pci_driver, ig4iic_devclass, 0, 0, SI_ORDER_ANY); -MODULE_DEPEND(ig4iic_pci, pci, 1, 1, 1); -MODULE_DEPEND(ig4iic_pci, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); -MODULE_VERSION(ig4iic_pci, 1); -MODULE_PNP_INFO("W32:vendor/device", pci, ig4iic_pci, ig4iic_pci_devices, +MODULE_DEPEND(ig4iic, pci, 1, 1, 1); +MODULE_PNP_INFO("W32:vendor/device", pci, ig4iic, ig4iic_pci_devices, nitems(ig4iic_pci_devices)); Modified: head/sys/dev/ichiic/ig4_var.h == --- head/sys/dev/ichiic/ig4_var.h Sun Nov 3 19:36:34 2019 (r354290) +++ head/sys/dev/ichiic/ig4_var.h Sun Nov 3 20:39:46 2019 (r354291) @@ -101,6 +101,8 @@ struct ig4iic_softc { typedef struct ig4iic_softc ig4iic_softc_t; +extern devclass_t ig4iic_devclass; + /* Attach/Detach called from ig4iic_pci_*() */ int ig4iic_attach(ig4iic_softc_t *sc); int ig4iic_detach(ig4iic_softc_t *sc); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-h
svn commit: r354308 - in head/sys/dev: ichiic iicbus
Author: wulf Date: Sun Nov 3 21:00:55 2019 New Revision: 354308 URL: https://svnweb.freebsd.org/changeset/base/354308 Log: [ig4] Add suspend/resume support That is done with re-execution of controller initialization procedure from resume handler. PR: 238037 Modified: head/sys/dev/ichiic/ig4_acpi.c head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_pci.c head/sys/dev/ichiic/ig4_var.h head/sys/dev/iicbus/iicbus.c Modified: head/sys/dev/ichiic/ig4_acpi.c == --- head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 20:59:04 2019 (r354307) +++ head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 21:00:55 2019 (r354308) @@ -145,11 +145,29 @@ ig4iic_acpi_detach(device_t dev) return (0); } +static int +ig4iic_acpi_suspend(device_t dev) +{ + ig4iic_softc_t *sc = device_get_softc(dev); + + return (ig4iic_suspend(sc)); +} + +static int +ig4iic_acpi_resume(device_t dev) +{ + ig4iic_softc_t *sc = device_get_softc(dev); + + return (ig4iic_resume(sc)); +} + static device_method_t ig4iic_acpi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ig4iic_acpi_probe), DEVMETHOD(device_attach, ig4iic_acpi_attach), DEVMETHOD(device_detach, ig4iic_acpi_detach), + DEVMETHOD(device_suspend, ig4iic_acpi_suspend), + DEVMETHOD(device_resume, ig4iic_acpi_resume), /* iicbus interface */ DEVMETHOD(iicbus_transfer, ig4iic_transfer), Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:59:04 2019 (r354307) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:00:55 2019 (r354308) @@ -799,20 +799,11 @@ ig4iic_get_config(ig4iic_softc_t *sc) } } -/* - * Called from ig4iic_pci_attach/detach() - */ -int -ig4iic_attach(ig4iic_softc_t *sc) +static int +ig4iic_set_config(ig4iic_softc_t *sc) { - int error; uint32_t v; - mtx_init(&sc->io_lock, "IG4 I/O lock", NULL, MTX_DEF); - sx_init(&sc->call_lock, "IG4 call lock"); - - ig4iic_get_config(sc); - v = reg_read(sc, IG4_REG_DEVIDLE_CTRL); if (sc->version == IG4_SKYLAKE && (v & IG4_RESTORE_REQUIRED) ) { reg_write(sc, IG4_REG_DEVIDLE_CTRL, IG4_DEVICE_IDLE | IG4_RESTORE_REQUIRED); @@ -851,16 +842,13 @@ ig4iic_attach(ig4iic_softc_t *sc) if (sc->version == IG4_HASWELL || sc->version == IG4_ATOM) { v = reg_read(sc, IG4_REG_COMP_VER); - if (v < IG4_COMP_MIN_VER) { - error = ENXIO; - goto done; - } + if (v < IG4_COMP_MIN_VER) + return(ENXIO); } if (set_controller(sc, 0)) { device_printf(sc->dev, "controller error during attach-1\n"); - error = ENXIO; - goto done; + return (ENXIO); } reg_read(sc, IG4_REG_CLR_INTR); @@ -890,6 +878,26 @@ ig4iic_attach(ig4iic_softc_t *sc) IG4_CTL_RESTARTEN | (sc->cfg.bus_speed & IG4_CTL_SPEED_MASK)); + return (0); +} + +/* + * Called from ig4iic_pci_attach/detach() + */ +int +ig4iic_attach(ig4iic_softc_t *sc) +{ + int error; + + mtx_init(&sc->io_lock, "IG4 I/O lock", NULL, MTX_DEF); + sx_init(&sc->call_lock, "IG4 call lock"); + + ig4iic_get_config(sc); + + error = ig4iic_set_config(sc); + if (error) + goto done; + sc->iicbus = device_add_child(sc->dev, "iicbus", -1); if (sc->iicbus == NULL) { device_printf(sc->dev, "iicbus driver not found\n"); @@ -965,6 +973,49 @@ ig4iic_detach(ig4iic_softc_t *sc) sx_destroy(&sc->call_lock); return (0); +} + +int +ig4iic_suspend(ig4iic_softc_t *sc) +{ + int error; + + /* suspend all children */ + error = bus_generic_suspend(sc->dev); + + sx_xlock(&sc->call_lock); + set_controller(sc, 0); + if (sc->version == IG4_SKYLAKE) { + /* +* Place the device in the idle state, just to be safe +*/ + reg_write(sc, IG4_REG_DEVIDLE_CTRL, IG4_DEVICE_IDLE); + /* +* Controller can become dysfunctional if I2C lines are pulled +* down when suspend procedure turns off power to I2C device. +* Place device in the reset state to avoid this. +*/ + reg_write(sc, IG4_REG_RESETS_SKL, IG4_RESETS_ASSERT_SKL); + } + sx_xunlock(&sc->call_lock); + + return (error); +} + +int ig4iic_resume(ig4iic_softc_t *sc) +{ + int error; + + sx_xlock(&sc->call_lock); + if (ig4iic_set_config(sc)) + device_printf(sc->dev, "controller error during resume\n"); +
svn commit: r354301 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:51:22 2019 New Revision: 354301 URL: https://svnweb.freebsd.org/changeset/base/354301 Log: [ig4] Add support for polled mode Currently ig4 internally depends on it's own interrupts and uses mtx_sleep() to wait for them. That means it can not be used from any context where sleeping is disallowed e.g. on cold boot, from DDB/KDB, from other device driver's interrupt handlers and so on. This change replaces sleeps with busy loops in cold boot and DDB cases. Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:50:06 2019 (r354300) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:51:22 2019 (r354301) @@ -48,8 +48,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include #include @@ -70,6 +72,8 @@ __FBSDID("$FreeBSD$"); #define TRANS_PCALL2 #define TRANS_BLOCK3 +#define DO_POLL(sc)(cold || kdb_active || SCHEDULER_STOPPED()) + static void ig4iic_start(void *xdev); static void ig4iic_intr(void *cookie); static void ig4iic_dump(ig4iic_softc_t *sc); @@ -187,7 +191,7 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) * When waiting for receive data let the interrupt do its * work, otherwise poll with the lock held. */ - if (status & IG4_STATUS_RX_NOTEMPTY) { + if ((status & IG4_STATUS_RX_NOTEMPTY) && !DO_POLL(sc)) { mtx_lock(&sc->io_lock); set_intr_mask(sc, IG4_INTR_STOP_DET | IG4_INTR_RX_FULL); mtx_sleep(sc, &sc->io_lock, 0, "i2cwait", ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354319 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:15:01 2019 New Revision: 354319 URL: https://svnweb.freebsd.org/changeset/base/354319 Log: [ig4] Add generic resource methods to bus interface That allows ig4 children to allocate IRQs Modified: head/sys/dev/ichiic/ig4_acpi.c head/sys/dev/ichiic/ig4_pci.c Modified: head/sys/dev/ichiic/ig4_acpi.c == --- head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 21:14:08 2019 (r354318) +++ head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 21:15:01 2019 (r354319) @@ -169,6 +169,17 @@ static device_method_t ig4iic_acpi_methods[] = { DEVMETHOD(device_suspend, ig4iic_acpi_suspend), DEVMETHOD(device_resume, ig4iic_acpi_resume), + /* Bus interface */ + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + /* iicbus interface */ DEVMETHOD(iicbus_transfer, ig4iic_transfer), DEVMETHOD(iicbus_reset, ig4iic_reset), Modified: head/sys/dev/ichiic/ig4_pci.c == --- head/sys/dev/ichiic/ig4_pci.c Sun Nov 3 21:14:08 2019 (r354318) +++ head/sys/dev/ichiic/ig4_pci.c Sun Nov 3 21:15:01 2019 (r354319) @@ -230,6 +230,18 @@ static device_method_t ig4iic_pci_methods[] = { DEVMETHOD(device_suspend, ig4iic_pci_suspend), DEVMETHOD(device_resume, ig4iic_pci_resume), + /* Bus interface */ + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + + /* iicbus interface */ DEVMETHOD(iicbus_transfer, ig4iic_transfer), DEVMETHOD(iicbus_reset, ig4iic_reset), DEVMETHOD(iicbus_callback, ig4iic_callback), ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354304 - head/sys/dev/cyapa
Author: wulf Date: Sun Nov 3 20:55:28 2019 New Revision: 354304 URL: https://svnweb.freebsd.org/changeset/base/354304 Log: [cyapa] Postpone start of the polling thread until sleep is available After recent ig4 changes cyapa driver can be attached before timers initialization is completed. Start polling thread from config_intrhook to avoid busy loops in that case. Modified: head/sys/dev/cyapa/cyapa.c Modified: head/sys/dev/cyapa/cyapa.c == --- head/sys/dev/cyapa/cyapa.c Sun Nov 3 20:54:17 2019(r354303) +++ head/sys/dev/cyapa/cyapa.c Sun Nov 3 20:55:28 2019(r354304) @@ -152,6 +152,7 @@ struct cyapa_softc { struct cdev *devnode; struct selinfo selinfo; struct mtx mutex; + struct intr_config_hook intr_hook; int cap_resx; int cap_resy; @@ -419,6 +420,27 @@ done: return (error); } +/* + * Start the polling thread + */ +static void +cyapa_start(void *xdev) +{ + struct cyapa_softc *sc; + device_t dev = xdev; + + sc = device_get_softc(dev); + + config_intrhook_disestablish(&sc->intr_hook); + + /* Setup input event tracking */ + cyapa_set_power_mode(sc, CMD_POWER_MODE_IDLE); + + /* Start the polling thread */ + kthread_add(cyapa_poll_thread, sc, NULL, NULL, + 0, 0, "cyapa-poll"); +} + static int cyapa_probe(device_t); static int cyapa_attach(device_t); static int cyapa_detach(device_t); @@ -536,12 +558,14 @@ cyapa_attach(device_t dev) sc->mode.level = 0; sc->mode.packetsize = MOUSE_PS2_PACKETSIZE; - /* Setup input event tracking */ - cyapa_set_power_mode(sc, CMD_POWER_MODE_IDLE); + sc->intr_hook.ich_func = cyapa_start; + sc->intr_hook.ich_arg = sc->dev; - /* Start the polling thread */ -kthread_add(cyapa_poll_thread, sc, NULL, NULL, - 0, 0, "cyapa-poll"); + /* Postpone start of the polling thread until sleep is available */ + if (config_intrhook_establish(&sc->intr_hook) != 0) { + mtx_destroy(&sc->mutex); + return (ENOMEM); + } sc->devnode = make_dev(&cyapa_cdevsw, unit, UID_ROOT, GID_WHEEL, 0600, "cyapa%d", unit); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354303 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:54:17 2019 New Revision: 354303 URL: https://svnweb.freebsd.org/changeset/base/354303 Log: [ig4] Do not wait until interrupts are enabled at attach stage as the driver is fully functional on a cold boot through utilization of polled mode. As a side effect, ig4 children probe and attach methods can be called earlier in the boot sequence, so now it is up to the child drivers to wait for a kernel initialization completion if it is required. Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:53:13 2019 (r354302) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:54:17 2019 (r354303) @@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$"); #define DO_POLL(sc)(cold || kdb_active || SCHEDULER_STOPPED() || sc->poll) -static void ig4iic_start(void *xdev); static void ig4iic_intr(void *cookie); static void ig4iic_dump(ig4iic_softc_t *sc); @@ -664,38 +663,14 @@ ig4iic_attach(ig4iic_softc_t *sc) "Unable to setup irq: error %d\n", error); } - sc->enum_hook.ich_func = ig4iic_start; - sc->enum_hook.ich_arg = sc->dev; - - /* -* We have to wait until interrupts are enabled. I2C read and write -* only works if the interrupts are available. -*/ - if (config_intrhook_establish(&sc->enum_hook) != 0) - error = ENOMEM; - else - error = 0; - -done: - return (error); -} - -void -ig4iic_start(void *xdev) -{ - int error; - ig4iic_softc_t *sc; - device_t dev = (device_t)xdev; - - sc = device_get_softc(dev); - - config_intrhook_disestablish(&sc->enum_hook); - error = bus_generic_attach(sc->dev); if (error) { device_printf(sc->dev, "failed to attach child: error %d\n", error); } + +done: + return (error); } int Modified: head/sys/dev/ichiic/ig4_var.h == --- head/sys/dev/ichiic/ig4_var.h Sun Nov 3 20:53:13 2019 (r354302) +++ head/sys/dev/ichiic/ig4_var.h Sun Nov 3 20:54:17 2019 (r354303) @@ -48,7 +48,6 @@ enum ig4_vers { IG4_HASWELL, IG4_ATOM, IG4_SKYLAKE, IG struct ig4iic_softc { device_tdev; - struct intr_config_hook enum_hook; device_tiicbus; struct resource *regs_res; int regs_rid; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354293 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:42:04 2019 New Revision: 354293 URL: https://svnweb.freebsd.org/changeset/base/354293 Log: [ig4] Only enable interrupts when we want them. Otherwise keep mask at 0. This avoids possible interrupt storms, depending on the state of the I2C controller before the driver attached. During attaching this clears the interrupt mask. Revert r338215 as this change makes it no-op. Obtained from:DragonflyBSD (d7c8555) Modified: head/sys/dev/ichiic/ig4_acpi.c head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_acpi.c == --- head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 20:40:55 2019 (r354292) +++ head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 20:42:04 2019 (r354293) @@ -69,18 +69,15 @@ static int ig4iic_acpi_probe(device_t dev) { ig4iic_softc_t *sc; - char *hid; int rv; sc = device_get_softc(dev); if (acpi_disabled("ig4iic")) return (ENXIO); - rv = ACPI_ID_PROBE(device_get_parent(dev), dev, ig4iic_ids, &hid); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, ig4iic_ids, NULL); if (rv > 0) return (rv); -if (strcmp("AMDI0010", hid) == 0) -sc->access_intr_mask = 1; device_set_desc(dev, "Designware I2C Controller"); return (rv); } Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:40:55 2019 (r354292) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:42:04 2019 (r354293) @@ -98,6 +98,15 @@ reg_read(ig4iic_softc_t *sc, uint32_t reg) return (value); } +static void +set_intr_mask(ig4iic_softc_t *sc, uint32_t val) +{ + if (sc->intr_mask != val) { + reg_write(sc, IG4_REG_INTR_MASK, val); + sc->intr_mask = val; + } +} + /* * Enable or disable the controller and wait for the controller to acknowledge * the state change. @@ -113,12 +122,9 @@ set_controller(ig4iic_softc_t *sc, uint32_t ctl) * When the controller is enabled, interrupt on STOP detect * or receive character ready and clear pending interrupts. */ - if (ctl & IG4_I2C_ENABLE) { - reg_write(sc, IG4_REG_INTR_MASK, IG4_INTR_STOP_DET | -IG4_INTR_RX_FULL); + set_intr_mask(sc, 0); + if (ctl & IG4_I2C_ENABLE) reg_read(sc, IG4_REG_CLR_INTR); - } else - reg_write(sc, IG4_REG_INTR_MASK, 0); reg_write(sc, IG4_REG_I2C_EN, ctl); error = IIC_ETIMEOUT; @@ -196,8 +202,10 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) * work, otherwise poll with the lock held. */ if (status & IG4_STATUS_RX_NOTEMPTY) { + set_intr_mask(sc, IG4_INTR_STOP_DET | IG4_INTR_RX_FULL); mtx_sleep(sc, &sc->io_lock, 0, "i2cwait", (hz + 99) / 100); /* sleep up to 10ms */ + set_intr_mask(sc, 0); count_us += 1; } else { DELAY(25); @@ -579,6 +587,10 @@ ig4iic_attach(ig4iic_softc_t *sc) v = reg_read(sc, IG4_REG_SS_SCL_LCNT); reg_write(sc, IG4_REG_FS_SCL_LCNT, v); + reg_read(sc, IG4_REG_CLR_INTR); + reg_write(sc, IG4_REG_INTR_MASK, 0); + sc->intr_mask = 0; + /* * Program based on a 25000 Hz clock. This is a bit of a * hack (obviously). The defaults are 400 and 470 for standard @@ -725,7 +737,7 @@ ig4iic_intr(void *cookie) uint32_t status; mtx_lock(&sc->io_lock); -/* reg_write(sc, IG4_REG_INTR_MASK, IG4_INTR_STOP_DET);*/ + set_intr_mask(sc, 0); reg_read(sc, IG4_REG_CLR_INTR); status = reg_read(sc, IG4_REG_I2C_STA); while (status & IG4_STATUS_RX_NOTEMPTY) { @@ -733,18 +745,6 @@ ig4iic_intr(void *cookie) (uint8_t)reg_read(sc, IG4_REG_DATA_CMD); ++sc->rnext; status = reg_read(sc, IG4_REG_I2C_STA); - } - - /* -* Workaround to trigger pending interrupt if IG4_REG_INTR_STAT -* is changed after clearing it -*/ - if (sc->access_intr_mask != 0) { - status = reg_read(sc, IG4_REG_INTR_MASK); - if (status != 0) { - reg_write(sc, IG4_REG_INTR_MASK, 0); - reg_write(sc, IG4_REG_INTR_MASK, status); - } } wakeup(sc); Modified: head/sys/dev/ichiic/ig4_var.h == --- head/sys/dev/ichiic/ig4_var.h Sun Nov 3 20:40:55 2019 (r354292) +++
svn commit: r354302 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:53:13 2019 New Revision: 354302 URL: https://svnweb.freebsd.org/changeset/base/354302 Log: [ig4] Allow enabling of polled mode from iicbus allocation callback If controller is allocated with IIC_NOWAIT option ig4 enables polled mode for a period of allocation that makes possible to start I2C transfers from the contexts where sleeping is not allowed e.g. from ithreads or callouts. Modified: head/sys/dev/ichiic/ig4_acpi.c head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_pci.c head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_acpi.c == --- head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 20:51:22 2019 (r354301) +++ head/sys/dev/ichiic/ig4_acpi.c Sun Nov 3 20:53:13 2019 (r354302) @@ -154,7 +154,7 @@ static device_method_t ig4iic_acpi_methods[] = { /* iicbus interface */ DEVMETHOD(iicbus_transfer, ig4iic_transfer), DEVMETHOD(iicbus_reset, ig4iic_reset), - DEVMETHOD(iicbus_callback, iicbus_null_callback), + DEVMETHOD(iicbus_callback, ig4iic_callback), DEVMETHOD_END }; Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:51:22 2019 (r354301) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:53:13 2019 (r354302) @@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$"); #define TRANS_PCALL2 #define TRANS_BLOCK3 -#define DO_POLL(sc)(cold || kdb_active || SCHEDULER_STOPPED()) +#define DO_POLL(sc)(cold || kdb_active || SCHEDULER_STOPPED() || sc->poll) static void ig4iic_start(void *xdev); static void ig4iic_intr(void *cookie); @@ -350,6 +350,7 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui int unit; bool rpstart; bool stop; + bool allocated; /* * The hardware interface imposes limits on allowed I2C messages. @@ -410,7 +411,10 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui return (IIC_ENOTSUPP); } - sx_xlock(&sc->call_lock); + /* Check if device is already allocated with iicbus_request_bus() */ + allocated = sx_xlocked(&sc->call_lock) != 0; + if (!allocated) + sx_xlock(&sc->call_lock); /* Debugging - dump registers. */ if (ig4_dump) { @@ -458,7 +462,8 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui rpstart = !stop; } - sx_unlock(&sc->call_lock); + if (!allocated) + sx_unlock(&sc->call_lock); return (error); } @@ -466,8 +471,11 @@ int ig4iic_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr) { ig4iic_softc_t *sc = device_get_softc(dev); + bool allocated; - sx_xlock(&sc->call_lock); + allocated = sx_xlocked(&sc->call_lock) != 0; + if (!allocated) + sx_xlock(&sc->call_lock); /* TODO handle speed configuration? */ if (oldaddr != NULL) @@ -476,8 +484,41 @@ ig4iic_reset(device_t dev, u_char speed, u_char addr, if (addr == IIC_UNKNOWN) sc->slave_valid = false; - sx_unlock(&sc->call_lock); + if (!allocated) + sx_unlock(&sc->call_lock); return (0); +} + +int +ig4iic_callback(device_t dev, int index, caddr_t data) +{ + ig4iic_softc_t *sc = device_get_softc(dev); + int error = 0; + int how; + + switch (index) { + case IIC_REQUEST_BUS: + /* force polling if ig4iic is requested with IIC_DONTWAIT */ + how = *(int *)data; + if ((how & IIC_WAIT) == 0) { + if (sx_try_xlock(&sc->call_lock) == 0) + error = IIC_EBUSBSY; + else + sc->poll = true; + } else + sx_xlock(&sc->call_lock); + break; + + case IIC_RELEASE_BUS: + sc->poll = false; + sx_unlock(&sc->call_lock); + break; + + default: + error = errno2iic(EINVAL); + } + + return (error); } /* Modified: head/sys/dev/ichiic/ig4_pci.c == --- head/sys/dev/ichiic/ig4_pci.c Sun Nov 3 20:51:22 2019 (r354301) +++ head/sys/dev/ichiic/ig4_pci.c Sun Nov 3 20:53:13 2019 (r354302) @@ -214,7 +214,7 @@ static device_method_t ig4iic_pci_methods[] = { DEVMETHOD(iicbus_transfer, ig4iic_transfer), DEVMETHOD(iicbus_reset, ig4iic_reset), - DEVMETHOD(iicbus_callback, iicbus_null_callback), + DEVMETHOD(iicbus_callback, ig4iic_callback), DEVMETHOD_END }; Modified: head/sys/dev/ichiic/ig4_var.h
svn commit: r354321 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:17:01 2019 New Revision: 354321 URL: https://svnweb.freebsd.org/changeset/base/354321 Log: [ig4] Enable additional registers support on Appolo Lake controllers To be inline with intel-lpss Linux driver Modified: head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_var.h == --- head/sys/dev/ichiic/ig4_var.h Sun Nov 3 21:16:06 2019 (r354320) +++ head/sys/dev/ichiic/ig4_var.h Sun Nov 3 21:17:01 2019 (r354321) @@ -46,7 +46,7 @@ enum ig4_vers { IG4_HASWELL, IG4_ATOM, IG4_SKYLAKE, IG4_APL, IG4_CANNONLAKE }; /* Controller has additional registers */ #defineIG4_HAS_ADDREGS(vers) ((vers) == IG4_SKYLAKE || \ - (vers) == IG4_CANNONLAKE) + (vers) == IG4_APL || (vers) == IG4_CANNONLAKE) struct ig4_hw { uint32_tic_clock_rate; /* MHz */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354299 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:49:04 2019 New Revision: 354299 URL: https://svnweb.freebsd.org/changeset/base/354299 Log: [ig4] Stop I2C controller after checking that it's kind of functional. Obtained from:DragonfliBSD (0b3eedb) Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:47:49 2019 (r354298) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:49:04 2019 (r354299) @@ -605,6 +605,11 @@ ig4iic_attach(ig4iic_softc_t *sc) error = ENXIO; goto done; } + if (set_controller(sc, 0)) { + device_printf(sc->dev, "controller error during attach-3\n"); + error = ENXIO; + goto done; + } error = bus_setup_intr(sc->dev, sc->intr_res, INTR_TYPE_MISC | INTR_MPSAFE, NULL, ig4iic_intr, sc, &sc->intr_handle); if (error) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354300 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:50:06 2019 New Revision: 354300 URL: https://svnweb.freebsd.org/changeset/base/354300 Log: [ig4] disable controller before initialization of clock counters It is required by controller specifications. Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:49:04 2019 (r354299) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:50:06 2019 (r354300) @@ -531,6 +531,13 @@ ig4iic_attach(ig4iic_softc_t *sc) goto done; } } + + if (set_controller(sc, 0)) { + device_printf(sc->dev, "controller error during attach-1\n"); + error = ENXIO; + goto done; + } + v = reg_read(sc, IG4_REG_SS_SCL_HCNT); v = reg_read(sc, IG4_REG_SS_SCL_LCNT); v = reg_read(sc, IG4_REG_FS_SCL_HCNT); @@ -595,11 +602,6 @@ ig4iic_attach(ig4iic_softc_t *sc) } #endif - if (set_controller(sc, 0)) { - device_printf(sc->dev, "controller error during attach-1\n"); - error = ENXIO; - goto done; - } if (set_controller(sc, IG4_I2C_ENABLE)) { device_printf(sc->dev, "controller error during attach-2\n"); error = ENXIO; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354296 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:45:25 2019 New Revision: 354296 URL: https://svnweb.freebsd.org/changeset/base/354296 Log: [ig4] Reduce scope of io_lock Now io_lock is used as condition variable to synchronize active process with the interrupt handler. It is not used for tasks other than waiting for interrupt and passing parameters to and from it's handler. Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:44:16 2019 (r354295) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:45:25 2019 (r354296) @@ -188,10 +188,12 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) * work, otherwise poll with the lock held. */ if (status & IG4_STATUS_RX_NOTEMPTY) { + mtx_lock(&sc->io_lock); set_intr_mask(sc, IG4_INTR_STOP_DET | IG4_INTR_RX_FULL); mtx_sleep(sc, &sc->io_lock, 0, "i2cwait", (hz + 99) / 100); /* sleep up to 10ms */ set_intr_mask(sc, 0); + mtx_unlock(&sc->io_lock); count_us += 1; } else { DELAY(25); @@ -405,7 +407,6 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui } sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); /* Debugging - dump registers. */ if (ig4_dump) { @@ -453,7 +454,6 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui rpstart = !stop; } - mtx_unlock(&sc->io_lock); sx_unlock(&sc->call_lock); return (error); } @@ -464,7 +464,6 @@ ig4iic_reset(device_t dev, u_char speed, u_char addr, ig4iic_softc_t *sc = device_get_softc(dev); sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); /* TODO handle speed configuration? */ if (oldaddr != NULL) @@ -473,7 +472,6 @@ ig4iic_reset(device_t dev, u_char speed, u_char addr, if (addr == IIC_UNKNOWN) sc->slave_valid = false; - mtx_unlock(&sc->io_lock); sx_unlock(&sc->call_lock); return (0); } @@ -664,14 +662,12 @@ ig4iic_detach(ig4iic_softc_t *sc) bus_teardown_intr(sc->dev, sc->intr_res, sc->intr_handle); sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); sc->iicbus = NULL; sc->intr_handle = NULL; reg_write(sc, IG4_REG_INTR_MASK, 0); set_controller(sc, 0); - mtx_unlock(&sc->io_lock); sx_xunlock(&sc->call_lock); mtx_destroy(&sc->io_lock); Modified: head/sys/dev/ichiic/ig4_var.h == --- head/sys/dev/ichiic/ig4_var.h Sun Nov 3 20:44:16 2019 (r354295) +++ head/sys/dev/ichiic/ig4_var.h Sun Nov 3 20:45:25 2019 (r354296) @@ -73,8 +73,12 @@ struct ig4iic_softc { * * Functions implementing the icbus interface that interact * with the controller acquire an exclusive lock on call_lock -* to prevent interleaving of calls to the interface and a lock on -* io_lock right afterwards, to synchronize controller I/O activity. +* to prevent interleaving of calls to the interface. +* +* io_lock is used as condition variable to synchronize active process +* with the interrupt handler. It should not be used for tasks other +* than waiting for interrupt and passing parameters to and from +* it's handler. */ struct sx call_lock; struct mtx io_lock; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354295 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:44:16 2019 New Revision: 354295 URL: https://svnweb.freebsd.org/changeset/base/354295 Log: [ig4] Do not wait for interrupts in set_controller() routine Specs shows no dedicated interrupt firing on disable of the controller. Remove io lock acquisitions around set_controller() calls as they are not needed anymore. Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:43:02 2019 (r354294) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:44:16 2019 (r354295) @@ -135,10 +135,7 @@ set_controller(ig4iic_softc_t *sc, uint32_t ctl) error = 0; break; } - if (cold) - DELAY(1000); - else - mtx_sleep(sc, &sc->io_lock, 0, "i2cslv", 1); + pause("i2cslv", 1); } return (error); } @@ -600,20 +597,16 @@ ig4iic_attach(ig4iic_softc_t *sc) } #endif - mtx_lock(&sc->io_lock); if (set_controller(sc, 0)) { device_printf(sc->dev, "controller error during attach-1\n"); - mtx_unlock(&sc->io_lock); error = ENXIO; goto done; } if (set_controller(sc, IG4_I2C_ENABLE)) { device_printf(sc->dev, "controller error during attach-2\n"); - mtx_unlock(&sc->io_lock); error = ENXIO; goto done; } - mtx_unlock(&sc->io_lock); error = bus_setup_intr(sc->dev, sc->intr_res, INTR_TYPE_MISC | INTR_MPSAFE, NULL, ig4iic_intr, sc, &sc->intr_handle); if (error) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354311 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:03:55 2019 New Revision: 354311 URL: https://svnweb.freebsd.org/changeset/base/354311 Log: [ig4] Convert last remaining usage of TX_NOTFULL status to TX_EMPTY in ig4iic_read routine. It makes possible interrupt utilization while waiting for empty space in TX FIFO. Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:03:07 2019 (r354310) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:03:55 2019 (r354311) @@ -337,14 +337,14 @@ ig4iic_read(ig4iic_softc_t *sc, uint8_t *buf, uint16_t while (received < len) { burst = sc->cfg.txfifo_depth - (reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK); - /* Ensure we have enough free space in RXFIFO */ - burst = MIN(burst, sc->cfg.rxfifo_depth - lowat); if (burst <= 0) { - error = wait_status(sc, IG4_STATUS_TX_NOTFULL); + error = wait_status(sc, IG4_STATUS_TX_EMPTY); if (error) break; - burst = 1; + burst = sc->cfg.txfifo_depth; } + /* Ensure we have enough free space in RXFIFO */ + burst = MIN(burst, sc->cfg.rxfifo_depth - lowat); target = MIN(requested + burst, (int)len); while (requested < target) { cmd = IG4_DATA_COMMAND_RD; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354314 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:07:12 2019 New Revision: 354314 URL: https://svnweb.freebsd.org/changeset/base/354314 Log: [ig4] Improve error detection Handle error bits of INTR_STAT and TX_ABORT registers. Move interrupt clearing from interrupt handler to polling loop to get common execution path with polled mode. Do not clear interrupts with reading of IG4_REG_CLR_INTR register as interrupts, triggered during the period from reg_read(IG4_REG_INTR_STAT) to reg_read(IG4_REG_CLR_INTR) will be missed. Instead, read each IG4_REG_CLR_* register separately. Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_reg.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:06:06 2019 (r354313) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:07:12 2019 (r354314) @@ -164,6 +164,55 @@ set_intr_mask(ig4iic_softc_t *sc, uint32_t val) } } +static int +intrstat2iic(ig4iic_softc_t *sc, uint32_t val) +{ + uint32_t src; + + if (val & IG4_INTR_RX_UNDER) + reg_read(sc, IG4_REG_CLR_RX_UNDER); + if (val & IG4_INTR_RX_OVER) + reg_read(sc, IG4_REG_CLR_RX_OVER); + if (val & IG4_INTR_TX_OVER) + reg_read(sc, IG4_REG_CLR_TX_OVER); + + if (val & IG4_INTR_TX_ABRT) { + src = reg_read(sc, IG4_REG_TX_ABRT_SOURCE); + reg_read(sc, IG4_REG_CLR_TX_ABORT); + /* User-requested abort. Not really a error */ + if (src & IG4_ABRTSRC_TRANSFER) + return (IIC_ESTATUS); + /* Master has lost arbitration */ + if (src & IG4_ABRTSRC_ARBLOST) + return (IIC_EBUSBSY); + /* Did not receive an acknowledge from the remote slave */ + if (src & (IG4_ABRTSRC_TXNOACK_ADDR7 | + IG4_ABRTSRC_TXNOACK_ADDR10_1 | + IG4_ABRTSRC_TXNOACK_ADDR10_2 | + IG4_ABRTSRC_TXNOACK_DATA | + IG4_ABRTSRC_GENCALL_NOACK)) + return (IIC_ENOACK); + /* Programming errors */ + if (src & (IG4_ABRTSRC_GENCALL_READ | + IG4_ABRTSRC_NORESTART_START | + IG4_ABRTSRC_NORESTART_10)) + return (IIC_ENOTSUPP); + /* Other errors */ + if (src & IG4_ABRTSRC_ACKED_START) + return (IIC_EBUSERR); + } + /* +* TX_OVER, RX_OVER and RX_UNDER are caused by wrong RX/TX FIFO depth +* detection or driver's read/write pipelining errors. +*/ + if (val & (IG4_INTR_TX_OVER | IG4_INTR_RX_OVER)) + return (IIC_EOVERFLOW); + if (val & IG4_INTR_RX_UNDER) + return (IIC_EUNDERFLOW); + + return (IIC_NOERR); +} + /* * Enable or disable the controller and wait for the controller to acknowledge * the state change. @@ -209,17 +258,14 @@ wait_intr(ig4iic_softc_t *sc, uint32_t intr) u_int count_us = 0; u_int limit_us = 25000; /* 25ms */ - error = IIC_ETIMEOUT; - for (;;) { /* * Check requested status */ v = reg_read(sc, IG4_REG_RAW_INTR_STAT); - if (v & intr) { - error = 0; + error = intrstat2iic(sc, v & IG4_INTR_ERR_MASK); + if (error || (v & intr)) break; - } /* * When waiting for the transmit FIFO to become empty, @@ -237,15 +283,17 @@ wait_intr(ig4iic_softc_t *sc, uint32_t intr) /* * Stop if we've run out of time. */ - if (count_us >= limit_us) + if (count_us >= limit_us) { + error = IIC_ETIMEOUT; break; + } /* * When polling is not requested let the interrupt do its work. */ if (!DO_POLL(sc)) { mtx_lock(&sc->io_lock); - set_intr_mask(sc, intr); + set_intr_mask(sc, intr | IG4_INTR_ERR_MASK); mtx_sleep(sc, &sc->io_lock, 0, "i2cwait", (hz + 99) / 100); /* sleep up to 10ms */ set_intr_mask(sc, 0); @@ -307,9 +355,17 @@ set_slave_addr(ig4iic_softc_t *sc, uint8_t slave) * IICBUS API FUNCTIONS */ static int -ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave) +ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave, bool repeated_start) { set_slave_addr(sc, slave >> 1); + + if (!repeated_start) { + /* +* Clear any prev
svn commit: r354305 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:56:53 2019 New Revision: 354305 URL: https://svnweb.freebsd.org/changeset/base/354305 Log: [ig4] dump IG4_REG_COMP_PARAM1 and IG4_REG_COMP_VER registers unconditionally They appeared to be supported (although undocumented) on SkyLakes+ too. Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_reg.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:55:28 2019 (r354304) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:56:53 2019 (r354305) @@ -751,10 +751,8 @@ ig4iic_dump(ig4iic_softc_t *sc) REGDUMP(sc, IG4_REG_DMA_RDLR); REGDUMP(sc, IG4_REG_SDA_SETUP); REGDUMP(sc, IG4_REG_ENABLE_STATUS); - if (sc->version == IG4_HASWELL || sc->version == IG4_ATOM) { - REGDUMP(sc, IG4_REG_COMP_PARAM1); - REGDUMP(sc, IG4_REG_COMP_VER); - } + REGDUMP(sc, IG4_REG_COMP_PARAM1); + REGDUMP(sc, IG4_REG_COMP_VER); if (sc->version == IG4_ATOM) { REGDUMP(sc, IG4_REG_COMP_TYPE); REGDUMP(sc, IG4_REG_CLK_PARMS); Modified: head/sys/dev/ichiic/ig4_reg.h == --- head/sys/dev/ichiic/ig4_reg.h Sun Nov 3 20:55:28 2019 (r354304) +++ head/sys/dev/ichiic/ig4_reg.h Sun Nov 3 20:56:53 2019 (r354305) @@ -112,7 +112,7 @@ #define IG4_REG_SDA_SETUP 0x0094 /* RW SDA Setup */ #define IG4_REG_ACK_GENERAL_CALL 0x0098/* RW I2C ACK General Call */ #define IG4_REG_ENABLE_STATUS 0x009C /* RO Enable Status */ -/* Available at least on Atom SoCs and Haswell mobile. */ +/* Available at least on Atom SoCs, Haswell mobile and some Skylakes. */ #define IG4_REG_COMP_PARAM10x00F4 /* RO Component Parameter */ #define IG4_REG_COMP_VER 0x00F8 /* RO Component Version */ /* Available at least on Atom SoCs */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354312 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:04:51 2019 New Revision: 354312 URL: https://svnweb.freebsd.org/changeset/base/354312 Log: [ig4] Use interrupts for waiting for empty TX FIFO Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:03:55 2019 (r354311) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:04:51 2019 (r354312) @@ -252,6 +252,14 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) set_intr_mask(sc, 0); mtx_unlock(&sc->io_lock); count_us += 1; + } else if ((status & IG4_STATUS_TX_EMPTY) && !DO_POLL(sc)) { + mtx_lock(&sc->io_lock); + set_intr_mask(sc, IG4_INTR_TX_EMPTY); + mtx_sleep(sc, &sc->io_lock, 0, "i2cwait", + (hz + 99) / 100); /* sleep up to 10ms */ + set_intr_mask(sc, 0); + mtx_unlock(&sc->io_lock); + count_us += 1; } else { DELAY(25); count_us += 25; @@ -861,6 +869,7 @@ ig4iic_set_config(ig4iic_softc_t *sc) * See ig4_var.h for details on interrupt handler synchronization. */ reg_write(sc, IG4_REG_RX_TL, 0); + reg_write(sc, IG4_REG_TX_TL, 0); reg_write(sc, IG4_REG_CTL, IG4_CTL_MASTER | ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354306 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:57:59 2019 New Revision: 354306 URL: https://svnweb.freebsd.org/changeset/base/354306 Log: [ig4] Set clock registers based on controller model IC clock rates are varied between different controller models so we have to adjust timing registers in each case individually. Borrow intresting constants and formulas from Intel specs, i2c-designware and lpss_intel drivers and apply them to FreeBSD supported controller models. Implement fetching of timing data via ACPI methods execution if available. Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_reg.h head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:56:53 2019 (r354305) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:57:59 2019 (r354306) @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); * See ig4_var.h for locking semantics. */ +#include "opt_acpi.h" + #include #include #include @@ -60,6 +62,12 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef DEV_ACPI +#include +#include +#include +#endif + #include #include #include @@ -74,6 +82,43 @@ __FBSDID("$FreeBSD$"); #define DO_POLL(sc)(cold || kdb_active || SCHEDULER_STOPPED() || sc->poll) +/* + * tLOW, tHIGH periods of the SCL clock and maximal falling time of both + * lines are taken from I2C specifications. + */ +#defineIG4_SPEED_STD_THIGH 4000/* nsec */ +#defineIG4_SPEED_STD_TLOW 4700/* nsec */ +#defineIG4_SPEED_STD_TF_MAX300 /* nsec */ +#defineIG4_SPEED_FAST_THIGH600 /* nsec */ +#defineIG4_SPEED_FAST_TLOW 1300/* nsec */ +#defineIG4_SPEED_FAST_TF_MAX 300 /* nsec */ + +/* + * Ig4 hardware parameters except Haswell are taken from intel_lpss driver + */ +static const struct ig4_hw ig4iic_hw[] = { + [IG4_HASWELL] = { + .ic_clock_rate = 100, /* MHz */ + .sda_hold_time = 90,/* nsec */ + }, + [IG4_ATOM] = { + .ic_clock_rate = 100, + .sda_fall_time = 280, + .scl_fall_time = 240, + .sda_hold_time = 60, + }, + [IG4_SKYLAKE] = { + .ic_clock_rate = 120, + .sda_hold_time = 230, + }, + [IG4_APL] = { + .ic_clock_rate = 133, + .sda_fall_time = 171, + .scl_fall_time = 208, + .sda_hold_time = 207, + }, +}; + static void ig4iic_intr(void *cookie); static void ig4iic_dump(ig4iic_softc_t *sc); @@ -82,6 +127,17 @@ SYSCTL_INT(_debug, OID_AUTO, ig4_dump, CTLFLAG_RW, &ig4_dump, 0, "Dump controller registers"); /* + * Clock registers initialization control + * 0 - Try read clock registers from ACPI and fallback to p.1. + * 1 - Calculate values based on controller type (IC clock rate). + * 2 - Use values inherited from DragonflyBSD driver (old behavior). + * 3 - Keep clock registers intact. + */ +static int ig4_timings; +SYSCTL_INT(_debug, OID_AUTO, ig4_timings, CTLFLAG_RDTUN, &ig4_timings, 0, +"Controller timings 0=ACPI, 1=predefined, 2=legacy, 3=do not change"); + +/* * Low-level inline support functions */ static __inline void @@ -521,6 +577,166 @@ ig4iic_callback(device_t dev, int index, caddr_t data) } /* + * Clock register values can be calculated with following rough equations: + * SCL_HCNT = ceil(IC clock rate * tHIGH) + * SCL_LCNT = ceil(IC clock rate * tLOW) + * SDA_HOLD = ceil(IC clock rate * SDA hold time) + * Precise equations take signal's falling, rising and spike suppression + * times in to account. They can be found in Synopsys or Intel documentation. + * + * Here we snarf formulas and defaults from Linux driver to be able to use + * timing values provided by Intel LPSS driver "as is". + */ +static int +ig4iic_clk_params(const struct ig4_hw *hw, int speed, +uint16_t *scl_hcnt, uint16_t *scl_lcnt, uint16_t *sda_hold) +{ + uint32_t thigh, tlow, tf_max; /* nsec */ + uint32_t sda_fall_time; /* nsec */ +uint32_t scl_fall_time;/* nsec */ + + switch (speed) { + case IG4_CTL_SPEED_STD: + thigh = IG4_SPEED_STD_THIGH; + tlow = IG4_SPEED_STD_TLOW; + tf_max = IG4_SPEED_STD_TF_MAX; + break; + + case IG4_CTL_SPEED_FAST: + thigh = IG4_SPEED_FAST_THIGH; + tlow = IG4_SPEED_FAST_TLOW; + tf_max = IG4_SPEED_FAST_TF_MAX; + break; + + default: + return (EINVAL); + } + + /* Use slowest falling time defaults to be on the safe side */ + sda_fall_time = hw->sda_fall_time == 0 ? tf_max : hw->sda_fall_time; + *scl_hcnt = (uint16_t) + ((hw->ic_clock_rate * (thigh + sda_fall_time) + 500) / 1000 - 3); + +
svn commit: r354310 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:03:07 2019 New Revision: 354310 URL: https://svnweb.freebsd.org/changeset/base/354310 Log: [ig4] Rewrite ig4iic_write routine to use TX_EMPTY status flag rather than TX_NOTFULL. It makes possible interrupt utilization while waiting for empty space in TX FIFO. Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:01:53 2019 (r354309) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:03:07 2019 (r354310) @@ -384,21 +384,31 @@ ig4iic_write(ig4iic_softc_t *sc, uint8_t *buf, uint16_ bool repeated_start, bool stop) { uint32_t cmd; - uint16_t i; + int sent = 0; + int burst, target; int error; if (len == 0) return (0); - cmd = repeated_start ? IG4_DATA_RESTART : 0; - for (i = 0; i < len; i++) { - error = wait_status(sc, IG4_STATUS_TX_NOTFULL); - if (error) - break; - cmd |= buf[i]; - cmd |= stop && i == len - 1 ? IG4_DATA_STOP : 0; - reg_write(sc, IG4_REG_DATA_CMD, cmd); - cmd = 0; + while (sent < len) { + burst = sc->cfg.txfifo_depth - + (reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK); + target = MIN(sent + burst, (int)len); + while(sent < target) { + cmd = buf[sent]; + if (repeated_start && sent == 0) + cmd |= IG4_DATA_RESTART; + if (stop && sent == len - 1) + cmd |= IG4_DATA_STOP; + reg_write(sc, IG4_REG_DATA_CMD, cmd); + sent++; + } + if (sent < len) { + error = wait_status(sc, IG4_STATUS_TX_EMPTY); + if (error) + break; + } } (void)reg_read(sc, IG4_REG_TX_ABRT_SOURCE); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354316 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:10:47 2019 New Revision: 354316 URL: https://svnweb.freebsd.org/changeset/base/354316 Log: [ig4] On SkyLake controllers issue reset on attach unconditionally. It is very helpful during debugging of I2C issues. It is done only for SkyLakes due to lack of testing on other hardware. Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:08:26 2019 (r354315) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:10:47 2019 (r354316) @@ -995,7 +995,7 @@ ig4iic_attach(ig4iic_softc_t *sc) ig4iic_get_config(sc); - error = ig4iic_set_config(sc, false); + error = ig4iic_set_config(sc, sc->version == IG4_SKYLAKE); if (error) goto done; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354313 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 21:06:06 2019 New Revision: 354313 URL: https://svnweb.freebsd.org/changeset/base/354313 Log: [ig4] Convert polling loop from status-based to interrupt-based INTR_STAT register exposes more useful informaton then STA register does e.g. it exposes error and I2C bus STOP conditions. Make it a main source of I2C transfer state. Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:04:51 2019 (r354312) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 21:06:06 2019 (r354313) @@ -198,10 +198,10 @@ set_controller(ig4iic_softc_t *sc, uint32_t ctl) } /* - * Wait up to 25ms for the requested status using a 25uS polling loop. + * Wait up to 25ms for the requested interrupt using a 25uS polling loop. */ static int -wait_status(ig4iic_softc_t *sc, uint32_t status) +wait_intr(ig4iic_softc_t *sc, uint32_t intr) { uint32_t v; int error; @@ -215,8 +215,8 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) /* * Check requested status */ - v = reg_read(sc, IG4_REG_I2C_STA); - if (v & status) { + v = reg_read(sc, IG4_REG_RAW_INTR_STAT); + if (v & intr) { error = 0; break; } @@ -226,7 +226,7 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) * reset the timeout if we see a change in the transmit * FIFO level as progress is being made. */ - if (status & IG4_STATUS_TX_EMPTY) { + if (intr & IG4_INTR_TX_EMPTY) { v = reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK; if (txlvl != v) { txlvl = v; @@ -241,25 +241,16 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) break; /* -* When waiting for receive data let the interrupt do its -* work, otherwise poll with the lock held. +* When polling is not requested let the interrupt do its work. */ - if ((status & IG4_STATUS_RX_NOTEMPTY) && !DO_POLL(sc)) { + if (!DO_POLL(sc)) { mtx_lock(&sc->io_lock); - set_intr_mask(sc, IG4_INTR_STOP_DET | IG4_INTR_RX_FULL); + set_intr_mask(sc, intr); mtx_sleep(sc, &sc->io_lock, 0, "i2cwait", (hz + 99) / 100); /* sleep up to 10ms */ set_intr_mask(sc, 0); mtx_unlock(&sc->io_lock); count_us += 1; - } else if ((status & IG4_STATUS_TX_EMPTY) && !DO_POLL(sc)) { - mtx_lock(&sc->io_lock); - set_intr_mask(sc, IG4_INTR_TX_EMPTY); - mtx_sleep(sc, &sc->io_lock, 0, "i2cwait", - (hz + 99) / 100); /* sleep up to 10ms */ - set_intr_mask(sc, 0); - mtx_unlock(&sc->io_lock); - count_us += 1; } else { DELAY(25); count_us += 25; @@ -293,7 +284,7 @@ set_slave_addr(ig4iic_softc_t *sc, uint8_t slave) /* * Wait for TXFIFO to drain before disabling the controller. */ - wait_status(sc, IG4_STATUS_TX_EMPTY); + wait_intr(sc, IG4_INTR_TX_EMPTY); set_controller(sc, 0); ctl = reg_read(sc, IG4_REG_CTL); @@ -346,7 +337,7 @@ ig4iic_read(ig4iic_softc_t *sc, uint8_t *buf, uint16_t burst = sc->cfg.txfifo_depth - (reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK); if (burst <= 0) { - error = wait_status(sc, IG4_STATUS_TX_EMPTY); + error = wait_intr(sc, IG4_INTR_TX_EMPTY); if (error) break; burst = sc->cfg.txfifo_depth; @@ -376,7 +367,7 @@ ig4iic_read(ig4iic_softc_t *sc, uint8_t *buf, uint16_t buf[received++] = 0xFF & reg_read(sc, IG4_REG_DATA_CMD); } else { - error = wait_status(sc, IG4_STATUS_RX_NOTEMPTY); + error = wait_intr(sc, IG4_INTR_RX_FULL); if (error) goto out; } @@ -413,7 +404,7 @@ ig4iic_write(ig4iic_softc_t *sc, uint8_t *buf, uint16_ sent++; } if (sent < len) { - error = wait_status(sc
svn commit: r354307 - head/sys/dev/ichiic
Author: wulf Date: Sun Nov 3 20:59:04 2019 New Revision: 354307 URL: https://svnweb.freebsd.org/changeset/base/354307 Log: [ig4] Implement burst mode for data reads In this mode DATA_CMD register reads and writes are performed in TX/RX FIFO-sized bursts to increase I2C bus utilization. That reduces read time from 60us to 30us per byte when read data is fit in to RX FIFO buffer in FAST speed mode in my setup. Modified: head/sys/dev/ichiic/ig4_iic.c head/sys/dev/ichiic/ig4_reg.h head/sys/dev/ichiic/ig4_var.h Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:57:59 2019 (r354306) +++ head/sys/dev/ichiic/ig4_iic.c Sun Nov 3 20:59:04 2019 (r354307) @@ -100,12 +100,16 @@ static const struct ig4_hw ig4iic_hw[] = { [IG4_HASWELL] = { .ic_clock_rate = 100, /* MHz */ .sda_hold_time = 90,/* nsec */ + .txfifo_depth = 32, + .rxfifo_depth = 32, }, [IG4_ATOM] = { .ic_clock_rate = 100, .sda_fall_time = 280, .scl_fall_time = 240, .sda_hold_time = 60, + .txfifo_depth = 32, + .rxfifo_depth = 32, }, [IG4_SKYLAKE] = { .ic_clock_rate = 120, @@ -330,41 +334,67 @@ ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave) return (0); } +/* + * Amount of unread data before next burst to get better I2C bus utilization. + * 2 bytes is enough in FAST mode. 8 bytes is better in FAST+ and HIGH modes. + * Intel-recommended value is 16 for DMA transfers with 64-byte depth FIFOs. + */ +#defineIG4_FIFO_LOWAT 2 + static int ig4iic_read(ig4iic_softc_t *sc, uint8_t *buf, uint16_t len, bool repeated_start, bool stop) { uint32_t cmd; - uint16_t i; + int requested = 0; + int received = 0; + int burst, target, lowat = 0; int error; if (len == 0) return (0); - cmd = IG4_DATA_COMMAND_RD; - cmd |= repeated_start ? IG4_DATA_RESTART : 0; - cmd |= stop && len == 1 ? IG4_DATA_STOP : 0; - - /* Issue request for the first byte (could be last as well). */ - reg_write(sc, IG4_REG_DATA_CMD, cmd); - - for (i = 0; i < len; i++) { - /* -* Maintain a pipeline by queueing the allowance for the next -* read before waiting for the current read. -*/ - cmd = IG4_DATA_COMMAND_RD; - if (i < len - 1) { + while (received < len) { + burst = sc->cfg.txfifo_depth - + (reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK); + /* Ensure we have enough free space in RXFIFO */ + burst = MIN(burst, sc->cfg.rxfifo_depth - lowat); + if (burst <= 0) { + error = wait_status(sc, IG4_STATUS_TX_NOTFULL); + if (error) + break; + burst = 1; + } + target = MIN(requested + burst, (int)len); + while (requested < target) { cmd = IG4_DATA_COMMAND_RD; - cmd |= stop && i == len - 2 ? IG4_DATA_STOP : 0; + if (repeated_start && requested == 0) + cmd |= IG4_DATA_RESTART; + if (stop && requested == len - 1) + cmd |= IG4_DATA_STOP; reg_write(sc, IG4_REG_DATA_CMD, cmd); + requested++; } - error = wait_status(sc, IG4_STATUS_RX_NOTEMPTY); - if (error) - break; - buf[i] = (uint8_t)reg_read(sc, IG4_REG_DATA_CMD); + /* Leave some data queued to maintain the hardware pipeline */ + lowat = 0; + if (requested != len && requested - received > IG4_FIFO_LOWAT) + lowat = IG4_FIFO_LOWAT; + /* After TXFLR fills up, clear it by reading available data */ + while (received < requested - lowat) { + burst = MIN((int)len - received, + reg_read(sc, IG4_REG_RXFLR) & IG4_FIFOLVL_MASK); + if (burst > 0) { + while (burst--) + buf[received++] = 0xFF & + reg_read(sc, IG4_REG_DATA_CMD); + } else { + error = wait_status(sc, IG4_STATUS_RX_NOTEMPTY); + if (error) + goto out; + } + } } - +out: (void)reg_read(sc, IG4_REG_TX_ABRT_S
svn commit: r352243 - head/sys/dev/ichiic
Author: wulf Date: Thu Sep 12 12:33:09 2019 New Revision: 352243 URL: https://svnweb.freebsd.org/changeset/base/352243 Log: ig4(4): Fix SDA HOLD time set too low on Skylake controllers Execution of "Soft reset" command (IG4_REG_RESETS_SKL) at controller init stage sets SDA_HOLD register value to 0x0001 which is often too low for normal operation. Set SDA_HOLD back to 28 after reset to restore controller functionality. PR: 240339 Reported by: imp, GregV, et al. MFC after:3 days Modified: head/sys/dev/ichiic/ig4_iic.c Modified: head/sys/dev/ichiic/ig4_iic.c == --- head/sys/dev/ichiic/ig4_iic.c Thu Sep 12 08:54:48 2019 (r352242) +++ head/sys/dev/ichiic/ig4_iic.c Thu Sep 12 12:33:09 2019 (r352243) @@ -590,6 +590,8 @@ ig4iic_attach(ig4iic_softc_t *sc) reg_write(sc, IG4_REG_SS_SCL_LCNT, 125); reg_write(sc, IG4_REG_FS_SCL_HCNT, 100); reg_write(sc, IG4_REG_FS_SCL_LCNT, 125); + if (sc->version == IG4_SKYLAKE) + reg_write(sc, IG4_REG_SDA_HOLD, 28); /* * Use a threshold of 1 so we get interrupted on each character, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r346456 - head/sys/dev/atkbdc
Author: wulf Date: Sat Apr 20 21:02:41 2019 New Revision: 346456 URL: https://svnweb.freebsd.org/changeset/base/346456 Log: psm(4): do not process gestures when palm is present Ignoring of gesture processing when the palm is detected helps to reduce some of the erratic pointer behavior. This fixes regression introduced in r317814 Reported by: Ben LeMasurier MFC after:2 weeks Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Apr 20 21:00:44 2019(r346455) +++ head/sys/dev/atkbdc/psm.c Sat Apr 20 21:02:41 2019(r346456) @@ -3214,7 +3214,7 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, static int guest_buttons; static int ew_finger_count; static finger_t f[PSM_FINGERS]; - int w, id, nfingers, ewcode, extended_buttons, clickpad_pressed; + int w, id, nfingers, palm, ewcode, extended_buttons, clickpad_pressed; extended_buttons = 0; @@ -3577,12 +3577,16 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, ms->button = touchpad_buttons; - psmgestures(sc, &f[0], nfingers, ms); + palm = psmpalmdetect(sc, &f[0], nfingers); + + /* Palm detection doesn't terminate the current action. */ + if (!palm) + psmgestures(sc, &f[0], nfingers, ms); + for (id = 0; id < PSM_FINGERS; id++) psmsmoother(sc, &f[id], id, ms, x, y); - /* Palm detection doesn't terminate the current action. */ - if (psmpalmdetect(sc, &f[0], nfingers)) { + if (palm) { *x = *y = *z = 0; ms->button = ms->obutton; return (0); @@ -4324,7 +4328,7 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m { static int touchpad_button, trackpoint_button; finger_t fn, f[ELANTECH_MAX_FINGERS]; - int pkt, id, scale, i, nfingers, mask; + int pkt, id, scale, i, nfingers, mask, palm; if (!elantech_support) return (0); @@ -4713,10 +4717,14 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m ms->button = touchpad_button | trackpoint_button; + /* Palm detection doesn't terminate the current action. */ + palm = psmpalmdetect(sc, &f[0], nfingers); + /* Send finger 1 position to gesture processor */ - if (PSM_FINGER_IS_SET(f[0]) || PSM_FINGER_IS_SET(f[1]) || - nfingers == 0) + if ((PSM_FINGER_IS_SET(f[0]) || PSM_FINGER_IS_SET(f[1]) || + nfingers == 0) && !palm) psmgestures(sc, &f[0], imin(nfingers, 3), ms); + /* Send fingers positions to movement smoothers */ for (id = 0; id < PSM_FINGERS; id++) if (PSM_FINGER_IS_SET(f[id]) || !(mask & (1 << id))) @@ -4731,8 +4739,7 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m } sc->elanaction.mask = mask; - /* Palm detection doesn't terminate the current action. */ - if (psmpalmdetect(sc, &f[0], nfingers)) { + if (palm) { *x = *y = *z = 0; ms->button = ms->obutton; return (0); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r346458 - head/sys/dev/atkbdc
Author: wulf Date: Sat Apr 20 21:06:12 2019 New Revision: 346458 URL: https://svnweb.freebsd.org/changeset/base/346458 Log: psm(4): give names to synaptics commands Submitted by: Ben LeMasurier MFC after:2 weeks Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Apr 20 21:04:56 2019(r346457) +++ head/sys/dev/atkbdc/psm.c Sat Apr 20 21:06:12 2019(r346458) @@ -178,6 +178,22 @@ typedef struct packetbuf { #definePSM_PACKETQUEUE 128 #endif +/* + * Synaptics command definitions. + */ +#defineSYNAPTICS_READ_IDENTITY 0x00 +#defineSYNAPTICS_READ_MODES0x01 +#defineSYNAPTICS_READ_CAPABILITIES 0x02 +#defineSYNAPTICS_READ_MODEL_ID 0x03 +#defineSYNAPTICS_READ_SERIAL_PREFIX0x06 +#defineSYNAPTICS_READ_SERIAL_SUFFIX0x07 +#defineSYNAPTICS_READ_RESOLUTIONS 0x08 +#defineSYNAPTICS_READ_EXTENDED 0x09 +#defineSYNAPTICS_READ_CAPABILITIES_CONT0x0c +#defineSYNAPTICS_READ_MAX_COORDS 0x0d +#defineSYNAPTICS_READ_DELUXE_LED 0x0e +#defineSYNAPTICS_READ_MIN_COORDS 0x0f + typedef struct synapticsinfo { struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; @@ -1119,7 +1135,7 @@ doopen(struct psm_softc *sc, int command_byte) "active multiplexing mode.\n", sc->unit); } - mouse_ext_command(sc->kbdc, 1); + mouse_ext_command(sc->kbdc, SYNAPTICS_READ_MODES); get_mouse_status(sc->kbdc, stat, 0, 3); if ((SYNAPTICS_VERSION_GE(sc->synhw, 7, 5) || stat[1] == 0x47) && @@ -6158,7 +6174,7 @@ synaptics_set_mode(struct psm_softc *sc, int mode_byte */ if ((sc->synhw.capAdvancedGestures || sc->synhw.capReportsV) && sc->hw.model == MOUSE_MODEL_SYNAPTICS && !(mode_byte & (1 << 5))) { - mouse_ext_command(sc->kbdc, 3); + mouse_ext_command(sc->kbdc, SYNAPTICS_READ_MODEL_ID); set_mouse_sampling_rate(sc->kbdc, 0xc8); } } @@ -6238,7 +6254,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a set_mouse_scaling(kbdc, 1); /* Identify the Touchpad version. */ - if (mouse_ext_command(kbdc, 0) == 0) + if (mouse_ext_command(kbdc, SYNAPTICS_READ_IDENTITY) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6259,7 +6275,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a } /* Get the Touchpad model information. */ - if (mouse_ext_command(kbdc, 3) == 0) + if (mouse_ext_command(kbdc, SYNAPTICS_READ_MODEL_ID) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6290,7 +6306,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a } /* Read the extended capability bits. */ - if (mouse_ext_command(kbdc, 2) == 0) + if (mouse_ext_command(kbdc, SYNAPTICS_READ_CAPABILITIES) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6321,7 +6337,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a if (!set_mouse_scaling(kbdc, 1)) return (FALSE); - if (mouse_ext_command(kbdc, 0x08) == 0) + if (mouse_ext_command(kbdc, SYNAPTICS_READ_RESOLUTIONS) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6358,7 +6374,8 @@ enable_synaptics(struct psm_softc *sc, enum probearg a if (synhw.nExtendedQueries >= 1) { if (!set_mouse_scaling(kbdc, 1)) return (FALSE); - if (mouse_ext_command(kbdc, 0x09) == 0) + if (mouse_ext_command(kbdc, + SYNAPTICS_READ_EXTENDED) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6397,7 +6414,8 @@ enable_synaptics(struct psm_softc *sc, enum probearg a if (synhw.nExtendedQueries >= 4) { if (!set_mouse_scaling(kbdc, 1)) return (FALSE); - if (mouse_ext_command(kbdc, 0x0c) == 0) + if (mouse_ext_command(kbdc, + SYNAPTICS_READ_CAPABILITIES_CONT) == 0)
svn commit: r346455 - head/sys/dev/atkbdc
Author: wulf Date: Sat Apr 20 21:00:44 2019 New Revision: 346455 URL: https://svnweb.freebsd.org/changeset/base/346455 Log: psm(4): Add support for 4 and 5 finger touches in synaptics driver While 4-th and 5-th finger positions are not exported through PS/2 interface, total number of touches is reported by MT trackpads. MFC after:2 weeks Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Apr 20 20:29:03 2019(r346454) +++ head/sys/dev/atkbdc/psm.c Sat Apr 20 21:00:44 2019(r346455) @@ -1830,7 +1830,7 @@ psm_register_synaptics(device_t dev) if (sc->synhw.capClickPad && sc->synhw.topButtonPad) evdev_support_prop(evdev_a, INPUT_PROP_TOPBUTTONPAD); evdev_support_key(evdev_a, BTN_TOUCH); - evdev_support_nfingers(evdev_a, 3); + evdev_support_nfingers(evdev_a, sc->synhw.capReportsV ? 5 : 3); psm_support_abs_bulk(evdev_a, synaptics_absinfo_st); if (sc->synhw.capAdvancedGestures || sc->synhw.capReportsV) psm_support_abs_bulk(evdev_a, synaptics_absinfo_mt); @@ -3212,6 +3212,7 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, { static int touchpad_buttons; static int guest_buttons; + static int ew_finger_count; static finger_t f[PSM_FINGERS]; int w, id, nfingers, ewcode, extended_buttons, clickpad_pressed; @@ -3372,6 +3373,9 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, (pb->ipacket[1] & 0x01)) + 8, .flags = PSM_FINGER_FUZZY, }; + break; + case 2: + ew_finger_count = pb->ipacket[1] & 0x0f; default: break; } @@ -3379,6 +3383,11 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, goto SYNAPTICS_END; case 1: + if (sc->synhw.capReportsV && ew_finger_count > 3) { + nfingers = ew_finger_count; + break; + } + /* FALLTHROUGH */ case 0: nfingers = w + 2; break; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r346457 - in head: share/man/man4 sys/dev/atkbdc
Author: wulf Date: Sat Apr 20 21:04:56 2019 New Revision: 346457 URL: https://svnweb.freebsd.org/changeset/base/346457 Log: psm(4): respect tap_disabled configuration with enabled Extended support This fixes a bug where, even when hw.psm.tap_enabled=0, touchpad taps were processed. tap_enabled has three states: unconfigured, disabled, and enabled (-1, 0, 1). To respect PR kern/139272, taps are ignored only when explicity disabled. Submitted by: Ben LeMasurier (initial version) MFC after:2 weeks Modified: head/share/man/man4/psm.4 head/sys/dev/atkbdc/psm.c Modified: head/share/man/man4/psm.4 == --- head/share/man/man4/psm.4 Sat Apr 20 21:02:41 2019(r346456) +++ head/share/man/man4/psm.4 Sat Apr 20 21:04:56 2019(r346457) @@ -354,8 +354,8 @@ Tap and drag gestures can be disabled by setting to .Em 0 at boot-time. -Currently, this is only supported on Synaptics touchpads with Extended -support disabled. +Currently, this is supported on Synaptics touchpads regardless of Extended +support state and on Elantech touchpads with Extended support enabled. The behaviour may be changed after boot by setting the sysctl with the same name and by restarting .Xr moused 8 Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Apr 20 21:02:41 2019(r346456) +++ head/sys/dev/atkbdc/psm.c Sat Apr 20 21:04:56 2019(r346457) @@ -3820,9 +3820,15 @@ psmgestures(struct psm_softc *sc, finger_t *fingers, i gest->in_vscroll = 0; /* Compute tap timeout. */ - gest->taptimeout.tv_sec = tap_timeout / 100; - gest->taptimeout.tv_usec = tap_timeout % 100; - timevaladd(&gest->taptimeout, &sc->lastsoftintr); + if (tap_enabled != 0) { + gest->taptimeout = (struct timeval) { + .tv_sec = tap_timeout / 100, + .tv_usec = tap_timeout % 100, + }; + timevaladd( + &gest->taptimeout, &sc->lastsoftintr); + } else + timevalclear(&gest->taptimeout); sc->flags |= PSM_FLAGS_FINGERDOWN; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r351199 - head/usr.sbin/bluetooth/iwmbtfw
Author: wulf Date: Sun Aug 18 23:10:07 2019 New Revision: 351199 URL: https://svnweb.freebsd.org/changeset/base/351199 Log: iwmbtfw(8): Fix compilation on platforms using gcc. X-MFC with: r351197 Modified: head/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c Modified: head/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c == --- head/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c Sun Aug 18 23:07:56 2019 (r351198) +++ head/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c Sun Aug 18 23:10:07 2019 (r351199) @@ -68,7 +68,7 @@ iwmbt_send_fragment(struct libusb_device_handle *hdl, &transferred, timeout); - if (ret < 0 || transferred != IWMBT_HCI_CMD_SIZE(cmd)) { + if (ret < 0 || transferred != (int)IWMBT_HCI_CMD_SIZE(cmd)) { iwmbt_err("libusb_bulk_transfer() failed: err=%s, size=%zu", libusb_strerror(ret), IWMBT_HCI_CMD_SIZE(cmd)); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r351197 - in head: targets/pseudo/userland tools/build/mk usr.sbin/bluetooth usr.sbin/bluetooth/iwmbtfw
Author: wulf Date: Sun Aug 18 22:20:28 2019 New Revision: 351197 URL: https://svnweb.freebsd.org/changeset/base/351197 Log: iwmbtfw: Firmware loader for Intel Wireless 8260 based Bluetooth USB devices Currently supported models are: 8260, 8265, 9560, 9260 and 22161. Firmware files can be installed with comms/iwmbt-firmware port. PR: 237083 Reviewed by: hps, emax X-MFC with: r351196 Differential Revision:https://reviews.freebsd.org/D21071 Added: head/usr.sbin/bluetooth/iwmbtfw/ head/usr.sbin/bluetooth/iwmbtfw/Makefile (contents, props changed) head/usr.sbin/bluetooth/iwmbtfw/iwmbt_dbg.h (contents, props changed) head/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.c (contents, props changed) head/usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.h (contents, props changed) head/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c (contents, props changed) head/usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.h (contents, props changed) head/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8 (contents, props changed) head/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf (contents, props changed) head/usr.sbin/bluetooth/iwmbtfw/main.c (contents, props changed) Modified: head/targets/pseudo/userland/Makefile.depend head/tools/build/mk/OptionalObsoleteFiles.inc head/usr.sbin/bluetooth/Makefile Modified: head/targets/pseudo/userland/Makefile.depend == --- head/targets/pseudo/userland/Makefile.dependSun Aug 18 22:11:42 2019(r351196) +++ head/targets/pseudo/userland/Makefile.dependSun Aug 18 22:20:28 2019(r351197) @@ -443,6 +443,7 @@ DIRDEPS+= \ usr.sbin/bluetooth/hccontrol \ usr.sbin/bluetooth/hcsecd \ usr.sbin/bluetooth/hcseriald \ + usr.sbin/bluetooth/iwmbtfw \ usr.sbin/bluetooth/l2control \ usr.sbin/bluetooth/l2ping \ usr.sbin/bluetooth/rfcomm_pppd \ Modified: head/tools/build/mk/OptionalObsoleteFiles.inc == --- head/tools/build/mk/OptionalObsoleteFiles.inc Sun Aug 18 22:11:42 2019(r351196) +++ head/tools/build/mk/OptionalObsoleteFiles.inc Sun Aug 18 22:20:28 2019(r351197) @@ -471,6 +471,7 @@ OLD_FILES+=etc/bluetooth/hcsecd.conf OLD_FILES+=etc/bluetooth/hosts OLD_FILES+=etc/bluetooth/protocols OLD_FILES+=etc/defaults/bluetooth.device.conf +OLD_FILES+=etc/devd/iwmbtfw.conf OLD_DIRS+=etc/bluetooth OLD_FILES+=etc/rc.d/bluetooth OLD_FILES+=etc/rc.d/bthidd @@ -524,6 +525,7 @@ OLD_FILES+=usr/sbin/btpand OLD_FILES+=usr/sbin/hccontrol OLD_FILES+=usr/sbin/hcsecd OLD_FILES+=usr/sbin/hcseriald +OLD_FILES+=usr/sbin/iwmbtfw OLD_FILES+=usr/sbin/l2control OLD_FILES+=usr/sbin/l2ping OLD_FILES+=usr/sbin/rfcomm_pppd @@ -601,6 +603,7 @@ OLD_FILES+=usr/share/man/man8/btpand.8.gz OLD_FILES+=usr/share/man/man8/hccontrol.8.gz OLD_FILES+=usr/share/man/man8/hcsecd.8.gz OLD_FILES+=usr/share/man/man8/hcseriald.8.gz +OLD_FILES+=usr/share/man/man8/iwmbtfw.8.gz OLD_FILES+=usr/share/man/man8/l2control.8.gz OLD_FILES+=usr/share/man/man8/l2ping.8.gz OLD_FILES+=usr/share/man/man8/rfcomm_pppd.8.gz Modified: head/usr.sbin/bluetooth/Makefile == --- head/usr.sbin/bluetooth/MakefileSun Aug 18 22:11:42 2019 (r351196) +++ head/usr.sbin/bluetooth/MakefileSun Aug 18 22:20:28 2019 (r351197) @@ -21,6 +21,7 @@ SUBDIR+= ath3kfw SUBDIR+= bcmfw SUBDIR+= bthidcontrol SUBDIR+= bthidd +SUBDIR+= iwmbtfw .endif .include Added: head/usr.sbin/bluetooth/iwmbtfw/Makefile == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/bluetooth/iwmbtfw/MakefileSun Aug 18 22:20:28 2019 (r351197) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +PACKAGE= bluetooth +CONFS= iwmbtfw.conf +CONFSDIR= /etc/devd +PROG= iwmbtfw +MAN= iwmbtfw.8 +LIBADD+= usb +SRCS= main.c iwmbt_fw.c iwmbt_hw.c + +.include Added: head/usr.sbin/bluetooth/iwmbtfw/iwmbt_dbg.h == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/bluetooth/iwmbtfw/iwmbt_dbg.h Sun Aug 18 22:20:28 2019 (r351197) @@ -0,0 +1,47 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2013 Adrian Chadd + * Copyright (c) 2019 Vladimir Kondratyev + * + * 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
svn commit: r351196 - in head/sys: conf modules/netgraph/bluetooth/ubt netgraph/bluetooth/drivers/ubt
+ struct usb_device_request req; + struct usb_xfer *xfer[1]; + struct mtx mtx; + usb_error_t error = USB_ERR_NORMAL_COMPLETION; + uint8_t iface_index = 0; + + /* Initialize a USB control request and then do it */ + bzero(&req, sizeof(req)); + req.bmRequestType = UBT_HCI_REQUEST; + req.wIndex[0] = iface_index; + USETW(req.wLength, UBT_HCI_CMD_SIZE(cmd)); + + error = usbd_do_request(udev, NULL, &req, cmd); + if (error != USB_ERR_NORMAL_COMPLETION) { + printf("ng_ubt: usbd_do_request error=%s\n", + usbd_errstr(error)); + return (error); + } + + if (evt == NULL) + return (USB_ERR_NORMAL_COMPLETION); + + /* Initialize INTR endpoint xfer and wait for response */ + mtx_init(&mtx, "ubt pb", NULL, MTX_DEF); + + error = usbd_transfer_setup(udev, &iface_index, xfer, + &ubt_probe_config, 1, evt, &mtx); + if (error == USB_ERR_NORMAL_COMPLETION) { + + mtx_lock(&mtx); + usbd_transfer_start(*xfer); + + if (msleep_sbt(evt, &mtx, 0, "ubt pb", SBT_1MS * timeout, + 0, C_HARDCLOCK) == EWOULDBLOCK) { + printf("ng_ubt: HCI command 0x%04x timed out\n", + le16toh(cmd->opcode)); + error = USB_ERR_TIMEOUT; + } + + usbd_transfer_stop(*xfer); + mtx_unlock(&mtx); + + usbd_transfer_unsetup(xfer, 1); + } else + printf("ng_ubt: usbd_transfer_setup error=%s\n", + usbd_errstr(error)); + + mtx_destroy(&mtx); + + return (error); +} + +/* * Probe for a USB Bluetooth device. * USB context. */ @@ -717,6 +798,49 @@ ubt_detach(device_t dev) return (0); } /* ubt_detach */ +/* + * Called when incoming interrupt transfer (HCI event) has completed, i.e. + * HCI event was received from the device during device probe stage. + * USB context. + */ + +static void +ubt_probe_intr_callback(struct usb_xfer *xfer, usb_error_t error) +{ + struct ubt_hci_event*evt = usbd_xfer_softc(xfer); + struct usb_page_cache *pc; + int actlen; + + usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL); + + switch (USB_GET_STATE(xfer)) { + case USB_ST_TRANSFERRED: + if (actlen > UBT_HCI_EVENT_SIZE(evt)) + actlen = UBT_HCI_EVENT_SIZE(evt); + pc = usbd_xfer_get_frame(xfer, 0); + usbd_copy_out(pc, 0, evt, actlen); + /* OneShot mode */ + wakeup(evt); + break; + +case USB_ST_SETUP: +submit_next: + /* Try clear stall first */ + usbd_xfer_set_stall(xfer); + usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer)); + usbd_transfer_submit(xfer); + break; + + default: + if (error != USB_ERR_CANCELLED) { + printf("ng_ubt: interrupt transfer failed: %s\n", + usbd_errstr(error)); + goto submit_next; + } + break; + } +} /* ubt_probe_intr_callback */ + /* * Called when outgoing control request (HCI command) has completed, i.e. * HCI command was sent to the device. @@ -1852,7 +1976,7 @@ ubt_modevent(module_t mod, int event, void *data) return (error); } /* ubt_modevent */ -static devclass_t ubt_devclass; +devclass_t ubt_devclass; static device_method_t ubt_methods[] = { @@ -1862,7 +1986,7 @@ static device_method_tubt_methods[] = DEVMETHOD_END }; -static driver_tubt_driver = +driver_t ubt_driver = { .name ="ubt", .methods = ubt_methods, Added: head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c Sun Aug 18 22:11:42 2019(r351196) @@ -0,0 +1,161 @@ +/* + * ng_ubt_intel.c + */ + +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 Vladimir Kondratyev + * + * 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 mater
svn commit: r348818 - head/sys/dev/atkbdc
Author: wulf Date: Sat Jun 8 21:36:22 2019 New Revision: 348818 URL: https://svnweb.freebsd.org/changeset/base/348818 Log: psm(4): Add extra sanity checks to Elantech trackpoint packet parser. Add strict checks for unused bit states in Elantech trackpoint packet parser to filter out spurious events produces by some hardware which are detected as trackpoint packets. See comment on r328191 for example. Tested by:Andrey Kosachenko Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Jun 8 21:33:34 2019(r348817) +++ head/sys/dev/atkbdc/psm.c Sat Jun 8 21:36:22 2019(r348818) @@ -4687,22 +4687,32 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m * over 9 bits with SX/SY the relative top bit and * X7..X0 and Y7..Y0 the lower bits. */ - *x = (pb->ipacket[0] & MOUSE_PS2_XNEG) ? - pb->ipacket[4] - 256 : pb->ipacket[4]; - *y = (pb->ipacket[0] & MOUSE_PS2_YNEG) ? - pb->ipacket[5] - 256 : pb->ipacket[5]; + if (!(pb->ipacket[0] & 0xC8) && !(pb->ipacket[1] & 0x7F) && + !(pb->ipacket[2] & 0x7F) && !(pb->ipacket[3] & 0xC9) && + !(pb->ipacket[0] & 0x10) != !(pb->ipacket[1] & 0x80) && + !(pb->ipacket[0] & 0x10) != !(pb->ipacket[3] & 0x10) && + !(pb->ipacket[0] & 0x20) != !(pb->ipacket[2] & 0x80) && + !(pb->ipacket[0] & 0x20) != !(pb->ipacket[3] & 0x20)) { - trackpoint_button = - ((pb->ipacket[0] & 0x01) ? MOUSE_BUTTON1DOWN : 0) | - ((pb->ipacket[0] & 0x02) ? MOUSE_BUTTON3DOWN : 0) | - ((pb->ipacket[0] & 0x04) ? MOUSE_BUTTON2DOWN : 0); + *x = (pb->ipacket[0] & MOUSE_PS2_XNEG) ? + pb->ipacket[4] - 256 : pb->ipacket[4]; + *y = (pb->ipacket[0] & MOUSE_PS2_YNEG) ? + pb->ipacket[5] - 256 : pb->ipacket[5]; + + trackpoint_button = + ((pb->ipacket[0] & 0x01) ? MOUSE_BUTTON1DOWN : 0) | + ((pb->ipacket[0] & 0x02) ? MOUSE_BUTTON3DOWN : 0) | + ((pb->ipacket[0] & 0x04) ? MOUSE_BUTTON2DOWN : 0); #ifdef EVDEV_SUPPORT - evdev_push_rel(sc->evdev_r, REL_X, *x); - evdev_push_rel(sc->evdev_r, REL_Y, -*y); - evdev_push_mouse_btn(sc->evdev_r, trackpoint_button); - evdev_sync(sc->evdev_r); + evdev_push_rel(sc->evdev_r, REL_X, *x); + evdev_push_rel(sc->evdev_r, REL_Y, -*y); + evdev_push_mouse_btn(sc->evdev_r, trackpoint_button); + evdev_sync(sc->evdev_r); #endif - ms->button = touchpad_button | trackpoint_button; + ms->button = touchpad_button | trackpoint_button; + } else + VLOG(3, (LOG_DEBUG, "elantech: " + "unexpected trackpoint packet skipped\n")); return (0); case ELANTECH_PKT_NOP: ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r348817 - head/sys/dev/atkbdc
Author: wulf Date: Sat Jun 8 21:33:34 2019 New Revision: 348817 URL: https://svnweb.freebsd.org/changeset/base/348817 Log: psm(4): Fix Elantech trackpoint support. Sign bits for X and Y motion data were taken from wrong places. PR: 238291 Reported by: Andrey Kosachenko Tested by:Andrey Kosachenko MFC after:2 weeks Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Jun 8 20:28:04 2019(r348816) +++ head/sys/dev/atkbdc/psm.c Sat Jun 8 21:33:34 2019(r348817) @@ -4676,7 +4676,7 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m case ELANTECH_PKT_TRACKPOINT: /* 7 6 5 4 3 2 1 0 (LSB) * --- -* ipacket[0]: 0 0 SX SY 0 M R L +* ipacket[0]: 0 0 SY SX 0 M R L * ipacket[1]: ~SX 0 0 0 0 0 0 0 * ipacket[2]: ~SY 0 0 0 0 0 0 0 * ipacket[3]: 0 0 ~SY ~SX 0 1 1 0 @@ -4687,9 +4687,9 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m * over 9 bits with SX/SY the relative top bit and * X7..X0 and Y7..Y0 the lower bits. */ - *x = (pb->ipacket[0] & 0x20) ? + *x = (pb->ipacket[0] & MOUSE_PS2_XNEG) ? pb->ipacket[4] - 256 : pb->ipacket[4]; - *y = (pb->ipacket[0] & 0x10) ? + *y = (pb->ipacket[0] & MOUSE_PS2_YNEG) ? pb->ipacket[5] - 256 : pb->ipacket[5]; trackpoint_button = ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r348529 - head/sys/dev/atkbdc
Author: wulf Date: Mon Jun 3 10:04:34 2019 New Revision: 348529 URL: https://svnweb.freebsd.org/changeset/base/348529 Log: psm(4): Add natural scrolling support to sysmouse protocol This change enables natural scrolling with two finger scroll enabled and when user is using a trackpad (mouse and trackpoint are not affected). Depending on trackpad model it can be activated with setting of hw.psm.synaptics.natural_scroll or hw.psm.elantech.natural_scroll sysctl values to 1. Evdev protocol is not affected by this change too. Tune userland client e.g. libinput to enable natural scrolling in that case. Submitted by: nyan_myuji.xyz Reviewed by: wulf MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D20447 Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Mon Jun 3 07:57:54 2019(r348528) +++ head/sys/dev/atkbdc/psm.c Mon Jun 3 10:04:34 2019(r348529) @@ -236,6 +236,7 @@ typedef struct synapticsinfo { int softbutton3_x; int max_x; int max_y; + int natural_scroll; } synapticsinfo_t; typedef struct synapticspacket { @@ -571,6 +572,8 @@ enum { SYNAPTICS_SYSCTL_SOFTBUTTONS_Y =SYN_OFFSET(softbuttons_y), SYNAPTICS_SYSCTL_SOFTBUTTON2_X =SYN_OFFSET(softbutton2_x), SYNAPTICS_SYSCTL_SOFTBUTTON3_X =SYN_OFFSET(softbutton3_x), + SYNAPTICS_SYSCTL_NATURAL_SCROLL = SYN_OFFSET(natural_scroll), +#defineSYNAPTICS_SYSCTL_LAST SYNAPTICS_SYSCTL_NATURAL_SCROLL }; /* packet formatting function */ @@ -4134,6 +4137,7 @@ psmsmoother(struct psm_softc *sc, finger_t *f, int smo int len, weight_prev_x, weight_prev_y; int div_max_x, div_max_y, div_x, div_y; int is_fuzzy; + int natural_scroll; /* Read sysctl. */ /* XXX Verify values? */ @@ -4161,6 +4165,7 @@ psmsmoother(struct psm_softc *sc, finger_t *f, int smo two_finger_scroll = sc->syninfo.two_finger_scroll; max_x = sc->syninfo.max_x; max_y = sc->syninfo.max_y; + natural_scroll = sc->syninfo.natural_scroll; is_fuzzy = (f->flags & PSM_FINGER_FUZZY) != 0; @@ -4322,14 +4327,24 @@ psmsmoother(struct psm_softc *sc, finger_t *f, int smo smoother_id, dx, dy, dxp, dyp)); break; case 1: /* Vertical scrolling. */ - if (dyp != 0) - ms->button |= (dyp > 0) ? - MOUSE_BUTTON4DOWN : MOUSE_BUTTON5DOWN; + if (dyp != 0) { + if (two_finger_scroll && natural_scroll) + ms->button |= (dyp > 0) ? + MOUSE_BUTTON5DOWN : MOUSE_BUTTON4DOWN; + else + ms->button |= (dyp > 0) ? + MOUSE_BUTTON4DOWN : MOUSE_BUTTON5DOWN; + } break; case 2: /* Horizontal scrolling. */ - if (dxp != 0) - ms->button |= (dxp > 0) ? - MOUSE_BUTTON7DOWN : MOUSE_BUTTON6DOWN; + if (dxp != 0) { + if (two_finger_scroll && natural_scroll) + ms->button |= (dxp > 0) ? + MOUSE_BUTTON6DOWN : MOUSE_BUTTON7DOWN; + else + ms->button |= (dxp > 0) ? + MOUSE_BUTTON7DOWN : MOUSE_BUTTON6DOWN; + } break; } @@ -5641,7 +5656,7 @@ synaptics_sysctl(SYSCTL_HANDLER_ARGS) int error, arg; if (oidp->oid_arg1 == NULL || oidp->oid_arg2 < 0 || - oidp->oid_arg2 > SYNAPTICS_SYSCTL_SOFTBUTTON3_X) + oidp->oid_arg2 > SYNAPTICS_SYSCTL_LAST) return (EINVAL); sc = oidp->oid_arg1; @@ -5730,6 +5745,7 @@ synaptics_sysctl(SYSCTL_HANDLER_ARGS) return (EINVAL); break; case SYNAPTICS_SYSCTL_TOUCHPAD_OFF: + case SYNAPTICS_SYSCTL_NATURAL_SCROLL: if (arg < 0 || arg > 1) return (EINVAL); break; @@ -6121,6 +6137,15 @@ synaptics_sysctl_create_tree(struct psm_softc *sc, con sc, SYNAPTICS_SYSCTL_TOUCHPAD_OFF, synaptics_sysctl, "I", "Turn off touchpad"); + + /* hw.psm.syn
svn commit: r348520 - head/sys/dev/atkbdc
Author: wulf Date: Sun Jun 2 22:27:26 2019 New Revision: 348520 URL: https://svnweb.freebsd.org/changeset/base/348520 Log: psm(4): Add Elantech touchpad IC type 15 found on Thinkpad L480 laptops PR: 238291 Submitted by: Andrey Kosachenko MFC after:2 weeks Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sun Jun 2 20:52:21 2019(r348519) +++ head/sys/dev/atkbdc/psm.c Sun Jun 2 22:27:26 2019(r348520) @@ -7114,7 +7114,7 @@ enable_elantech(struct psm_softc *sc, enum probearg ar { static const int ic2hw[] = /*IC: 0 1 2 3 4 5 6 7 8 9 a b c d e f */ - { 0, 0, 2, 0, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0 }; + { 0, 0, 2, 0, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; static const int fw_sizes[][3] = { /* FW.vers MaxX MaxY */ { 0x020030, 1152, 768 }, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r346458 - head/sys/dev/atkbdc
Author: wulf Date: Sat Apr 20 21:06:12 2019 New Revision: 346458 URL: https://svnweb.freebsd.org/changeset/base/346458 Log: psm(4): give names to synaptics commands Submitted by: Ben LeMasurier MFC after:2 weeks Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Apr 20 21:04:56 2019(r346457) +++ head/sys/dev/atkbdc/psm.c Sat Apr 20 21:06:12 2019(r346458) @@ -178,6 +178,22 @@ typedef struct packetbuf { #definePSM_PACKETQUEUE 128 #endif +/* + * Synaptics command definitions. + */ +#defineSYNAPTICS_READ_IDENTITY 0x00 +#defineSYNAPTICS_READ_MODES0x01 +#defineSYNAPTICS_READ_CAPABILITIES 0x02 +#defineSYNAPTICS_READ_MODEL_ID 0x03 +#defineSYNAPTICS_READ_SERIAL_PREFIX0x06 +#defineSYNAPTICS_READ_SERIAL_SUFFIX0x07 +#defineSYNAPTICS_READ_RESOLUTIONS 0x08 +#defineSYNAPTICS_READ_EXTENDED 0x09 +#defineSYNAPTICS_READ_CAPABILITIES_CONT0x0c +#defineSYNAPTICS_READ_MAX_COORDS 0x0d +#defineSYNAPTICS_READ_DELUXE_LED 0x0e +#defineSYNAPTICS_READ_MIN_COORDS 0x0f + typedef struct synapticsinfo { struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; @@ -1119,7 +1135,7 @@ doopen(struct psm_softc *sc, int command_byte) "active multiplexing mode.\n", sc->unit); } - mouse_ext_command(sc->kbdc, 1); + mouse_ext_command(sc->kbdc, SYNAPTICS_READ_MODES); get_mouse_status(sc->kbdc, stat, 0, 3); if ((SYNAPTICS_VERSION_GE(sc->synhw, 7, 5) || stat[1] == 0x47) && @@ -6158,7 +6174,7 @@ synaptics_set_mode(struct psm_softc *sc, int mode_byte */ if ((sc->synhw.capAdvancedGestures || sc->synhw.capReportsV) && sc->hw.model == MOUSE_MODEL_SYNAPTICS && !(mode_byte & (1 << 5))) { - mouse_ext_command(sc->kbdc, 3); + mouse_ext_command(sc->kbdc, SYNAPTICS_READ_MODEL_ID); set_mouse_sampling_rate(sc->kbdc, 0xc8); } } @@ -6238,7 +6254,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a set_mouse_scaling(kbdc, 1); /* Identify the Touchpad version. */ - if (mouse_ext_command(kbdc, 0) == 0) + if (mouse_ext_command(kbdc, SYNAPTICS_READ_IDENTITY) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6259,7 +6275,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a } /* Get the Touchpad model information. */ - if (mouse_ext_command(kbdc, 3) == 0) + if (mouse_ext_command(kbdc, SYNAPTICS_READ_MODEL_ID) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6290,7 +6306,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a } /* Read the extended capability bits. */ - if (mouse_ext_command(kbdc, 2) == 0) + if (mouse_ext_command(kbdc, SYNAPTICS_READ_CAPABILITIES) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6321,7 +6337,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a if (!set_mouse_scaling(kbdc, 1)) return (FALSE); - if (mouse_ext_command(kbdc, 0x08) == 0) + if (mouse_ext_command(kbdc, SYNAPTICS_READ_RESOLUTIONS) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6358,7 +6374,8 @@ enable_synaptics(struct psm_softc *sc, enum probearg a if (synhw.nExtendedQueries >= 1) { if (!set_mouse_scaling(kbdc, 1)) return (FALSE); - if (mouse_ext_command(kbdc, 0x09) == 0) + if (mouse_ext_command(kbdc, + SYNAPTICS_READ_EXTENDED) == 0) return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); @@ -6397,7 +6414,8 @@ enable_synaptics(struct psm_softc *sc, enum probearg a if (synhw.nExtendedQueries >= 4) { if (!set_mouse_scaling(kbdc, 1)) return (FALSE); - if (mouse_ext_command(kbdc, 0x0c) == 0) + if (mouse_ext_command(kbdc, + SYNAPTICS_READ_CAPABILITIES_CONT) == 0)
svn commit: r346457 - in head: share/man/man4 sys/dev/atkbdc
Author: wulf Date: Sat Apr 20 21:04:56 2019 New Revision: 346457 URL: https://svnweb.freebsd.org/changeset/base/346457 Log: psm(4): respect tap_disabled configuration with enabled Extended support This fixes a bug where, even when hw.psm.tap_enabled=0, touchpad taps were processed. tap_enabled has three states: unconfigured, disabled, and enabled (-1, 0, 1). To respect PR kern/139272, taps are ignored only when explicity disabled. Submitted by: Ben LeMasurier (initial version) MFC after:2 weeks Modified: head/share/man/man4/psm.4 head/sys/dev/atkbdc/psm.c Modified: head/share/man/man4/psm.4 == --- head/share/man/man4/psm.4 Sat Apr 20 21:02:41 2019(r346456) +++ head/share/man/man4/psm.4 Sat Apr 20 21:04:56 2019(r346457) @@ -354,8 +354,8 @@ Tap and drag gestures can be disabled by setting to .Em 0 at boot-time. -Currently, this is only supported on Synaptics touchpads with Extended -support disabled. +Currently, this is supported on Synaptics touchpads regardless of Extended +support state and on Elantech touchpads with Extended support enabled. The behaviour may be changed after boot by setting the sysctl with the same name and by restarting .Xr moused 8 Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Apr 20 21:02:41 2019(r346456) +++ head/sys/dev/atkbdc/psm.c Sat Apr 20 21:04:56 2019(r346457) @@ -3820,9 +3820,15 @@ psmgestures(struct psm_softc *sc, finger_t *fingers, i gest->in_vscroll = 0; /* Compute tap timeout. */ - gest->taptimeout.tv_sec = tap_timeout / 100; - gest->taptimeout.tv_usec = tap_timeout % 100; - timevaladd(&gest->taptimeout, &sc->lastsoftintr); + if (tap_enabled != 0) { + gest->taptimeout = (struct timeval) { + .tv_sec = tap_timeout / 100, + .tv_usec = tap_timeout % 100, + }; + timevaladd( + &gest->taptimeout, &sc->lastsoftintr); + } else + timevalclear(&gest->taptimeout); sc->flags |= PSM_FLAGS_FINGERDOWN; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r346456 - head/sys/dev/atkbdc
Author: wulf Date: Sat Apr 20 21:02:41 2019 New Revision: 346456 URL: https://svnweb.freebsd.org/changeset/base/346456 Log: psm(4): do not process gestures when palm is present Ignoring of gesture processing when the palm is detected helps to reduce some of the erratic pointer behavior. This fixes regression introduced in r317814 Reported by: Ben LeMasurier MFC after:2 weeks Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Apr 20 21:00:44 2019(r346455) +++ head/sys/dev/atkbdc/psm.c Sat Apr 20 21:02:41 2019(r346456) @@ -3214,7 +3214,7 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, static int guest_buttons; static int ew_finger_count; static finger_t f[PSM_FINGERS]; - int w, id, nfingers, ewcode, extended_buttons, clickpad_pressed; + int w, id, nfingers, palm, ewcode, extended_buttons, clickpad_pressed; extended_buttons = 0; @@ -3577,12 +3577,16 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, ms->button = touchpad_buttons; - psmgestures(sc, &f[0], nfingers, ms); + palm = psmpalmdetect(sc, &f[0], nfingers); + + /* Palm detection doesn't terminate the current action. */ + if (!palm) + psmgestures(sc, &f[0], nfingers, ms); + for (id = 0; id < PSM_FINGERS; id++) psmsmoother(sc, &f[id], id, ms, x, y); - /* Palm detection doesn't terminate the current action. */ - if (psmpalmdetect(sc, &f[0], nfingers)) { + if (palm) { *x = *y = *z = 0; ms->button = ms->obutton; return (0); @@ -4324,7 +4328,7 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m { static int touchpad_button, trackpoint_button; finger_t fn, f[ELANTECH_MAX_FINGERS]; - int pkt, id, scale, i, nfingers, mask; + int pkt, id, scale, i, nfingers, mask, palm; if (!elantech_support) return (0); @@ -4713,10 +4717,14 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m ms->button = touchpad_button | trackpoint_button; + /* Palm detection doesn't terminate the current action. */ + palm = psmpalmdetect(sc, &f[0], nfingers); + /* Send finger 1 position to gesture processor */ - if (PSM_FINGER_IS_SET(f[0]) || PSM_FINGER_IS_SET(f[1]) || - nfingers == 0) + if ((PSM_FINGER_IS_SET(f[0]) || PSM_FINGER_IS_SET(f[1]) || + nfingers == 0) && !palm) psmgestures(sc, &f[0], imin(nfingers, 3), ms); + /* Send fingers positions to movement smoothers */ for (id = 0; id < PSM_FINGERS; id++) if (PSM_FINGER_IS_SET(f[id]) || !(mask & (1 << id))) @@ -4731,8 +4739,7 @@ proc_elantech(struct psm_softc *sc, packetbuf_t *pb, m } sc->elanaction.mask = mask; - /* Palm detection doesn't terminate the current action. */ - if (psmpalmdetect(sc, &f[0], nfingers)) { + if (palm) { *x = *y = *z = 0; ms->button = ms->obutton; return (0); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r346455 - head/sys/dev/atkbdc
Author: wulf Date: Sat Apr 20 21:00:44 2019 New Revision: 346455 URL: https://svnweb.freebsd.org/changeset/base/346455 Log: psm(4): Add support for 4 and 5 finger touches in synaptics driver While 4-th and 5-th finger positions are not exported through PS/2 interface, total number of touches is reported by MT trackpads. MFC after:2 weeks Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Apr 20 20:29:03 2019(r346454) +++ head/sys/dev/atkbdc/psm.c Sat Apr 20 21:00:44 2019(r346455) @@ -1830,7 +1830,7 @@ psm_register_synaptics(device_t dev) if (sc->synhw.capClickPad && sc->synhw.topButtonPad) evdev_support_prop(evdev_a, INPUT_PROP_TOPBUTTONPAD); evdev_support_key(evdev_a, BTN_TOUCH); - evdev_support_nfingers(evdev_a, 3); + evdev_support_nfingers(evdev_a, sc->synhw.capReportsV ? 5 : 3); psm_support_abs_bulk(evdev_a, synaptics_absinfo_st); if (sc->synhw.capAdvancedGestures || sc->synhw.capReportsV) psm_support_abs_bulk(evdev_a, synaptics_absinfo_mt); @@ -3212,6 +3212,7 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, { static int touchpad_buttons; static int guest_buttons; + static int ew_finger_count; static finger_t f[PSM_FINGERS]; int w, id, nfingers, ewcode, extended_buttons, clickpad_pressed; @@ -3372,6 +3373,9 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, (pb->ipacket[1] & 0x01)) + 8, .flags = PSM_FINGER_FUZZY, }; + break; + case 2: + ew_finger_count = pb->ipacket[1] & 0x0f; default: break; } @@ -3379,6 +3383,11 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, goto SYNAPTICS_END; case 1: + if (sc->synhw.capReportsV && ew_finger_count > 3) { + nfingers = ew_finger_count; + break; + } + /* FALLTHROUGH */ case 0: nfingers = w + 2; break; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r344982 - head/sys/x86/isa
On 2019-03-11 21:17, Jung-uk Kim wrote: On 19. 3. 11., Ravi Pokala wrote: -Original Message- From: on behalf of Vladimir Kondratyev Date: 2019-03-10, Sunday at 13:19 To: , , Subject: svn commit: r344982 - head/sys/x86/isa Author: wulf Date: Sun Mar 10 20:19:43 2019 New Revision: 344982 URL: https://svnweb.freebsd.org/changeset/base/344982 Log: atrtc(4): install ACPI RTC/CMOS operation region handler Hi Vladimir, This appears to have broken all the various LINT kernels for amd64 and i386: /usr/home/rpokala/freebsd/clean/base/head/sys/x86/isa/atrtc.c:321:2: error: use of undeclared identifier '_AcpiModuleName' ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); ^ /usr/home/rpokala/freebsd/clean/base/head/sys/contrib/dev/acpica/include/acoutput.h:480:18: note: expanded from macro 'ACPI_FUNCTION_TRACE' AcpiUtTrace (ACPI_DEBUG_PARAMETERS) ^ /usr/home/rpokala/freebsd/clean/base/head/sys/contrib/dev/acpica/include/acoutput.h:402:39: note: expanded from macro 'ACPI_DEBUG_PARAMETERS' __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT ^ /usr/home/rpokala/freebsd/clean/base/head/sys/x86/isa/atrtc.c:321:2: error: use of undeclared identifier '_COMPONENT' /usr/home/rpokala/freebsd/clean/base/head/sys/contrib/dev/acpica/include/acoutput.h:480:18: note: expanded from macro 'ACPI_FUNCTION_TRACE' AcpiUtTrace (ACPI_DEBUG_PARAMETERS) ^ /usr/home/rpokala/freebsd/clean/base/head/sys/contrib/dev/acpica/include/acoutput.h:402:56: note: expanded from macro 'ACPI_DEBUG_PARAMETERS' __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT ^ That same pattern of errors is noted for lines 321, 362, and 386. Please take a look at your earliest convenience. Please try the attached patch. Jung-uk Kim Thank you! It fixed LINT at least on amd64. Sorry for breakage :-( -- WBR Vladimir Kondratyev ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r345022 - head/sys/x86/isa
Author: wulf Date: Mon Mar 11 19:46:15 2019 New Revision: 345022 URL: https://svnweb.freebsd.org/changeset/base/345022 Log: Fix amd64/i386 LINT build after r344982 Submitted by: jkim Reported by: rpokala MFC with: r344982 Modified: head/sys/x86/isa/atrtc.c Modified: head/sys/x86/isa/atrtc.c == --- head/sys/x86/isa/atrtc.cMon Mar 11 19:15:57 2019(r345021) +++ head/sys/x86/isa/atrtc.cMon Mar 11 19:46:15 2019(r345022) @@ -83,6 +83,11 @@ static int rtc_reg = -1; static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF; static u_char rtc_statusb = RTCSB_24HR; +#ifdef DEV_ACPI +#define_COMPONENT ACPI_TIMER +ACPI_MODULE_NAME("ATRTC") +#endif + /* * RTC support routines */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344982 - head/sys/x86/isa
Author: wulf Date: Sun Mar 10 20:19:43 2019 New Revision: 344982 URL: https://svnweb.freebsd.org/changeset/base/344982 Log: atrtc(4): install ACPI RTC/CMOS operation region handler FreeBSD base system does not provide an ACPI handler for the PC/AT RTC/CMOS device with PnP ID PNP0B00; on some HP laptops, the absence of this handler causes suspend/resume and poweroff(8) to hang or fail [1], [2]. On these laptops EC _REG method queries the RTC date/time registers via ACPI before suspending/powering off. The handler should be registered before acpi_ec driver is loaded. This change adds handler to access CMOS RTC operation region described in section 9.15 of ACPI-6.2 specification [3]. It is installed only for ACPI version of atrtc(4) so it should not affect old ACPI-less i386 systems. It is possible to disable the handler with loader tunable: debug.acpi.disabled=atrtc Informational debugging printf can be enabled by setting hw.acpi.verbose=1 in loader.conf [1] https://wiki.freebsd.org/Laptops/HP_Envy_6Z-1100 [2] https://wiki.freebsd.org/Laptops/HP_Notebook_15-af104ur [3] https://uefi.org/sites/default/files/resources/ACPI_6_2.pdf PR: 207419, 213039 Submitted by: Anthony Jenkins Reviewed by: ian Discussed on: acpi@, 2013-2015, several threads MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D19314 Modified: head/sys/x86/isa/atrtc.c Modified: head/sys/x86/isa/atrtc.c == --- head/sys/x86/isa/atrtc.cSun Mar 10 18:48:08 2019(r344981) +++ head/sys/x86/isa/atrtc.cSun Mar 10 20:19:43 2019(r344982) @@ -32,6 +32,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_acpi.h" #include "opt_isa.h" #include @@ -54,8 +55,12 @@ __FBSDID("$FreeBSD$"); #endif #include #include "clock_if.h" +#ifdef DEV_ACPI #include +#include +#include #include +#endif /* * atrtc_lock protects low-level access to individual hardware registers. @@ -193,6 +198,9 @@ struct atrtc_softc { struct resource *intr_res; void *intr_handler; struct eventtimer et; +#ifdef DEV_ACPI + ACPI_HANDLE acpi_handle; +#endif }; static int @@ -247,7 +255,145 @@ rtc_intr(void *arg) return(flag ? FILTER_HANDLED : FILTER_STRAY); } +#ifdef DEV_ACPI /* + * ACPI RTC CMOS address space handler + */ +#defineATRTC_LAST_REG 0x40 + +static void +rtcin_region(int reg, void *buf, int len) +{ + u_char *ptr = buf; + + /* Drop lock after each IO as intr and settime have greater priority */ + while (len-- > 0) + *ptr++ = rtcin(reg++) & 0xff; +} + +static void +rtcout_region(int reg, const void *buf, int len) +{ + const u_char *ptr = buf; + + while (len-- > 0) + writertc(reg++, *ptr++); +} + +static bool +atrtc_check_cmos_access(bool is_read, ACPI_PHYSICAL_ADDRESS addr, UINT32 len) +{ + + /* Block address space wrapping on out-of-bound access */ + if (addr >= ATRTC_LAST_REG || addr + len > ATRTC_LAST_REG) + return (false); + + if (is_read) { + /* Reading 0x0C will muck with interrupts */ + if (addr <= RTC_INTR && addr + len > RTC_INTR) + return (false); + } else { + /* +* Allow single-byte writes to alarm registers and +* multi-byte writes to addr >= 0x30, else deny. +*/ + if (!((len == 1 && (addr == RTC_SECALRM || + addr == RTC_MINALRM || + addr == RTC_HRSALRM)) || + addr >= 0x30)) + return (false); + } + return (true); +} + +static ACPI_STATUS +atrtc_acpi_cmos_handler(UINT32 func, ACPI_PHYSICAL_ADDRESS addr, +UINT32 bitwidth, UINT64 *value, void *context, void *region_context) +{ + device_t dev = context; + UINT32 bytewidth = howmany(bitwidth, 8); + bool is_read = func == ACPI_READ; + + /* ACPICA is very verbose on CMOS handler failures, so we, too */ +#defineCMOS_HANDLER_ERR(fmt, ...) \ + device_printf(dev, "ACPI [SystemCMOS] handler: " fmt, ##__VA_ARGS__) + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + + if (value == NULL) { + CMOS_HANDLER_ERR("NULL parameter\n"); + return (AE_BAD_PARAMETER); + } + if (bitwidth == 0 || (bitwidth & 0x07) != 0) { + CMOS_HANDLER_ERR("Invalid bitwidth: %u\n", bitwidth); + return (AE_BAD_PARAMETER); + } + if (!atrtc_check_cmos_access(is_read, addr, bytewidth)) { + CMOS_HANDLER_ERR("%s access rejected: addr=%#04jx, len=%u\n", + is_read ? "Read" : "Write", (uintmax_t)addr, bytewidth); + return (AE_BAD_PARAMETER); + } + + switch (func) { +
svn commit: r344495 - head/sys/dev/evdev
Author: wulf Date: Sun Feb 24 19:31:42 2019 New Revision: 344495 URL: https://svnweb.freebsd.org/changeset/base/344495 Log: Fix build when EVDEV_SUPPORT is option disabled after r344494 MFC with: 344494 Modified: head/sys/dev/evdev/evdev.c Modified: head/sys/dev/evdev/evdev.c == --- head/sys/dev/evdev/evdev.c Sun Feb 24 18:47:04 2019(r344494) +++ head/sys/dev/evdev/evdev.c Sun Feb 24 19:31:42 2019(r344495) @@ -69,16 +69,16 @@ MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory"); int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX; int evdev_sysmouse_t_axis = 0; -#ifdef EVDEV_SUPPORT SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args"); +#ifdef EVDEV_SUPPORT SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, &evdev_rcpt_mask, 0, "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, " "bit2 - mouse hardware, bit3 - keyboard hardware"); SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW, &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm"); +#endif SYSCTL_NODE(_kern_evdev, OID_AUTO, input, CTLFLAG_RD, 0, "Evdev input devices"); -#endif static void evdev_start_repeat(struct evdev_dev *, uint16_t); static void evdev_stop_repeat(struct evdev_dev *); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r344494 - in head: sbin/sysctl sys/dev/evdev
Author: wulf Date: Sun Feb 24 18:47:04 2019 New Revision: 344494 URL: https://svnweb.freebsd.org/changeset/base/344494 Log: evdev: export event device properties through sysctl interface A big security advantage of Wayland is not allowing applications to read input devices all the time. Having /dev/input/* accessible to the user account subverts this advantage. libudev-devd was opening the evdev devices to detect their types (mouse, keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible. With the kernel exposing this information as sysctls (kern.evdev.input.*), we can work w/o /dev/input/* access, preserving the Wayland security model. Submitted by: Greg V Reviewed by: wulf, imp MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D18694 Modified: head/sbin/sysctl/sysctl.c head/sys/dev/evdev/evdev.c head/sys/dev/evdev/evdev_private.h Modified: head/sbin/sysctl/sysctl.c == --- head/sbin/sysctl/sysctl.c Sun Feb 24 17:23:55 2019(r344493) +++ head/sbin/sysctl/sysctl.c Sun Feb 24 18:47:04 2019(r344494) @@ -49,6 +49,7 @@ static const char rcsid[] = #include #include #include +#include #ifdef __amd64__ #include @@ -680,6 +681,22 @@ S_vmtotal(size_t l2, void *p) return (0); } +static int +S_input_id(size_t l2, void *p) +{ + struct input_id *id = p; + + if (l2 != sizeof(*id)) { + warnx("S_input_id %zu != %zu", l2, sizeof(*id)); + return (1); + } + + printf("{ bustype = 0x%04x, vendor = 0x%04x, " + "product = 0x%04x, version = 0x%04x }", + id->bustype, id->vendor, id->product, id->version); + return (0); +} + #ifdef __amd64__ static int S_efi_map(size_t l2, void *p) @@ -983,6 +1000,8 @@ show_var(int *oid, int nlen) func = S_loadavg; else if (strcmp(fmt, "S,vmtotal") == 0) func = S_vmtotal; + else if (strcmp(fmt, "S,input_id") == 0) + func = S_input_id; #ifdef __amd64__ else if (strcmp(fmt, "S,efi_map_header") == 0) func = S_efi_map; Modified: head/sys/dev/evdev/evdev.c == --- head/sys/dev/evdev/evdev.c Sun Feb 24 17:23:55 2019(r344493) +++ head/sys/dev/evdev/evdev.c Sun Feb 24 18:47:04 2019(r344494) @@ -76,6 +76,8 @@ SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_R "bit2 - mouse hardware, bit3 - keyboard hardware"); SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW, &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm"); +SYSCTL_NODE(_kern_evdev, OID_AUTO, input, CTLFLAG_RD, 0, +"Evdev input devices"); #endif static void evdev_start_repeat(struct evdev_dev *, uint16_t); @@ -196,6 +198,87 @@ evdev_estimate_report_size(struct evdev_dev *evdev) return (size); } +static void +evdev_sysctl_create(struct evdev_dev *evdev) +{ + struct sysctl_oid *ev_sysctl_tree; + char ev_unit_str[8]; + + snprintf(ev_unit_str, sizeof(ev_unit_str), "%d", evdev->ev_unit); + sysctl_ctx_init(&evdev->ev_sysctl_ctx); + + ev_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&evdev->ev_sysctl_ctx, + SYSCTL_STATIC_CHILDREN(_kern_evdev_input), OID_AUTO, + ev_unit_str, CTLFLAG_RD, NULL, "", "device index"); + + SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "name", CTLFLAG_RD, + evdev->ev_name, 0, + "Input device name"); + + SYSCTL_ADD_STRUCT(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "id", CTLFLAG_RD, + &evdev->ev_id, input_id, + "Input device identification"); + + /* ioctl returns ENOENT if phys is not set. sysctl returns "" here */ + SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "phys", CTLFLAG_RD, + evdev->ev_shortname, 0, + "Input device short name"); + + /* ioctl returns ENOENT if uniq is not set. sysctl returns "" here */ + SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "uniq", CTLFLAG_RD, + evdev->ev_serial, 0, + "Input device unique number"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "props", CTLFLAG_RD, + evdev->ev_prop_flags, sizeof(evdev->ev_prop_flags), "", + "Input device properties"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "type_bits", CTLFLAG_RD, + evdev->ev_type_flags, sizeof(evdev->ev_type_flags), "", + "Input device supported ev
svn commit: r343327 - head/sys/dev/sound/pci/hda
Author: wulf Date: Tue Jan 22 22:39:46 2019 New Revision: 343327 URL: https://svnweb.freebsd.org/changeset/base/343327 Log: Add quirk to enable mic and headphones redirection on HP Spectre laptops. Tested on HP AF006UR. MFC after:2 weeks Modified: head/sys/dev/sound/pci/hda/hdaa_patches.c head/sys/dev/sound/pci/hda/hdac.h Modified: head/sys/dev/sound/pci/hda/hdaa_patches.c == --- head/sys/dev/sound/pci/hda/hdaa_patches.c Tue Jan 22 21:52:07 2019 (r343326) +++ head/sys/dev/sound/pci/hda/hdaa_patches.c Tue Jan 22 22:39:46 2019 (r343327) @@ -410,6 +410,18 @@ hdac_pin_patch(struct hdaa_widget *w) patch = "as=1 seq=15"; break; } + } else if (id == HDA_CODEC_ALC295 && subid == HP_AF006UR_SUBVENDOR) { + switch (nid) { + case 18: + patch = "as=2"; + break; + case 25: + patch = "as=2 seq=15"; + break; + case 33: + patch = "as=1 seq=15"; + break; + } } else if (id == HDA_CODEC_ALC298 && subid == DELL_XPS9560_SUBVENDOR) { switch (nid) { case 24: Modified: head/sys/dev/sound/pci/hda/hdac.h == --- head/sys/dev/sound/pci/hda/hdac.h Tue Jan 22 21:52:07 2019 (r343326) +++ head/sys/dev/sound/pci/hda/hdac.h Tue Jan 22 22:39:46 2019 (r343327) @@ -188,6 +188,7 @@ #define HP_DV5000_SUBVENDORHDA_MODEL_CONSTRUCT(HP, 0x30a5) #define HP_DC7700S_SUBVENDOR HDA_MODEL_CONSTRUCT(HP, 0x2801) #define HP_DC7700_SUBVENDORHDA_MODEL_CONSTRUCT(HP, 0x2802) +#define HP_AF006UR_SUBVENDOR HDA_MODEL_CONSTRUCT(HP, 0x83a2) #define HP_ALL_SUBVENDOR HDA_MODEL_CONSTRUCT(HP, 0x) /* What is wrong with XN 2563 anyway? (Got the picture ?) */ #define HP_NX6325_SUBVENDORX 0x103c30b0 ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r343163 - in head/sys: dev/atkbdc sys
Author: wulf Date: Fri Jan 18 22:20:29 2019 New Revision: 343163 URL: https://svnweb.freebsd.org/changeset/base/343163 Log: psm(4): detect Lenovo top-button clickpads libinput has special handling for Lenovo ThinkPad *40 series, where it treats clicks on the top button area as if they came from the TrackPoint: https://wayland.freedesktop.org/libinput/doc/latest/t440-support.html Detect these devices and set the corresponding evdev property. Submitted by: Greg V MFC after:2 weeks Differential Revision:https://reviews.freebsd.org/D18676 Modified: head/sys/dev/atkbdc/psm.c head/sys/sys/mouse.h Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Fri Jan 18 21:46:38 2019(r343162) +++ head/sys/dev/atkbdc/psm.c Fri Jan 18 22:20:29 2019(r343163) @@ -136,6 +136,7 @@ struct psmcpnp_softc { enum { PSMCPNP_GENERIC, PSMCPNP_FORCEPAD, + PSMCPNP_TOPBUTTONPAD, } type; /* Based on PnP ID */ }; @@ -1826,6 +1827,8 @@ psm_register_synaptics(device_t dev) evdev_support_prop(evdev_a, INPUT_PROP_SEMI_MT); if (sc->synhw.capClickPad) evdev_support_prop(evdev_a, INPUT_PROP_BUTTONPAD); + if (sc->synhw.capClickPad && sc->synhw.topButtonPad) + evdev_support_prop(evdev_a, INPUT_PROP_TOPBUTTONPAD); evdev_support_key(evdev_a, BTN_TOUCH); evdev_support_nfingers(evdev_a, 3); psm_support_abs_bulk(evdev_a, synaptics_absinfo_st); @@ -5711,7 +5714,7 @@ synaptics_sysctl_create_softbuttons_tree(struct psm_so */ /* hw.psm.synaptics.softbuttons_y */ - sc->syninfo.softbuttons_y = 1700; + sc->syninfo.softbuttons_y = sc->synhw.topButtonPad ? -1700 : 1700; SYSCTL_ADD_PROC(&sc->syninfo.sysctl_ctx, SYSCTL_CHILDREN(sc->syninfo.sysctl_tree), OID_AUTO, "softbuttons_y", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, @@ -6441,6 +6444,9 @@ enable_synaptics(struct psm_softc *sc, enum probearg a case PSMCPNP_FORCEPAD: synhw.forcePad = 1; break; + case PSMCPNP_TOPBUTTONPAD: + synhw.topButtonPad = 1; + break; default: break; } @@ -6483,8 +6489,11 @@ enable_synaptics(struct psm_softc *sc, enum probearg a synhw.minimumYCoord); } if (synhw.capClickPad) { + printf(" Clickpad capabilities:\n"); printf(" forcePad: %d\n", synhw.forcePad); + printf(" topButtonPad: %d\n", + synhw.topButtonPad); } } buttons += synhw.capClickPad; @@ -7332,6 +7341,44 @@ static struct isa_pnp_id psmcpnp_ids[] = { }; /* _HID list for quirk detection. Any device below has _CID from psmcpnp_ids */ +static struct isa_pnp_id topbtpad_ids[] = { + { 0x1700ae30, "Lenovo PS/2 clickpad port" },/* LEN0017, ThinkPad */ + { 0x1800ae30, "Lenovo PS/2 clickpad port" },/* LEN0018, ThinkPad */ + { 0x1900ae30, "Lenovo PS/2 clickpad port" },/* LEN0019, ThinkPad */ + { 0x2300ae30, "Lenovo PS/2 clickpad port" },/* LEN0023, ThinkPad */ + { 0x2a00ae30, "Lenovo PS/2 clickpad port" },/* LEN002a, ThinkPad */ + { 0x2b00ae30, "Lenovo PS/2 clickpad port" },/* LEN002b, ThinkPad */ + { 0x2c00ae30, "Lenovo PS/2 clickpad port" },/* LEN002c, ThinkPad */ + { 0x2d00ae30, "Lenovo PS/2 clickpad port" },/* LEN002d, ThinkPad */ + { 0x2e00ae30, "Lenovo PS/2 clickpad port" },/* LEN002e, ThinkPad */ + { 0x3300ae30, "Lenovo PS/2 clickpad port" },/* LEN0033, ThinkPad */ + { 0x3400ae30, "Lenovo PS/2 clickpad port" },/* LEN0034, ThinkPad */ + { 0x3500ae30, "Lenovo PS/2 clickpad port" },/* LEN0035, ThinkPad */ + { 0x3600ae30, "Lenovo PS/2 clickpad port" },/* LEN0036, ThinkPad */ + { 0x3700ae30, "Lenovo PS/2 clickpad port" },/* LEN0037, ThinkPad */ + { 0x3800ae30, "Lenovo PS/2 clickpad port" },/* LEN0038, ThinkPad */ + { 0x3900ae30, "Lenovo PS/2 clickpad port" },/* LEN0039, ThinkPad */ + { 0x4100ae30, "Lenovo PS/2 clickpad port" },/* LEN0041, ThinkPad */ + { 0x4200ae30, "Lenovo PS/2 clickpad port" },/* LEN0042, ThinkPad */ + { 0x4500ae30, "Lenovo PS/2 clickpad por
svn commit: r340926 - head/sys/dev/evdev
Author: wulf Date: Sun Nov 25 19:37:00 2018 New Revision: 340926 URL: https://svnweb.freebsd.org/changeset/base/340926 Log: evdev: Fix pause key release event in AT keyboard set 1 to evdev xlat-or. MFC after:2 weeks Modified: head/sys/dev/evdev/evdev_utils.c Modified: head/sys/dev/evdev/evdev_utils.c == --- head/sys/dev/evdev/evdev_utils.cSun Nov 25 18:09:39 2018 (r340925) +++ head/sys/dev/evdev/evdev_utils.cSun Nov 25 19:37:00 2018 (r340926) @@ -250,12 +250,15 @@ evdev_scancode2key(int *state, int scancode) */ *state = 0; if ((scancode & 0x7f) == 0x1D) - *state = 0x1D; + *state = scancode; return (NONE); /* NOT REACHED */ case 0x1D: /* pause / break */ + case 0x9D: + if ((*state ^ scancode) & 0x80) + return (NONE); *state = 0; - if (scancode != 0x45) + if ((scancode & 0x7f) != 0x45) return (NONE); keycode = KEY_PAUSE; break; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r340913 - head/sys/dev/atkbdc
Author: wulf Date: Sat Nov 24 21:23:12 2018 New Revision: 340913 URL: https://svnweb.freebsd.org/changeset/base/340913 Log: psm(4): Add minimal support for active AUX port multiplexers Active PS/2 multiplexing is a method for attaching up to four PS/2 pointing devices to a computer. Enabling of multiplexed mode allows commands to be directed to individual devices using routing prefixes. Multiplexed mode reports input with each byte tagged to identify its source. This method differs from one currently supported by psm(4) where so called guest device (trackpoint) is attached to special interface located on the host device (touchpad) and latter performs guest protocol conversion to special encapsulation packet format. At present time active PS/2 multiplexing is used in some models of HP laptops e.g. EliteBook 8560w, 9470m. Enabling of absolute operation mode on such touchpads is connected with following problems: 1. Touchpad's port priority is lower than trackpoint's. That blocks information queries thus prevents touchpad detection and configuration. 2. Touchpad and trackpoint have different protocol packet sizes and sync bytes. As PS/2 usage is on decline only minimal possible set of changes to support Synaptics touchpad and generic mouses is implemented. Active multiplexing mode is enabled only at probe stage to scan through attached PS/2 devices to query and configure Synaptics touchpad. After touchpad has been configured, mux is switched back to legacy (hidden multiplexing) mode to perform normal interrupt-driven input data processing. Overflow bit values rather than tags are used to separate packets produced by different devices. Switching back to legacy mode allows to avoid psm(4) and atkbd(4) rework to support 4 instances of mouse driver. Note: While in hidden multiplexing mode KBC does some editing of the packet stream. It remembers the button bits from the last packet received from each device, and replaces the button bits of every packet with the logical OR of all devices’ most recent button bits. This sort of button crosstalk results in spurious button events which are inhibitted with various tricks. E.g. trackpoint middle button events are suppressed while trackpad surface is touched and touchpad left and right button events are suppressed if corresponding trackpoint buttons are pressed. PR: 231058 Reported by: Michael Figiel Tested by:Michael Figiel MFC after:2 weeks Modified: head/sys/dev/atkbdc/atkbdc.c head/sys/dev/atkbdc/atkbdcreg.h head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/atkbdc.c == --- head/sys/dev/atkbdc/atkbdc.cSat Nov 24 21:17:51 2018 (r340912) +++ head/sys/dev/atkbdc/atkbdc.cSat Nov 24 21:23:12 2018 (r340913) @@ -296,6 +296,7 @@ atkbdc_setup(atkbdc_softc_t *sc, bus_space_tag_t tag, sc->lock = FALSE; sc->kbd.head = sc->kbd.tail = 0; sc->aux.head = sc->aux.tail = 0; + sc->aux_mux_enabled = FALSE; #if KBDIO_DEBUG >= 2 sc->kbd.call_count = 0; sc->kbd.qcount = sc->kbd.max_qcount = 0; @@ -639,7 +640,12 @@ write_kbd_command(KBDC p, int c) int write_aux_command(KBDC p, int c) { -if (!write_controller_command(p, KBDC_WRITE_TO_AUX)) +int f; + +f = aux_mux_is_enabled(p) ? +KBDC_WRITE_TO_AUX_MUX + kbdcp(p)->aux_mux_port : KBDC_WRITE_TO_AUX; + +if (!write_controller_command(p, f)) return FALSE; return write_controller_data(p, c); } @@ -1200,4 +1206,79 @@ set_controller_command_byte(KBDC p, int mask, int comm command); return TRUE; +} + +/* + * Rudimentary support for active PS/2 AUX port multiplexing. + * Only write commands can be routed to a selected AUX port. + * Source port of data processed by read commands is totally ignored. + */ +static int +set_aux_mux_state(KBDC p, int enabled) +{ + int command, version; + + if (write_controller_command(p, KBDC_FORCE_AUX_OUTPUT) == 0 || + write_controller_data(p, 0xF0) == 0 || + read_controller_data(p) != 0xF0) + return (-1); + + if (write_controller_command(p, KBDC_FORCE_AUX_OUTPUT) == 0 || + write_controller_data(p, 0x56) == 0 || + read_controller_data(p) != 0x56) + return (-1); + + command = enabled ? 0xa4 : 0xa5; + if (write_controller_command(p, KBDC_FORCE_AUX_OUTPUT) == 0 || + write_controller_data(p, command) == 0 || + (version = read_controller_data(p)) == command) + return (-1); + + return (version); +} + +int +set_active_aux_mux_port(KBDC p, int port) +{ + + if (!aux_mux_is_enabled(p)) + return (FALSE); + + if (port < 0 || port >= KBDC_AUX_MUX_NUM_PORTS) + return (FALSE); + + kbdcp(p)->au
svn commit: r340912 - head/sys/dev/atkbdc
Author: wulf Date: Sat Nov 24 21:17:51 2018 New Revision: 340912 URL: https://svnweb.freebsd.org/changeset/base/340912 Log: Revert r328640: Add kludge for 0x46 identity middle byte Synaptics touchpads. It appeared that "0x46 identity middle byte" response is caused by so called "Active PS/2 multiplexing controller" presence. Support for it will be added in next commit. Modified: head/sys/dev/atkbdc/psm.c Modified: head/sys/dev/atkbdc/psm.c == --- head/sys/dev/atkbdc/psm.c Sat Nov 24 18:25:00 2018(r340911) +++ head/sys/dev/atkbdc/psm.c Sat Nov 24 21:17:51 2018(r340912) @@ -136,7 +136,6 @@ struct psmcpnp_softc { enum { PSMCPNP_GENERIC, PSMCPNP_FORCEPAD, - PSMCPNP_HPSYN81, } type; /* Based on PnP ID */ }; @@ -175,15 +174,6 @@ typedef struct packetbuf { #definePSM_PACKETQUEUE 128 #endif -/* - * Typical bezel limits. Taken from 'Synaptics - * PS/2 TouchPad Interfacing Guide' p.3.2.3. - */ -#defineSYNAPTICS_DEFAULT_MAX_X 5472 -#defineSYNAPTICS_DEFAULT_MAX_Y 4448 -#defineSYNAPTICS_DEFAULT_MIN_X 1472 -#defineSYNAPTICS_DEFAULT_MIN_Y 1408 - typedef struct synapticsinfo { struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; @@ -1109,7 +1099,7 @@ doopen(struct psm_softc *sc, int command_byte) mouse_ext_command(sc->kbdc, 1); get_mouse_status(sc->kbdc, stat, 0, 3); if ((SYNAPTICS_VERSION_GE(sc->synhw, 7, 5) || -stat[1] == 0x46 || stat[1] == 0x47) && +stat[1] == 0x47) && stat[2] == 0x40) { synaptics_set_mode(sc, synaptics_preferred_mode(sc)); VLOG(5, (LOG_DEBUG, "psm%d: Synaptis Absolute Mode " @@ -6047,7 +6037,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a KBDC kbdc = sc->kbdc; synapticshw_t synhw; int status[3]; - int buttons, middle_byte; + int buttons; VLOG(3, (LOG_DEBUG, "synaptics: BEGIN init\n")); @@ -6064,8 +6054,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); - middle_byte = status[1]; - if (middle_byte != 0x46 && middle_byte != 0x47) + if (status[1] != 0x47) return (FALSE); bzero(&synhw, sizeof(synhw)); @@ -6076,15 +6065,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a printf("Synaptics Touchpad v%d.%d\n", synhw.infoMajor, synhw.infoMinor); - /* -* Most synaptics touchpads return 0x47 in middle byte in responce to -* identify command as stated in p.4.4 of "Synaptics PS/2 TouchPad -* Interfacing Guide" and we only support v4.0 or better. But some -* devices return 0x46 here and have a different numbering scheme. -* In the case of 0x46, we allow versions as low as v2.0 -*/ - if ((middle_byte == 0x47 && synhw.infoMajor < 4) || - (middle_byte == 0x46 && synhw.infoMajor < 2)) { + if (synhw.infoMajor < 4) { printf(" Unsupported (pre-v4) Touchpad detected\n"); return (FALSE); } @@ -6125,7 +6106,7 @@ enable_synaptics(struct psm_softc *sc, enum probearg a return (FALSE); if (get_mouse_status(kbdc, status, 0, 3) != 3) return (FALSE); - if (!SYNAPTICS_VERSION_GE(synhw, 7, 5) && status[1] != middle_byte) { + if (!SYNAPTICS_VERSION_GE(synhw, 7, 5) && status[1] != 0x47) { printf(" Failed to read extended capability bits\n"); return (FALSE); } @@ -6134,29 +6115,10 @@ enable_synaptics(struct psm_softc *sc, enum probearg a sc->unit); psmcpnp_sc = (psmcpnp != NULL) ? device_get_softc(psmcpnp) : NULL; - /* -* Set conservative defaults for 0x46 middle byte touchpads -* as ExtendedQueries return bogus data. -*/ - if (middle_byte == 0x46) { - synhw.capExtended = 1; - synhw.capPalmDetect = 1; - synhw.capPassthrough = 1; - synhw.capMultiFinger = 1; - synhw.maximumXCoord = SYNAPTICS_DEFAULT_MAX_X; - synhw.maximumYCoord = SYNAPTICS_DEFAULT_MAX_Y; - synhw.minimumXCoord = SYNAPTICS_DEFAULT_MIN_X; - synhw.minimumYCoord = SYNAPTICS_DEFAULT_MIN_Y; - /* Enable multitouch mode for HW v8.1 devices */ - if (psmcpnp_sc != NULL && - psmcpnp_sc->type == PSMCPNP_HPSYN81) - synhw.capReportsV = 1; - } else - synhw.capExtended = (status[0] & 0x80) != 0; - /* Set the different capabilities
svn commit: r340338 - head/sys/dev/usb/input
Author: wulf Date: Sat Nov 10 22:14:09 2018 New Revision: 340338 URL: https://svnweb.freebsd.org/changeset/base/340338 Log: wmt(4): Add PNP record so it could be picked by devd/devmatch. Fix uhid(4) conflict with blacklisting of multitouch HID-usages in uhid(4) probe handler. Reviewed by: imp No objections from: hps MFC after:1 month Differential Revision:https://reviews.freebsd.org/D17689 Modified: head/sys/dev/usb/input/uhid.c head/sys/dev/usb/input/wmt.c Modified: head/sys/dev/usb/input/uhid.c == --- head/sys/dev/usb/input/uhid.c Sat Nov 10 21:02:32 2018 (r340337) +++ head/sys/dev/usb/input/uhid.c Sat Nov 10 22:14:09 2018 (r340338) @@ -675,6 +675,8 @@ uhid_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); int error; + void *buf; + uint16_t len; DPRINTFN(11, "\n"); @@ -700,6 +702,25 @@ uhid_probe(device_t dev) ((uaa->info.bInterfaceProtocol == UIPROTO_MOUSE) && !usb_test_quirk(uaa, UQ_UMS_IGNORE return (ENXIO); + + /* Check for mandatory multitouch usages to give wmt(4) a chance */ + if (!usb_test_quirk(uaa, UQ_WMT_IGNORE)) { + error = usbd_req_get_hid_desc(uaa->device, NULL, + &buf, &len, M_USBDEV, uaa->info.bIfaceIndex); + /* Let HID decscriptor-less devices to be handled at attach */ + if (!error) { + if (hid_locate(buf, len, + HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACT_MAX), + hid_feature, 0, NULL, NULL, NULL) && + hid_locate(buf, len, + HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACTID), + hid_input, 0, NULL, NULL, NULL)) { + free(buf, M_USBDEV); + return (ENXIO); + } + free(buf, M_USBDEV); + } + } return (BUS_PROBE_GENERIC); } Modified: head/sys/dev/usb/input/wmt.c == --- head/sys/dev/usb/input/wmt.cSat Nov 10 21:02:32 2018 (r340337) +++ head/sys/dev/usb/input/wmt.cSat Nov 10 22:14:09 2018 (r340338) @@ -856,6 +856,12 @@ wmt_cont_max_parse(struct wmt_softc *sc, const void *r } } +static const STRUCT_USB_HOST_ID wmt_devs[] = { + /* generic HID class w/o boot interface */ + {USB_IFACE_CLASS(UICLASS_HID), +USB_IFACE_SUBCLASS(0),}, +}; + static devclass_t wmt_devclass; static device_method_t wmt_methods[] = { @@ -876,3 +882,4 @@ DRIVER_MODULE(wmt, uhub, wmt_driver, wmt_devclass, NUL MODULE_DEPEND(wmt, usb, 1, 1, 1); MODULE_DEPEND(wmt, evdev, 1, 1, 1); MODULE_VERSION(wmt, 1); +USB_PNP_HOST_INFO(wmt_devs); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"