Subject: Re: port-i386/36852: Port of the aps driver from OpenBSD
To: None <xtraeme@NetBSD.org, gnats-admin@netbsd.org,>
From: Pierre Pronchery <khorben@defora.org>
List: netbsd-bugs
Date: 09/03/2007 20:15:12
The following reply was made to PR port-i386/36852; it has been noted by GNATS.

From: Pierre Pronchery <khorben@defora.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-i386/36852: Port of the aps driver from OpenBSD
Date: Mon, 03 Sep 2007 22:12:37 +0200

 This is a multi-part message in MIME format.
 --------------010201020900010205040708
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 
 	Hi,
 
 Juan RP wrote:
 > On Mon, 27 Aug 2007 22:40:02 +0000 (UTC)
 > Pierre Pronchery <khorben@defora.org> wrote:
 > 
 >>> Description:
 >> Please find a port of the aps driver from OpenBSD here. It supports the
 >> accel-o-meter device found on ThinkPads laptops for a while now.
 > 
 > Thanks for your port. I've modified it a bit, I made the following changes:
 > 
 > - Use sme_flags = SME_DISABLE_GTREDATA; because the driver refreshes the
 >   sensors by itself, so there's no need to use the gtredata function
 >   (see sysmon_envsys(9) for more info).
 > - use aprint(9) for autoconf messages.
 > - some KNF.
 > - Change private driver functions to be static.
 > - Invalid use of ENVSYS_FNOTVALID.
 > 
 > Please test and let me know if it works as before and then I'll commit.
 
 It does indeed. Feel free to commit if appropriate.
 
 I attach here a copy of my dmesg and envstat as with the patch.
 There is a spurious "aps: can't map i/o space" line from the kernel, but
 I also had it before. I could not figure why this happens so far.
 
 I still don't know if the movement values represent what should actually
 be obtained, but they seem to be updated coherently when I move the laptop.
 
 > Also, you should provide a manpage for new drivers.
 
 Is it ok to import the page from the OpenBSD project?
 
 Thanks again,
 -- 
 khorben
 
 --------------010201020900010205040708
 Content-Type: text/plain;
  name="dmesg-aps.txt"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="dmesg-aps.txt"
 
 Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
     2006, 2007
     The NetBSD Foundation, Inc.  All rights reserved.
 Copyright (c) 1982, 1986, 1989, 1991, 1993
     The Regents of the University of California.  All rights reserved.
 
 NetBSD 4.99.30 (GENERIC.MP) #3: Mon Sep  3 20:01:22 CEST 2007
 	khorben@syn.defora.rom:/usr/obj/sys/arch/amd64/compile/GENERIC.MP
 total memory = 2046 MB
 avail memory = 1954 MB
 timecounter: Timecounters tick every 10.000 msec
 timecounter: Timecounter "i8254" frequency 1193182 Hz quality 100
 mainbus0 (root)
 cpu0 at mainbus0 apid 0: (boot processor)
 cpu0: Intel(R) Core(TM)2 CPU         T7200  @ 2.00GHz, 1995.11 MHz
 cpu0: features: bffbfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
 cpu0: features: bffbfbff<PGE,MCA,CMOV,PAT,PSE36,CFLUSH,B20,DS,ACPI,MMX>
 cpu0: features: bffbfbff<FXSR,SSE,SSE2,SS,HTT,TM,SBF>
 cpu0: features2: e3bd<SSE3,MONITOR,DS-CPL,VMX,EST,TM2,xTPR,PDCM>
 cpu0: features3: bffbfbff<SYSCALL/SYSRET,XD,EM64T>
 cpu0: L2 cache 4 MB 64B/line 16-way
 cpu0: Enhanced SpeedStep (1324 mV) 2000 MHz
 cpu0: unknown Enhanced SpeedStep CPU.
 cpu0: Enhanced SpeedStep frequencies available (MHz): 2000 1833 1667 1500 1333 1167 1000
 cpu0: calibrating local timer
 cpu0: apic clock running at 166 MHz
 cpu0: 64 page colors
 cpu1 at mainbus0 apid 1: (application processor)
 cpu1: Intel(R) Core(TM)2 CPU         T7200  @ 2.00GHz, 1995.00 MHz
 cpu1: features: bffbfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
 cpu1: features: bffbfbff<PGE,MCA,CMOV,PAT,PSE36,CFLUSH,B20,DS,ACPI,MMX>
 cpu1: features: bffbfbff<FXSR,SSE,SSE2,SS,HTT,TM,SBF>
 cpu1: features2: e3bd<SSE3,MONITOR,DS-CPL,VMX,EST,TM2,xTPR,PDCM>
 cpu1: features3: bffbfbff<SYSCALL/SYSRET,XD,EM64T>
 cpu1: L2 cache 4 MB 64B/line 16-way
 ioapic0 at mainbus0 apid 1
 ioapic0: pa 0xfec00000, version 20, 24 pins
 ioapic0: misconfigured as apic 2
 ioapic0: remapped to apic 1
 acpi0 at mainbus0: Advanced Configuration and Power Interface
 acpi0: using Intel ACPI CA subsystem version 20060217
 acpi0: X/RSDT: OemId <LENOVO,TP-79   ,00002110>, AslId < LTP,00000000>
 acpi0: found ECDT, GPE 28
 acpi0: SCI interrupting at int 9
 acpi0: fixed-feature power button present
 timecounter: Timecounter "ACPI-Fast" frequency 3579545 Hz quality 1000
 ACPI-Fast 24-bit timer
 CPU0 (ACPI Object Type 'Processor' [0x0c]) at acpi0 not configured
 CPU1 (ACPI Object Type 'Processor' [0x0c]) at acpi0 not configured
 LNKA (PNP0C0F) [PCI interrupt link device] at acpi0 not configured
 LNKB (PNP0C0F) [PCI interrupt link device] at acpi0 not configured
 LNKC (PNP0C0F) [PCI interrupt link device] at acpi0 not configured
 LNKD (PNP0C0F) [PCI interrupt link device] at acpi0 not configured
 LNKE (PNP0C0F) [PCI interrupt link device] at acpi0 not configured
 LNKF (PNP0C0F) [PCI interrupt link device] at acpi0 not configured
 LNKG (PNP0C0F) [PCI interrupt link device] at acpi0 not configured
 LNKH (PNP0C0F) [PCI interrupt link device] at acpi0 not configured
 MEM (PNP0C01) [System Board] at acpi0 not configured
 acpilid0 at acpi0 (LID, PNP0C0D): ACPI Lid Switch
 acpibut0 at acpi0 (SLPB, PNP0C0E): ACPI Sleep Button
 PCI0 (PNP0A08) [PCI Express/PCI-X Mode-2 Host Bridge] at acpi0 not configured
 SIO (PNP0C02) [Plug and Play motherboard register resources] at acpi0 not configured
 PIC (PNP0000) [AT Interrupt Controller] at acpi0 not configured
 attimer1 at acpi0 (TIMR, PNP0100): AT Timer
 attimer1: io 0x40-0x43 irq 0
 HPET (PNP0103) [HPET Timer] at acpi0 not configured
 DMAC (PNP0200) [AT DMA Controller] at acpi0 not configured
 pcppi1 at acpi0 (SPKR, PNP0800)
 pcppi1: io 0x61
 midi0 at pcppi1: PC speaker (CPU-intensive output)
 sysbeep0 at pcppi1
 FPU (PNP0C04) [Math Coprocessor] at acpi0 not configured
 RTC (PNP0B00) [AT Real-Time Clock] at acpi0 not configured
 pckbc1 at acpi0 (KBD, PNP0303): kbd port
 pckbc1: io 0x60,0x64 irq 1
 pckbc2 at acpi0 (MOU, IBM0057): aux port
 pckbc2: irq 12
 com2 at acpi0 (FIR, IBM0071)
 com2: io 0x2f8-0x2ff irq 3 drq 3
 com2: ns16550a, working fifo
 TPM (ATM1200) at acpi0 not configured
 acpiec0 at acpi0 (EC, PNP0C09-0): ACPI Embedded Controller
 acpiec0: io 0x62,0x66
 PUBS (ACPI Object Type 'Power' [0x0b]) at acpi0 not configured
 acpibat0 at acpi0 (BAT0, PNP0C0A-0): ACPI Battery (Control Method)
 acpibat1 at acpi0 (BAT1, PNP0C0A-1): ACPI Battery (Control Method)
 acpiacad0 at acpi0 (AC, ACPI0003-0): ACPI AC Adapter
 HKEY (IBM0068) at acpi0 not configured
 acpitz0 at acpi0 (THM0): ACPI Thermal Zone
 acpitz0: unable to get polling interval; using default of 30.0s
 acpitz0: passive cooling mode only
 acpitz0: critical 127.0C
 acpitz1 at acpi0 (THM1): ACPI Thermal Zone
 acpitz1: unable to get polling interval; using default of 30.0s
 acpitz1: critical 99.0C passive 61.0C
 pcppi1: attached to attimer1
 pckbd0 at pckbc1 (kbd slot)
 pckbc1: using irq 1 for kbd slot
 wskbd0 at pckbd0: console keyboard
 pms0 at pckbc1 (aux slot)
 pckbc1: using irq 12 for aux slot
 wsmouse0 at pms0 mux 0
 pci0 at mainbus0 bus 0: configuration mode 1
 pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
 pchb0 at pci0 dev 0 function 0
 pchb0: Intel 82945GM/PM/GMS Host Bridge (rev. 0x03)
 agp at pchb0 not configured
 ppb0 at pci0 dev 1 function 0: Intel product 0x27a1 (rev. 0x03)
 pci1 at ppb0 bus 1
 pci1: i/o space, memory space enabled, rd/line, wr/inv ok
 vga0 at pci1 dev 0 function 0: ATI Technologies product 0x7145 (rev. 0x00)
 wsdisplay0 at vga0 kbdmux 1: console (80x25, vt100 emulation), using wskbd0
 wsmux1: connecting to wsdisplay0
 direct rendering for vga0 unsupported
 azalia0 at pci0 dev 27 function 0: Generic High Definition Audio Controller
 azalia0: interrupting at ioapic0 pin 17 (irq 11)
 azalia0: host: Intel 82801GB/GR High Definition Audio Controller (rev. 2)
 azalia0: host: High Definition Audio rev. 1.0
 ppb1 at pci0 dev 28 function 0: Intel 82801GB/GR PCI Express Port #1 (rev. 0x02)
 pci2 at ppb1 bus 2
 pci2: i/o space, memory space enabled, rd/line, wr/inv ok
 wm0 at pci2 dev 0 function 0: Intel i82573L Gigabit Ethernet, rev. 0
 wm0: interrupting at ioapic0 pin 16 (irq 11)
 wm0: PCI-Express bus
 wm0: 256 word (8 address bits) SPI EEPROM
 wm0: Ethernet address 00:xx:xx:xx:xx:xx
 makphy0 at wm0 phy 1: Marvell 88E1111 Gigabit PHY, rev. 2
 makphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
 ppb2 at pci0 dev 28 function 1: Intel 82801GB/GR PCI Express Port #2 (rev. 0x02)
 pci3 at ppb2 bus 3
 pci3: i/o space, memory space enabled, rd/line, wr/inv ok
 wpi0 at pci3 dev 0 function 0: Intel PRO/Wireless LAN 3945ABG Mini-PCI Adapter (rev. 0x02)
 wpi0: interrupting at ioapic0 pin 17 (irq 11)
 , MoW2, address 00:xx:xx:xx:xx:xx
 wpi0: 11a rates: 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
 wpi0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
 wpi0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
 ppb3 at pci0 dev 28 function 2: Intel 82801GB/GR PCI Express Port #3 (rev. 0x02)
 pci4 at ppb3 bus 4
 pci4: i/o space, memory space enabled, rd/line, wr/inv ok
 ppb4 at pci0 dev 28 function 3: Intel 82801GB/GR PCI Express Port #4 (rev. 0x02)
 pci5 at ppb4 bus 12
 pci5: i/o space, memory space enabled, rd/line, wr/inv ok
 uhci0 at pci0 dev 29 function 0: Intel 82801GB/GR USB UHCI Controller (rev. 0x02)
 uhci0: interrupting at ioapic0 pin 16 (irq 11)
 usb0 at uhci0: USB revision 1.0
 uhub0 at usb0
 uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub0: 2 ports with 2 removable, self powered
 uhci1 at pci0 dev 29 function 1: Intel 82801GB/GR USB UHCI Controller (rev. 0x02)
 uhci1: interrupting at ioapic0 pin 17 (irq 11)
 usb1 at uhci1: USB revision 1.0
 uhub1 at usb1
 uhub1: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub1: 2 ports with 2 removable, self powered
 uhci2 at pci0 dev 29 function 2: Intel 82801GB/GR USB UHCI Controller (rev. 0x02)
 uhci2: interrupting at ioapic0 pin 18 (irq 11)
 usb2 at uhci2: USB revision 1.0
 uhub2 at usb2
 uhub2: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub2: 2 ports with 2 removable, self powered
 uhci3 at pci0 dev 29 function 3: Intel 82801GB/GR USB UHCI Controller (rev. 0x02)
 uhci3: interrupting at ioapic0 pin 19 (irq 11)
 usb3 at uhci3: USB revision 1.0
 uhub3 at usb3
 uhub3: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 uhub3: 2 ports with 2 removable, self powered
 ehci0 at pci0 dev 29 function 7: Intel 82801GB/GR USB EHCI Controller (rev. 0x02)
 ehci0: interrupting at ioapic0 pin 19 (irq 11)
 ehci0: BIOS has given up ownership
 ehci0: EHCI version 1.0
 ehci0: companion controllers, 2 ports each: uhci0 uhci1 uhci2 uhci3
 usb4 at ehci0: USB revision 2.0
 uhub4 at usb4
 uhub4: Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
 uhub4: 8 ports with 8 removable, self powered
 ppb5 at pci0 dev 30 function 0: Intel 82801BAM Hub-PCI Bridge (rev. 0xe2)
 pci6 at ppb5 bus 21
 pci6: i/o space enabled
 cbb0 at pci6 dev 0 function 0: Texas Instruments PCI1510 PCI-CardBus Bridge (rev. 0x00)
 cbb0: can't map socket base address 0xe4300000
 pci_io_find: expected type i/o, found mem
 cbb0: can't map socket base address 0xe4300000: io mode
 cbb0: interrupting at ioapic0 pin 16 (irq 11)
 cardslot0 at cbb0 slot 0 flags 0
 cardbus0 at cardslot0: bus 22
 pcmcia0 at cardslot0
 pcib0 at pci0 dev 31 function 0
 pcib0: Intel 82801GBM LPC Interface Bridge (rev. 0x02)
 piixide0 at pci0 dev 31 function 1
 piixide0: Intel 82801GB/GR IDE Controller (ICH7) (rev. 0x02)
 piixide0: bus-master DMA support present
 piixide0: primary channel configured to compatibility mode
 piixide0: primary channel interrupting at ioapic0 pin 14 (irq 14)
 atabus0 at piixide0 channel 0
 piixide0: secondary channel configured to compatibility mode
 piixide0: secondary channel ignored (disabled)
 ahcisata0 at pci0 dev 31 function 2: Intel 82801GBM AHCI SATA Controller
 ahcisata0: interrupting at ioapic0 pin 16 (irq 11)
 ahcisata0: AHCI revision 1.1, 4 ports, 32 command slots, features 0xc710e000
 atabus1 at ahcisata0 channel 0
 ichsmb0 at pci0 dev 31 function 3: Intel 82801GB/GR SMBus Controller (rev. 0x02)
 ichsmb0: interrupting at ioapic0 pin 23 (irq 11)
 iic0 at ichsmb0: I2C bus
 iic0: devices at 0x44 0x54 0x55 0x56 0x5c
 isa0 at pcib0
 aps: state register 0x1
 aps0 at isa0 port 0x1600-0x161e
 aps: can't map i/o space
 timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
 azalia0: codec[0]: Analog Devices AD1981HD (rev. 2.0)
 azalia0: codec[0]: High Definition Audio rev. 1.0
 azalia0: playback: max channels=2, encodings=1<PCM>
 azalia0: playback: PCM formats=e007f<24bit,20bit,16bit,48kHz,44.1kHz,32kHz,22.05kHz,16kHz,11.025kHz,8kHz>
 azalia0: recording: max channels=2, encodings=1<PCM>
 azalia0: recording: PCM formats=6007f<20bit,16bit,48kHz,44.1kHz,32kHz,22.05kHz,16kHz,11.025kHz,8kHz>
 azalia0: codec[1]: 0x14f1/0x2bfa (rev. 0.0)
 azalia0: codec[1]: High Definition Audio rev. 0.9
 azalia0: codec[1]: No support for modem function groups
 azalia0: codec[1] has no audio function groups
 audio0 at azalia0: full duplex, independent
 Kernelized RAIDframe activated
 ahcisata0 port 0: device present, speed: 1.5Gb/s
 wd0 at atabus1 drive 0: <HTS721010G9SA00>
 wd0: drive supports 16-sector PIO transfers, LBA48 addressing
 wd0: 95396 MB, 193821 cyl, 16 head, 63 sec, 512 bytes/sect x 195371568 sectors
 wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100)
 wd0(ahcisata0:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100) (using DMA)
 uhidev0 at uhub2 port 1 configuration 1 interface 0boot device: wd0
 root on wd0a dumps on wd0b
 
 uhidev0: Logitech USB-PS/2 Optical Mouse, rev 2.00/20.00, addr 2, iclass 3/1
 ums0 at uhidev0: 3 buttons and Z dir.
 wsmouse1 at ums0 mux 0
 root file system type: ffs
 ugen0 at uhub3 port 2
 ugen0: STMicroelectronics Biometric Coprocessor, rev 1.00/0.01, addr 2
 acpibat1: battery info: SONY, LiP, 40Y6790  1193
 acpibat0: battery info: SANYO, LION, 42T4504   695
 wsdisplay0: screen 1 added (80x25, vt100 emulation)
 wsdisplay0: screen 2 added (80x25, vt100 emulation)
 wsdisplay0: screen 3 added (80x25, vt100 emulation)
 wsdisplay0: screen 4 added (80x25, vt100 emulation)
 Accounting started
 uhidev0: at uhub2 port 1 (addr 2) disconnected
 wsmouse1 detached
 ums0 detached
 uhidev0 detached
 
 --------------010201020900010205040708
 Content-Type: text/plain;
  name="envstat-aps.txt"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="envstat-aps.txt"
 
     acpiacad0 connected:         ON
        acpibat0 present:         ON
     acpibat0 design cap:     56.160 Wh
  acpibat0 last full cap:     55.210 Wh
     acpibat0 technology:          1
 acpibat0 design voltage:     10.800 V
       acpibat0 warn cap:      2.760 Wh ( 5.00%)
        acpibat0 low cap:      0.200 Wh ( 0.36%)
        acpibat0 voltage:     12.497 V
    acpibat0 charge rate:        N/A
 acpibat0 discharge rate:        N/A
         acpibat0 charge:     55.210 Wh (100.00%)
       acpibat0 charging:        OFF
   acpibat0 charge state:     NORMAL
        acpibat1 present:         ON
     acpibat1 design cap:     29.160 Wh
  acpibat1 last full cap:     29.160 Wh
     acpibat1 technology:          1
 acpibat1 design voltage:     10.800 V
       acpibat1 warn cap:      1.458 Wh ( 5.00%)
        acpibat1 low cap:      0.200 Wh ( 0.69%)
        acpibat1 voltage:     12.406 V
    acpibat1 charge rate:        N/A
 acpibat1 discharge rate:        N/A
         acpibat1 charge:     28.860 Wh (98.97%)
       acpibat1 charging:        OFF
   acpibat1 charge state:     NORMAL
     acpitz0 temperature:     47.000 degC
     acpitz1 temperature:     46.000 degC
            aps0 X_ACCEL:        465
            aps0 Y_ACCEL:        492
              aps0 X_VAR:        465
              aps0 Y_VAR:        492
             aps0 TEMP_1:     38.000 degC
             aps0 TEMP_2:     38.000 degC
    aps0 Keyboard Active:         ON
       aps0 Mouse Active:        OFF
           aps0 Lid Open:         ON
 
 --------------010201020900010205040708--