From patchwork Mon Aug 19 09:03:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 13768094 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 712A215D5CA for ; Mon, 19 Aug 2024 09:04:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724058277; cv=none; b=c2fG0ok8dcE0Bfa4LCj3f0ZLA5OARduSsrW1g3Vc4GcNSMLJ2dAIjCDiN/tt9oScJfjDgl3j2kBKG5S4IXyA9knMyls/xaSohBBbeABlSbOizqS41+mtJNlZB5gaG1rJl3cnw4MgEm6Fi2vnL8j+BRaSdQtZryvO/40cnM3yE3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724058277; c=relaxed/simple; bh=PBWJwpQrTmQMhxS1evGm66Kvqii7McCIh/AU7DcqbUI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dR0Zf8KPFJPsXI51eiH7Regv2eGoZamlQwKoEHmlYGbs0gtoBwm7QNm1MJqk3zOMvWMOPbiyA1nnBrJrtE/e1OuZHFYLvpgUtabg+jO13U5QT0VtihHnY8GC/5yIcm9NJkVWRfccU/iUt9bgebnWSCWcu15/aUTR4doh7nN5fkk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KHqejUBT; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KHqejUBT" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3719f0758c6so1340179f8f.1 for ; Mon, 19 Aug 2024 02:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724058274; x=1724663074; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m1WZmnJzwRNoGQ6pe2EZwbvZJ2ojrMh6cxbYC/hMf9M=; b=KHqejUBT3iBbUaseY9vGpsHnqJ+SlDl+q2sI7L9n6wK+Fb1ZENSK7uWrS83OtR2kEp /uAtz2s89ADJB056piqtokTi8EiAdwNfZi+8XuR/hJlXJcFnQShD8CedAAwZJ2TwzYjo 1hWS4BAr8KgAGziTq2qw8aeW78MdkxIQIjyw7aB5vJbxdkFkn1pZdh/NC+daXx/Qwu1L eYXa1GrsfRZTdi4mbhK4qslLNFspGPjCZYLjT2HWv+jwQWH2uUVawmnfUruoLVvK5dg4 mzthMhyOy+mW8/8GHRMgNqLsuX2VxVMSyPoZKnMTNtUtE4SzR7jfmyAcMroEE2SS9Wkw nqrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724058274; x=1724663074; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m1WZmnJzwRNoGQ6pe2EZwbvZJ2ojrMh6cxbYC/hMf9M=; b=FemngNiF3nWa5QsHWGSev4znwphwEq09o6wavpzAXpTu0rBzDVawzyaUT9xBnUaHwS L9g2hqogBL2zRl+0kO7dp6a54cxXXW0i+KdaBi9ddrndFd+8sSwmZ2GotlBN3VRWwPoL dHgXzlO2uaQFaU9WP4Wuv4RG3bfeWr2IS8HjdCAu5FzZISdd6csQMD19/KCcUskhJ/ZK 0VxP2o7Hrd+cqF1dacF1N4tpxoY8hWWALfDgTPYbq/nF0sVuaCXWYqjYPiHcWvytVc4D MNaW9ZiI8AjI7WWxSKC/CaTmXzlLhjADsSLPjYf/vHN3VzfkatscO4ycZ/irjdbOGDv7 C+AA== X-Forwarded-Encrypted: i=1; AJvYcCUdyRMWvPb0wIDzd6R417wjJiCXf0j5kj6oHRBYg3jizHb5TQMigjM/H/aFxQtfBG0larI30SaD34MQshnZ/wgtbKyU X-Gm-Message-State: AOJu0YzJ5DGQMNVXPFZOa20WDxuVckZGhhihLOTGSxyo0PA59hxYlc2U UiFdxxxH/o5cCKfaVop4cOInqS+YWgZVYRi1Aqn8I5JdF3O1dLlh X-Google-Smtp-Source: AGHT+IHE05TuCyt00A6s9cE1mKfpK9EVIx9TkS3oCHaFi1BhoF8/ztPZ5xgaGZQyiwuRYNARtev9jw== X-Received: by 2002:a05:6000:1a89:b0:371:8d08:6309 with SMTP id ffacd0b85a97d-371a7477af5mr5590541f8f.55.1724058273566; Mon, 19 Aug 2024 02:04:33 -0700 (PDT) Received: from eichest-laptop.toradex.int ([2a02:168:af72:0:a64c:8731:e4fb:38f1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded19627sm154672095e9.5.2024.08.19.02.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 02:04:33 -0700 (PDT) From: Stefan Eichenberger To: hongxing.zhu@nxp.com, l.stach@pengutronix.de, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, francesco.dolcini@toradex.com Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org, Stefan Eichenberger Subject: [PATCH v1 1/3] PCI: imx6: Add a function to deassert the reset gpio Date: Mon, 19 Aug 2024 11:03:17 +0200 Message-ID: <20240819090428.17349-2-eichest@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240819090428.17349-1-eichest@gmail.com> References: <20240819090428.17349-1-eichest@gmail.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Stefan Eichenberger To avoid code duplication, move the code to disable the reset GPIO to a separate function. Signed-off-by: Stefan Eichenberger --- drivers/pci/controller/dwc/pci-imx6.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 964d67756eb2b..fda704d82431f 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -722,6 +722,17 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) gpiod_set_value_cansleep(imx6_pcie->reset_gpiod, 1); } +static void imx6_pcie_deassert_reset_gpio(struct imx6_pcie *imx6_pcie) +{ + /* Some boards don't have PCIe reset GPIO. */ + if (imx6_pcie->reset_gpiod) { + msleep(100); + gpiod_set_value_cansleep(imx6_pcie->reset_gpiod, 0); + /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */ + msleep(100); + } +} + static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) { struct dw_pcie *pci = imx6_pcie->pci; @@ -766,13 +777,7 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) break; } - /* Some boards don't have PCIe reset GPIO. */ - if (imx6_pcie->reset_gpiod) { - msleep(100); - gpiod_set_value_cansleep(imx6_pcie->reset_gpiod, 0); - /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */ - msleep(100); - } + imx6_pcie_deassert_reset_gpio(imx6_pcie); return 0; }