From patchwork Mon Apr 29 10:23:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13646548 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D7E42940C; Mon, 29 Apr 2024 10:25:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386322; cv=none; b=PolfahV+cdx5tIEuwZpW1ZNdbzYOHXbOtExNL90QESm8fIupwwjvd2ZoFnD8Kus45tLDlqAGmRcs/FTSsG1f5rMHwofwgZ7JU77tsMZoGF5Jqj8YB8Eb6BQXHgtNdnFbLLDlKgSgzJPmv72PkAbd+CvjKu+Hsm9oe1HEZmLp6GA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386322; c=relaxed/simple; bh=uldoHXOi58gOtXmEwfsBKEgTKr1MJDimWsgLcyfBNoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DnrZ0+ToIIO+B6G0w+gCUa4+H9p1FFQqyUxrpekwCO/7LB0ql71c6fANPTuornnRMcU8utg6RhhPV0CPz09OYJhsfbs1wrWwqLN3dEBFyqtogczjfBlg6p7eTKXitc5iULkKyuu1k2F+vQfsiV5Qf407e9Q+zPdTvO+MqjdQySs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=U0shSVIz; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="U0shSVIz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714386321; x=1745922321; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uldoHXOi58gOtXmEwfsBKEgTKr1MJDimWsgLcyfBNoE=; b=U0shSVIzntZrBgpVEklUKQo5WW2mkxVdmN1+cnKccY2YNnDOWAcY1oOj zG240iFfGyGqOFYZ1jXzy1GKWMV2pWjjc22+G9KlhFibEkCrmH25UyzxS ucAAOnzT9CI5wcmU/P6l4yabxyaSzumjVLjQK6TNBBro2wJQCskxpPYlU 5RVjqZZvVMopY7nSePk9eu3vVu9zVSfkYmPAAGAiuJOOtAL/EiqYAseXt sqeZefWv0EuzXOzhtdPYBAqbd7MM40IC1MJn8qU1Z0Qpcv+Kqn4G+IOPM NwGtCagIZ8Ngas4AoUX35sckNIboNVT2SObTDSlIAFcJoGAzsKg5QlvJK w==; X-CSE-ConnectionGUID: Q0ttS7hJRze7/X/Kc4ERtA== X-CSE-MsgGUID: q1p8SjBsTcio663kcOH4Ww== X-IronPort-AV: E=McAfee;i="6600,9927,11057"; a="20726812" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="20726812" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 03:25:20 -0700 X-CSE-ConnectionGUID: U0qSP98fTDCPthNQcPK/6Q== X-CSE-MsgGUID: B/DsE5IrSSKOPrsPw4XOoQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26176422" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa006.fm.intel.com with ESMTP; 29 Apr 2024 03:25:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C4185299; Mon, 29 Apr 2024 13:25:11 +0300 (EEST) From: Andy Shevchenko To: Manivannan Sadhasivam , Frank Li , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-omap@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Vignesh Raghavendra , Siddharth Vadapalli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Yue Wang , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Xiaowei Song , Binghui Wang , Thierry Reding , Jonathan Hunter , Thomas Petazzoni , =?utf-8?q?Pali_Roh=C3=A1r?= Subject: [PATCH v3 4/5] PCI: imx6: Convert to agnostic GPIO API Date: Mon, 29 Apr 2024 13:23:21 +0300 Message-ID: <20240429102510.2665280-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240429102510.2665280-1-andriy.shevchenko@linux.intel.com> References: <20240429102510.2665280-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The of_gpio.h is going to be removed. In preparation of that convert the driver to the agnostic API. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Frank Li Signed-off-by: Andy Shevchenko --- drivers/pci/controller/dwc/pci-imx6.c | 37 ++++++++++----------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 917c69edee1d..d620f1e1a43c 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -11,14 +11,13 @@ #include #include #include -#include +#include #include #include #include #include #include #include -#include #include #include #include @@ -107,7 +106,7 @@ struct imx6_pcie_drvdata { struct imx6_pcie { struct dw_pcie *pci; - int reset_gpio; + struct gpio_desc *reset_gpiod; bool gpio_active_high; bool link_is_up; struct clk_bulk_data clks[IMX6_PCIE_MAX_CLKS]; @@ -721,9 +720,8 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) } /* Some boards don't have PCIe reset GPIO. */ - if (gpio_is_valid(imx6_pcie->reset_gpio)) - gpio_set_value_cansleep(imx6_pcie->reset_gpio, - imx6_pcie->gpio_active_high); + gpiod_set_raw_value_cansleep(imx6_pcie->reset_gpiod, + imx6_pcie->gpio_active_high); } static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) @@ -771,10 +769,10 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) } /* Some boards don't have PCIe reset GPIO. */ - if (gpio_is_valid(imx6_pcie->reset_gpio)) { + if (imx6_pcie->reset_gpiod) { msleep(100); - gpio_set_value_cansleep(imx6_pcie->reset_gpio, - !imx6_pcie->gpio_active_high); + gpiod_set_raw_value_cansleep(imx6_pcie->reset_gpiod, + !imx6_pcie->gpio_active_high); /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */ msleep(100); } @@ -1285,22 +1283,15 @@ static int imx6_pcie_probe(struct platform_device *pdev) return PTR_ERR(pci->dbi_base); /* Fetch GPIOs */ - imx6_pcie->reset_gpio = of_get_named_gpio(node, "reset-gpio", 0); imx6_pcie->gpio_active_high = of_property_read_bool(node, "reset-gpio-active-high"); - if (gpio_is_valid(imx6_pcie->reset_gpio)) { - ret = devm_gpio_request_one(dev, imx6_pcie->reset_gpio, - imx6_pcie->gpio_active_high ? - GPIOF_OUT_INIT_HIGH : - GPIOF_OUT_INIT_LOW, - "PCIe reset"); - if (ret) { - dev_err(dev, "unable to get reset gpio\n"); - return ret; - } - } else if (imx6_pcie->reset_gpio == -EPROBE_DEFER) { - return imx6_pcie->reset_gpio; - } + imx6_pcie->reset_gpiod = + devm_gpiod_get_optional(dev, "reset", + imx6_pcie->gpio_active_high ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW); + if (IS_ERR(imx6_pcie->reset_gpiod)) + return dev_err_probe(dev, PTR_ERR(imx6_pcie->reset_gpiod), + "unable to get reset gpio\n"); + gpiod_set_consumer_name(imx6_pcie->reset_gpiod, "PCIe reset"); if (imx6_pcie->drvdata->clks_cnt >= IMX6_PCIE_MAX_CLKS) return dev_err_probe(dev, -ENOMEM, "clks_cnt is too big\n");