From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751204AbdKSSMT (ORCPT ); Sun, 19 Nov 2017 13:12:19 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:34967 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751014AbdKSSMR (ORCPT ); Sun, 19 Nov 2017 13:12:17 -0500 X-Auth-Info: KDAZgpVLltRP9nmz9+4cnUXTsWrEATJOBCce0GNmiIs= Subject: Re: [RFC] iio: light: acpi-als: Enable the light sensor on the Zenbook UX430UQ To: Gabriele Mazzotta , Jonathan Cameron Cc: Kiernan Hager , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" References: <20171116032754.20719-1-kah.listaddress@gmail.com> <20171119170341.62e5de3d@archlinux> From: Marek Vasut Message-ID: <2bf0e8c2-efe9-c309-844c-de5392216848@denx.de> Date: Sun, 19 Nov 2017 19:11:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/19/2017 06:38 PM, Gabriele Mazzotta wrote: > 2017-11-19 18:03 GMT+01:00 Jonathan Cameron : >> On Wed, 15 Nov 2017 20:27:54 -0700 >> Kiernan Hager wrote: >> >>> This makes acpi-als properly enable the light sensor on the Zenbook UX430UQ. I don't know if the checking that I do to make sure that the ACPI method exists is sufficient or if it should disable the sensor when the module is unloaded, so input is appreciated on those matters. >> >> Please wrap descriptions to around 72 characters (leaves room for indentation >> in the email thread :) >> >> This seems very much like a board specific hack. I've cc'd people >> who have worked on the driver recently and the acpi list. > > This is indeed board specific. I know many other laptops of the > Zenbook line need something similar and if you look at > drivers/platform/x86/asus-wmi.c or any other asus-* driver you'll > find several quirks to enable various features. Maybe that's where it should go . EC0 in the ACPI path seems like Embedded Controller to me . > Kiernan, check commit aca234f6378864d85514be558746c0ea6eabfa8e > ("asus-wmi: provide access to ALS control") in particular. > >>> >>> Signed-off-by: Kiernan Hager >>> --- >>> drivers/iio/light/acpi-als.c | 16 ++++++++++++++++ >>> 1 file changed, 16 insertions(+) >>> >>> diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c >>> index c35e2f8df339..8fd66166f19f 100644 >>> --- a/drivers/iio/light/acpi-als.c >>> +++ b/drivers/iio/light/acpi-als.c >>> @@ -179,6 +179,10 @@ static int acpi_als_add(struct acpi_device *device) >>> struct acpi_als *als; >>> struct iio_dev *indio_dev; >>> struct iio_buffer *buffer; >>> + unsigned long long temp_val; >>> + acpi_status status; >>> + struct acpi_object_list arg_list; >>> + union acpi_object arg; >>> >>> indio_dev = devm_iio_device_alloc(&device->dev, sizeof(*als)); >>> if (!indio_dev) >>> @@ -203,6 +207,18 @@ static int acpi_als_add(struct acpi_device *device) >>> >>> iio_device_attach_buffer(indio_dev, buffer); >>> >>> + arg_list.count = 1; >>> + arg_list.pointer = &arg; >>> + arg.type = ACPI_TYPE_INTEGER; >>> + arg.integer.value = 1; >>> + >>> + if (acpi_has_method(als->device->handle, "\\_SB.PCI0.LPCB.EC0.ALSC")) { >> So this is poking something on >> PCI bus 0 >> LPC bus B >> Somethingbus 0 >> Ambient light controller. >> >> I assume there is a better way of establishing this needs to be set? >> >>> + status = acpi_evaluate_integer(als->device->handle, >>> + "\\_SB.PCI0.LPCB.EC0.ALSC", >>> + &arg_list, >>> + &temp_val); >>> + } >>> + >>> return devm_iio_device_register(&device->dev, indio_dev); >>> } >>> >> -- Best regards, Marek Vasut