From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753209AbdCMJXe (ORCPT ); Mon, 13 Mar 2017 05:23:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46944 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751669AbdCMIkI (ORCPT ); Mon, 13 Mar 2017 04:40:08 -0400 From: Hans de Goede To: MyungJoo Ham , Chanwoo Choi , Chen-Yu Tsai Cc: Hans de Goede , linux-kernel@vger.kernel.org, Andy Shevchenko Subject: [PATCH v2] extcon: int3496: Set the id pin to direction-input if necessary Date: Mon, 13 Mar 2017 09:40:03 +0100 Message-Id: <20170313084003.14416-1-hdegoede@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 13 Mar 2017 08:40:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the new more strict ACPI gpio code the dsdt's IoRestriction flags are honored on gpiod_get, but in some dsdt's it is wrong, so explicitly call gpiod_direction_input on the id gpio if necessary. This fixes the following errors when the int3496 code is used together with the new more strict ACPI gpio code: [ 2382.484415] gpio gpiochip1: (INT33FF:01): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ [ 2382.484425] gpio gpiochip1: (INT33FF:01): unable to lock HW IRQ 3 for IRQ [ 2382.484429] genirq: Failed to request resources for INT3496:00 (irq 174) on irqchip chv-gpio [ 2382.484518] intel-int3496 INT3496:00: can't request IRQ for USB ID GPIO: -22 [ 2382.500359] intel-int3496: probe of INT3496:00 failed with error -22 Cc: Andy Shevchenko Signed-off-by: Hans de Goede --- Changes in v2: -Warn about firmware bug when the dsdt's IoRestriction does not allow input --- drivers/extcon/extcon-intel-int3496.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c index b8ac947..18801eb 100644 --- a/drivers/extcon/extcon-intel-int3496.c +++ b/drivers/extcon/extcon-intel-int3496.c @@ -113,6 +113,10 @@ static int int3496_probe(struct platform_device *pdev) dev_err(dev, "can't request USB ID GPIO: %d\n", ret); return ret; } + if (gpiod_get_direction(data->gpio_usb_id) != GPIOF_DIR_IN) { + dev_warn(dev, "firmware bug USB ID GPIO not in input mode, fixing\n"); + gpiod_direction_input(data->gpio_usb_id); + } data->usb_id_irq = gpiod_to_irq(data->gpio_usb_id); if (data->usb_id_irq < 0) { -- 2.9.3