Date: Mon, 25 Aug 2014 12:10:57 -0400 From: Anthony Jenkins <Anthony.B.Jenkins@att.net> To: =?UTF-8?B?5byg5pmT6Z2W?= <zhangxiaojing@hotmail.com> Cc: freebsd-acpi@freebsd.org Subject: Re: =?UTF-8?B?562U5aSNOiDnrZTlpI06IE15IGxhcHRvcCBjYW4ndCByZXN1bWU=?= =?UTF-8?B?IGZyb20gc3VzcGVuZC4=?= Message-ID: <53FB6011.3080509@att.net> In-Reply-To: <BLU436-SMTP67343C48955DBE96365728A0DF0@phx.gbl> References: <BLU436-SMTP62EDBC36C40E7A96279D03A0EA0@phx.gbl> <CAN6yY1sieCOVmpXOcBvavh8-UB3=zQbP4vn2%2B%2B=Sq49VmCDtWw@mail.gmail.com> <BLU437-SMTP14CC6D27278DD1F2D7B9E5A0E90@phx.gbl> <53EE78ED.2030208@att.net> <BLU436-SMTP67343C48955DBE96365728A0DF0@phx.gbl>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------010903030303070503090707 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No problem... attached. And amd64 doesn't matter - works for x86-based computers with the basic CMOS RTC chip (PNP0B00). Hopefully your suspend/resume problems are due to your ACPI BIOS needing to read/write info from/to CMOS and not finding a CMOS handler. Anthony On 08/25/2014 11:50, 张晓靖 wrote: > I google less than complete information. Do you have the relevant code can be shared under it? I found atrtc.c file in /usr/src/sys/x86/isa directory, but my system is amd64 of ...... > > root@skycn:~ # uname -a > FreeBSD skycn 10.0-RELEASE-p7 FreeBSD 10.0-RELEASE-p7 #2: Sat Aug 16 00:06:30 CST 2014 root@skycn:/usr/obj/usr/src/sys/MyKernel amd64 > > > -----邮件原件----- > 发件人: Anthony Jenkins [mailto:Anthony.B.Jenkins@att.net] > 发送时间: 2014年8月16日 5:18 > 收件人: 张晓靖; 'Kevin Oberman' > 抄送: freebsd-acpi@freebsd.org > 主题: Re: 答复: My laptop can't resume from suspend. > > On 08/15/2014 16:20, 张晓靖 wrote: >> Thank Bykov Vladislav and Kevin Oberman's recommendations. Later I >> received an e-mail, >> >> immediately compile the kernel (make a note #options VESA).But the >> problem persists, dmesg >> >> Information Reference url http://url.cn/SQ0vXD. >> >> >> >> Even worse thing is, I do use "acpiconf -s 3"debugger, resulting in a >> notebook can not boot >> >> until yesterday afternoon for a good notebook motherboard, now do not >> dare to use “acpiconf >> >> -s 3” testing. >> >> >> >> Do you have suggestions for me? > You could dig up my kernel patch (Google "FreeBSD ACPI CMOS region support atrtc.c.patch") to play with, it works to enable suspend/resume on some laptops and should be safe to try. I still need to clean it up (style, other suggestions) for submission to FreeBSD, haven't gotten around to it yet. > > Anthony Jenkins > >> Thanks you~ >> >> >> >> >> >> >> >> -----邮件原件----- >> 发件人: Bykov Vladislav [mailto:envolyse@gmail.com] >> 发送时间: 2014年8月13日 0:13 >> 收件人: 张晓靖 >> 主题: Re: My laptop can't resume from suspend. >> >> >> >> On Tue, Aug 12, 2014 at 12:20:28PM +0800, 张晓靖 wrote: >> >>> The laptop can't resume, the screen no display, no beep sound. >> Can you please try to install video driver for your card and remove VESA device from kernel configuration? >> >> >> >> >> >> 发件人: kob6558@gmail.com [mailto:kob6558@gmail.com] 代表 Kevin Oberman >> 发送时间: 2014年8月13日 1:15 >> 收件人: 张晓靖 >> 抄送: freebsd-acpi@freebsd.org >> 主题: Re: My laptop can't resume from suspend. >> >> >> >> On Mon, Aug 11, 2014 at 9:20 PM, 张晓靖 <zhangxiaojing@hotmail.com <mailto:zhangxiaojing@hotmail.com> > wrote: >> >> Hello, >> >> I am having a problem. >> >> My laptop is lenovo's zhaoyang K47A series HM65. >> >> I used ati graphics CARDS, Use the url ( >> <https://wiki.freebsd.org/Graphics> https://wiki.freebsd.org/Graphics) >> the method of normal driving the graphics card. >> >> >> >> After set " >> >> sysctl debug. Bootverbose = 1 >> >> sysctl debug. Acpi. Suspend_bounce = 1 >> >> sysctl debug. Acpi. Resume_beep = 1 >> >> acpiconf -s 3 >> >> " >> >> The laptop can't resume, the screen no display, no beep sound. >> >> >> >> Disabling ACPI not helps to fix the problem. All files downloaded from >> http://url.cn/WVISGF. >> >> >> >> Output from sysctl hw.acpi >> >> hw.acpi.supported_sleep_state: S1 S3 S4 S5 >> >> hw.acpi.power_button_state: S5 >> >> hw.acpi.sleep_button_state: S1 >> >> hw.acpi.lid_switch_state: NONE >> >> hw.acpi.standby_state: S1 >> >> hw.acpi.suspend_state: S3 >> >> hw.acpi.sleep_delay: 1 >> >> hw.acpi.s4bios: 0 >> >> hw.acpi.verbose: 1 >> >> hw.acpi.disable_on_reboot: 0 >> >> hw.acpi.handle_reboot: 0 >> >> hw.acpi.reset_video: 0 >> >> hw.acpi.cpu.cx_lowest: C1 >> >> hw.acpi.acline: 1 >> >> hw.acpi.battery.life: 100 >> >> hw.acpi.battery.time: -1 >> >> hw.acpi.battery.state: 0 >> >> hw.acpi.battery.units: 2 >> >> hw.acpi.battery.info_expire: 5 >> >> hw.acpi.thermal.min_runtime: 0 >> >> hw.acpi.thermal.polling_rate: 10 >> >> hw.acpi.thermal.user_override: 0 >> >> hw.acpi.thermal.tz0.temperature: 62.0C >> >> hw.acpi.thermal.tz0.active: -1 >> >> hw.acpi.thermal.tz0.passive_cooling: 1 >> >> hw.acpi.thermal.tz0.thermal_flags: 0 >> >> hw.acpi.thermal.tz0._PSV: 95.0C >> >> hw.acpi.thermal.tz0._HOT: -1 >> >> hw.acpi.thermal.tz0._CRT: 100.0C >> >> hw.acpi.thermal.tz0._ACx: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 >> >> hw.acpi.thermal.tz0._TC1: 2 >> >> hw.acpi.thermal.tz0._TC2: 3 >> >> hw.acpi.thermal.tz0._TSP: 100 >> >> >> >> Sincerely, >> ZhangXiaoJing. >> >> >> >> Have you tried building the kernel without VESA? Many laptops won't resume if you leave VESA in the kernel build. >> >> -- >> >> >> R. Kevin Oberman, Network Engineer, Retired >> E-mail: rkoberman@gmail.com <mailto:rkoberman@gmail.com> >> >> _______________________________________________ >> freebsd-acpi@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-acpi >> To unsubscribe, send any mail to "freebsd-acpi-unsubscribe@freebsd.org" > > --------------010903030303070503090707 Content-Type: text/x-patch; name="atrtc.c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="atrtc.c.patch" Index: sys/x86/isa/atrtc.c =================================================================== --- sys/x86/isa/atrtc.c (revision 268728) +++ sys/x86/isa/atrtc.c (working copy) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include "opt_isa.h" +#include "opt_acpi.h" #include <sys/param.h> #include <sys/systm.h> @@ -53,12 +54,19 @@ #include <machine/intr_machdep.h> #include "clock_if.h" +#include <contrib/dev/acpica/include/acpi.h> +#include <contrib/dev/acpica/include/accommon.h> +#include <dev/acpica/acpivar.h> + #define RTC_LOCK do { if (!kdb_active) mtx_lock_spin(&clock_lock); } while (0) #define RTC_UNLOCK do { if (!kdb_active) mtx_unlock_spin(&clock_lock); } while (0) +#define IO_DELAY() (void)inb(0x84) +#define IO_RTC_ADDR (IO_RTC + 0) +#define IO_RTC_DATA (IO_RTC + 1) + int atrtcclock_disable = 0; -static int rtc_reg = -1; static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF; static u_char rtc_statusb = RTCSB_24HR; @@ -66,39 +74,50 @@ * RTC support routines */ -int -rtcin(int reg) +static void acpi_cmos_read(ACPI_PHYSICAL_ADDRESS address, UINT8 *buf, UINT32 buflen) { - u_char val; + UINT32 offset; RTC_LOCK; - if (rtc_reg != reg) { - inb(0x84); - outb(IO_RTC, reg); - rtc_reg = reg; - inb(0x84); + for (offset = 0U; offset < buflen; ++offset) { + IO_DELAY(); + outb(IO_RTC_ADDR, ((address + offset) | 0x80) & 0xFF); + IO_DELAY(); + buf[offset] = inb(IO_RTC_DATA); } - val = inb(IO_RTC + 1); RTC_UNLOCK; - return (val); } -void -writertc(int reg, u_char val) +static void acpi_cmos_write(ACPI_PHYSICAL_ADDRESS address, const UINT8 *buf, UINT32 buflen) { + UINT32 offset; RTC_LOCK; - if (rtc_reg != reg) { - inb(0x84); - outb(IO_RTC, reg); - rtc_reg = reg; - inb(0x84); + for (offset = 0U; offset < buflen; ++offset) { + IO_DELAY(); + outb(IO_RTC_ADDR, ((address + offset) | 0x80) & 0xFF); + IO_DELAY(); + outb(IO_RTC_DATA, buf[offset]); } - outb(IO_RTC + 1, val); - inb(0x84); + IO_DELAY(); RTC_UNLOCK; } +int +rtcin(int reg) +{ + u_char val; + + acpi_cmos_read(reg & 0xFF, &val, 1); + return (val); +} + +void +writertc(int reg, u_char val) +{ + acpi_cmos_write(reg & 0xFF, &val, 1); +} + static __inline int readrtc(int port) { @@ -144,7 +163,6 @@ { /* Restore all of the RTC's "status" (actually, control) registers. */ - rtcin(RTC_STATUSA); /* dummy to get rtc_reg set */ writertc(RTC_STATUSB, RTCSB_24HR); writertc(RTC_STATUSA, rtc_statusa); writertc(RTC_STATUSB, rtc_statusb); @@ -161,9 +179,52 @@ struct resource *intr_res; void *intr_handler; struct eventtimer et; + ACPI_HANDLE acpi_handle; /* Handle of the PNP0B00 node */ }; static int +is_datetime_reg(ACPI_PHYSICAL_ADDRESS address) +{ + return address == 0x00 || + address == 0x02 || + address == 0x04 || + address == 0x04 || + (address >= 0x06 && address <= 0x09); +} + +static ACPI_STATUS +acpi_rtc_cmos_handler(UINT32 function, ACPI_PHYSICAL_ADDRESS address, UINT32 width, + UINT64 *value, void *context, void *region_context) +{ + struct atrtc_softc *sc; + + sc = (struct atrtc_softc *)context; + if (!value || !sc) + return AE_BAD_PARAMETER; + if (width > 32 || (width & 0x07) || address >= 64U) + return AE_BAD_PARAMETER; + if (function == ACPI_WRITE && + (is_datetime_reg(address) || + (width > 8 && address <= 0x09))) + return AE_BAD_PARAMETER; + + switch (function) { + case ACPI_READ: + acpi_cmos_read(address, (UINT8 *)value, width >> 3); + break; + case ACPI_WRITE: + acpi_cmos_write(address, (const UINT8 *)value, width >> 3); + break; + default: + return AE_BAD_PARAMETER; + } + printf("%s: %-5s%02u address=%04lx value=%08x\n", + __FUNCTION__, function == ACPI_READ ? "READ" : "WRITE", + width >> 3, address, *((UINT32 *)value)); + return AE_OK; +} + +static int rtc_start(struct eventtimer *et, sbintime_t first, sbintime_t period) { @@ -245,10 +306,17 @@ int i; sc = device_get_softc(dev); + sc->acpi_handle = acpi_get_handle(dev); sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid, IO_RTC, IO_RTC + 1, 2, RF_ACTIVE); if (sc->port_res == NULL) device_printf(dev, "Warning: Couldn't map I/O.\n"); + if (ACPI_FAILURE(AcpiInstallAddressSpaceHandler(sc->acpi_handle, + ACPI_ADR_SPACE_CMOS, acpi_rtc_cmos_handler, NULL, sc))) + { + device_printf(dev, "Error registering ACPI CMOS address space handler.\n"); + return 0; + } atrtc_start(); clock_register(dev, 1000000); bzero(&sc->et, sizeof(struct eventtimer)); @@ -286,6 +354,15 @@ return(0); } +static int atrtc_detach(device_t dev) +{ + struct atrtc_softc *sc; + + sc = device_get_softc(dev); + AcpiRemoveAddressSpaceHandler(sc->acpi_handle, ACPI_ADR_SPACE_CMOS, acpi_rtc_cmos_handler); + return bus_generic_detach(dev); +} + static int atrtc_resume(device_t dev) { @@ -366,7 +443,7 @@ /* Device interface */ DEVMETHOD(device_probe, atrtc_probe), DEVMETHOD(device_attach, atrtc_attach), - DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_detach, atrtc_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), DEVMETHOD(device_suspend, bus_generic_suspend), /* XXX stop statclock? */ --------------010903030303070503090707--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53FB6011.3080509>