From nobody Sun Jun 14 06:08:19 2026 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4342321457 for ; Sat, 2 May 2026 10:13:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716828; cv=none; b=RELio0OlmlsJ1/sHx/wAcwoy45gkC1/D6oq1QoWxQljWwdQt6O9PXhvZRdHScsKBUrvdR3aRQ1M8iFu/NzdLvu35uma9PboCUQAkNkrCmk6Mm2FQM67IzzEcFVBO5awRXTRqLXfj6pAlkbAw6RlFH8/edi1jHy02pkOcbfOZ4Fo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716828; c=relaxed/simple; bh=gEjev9liaNaMDJWD4B3vuXkcNGIuaztQH3cR5GkLXz8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bwd+1eEx07sMPjdvyOu8/GtAATuvSn9ku5JUuLx2Icu7mewTxJVLv+9IqGE3ESyf4IyJ1cOTUaWxXMJZpW2HgLZPHHCBQtPCFegIQh5jfgLyKDPHUv5UPz/+SG19GTH+EsNPTTzrORj1M792fBZVn2lVxJ/ekWKPm90APQS5iR0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=r+SDHlH0; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="r+SDHlH0" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2b788a98557so22600305ad.2 for ; Sat, 02 May 2026 03:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777716824; x=1778321624; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WcMticRbbnlhc13eC+umkLKNNwt7Hul0SNRld9/CX3o=; b=r+SDHlH0xQkfOXSRpsDx9ariCPBW2itqBHi0j3/5svsATKlEC9QtJzthMWaXtvkn1y IHBoPiPotV6WnoysyPAMsG+aSiTiW2GEg0yksiFgIJ7C22FNtBWTnya99jbtlpG1vaHD TLLUWaDb+xeyAL3fUA7D6YFHfmGrouZFW93RREvi9lfDYNAIqAEw2JIA/LEdz+xu8vSM wsnyAhY2FxxDfws/PlK6gLLCW3P9SsLP9nXAnu82/BNAFiddpZ5bmM7GwERPJqjIOqFW sVP7TTlWd8DHs624Z6KL+CWUeN3KrGZBAkjg6zv/TI/KiOJFpxDnA7IEefThQyUPg8S8 hRBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777716824; x=1778321624; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WcMticRbbnlhc13eC+umkLKNNwt7Hul0SNRld9/CX3o=; b=gUoDweKyAc4qBdvipF62HUUBVi6UhOAnn7WGLVJuNZZyM9dVLKvEQHLyxPvzCGfVIT PEByNNmiLAAIO6HYBEqpGRbIEr7rSGB7w5R1GqEHtqvwGG46IP9EIvwrN1pc+y4LYXaw JzAEgShuKWXTxnHj8rDy1pFRJHfHDL3OZRdqBNjnQyaTGzmWPtgsRtCFGoVgKvQjYRVm f/vnhLrfbHNVYgMWk2mIFcS2oTCQqy5WEb9e+bxAfRxoUj2GhHwBvPbLqJn24XNTM3AX GRcMbxvlL6f8uZM44ZS8hdYcijoHTm+dxbmA6iB7h5vZml+QOdCaIVaqYIKuV7tE3PUt LK3A== X-Forwarded-Encrypted: i=1; AFNElJ/rEy2eaJ/4d48hcH0+BefK3CRn78hjFWwQwDT2W4plxBViXuxWba55x21YtGBw62WBCeFsgHcJ6U91NLE=@vger.kernel.org X-Gm-Message-State: AOJu0YzB9mANgP2p6xlQPiBHlGv/vxtZb1ETjdGOovKD0MZ2QMqxuvN2 TtP+7IUz4wzhcaS65wkogXBh4LVcPhwkj8PX2DPrpMGok1UmjrapBXwW X-Gm-Gg: AeBDiessL/dm1CKElB9aVnXWCEZhIlrhUDJT3b5S25ZjE2dA+xFj39yukuuGDlA4rGQ huiv0Dn57madhR/zpH1LXilJvWkZSeOmXrUMk7ujqAaO2Zy3D14Kjmq8kueutcJtojClfblYNJP 7f25kYK5kuJkoX4ipbbmO1TZU3mbNbtG06lSO47EmCg8okXNfmJLt0pCl7DVJ2sllJyFu2yXJ2q JXkbGGwj+imUUJYrnTSxu5CA7fjQMRK/FjBMJFSMNeWW9Wo7NFLUbzagOUymangnEfVAXVWPzn9 hZPwuvmJbfbpczu2SzeomYLHOLp8vvZLzIoCeneeOtKfanTn3gOOtJ7fX8Xq/Sh0FESo0fu34wl kN51xNxcX5h0sMgivKqy9wsQvXhPGYP3M1J47DMGcI8aWMQ1Z9Ajeq5MR1eZwFyiPs+4eoBE00h 2ULcl/MerNE7HRaeXBZPUbkQaSuWhmKYDfOg== X-Received: by 2002:a17:903:2ecc:b0:2b2:4dd2:dcf5 with SMTP id d9443c01a7336-2b9f260b757mr24434785ad.20.1777716824197; Sat, 02 May 2026 03:13:44 -0700 (PDT) Received: from localhost ([2001:19f0:8001:1b2d:5400:5ff:fefa:a95d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b9cae68476sm45629345ad.80.2026.05.02.03.13.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2026 03:13:43 -0700 (PDT) From: Inochi Amaoto To: Jingoo Han , Manivannan Sadhasivam , Bjorn Helgaas , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Yixun Lan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Inochi Amaoto , Alex Elder , Gustavo Pimentel Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, Yixun Lan , Longbin Li Subject: [PATCH 1/5] PCI: spacemit-k1: Add device data support Date: Sat, 2 May 2026 18:13:14 +0800 Message-ID: <20260502101319.2364052-2-inochiama@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260502101319.2364052-1-inochiama@gmail.com> References: <20260502101319.2364052-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To reuse the K1 PCIe driver logic for K3 PCIe controller, add device data to handle the K1 specific logic and make room for the incoming logic for K3. Signed-off-by: Inochi Amaoto --- drivers/pci/controller/dwc/pcie-spacemit-k1.c | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/co= ntroller/dwc/pcie-spacemit-k1.c index be20a520255b..cd3cd038ad2b 100644 --- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c +++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c @@ -57,6 +57,13 @@ struct k1_pcie { u32 pmu_off; }; =20 +struct k1_pcie_device_data { + const struct dw_pcie_host_ops *host_ops; + const struct dw_pcie_ops *ops; + int (*parse_port)(struct k1_pcie *k1); + int (*post_init)(struct k1_pcie *k1); +}; + #define to_k1_pcie(dw_pcie) \ platform_get_drvdata(to_platform_device((dw_pcie)->dev)) =20 @@ -278,10 +285,15 @@ static int k1_pcie_parse_port(struct k1_pcie *k1) =20 static int k1_pcie_probe(struct platform_device *pdev) { + const struct k1_pcie_device_data *data; struct device *dev =3D &pdev->dev; struct k1_pcie *k1; int ret; =20 + data =3D device_get_match_data(dev); + if (!data) + return -ENODEV; + k1 =3D devm_kzalloc(dev, sizeof(*k1), GFP_KERNEL); if (!k1) return -ENOMEM; @@ -299,11 +311,11 @@ static int k1_pcie_probe(struct platform_device *pdev) "failed to map \"link\" registers\n"); =20 k1->pci.dev =3D dev; - k1->pci.ops =3D &k1_pcie_ops; + k1->pci.ops =3D data->ops; k1->pci.pp.num_vectors =3D MAX_MSI_IRQS; dw_pcie_cap_set(&k1->pci, REQ_RES); =20 - k1->pci.pp.ops =3D &k1_pcie_host_ops; + k1->pci.pp.ops =3D data->host_ops; =20 /* Hold the PHY in reset until we start the link */ regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL, @@ -320,7 +332,7 @@ static int k1_pcie_probe(struct platform_device *pdev) =20 platform_set_drvdata(pdev, k1); =20 - ret =3D k1_pcie_parse_port(k1); + ret =3D data->parse_port(k1); if (ret) return dev_err_probe(dev, ret, "failed to parse root port\n"); =20 @@ -328,6 +340,15 @@ static int k1_pcie_probe(struct platform_device *pdev) if (ret) return dev_err_probe(dev, ret, "failed to initialize host\n"); =20 + if (data->post_init) { + ret =3D data->post_init(k1); + if (ret) { + dw_pcie_host_deinit(&k1->pci.pp); + return dev_err_probe(dev, ret, + "Failed to post init\n"); + } + } + return 0; } =20 @@ -338,8 +359,14 @@ static void k1_pcie_remove(struct platform_device *pde= v) dw_pcie_host_deinit(&k1->pci.pp); } =20 +static const struct k1_pcie_device_data k1_pcie_device_data =3D { + .host_ops =3D &k1_pcie_host_ops, + .ops =3D &k1_pcie_ops, + .parse_port =3D k1_pcie_parse_port, +}; + static const struct of_device_id k1_pcie_of_match_table[] =3D { - { .compatible =3D "spacemit,k1-pcie", }, + { .compatible =3D "spacemit,k1-pcie", .data =3D &k1_pcie_device_data}, { } }; =20 --=20 2.54.0 From nobody Sun Jun 14 06:08:19 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1B23325707 for ; Sat, 2 May 2026 10:13:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716831; cv=none; b=J/P94BTn9Uq421h4/RC070a/2dV5GDFmY9c5P4SiaIEC3OGvrjDw3GXhuugxFXE3YBzkc55c6rUV3kY7ZQXUaMXctZNY9DY7HlLTrD29cUg68xmMW5vXTMbgasu6djeMRgOwxzMMvtlbrgMh5VCM9ULg17Yxt4c1CZhhjy4A1YU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716831; c=relaxed/simple; bh=3pw1bdZuuXwrz+VnxjRJOnM0J5m0J5qcFaU9OOGALKg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZsOPiu0O/dSgbVMpk9ykbRLwM3eaZT7Qa3PC7+Zc1a0+uozgsFSl0Yo0B2s5d1hS5+OGBAoR9nl+/fBj2fcstad1EOyKr1F/t2VC/DrKSozhxxjyEnCU87XLZ3INgK1s74ZTJaz1JJ1V9/Mky/kE6lQElYT40wWhI/3is6hA5Ys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iTWVdTtO; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iTWVdTtO" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2b9fcf7c91bso2367145ad.0 for ; Sat, 02 May 2026 03:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777716826; x=1778321626; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KmMzz9kPOMJ2V6hEeqZMS4vdi4snOlkMyKNu1sYiAzY=; b=iTWVdTtOX5ZK62LXFvK4n1MwikrAxtRgCiAvF3VfshdeoXq69dmuzZbMWT5Uuq9vw7 4OnDMilqRcS+9vFFm+fOLJKlgk8ONlCuj62Qd2aGU2jg7xeazqIvZ5l5t6Z1qXb3kma7 HylTwmpK1lpxHdYSAxaIHjbMjgN3gn7WobDqQlziA9u86tTkpaCPEpy3/zpZPqcr0Ixr hQIDNZs9pFLSpJu5uG1wHS7bVU+1a3g0o3lZrUZ4SVqnlIpH4e39ShWXxTpFzB/wnDvY rIxUudTHtAlmQgKoUSOsHAgCBV5qDqjgkY1CiCYLYO1Wz+sWl+iwle5wG7///5OajFDY WDkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777716826; x=1778321626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=KmMzz9kPOMJ2V6hEeqZMS4vdi4snOlkMyKNu1sYiAzY=; b=KFQkslLElCOwXHuNlW4TwBRrY0XrFg3aFoKbzFTagQkaNhox/UV08iU9rdRcJDqFUU ZczjfsnOq7E3O0GzlEEGpnL4op/EiXTPNeQfZOupxA9ZQXRJf6oit75PWFB9snkvhBuV tUIKtYBYcveDh0xqhXIbND9HktbItdVwBEePuSM9kkFjF5EPU5cF/NYDDQp0HS5R6nPH ojs9c2UIAw1M4xtri0nvmfQ3ca0GzQZYBLV8tnqxCBZiR0wZIoelHLX0verfFg02D1LC uwNQaminZIZk2MzY+gE4W3bhpbDwgcyCMJoGNzcf770uoVTvrJ73kZGmgiKGPLHCWFZr RWmQ== X-Forwarded-Encrypted: i=1; AFNElJ/0SOX046K1wPnKVJ3LweGdg7X7Dx5TzYuPitNFzY0vL0ZJUhSYweltCxXeie679hDtAVYTbNSyIjyZgRc=@vger.kernel.org X-Gm-Message-State: AOJu0YzpGiOPLRQOZN2KM/OPwuoq4WNWQ6VZwwRKEDblPhGxyi7ZUZo9 p3Jc17yEwjvWQovgqk1l19cUpPhlq4zCMDnno/15o4B9iMuW9kvJOgsO X-Gm-Gg: AeBDietvbIlZXH7qmH9ryLDjD614/ZH+nPfGiz7Wt2fTb/o8M9dziuOmLU/jUrAJTMe 1VJVP9KeT73PYh+7f5PzVEWHLGSicV4BnM8aOst2jWibz8wYGCzR+ZsBNYvL1tItnzBpnyjQ5TA qNeLJHlEuqLj5Fl7/k6wVPyMmVggO36GvjoXLz/Wki6h6cq0eOPF2e7yRzE/Fzk+Bx4WFn1V6hE p3M2VfBi1Lf0MTOBPW62cFsgzwDJuNd1zYvrFu3SJw4bzmtAWHn72/ljniaroR5OOqOEFKdAVsi 7nJ6444O9rA/jRQJ6kqB3xgOOZZIuyN2z3JD41vIDumj7LrZibV3FC4dKWQRKMzzp7MRI8nOYqq rw9Q/5dVNAv2bOBiw4W3y2AVUM4uok8/EAwizZC6TkYMzryXjJcm/lxxW6Ap6BgyuTGZJQ9xnX1 3r7t/ohYnN6Gzjq71o6MtzTLDglJkKrDNxSQ== X-Received: by 2002:a17:903:3d4c:b0:2b7:ade8:2407 with SMTP id d9443c01a7336-2b9f25e8353mr15599855ad.19.1777716826438; Sat, 02 May 2026 03:13:46 -0700 (PDT) Received: from localhost ([2001:19f0:8001:1b2d:5400:5ff:fefa:a95d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b9caaadb1esm48776715ad.20.2026.05.02.03.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2026 03:13:46 -0700 (PDT) From: Inochi Amaoto To: Jingoo Han , Manivannan Sadhasivam , Bjorn Helgaas , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Yixun Lan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Inochi Amaoto , Alex Elder , Gustavo Pimentel Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, Yixun Lan , Longbin Li Subject: [PATCH 2/5] PCI: spacemit-k1: Add multiple phy handles support Date: Sat, 2 May 2026 18:13:15 +0800 Message-ID: <20260502101319.2364052-3-inochiama@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260502101319.2364052-1-inochiama@gmail.com> References: <20260502101319.2364052-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The PCIe controller on Spacemit K3 may use multiple phys at the same time. The feature is not support by the current driver. So extend the phy definition to support multiple phy handles. Signed-off-by: Inochi Amaoto --- drivers/pci/controller/dwc/pcie-spacemit-k1.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/co= ntroller/dwc/pcie-spacemit-k1.c index cd3cd038ad2b..f2a722e5edb5 100644 --- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c +++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c @@ -51,7 +51,8 @@ =20 struct k1_pcie { struct dw_pcie pci; - struct phy *phy; + struct phy **phy; + int phy_count; void __iomem *link; struct regmap *pmu; /* Errors ignored; MMIO-backed regmap */ u32 pmu_off; @@ -172,7 +173,7 @@ static int k1_pcie_init(struct dw_pcie_rp *pp) */ regmap_set_bits(k1->pmu, reset_ctrl, DEVICE_TYPE_RC | PCIE_AUX_PWR_DET); =20 - ret =3D phy_init(k1->phy); + ret =3D phy_init(k1->phy[0]); if (ret) { k1_pcie_disable_resources(k1); =20 @@ -192,12 +193,14 @@ static void k1_pcie_deinit(struct dw_pcie_rp *pp) { struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp); struct k1_pcie *k1 =3D to_k1_pcie(pci); + int i; =20 /* Assert fundamental reset (drive PERST# low) */ regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL, PCIE_RC_PERST); =20 - phy_exit(k1->phy); + for (i =3D 0; i < k1->phy_count; i++) + phy_exit(k1->phy[i]); =20 k1_pcie_disable_resources(k1); } @@ -278,7 +281,12 @@ static int k1_pcie_parse_port(struct k1_pcie *k1) if (IS_ERR(phy)) return PTR_ERR(phy); =20 - k1->phy =3D phy; + k1->phy =3D devm_kmalloc_array(dev, sizeof(*k1->phy), 1, GFP_KERNEL); + if (IS_ERR(k1->phy)) + return PTR_ERR(k1->phy); + + k1->phy[0] =3D phy; + k1->phy_count =3D 1; =20 return 0; } --=20 2.54.0 From nobody Sun Jun 14 06:08:19 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E14E531F985 for ; Sat, 2 May 2026 10:13:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716834; cv=none; b=owbzjfh+MMLqW1QZVJtrqIW90VgMQIABbcSiHpmS8AQNhXeWcIQ4nZI/9RYgZgOCNoY4CF+DGD7eaey3OHdJ4XwnQ1Mvx15x7zxHjAE55Vh2dLdnP8+GfIZlKkGF48BoSDPtTdqro1bP33pszMeeanY78ZGHNVekD+ZFacKE7YI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716834; c=relaxed/simple; bh=Qeyor5pnGeEUxHDLnSAUNrklZACkQd3iPe/8N51JgLc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LGo85jrw9PuEWplkrwp6S4tF2q2Ajscv8YMFmXeq/M+DgJ0IdtyEkIIPutg321zPuEZdCBUWlRk7tTJZNA5dZDfDiHbxSIeCOnLUS2BbtqE/r/WptqLj9FL9iWtRkol7DZ3rKkb8GsWWYC7apTzJwePsabZNq97WfRaW2RfI1GM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kiCgcBXU; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kiCgcBXU" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2b25cf1b5f0so13845045ad.3 for ; Sat, 02 May 2026 03:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777716829; x=1778321629; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/xxbrEotld4A1INaWDXAQzVmz+vSmMssLxNlmQzLKGY=; b=kiCgcBXUAWJwH10riDIuTSYrQlMnGZsVj4epzPPBHl080ttjr14cLDKL1p0snx+G28 tQjqxbX5VnOLP+iq+VJjGLQtcXXPsxASvjFC0ApGjGhHTfnuoiLjAoDXQR6e8cmeCB7Q 15KS27gs2IMoYMjl1veGxvx68ZUm74wG5isPB5cPprXApLamM8Pvp9khv4c0BB4QpOyl 7VwNlMVd6pBprulFCc/qO0fPDqSKpfP2NkNsxKmq2rzzXw1z3Z86UC4n1ZbzQKY3mL1I McSAKrPWYBa4BP6DnDBf2+BU2JW8y7tlhd6VIneWs+hrpJiADqWIzoJ88j0CWZapX/CN OQcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777716829; x=1778321629; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/xxbrEotld4A1INaWDXAQzVmz+vSmMssLxNlmQzLKGY=; b=NvwjkHXFjm8uuw8dEiYZoQAtwZ1EC9YL6FnxveVIIWn2ULG+JWHkmO3Q4yCJOG+ScU N1pqCpuEdwFggJkW6GcwKqZD12MJdMmwQDhikHqKMIFhdhxiZffF5+DMWsGWia+sSZT4 4Uf7kyU+Yv8wAlGKguwPAKgrRRsSavjOdvFT7k8KXeueG34AueYEA5QPRyhB6uXEvYyR xUPY3Ck66odBm9OUJ6te8CiTgrGg394or80e/RHvFTmhAec+mpKgmaa2s+PcH89iHTsR hnp1rM2TDqCFys1NJRnr326VCJ4vSlCBAuEEXJRyxoM1QdEsjg7lGsJHUZeuSDIS3Kst OSlQ== X-Forwarded-Encrypted: i=1; AFNElJ+LY1ZYFm/WFHwJ71iqozg8lSaGcDgSdKoeeQf92fnFvFDFutoLvRLbKr0+hu9jDFG//gbgSwuJbbuZZDo=@vger.kernel.org X-Gm-Message-State: AOJu0Ywt6iWgjWW/Ol47F3kPg1l64Fbis0EfGoD3xrciABdsuSgplD6m 83PtraoxujXHtyu4MAxgcJLPsmJ4LotiD8OpvGKCxCm9G5ao+rLBQPKV X-Gm-Gg: AeBDieuMzz7063HHNrW+dZC8pQH8OyXqx78xKmoMXlR2gmYlcKNKw9ghnsCAIDjMXjW RQ0zvyDixF1ayf9cI/TEoQ/KFuKrs8ZpZzQoxz5vWLqenQOLH5sJqzPQz8mpFd7vy9njE2kXp0Q SvnCPgEGqJbzg7PqZKiv8ZIUZ5+VUFWOG5N+d2Q8O1Krfo82WCjUfJHnVYMi/KKhEreReU0NxMF /9ul4CbsTTYw35jO7hQ5jL2RTKhE9E5uwU7S1xAgjhlRjy5q156c4TW08YB+nnm0Klgioovx4rh 0w3UgKTD9+iKkFHvhHWwrSvYRASWYlkUNSftruABj/rP0FuE2nwl/X8omgBM9Yi3W6dBHLswXYB WoyAvXYxOjnDuMZxccTHoLlidJeXhdac120uwa/Lr+lQ199dci/Me6oTrU1WAWJo//HoK1dF3uJ /zDi31VLkDkeFKaSpwx6CD5UrbpT/wMcikQE7qYesCZYkG X-Received: by 2002:a17:902:d20c:b0:2b9:ce81:fd75 with SMTP id d9443c01a7336-2b9f25674cemr17239855ad.11.1777716829028; Sat, 02 May 2026 03:13:49 -0700 (PDT) Received: from localhost ([2001:19f0:8001:1b2d:5400:5ff:fefa:a95d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b9cae6d123sm50453575ad.84.2026.05.02.03.13.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2026 03:13:48 -0700 (PDT) From: Inochi Amaoto To: Jingoo Han , Manivannan Sadhasivam , Bjorn Helgaas , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Yixun Lan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Inochi Amaoto , Alex Elder , Gustavo Pimentel Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, Yixun Lan , Longbin Li Subject: [PATCH 3/5] dt-bindings: PCI: snps,dw-pcie: Add msi-parent for msi handle check Date: Sat, 2 May 2026 18:13:16 +0800 Message-ID: <20260502101319.2364052-4-inochiama@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260502101319.2364052-1-inochiama@gmail.com> References: <20260502101319.2364052-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The IMSIC device on RISC-V based system does not require ID remapping for MSI. So this device only needs "msi-parent" property for IMSIC-based SoC, and the "msi-map" is not a necessary property. Add new condition for msi handling on IMSIC based SoC. Signed-off-by: Inochi Amaoto Acked-by: Rob Herring (Arm) --- Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml b/Docu= mentation/devicetree/bindings/pci/snps,dw-pcie.yaml index b3216141881c..6a595207fae1 100644 --- a/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml @@ -27,8 +27,11 @@ allOf: - $ref: /schemas/pci/snps,dw-pcie-common.yaml# - if: not: - required: - - msi-map + oneOf: + - required: + - msi-map + - required: + - msi-parent then: properties: interrupt-names: --=20 2.54.0 From nobody Sun Jun 14 06:08:19 2026 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A3111C5D44 for ; Sat, 2 May 2026 10:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716836; cv=none; b=c30WcqqXFI96v9gm2CNP/l+KuZUvm1MmuS2yVh0dVUg2jueeJHUfj5Y0z4fSL/O4RHnHa/4EghtQG1hPsIqbOzSG3wX2aIGeB1LGTjExp3SPV40C3f7IkMVKG3XDOYljk2e40tOGoxiFLpTbGq21jJsSAcycirBXbzR03v4KpL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716836; c=relaxed/simple; bh=nSlzbIx7Nmk0KHaWQK/SZMleU7sulO2Kk1O2J1oM+3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lDGdIfDAU0ZdJEw0/HVOPk11tED+IpsFa9pcXta14JxoEymKzDActTsT1ObTw3QyOtYeQ7PIycYaCYCQcVzah/Cgk5t/kJMtax8s9yOMiHN9hMQCUtpje81WyRsY9avZrLy0S+xeJrHee+TA8jpf+s+wnP7bB5IVgpDD84yr5Qk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AZKTfUwB; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AZKTfUwB" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2b24fdac394so21212635ad.3 for ; Sat, 02 May 2026 03:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777716832; x=1778321632; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tMpwp33NUvTYaPHi9wjn2SqCZPfqp0TeYPs16K2j4ho=; b=AZKTfUwB/DqxeKDS60BVcxePyis1GEVsYXNgC5M+wVgbN4PbehGvp8p2xZ50dOrmWS 7VWxmNv9KyHFs2bEZoFUfEdRjKsIUHzHQymCxtmd5OdTpNDvF687WbGPLcwp7q4jOFER 9+3jw3nSP9f1cIwqvDDWZCdQTNEm3m/opOLBEfyZ4epjNVWNuSN+0gsWuD4EDx/cWyiM TTDEaX0EeflRKkOgJ/Vdq6iIxLoAteApj4IBvrqnRsUEU/589eQyNIP6txGboUAIg8gO Mv0VLHWrjg2pa50V1JqyqVbTdlVgEOmcUBN/kWa0smSCxezf5Y6zl8bYRwVLrveHseN4 vhJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777716832; x=1778321632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=tMpwp33NUvTYaPHi9wjn2SqCZPfqp0TeYPs16K2j4ho=; b=jQYf7FHMBmsbUbiJ3wnDm6mxMYIyppKBM7OCXWiKsOWYfroj9JjeY0dwu8kFwxvVKM UrtOenYhZs3DKO9gyTTkgbfGEuYIIsI1X3lGZ2LCMqUbyMtvShQjpe8ntsE/bqAM7f+9 5yPtP4y+brXLp6roPgRDu1h4fz9oqBqPcAQLCLomIsZ0OXCF/z9N3S9EhKLHQiFgXWU+ eSUdEQf4LfHRJxyqHU1EMMmaa6Z6HbdXXvRgdMVjsxxqawp1gAdfMMcbRD0LD70aq/ah YxJX5a+HmS7tHuVaeRPUfVrNzfC73ItDIumq9rW1Jo63U2H2yyl66DBdkQJnTtPkBUYH xeHw== X-Forwarded-Encrypted: i=1; AFNElJ8Ybr0iI/QWHDDPQ0pdLHMbpk494p7fBmTBAybwvIZexQY19PjyTUWAXWhnW47U0AJBsXkC/8QAflieobA=@vger.kernel.org X-Gm-Message-State: AOJu0YxIFsLWxXWMNnvNF4PmK30uZ23Ai00cg2NoaVzctKDb/Hl90p+o k7DgmuB7XNekKKnerFh5Nuu0/1FSKeJcA3EIGa1LzeA3a3lYsUjLMtTN X-Gm-Gg: AeBDiesYRljS68xHudiUamThlYPHXv3CGkAJlCoG4Yg/sxg4AA4Jpo2DdOwMXSXv0G3 FYx+WTEfkE8qVHkGF18LzAqaxLxMW8/ReaBWj8ZgW2rsjhcF43Hp7tHfle1yh90t2beqMhVpYUI amqs9h02AWlcTQIrWJ1gNwO4N8NUQdWNGWpG2zJesz0a3vQB3xDc9uT6g7pzFDm6SNSskCGaeA3 XNI7GnssGulnbumIQ2M4ytFAAErRzCXLnor2Ky4aHjLEk4fxtYWZE1Taus+Q6djseawweLMqkEx qn+CitCw/TcYNJBGKfml84VAo2V4jnlZ17vWetg4EfMCIcs+Ul1SV3sJV4z1BTmR/N0QVpTrHRQ RkEvPrdeIZbEEePII0d/2WFj1/OgIxY9CM/leKjXRSpLbotlNgWWjWBeWp9gEL7ddojA6NsROVl jepcbu+F490PmcqMI8p0WNLCINmKxXlwBuUw== X-Received: by 2002:a17:902:ebc4:b0:2b4:5dad:2523 with SMTP id d9443c01a7336-2b9f2815bb5mr27612865ad.35.1777716831640; Sat, 02 May 2026 03:13:51 -0700 (PDT) Received: from localhost ([2001:19f0:8001:1b2d:5400:5ff:fefa:a95d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b9cae36885sm47201105ad.59.2026.05.02.03.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2026 03:13:51 -0700 (PDT) From: Inochi Amaoto To: Jingoo Han , Manivannan Sadhasivam , Bjorn Helgaas , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Yixun Lan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Inochi Amaoto , Alex Elder , Gustavo Pimentel Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, Yixun Lan , Longbin Li Subject: [PATCH 4/5] dt-bindings: pci: spacemit: Introduce Spacemit K3 PCIe host controller Date: Sat, 2 May 2026 18:13:17 +0800 Message-ID: <20260502101319.2364052-5-inochiama@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260502101319.2364052-1-inochiama@gmail.com> References: <20260502101319.2364052-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add binding support for the PCIe controller on the SpacemiT K3 SoC. This controller is almost a standard Synopsys Designware PCIe IP, with some extra link and reset state control. Signed-off-by: Inochi Amaoto --- .../bindings/pci/spacemit,k3-pcie-host.yaml | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/spacemit,k3-pcie-= host.yaml diff --git a/Documentation/devicetree/bindings/pci/spacemit,k3-pcie-host.ya= ml b/Documentation/devicetree/bindings/pci/spacemit,k3-pcie-host.yaml new file mode 100644 index 000000000000..be2641526b19 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/spacemit,k3-pcie-host.yaml @@ -0,0 +1,142 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/spacemit,k3-pcie-host.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT K3 PCI Express Host Controller + +maintainers: + - Inochi Amaoto + +description: + The SpacemiT K3 SoC PCIe host controller is based on the Synopsys + DesignWare PCIe IP. The controller uses the external MSI interrupt + controller. + +allOf: + - $ref: /schemas/pci/pci-host-bridge.yaml# + - $ref: /schemas/pci/snps,dw-pcie.yaml# + +properties: + compatible: + const: spacemit,k3-pcie + + reg: + items: + - description: DesignWare PCIe registers + - description: Data Bus Interface (DBI) shadow registers + - description: ATU address space + - description: PCIe configuration space + - description: Link control registers + + reg-names: + items: + - const: dbi + - const: dbi2 + - const: atu + - const: config + - const: link + + clocks: + items: + - description: DWC PCIe Data Bus Interface (DBI) clock + - description: DWC PCIe application AXI-bus master interface clock + - description: DWC PCIe application AXI-bus slave interface clock + + clock-names: + items: + - const: dbi + - const: mstr + - const: slv + + resets: + items: + - description: DWC PCIe Data Bus Interface (DBI) reset + - description: DWC PCIe application AXI-bus master interface reset + - description: DWC PCIe application AXI-bus slave interface reset + + reset-names: + items: + - const: dbi + - const: mstr + - const: slv + + interrupts: + items: + - description: Interrupt used for port state + + interrupt-names: + const: app + + msi-parent: true + + phys: + minItems: 1 + maxItems: 6 + + phy-names: + minItems: 1 + maxItems: 6 + + spacemit,apmu: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: + A phandle that refers to the APMU system controller, whose regmap is + used in managing resets and link state, along with and offset of its + reset control register. + items: + - items: + - description: phandle to APMU system controller + - description: register offset + +required: + - clocks + - clock-names + - resets + - reset-names + - interrupts + - interrupt-names + - msi-parent + - spacemit,apmu + +unevaluatedProperties: false + +examples: + - | + #include + + soc { + #address-cells =3D <2>; + #size-cells =3D <2>; + + pcie@80000000 { + compatible =3D "spacemit,k3-pcie"; + reg =3D <0x0 0x80000000 0x0 0x00001000>, + <0x0 0x80100000 0x0 0x00001000>, + <0x0 0x80300000 0x0 0x00003f20>, + <0x11 0x00000000 0x0 0x00010000>, + <0x0 0x82900000 0x0 0x00001000>; + reg-names =3D "dbi", "dbi2", "atu", "config", "link"; + device_type =3D "pci"; + #address-cells =3D <3>; + #size-cells =3D <2>; + clocks =3D <&syscon_apmu 89>, + <&syscon_apmu 56>, + <&syscon_apmu 57>; + clock-names =3D "dbi", "mstr", "slv"; + interrupts =3D <141 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names =3D "app"; + msi-parent =3D <&simsic>; + ranges =3D <0x01000000 0x00 0x00010000 0x11 0x00010000 0x0 0x00100= 000>, + <0x02000000 0x0 0x00110000 0x11 0x00110000 0x0 0x7fef000= 0>, + <0x43000000 0x18 0x00000000 0x18 0x00000000 0x1 0x0000000= 0>; + resets =3D <&syscon_apmu 76>, + <&syscon_apmu 78>, + <&syscon_apmu 77>; + reset-names =3D "dbi", "mstr", "slv"; + linux,pci-domain =3D <0>; + spacemit,apmu =3D <&syscon_apmu 0x1f0>; + }; + }; + --=20 2.54.0 From nobody Sun Jun 14 06:08:19 2026 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2E3633064D for ; Sat, 2 May 2026 10:13:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716840; cv=none; b=f1vhI9mHmcGx0BT1s56ui5LlLsBjXJM5aDVnqJdX65g8BNlC5pEfQuuRE0SaAPolO5lQSUsDBVktudLoKds6jNJNcC9FVaRddl/36eKmCt8RJehK/VqWUjqTqOlhHpnSgoHp1LVaRwvyD7rtS2ZBGNsJyJFI2N0sWvG55/06VFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777716840; c=relaxed/simple; bh=IIn0BqYi016AJzSVBnUNDk9SvN+vM/Po4/FcjBlMWf8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NW4GaFro4iLvfM3wW+x2FT6mkgouMP+oygVfo7fo+kHn6o9Hw2c4rVeLFWPbbAcP3/NixV4ovqwpJwfaAF/y4m4cZIaHcNwghCCopemYNQeRr0hlEnD6UMN8VPsp90D4RL0gShFLNMUDHBOr1z18GInmoenkororkPTYiiutPDE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TwOL8+DZ; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TwOL8+DZ" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-c6dd5b01e14so938373a12.0 for ; Sat, 02 May 2026 03:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777716834; x=1778321634; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gr6D/Xzdn4v9rbHKlmP/r4GXGKbaNof+CbkZ0R6qh7Y=; b=TwOL8+DZNv1xF6v7995T1SodJ99yLez5hgKGe/hgR4lAMv74R296qrdDDynr/fG+G9 fdD/uHwDin3G5QXbmOgI1fhl4eI1GQJNFy+G65XmtHfmxyodSktZlD/cCgry02N+IM/d xzO8Ka8kGM42CoHb00CxStfiSQTm4Vbj6Wbz8HxqqAdGJUIzl95nmgomOxmGBtF/Az8n I+MvC8fpe5zweYkHFOQpNLHnCwKTN+PwBIPIYBxqRhA0HH4UDGMXmXXf+tb5PyrhAAj9 IC5hscrRA7INgV8EBK80AMSo5HTJ1wH8z6LFijSAkQBapU8gPXQK4UfzyFh8o7+3IOKK awZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777716834; x=1778321634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gr6D/Xzdn4v9rbHKlmP/r4GXGKbaNof+CbkZ0R6qh7Y=; b=dDQ6p2T/mUA/qVuclRBV3rUJwfuf77gPCJ3q7K2liO8iXDZxXuTDwdKpi66iYcuIxw im2CBLlzkdo7Z93AnIsoRRmji6IdAxJXrgHmokupaRoeca1MxEt+ogteQiCkte4ULE+R kgfjUyshafI5nPztEGsSBzbxlC3oEa5sM45DAbGwni6HfpLFlz9KUaVYwL87UhYGCbKe HWgp1ubkAKqQezFqC4PZO49zbkKH73Op1KIodZXGEOLYO9BSS/bnRaQgS5OyzXFpTm0r pxXXpoC89uOPU7EYXUNJcRDr/6Q0vb4b2CntovdilgUfhcczFfSDMAEqYnqFqTCd7TgY 3NuQ== X-Forwarded-Encrypted: i=1; AFNElJ+X4ih0QgO9MztmEbJc4Qj/70HjRuxzoEfKloBXYIAh0p+8bXwYBjM+57DT2zx5SFIX4JrX7R2V8zvMb+4=@vger.kernel.org X-Gm-Message-State: AOJu0YxD8ORCxkXR7CfXyley8CAZUQ9nUrW3cc8jP+yA/iKGcv3niFgQ xenaalShwNhTb6MHUmTqzJ4BaQpICTFke75rnKfKcdEb3nRndAid7z2y X-Gm-Gg: AeBDiesqT+pJgfQ6OyYbRMJ0eGzFA/WxqFjJjXUJRsvBnnr6J0xoYWE2GggjE2WUw9q 0vFuxufQf/mB5db2t5avPEIrwT9RNbck1FLORyfLIl30JG+NgpQhhh17WNtcv1L7CassmzkqcgB YPzDfGaeOXUedXlSsSGiilkL59MwQmcDZadaT/zM3v3zQdhlgktqSgn6gyZ6+BMiZRcVBNvC32K tWxGRWLfufDzzgumELkpmZ5PXCHCta48Wi8jorJMVGts6CY9kzredqGxnxQNbHCD7KOh4RQUL12 B9mCviB4D/KO5UonEKs/Mr/o9R0m/IeuXv3k7VQKStShJ8V/pfJj3Ej8RnzA9YTjH3AA5wz9mYE xcbtjYAnx6glsNDEJsqk37lEuvVAhtQ/YT23udECQvDdUqxJBBKpqNJWOVrn5qpbOe6X4iORo0q uDTXBN1UGplsoTVuMu1aL6ajsKT6AhBTtn9wZIiKeFo8bG X-Received: by 2002:a05:6a20:72a7:b0:39c:235:c5ec with SMTP id adf61e73a8af0-3a7f1d18314mr2674945637.34.1777716834197; Sat, 02 May 2026 03:13:54 -0700 (PDT) Received: from localhost ([2001:19f0:8001:1b2d:5400:5ff:fefa:a95d]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83515ad0049sm5842519b3a.33.2026.05.02.03.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2026 03:13:53 -0700 (PDT) From: Inochi Amaoto To: Jingoo Han , Manivannan Sadhasivam , Bjorn Helgaas , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Yixun Lan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Inochi Amaoto , Alex Elder , Gustavo Pimentel Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, Yixun Lan , Longbin Li Subject: [PATCH 5/5] PCI: spacemit-k1: Add Spacemit K3 PCIe host controller support Date: Sat, 2 May 2026 18:13:18 +0800 Message-ID: <20260502101319.2364052-6-inochiama@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260502101319.2364052-1-inochiama@gmail.com> References: <20260502101319.2364052-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The PCIe controller on Spacemit K3 is almost a standard Synopsys Designware PCIe IP with extra link and reset control. Unlike the PCIe controller on K1, this controller supports external MSI interrupt controller and can use multiple phy at the same time. Add driver to support PCIe controller on Spacemit K3 PCIe. Signed-off-by: Inochi Amaoto --- drivers/pci/controller/dwc/pcie-spacemit-k1.c | 238 ++++++++++++++++++ 1 file changed, 238 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/co= ntroller/dwc/pcie-spacemit-k1.c index f2a722e5edb5..fa529ac18f2d 100644 --- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c +++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c @@ -23,6 +23,7 @@ =20 #define PCI_VENDOR_ID_SPACEMIT 0x201f #define PCI_DEVICE_ID_SPACEMIT_K1 0x0001 +#define PCI_DEVICE_ID_SPACEMIT_K3 0x0002 =20 /* Offsets and field definitions for link management registers */ #define K1_PHY_AHB_IRQ_EN 0x0000 @@ -32,8 +33,27 @@ #define SMLH_LINK_UP BIT(1) #define RDLH_LINK_UP BIT(12) =20 +#define INTR_STATUS 0x0010 + #define INTR_ENABLE 0x0014 #define MSI_CTRL_INT BIT(11) +#define RDLH_LINK_UP_INT BIT(20) + +#define K3_PHY_AHB_IRQSTATUS_INTX 0x0008 + +#define K3_PHY_AHB_IRQENABLE_SET_INTX 0x000c +#define LEG_EP_INTERRUPTS (BIT(6) | BIT(7) | BIT(8) | BIT(9)) + +#define K3_PHY_AHB_IRQENABLE_SET_MSI 0x0014 +/* MSI defined as BIT(11) in existing INTR_ENABLE, reusing */ + +#define K3_ADDR_INTR_STATUS1 0x0018 + +#define K3_ADDR_INTR_ENABLE1 0x001C +#define MSI_INT BIT(0) +#define MSIX_INT GENMASK(8, 1) + +#define K3_MAX_PHY_NUMBER 6 =20 /* Some controls require APMU regmap access */ #define SYSCON_APMU "spacemit,apmu" @@ -48,6 +68,9 @@ =20 #define PCIE_CONTROL_LOGIC 0x0004 #define PCIE_SOFT_RESET BIT(0) +#define PCIE_PERSTN_OE BIT(24) +#define PCIE_PERSTN_OUT BIT(25) +#define PCIE_IGNORE_PERSTN BIT(31) =20 struct k1_pcie { struct dw_pcie pci; @@ -263,6 +286,213 @@ static const struct dw_pcie_ops k1_pcie_ops =3D { .stop_link =3D k1_pcie_stop_link, }; =20 +static int k3_pcie_enable_phy(struct k1_pcie *pcie) +{ + int i, ret; + + for (i =3D 0; i < pcie->phy_count; i++) { + ret =3D phy_init(pcie->phy[i]); + if (ret) + goto err_phy; + } + + return 0; + +err_phy: + while (--i >=3D 0) + phy_exit(pcie->phy[i]); + + return ret; +} + +static int k3_pcie_init(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp); + struct k1_pcie *k1 =3D to_k1_pcie(pci); + u32 reset_ctrl =3D k1->pmu_off + PCIE_CLK_RESET_CONTROL; + u32 val; + int ret; + + regmap_clear_bits(k1->pmu, reset_ctrl, LTSSM_EN); + + k1_pcie_toggle_soft_reset(k1); + + ret =3D k1_pcie_enable_resources(k1); + if (ret) + return ret; + + regmap_set_bits(k1->pmu, reset_ctrl, PCIE_AUX_PWR_DET); + regmap_clear_bits(k1->pmu, reset_ctrl, APP_HOLD_PHY_RST); + + ret =3D k3_pcie_enable_phy(k1); + if (ret) + return ret; + + /* K3: Set IGNORE_PERSTN and drive PERSTN_OE high (assert reset) */ + regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CONTROL_LOGIC, + PCIE_IGNORE_PERSTN | PCIE_PERSTN_OE | PCIE_PERSTN_OUT); + usleep_range(1000, 2000); + regmap_clear_bits(k1->pmu, k1->pmu_off + PCIE_CONTROL_LOGIC, PCIE_PERSTN_= OUT); + + mdelay(PCIE_T_PVPERL_MS); + + /* + * Put the controller in root complex mode, and indicate that + * Vaux (3.3v) is present. + */ + regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CONTROL_LOGIC, + PCIE_PERSTN_OUT | PCIE_PERSTN_OE); + + val =3D dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF); + val &=3D ~(0xffff << 8); + val |=3D ((0x1 << 4) << 8); + dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, val); + + /* Set the PCI vendor and device ID */ + dw_pcie_dbi_ro_wr_en(pci); + dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, PCI_VENDOR_ID_SPACEMIT); + dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, PCI_DEVICE_ID_SPACEMIT_K3); + dw_pcie_dbi_ro_wr_dis(pci); + + /* Finally, as a workaround, disable ASPM L1 */ + k1_pcie_disable_aspm_l1(k1); + + return 0; +} + +static int k3_pcie_msi_host_init(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp); + u32 val; + + dw_pcie_dbi_ro_wr_en(pci); + + val =3D dw_pcie_readl_dbi(pci, COHERENCY_CONTROL_3_OFF); + val |=3D (0xf << 11); + dw_pcie_writel_dbi(pci, COHERENCY_CONTROL_3_OFF, val); + + dw_pcie_dbi_ro_wr_dis(pci); + + return 0; +} + +static const struct dw_pcie_host_ops k3_pcie_host_ops =3D { + .init =3D k3_pcie_init, + .deinit =3D k1_pcie_deinit, + .msi_init =3D k3_pcie_msi_host_init, +}; + +static int k3_pcie_start_link(struct dw_pcie *pci) +{ + struct k1_pcie *k1 =3D to_k1_pcie(pci); + u32 val; + + k1_pcie_start_link(pci); + + /* Enable INTx */ + val =3D readl_relaxed(k1->link + K3_PHY_AHB_IRQENABLE_SET_INTX); + val |=3D LEG_EP_INTERRUPTS; + writel_relaxed(val, k1->link + K3_PHY_AHB_IRQENABLE_SET_INTX); + + /* Enable MSI/MSIX specific to K3 */ + val =3D readl_relaxed(k1->link + K3_ADDR_INTR_ENABLE1); + val |=3D (MSI_INT | MSIX_INT); + writel_relaxed(val, k1->link + K3_ADDR_INTR_ENABLE1); + + return 0; +} + +static const struct dw_pcie_ops k3_pcie_ops =3D { + .link_up =3D k1_pcie_link_up, + .start_link =3D k3_pcie_start_link, + .stop_link =3D k1_pcie_stop_link, +}; + +static void k3_pcie_clear_irq_status(struct k1_pcie *k1, + u32 *status0, u32 *status1, u32 *status2) +{ + *status0 =3D readl_relaxed(k1->link + K3_PHY_AHB_IRQSTATUS_INTX); + *status1 =3D readl_relaxed(k1->link + INTR_STATUS); + *status2 =3D readl_relaxed(k1->link + K3_ADDR_INTR_STATUS1); + + writel_relaxed(*status0, k1->link + K3_PHY_AHB_IRQSTATUS_INTX); + writel_relaxed(*status1, k1->link + INTR_STATUS); + writel_relaxed(*status2, k1->link + K3_ADDR_INTR_STATUS1); +} + +static int k3_pcie_parse_port(struct k1_pcie *k1) +{ + struct device *dev =3D k1->pci.dev; + u32 status0, status1, status2; + int i; + + k1->phy =3D devm_kmalloc_array(dev, sizeof(*k1->phy), + K3_MAX_PHY_NUMBER, GFP_KERNEL); + if (IS_ERR(k1->phy)) + return PTR_ERR(k1->phy); + + for (i =3D 0; i < K3_MAX_PHY_NUMBER; i++) { + k1->phy[i] =3D devm_of_phy_get_by_index(dev, dev->of_node, i); + if (IS_ERR(k1->phy[i])) { + if (PTR_ERR(k1->phy[i]) =3D=3D -ENODEV) + break; + + return PTR_ERR(k1->phy[i]); + } + } + + k1->phy_count =3D i; + if (k1->phy_count =3D=3D 0) + return -EINVAL; + + k3_pcie_clear_irq_status(k1, &status0, &status1, &status2); + + return 0; +} + +static irqreturn_t k3_pcie_irq_thread(int irq, void *data) +{ + struct k1_pcie *k1 =3D data; + struct dw_pcie_rp *pp =3D &k1->pci.pp; + struct device *dev =3D k1->pci.dev; + u32 status0, status1, status2; + + k3_pcie_clear_irq_status(k1, &status0, &status1, &status2); + + writel_relaxed(status0, k1->link + K3_PHY_AHB_IRQSTATUS_INTX); + writel_relaxed(status1, k1->link + INTR_STATUS); + writel_relaxed(status2, k1->link + K3_ADDR_INTR_STATUS1); + + if (FIELD_GET(RDLH_LINK_UP_INT, status1)) { + msleep(PCIE_RESET_CONFIG_WAIT_MS); + /* Rescan the bus to enumerate endpoint devices */ + pci_lock_rescan_remove(); + pci_rescan_bus(pp->bridge->bus); + pci_unlock_rescan_remove(); + } else if (!status0 && !status1 && !status2) + dev_WARN_ONCE(dev, true, + "Received unknown event. status0=3D0x%08x status1=3D0x%08x status= 2=3D0x%08x\n", + status0, status1, status2); + + return IRQ_HANDLED; +} + +static int k3_pcie_post_init(struct k1_pcie *k1) +{ + struct device *dev =3D k1->pci.dev; + struct platform_device *pdev =3D to_platform_device(dev); + int irq; + + irq =3D platform_get_irq_byname_optional(pdev, "app"); + if (irq > 0) { + return devm_request_threaded_irq(dev, irq, NULL, + k3_pcie_irq_thread, + IRQF_ONESHOT, NULL, k1); + } + + return 0; +} + static int k1_pcie_parse_port(struct k1_pcie *k1) { struct device *dev =3D k1->pci.dev; @@ -373,8 +603,16 @@ static const struct k1_pcie_device_data k1_pcie_device= _data =3D { .parse_port =3D k1_pcie_parse_port, }; =20 +static const struct k1_pcie_device_data k3_pcie_device_data =3D { + .host_ops =3D &k3_pcie_host_ops, + .ops =3D &k3_pcie_ops, + .parse_port =3D k3_pcie_parse_port, + .post_init =3D k3_pcie_post_init, +}; + static const struct of_device_id k1_pcie_of_match_table[] =3D { { .compatible =3D "spacemit,k1-pcie", .data =3D &k1_pcie_device_data}, + { .compatible =3D "spacemit,k3-pcie", .data =3D &k3_pcie_device_data}, { } }; =20 --=20 2.54.0