From patchwork Wed Jul 4 13:09:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 10506873 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A456260325 for ; Wed, 4 Jul 2018 13:10:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9628626E16 for ; Wed, 4 Jul 2018 13:10:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A38228BAD; Wed, 4 Jul 2018 13:10:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CDB326E16 for ; Wed, 4 Jul 2018 13:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753106AbeGDNKk (ORCPT ); Wed, 4 Jul 2018 09:10:40 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:43545 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752715AbeGDNKj (ORCPT ); Wed, 4 Jul 2018 09:10:39 -0400 Received: by mail-qk0-f196.google.com with SMTP id z74-v6so2807902qkb.10 for ; Wed, 04 Jul 2018 06:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=9QrB2y5Kv1FZI3kGeliN2vKT/dNN90FegCD9rqEKlNA=; b=ATEDQwVXqU1CRbD7a7nUPhr9s1vHGeErFrvwrX5PnhQ9hqqf40IIN7IIPSS7HAO05h dPNp74mWXA58AKJYOwu/6/bHz2kopGIzUvkacOSSOpFiaSwLNmBIFg78A2/cfQeLA5X/ xdB55OoGedoiqUgugrxAHpor5gS3fT3K0sXB/scEtZLtGdrQGVgWs8ky5K2QWAxiN7U7 +MFXS5vLU9/Mhn/CnRdfh13IxryRw5Lye4Wpi6x8atSFE9qlhGvTHbNRu+HtSeq1JI+D c8C+Q+DjsNVn3jVkTWRUzlz/gdpe/5eR79jbEckDZ0kQV22uUrvKXqLf3DJ/F1hFN3CI ZICw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9QrB2y5Kv1FZI3kGeliN2vKT/dNN90FegCD9rqEKlNA=; b=DmvnGeL+E6k1wJerunrxB929OTqqZVgXxR7Si0vfwMKMbIcVo0/EAGId5cimICVwuG TT7W8HCVM55UD8skHiLfNgJlh/xdaNpXiJObjH+YDlYTnNYclX1eWm7w30QP1f84m02E xOoBtuvIxB365SPEiX4xpmoJIesFgntDPAfixPiYxqHxMIS6gLMDBopsC9JscYYO9nJX elpKVEkyOTn9I5FNJAr3O1uG+NxT70bsxHUqGgnXU1xKhGtIfL0BDdLDwhk/5USfVN0D fnJ2avmT0QyuAYDgNs+RhtEcwrYhwytQM6Tv237WSbEqQVe+8BNJDXYgAFkqYcgZF3hC 58LQ== X-Gm-Message-State: APt69E270+bUAWscDxBe9jHDFmeHvLjn/KfJm5875CFIMtUzYlK1aawx TDN2gde1z3oUczxBY/HUYp0= X-Google-Smtp-Source: AAOMgpdZrmPvCqQ5gticrFrhcf/gfPyox8mtYopCUJ2ZAaqu/hSn38QHQ80Q9LkZPsRbh4aTMgaofQ== X-Received: by 2002:a37:9846:: with SMTP id a67-v6mr1476723qke.219.1530709838401; Wed, 04 Jul 2018 06:10:38 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:482:8e7:ed0c:5c71:2b55:6107]) by smtp.gmail.com with ESMTPSA id m4-v6sm2570062qtm.79.2018.07.04.06.10.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Jul 2018 06:10:37 -0700 (PDT) From: Fabio Estevam To: Peter.Chen@nxp.com Cc: linux-usb@vger.kernel.org, andrew.smirnov@gmail.com, shawnguo@kernel.org, kernel@pengutronix.de, linux-imx@nxp.com, Fabio Estevam Subject: [PATCH v2] usb: chipidea: Always build ULPI code Date: Wed, 4 Jul 2018 10:09:58 -0300 Message-Id: <1530709798-6702-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabio Estevam Commit 03e6275ae381 ("usb: chipidea: Fix ULPI on imx51") causes a kernel hang on imx51 systems that use the ULPI interface and do not select the CONFIG_USB_CHIPIDEA_ULPI option. In order to avoid such potential misuse, let's always build the chipidea ULPI code into the final ci_hdrc object. Tested on a imx51-babbage board. Fixes: 03e6275ae381 ("usb: chipidea: Fix ULPI on imx51") Signed-off-by: Fabio Estevam --- Changes since v1: - Instead of warning when CONFIG_USB_CHIPIDEA_ULPI is not selected, let the chipidea ULPI code always to be built-in. (Peter) drivers/usb/chipidea/Kconfig | 9 +-------- drivers/usb/chipidea/Makefile | 3 +-- drivers/usb/chipidea/ci.h | 8 -------- drivers/usb/chipidea/ulpi.c | 6 ++++++ 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index 785f0ed..ee34e90 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig @@ -3,6 +3,7 @@ config USB_CHIPIDEA depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA select EXTCON select RESET_CONTROLLER + select USB_ULPI_BUS help Say Y here if your system has a dual role high speed USB controller based on ChipIdea silicon IP. It supports: @@ -38,12 +39,4 @@ config USB_CHIPIDEA_HOST help Say Y here to enable host controller functionality of the ChipIdea driver. - -config USB_CHIPIDEA_ULPI - bool "ChipIdea ULPI PHY support" - depends on USB_ULPI_BUS=y || USB_ULPI_BUS=USB_CHIPIDEA - help - Say Y here if you have a ULPI PHY attached to your ChipIdea - controller. - endif diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index e3d5e72..12df94f 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile @@ -1,11 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o -ci_hdrc-y := core.o otg.o debug.o +ci_hdrc-y := core.o otg.o debug.o ulpi.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o ci_hdrc-$(CONFIG_USB_OTG_FSM) += otg_fsm.o -ci_hdrc-$(CONFIG_USB_CHIPIDEA_ULPI) += ulpi.o # Glue/Bridge layers go here diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 0bf244d..6a2cc5c 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -240,10 +240,8 @@ struct ci_hdrc { struct ci_hdrc_platform_data *platdata; int vbus_active; -#ifdef CONFIG_USB_CHIPIDEA_ULPI struct ulpi *ulpi; struct ulpi_ops ulpi_ops; -#endif struct phy *phy; /* old usb_phy interface */ struct usb_phy *usb_phy; @@ -426,15 +424,9 @@ static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci) #endif } -#if IS_ENABLED(CONFIG_USB_CHIPIDEA_ULPI) int ci_ulpi_init(struct ci_hdrc *ci); void ci_ulpi_exit(struct ci_hdrc *ci); int ci_ulpi_resume(struct ci_hdrc *ci); -#else -static inline int ci_ulpi_init(struct ci_hdrc *ci) { return 0; } -static inline void ci_ulpi_exit(struct ci_hdrc *ci) { } -static inline int ci_ulpi_resume(struct ci_hdrc *ci) { return 0; } -#endif u32 hw_read_intr_enable(struct ci_hdrc *ci); diff --git a/drivers/usb/chipidea/ulpi.c b/drivers/usb/chipidea/ulpi.c index 6da42dc..bf57f33 100644 --- a/drivers/usb/chipidea/ulpi.c +++ b/drivers/usb/chipidea/ulpi.c @@ -85,6 +85,9 @@ int ci_ulpi_init(struct ci_hdrc *ci) void ci_ulpi_exit(struct ci_hdrc *ci) { + if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI) + return; + if (ci->ulpi) { ulpi_unregister_interface(ci->ulpi); ci->ulpi = NULL; @@ -95,6 +98,9 @@ int ci_ulpi_resume(struct ci_hdrc *ci) { int cnt = 100000; + if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI) + return 0; + while (cnt-- > 0) { if (hw_read(ci, OP_ULPI_VIEWPORT, ULPI_SYNC_STATE)) return 0;