Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4596895pxj; Wed, 12 May 2021 08:57:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDLCodm9AiQHvlIvhyQ5xsoLDqdd/PTfBQd8GXZCqjucLZPgb0mKdc0s7/KSuZtAsjgyJn X-Received: by 2002:aa7:dc49:: with SMTP id g9mr678165edu.160.1620835028508; Wed, 12 May 2021 08:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835028; cv=none; d=google.com; s=arc-20160816; b=sFnM1AEqnRRzTDMGyKgeYcsnq+mPHF+NEFU0udREuUXOIcluDhgoO+Awre6F2PusED HtsSlQhbKB7QA0GxaCC0AODMV5BRYyPba2KQcqNWMTkwLWEz8XFmzogbIIVBqtePXF02 IMeRLP9lFsFR7l8qmsZ/qeUoLlHzEn61x9mECAtOE23W2eh3lQDGrpdGXJHWZKUomKg7 7mqXQjdfiRWqtBUjfI7mAIa1q4fYoe4rD1K6rTZApF0l7CSHfDzOqhcnZc8dNpGLH2sh cLWg3jsnKVPqoE3Gg1mGmekr6Mj6YUmkBTK8Y24tZeqD2VA6E1Qu35Ud4wKVaVLwqwti kBYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SR9i1hOeO8lhoEHmULBiGVZpYgX2p7eTDd6Uju4nZS4=; b=SJI22taDzV54alD2tSOnaSElOLW0xy+EfhDNOsTcKadKX/KpjBLo2RI2vBtJRhDSfE wAn+SPvzyNns3zxmPiBO8P6Fre8y3U6wDFsfzP1BULJUMJJ3fouVDfE8xOFUCcABpzjd YLNkO5QsjQEChkdj02UwK+/oxIS5HUU85Roak1UUVGr3AdJNrl4LERAr4sUjCn0PX1bn qjok5T2ZLjI0pVYQV+3M7h5j4VxxyxLqOVflv2sWstAeFWpfWyUMNXi9JVZRKBCMSPvn 6V7qsr8OSQKnoEecdehPhTYn5+y+UT+BQ9spyPDvRnv2b29sQeBgygZ/kkmqUpMCqbGe TV2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Wwrh6/kl"; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si17611edq.445.2021.05.12.08.56.38; Wed, 12 May 2021 08:57:08 -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=@linuxfoundation.org header.s=korg header.b="Wwrh6/kl"; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237236AbhELPs6 (ORCPT + 99 others); Wed, 12 May 2021 11:48:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:59196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233900AbhELPXO (ORCPT ); Wed, 12 May 2021 11:23:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 902B9619AF; Wed, 12 May 2021 15:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832178; bh=cM4N5uP7brzU1NXDwWlNLOAKsrLCvAENPmzXLCdGhZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wwrh6/klKw0zy00ev2Pdd9wG3eBoKawswcpyzYlG0nrqJoDROIG8WENhIJJszEVoq etegs4SPMO68eJNgxIZZf4dk7rVIh1zdNrAHLY+vtn2DefpzvmV8nnIWUl/EvgjCr7 aznJvtpEujkdECr56Vk6lUHgfAw/OHi1OsamtFoI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Sasha Levin Subject: [PATCH 5.10 172/530] usb: gadget: pch_udc: Provide a GPIO line used on Intel Minnowboard (v1) Date: Wed, 12 May 2021 16:44:42 +0200 Message-Id: <20210512144825.488857728@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko [ Upstream commit 049d3db625a652e23488db88b6104de4d5b62f16 ] Intel Minnowboard (v1) uses SCH GPIO line SUS7 (i.e. 12) for VBUS sense. Provide a DMI based quirk to have it's being used. Fixes: e20849a8c883 ("usb: gadget: pch_udc: Convert to use GPIO descriptors") Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210323153626.54908-7-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/pch_udc.c | 71 +++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c index a39122f01cdb..fd3656d0f760 100644 --- a/drivers/usb/gadget/udc/pch_udc.c +++ b/drivers/usb/gadget/udc/pch_udc.c @@ -7,12 +7,14 @@ #include #include #include +#include #include +#include +#include #include #include #include #include -#include #include #define PCH_VBUS_PERIOD 3000 /* VBUS polling period (msec) */ @@ -1359,6 +1361,43 @@ static irqreturn_t pch_vbus_gpio_irq(int irq, void *data) return IRQ_HANDLED; } +static struct gpiod_lookup_table minnowboard_udc_gpios = { + .dev_id = "0000:02:02.4", + .table = { + GPIO_LOOKUP("sch_gpio.33158", 12, NULL, GPIO_ACTIVE_HIGH), + {} + }, +}; + +static const struct dmi_system_id pch_udc_gpio_dmi_table[] = { + { + .ident = "MinnowBoard", + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "MinnowBoard"), + }, + .driver_data = &minnowboard_udc_gpios, + }, + { } +}; + +static void pch_vbus_gpio_remove_table(void *table) +{ + gpiod_remove_lookup_table(table); +} + +static int pch_vbus_gpio_add_table(struct pch_udc_dev *dev) +{ + struct device *d = &dev->pdev->dev; + const struct dmi_system_id *dmi; + + dmi = dmi_first_match(pch_udc_gpio_dmi_table); + if (!dmi) + return 0; + + gpiod_add_lookup_table(dmi->driver_data); + return devm_add_action_or_reset(d, pch_vbus_gpio_remove_table, dmi->driver_data); +} + /** * pch_vbus_gpio_init() - This API initializes GPIO port detecting VBUS. * @dev: Reference to the driver structure @@ -1377,8 +1416,12 @@ static int pch_vbus_gpio_init(struct pch_udc_dev *dev) dev->vbus_gpio.port = NULL; dev->vbus_gpio.intr = 0; + err = pch_vbus_gpio_add_table(dev); + if (err) + return err; + /* Retrieve the GPIO line from the USB gadget device */ - gpiod = devm_gpiod_get(d, NULL, GPIOD_IN); + gpiod = devm_gpiod_get_optional(d, NULL, GPIOD_IN); if (IS_ERR(gpiod)) return PTR_ERR(gpiod); gpiod_set_consumer_name(gpiod, "pch_vbus"); @@ -2888,14 +2931,20 @@ static void pch_udc_pcd_reinit(struct pch_udc_dev *dev) * @dev: Reference to the driver structure * * Return codes: - * 0: Success + * 0: Success + * -%ERRNO: All kind of errors when retrieving VBUS GPIO */ static int pch_udc_pcd_init(struct pch_udc_dev *dev) { + int ret; + pch_udc_init(dev); pch_udc_pcd_reinit(dev); - pch_vbus_gpio_init(dev); - return 0; + + ret = pch_vbus_gpio_init(dev); + if (ret) + pch_udc_exit(dev); + return ret; } /** @@ -3097,16 +3146,10 @@ static int pch_udc_probe(struct pci_dev *pdev, dev->base_addr = pcim_iomap_table(pdev)[bar]; - /* - * FIXME: add a GPIO descriptor table to pdev.dev using - * gpiod_add_descriptor_table() from based on - * the PCI subsystem ID. The system-dependent GPIO is necessary for - * VBUS operation. - */ - /* initialize the hardware */ - if (pch_udc_pcd_init(dev)) - return -ENODEV; + retval = pch_udc_pcd_init(dev); + if (retval) + return retval; pci_enable_msi(pdev); -- 2.30.2