spacemit/k3-pico-itx: Bump to kernel 7.3

This commit is contained in:
liberodark committed 2026-10-19 10:43:34 +02:00
1 parent dc3f0cfde2
commit 2736ebd70c
17 files changed
+1961 -480

No files matched your search

+47 -33
View File
@@ -6,32 +6,24 @@
}@args:
let
modDirVersion = "7.2.0";
modDirVersion = "7.3.0";
in
buildLinux (
args
// {
inherit modDirVersion;
version = "7.2-spacemit-k3";
version = "7.3-spacemit-k3";
src = fetchFromGitHub {
owner = "torvalds";
repo = "linux";
tag = "v7.2";
hash = "sha256-GAjLGXXJiU42En31XWWx31IRT63G2pNsDN4ifNGtHis=";
tag = "v7.3";
hash = "sha256-ca8CMAWKe1yzkQIn8sasUQxMLqdtfvC+wBFtX3819Zk=";
};
defconfig = "defconfig";
kernelPatches = [
{
name = "k3-pcie-01-phy-dt-bindings";
patch = ./patches/0001-phy-dt-bindings-k3-comb-phy.patch;
}
{
name = "k3-pcie-02-phy-combphy-driver";
patch = ./patches/0002-phy-k3-combphy-driver.patch;
}
{
name = "k3-pcie-03-pci-k1-device-data";
patch = ./patches/0003-pci-k1-device-data.patch;
@@ -40,6 +32,10 @@ buildLinux (
name = "k3-pcie-04-pci-k1-multiple-phy-handles";
patch = ./patches/0004-pci-k1-multiple-phy-handles.patch;
}
{
name = "k3-pcie-04b-pci-k1-device-id-helper";
patch = ./patches/0004b-pci-k1-device-id-helper.patch;
}
{
name = "k3-pcie-05-dt-bindings-dw-pcie-msi-parent";
patch = ./patches/0005-dt-bindings-dw-pcie-msi-parent.patch;
@@ -61,7 +57,7 @@ buildLinux (
patch = ./patches/0009-dts-k3-uart0-gate-clock.patch;
}
{
name = "k3-09-dts-k3-add-pcie-combphy";
name = "k3-10-dts-k3-add-pcie";
patch = ./patches/0010-dts-k3-add-pcie-combphy.patch;
}
{
@@ -80,15 +76,42 @@ buildLinux (
name = "k3-14-cpufreq-spacemit-k3";
patch = ./patches/0014-cpufreq-spacemit-k3.patch;
}
# SM10 Support
#{
# name = "k3-15-dts-com260-pcie";
# patch = ./patches/0015-dts-k3-com260-pcie.patch;
#}
#{
# name = "k3-16-remoteproc-rcpu";
# patch = ./patches/0016-remoteproc-spacemit-k3-rcpu.patch;
#}
{
name = "k3-15-dts-com260-pcie";
patch = ./patches/0015-dts-k3-com260-pcie.patch;
}
{
name = "k3-15-dt-bindings-vendor-prefixes-sensylink";
patch = ./patches/0015-dt-bindings-vendor-prefixes-sensylink.patch;
}
{
name = "k3-16-dt-bindings-hwmon-lm63-family";
patch = ./patches/0016-dt-bindings-hwmon-lm63-family.patch;
}
{
name = "k3-17-dt-bindings-hwmon-ctf2301";
patch = ./patches/0017-dt-bindings-hwmon-ctf2301.patch;
}
{
name = "k3-18-hwmon-lm63-ctf2301";
patch = ./patches/0018-hwmon-lm63-ctf2301.patch;
}
{
name = "k3-19-dts-i2c6-pinctrl";
patch = ./patches/0019-dts-k3-i2c6-pinctrl.patch;
}
{
name = "k3-20-dts-com260-ctf2301";
patch = ./patches/0020-dts-k3-com260-ctf2301.patch;
}
{
name = "k3-21-dts-com260-fan-cooling";
patch = ./patches/0021-dts-k3-com260-fan-cooling.patch;
}
{
name = "k3-22-dts-com260-qspi-nor";
patch = ./patches/0022-dts-k3-com260-qspi-nor.patch;
}
];
structuredExtraConfig = with lib.kernel; {
@@ -105,13 +128,7 @@ buildLinux (
THERMAL = option yes;
THERMAL_HWMON = option yes;
HWMON = option yes;
# SM10
#MAILBOX = option yes;
#SPACEMIT_K3_MAILBOX = option yes;
#REMOTEPROC = option yes;
#SPACEMIT_K3_RPROC = option yes;
#RPMSG = option yes;
#RPMSG_VIRTIO = option yes;
SENSORS_LM63 = option yes;
SMP = option yes;
SPACEMIT_K3_CCU = option yes;
GPIO_SPACEMIT_K1 = option yes;
@@ -124,9 +141,6 @@ buildLinux (
PCIE_SPACEMIT_K1 = option yes;
PHY_SPACEMIT_K3_COMBO_PHY = option yes;
PHY_SPACEMIT_K3_COMMON_OPS = option yes;
# SM10
#PWM = option yes;
#PWM_PXA = option yes;
NVME_CORE = option yes;
BLK_DEV_NVME = option yes;
MMC = option yes;
@@ -202,7 +216,7 @@ buildLinux (
DEBUG_INFO_BTF_MODULES = lib.mkForce no;
};
extraMeta.branch = "7.2";
extraMeta.branch = "7.3";
}
// (args.argsOverride or { })
)
@@ -1,8 +1,8 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH 1/5] PCI: spacemit-k1: Add device data support
From From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 1/6] PCI: spacemit-k1: Add device data support
From: Inochi Amaoto <inochiama@gmail.com>
Date: Sat, 02 May 2026 18:13:14 +0800
Message-Id: <20260502101319.2364052-2-inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:21 +0800
Message-Id: <20260709040027.958400-2-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
@@ -12,29 +12,35 @@ data to handle the K1 specific logic and make room for the incoming
logic for K3.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Alex Elder <elder@riscstar.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
---
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 35 ++++++++++++++++---
1 file changed, 31 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 30 ++++++++++++++++---
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
index be20a520255b..cd3cd038ad2b 100644
index be20a520255b..f6ae8ff3589a 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;
};
@@ -49,8 +49,17 @@
#define PCIE_CONTROL_LOGIC 0x0004
#define PCIE_SOFT_RESET BIT(0)
+struct k1_pcie;
+
+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))
@@ -278,10 +285,15 @@ static int k1_pcie_parse_port(struct k1_pcie *k1)
struct k1_pcie {
struct dw_pcie pci;
+ const struct k1_pcie_device_data *data;
struct phy *phy;
void __iomem *link;
struct regmap *pmu; /* Errors ignored; MMIO-backed regmap */
@@ -278,14 +287,21 @@ static int k1_pcie_parse_port(struct k1_pcie *k1)
static int k1_pcie_probe(struct platform_device *pdev)
{
@@ -50,7 +56,13 @@ index be20a520255b..cd3cd038ad2b 100644
k1 = devm_kzalloc(dev, sizeof(*k1), GFP_KERNEL);
if (!k1)
return -ENOMEM;
@@ -299,11 +311,11 @@ static int k1_pcie_probe(struct platform_device *pdev)
+ k1->data = data;
+
k1->pmu = syscon_regmap_lookup_by_phandle_args(dev_of_node(dev),
SYSCON_APMU, 1,
&k1->pmu_off);
@@ -299,11 +315,11 @@ static int k1_pcie_probe(struct platform_device *pdev)
"failed to map \"link\" registers\n");
k1->pci.dev = dev;
@@ -64,7 +76,7 @@ index be20a520255b..cd3cd038ad2b 100644
/* 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)
@@ -320,7 +336,7 @@ static int k1_pcie_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, k1);
@@ -73,23 +85,7 @@ index be20a520255b..cd3cd038ad2b 100644
if (ret)
return dev_err_probe(dev, ret, "failed to parse root port\n");
@@ -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");
+ if (data->post_init) {
+ ret = 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;
}
@@ -338,8 +359,14 @@ static void k1_pcie_remove(struct platform_device *pdev)
@@ -338,8 +354,14 @@ static void k1_pcie_remove(struct platform_device *pdev)
dw_pcie_host_deinit(&k1->pci.pp);
}
@@ -106,5 +102,4 @@ index be20a520255b..cd3cd038ad2b 100644
};
--
2.54.0
2.55.0
@@ -1,45 +1,107 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH 2/5] PCI: spacemit-k1: Add multiple phy handles support
Subject: [PATCH v4 2/6] PCI: spacemit-k1: Add multiple PHY handles support
From: Inochi Amaoto <inochiama@gmail.com>
Date: Sat, 02 May 2026 18:13:15 +0800
Message-Id: <20260502101319.2364052-3-inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:22 +0800
Message-Id: <20260709040027.958400-3-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
The PCIe controller on Spacemit K3 may use multiple phys at the
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.
So extend the PHY definition to support multiple PHY handles.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
---
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 70 ++++++++++++++++---
1 file changed, 59 insertions(+), 11 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
index cd3cd038ad2b..f2a722e5edb5 100644
index f6ae8ff3589a..e22ecbd09579 100644
--- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
+++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
@@ -51,7 +51,8 @@
@@ -55,12 +55,14 @@ 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);
+ unsigned int max_phy_count;
};
struct k1_pcie {
struct dw_pcie pci;
const struct k1_pcie_device_data *data;
- struct phy *phy;
+ struct phy **phy;
+ int phy_count;
+ unsigned 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)
@@ -119,6 +121,54 @@ static void k1_pcie_disable_resources(struct k1_pcie *k1)
clk_bulk_disable_unprepare(ARRAY_SIZE(pci->app_clks), pci->app_clks);
}
+static int k1_pcie_get_phy_handle(struct k1_pcie *k1, struct device_node *node)
+{
+ const struct k1_pcie_device_data *data = k1->data;
+ struct device *dev = k1->pci.dev;
+ unsigned int i;
+
+ k1->phy = devm_kmalloc_array(dev, data->max_phy_count,
+ sizeof(*k1->phy), GFP_KERNEL);
+ if (!k1->phy)
+ return -ENOMEM;
+
+ for (i = 0; i < data->max_phy_count; i++) {
+ k1->phy[i] = devm_of_phy_get_by_index(dev, node, i);
+ if (IS_ERR(k1->phy[i])) {
+ if (PTR_ERR(k1->phy[i]) == -ENODEV)
+ break;
+
+ return PTR_ERR(k1->phy[i]);
+ }
+ }
+
+ k1->phy_count = i;
+ if (k1->phy_count == 0)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int k1_pcie_enable_phy(struct k1_pcie *k1)
+{
+ unsigned int i;
+ int ret;
+
+ for (i = 0; i < k1->phy_count; i++) {
+ ret = phy_init(k1->phy[i]);
+ if (ret)
+ goto err_phy;
+ }
+
+ return 0;
+
+err_phy:
+ while (i--)
+ phy_exit(k1->phy[i]);
+
+ return ret;
+}
+
/* FIXME: Disable ASPM L1 to avoid errors reported on some NVMe drives */
static void k1_pcie_disable_aspm_l1(struct k1_pcie *k1)
{
@@ -174,7 +224,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);
- ret = phy_init(k1->phy);
+ ret = phy_init(k1->phy[0]);
+ ret = k1_pcie_enable_phy(k1);
if (ret) {
k1_pcie_disable_resources(k1);
@@ -192,12 +193,14 @@ static void k1_pcie_deinit(struct dw_pcie_rp *pp)
@@ -194,12 +244,14 @@ static void k1_pcie_deinit(struct dw_pcie_rp *pp)
{
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
struct k1_pcie *k1 = to_k1_pcie(pci);
@@ -55,20 +117,40 @@ index cd3cd038ad2b..f2a722e5edb5 100644
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);
@@ -266,23 +318,18 @@ static int k1_pcie_parse_port(struct k1_pcie *k1)
{
struct device *dev = k1->pci.dev;
struct device_node *root_port;
- struct phy *phy;
+ int ret;
/* We assume only one root port */
root_port = of_get_next_available_child(dev_of_node(dev), NULL);
if (!root_port)
return -EINVAL;
- phy = devm_of_phy_get(dev, root_port, NULL);
+ ret = k1_pcie_get_phy_handle(k1, root_port);
of_node_put(root_port);
- if (IS_ERR(phy))
- return PTR_ERR(phy);
-
- k1->phy = phy;
+ k1->phy = devm_kmalloc_array(dev, sizeof(*k1->phy), 1, GFP_KERNEL);
+ if (IS_ERR(k1->phy))
+ return PTR_ERR(k1->phy);
+
+ k1->phy[0] = phy;
+ k1->phy_count = 1;
return 0;
-
- return 0;
+ return ret;
}
static int k1_pcie_probe(struct platform_device *pdev)
@@ -358,6 +405,7 @@ static const struct k1_pcie_device_data k1_pcie_device_data = {
.host_ops = &k1_pcie_host_ops,
.ops = &k1_pcie_ops,
.parse_port = k1_pcie_parse_port,
+ .max_phy_count = 1,
};
static const struct of_device_id k1_pcie_of_match_table[] = {
--
2.54.0
2.55.0
@@ -0,0 +1,70 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 3/6] PCI: spacemit-k1: Add device id update helper
From: Inochi Amaoto <inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:23 +0800
Message-Id: <20260709040027.958400-4-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Both K1 and K3 needs to set vendor id and device id, add a helper function
to simplify this.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Alex Elder <elder@riscstar.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
---
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
index e22ecbd09579..31aac056b68e 100644
--- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
+++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
@@ -56,6 +56,7 @@ struct k1_pcie_device_data {
const struct dw_pcie_ops *ops;
int (*parse_port)(struct k1_pcie *k1);
unsigned int max_phy_count;
+ unsigned int device_id;
};
struct k1_pcie {
@@ -186,6 +187,16 @@ static void k1_pcie_disable_aspm_l1(struct k1_pcie *k1)
dw_pcie_dbi_ro_wr_dis(pci);
}
+static void k1_pcie_set_device_id(struct k1_pcie *k1)
+{
+ struct dw_pcie *pci = &k1->pci;
+
+ 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, k1->data->device_id);
+ dw_pcie_dbi_ro_wr_dis(pci);
+}
+
static int k1_pcie_init(struct dw_pcie_rp *pp)
{
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
@@ -201,10 +212,7 @@ static int k1_pcie_init(struct dw_pcie_rp *pp)
return ret;
/* 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_K1);
- dw_pcie_dbi_ro_wr_dis(pci);
+ k1_pcie_set_device_id(k1);
/*
* Start by asserting fundamental reset (drive PERST# low). The
@@ -406,6 +414,7 @@ static const struct k1_pcie_device_data k1_pcie_device_data = {
.ops = &k1_pcie_ops,
.parse_port = k1_pcie_parse_port,
.max_phy_count = 1,
+ .device_id = PCI_DEVICE_ID_SPACEMIT_K1,
};
static const struct of_device_id k1_pcie_of_match_table[] = {
--
2.55.0
@@ -1,9 +1,9 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH 3/5] dt-bindings: PCI: snps,dw-pcie: Add msi-parent for msi
handle check
Subject: [PATCH v4 4/6] dt-bindings: PCI: snps,dw-pcie: Add msi-parent for
MSI handle check
From: Inochi Amaoto <inochiama@gmail.com>
Date: Sat, 02 May 2026 18:13:16 +0800
Message-Id: <20260502101319.2364052-4-inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:24 +0800
Message-Id: <20260709040027.958400-5-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
@@ -13,16 +13,17 @@ 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.
Add new condition for MSI handling on IMSIC based SoC.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
---
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/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml
index b3216141881c..6a595207fae1 100644
index b3216141881c..91bbbc8924f6 100644
--- a/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml
+++ b/Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml
@@ -27,8 +27,11 @@ allOf:
@@ -31,7 +32,7 @@ index b3216141881c..6a595207fae1 100644
not:
- required:
- - msi-map
+ oneOf:
+ anyOf:
+ - required:
+ - msi-map
+ - required:
@@ -40,5 +41,4 @@ index b3216141881c..6a595207fae1 100644
properties:
interrupt-names:
--
2.54.0
2.55.0
@@ -1,171 +1,124 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH 4/5] dt-bindings: pci: spacemit: Introduce Spacemit K3 PCIe
host controller
Subject: [PATCH v4 5/6] dt-bindings: PCI: spacemit: Introduce Spacemit K3
PCIe host controller
From: Inochi Amaoto <inochiama@gmail.com>
Date: Sat, 02 May 2026 18:13:17 +0800
Message-Id: <20260502101319.2364052-5-inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:25 +0800
Message-Id: <20260709040027.958400-6-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Add binding support for the PCIe controller on the SpacemiT K3 SoC.
This controller is almost a standard Synopsys Designware PCIe IP,
This controller is almost a standard Synopsys DesignWare PCIe IP,
with some extra link and reset state control.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
.../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
.../bindings/pci/spacemit,k1-pcie-host.yaml | 50 ++++++++++++++++---
1 file changed, 43 insertions(+), 7 deletions(-)
diff --git a/Documentation/devicetree/bindings/pci/spacemit,k3-pcie-host.yaml 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 <inochiama@gmail.com>
+
+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
diff --git a/Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml b/Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml
index c4c00b5fcdc0..54817d6fd9af 100644
--- a/Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml
+++ b/Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml
@@ -14,26 +14,29 @@ description: >
PCIe IP. The controller uses the DesignWare built-in MSI interrupt
controller, and supports 256 MSIs.
-allOf:
- - $ref: /schemas/pci/snps,dw-pcie.yaml#
-
properties:
compatible:
- const: spacemit,k1-pcie
+ enum:
+ - spacemit,k1-pcie
+ - spacemit,k3-pcie
reg:
+ minItems: 4
items:
- description: DesignWare PCIe registers
- description: ATU address space
- description: PCIe configuration space
- description: Link control registers
+ - description: Data Bus Interface (DBI) shadow registers.
reg-names:
+ minItems: 4
items:
- const: dbi
- const: atu
- const: config
- const: link
+ - 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
+
clocks:
items:
@@ -66,6 +69,8 @@ properties:
interrupt-names:
const: msi
+ msi-parent: true
+
+ phys:
+ minItems: 1
+ maxItems: 6
spacemit,apmu:
$ref: /schemas/types.yaml#/definitions/phandle-array
description:
@@ -84,7 +89,8 @@ patternProperties:
properties:
phys:
- maxItems: 1
+ minItems: 1
+ maxItems: 6
vpcie3v3-supply:
description:
@@ -96,13 +102,43 @@ patternProperties:
unevaluatedProperties: false
+allOf:
+ - $ref: /schemas/pci/snps,dw-pcie.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: spacemit,k1-pcie
+ then:
+ properties:
+ reg:
+ maxItems: 4
+
+ phy-names:
+ minItems: 1
+ maxItems: 6
+ reg-names:
+ maxItems: 4
+
+ 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
+ patternProperties:
+ '^pcie@':
+ properties:
+ phys:
+ maxItems: 1
+
+required:
+ - clocks
+ - clock-names
+ - resets
+ - reset-names
+ - interrupts
+ - interrupt-names
+ - msi-parent
+ - spacemit,apmu
+ required:
+ - interrupts
+ - interrupt-names
+ else:
+ properties:
+ reg:
+ minItems: 5
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ soc {
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ pcie@80000000 {
+ compatible = "spacemit,k3-pcie";
+ reg = <0x0 0x80000000 0x0 0x00001000>,
+ <0x0 0x80100000 0x0 0x00001000>,
+ <0x0 0x80300000 0x0 0x00003f20>,
+ <0x11 0x00000000 0x0 0x00010000>,
+ <0x0 0x82900000 0x0 0x00001000>;
+ reg-names = "dbi", "dbi2", "atu", "config", "link";
+ device_type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ clocks = <&syscon_apmu 89>,
+ <&syscon_apmu 56>,
+ <&syscon_apmu 57>;
+ clock-names = "dbi", "mstr", "slv";
+ interrupts = <141 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "app";
+ msi-parent = <&simsic>;
+ ranges = <0x01000000 0x00 0x00010000 0x11 0x00010000 0x0 0x00100000>,
+ <0x02000000 0x0 0x00110000 0x11 0x00110000 0x0 0x7fef0000>,
+ <0x43000000 0x18 0x00000000 0x18 0x00000000 0x1 0x00000000>;
+ resets = <&syscon_apmu 76>,
+ <&syscon_apmu 78>,
+ <&syscon_apmu 77>;
+ reset-names = "dbi", "mstr", "slv";
+ linux,pci-domain = <0>;
+ spacemit,apmu = <&syscon_apmu 0x1f0>;
+ };
+ };
+ reg-names:
+ minItems: 5
+
required:
- clocks
- clock-names
- resets
- reset-names
- - interrupts
- - interrupt-names
- spacemit,apmu
unevaluatedProperties: false
--
2.54.0
2.55.0
@@ -1,38 +1,54 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH 5/5] PCI: spacemit-k1: Add Spacemit K3 PCIe host controller
support
Subject: [PATCH v4 6/6] PCI: spacemit-k1: Add Spacemit K3 PCIe host
controller support
From: Inochi Amaoto <inochiama@gmail.com>
Date: Sat, 02 May 2026 18:13:18 +0800
Message-Id: <20260502101319.2364052-6-inochiama@gmail.com>
Date: Thu, 09 Jul 2026 12:00:26 +0800
Message-Id: <20260709040027.958400-7-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
The PCIe controller on Spacemit K3 is almost a standard Synopsys
Designware PCIe IP with extra link and reset control. Unlike
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.
interrupt controller and can use multiple PHYs at the same time.
Add driver to support PCIe controller on Spacemit K3 PCIe.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
---
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 238 ++++++++++++++++++
1 file changed, 238 insertions(+)
drivers/pci/controller/dwc/Kconfig | 4 +-
drivers/pci/controller/dwc/pcie-spacemit-k1.c | 126 ++++++++++++++++++
2 files changed, 128 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig
index aa0b784c85b4..dacbac5cc35c 100644
--- a/drivers/pci/controller/dwc/Kconfig
+++ b/drivers/pci/controller/dwc/Kconfig
@@ -440,7 +440,7 @@ config PCIE_SOPHGO_DW
Sophgo SoCs.
config PCIE_SPACEMIT_K1
- tristate "SpacemiT K1 PCIe controller (host mode)"
+ tristate "SpacemiT PCIe controller (host mode)"
depends on ARCH_SPACEMIT || COMPILE_TEST
depends on HAS_IOMEM
select PCIE_DW_HOST
@@ -448,7 +448,7 @@ config PCIE_SPACEMIT_K1
default ARCH_SPACEMIT
help
Enables support for the DesignWare based PCIe controller in
- the SpacemiT K1 SoC operating in host mode. Three controllers
+ the SpacemiT SoC operating in host mode. Three controllers
are available on the K1 SoC; the first of these shares a PHY
with a USB 3.0 host controller (one or the other can be used).
diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
index f2a722e5edb5..fa529ac18f2d 100644
index 31aac056b68e..680acc93f539 100644
--- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
+++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
@@ -23,6 +23,7 @@
#define PCI_VENDOR_ID_SPACEMIT 0x201f
#define PCI_DEVICE_ID_SPACEMIT_K1 0x0001
+#define PCI_DEVICE_ID_SPACEMIT_K3 0x0002
/* Offsets and field definitions for link management registers */
#define K1_PHY_AHB_IRQ_EN 0x0000
@@ -32,8 +33,27 @@
@@ -32,8 +33,18 @@
#define SMLH_LINK_UP BIT(1)
#define RDLH_LINK_UP BIT(12)
@@ -44,23 +60,14 @@ index f2a722e5edb5..fa529ac18f2d 100644
+
+#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
+#define K3_CACHE_MSTR_AWCACHE_MODE GENMASK(14, 11)
+#define K3_CACHE_MSTR_AWCACHE_BEHAVIOR 0xf
/* Some controls require APMU regmap access */
#define SYSCON_APMU "spacemit,apmu"
@@ -48,6 +68,9 @@
@@ -48,6 +59,9 @@
#define PCIE_CONTROL_LOGIC 0x0004
#define PCIE_SOFT_RESET BIT(0)
@@ -68,31 +75,12 @@ index f2a722e5edb5..fa529ac18f2d 100644
+#define PCIE_PERSTN_OUT BIT(25)
+#define PCIE_IGNORE_PERSTN BIT(31)
struct k1_pcie {
struct dw_pcie pci;
@@ -263,6 +286,213 @@ static const struct dw_pcie_ops k1_pcie_ops = {
.stop_link = k1_pcie_stop_link,
};
struct k1_pcie;
@@ -340,6 +354,109 @@ static int k1_pcie_parse_port(struct k1_pcie *k1)
return ret;
}
+static int k3_pcie_enable_phy(struct k1_pcie *pcie)
+{
+ int i, ret;
+
+ for (i = 0; i < pcie->phy_count; i++) {
+ ret = phy_init(pcie->phy[i]);
+ if (ret)
+ goto err_phy;
+ }
+
+ return 0;
+
+err_phy:
+ while (--i >= 0)
+ phy_exit(pcie->phy[i]);
+
+ return ret;
+}
+
+static int k3_pcie_init(struct dw_pcie_rp *pp)
+{
+ struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
@@ -112,9 +100,11 @@ index f2a722e5edb5..fa529ac18f2d 100644
+ regmap_set_bits(k1->pmu, reset_ctrl, PCIE_AUX_PWR_DET);
+ regmap_clear_bits(k1->pmu, reset_ctrl, APP_HOLD_PHY_RST);
+
+ ret = k3_pcie_enable_phy(k1);
+ if (ret)
+ ret = k1_pcie_enable_phy(k1);
+ if (ret) {
+ k1_pcie_disable_resources(k1);
+ return ret;
+ }
+
+ /* K3: Set IGNORE_PERSTN and drive PERSTN_OE high (assert reset) */
+ regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CONTROL_LOGIC,
@@ -122,7 +112,7 @@ index f2a722e5edb5..fa529ac18f2d 100644
+ usleep_range(1000, 2000);
+ regmap_clear_bits(k1->pmu, k1->pmu_off + PCIE_CONTROL_LOGIC, PCIE_PERSTN_OUT);
+
+ mdelay(PCIE_T_PVPERL_MS);
+ msleep(PCIE_T_PVPERL_MS);
+
+ /*
+ * Put the controller in root complex mode, and indicate that
@@ -132,15 +122,11 @@ index f2a722e5edb5..fa529ac18f2d 100644
+ PCIE_PERSTN_OUT | PCIE_PERSTN_OE);
+
+ val = dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF);
+ val &= ~(0xffff << 8);
+ val |= ((0x1 << 4) << 8);
+ val = u32_replace_bits(val, BIT(7),
+ GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC);
+ 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);
+ k1_pcie_set_device_id(k1);
+
+ /* Finally, as a workaround, disable ASPM L1 */
+ k1_pcie_disable_aspm_l1(k1);
@@ -156,7 +142,8 @@ index f2a722e5edb5..fa529ac18f2d 100644
+ dw_pcie_dbi_ro_wr_en(pci);
+
+ val = dw_pcie_readl_dbi(pci, COHERENCY_CONTROL_3_OFF);
+ val |= (0xf << 11);
+ val = u32_replace_bits(val, K3_CACHE_MSTR_AWCACHE_BEHAVIOR,
+ K3_CACHE_MSTR_AWCACHE_MODE);
+ dw_pcie_writel_dbi(pci, COHERENCY_CONTROL_3_OFF, val);
+
+ dw_pcie_dbi_ro_wr_dis(pci);
@@ -170,29 +157,9 @@ index f2a722e5edb5..fa529ac18f2d 100644
+ .msi_init = k3_pcie_msi_host_init,
+};
+
+static int k3_pcie_start_link(struct dw_pcie *pci)
+{
+ struct k1_pcie *k1 = to_k1_pcie(pci);
+ u32 val;
+
+ k1_pcie_start_link(pci);
+
+ /* Enable INTx */
+ val = readl_relaxed(k1->link + K3_PHY_AHB_IRQENABLE_SET_INTX);
+ val |= LEG_EP_INTERRUPTS;
+ writel_relaxed(val, k1->link + K3_PHY_AHB_IRQENABLE_SET_INTX);
+
+ /* Enable MSI/MSIX specific to K3 */
+ val = readl_relaxed(k1->link + K3_ADDR_INTR_ENABLE1);
+ val |= (MSI_INT | MSIX_INT);
+ writel_relaxed(val, k1->link + K3_ADDR_INTR_ENABLE1);
+
+ return 0;
+}
+
+static const struct dw_pcie_ops k3_pcie_ops = {
+ .link_up = k1_pcie_link_up,
+ .start_link = k3_pcie_start_link,
+ .start_link = k1_pcie_start_link,
+ .stop_link = k1_pcie_stop_link,
+};
+
@@ -210,89 +177,26 @@ index f2a722e5edb5..fa529ac18f2d 100644
+
+static int k3_pcie_parse_port(struct k1_pcie *k1)
+{
+ struct device *dev = k1->pci.dev;
+ u32 status0, status1, status2;
+ int i;
+
+ k1->phy = 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 = 0; i < K3_MAX_PHY_NUMBER; i++) {
+ k1->phy[i] = devm_of_phy_get_by_index(dev, dev->of_node, i);
+ if (IS_ERR(k1->phy[i])) {
+ if (PTR_ERR(k1->phy[i]) == -ENODEV)
+ break;
+
+ return PTR_ERR(k1->phy[i]);
+ }
+ }
+
+ k1->phy_count = i;
+ if (k1->phy_count == 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 = data;
+ struct dw_pcie_rp *pp = &k1->pci.pp;
+ struct device *dev = 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=0x%08x status1=0x%08x status2=0x%08x\n",
+ status0, status1, status2);
+
+ return IRQ_HANDLED;
+ return k1_pcie_parse_port(k1);
+}
+
+static int k3_pcie_post_init(struct k1_pcie *k1)
+{
+ struct device *dev = k1->pci.dev;
+ struct platform_device *pdev = to_platform_device(dev);
+ int irq;
+
+ irq = 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)
static int k1_pcie_probe(struct platform_device *pdev)
{
struct device *dev = k1->pci.dev;
@@ -373,8 +603,16 @@ static const struct k1_pcie_device_data k1_pcie_device_data = {
.parse_port = k1_pcie_parse_port,
const struct k1_pcie_device_data *data;
@@ -417,8 +534,17 @@ static const struct k1_pcie_device_data k1_pcie_device_data = {
.device_id = PCI_DEVICE_ID_SPACEMIT_K1,
};
+static const struct k1_pcie_device_data k3_pcie_device_data = {
+ .host_ops = &k3_pcie_host_ops,
+ .ops = &k3_pcie_ops,
+ .parse_port = k3_pcie_parse_port,
+ .post_init = k3_pcie_post_init,
+ .max_phy_count = 6,
+ .device_id = PCI_DEVICE_ID_SPACEMIT_K3,
+};
+
static const struct of_device_id k1_pcie_of_match_table[] = {
@@ -302,5 +206,5 @@ index f2a722e5edb5..fa529ac18f2d 100644
};
--
2.54.0
2.55.0
@@ -1,89 +1,318 @@
From: liberodark <liberodark@gmail.com>
Subject: [PATCH] riscv: dts: spacemit: k3: add comb PHY and PCIe0 nodes
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v2 2/2] riscv: dts: spacemit: k3: Add PCIe device node
From: Inochi Amaoto <inochiama@gmail.com>
Date: Mon, 27 Jul 2026 17:47:24 +0800
Message-Id: <20260727094726.890179-3-inochiama@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Add combphy and pcie0 (port A x4, M.2 NVMe) nodes and enable them on
the Pico-ITX. PHY lane config 0x14 = lane-share, A x4, C lane0 USB3.
Add all PCIe device node for Spacemit K3.
Signed-off-by: liberodark <liberodark@gmail.com>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts | 38 ++++
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi | 33 ++++
arch/riscv/boot/dts/spacemit/k3.dtsi | 195 +++++++++++++++++++
3 files changed, 266 insertions(+)
diff --git a/arch/riscv/boot/dts/spacemit/k3-pico-itx.dts b/arch/riscv/boot/dts/spacemit/k3-pico-itx.dts
index b89c152..56a769a 100644
index 2a6d35a64d5c..1eb5abbc61f9 100644
--- a/arch/riscv/boot/dts/spacemit/k3-pico-itx.dts
+++ b/arch/riscv/boot/dts/spacemit/k3-pico-itx.dts
@@ -4,6 +4,7 @@
* Copyright (c) 2026 Guodong Xu <guodong@riscstar.com>
*/
#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/phy/phy.h>
#include "k3.dtsi"
#include "k3-pinctrl.dtsi"
@@ -221,3 +222,14 @@ hub@1 {
&usb2_phy {
status = "okay";
@@ -205,6 +205,44 @@ phy0: phy@1 {
};
};
+
+&combphy {
+&pcie0_rc {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie0_0_cfg>;
+ num-lanes = <4>;
+ status = "okay";
+
+ pcie@0 {
+ vpcie3v3-supply = <&reg_aux_vcc3v3>;
+ phys = <&combophy 0 PHY_TYPE_PCIE>,
+ <&combophy 1 PHY_TYPE_PCIE>;
+ };
+};
+
+&pcie0 {
+ phys = <&combphy 0 PHY_TYPE_PCIE>,
+ <&combphy 1 PHY_TYPE_PCIE>;
+ phy-names = "phy0", "phy1";
+&pcie2_rc {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie2_0_cfg>;
+ num-lanes = <2>;
+ status = "okay";
+
+ pcie@0 {
+ vpcie3v3-supply = <&reg_aux_vcc3v3>;
+ phys = <&combophy 2 PHY_TYPE_PCIE>,
+ <&combophy 3 PHY_TYPE_PCIE>;
+ };
+};
+
+&pcie4_rc {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie4_0_cfg>;
+ num-lanes = <1>;
+ status = "okay";
+
+ pcie@0 {
+ vpcie3v3-supply = <&reg_aux_vcc3v3>;
+ phys = <&combophy 5 PHY_TYPE_PCIE>;
+ };
+};
+
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_0_cfg>;
diff --git a/arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi b/arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi
index 3ee1471f3798..68aa21a5279f 100644
--- a/arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi
@@ -689,4 +689,37 @@ uart0-0-pins {
drive-strength = <25>;
};
};
+
+ pcie0_0_cfg: pcie0-0-cfg {
+ pcie0-0-pins {
+ pinmux = <K3_PADCONF(79, 5)>, /* pcie0 perst */
+ <K3_PADCONF(81, 5)>; /* pcie0 clkreq */
+
+ bias-pull-up = <1>;
+ drive-strength = <33>;
+ power-source = <1800>;
+ };
+ };
+
+ pcie2_0_cfg: pcie2-0-cfg {
+ pcie2-0-pins {
+ pinmux = <K3_PADCONF(25, 4)>, /* pcie2 perst */
+ <K3_PADCONF(27, 4)>; /* pcie2 clkreq */
+
+ drive-strength = <38>;
+ power-source = <3300>;
+ };
+ };
+
+ pcie4_0_cfg: pcie4-0-cfg {
+ pcie4-0-pins {
+ pinmux = <K3_PADCONF(76, 5)>, /* pcie4 perst */
+ <K3_PADCONF(77, 5)>, /* pcie4 wake */
+ <K3_PADCONF(78, 5)>; /* pcie4 clkreq */
+
+ bias-pull-up = <1>;
+ drive-strength = <33>;
+ power-source = <1800>;
+ };
+ };
};
diff --git a/arch/riscv/boot/dts/spacemit/k3.dtsi b/arch/riscv/boot/dts/spacemit/k3.dtsi
index 19fc9b4..da143aa 100644
index 7863ab7dd308..314dea88b4a4 100644
--- a/arch/riscv/boot/dts/spacemit/k3.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k3.dtsi
@@ -1099,6 +1099,49 @@ pll: clock-controller@d4090000 {
#clock-cells = <1>;
};
@@ -439,6 +439,201 @@ soc: soc {
dma-noncoherent;
ranges;
+ combphy: phy@81d00000 {
+ compatible = "spacemit,k3-comb-phy";
+ reg = <0x0 0x81d00000 0x0 0x600000>;
+ #phy-cells = <2>;
+ spacemit,apb-spare = <&pll>;
+ spacemit,apmu = <&syscon_apmu 0x14>;
+ status = "disabled";
+ };
+
+ pcie0: pcie@80000000 {
+ pcie0_rc: pcie@80000000 {
+ compatible = "spacemit,k3-pcie";
+ reg = <0x0 0x80000000 0x0 0x00001000>,
+ <0x0 0x80100000 0x0 0x00001000>,
+ <0x0 0x80300000 0x0 0x00003f20>,
+ reg = <0x0 0x80000000 0x0 0x00001000>,
+ <0x0 0x80300000 0x0 0x00003f20>,
+ <0x11 0x00000000 0x0 0x00010000>,
+ <0x0 0x82900000 0x0 0x00001000>;
+ reg-names = "dbi", "dbi2", "atu", "config", "link";
+ <0x0 0x82900000 0x0 0x00001000>,
+ <0x0 0x80100000 0x0 0x00001000>;
+ reg-names = "dbi", "atu", "config", "link", "dbi2";
+ device_type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ bus-range = <0x00 0xff>;
+ max-link-speed = <3>;
+ num-lanes = <4>;
+ linux,pci-domain = <0>;
+ clocks = <&syscon_apmu CLK_APMU_PCIE_PORTA_DBI>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTA_MSTE>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTA_SLV>;
+ clock-names = "dbi", "mstr", "slv";
+ msi-parent = <&simsic>;
+ ranges = <0x01000000 0x00 0x00010000 0x11 0x00010000 0x0 0x00100000>,
+ <0x02000000 0x0 0x00110000 0x11 0x00110000 0x0 0x7fef0000>,
+ <0x43000000 0x18 0x00000000 0x18 0x00000000 0x1 0x00000000>;
+ resets = <&syscon_apmu RESET_APMU_PCIE_A_DBI>,
+ <&syscon_apmu RESET_APMU_PCIE_A_MASTER>,
+ <&syscon_apmu RESET_APMU_PCIE_A_SLAVE>;
+ reset-names = "dbi", "mstr", "slv";
+ interrupt-parent = <&saplic>;
+ interrupts = <141 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "app";
+ msi-parent = <&simsic>;
+ ranges = <0x01000000 0x00 0x00010000 0x11 0x00010000 0x0 0x00100000>,
+ <0x02000000 0x0 0x00110000 0x11 0x00110000 0x0 0x7fef0000>,
+ <0x43000000 0x18 0x00000000 0x18 0x00000000 0x1 0x00000000>;
+ max-link-speed = <3>;
+ linux,pci-domain = <0>;
+ spacemit,apmu = <&syscon_apmu 0x1f0>;
+ status = "disabled";
+
+ pcie0_port: pcie@0 {
+ device_type = "pci";
+ compatible = "pciclass,0604";
+ reg = <0x0 0x0 0x0 0x0 0x0>;
+ bus-range = <0x01 0xff>;
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+ };
+ };
+
syscon_apmu: system-controller@d4282800 {
compatible = "spacemit,k3-syscon-apmu";
reg = <0x0 0xd4282800 0x0 0x400>;
+ pcie1_rc: pcie@80400000 {
+ compatible = "spacemit,k3-pcie";
+ reg = <0x0 0x80400000 0x0 0x00001000>,
+ <0x0 0x80700000 0x0 0x00003f20>,
+ <0x11 0x80000000 0x0 0x00010000>,
+ <0x0 0x82c00000 0x0 0x00001000>,
+ <0x0 0x80500000 0x0 0x00001000>;
+ reg-names = "dbi", "atu", "config", "link", "dbi2";
+ device_type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ clocks = <&syscon_apmu CLK_APMU_PCIE_PORTB_DBI>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTB_MSTE>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTB_SLV>;
+ clock-names = "dbi", "mstr", "slv";
+ msi-parent = <&simsic>;
+ ranges = <0x01000000 0x0 0x00010000 0x11 0x80010000 0x0 0x00100000>,
+ <0x02000000 0x0 0x80110000 0x11 0x80110000 0x0 0x7fef0000>,
+ <0x43000000 0x16 0x00000000 0x16 0x00000000 0x1 0x00000000>;
+ resets = <&syscon_apmu RESET_APMU_PCIE_B_DBI>,
+ <&syscon_apmu RESET_APMU_PCIE_B_MASTER>,
+ <&syscon_apmu RESET_APMU_PCIE_B_SLAVE>;
+ reset-names = "dbi", "mstr", "slv";
+ max-link-speed = <3>;
+ linux,pci-domain = <1>;
+ spacemit,apmu = <&syscon_apmu 0x1d0>;
+ status = "disabled";
+
+ pcie1_port: pcie@0 {
+ device_type = "pci";
+ compatible = "pciclass,0604";
+ reg = <0x0 0x0 0x0 0x0 0x0>;
+ bus-range = <0x01 0xff>;
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+ };
+ };
+
+ pcie2_rc: pcie@80800000 {
+ compatible = "spacemit,k3-pcie";
+ reg = <0x0 0x80800000 0x0 0x00001000>,
+ <0x0 0x80b00000 0x0 0x00003f20>,
+ <0x12 0x00000000 0x0 0x00010000>,
+ <0x0 0x82d00000 0x0 0x00001000>,
+ <0x0 0x80900000 0x0 0x00001000>;
+ reg-names = "dbi", "atu", "config", "link", "dbi2";
+ device_type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ clocks = <&syscon_apmu CLK_APMU_PCIE_PORTC_DBI>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTC_MSTE>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTC_SLV>;
+ clock-names = "dbi", "mstr", "slv";
+ msi-parent = <&simsic>;
+ ranges = <0x01000000 0x00 0x00000000 0x12 0x00010000 0x0 0x00100000>,
+ <0x02000000 0x0 0x00110000 0x12 0x00110000 0x0 0x7fef0000>,
+ <0x43000000 0x15 0x00000000 0x15 0x00000000 0x1 0x00000000>;
+ resets = <&syscon_apmu RESET_APMU_PCIE_C_DBI>,
+ <&syscon_apmu RESET_APMU_PCIE_C_MASTER>,
+ <&syscon_apmu RESET_APMU_PCIE_C_SLAVE>;
+ reset-names = "dbi", "mstr", "slv";
+ linux,pci-domain = <2>;
+ max-link-speed = <3>;
+ spacemit,apmu = <&syscon_apmu 0x1c8>;
+ status = "disabled";
+
+ pcie2_port: pcie@0 {
+ device_type = "pci";
+ compatible = "pciclass,0604";
+ reg = <0x0 0x0 0x0 0x0 0x0>;
+ bus-range = <0x01 0xff>;
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+ };
+ };
+
+ pcie3_rc: pcie@80c00000 {
+ compatible = "spacemit,k3-pcie";
+ reg = <0x0 0x80c00000 0x0 0x00001000>,
+ <0x0 0x80f00000 0x0 0x00003f20>,
+ <0x12 0x80000000 0x0 0x00010000>,
+ <0x0 0x82a00000 0x0 0x00001000>,
+ <0x0 0x80d00000 0x0 0x00001000>;
+ reg-names = "dbi", "atu", "config", "link", "dbi2";
+ device_type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ clocks = <&syscon_apmu CLK_APMU_PCIE_PORTD_DBI>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTD_MSTE>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTD_SLV>;
+ clock-names = "dbi", "mstr", "slv";
+ msi-parent = <&simsic>;
+ ranges = <0x01000000 0x0 0x00010000 0x12 0x80010000 0x0 0x100000>,
+ <0x02000000 0x0 0x80110000 0x12 0x80110000 0x0 0x3fef0000>,
+ <0x43000000 0x14 0x00000000 0x14 0x00000000 0x1 0x00000000>;
+ resets = <&syscon_apmu RESET_APMU_PCIE_D_DBI>,
+ <&syscon_apmu RESET_APMU_PCIE_D_MASTER>,
+ <&syscon_apmu RESET_APMU_PCIE_D_SLAVE>;
+ reset-names = "dbi", "mstr", "slv";
+ linux,pci-domain = <3>;
+ bus-range = <0x00 0xff>;
+ max-link-speed = <3>;
+ spacemit,apmu = <&syscon_apmu 0x1e0>;
+ status = "disabled";
+
+ pcie3_port: pcie@0 {
+ device_type = "pci";
+ compatible = "pciclass,0604";
+ reg = <0x0 0x0 0x0 0x0 0x0>;
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+ };
+ };
+
+ pcie4_rc: pcie@81000000 {
+ compatible = "spacemit,k3-pcie";
+ reg = <0x0 0x81000000 0x0 0x00001000>,
+ <0x0 0x81300000 0x0 0x00003f20>,
+ <0x12 0xc0000000 0x0 0x00010000>,
+ <0x0 0x82b00000 0x0 0x00001000>,
+ <0x0 0x81100000 0x0 0x00001000>;
+ reg-names = "dbi", "atu", "config", "link", "dbi2";
+ device_type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ clocks = <&syscon_apmu CLK_APMU_PCIE_PORTE_DBI>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTE_MSTE>,
+ <&syscon_apmu CLK_APMU_PCIE_PORTE_SLV>;
+ clock-names = "dbi", "mstr", "slv";
+ msi-parent = <&simsic>;
+ ranges = <0x01000000 0x0 0x00000000 0x12 0xc0010000 0x0 0x100000>,
+ <0x02000000 0x0 0xc0110000 0x12 0xc0110000 0x0 0x3fef0000>,
+ <0x43000000 0x13 0x00000000 0x13 0x00000000 0x1 0x00000000>;
+ resets = <&syscon_apmu RESET_APMU_PCIE_E_DBI>,
+ <&syscon_apmu RESET_APMU_PCIE_E_MASTER>,
+ <&syscon_apmu RESET_APMU_PCIE_E_SLAVE>;
+ reset-names = "dbi", "mstr", "slv";
+ linux,pci-domain = <4>;
+ max-link-speed = <3>;
+ spacemit,apmu = <&syscon_apmu 0x1e8>;
+ status = "disabled";
+
+ pcie4_port: pcie@0 {
+ device_type = "pci";
+ compatible = "pciclass,0604";
+ reg = <0x0 0x0 0x0 0x0 0x0>;
+ bus-range = <0x01 0xff>;
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+ };
+ };
+
usb3d: usb@81a00000 {
compatible = "spacemit,k3-dwc3";
reg = <0x0 0x81a00000 0x0 0x10000>;
--
2.55.0
@@ -0,0 +1,34 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 1/6] dt-bindings: vendor-prefixes: Add Sensylink
From: Troy Mitchell <troy.mitchell@linux.dev>
Date: Mon, 31 Aug 2026 21:45:35 +0800
Message-Id: <20260831-ctl2301-v4-1-b335d52a0570@linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Add the vendor prefix for Sensylink Microelectronics.
Link: https://en.sensylink.com/
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.dev>
---
Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index ba2002969373..4a5cf436eb14 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1495,6 +1495,8 @@ patternProperties:
description: Sensirion AG
"^sensortek,.*":
description: Sensortek Technology Corporation
+ "^sensylink,.*":
+ description: Sensylink Microelectronics Technology Co., Ltd.
"^sercomm,.*":
description: Sercomm (Suzhou) Corporation
"^sff,.*":
--
2.55.0
@@ -1,10 +1,12 @@
From: liberodark <liberodark@gmail.com>
Subject: [PATCH] riscv: dts: spacemit: k3: enable PCIe/NVMe on CoM260-IFX
Subject: [PATCH] riscv: dts: spacemit: k3: enable PCIe on CoM260-IFX
The CoM260-IFX (BPI-SM10) boots from an NVMe drive on PCIe port A,
same x4 comb-phy groups 0/1 wiring as the Pico-ITX. Enable combphy
and pcie0 on this board. (SD host support is being upstreamed
separately.)
The CoM260-IFX (BPI-SM10) boots from an NVMe drive on PCIe port A, with
the same x4 wiring as the Pico-ITX. Enable the combo PHY and the first
PCIe root complex on this board.
Rebased on v7.3-rc1: the PHY node and the PCIe host nodes now come from
upstream, so only the board level enablement is left here.
Signed-off-by: liberodark <liberodark@gmail.com>
---
@@ -19,18 +21,24 @@ Signed-off-by: liberodark <liberodark@gmail.com>
#include "k3-com260.dtsi"
/ {
@@ -19,3 +21,14 @@
stdout-path = "serial0:115200n8";
};
@@ -52,3 +54,20 @@
sd-uhs-sdr104;
status = "okay";
};
+
+&combphy {
+&combophy {
+ spacemit,apmu = <&syscon_apmu 0x11>;
+ status = "okay";
+};
+
+&pcie0 {
+ phys = <&combphy 0 PHY_TYPE_PCIE>,
+ <&combphy 1 PHY_TYPE_PCIE>;
+ phy-names = "phy0", "phy1";
+&pcie0_rc {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie0_0_cfg>;
+ num-lanes = <4>;
+ status = "okay";
+
+ pcie@0 {
+ phys = <&combophy 0 PHY_TYPE_PCIE>,
+ <&combophy 1 PHY_TYPE_PCIE>;
+ };
+};
@@ -0,0 +1,105 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 2/6] dt-bindings: hwmon: Move LM63 family to a dedicated
binding
From: Troy Mitchell <troy.mitchell@linux.dev>
Date: Mon, 31 Aug 2026 21:45:36 +0800
Message-Id: <20260831-ctl2301-v4-2-b335d52a0570@linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Move the National Semiconductor LM63, LM64, and LM96163 compatibles out
of trivial-devices.yaml and into a dedicated binding. Describe their
integrated fan control and preserve the optional interrupt used by the
ALERT output. Permit use as thermal cooling devices via #cooling-cells.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.dev>
---
.../devicetree/bindings/hwmon/national,lm63.yaml | 53 ++++++++++++++++++++++
.../devicetree/bindings/trivial-devices.yaml | 6 ---
2 files changed, 53 insertions(+), 6 deletions(-)
diff --git a/Documentation/devicetree/bindings/hwmon/national,lm63.yaml b/Documentation/devicetree/bindings/hwmon/national,lm63.yaml
new file mode 100644
index 000000000000..f2e0993cfbef
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/national,lm63.yaml
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/national,lm63.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LM63-compatible temperature sensors with integrated fan control
+
+maintainers:
+ - Guenter Roeck <linux@roeck-us.net>
+
+description: |
+ The LM63 family provides local and remote temperature monitoring together
+ with fan speed monitoring and PWM fan control. Supported devices include
+ the National Semiconductor LM63, LM64 and LM96163.
+
+allOf:
+ - $ref: hwmon-common.yaml#
+
+properties:
+ compatible:
+ enum:
+ - national,lm63
+ - national,lm64
+ - national,lm96163
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ "#cooling-cells":
+ const: 2
+
+required:
+ - compatible
+ - reg
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ temperature-sensor@4c {
+ compatible = "national,lm63";
+ reg = <0x4c>;
+ #cooling-cells = <2>;
+ };
+ };
diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
index 2de8eb09cb7d..e46912ba2fd6 100644
--- a/Documentation/devicetree/bindings/trivial-devices.yaml
+++ b/Documentation/devicetree/bindings/trivial-devices.yaml
@@ -368,16 +368,10 @@ properties:
- mps,mpq82d00
# Murata D1U74T-W power supply unit
- murata,d1u74t
- # Temperature sensor with integrated fan control
- - national,lm63
- # Temperature sensor with integrated fan control
- - national,lm64
# Temperature sensor
- national,lm95235
# Temperature sensor
- national,lm95245
- # Temperature sensor with integrated fan control
- - national,lm96163
# Serial Interface ACPI-Compatible Microprocessor System Hardware Monitor
- national,lm80
# Serial Interface ACPI-Compatible Microprocessor System Hardware Monitor
--
2.55.0
@@ -0,0 +1,50 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 3/6] dt-bindings: hwmon: Add Sensylink CTF2301
From: Troy Mitchell <troy.mitchell@linux.dev>
Date: Mon, 31 Aug 2026 21:45:37 +0800
Message-Id: <20260831-ctl2301-v4-3-b335d52a0570@linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Add the Sensylink CTF2301 temperature sensor and fan controller to the
LM63 family binding. The chip follows the LM63 register model and can
provide a thermal cooling device when #cooling-cells is present.
Do not provide a national,lm63 fallback because the CTF2301 is not fully
compatible with LM63. It uses different conversion-rate encodings,
extended local-temperature registers, additional fan lookup table
entries, and device-specific PWM and ALERT/TACH configuration. An older
LM63 driver would therefore not operate the device correctly.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.dev>
---
Documentation/devicetree/bindings/hwmon/national,lm63.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/hwmon/national,lm63.yaml b/Documentation/devicetree/bindings/hwmon/national,lm63.yaml
index f2e0993cfbef..4c8d0a15fbd1 100644
--- a/Documentation/devicetree/bindings/hwmon/national,lm63.yaml
+++ b/Documentation/devicetree/bindings/hwmon/national,lm63.yaml
@@ -12,7 +12,8 @@ maintainers:
description: |
The LM63 family provides local and remote temperature monitoring together
with fan speed monitoring and PWM fan control. Supported devices include
- the National Semiconductor LM63, LM64 and LM96163.
+ the National Semiconductor LM63, LM64 and LM96163, and the Sensylink
+ CTF2301.
allOf:
- $ref: hwmon-common.yaml#
@@ -23,6 +24,7 @@ properties:
- national,lm63
- national,lm64
- national,lm96163
+ - sensylink,ctf2301
reg:
maxItems: 1
--
2.55.0
@@ -0,0 +1,804 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 4/6] hwmon: (lm63) Add Sensylink CTF2301 support
From: Troy Mitchell <troy.mitchell@linux.dev>
Date: Mon, 31 Aug 2026 21:45:38 +0800
Message-Id: <20260831-ctl2301-v4-4-b335d52a0570@linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Add Sensylink CTF2301 support to the LM63 driver. CTF2301 follows
the LM63-style temperature, tachometer, and PWM register layout,
while using a 12-bit local temperature register and requiring the
ALERT/TACH pin to be configured for tachometer input.
Register an optional thermal cooling device when the device tree
node provides #cooling-cells, allowing thermal zones to control
the fan through the existing PWM path without changing behavior
for existing LM63-family users.
Signed-off-by: Troy Mitchell <troy.mitchell@linux.dev>
---
Documentation/hwmon/lm63.rst | 22 +++
drivers/hwmon/Kconfig | 8 +-
drivers/hwmon/lm63.c | 426 +++++++++++++++++++++++++++++++++++--------
3 files changed, 377 insertions(+), 79 deletions(-)
diff --git a/Documentation/hwmon/lm63.rst b/Documentation/hwmon/lm63.rst
index 9e27367d7405..c40bd0dfe591 100644
--- a/Documentation/hwmon/lm63.rst
+++ b/Documentation/hwmon/lm63.rst
@@ -33,6 +33,16 @@ Supported chips:
http://www.national.com/pf/LM/LM96163.html
+ * Sensylink CTF2301
+
+ Prefix: 'ctf2301'
+
+ Addresses scanned: none
+
+ Datasheet: https://www.sensylink.com/upload/1/net.sensylink.portal/1689557281035.pdf
+
+ Register description: https://github.com/TroyMitchell911/ctf2301-datasheet
+
Author: Jean Delvare <jdelvare@suse.de>
@@ -62,6 +72,8 @@ value have to be masked out. The value is still 16 bit in width.
All temperature values are given in degrees Celsius. Resolution is 1.0
degree for the local temperature, 0.125 degree for the remote temperature.
+The CTF2301 local temperature input and limit have a resolution of 0.0625
+degree.
The fan speed is measured using a tachometer. Contrary to most chips which
store the value in an 8-bit register and have a selectable clock divider
@@ -93,3 +105,13 @@ support these GPIO lines at present.
The LM96163 is an enhanced version of LM63 with improved temperature accuracy
and better PWM resolution. For LM96163, the external temperature sensor type is
configurable as CPU embedded diode(1) or 3904 transistor(2).
+
+The CTF2301 is register-compatible with the LM63 family and provides 12 fan
+control lookup table entries. It supports 8-bit PWM resolution when configured
+for a 22.5 kHz PWM frequency.
+
+Device tree nodes may declare ``#cooling-cells`` to register the fan controller
+with the thermal framework. The cooling state is mapped to the existing
+``pwm1`` range from 0 to 255. The driver keeps the current automatic or manual
+fan control mode during probe and switches to manual control when the thermal
+framework first requests a cooling state.
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index fecff8610ea8..5d87ad3e7a20 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1521,10 +1521,10 @@ config SENSORS_LM63
depends on I2C
help
If you say yes here you get support for the National
- Semiconductor LM63, LM64, and LM96163 remote diode digital temperature
- sensors with integrated fan control. Such chips are found
- on the Tyan S4882 (Thunder K8QS Pro) motherboard, among
- others.
+ Semiconductor LM63, LM64, LM96163, and Sensylink CTF2301
+ remote diode digital temperature sensors with integrated fan
+ control. Such chips are found on the Tyan S4882 (Thunder K8QS
+ Pro) motherboard, among others.
This driver can also be built as a module. If so, the module
will be called lm63.
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index da09770c05e7..5a94895242ed 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -35,13 +35,14 @@
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/sysfs.h>
+#include <linux/thermal.h>
#include <linux/types.h>
/*
* Addresses to scan
* Address is fully defined internally and cannot be changed except for
* LM64 which has one pin dedicated to address selection.
- * LM63 and LM96163 have address 0x4c.
+ * LM63, LM96163, and CTF2301 have address 0x4c.
* LM64 can have address 0x18 or 0x4e.
*/
@@ -70,6 +71,9 @@ static const unsigned short normal_i2c[] = { 0x18, 0x4c, 0x4e, I2C_CLIENT_END };
#define LM63_REG_LOCAL_TEMP 0x00
#define LM63_REG_LOCAL_HIGH 0x05
+#define CTF2301_REG_LOCAL_TEMP_LSB 0x15
+#define CTF2301_REG_LOCAL_HIGH_LSB 0x06
+
#define LM63_REG_REMOTE_TEMP_MSB 0x01
#define LM63_REG_REMOTE_TEMP_LSB 0x10
#define LM63_REG_REMOTE_OFFSET_MSB 0x11
@@ -94,6 +98,7 @@ static const unsigned short normal_i2c[] = { 0x18, 0x4c, 0x4e, I2C_CLIENT_END };
#define LM63_PWM_BASE_FAST_HZ 180000
#define LM63_PWM_BASE_SLOW_HZ 700
+#define LM63_MAX_PWM 255
#define LM63_MAX_CONVRATE 9
@@ -121,6 +126,9 @@ static const unsigned short normal_i2c[] = { 0x18, 0x4c, 0x4e, I2C_CLIENT_END };
127000), 1000)
#define TEMP8U_TO_REG(val) DIV_ROUND_CLOSEST(clamp_val((val), 0, \
255000), 1000)
+#define TEMP12_FROM_REG(reg) DIV_ROUND_CLOSEST((s16)(reg) * 1000, 256)
+#define TEMP12_TO_REG(val) DIV_ROUND_CLOSEST(clamp_val((val), -128000, \
+ 127937) * 256, 1000)
#define TEMP11_FROM_REG(reg) ((reg) / 32 * 125)
#define TEMP11_TO_REG(val) (DIV_ROUND_CLOSEST(clamp_val((val), -128000, \
127875), 125) * 32)
@@ -132,7 +140,11 @@ static const unsigned short normal_i2c[] = { 0x18, 0x4c, 0x4e, I2C_CLIENT_END };
#define UPDATE_INTERVAL(max, rate) \
((1000 << (LM63_MAX_CONVRATE - (rate))) / (max))
-enum chips { lm63, lm64, lm96163 };
+enum chips { ctf2301, lm63, lm64, lm96163 };
+
+static const unsigned int ctf2301_update_intervals[] = {
+ 20000, 10000, 4902, 2463, 1000, 615, 307, 154, 107
+};
/*
* Client data (each client gets its own)
@@ -164,6 +176,8 @@ struct lm63_data {
1: local high limit
2: remote critical limit
3-14: lookup table */
+ s16 temp1_input; /* local input for chips with extended resolution */
+ s16 temp1_max; /* local limit for chips with extended resolution */
s16 temp11[4]; /* 0: remote input
1: remote low limit
2: remote high limit
@@ -229,6 +243,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
struct lm63_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
unsigned long next_update;
+ int msb, lsb;
mutex_lock(&data->update_lock);
@@ -253,10 +268,26 @@ static struct lm63_data *lm63_update_device(struct device *dev)
data->pwm1[0] = i2c_smbus_read_byte_data(client,
LM63_REG_PWM_VALUE);
- data->temp8[0] = i2c_smbus_read_byte_data(client,
- LM63_REG_LOCAL_TEMP);
- data->temp8[1] = i2c_smbus_read_byte_data(client,
- LM63_REG_LOCAL_HIGH);
+ if (data->kind == ctf2301) {
+ msb = i2c_smbus_read_byte_data(client,
+ LM63_REG_LOCAL_TEMP);
+ lsb = i2c_smbus_read_byte_data(client,
+ CTF2301_REG_LOCAL_TEMP_LSB);
+ if (msb >= 0 && lsb >= 0)
+ data->temp1_input = ((u16)(u8)msb << 8) | lsb;
+
+ msb = i2c_smbus_read_byte_data(client,
+ LM63_REG_LOCAL_HIGH);
+ lsb = i2c_smbus_read_byte_data(client,
+ CTF2301_REG_LOCAL_HIGH_LSB);
+ if (msb >= 0 && lsb >= 0)
+ data->temp1_max = ((u16)(u8)msb << 8) | lsb;
+ } else {
+ data->temp8[0] = i2c_smbus_read_byte_data(client,
+ LM63_REG_LOCAL_TEMP);
+ data->temp8[1] = i2c_smbus_read_byte_data(client,
+ LM63_REG_LOCAL_HIGH);
+ }
/* order matters for temp2_input */
data->temp11[0] = i2c_smbus_read_byte_data(client,
@@ -276,7 +307,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
| i2c_smbus_read_byte_data(client,
LM63_REG_REMOTE_OFFSET_LSB);
- if (data->kind == lm96163)
+ if (data->kind == lm96163 || data->kind == ctf2301)
data->temp11u = (i2c_smbus_read_byte_data(client,
LM96163_REG_REMOTE_TEMP_U_MSB) << 8)
| i2c_smbus_read_byte_data(client,
@@ -366,6 +397,49 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy,
return count;
}
+static int lm63_pwm_from_reg(struct lm63_data *data, u8 reg)
+{
+ if (data->pwm_highres)
+ return reg;
+
+ return reg >= 2 * data->pwm1_freq ?
+ LM63_MAX_PWM :
+ (reg * LM63_MAX_PWM + data->pwm1_freq) / (2 * data->pwm1_freq);
+}
+
+static u8 lm63_pwm_to_reg(struct lm63_data *data, unsigned long val)
+{
+ val = clamp_val(val, 0, LM63_MAX_PWM);
+
+ if (data->pwm_highres)
+ return val;
+
+ return (val * data->pwm1_freq * 2 + LM63_MAX_PWM / 2) / LM63_MAX_PWM;
+}
+
+static void lm63_update_pwm_highres(struct lm63_data *data,
+ int config_enhanced)
+{
+ data->pwm_highres = !(data->config_fan & 0x08) &&
+ data->pwm1_freq == 8 &&
+ (config_enhanced & 0x10);
+}
+
+static int lm63_write_pwm(struct lm63_data *data, int nr, unsigned long val)
+{
+ struct i2c_client *client = data->client;
+ u8 reg = nr ? LM63_REG_LUT_PWM(nr - 1) : LM63_REG_PWM_VALUE;
+ u8 regval = lm63_pwm_to_reg(data, val);
+ int ret;
+
+ ret = i2c_smbus_write_byte_data(client, reg, regval);
+ if (ret)
+ return ret;
+ data->pwm1[nr] = regval;
+
+ return 0;
+}
+
static ssize_t show_pwm1(struct device *dev, struct device_attribute *devattr,
char *buf)
{
@@ -375,12 +449,7 @@ static ssize_t show_pwm1(struct device *dev, struct device_attribute *devattr,
int pwm;
mutex_lock(&data->update_lock);
- if (data->pwm_highres)
- pwm = data->pwm1[nr];
- else
- pwm = data->pwm1[nr] >= 2 * data->pwm1_freq ?
- 255 : (data->pwm1[nr] * 255 + data->pwm1_freq) /
- (2 * data->pwm1_freq);
+ pwm = lm63_pwm_from_reg(data, data->pwm1[nr]);
mutex_unlock(&data->update_lock);
return sprintf(buf, "%d\n", pwm);
@@ -391,11 +460,9 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *devattr,
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct lm63_data *data = dev_get_drvdata(dev);
- struct i2c_client *client = data->client;
int nr = attr->index;
unsigned long val;
int err;
- u8 reg;
if (!(data->config_fan & 0x20)) /* register is read-only */
return -EPERM;
@@ -404,15 +471,11 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *devattr,
if (err)
return err;
- reg = nr ? LM63_REG_LUT_PWM(nr - 1) : LM63_REG_PWM_VALUE;
- val = clamp_val(val, 0, 255);
-
mutex_lock(&data->update_lock);
- data->pwm1[nr] = data->pwm_highres ? val :
- (val * data->pwm1_freq * 2 + 127) / 255;
- i2c_smbus_write_byte_data(client, reg, data->pwm1[nr]);
+ err = lm63_write_pwm(data, nr, val);
mutex_unlock(&data->update_lock);
- return count;
+
+ return err ? err : count;
}
static ssize_t pwm1_enable_show(struct device *dev,
@@ -485,7 +548,9 @@ static ssize_t pwm1_freq_store(struct device *dev,
struct lm63_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
unsigned long val, pfr_fast, pfr_slow, err_fast, err_slow, pfr;
+ u8 config_fan;
bool slow_clock;
+ int config_enhanced = 0;
int ret;
ret = kstrtoul(buf, 10, &val);
@@ -511,35 +576,58 @@ static ssize_t pwm1_freq_store(struct device *dev,
mutex_lock(&data->update_lock);
ret = i2c_smbus_read_byte_data(client, LM63_REG_CONFIG_FAN);
- if (ret < 0) {
- mutex_unlock(&data->update_lock);
- return ret;
- }
- data->config_fan = ret;
+ if (ret < 0)
+ goto unlock;
+ config_fan = ret;
+ data->config_fan = config_fan;
- if (!(data->config_fan & 0x20)) { /* register is read-only */
- mutex_unlock(&data->update_lock);
- return -EPERM;
+ if (!(config_fan & 0x20)) { /* register is read-only */
+ ret = -EPERM;
+ goto unlock;
}
- if (data->kind == lm96163) {
- ret = i2c_smbus_read_byte_data(client, LM96163_REG_CONFIG_ENHANCED);
- if (ret < 0) {
- mutex_unlock(&data->update_lock);
- return ret;
+ if (data->kind == lm96163 || data->kind == ctf2301) {
+ ret = i2c_smbus_read_byte_data(client,
+ LM96163_REG_CONFIG_ENHANCED);
+ if (ret < 0)
+ goto unlock;
+ config_enhanced = ret;
+ lm63_update_pwm_highres(data, config_enhanced);
+
+ if (data->kind == ctf2301) {
+ if (!slow_clock && pfr == 8)
+ config_enhanced |= 0x10;
+ else
+ config_enhanced &= ~0x10;
+ ret = i2c_smbus_write_byte_data(client,
+ LM96163_REG_CONFIG_ENHANCED,
+ config_enhanced);
+ if (ret)
+ goto unlock;
+ lm63_update_pwm_highres(data, config_enhanced);
}
- data->pwm_highres = !slow_clock && pfr == 8 && (ret & 0x10);
}
if (slow_clock)
- data->config_fan |= 0x08;
+ config_fan |= 0x08;
else
- data->config_fan &= ~0x08;
- i2c_smbus_write_byte_data(client, LM63_REG_CONFIG_FAN, data->config_fan);
- i2c_smbus_write_byte_data(client, LM63_REG_PWM_FREQ, pfr);
+ config_fan &= ~0x08;
+ ret = i2c_smbus_write_byte_data(client, LM63_REG_PWM_FREQ, pfr);
+ if (ret)
+ goto unlock;
data->pwm1_freq = pfr;
+ lm63_update_pwm_highres(data, config_enhanced);
+ ret = i2c_smbus_write_byte_data(client, LM63_REG_CONFIG_FAN,
+ config_fan);
+ if (ret)
+ goto unlock;
+
+ data->config_fan = config_fan;
+ lm63_update_pwm_highres(data, config_enhanced);
+unlock:
mutex_unlock(&data->update_lock);
- return count;
+
+ return ret ? ret : count;
}
/*
@@ -554,7 +642,17 @@ static ssize_t show_local_temp8(struct device *dev,
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct lm63_data *data = lm63_update_device(dev);
- return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index]));
+ int temp;
+
+ mutex_lock(&data->update_lock);
+ if (data->kind == ctf2301)
+ temp = TEMP12_FROM_REG(attr->index ? data->temp1_max :
+ data->temp1_input);
+ else
+ temp = TEMP8_FROM_REG(data->temp8[attr->index]);
+ mutex_unlock(&data->update_lock);
+
+ return sprintf(buf, "%d\n", temp);
}
static ssize_t show_remote_temp8(struct device *dev,
@@ -594,6 +692,21 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
return err;
mutex_lock(&data->update_lock);
+ if (data->kind == ctf2301 && nr == 1) {
+ temp = TEMP12_TO_REG(val);
+ err = i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH,
+ temp >> 8);
+ if (!err)
+ err = i2c_smbus_write_byte_data(client,
+ CTF2301_REG_LOCAL_HIGH_LSB,
+ temp & 0xf0);
+ if (!err)
+ data->temp1_max = temp;
+ mutex_unlock(&data->update_lock);
+
+ return err ? err : count;
+ }
+
switch (nr) {
case 2:
reg = LM63_REG_REMOTE_TCRIT;
@@ -610,10 +723,12 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
reg = LM63_REG_LUT_TEMP(nr - 3);
temp = lut_temp_to_reg(data, val);
}
- data->temp8[nr] = temp;
- i2c_smbus_write_byte_data(client, reg, temp);
+ err = i2c_smbus_write_byte_data(client, reg, temp);
+ if (!err)
+ data->temp8[nr] = temp;
mutex_unlock(&data->update_lock);
- return count;
+
+ return err ? err : count;
}
static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
@@ -787,11 +902,40 @@ static ssize_t temp2_crit_hyst_store(struct device *dev,
* Set conversion rate.
* client->update_lock must be held when calling this function.
*/
-static void lm63_set_convrate(struct lm63_data *data, unsigned int interval)
+static unsigned int lm63_update_interval(struct lm63_data *data, u8 rate)
+{
+ if (data->kind == ctf2301)
+ return ctf2301_update_intervals[min_t(unsigned int, rate,
+ ARRAY_SIZE(ctf2301_update_intervals) - 1)];
+
+ return UPDATE_INTERVAL(data->max_convrate_hz, rate);
+}
+
+static int lm63_set_convrate(struct lm63_data *data, unsigned int interval)
{
struct i2c_client *client = data->client;
- unsigned int update_interval;
- int i;
+ unsigned int update_interval, error, best_error = ~0U;
+ unsigned int best = 0;
+ unsigned int i;
+ int ret;
+
+ if (data->kind == ctf2301) {
+ for (i = 0; i < ARRAY_SIZE(ctf2301_update_intervals); i++) {
+ error = abs_diff(interval, ctf2301_update_intervals[i]);
+ if (error < best_error) {
+ best_error = error;
+ best = i;
+ }
+ }
+
+ ret = i2c_smbus_write_byte_data(client, LM63_REG_CONVRATE,
+ best);
+ if (ret)
+ return ret;
+ data->update_interval = ctf2301_update_intervals[best];
+
+ return 0;
+ }
/* Shift calculations to avoid rounding errors */
interval <<= 6;
@@ -803,8 +947,12 @@ static void lm63_set_convrate(struct lm63_data *data, unsigned int interval)
if (interval >= update_interval * 3 / 4)
break;
- i2c_smbus_write_byte_data(client, LM63_REG_CONVRATE, i);
+ ret = i2c_smbus_write_byte_data(client, LM63_REG_CONVRATE, i);
+ if (ret)
+ return ret;
data->update_interval = UPDATE_INTERVAL(data->max_convrate_hz, i);
+
+ return 0;
}
static ssize_t update_interval_show(struct device *dev,
@@ -828,10 +976,10 @@ static ssize_t update_interval_store(struct device *dev,
return err;
mutex_lock(&data->update_lock);
- lm63_set_convrate(data, clamp_val(val, 0, 100000));
+ err = lm63_set_convrate(data, clamp_val(val, 0, 100000));
mutex_unlock(&data->update_lock);
- return count;
+ return err ? err : count;
}
static ssize_t temp2_type_show(struct device *dev,
@@ -996,6 +1144,75 @@ static DEVICE_ATTR_RO(alarms);
static DEVICE_ATTR_RW(update_interval);
+static int lm63_get_max_state(struct thermal_cooling_device *cdev,
+ unsigned long *state)
+{
+ *state = LM63_MAX_PWM;
+
+ return 0;
+}
+
+static int lm63_get_cur_state(struct thermal_cooling_device *cdev,
+ unsigned long *state)
+{
+ struct lm63_data *data = cdev->devdata;
+ int ret;
+
+ mutex_lock(&data->update_lock);
+ ret = i2c_smbus_read_byte_data(data->client, LM63_REG_PWM_VALUE);
+ if (ret < 0)
+ goto unlock;
+
+ data->pwm1[0] = ret;
+ *state = lm63_pwm_from_reg(data, data->pwm1[0]);
+unlock:
+ mutex_unlock(&data->update_lock);
+
+ return ret < 0 ? ret : 0;
+}
+
+static int lm63_set_cur_state(struct thermal_cooling_device *cdev,
+ unsigned long state)
+{
+ struct lm63_data *data = cdev->devdata;
+ int config_fan;
+ int ret;
+
+ if (state > LM63_MAX_PWM)
+ return -EINVAL;
+
+ mutex_lock(&data->update_lock);
+ config_fan = i2c_smbus_read_byte_data(data->client,
+ LM63_REG_CONFIG_FAN);
+ if (config_fan < 0) {
+ ret = config_fan;
+ goto unlock;
+ }
+ data->config_fan = config_fan;
+
+ if (!(config_fan & 0x20)) {
+ config_fan |= 0x20;
+ ret = i2c_smbus_write_byte_data(data->client,
+ LM63_REG_CONFIG_FAN,
+ config_fan);
+ if (ret)
+ goto unlock;
+ data->config_fan = config_fan;
+ }
+
+ ret = lm63_write_pwm(data, 0, state);
+unlock:
+ mutex_unlock(&data->update_lock);
+
+ return ret;
+}
+
+static const struct thermal_cooling_device_ops lm63_cooling_ops = {
+ .get_max_state = lm63_get_max_state,
+ .get_cur_state = lm63_get_cur_state,
+ .set_cur_state = lm63_set_cur_state,
+};
+
static struct attribute *lm63_attributes[] = {
&sensor_dev_attr_pwm1.dev_attr.attr,
&dev_attr_pwm1_enable.attr,
@@ -1078,8 +1295,8 @@ static const struct attribute_group lm63_group_extra_lut = {
* On LM63, temp2_crit can be set only once, which should be job
* of the bootloader.
* On LM64, temp2_crit can always be set.
- * On LM96163, temp2_crit can be set if bit 1 of the configuration
- * register is true.
+ * On LM96163 and CTF2301, temp2_crit can be set if bit 1 of the
+ * configuration register is true.
*/
static umode_t lm63_attribute_mode(struct kobject *kobj,
struct attribute *attr, int index)
@@ -1089,7 +1306,8 @@ static umode_t lm63_attribute_mode(struct kobject *kobj,
if (attr == &sensor_dev_attr_temp2_crit.dev_attr.attr
&& (data->kind == lm64 ||
- (data->kind == lm96163 && (data->config & 0x02))))
+ ((data->kind == lm96163 || data->kind == ctf2301) &&
+ (data->config & 0x02))))
return attr->mode | S_IWUSR;
return attr->mode;
@@ -1164,29 +1382,48 @@ static int lm63_detect(struct i2c_client *client,
* Ideally we shouldn't have to initialize anything, since the BIOS
* should have taken care of everything
*/
-static void lm63_init_client(struct lm63_data *data)
+static int lm63_init_client(struct lm63_data *data)
{
struct i2c_client *client = data->client;
struct device *dev = &client->dev;
u8 convrate;
+ int ret;
- data->config = i2c_smbus_read_byte_data(client, LM63_REG_CONFIG1);
- data->config_fan = i2c_smbus_read_byte_data(client,
- LM63_REG_CONFIG_FAN);
+ ret = i2c_smbus_read_byte_data(client, LM63_REG_CONFIG1);
+ if (ret < 0)
+ return ret;
+ data->config = ret;
+ ret = i2c_smbus_read_byte_data(client, LM63_REG_CONFIG_FAN);
+ if (ret < 0)
+ return ret;
+ data->config_fan = ret;
/* Start converting if needed */
if (data->config & 0x40) { /* standby */
dev_dbg(dev, "Switching to operational mode\n");
data->config &= 0xA7;
- i2c_smbus_write_byte_data(client, LM63_REG_CONFIG1,
- data->config);
+ ret = i2c_smbus_write_byte_data(client, LM63_REG_CONFIG1,
+ data->config);
+ if (ret)
+ return ret;
}
/* Tachometer is always enabled on LM64 */
if (data->kind == lm64)
data->config |= 0x04;
+ if (data->kind == ctf2301 && !client->irq && !(data->config & 0x04)) {
+ dev_dbg(dev, "Configuring ALERT/TACH pin for tachometer input\n");
+ data->config |= 0x04;
+ ret = i2c_smbus_write_byte_data(client, LM63_REG_CONFIG1,
+ data->config);
+ if (ret)
+ return ret;
+ }
/* We may need pwm1_freq before ever updating the client data */
- data->pwm1_freq = i2c_smbus_read_byte_data(client, LM63_REG_PWM_FREQ) & 0x1f;
+ ret = i2c_smbus_read_byte_data(client, LM63_REG_PWM_FREQ);
+ if (ret < 0)
+ return ret;
+ data->pwm1_freq = ret & 0x1f;
if (data->pwm1_freq == 0)
data->pwm1_freq = 1;
@@ -1199,25 +1436,38 @@ static void lm63_init_client(struct lm63_data *data)
case lm96163:
data->max_convrate_hz = LM96163_MAX_CONVRATE_HZ;
data->lut_size = 12;
- data->trutherm
- = i2c_smbus_read_byte_data(client,
- LM96163_REG_TRUTHERM) & 0x02;
+ ret = i2c_smbus_read_byte_data(client, LM96163_REG_TRUTHERM);
+ if (ret < 0)
+ return ret;
+ data->trutherm = ret & 0x02;
+ break;
+ case ctf2301:
+ data->lut_size = 12;
break;
}
- convrate = i2c_smbus_read_byte_data(client, LM63_REG_CONVRATE);
- if (unlikely(convrate > LM63_MAX_CONVRATE))
+ ret = i2c_smbus_read_byte_data(client, LM63_REG_CONVRATE);
+ if (ret < 0)
+ return ret;
+ convrate = ret;
+ if (data->kind == ctf2301 &&
+ convrate >= ARRAY_SIZE(ctf2301_update_intervals))
+ convrate = ARRAY_SIZE(ctf2301_update_intervals) - 1;
+ else if (unlikely(convrate > LM63_MAX_CONVRATE))
convrate = LM63_MAX_CONVRATE;
- data->update_interval = UPDATE_INTERVAL(data->max_convrate_hz,
- convrate);
+ data->update_interval = lm63_update_interval(data, convrate);
/*
- * For LM96163, check if high resolution PWM
+ * For LM96163 and CTF2301, check if high resolution PWM
* and unsigned temperature format is enabled.
*/
- if (data->kind == lm96163) {
- u8 config_enhanced
- = i2c_smbus_read_byte_data(client,
- LM96163_REG_CONFIG_ENHANCED);
+ if (data->kind == lm96163 || data->kind == ctf2301) {
+ u8 config_enhanced;
+
+ ret = i2c_smbus_read_byte_data(client,
+ LM96163_REG_CONFIG_ENHANCED);
+ if (ret < 0)
+ return ret;
+ config_enhanced = ret;
if (config_enhanced & 0x20)
data->lut_temp_highres = true;
if ((config_enhanced & 0x10)
@@ -1238,6 +1488,8 @@ static void lm63_init_client(struct lm63_data *data)
dev_dbg(dev, "PWM output active %s, %s mode\n",
(data->config_fan & 0x10) ? "low" : "high",
(data->config_fan & 0x20) ? "manual" : "auto");
+
+ return 0;
}
static const struct i2c_device_id lm63_id[];
@@ -1245,9 +1497,11 @@ static const struct i2c_device_id lm63_id[];
static int lm63_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
+ struct thermal_cooling_device *cdev;
struct device *hwmon_dev;
struct lm63_data *data;
int groups = 0;
+ int ret;
data = devm_kzalloc(dev, sizeof(struct lm63_data), GFP_KERNEL);
if (!data)
@@ -1262,7 +1516,9 @@ static int lm63_probe(struct i2c_client *client)
data->temp2_offset = 16000;
/* Initialize chip */
- lm63_init_client(data);
+ ret = lm63_init_client(data);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to initialize device\n");
/* Register sysfs hooks */
data->groups[groups++] = &lm63_group;
@@ -1272,11 +1528,26 @@ static int lm63_probe(struct i2c_client *client)
if (data->kind == lm96163) {
data->groups[groups++] = &lm63_group_temp2_type;
data->groups[groups++] = &lm63_group_extra_lut;
+ } else if (data->kind == ctf2301) {
+ data->groups[groups++] = &lm63_group_extra_lut;
}
hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
data, data->groups);
- return PTR_ERR_OR_ZERO(hwmon_dev);
+ if (IS_ERR(hwmon_dev))
+ return PTR_ERR(hwmon_dev);
+
+ if (IS_ENABLED(CONFIG_THERMAL_OF) &&
+ of_property_present(dev->of_node, "#cooling-cells")) {
+ cdev = devm_thermal_of_cooling_device_register(dev, 0,
+ client->name,
+ data,
+ &lm63_cooling_ops);
+ if (IS_ERR(cdev))
+ return PTR_ERR(cdev);
+ }
+
+ return 0;
}
/*
@@ -1287,6 +1558,7 @@ static const struct i2c_device_id lm63_id[] = {
{ .name = "lm63", .driver_data = lm63 },
{ .name = "lm64", .driver_data = lm64 },
{ .name = "lm96163", .driver_data = lm96163 },
+ { .name = "ctf2301", .driver_data = ctf2301 },
{ }
};
MODULE_DEVICE_TABLE(i2c, lm63_id);
@@ -1304,6 +1576,10 @@ static const struct of_device_id __maybe_unused lm63_of_match[] = {
.compatible = "national,lm96163",
.data = (void *)lm96163
},
+ {
+ .compatible = "sensylink,ctf2301",
+ .data = (void *)ctf2301
+ },
{ },
};
MODULE_DEVICE_TABLE(of, lm63_of_match);
--
2.55.0
@@ -0,0 +1,44 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 5/6] riscv: dts: spacemit: Add K3 I2C6 pinctrl state
From: Troy Mitchell <troy.mitchell@linux.dev>
Date: Mon, 31 Aug 2026 21:45:39 +0800
Message-Id: <20260831-ctl2301-v4-5-b335d52a0570@linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Add the K3 I2C6 pinctrl state used by boards that route I2C6 to pads 7
and 8. Use a 25 mA drive strength, which is supported for both K3 IO
voltage domains, and leave board-specific IO voltage selection to board
files.
Signed-off-by: Troy Mitchell <troy.mitchell@linux.dev>
---
arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi b/arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi
index 6482d24be139..cb4f4f4e33af 100644
--- a/arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k3-pinctrl.dtsi
@@ -101,6 +101,17 @@ i2c2-1-pins {
};
};
+ /omit-if-no-ref/
+ i2c6_1_cfg: i2c6-1-cfg {
+ i2c6-1-pins {
+ pinmux = <K3_PADCONF(7, 6)>, /* i2c6 scl */
+ <K3_PADCONF(8, 6)>; /* i2c6 sda */
+
+ bias-pull-up = <0>;
+ drive-strength = <25>;
+ };
+ };
+
/omit-if-no-ref/
i2c8_cfg: i2c8-cfg {
i2c8-pins {
--
2.55.0
@@ -0,0 +1,52 @@
From git@z Thu Jan 1 00:00:00 1970
Subject: [PATCH v4 6/6] riscv: dts: spacemit: Add CTF2301 on K3 CoM260
From: Troy Mitchell <troy.mitchell@linux.dev>
Date: Mon, 31 Aug 2026 21:45:40 +0800
Message-Id: <20260831-ctl2301-v4-6-b335d52a0570@linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Enable I2C6 on the K3 CoM260 module and describe the Sensylink
CTF2301 temperature sensor and fan controller at address 0x4c.
Override the I2C6 pin power source at board level because the IO rail
voltage is board-specific.
Signed-off-by: Troy Mitchell <troy.mitchell@linux.dev>
---
arch/riscv/boot/dts/spacemit/k3-com260.dtsi | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/riscv/boot/dts/spacemit/k3-com260.dtsi b/arch/riscv/boot/dts/spacemit/k3-com260.dtsi
index 37627963a649..92dea8639779 100644
--- a/arch/riscv/boot/dts/spacemit/k3-com260.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k3-com260.dtsi
@@ -58,6 +58,23 @@ serial-number {
};
};
+&i2c6_1_cfg {
+ i2c6-1-pins {
+ power-source = <3300>;
+ };
+};
+
+&i2c6 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c6_1_cfg>;
+ status = "okay";
+
+ temperature-sensor@4c {
+ compatible = "sensylink,ctf2301";
+ reg = <0x4c>;
+ };
+};
+
&i2c8 {
pinctrl-names = "default";
pinctrl-0 = <&i2c8_cfg>;
--
2.55.0
@@ -0,0 +1,67 @@
From: liberodark <liberodark@gmail.com>
Subject: [PATCH] riscv: dts: spacemit: k3: wire the CoM260 fan to the thermal zones
The CTF2301 comes up in manual mode with a zero duty cycle and an
auto-temp lookup table still at its reset values, so the fan never spins
on its own. Register it as a thermal cooling device and let the CPU
cluster thermal zone drive it.
Signed-off-by: liberodark <liberodark@gmail.com>
---
--- a/arch/riscv/boot/dts/spacemit/k3-com260.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k3-com260.dtsi
@@ -69,9 +69,10 @@
pinctrl-0 = <&i2c6_1_cfg>;
status = "okay";
- temperature-sensor@4c {
+ fan: temperature-sensor@4c {
compatible = "sensylink,ctf2301";
reg = <0x4c>;
+ #cooling-cells = <2>;
};
};
@@ -237,3 +238,42 @@
pinctrl-0 = <&uart0_0_cfg>;
status = "okay";
};
+
+&{/thermal-zones/cluster-thermal} {
+ trips {
+ fan_low: fan-low {
+ temperature = <55000>;
+ hysteresis = <5000>;
+ type = "active";
+ };
+
+ fan_mid: fan-mid {
+ temperature = <65000>;
+ hysteresis = <5000>;
+ type = "active";
+ };
+
+ fan_high: fan-high {
+ temperature = <75000>;
+ hysteresis = <5000>;
+ type = "active";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&fan_low>;
+ cooling-device = <&fan 60 120>;
+ };
+
+ map1 {
+ trip = <&fan_mid>;
+ cooling-device = <&fan 120 190>;
+ };
+
+ map2 {
+ trip = <&fan_high>;
+ cooling-device = <&fan 190 255>;
+ };
+ };
+};
@@ -0,0 +1,70 @@
From: liberodark <liberodark@gmail.com>
Subject: [PATCH] riscv: dts: spacemit: k3: describe the CoM260 boot NOR flash
Same QSPI NOR and partition layout as the Pico-ITX, so the firmware
partitions show up as MTD devices and can be updated from Linux.
Signed-off-by: liberodark <liberodark@gmail.com>
---
--- a/arch/riscv/boot/dts/spacemit/k3-com260.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k3-com260.dtsi
@@ -277,3 +277,59 @@
};
};
};
+
+&qspi_cfg {
+ qspi-pins {
+ power-source = <1800>;
+ };
+
+ qspi-cs0-pins {
+ power-source = <1800>;
+ };
+};
+
+&qspi {
+ pinctrl-names = "default";
+ pinctrl-0 = <&qspi_cfg>;
+ status = "okay";
+
+ flash@0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <26500000>;
+ spi-rx-bus-width = <4>;
+ spi-tx-bus-width = <4>;
+ vcc-supply = <&aldo2>; /* PMIC_VCC1V8_QSPI */
+ m25p,fast-read;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ bootinfo@0 {
+ reg = <0x0 0x20000>;
+ };
+
+ fsbl@20000 {
+ reg = <0x20000 0x80000>;
+ };
+
+ env@a0000 {
+ reg = <0xa0000 0x10000>;
+ };
+
+ esos@b0000 {
+ reg = <0xb0000 0x100000>;
+ };
+
+ opensbi@1b0000 {
+ reg = <0x1b0000 0x60000>;
+ };
+
+ uboot@210000 {
+ reg = <0x210000 0x5f0000>;
+ };
+ };
+ };
+};