Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1272614pxk; Fri, 2 Oct 2020 05:41:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYYSAmNYoTTwud264nT1i+wdVlzcBl7Hs7vKBxl0/1PE13GE+5nxcNgDLnjHOzeGocV45I X-Received: by 2002:aa7:c0d3:: with SMTP id j19mr2169162edp.40.1601642519184; Fri, 02 Oct 2020 05:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601642519; cv=none; d=google.com; s=arc-20160816; b=Wh7BBBAO31ZUi5OucM2WLaJHCvU1ZIXCMNU4mCYtSg3nlMMlwJvd97DLzlnk9HjGTE 8ciiyq+QGSwW7+kWd+q62/RQBBherB+IHFeGZcctgaKUKTzv9N0LXUUG6TGVgVRmhnr4 S7t6TIu2nZuWz8MNTpceeHTQJ/dQfUyrj2duiNdo6DFgglRlKw0+v2btHsB2eWYrFnkV uQiUzL++T3r4WxRDdovyL/MBm6bTBQideq0i3DNt9TpL8o7RPtX7eBA9FtGcR7jKCkGm qoqtx3/cKKY5nwpAMInqZeLG2A9tcKdCCXfRhevtV8olbO1K0HGWSC0SOwoJP2YkwTbA 5kjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hNDtci8LWxqyWzF+Qr4E7pl31hjetSM6HC8+XaPpaC4=; b=qWThw3nau/7kGkEMO8g3ZcnJiGQ5qncj5cTpUWQ//WRIkXN3kWmIPRv15bAkgC8Suj MjE+B9O5obYT5IhrqP15V3263/uCSscvOfCIhR0ILchOyqNwyaL7BnOq9E6BvSkl+1tF Jkdu/8LvI6j/Jlfp+zbJ0FRdjEUqfnCxXvedeHOBwxZug6lUEgiT4+lO0axmYhrR0zxm m7lNEJLKnQcH/jIS3MlbocWIYCalHPqKqPsLnPIiyf+nFh1AAHOOoHwJwGoMtaYG6Uod KvPVa56Mho8UBd27shgDOzDleLzmdGEuON3CG9WaRRCs3HSXkOPOhWOi2ODIIWw7SBJb Ux/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=En3KJozJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk22si656146edb.258.2020.10.02.05.41.36; Fri, 02 Oct 2020 05:41:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=En3KJozJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387817AbgJBMke (ORCPT + 99 others); Fri, 2 Oct 2020 08:40:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725964AbgJBMke (ORCPT ); Fri, 2 Oct 2020 08:40:34 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B5B6C0613D0; Fri, 2 Oct 2020 05:40:32 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o25so717801pgm.0; Fri, 02 Oct 2020 05:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hNDtci8LWxqyWzF+Qr4E7pl31hjetSM6HC8+XaPpaC4=; b=En3KJozJK5WeYTddVtiDVbAwtndZnCJignJMqdPOoYmeYCoQF5+J9dTLeiQto3e/AV Js5C7gz7Kg+WBHQGahVlaITJxmOLQTQhmkj1DWtwf0nzS5pz2qUP8/oKt9JXFBAlN9uC NWNXvPj5QRh7D1EDpf8psBekoWrfXiQFfD7SiEVBgRGb0xAbS/9kyJrZh3gYJ5lioPUx yVNtsm1jP+9r5MEIglAoYQAmOn4D5JM/jSyo2QRlGnCUZLhQSinYe2miDqzwP5ZEPMAq f9Y2Y/1s1pQBHyx/x7CpyBi7/HG7LJMjWniLdRwMMzpFMdea5Tk+MAfmtzxSKYmv0MCJ oHrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hNDtci8LWxqyWzF+Qr4E7pl31hjetSM6HC8+XaPpaC4=; b=N3pqKT4//hImmbQ59FaOW2eqQz773JpQ+GQYCrwoURU5EGY3wHRAiickHSi+1KbTrN 3AEyqR/d2eUVdwKLYLgCXjAuhpiuYDwU+QJkT+iztoJOlRXoe/jTqYmdfp/nbN3Pvumc d1xRBM3FNgnahghdqcdz+WAg6tGHC28P87xbCj0UZcIA4+YGjDvzmh3klp+8uvaOYxxr QL5/yilVZgxNYYgXgzN87CY3EhfCCLEUsxW5vBVGB9PO4LMHlz0XEoaSFhR5E4cUYFHP Tz4qs50oB4+hFABdVeJC8toXIXyfhqwfybUQCIqIEuWqsTuVqhkuacickG4kj6+Qmsjl OQTQ== X-Gm-Message-State: AOAM533KuWufEYChbelN6No/OGjKOyfMwcowQw23sBejDTyEA5Jusx9j tDGeSEcMClnPnH/9HJEPVdDq75wgBlcf2c14SNtPqifds/2l+w== X-Received: by 2002:a63:4c1d:: with SMTP id z29mr2036940pga.203.1601642431884; Fri, 02 Oct 2020 05:40:31 -0700 (PDT) MIME-Version: 1.0 References: <9152bb8be33e4192a7766eb53c6ca9af@asem.it> <22753b53cd7d4dfba4ef3610f71cc462@asem.it> <20200930130113.GQ3956970@smile.fi.intel.com> <2c26adae711145639d0b982a354aff3c@asem.it> <8b6adbc45d134da7b0fd1f9044a37cf6@asem.it> In-Reply-To: <8b6adbc45d134da7b0fd1f9044a37cf6@asem.it> From: Andy Shevchenko Date: Fri, 2 Oct 2020 15:40:13 +0300 Message-ID: Subject: Re: How to use an ACPI declared GPIO in a userspace ... To: Flavio Suligoi Cc: Bartosz Golaszewski , "linux-gpio@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 2, 2020 at 1:26 PM Flavio Suligoi wrote: > Hi Andy, > > with my custom SSDT table: > > DefinitionBlock ("gpio_button.aml", "SSDT", 5, "ASEMsp", "GPIO_BTN", 1) > { > External (_SB_.GPO1, DeviceObj) > Scope (\_SB.GPO1) > { > Device (BTNS) > { > Name (_HID, "ASEM0005") // _HID: Hardware ID PRP0001 > Name (_UID, Zero) // _UID: Unique ID > Name (_DDN, "DDN - SW Readable Button") // _DDN: DOS Device Name > Name (_STR, Unicode ("STR - SW Readable Button")) // _STR: Description String > > Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings > { > GpioIo ( > Shared, // Not shared > PullNone, // No need for pulls > 0, // Debounce timeout > 0, // Drive strength > IoRestrictionInputOnly, // Only used as input > "\\_SB.GPO1", // GPIO controller > 0, ResourceConsumer, , ) // Must be 0 > { > 25, // GPIO number 25 > } > }) > } > } > } > > I'm able to see the GPIO in: > > /sys/bus/platform/devices/ASEM0005:00/firmware_node: > > -r--r--r-- 1 root root 4096 Oct 2 12:10 description > -r--r--r-- 1 root root 4096 Oct 2 12:10 hid > -r--r--r-- 1 root root 4096 Oct 2 12:10 modalias > -r--r--r-- 1 root root 4096 Oct 2 12:10 path > lrwxrwxrwx 1 root root 0 Oct 2 12:10 physical_node -> ../../../../platform/INT3452:01/ASEM0005:00 > drwxr-xr-x 2 root root 0 Oct 2 12:10 power > lrwxrwxrwx 1 root root 0 Oct 2 12:10 subsystem -> ../../../../../bus/acpi > -rw-r--r-- 1 root root 4096 Oct 2 12:10 uevent > -r--r--r-- 1 root root 4096 Oct 2 12:10 uid > > and so I can see some useful info: > > # cat description > STR - SW Readable Button > # cat hid > ASEM0005 > # cat modalias > acpi:ASEM0005: > bmxxxx-x86-64:/sys/bus/platform/devices/ASEM0005:00/firmware_node# cat path > \_SB_.GPO1.BTNS > > So, from userspace, I can discover the GPIO controller /dev/gpiochip1, > but I don't know how to discover the GPIO number (25 in this case). > Do you have any suggestion about how to discover this GPIO number? You don't need this SSDT at all. -- With Best Regards, Andy Shevchenko