Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6806272pxv; Fri, 30 Jul 2021 02:52:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEUlX+90xyL8mOEEH56nr731zGFwjz4swSSQbFZxjOM0wmsrcR711dHaVUt31Gwyd847Oe X-Received: by 2002:a17:907:3d91:: with SMTP id he17mr1770057ejc.355.1627638755664; Fri, 30 Jul 2021 02:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627638755; cv=none; d=google.com; s=arc-20160816; b=poae0DzXpsGLMaiSSUHNRdZJ3zbgEqaFXGsHdIgoQV1CGBwU6NEL08aeL2nAe97tWs PY92gxXB3ZV1KCeygt8WnZbkn59VnwmY5LvQXkif/T1/ePWA/i/kT3tTlxoQcQNS7NkL 7+3HY/LeefoH59cbDR6QkyMIC/YXdeT5PKKQ5Z135e9SfoWRYy0ZU1qqMvb/6VUXdC5s r1R/cBzZUoLmBa4cx8b5pHxzwO6OYy8hpcQcYNJMW0yyVTspNfgdxqhpaz7CPobE3Buw fyiSkraQ1EvRL4LYrIXc2zAhmYXZuL6rZpWdHJ7aBvRqhdKMifnQOsGInCuzd94BWl5E 7UFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CdJqL0iFLD0Src50mxRb6gVI8QuWp/gB/uAWxConYoY=; b=jTTcbbgWl5GctbdRgeOK5UVaFVYOdAuBbo6S+C/Xn0bvo3tEFvyZx6CtEZbxZIwf2E L9NPfGswFVU0lvcxgEudTFCpVogNSm9Uewf/uHtVmVe9/YfwxdT9iPyHMvt6cRKTcen2 GUEqz6u/MLvNr1MGoqZUt7cbkDHfgIi8S6fi5Lgr21qjyboiBH0kL9ookywlD8znjfAu a6X1K6cRV1l0J1elHRj0UjhHhmAmdG4WO+UUlyJsZSl0XwU5i8CifeEDcfIW28tv/NQA KSZy5WlsvY8icwoUKD8mnXBhr9Fej/IA9P41gq7UNTqAEAbjgTJuXAw5ZQxkf/l7n60s 51RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iXQUbsJD; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr6si1560873ejb.199.2021.07.30.02.52.12; Fri, 30 Jul 2021 02:52:35 -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=@kernel.org header.s=k20201202 header.b=iXQUbsJD; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238422AbhG3Jum (ORCPT + 99 others); Fri, 30 Jul 2021 05:50:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:59624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238268AbhG3Jub (ORCPT ); Fri, 30 Jul 2021 05:50:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E19761050; Fri, 30 Jul 2021 09:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627638627; bh=9wQvNNuV8XRlFJv8fGt0HOdtFjEXmFaSpuPiJvhTIsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iXQUbsJDyHCtAPZx3hoYm0x6MQmt8+S8fyHf44xPOOqWfMjIkW00DWDMa9Di43w44 6nAXCKRnjq6m2/xJvItd+HbtExsiJOoynzS6AOpMUzspvHzxUV5tg1Mqp2OkyH1v90 ev8NKBJQUq7TRW/r4we83SErRxplucRUKPKnMe+c96igYzwIFt6dhsEilW9hXtFNVh mJAqz7ezjh0qdcliy+Ywsvhh4Zes/FxhlLZ/OsmQUApne0gle0OCcctRCwy6O/jAOr a2jO00BoC4hLzGx4V6mZR5VcEemoRDGDzUCOsghcvTE6QU4TxyfCij40QMGt+PQ/uU OjsFN9fBvmiXQ== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1m9P9t-006s4Q-Ho; Fri, 30 Jul 2021 11:50:25 +0200 From: Mauro Carvalho Chehab To: Vinod Koul , Bjorn Helgaas , Rob Herring Cc: Mauro Carvalho Chehab , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Binghui Wang , Lorenzo Pieralisi , Xiaowei Song , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v8 09/11] PCI: kirin: Add power_off support for Kirin 960 PHY Date: Fri, 30 Jul 2021 11:50:12 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to prepare for module unload, add a power_off method for HiKey 960. Signed-off-by: Mauro Carvalho Chehab --- drivers/pci/controller/dwc/pcie-kirin.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index dc6e38ee02b3..58a993a998f3 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -343,6 +343,18 @@ static int hi3660_pcie_phy_init(struct platform_device *pdev, return hi3660_pcie_phy_get_resource(phy); } +static int hi3660_pcie_phy_power_off(struct kirin_pcie *pcie) +{ + struct hi3660_pcie_phy *phy = pcie->phy_priv; + + /* Drop power supply for Host */ + regmap_write(phy->sysctrl, SCTRL_PCIE_CMOS_OFFSET, 0x00); + + hi3660_pcie_phy_clk_ctrl(phy, false); + + return 0; +} + /* * The non-PHY part starts here */ @@ -563,7 +575,6 @@ static int kirin_pcie_add_bus(struct pci_bus *bus) return 0; } - static struct pci_ops kirin_pci_ops = { .read = kirin_pcie_rd_own_conf, .write = kirin_pcie_wr_own_conf, @@ -717,8 +728,12 @@ static int kirin_pcie_power_on(struct platform_device *pdev, return 0; err: - if (kirin_pcie->type != PCIE_KIRIN_INTERNAL_PHY) + if (kirin_pcie->type == PCIE_KIRIN_INTERNAL_PHY) { + hi3660_pcie_phy_power_off(kirin_pcie); + } else { + phy_power_off(kirin_pcie->phy); phy_exit(kirin_pcie->phy); + } return ret; } @@ -728,7 +743,7 @@ static int __exit kirin_pcie_remove(struct platform_device *pdev) struct kirin_pcie *kirin_pcie = platform_get_drvdata(pdev); if (kirin_pcie->type == PCIE_KIRIN_INTERNAL_PHY) - return 0; + return hi3660_pcie_phy_power_off(kirin_pcie); phy_power_off(kirin_pcie->phy); phy_exit(kirin_pcie->phy); -- 2.31.1