Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jul 2014 15:39:15 -0400
From:      Anthony Jenkins <Anthony.B.Jenkins@att.net>
To:        Daniele Mazzotti <kappei84@gmail.com>
Cc:        freebsd-acpi@freebsd.org
Subject:   Re: ACPI support - Freebsd 10 on Sony Vaio VPCCA3C5E
Message-ID:  <53C58363.6050809@att.net>
In-Reply-To: <CAC=ypSUqHF%2B2_ajsjU5x3=if01twAtmsPcmQGBgNC=VEAdOKnQ@mail.gmail.com>
References:  <CAC=ypSVopgcL82FpqJosmgFeRkeeevP0RG-GrAEZD2YQyi%2BPrg@mail.gmail.com> <53BF0546.70505@att.net> <CAC=ypSUe0_09pTMFsMKw4u3J=Kb8Q_uV0g6%2Bk_f2p1so3mnTgA@mail.gmail.com> <53BFCBF4.2090104@att.net> <CAC=ypSULmXU2HBpG2gf2J=9_o-sLccECud%2Be9KUg6-ppz7phww@mail.gmail.com> <CAC=ypSV36Dk_3a30OeCxmowqnM5iqcJkM%2B4qKgsOTNTEzmztSQ@mail.gmail.com> <53C020CE.8010205@att.net> <CAC=ypSV_qQ-EsfwJAa6NRiZhTvOi-xh9A=oFKXzNMj9GTpHbOA@mail.gmail.com> <53C02604.9070207@att.net> <CAC=ypSV=yXjnNYJTMSU3tDTjez9NAe3PqsDPRiF5sf2D6FBxRA@mail.gmail.com> <CAC=ypSVbiOpTxUZeJnQUTMdjtbicu2JdG5p5g9%2BgR%2BS72-6RVg@mail.gmail.com> <CAC=ypSU3J3cPuEqDhrwAGm3MyNNGCc39W_4kTLJFbsYWjV5HoQ@mail.gmail.com> <53C3D322.3080302@att.net> <CAC=ypSXA8MZzT0V1RxhxyXd88Xk8od_6zmjn%2B9rd4W%2BtVgyvXQ@mail.gmail.com> <CAC=ypSUqHF%2B2_ajsjU5x3=if01twAtmsPcmQGBgNC=VEAdOKnQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------050503070806000304030204
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On 07/15/2014 13:49, Daniele Mazzotti wrote:
> Hello Anthony,
> I just noticed that I forgot to answer the part where you proposed me to
> "patch" my ACPI. Unfortunately I am running and AMD 64 architecture and I
> do not think this is fitting with what you already patched.
x86-based architectures use my patch, including amd64.  It patches the sys/x86/isa/atrtc.c driver.  I'll attach it... might fix some stuff.  I've been running it on my laptop for several weeks and posted it to this newsgroup some time ago, so it should be safe at least.

    # cd /usr/src && patch < path/to/atrtc.c.patch

> By the way I am not sure that what I wrote is that relevant to you, but I
> just wanted to give you the feeling that I am not just passively requiring
> help.

Not at all... I'm scared I can't really help you with your problem.  At least it helps me learn ACPI.

Anthony

P.S. I alternate between top-posting and bottom-posting, depending on the audience...I know I've switched at least twice in this thread.


> Cheers,
> Daniele.
>
>
> 2014-07-14 20:21 GMT+02:00 Daniele Mazzotti <kappei84@gmail.com>:
>
>> Hi Anthony,
>>
>> no problem for the "delay". I did not expect you to answer 5 seconds or 5
>> minutes after my email as I think we all have lives and jobs that keep us
>> busy quite a lot. So, no problem at all!
>>
>> Regarding the issue we are discussing about, I think I already posted the
>> output of "acpidump -dt" here http://pastebin.com/F0a2mZP4 and I also
>> tried to understand a bit of the contents but I had no luck. Unfortunately
>> I am not so much into this ACPI thing, but I am very interested to know how
>> it works and fix (my.... maybe also someone's else) bug.
>>
>> I followed your recommendation and enabled the debug in the loader.conf.
>> You can find my output here: http://pastebin.com/JXMjBhyx.
>> Thanks again for the precious help.
>>
>> Cheers,
>> Daniele.
>>


--------------050503070806000304030204
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 267519)
+++ 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,6 +54,10 @@
 #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)
 
@@ -161,8 +166,33 @@
 	struct resource *intr_res;
 	void *intr_handler;
 	struct eventtimer et;
+	ACPI_HANDLE acpi_handle;	/* Handle of the PNP0B00 node */
 };
 
+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 != 8 || address >= 64U)
+		return AE_BAD_PARAMETER;
+	switch (function) {
+		case ACPI_READ:
+			*((UINT8 *)value) = rtcin((int)address);
+			break;
+		case ACPI_WRITE:
+			writertc((int)address, *((UINT8 *)value));
+			break;
+		default:
+			return AE_BAD_PARAMETER;
+	}
+	return AE_OK;
+}
+
 static int
 rtc_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
 {
@@ -245,10 +275,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 +323,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 +412,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? */
@@ -402,3 +448,4 @@
 		rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
 }
 #endif /* DDB */
+

--------------050503070806000304030204--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53C58363.6050809>