Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jun 2014 16:33:13 -0700
From:      Adrian Chadd <adrian@freebsd.org>
To:        Anthony Jenkins <Anthony.B.Jenkins@att.net>
Cc:        "freebsd-acpi@freebsd.org" <freebsd-acpi@freebsd.org>
Subject:   Re: [PATCH] Naive implementation of AcpiExCmosSpaceHandler()
Message-ID:  <CAJ-VmonAJ6ZTSaLM6bO6P=9aXncVagHqH%2B4k86z7=czPEaytYQ@mail.gmail.com>
In-Reply-To: <538F16B5.8040208@att.net>
References:  <538F16B5.8040208@att.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi!

Would you mind throwing this into a bugzilla report?

https://bugs.freebsd.org/bugzilla/

That way it won't get lost?

Let me know what number it is and I'll chase it down and get it into -HEAD.

Thanks!


-a


On 4 June 2014 05:53, Anthony Jenkins <Anthony.B.Jenkins@att.net> wrote:
> Here's a naive implementation of AcpiExCmosSpaceHandler(), it simply uses=
 I/O ports 0x70 and 0x71 to read/write CMOS registers using AcpiHwWritePort=
()/AcpiHwReadPort() calls.  I'm new(ish) to the ACPICA subsystem and I'm pr=
obably not going about this the right way - I think I should implement an a=
ctual CMOS RTC device which handles the three PNP IDs that represent those =
hardware devices, but this was good enough for what I was trying to do.
>
> This fixes my HP Envy 6z-1100 laptop's suspend/resume (except video fails=
 to resume, but I believe that's due to backlight handling from my research=
).  Before, initiating a suspend (zzz(8)) caused the laptop to seemingly su=
spend and immediately resume.
>
> Now trying to track down the backlight issue. I implemented a missing _BQ=
C method which returns a single value from the _BCL listj; I think Linux do=
es some kind of vendor backlight control method if this method is missing.
>
> Suggestions welcome.
> Anthony Jenkins
>
> Index: sys/contrib/dev/acpica/components/events/evhandler.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- sys/contrib/dev/acpica/components/events/evhandler.c    (revision 266=
756)
> +++ sys/contrib/dev/acpica/components/events/evhandler.c    (working copy=
)
> @@ -70,6 +70,7 @@
>      ACPI_ADR_SPACE_SYSTEM_MEMORY,
>      ACPI_ADR_SPACE_SYSTEM_IO,
>      ACPI_ADR_SPACE_PCI_CONFIG,
> +    ACPI_ADR_SPACE_CMOS,
>      ACPI_ADR_SPACE_DATA_TABLE
>  };
>
> @@ -379,9 +380,12 @@
>       */
>      if ((Node->Type !=3D ACPI_TYPE_DEVICE)     &&
>          (Node->Type !=3D ACPI_TYPE_PROCESSOR)  &&
> +    (Node->Type !=3D ACPI_TYPE_REGION)     &&
>          (Node->Type !=3D ACPI_TYPE_THERMAL)    &&
>          (Node !=3D AcpiGbl_RootNode))
>      {
> +        ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
> +            "Device %p not a DEVICE, PROCESSOR, REGION, THERMAL type or =
root node.\n", Node));
>          Status =3D AE_BAD_PARAMETER;
>          goto UnlockAndExit;
>      }
> Index: sys/contrib/dev/acpica/components/executer/exregion.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- sys/contrib/dev/acpica/components/executer/exregion.c    (revision 26=
6756)
> +++ sys/contrib/dev/acpica/components/executer/exregion.c    (working cop=
y)
> @@ -449,7 +449,21 @@
>      return_ACPI_STATUS (Status);
>  }
>
> +static UINT8 AcpiExCmosRead(ACPI_PHYSICAL_ADDRESS Address)
> +{
> +    UINT32 Value32;
>
> +    AcpiHwWritePort((ACPI_IO_ADDRESS) 0x70, (UINT32) Address, 8);
> +    AcpiHwReadPort ((ACPI_IO_ADDRESS) 0x71, &Value32, 8);
> +    return Value32 & 0xFF;
> +}
> +
> +static void AcpiExCmosWrite(ACPI_PHYSICAL_ADDRESS Address, UINT8 Value)
> +{
> +    AcpiHwWritePort((ACPI_IO_ADDRESS) 0x70, (UINT32) Address, 8);
> +    AcpiHwWritePort((ACPI_IO_ADDRESS) 0x71, (UINT32) Value, 8);
> +}
> +
>  /***********************************************************************=
********
>   *
>   * FUNCTION:    AcpiExCmosSpaceHandler
> @@ -473,7 +487,7 @@
>      UINT32                  Function,
>      ACPI_PHYSICAL_ADDRESS   Address,
>      UINT32                  BitWidth,
> -    UINT64                  *Value,
> +    UINT64                  *Value64,
>      void                    *HandlerContext,
>      void                    *RegionContext)
>  {
> @@ -482,7 +496,23 @@
>
>      ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
>
> +    if (Address < 0x80 &&
> +        (Function =3D=3D ACPI_READ || Function =3D=3D ACPI_WRITE) &&
> +        BitWidth <=3D 64)
> +    {
> +        UINT32 i;
> +        UINT8 *Value =3D (UINT8 *)Value64;
>
> +        for (i =3D 0; i < (BitWidth + 7) / 8; ++i, ++Address, ++Value) {
> +            if (Function =3D=3D ACPI_READ) {
> +                *Value =3D AcpiExCmosRead(Address);
> +            } else {
> +                AcpiExCmosWrite(Address, *Value);
> +            }
> +        }
> +    } else {
> +        Status =3D AE_BAD_PARAMETER;
> +    }
>      return_ACPI_STATUS (Status);
>  }
>
> Index: sys/contrib/dev/acpica/include/acconfig.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- sys/contrib/dev/acpica/include/acconfig.h    (revision 266756)
> +++ sys/contrib/dev/acpica/include/acconfig.h    (working copy)
> @@ -194,7 +194,7 @@
>  /* Maximum SpaceIds for Operation Regions */
>
>  #define ACPI_MAX_ADDRESS_SPACE          255
> -#define ACPI_NUM_DEFAULT_SPACES         4
> +#define ACPI_NUM_DEFAULT_SPACES         5
>
>  /* Array sizes. Used for range checking also */
>
>
>
> _______________________________________________
> 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"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-VmonAJ6ZTSaLM6bO6P=9aXncVagHqH%2B4k86z7=czPEaytYQ>