Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp411844pxt; Thu, 12 Aug 2021 01:06:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylITOxf80cQVaTLjVts4xmhbq/kFmME0Hf1IX+WG6U6+DHDItJJfeteXFjiyNZJJBFyFKx X-Received: by 2002:aa7:da52:: with SMTP id w18mr4081965eds.48.1628755561185; Thu, 12 Aug 2021 01:06:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628755561; cv=none; d=google.com; s=arc-20160816; b=SXFagcgZKYmBWNXG25/75SrbvWAsp4vOb5i2HckCVhuvL+JM9CqaWCSPgTirG9VksZ ZLLnl0VfsAox770qUi4UhQ6kjXZKRjouSadtvZS44BwUqWV3kch/VlL77vnvF9/wlWDg ag0BXlz7F5nYjPK8+ulQwOGAjUe63vfAjyL35RAUQuRQnxQOIhvBlqXl2JYKBAiUlBeH wJnDrlZvj19bbKgwoePFc/B2U6AGvUgo8lC3TJGLGrWYVF32IL4IoMYL5CYNKqR+ppN/ C1dBSlpRcfJGcIpXKA8CcI1mKmEqeo+h/y2d3KT3eQ9lUk4ONi3YXyqw2CwzK/GZpp4n k1bA== 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=aIUG+DFD1Udu8srFpgAibI4sgnZ1e1Ia8GKduHGF2NU=; b=j764mxovwKT4wE3ezDJ1Aj64fAzbFHJetlIQPKzYJUfA/b8DZqOlDAeYTaqrQu288n AXFEyUC2nl73SGqqXCzv22cMDXqStX0LI2JTTFUaSyG82kGK5OFFGQEC5C8wF9JqL8El BcwiuoYXOhgs3pNLq2nrnxrIB3T0jaiVRNgyH6H9XdPCvLMNanfIvMfJjKG5GaX8Kwxn nQOBqsbIGB3yeAj5OBda8Lydscw2a8a1ssBFzgAvG4BA59W+QA7N4CX8Xe8HXg2RT1lk vFp0COFe0Yqhpkwdt8NCKR3PiK1hJk4XtshwOJqB9l0DlAEjbyB2XdWe4DSyZLw09o9K f51w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="IGb763e/"; 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 dy18si2070721edb.594.2021.08.12.01.05.38; Thu, 12 Aug 2021 01:06:01 -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="IGb763e/"; 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 S235079AbhHLIE3 (ORCPT + 99 others); Thu, 12 Aug 2021 04:04:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:51218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234959AbhHLIC4 (ORCPT ); Thu, 12 Aug 2021 04:02:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9434D6109D; Thu, 12 Aug 2021 08:02:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628755345; bh=QO6ks9o/w7e9RGBeirwIusqXEl5dEdnKfYYFLp5hQTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IGb763e/zd9QJBRq3LtEh15AH1et0Wc4pcSQsHjs3lvqmp3KVLHitpoW17yqjdhaH DI7uh/ae5+66f1BGs5viDiEhpmw5Q1wYY0L2PjGrFi55nGq2YE1n8DGKAgT2fhmqr2 LC1xYqrO/1Lc73SLygHUn51dFy95p9SRen0GCo308osvIcZtFDKOdmvrXoSKo7tAwI czNU8Z3p46Mmym26knGyzJ5uW1+n1VNmtuWi2HLOu8cUzhN6bjIYICU5Mb2rlV7sBt EWPfQTYfBFpiI2VMCnp4cGavS0Uv2f0xWBL+U09ALG0spNIlNN2gJ8MTQaQE1GNhxy 027ugL5N7QOAg== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mE5fT-00DZDF-Ub; Thu, 12 Aug 2021 10:02:23 +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 v11 09/11] PCI: kirin: Add power_off support for Kirin 960 PHY Date: Thu, 12 Aug 2021 10:02:20 +0200 Message-Id: <241c5c064907c3c32f5b8c232638fd47d2a53035.1628755058.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 d5c29a266756..b17a194cf78d 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 */ @@ -560,7 +572,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, @@ -714,8 +725,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; } @@ -725,7 +740,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