Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp206050pxt; Wed, 4 Aug 2021 09:06:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCrdCS8954LNOiKDzbHWhzoNZUX+NwH+dl2dZXD0wh/ZLIhM0gbDliGaQ1NS3CQhhmK0nR X-Received: by 2002:a17:906:9c84:: with SMTP id fj4mr25865042ejc.180.1628093163890; Wed, 04 Aug 2021 09:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628093163; cv=none; d=google.com; s=arc-20160816; b=dfynqIcHYWcB/gtrt5SwvUQGkrN7R30xwl1F9cYTvt9+gYOE2FOQD6qKTZb0hlUmuZ l8OMuu5PwiZu4IM9XXl4g2Ioqvx9izGQet+tWdw2L4sjDCj0ABpVX7/1vV7HFj0j+70K MrbLKr+rTrtyTt5Vr377i1RpCwBFFFnDQv5tpyUY1XE25/IKqTLHYyrMA3zTK3RNsjsJ WEmDkPHbWIzaglxB7KQ+vFz1Ii9ACsxxrkwhWCAZmif20VKrxs9aR4uoELE6Q4uRJhmJ FN3rs3wmwabKE/WLDfDct1Ry0ubmyo2M0MoOAveR+n4tIp8PTue+BNafVWKiQox7X5xD YLoA== 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=t5PQwINTAyghqlmKZjBqSXCVE20R00+0ba2NVpccgeI=; b=0lBUryZJZ4pCy66hVRJ65/Tmi/Q92G8C21Hf55rDehCZDhIf9D8o2xlo9WVGGcvLRw 83qvETYu65Tb1lXiZb1H3QrsVo+k3XBPlVjj1uMlOW/nCRQRUrw9lsj5Xs5yGuxO52PM 4McueOJkWahgdJLREvvBdY31HHhbxCOYcSKR0RAf7KbKNvQo5AFlC9/7iOIF4nrybGO+ qmb3K2iP6ybIZsoZzvQC4WuwBcg3ryJlU4WbzYTNOnS7O0jv31ZvbIEt/ok7WzL/tKp6 YwBU+AbmsnZSLsHHx2855Qoa0i+EQ6hr1M3423uLUZrvuNFhpxXTrqcTabnBC5Tv4D2Z kO8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QOQwJFp1; 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 o7si2307219edv.68.2021.08.04.09.05.26; Wed, 04 Aug 2021 09:06:03 -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=QOQwJFp1; 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 S233615AbhHDQDf (ORCPT + 99 others); Wed, 4 Aug 2021 12:03:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:58912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbhHDQDX (ORCPT ); Wed, 4 Aug 2021 12:03:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 73B1061008; Wed, 4 Aug 2021 16:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628092990; bh=Hy8eNUUARmfSXo114esRtBNHADBjh2HhC5zgYtA2zEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QOQwJFp1+EfjDECMx5h7cUJVQ3oYNeoNXzaBL6OKj6agiAZcqPaovI0yLDzoA+Je4 2niXudUvjUbtZf3p+uwEVkg5Jy+F0roYeOwBeyuk9gZp3cHWQCGZNOkFummGAFhbnB DrsP5Ng8dFLR0jbsZOLuvxl96mH9c3SGE049nK9DYRL1NV7AO44hlOmKN2NPQ++H5C M2X15wAVyn2eQKtj93VZTIx9lcKUBURaAQHpxSGCgy+wfQ2909GazY0qYCGAR2bHpy v3cyEz0lhtINqRJXF0WiXxs5N5EH+QhMxgyc/ubeKiqbyyRrINLUDoTMIdL/sK2cRl G0xWUchWYqyDQ== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mBJMK-000Pzr-OE; Wed, 04 Aug 2021 18:03:08 +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?= , "Rob Herring" , Binghui Wang , Lorenzo Pieralisi , Xiaowei Song , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v9 09/11] PCI: kirin: Add power_off support for Kirin 960 PHY Date: Wed, 4 Aug 2021 18:03:05 +0200 Message-Id: <3ee32cd118bec7603937c3b9b55f51c424d54ba6.1628092716.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 dbd45896920f..b7cc0c6701e4 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 */ @@ -562,7 +574,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, @@ -716,8 +727,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; } @@ -727,7 +742,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