Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp491995pxb; Thu, 21 Oct 2021 03:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytXNnV6oQzpqMRXjA1ppPmTbRWscZHKWXhoQ0cgUbyFTRqqHQJZ5ulTni6OSObMyc9NsCe X-Received: by 2002:a63:6b42:: with SMTP id g63mr3777327pgc.461.1634813317515; Thu, 21 Oct 2021 03:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634813317; cv=none; d=google.com; s=arc-20160816; b=zHbJBueuOlMVWZD4x5OjHQb2gUYIe11U9u9z1g43rp9m3KEjbISpgZLb2/Zs4bc3ks xijnQ++OKbEh8NSmQpGkwgIdF8xfoJt+ls2Y24muwTNP4czfs+GjRcNA0S42/fAZh6ri hQ9PaHsC59WC7w6RV7ToenItTPK/IBRkEcnn67ELs3mC+Gll1ODuz3Q3PQP0f6zg1xg8 KJDzPHcyNShz10YdLOOK67jl5faGCs8T/0Qdn25ZGGhyj6iSgGjksMuJmmQfCHtWzh2G 5Vh/b5vCCaqKxIM3GyJZ+hJ3GGP6uCpl/Kqi9rvMaNt/u3b34D/OQTNxXr2E89Rjmd2a GMUA== 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=hS1ANjeLxQ4GnTsrR9dQkUrDODSR0/tcSw+mDPXRlYM=; b=y0dMxBxPym4vy5x32J7Eg4/uyi/uW88XgGMNPKX29tsIehye6iff+3Wotk12GyMh/U gDSNtGVRs99ZOuvaizRaSYYmEyGypVhkvR2NK2+FCHfRgOA2ZBJmunZcTovVkgRM7fYR bxBKTF2mRGxha2Lt+R8zyU66E32AA4UHhUuUd3YQE+zeGBD3fBl+l0Zl+8B/1r+7pLvZ QE6KOF49XlNLBvAk01tQ4ikPk8kooZcBu/oWh70cEFRwELdMyKXC5qjcHI2AYZeNkw2f fUSBPnU3WSJZpqBYXUs9MC7WFEhnM4T/ydRpkyX6Sas/oD5rHXHXlGeQOAqD89I3wNBZ /I9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SIGM+j6s; 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 i191si6954235pge.422.2021.10.21.03.48.24; Thu, 21 Oct 2021 03:48:37 -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=SIGM+j6s; 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 S231376AbhJUKsO (ORCPT + 99 others); Thu, 21 Oct 2021 06:48:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:57890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230422AbhJUKrv (ORCPT ); Thu, 21 Oct 2021 06:47:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C45B06120F; Thu, 21 Oct 2021 10:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634813135; bh=9pMk1k6uGmU9IojtZe74/yowfnvVlZuYtg/BQ7QzHME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SIGM+j6spFov+VGW3zCMRqBhXHOCWMC1dxD7MHCl1zaFh3Hj6PihZx0bm5V4DwY2O J05aTzTCxFVf1fbGGtxFBLhv+QrUgk/i93Hf9YFRvNajJuzLBZYklx9uvVoYbima+1 CDUZeVBp46evwMa2vNPI5BuWLpzSESUcUnPznfETDKr5+wZSiRUiMy4MtLXJen5iKU 8/UUEHQ/VB1kNrGj08FQP5dJ1xCrnuvQ1p800fx85M2nGQdJPzjveFlJA/uNJycuKm nogS8oIZl9KY2LRDKaleziF5bpGkrjFcuQRX9hvG+tcweNfhAs5BM0QdUJsdnhIVH/ Y/O3Cxr+l8tfg== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mdVZj-002z5E-5A; Thu, 21 Oct 2021 11:45:31 +0100 From: Mauro Carvalho Chehab To: Lorenzo Pieralisi Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Binghui Wang , Bjorn Helgaas , Rob Herring , Xiaowei Song , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v15 09/13] PCI: kirin: Add power_off support for Kirin 960 PHY Date: Thu, 21 Oct 2021 11:45:16 +0100 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. Acked-by: Xiaowei Song Signed-off-by: Mauro Carvalho Chehab --- To mailbombing on a large number of people, only mailing lists were C/C on the cover. See [PATCH v15 00/13] at: https://lore.kernel.org/all/cover.1634812676.git.mchehab+huawei@kernel.org/ 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 b55830d2a19b..64221a204db2 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