Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3553501pxt; Tue, 10 Aug 2021 06:19:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaUqKK/nLgWjvF4SrfJI/2xh3IXq4sCs0X3L1k0e6PoU+ce+AcKsX5Yw7PjYjRi+ngwIwj X-Received: by 2002:a92:440c:: with SMTP id r12mr249386ila.174.1628601554419; Tue, 10 Aug 2021 06:19:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628601554; cv=none; d=google.com; s=arc-20160816; b=ZZ1Dv/Xykbii7jl6a7XZ53QkX0Yf09UicqQjg+mZfMLdZdcAFrYCdcoUbMK9/pNEiC /op7WfnsYFjSybLnq0Xeyvz5JCTH/wAshBRYOsQnJGrvSHSLVPGGnfmnD9wpSlzVujr0 uMxtyvSXkV81ZHT59ksAZu4vdGb8jJxAw7OWYjc9C3J0TZCj0jI66drgNlRfjMlTJbqv 1ex8JVrXHxxZNlsWx7P8Bep0T514XRqHj9xDZffRnCTGbGQXqCQG/YAWDNSbKD8fIHzo f2NHJJ8Q687CEucA4+b6vsXSsGIDRam5+tg7s8Oj5hGYTcPR2+/gtzqCC0yD+ZDtxM8N BHoA== 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=zxyO6Wng/VsyoqFhUBhGp41LEzOZ+Cgi3MyxDffYZT4=; b=dtwBY3Gj3SH2XJthWedPV4bsKyBin2NjscNLKIrBRHwQPqkF/Q/69gXKI5bwsTyh5E +bqVST1Wmn+k9vju92PnTN8kSeEgh3Pj82jG4EuXWzMt6QEal1/iNWKFIwRsKWOYt2f9 PX7y8/KGUYwLW7xcPJpa3i+IEm8v+FcjBg1ttNdnUYUEUSeVwL9otwr0qpMDrYWfDUt4 /iXJsr+LLNbqE3wNm9cb0hHSl3f4+rnMoBX4HShracQ+VxXj6lDHriGs4TkFUA8Tk0ll /2OYFxoETvsmf6dNyPjNj7dFakWDinaZpk1eCx8BnzDL4QUA6wgvt6mTTE9hwszt59B3 PUjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bMv7gpD6; 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 x22si18113146jat.14.2021.08.10.06.19.02; Tue, 10 Aug 2021 06:19:14 -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=bMv7gpD6; 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 S239452AbhHJJ4h (ORCPT + 99 others); Tue, 10 Aug 2021 05:56:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:42898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238418AbhHJJ4K (ORCPT ); Tue, 10 Aug 2021 05:56:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 98181610A3; Tue, 10 Aug 2021 09:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628589348; bh=8NHFWLi4L6SzQcNwNbDCIoqONtSTEk20Raqln48U58Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bMv7gpD6hRCcPIGmG7s5x0LhavBwkkgToQc+LX03jRrSWWuQhagrQ5KB9rzd8H9AS pyelKoOlbuTP8BUq5qs2LJwOUTWhBSEQoUMWxQLm1MPdjV34E7QLxgZ2hhVnSq5v4G Yif1xD5quqEoth7tA244svAuPi4iKKy+QwHVnO24EqLWU+ze7ec3sYfTUHUBRw3PTE caImKnezX7dyqJ1ccLxPEYC6xha8UCE08n4MPpPfi6nFkbF0DN62n4nZOftfyfbklj BgTtpBpxY9f27F4WdEe8KlbPLY2Wtb5qsEimgs1BJqovFeZZwckoAhzRS1yraIQXmy QBUrN1n762MNA== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mDOU6-00AcG7-2O; Tue, 10 Aug 2021 11:55:46 +0200 From: Mauro Carvalho Chehab To: Vinod Koul , Bjorn Helgaas Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Binghui Wang , Lorenzo Pieralisi , Rob Herring , Xiaowei Song , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v10 09/11] PCI: kirin: Add power_off support for Kirin 960 PHY Date: Tue, 10 Aug 2021 11:55:40 +0200 Message-Id: <8eb48c5b6d68fcff7b6fd0b13808d807bf04116e.1628589155.git.mchehab+huawei@kernel.org> 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 218b90ac93dc..21453d21ebad 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 */ @@ -558,7 +570,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, @@ -712,8 +723,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; } @@ -723,7 +738,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