* [PATCH 1/4] dt-bindings: soc: actions: Add Actions Semi Owl socinfo binding
2021-03-19 18:27 [PATCH 0/4] Add support for Actions Semi Owl soc info Cristian Ciocaltea
@ 2021-03-19 18:27 ` Cristian Ciocaltea
2021-03-27 16:30 ` Rob Herring
2021-03-19 18:28 ` [PATCH 2/4] soc: actions: Add Actions Semi Owl socinfo driver Cristian Ciocaltea
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Cristian Ciocaltea @ 2021-03-19 18:27 UTC (permalink / raw)
To: Rob Herring, Andreas Färber, Manivannan Sadhasivam
Cc: devicetree, linux-arm-kernel, linux-actions, linux-kernel
Add devicetree binding for the Actions Semi Owl SoCs info module.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
---
.../bindings/soc/actions/owl-socinfo.yaml | 71 +++++++++++++++++++
1 file changed, 71 insertions(+)
create mode 100644 Documentation/devicetree/bindings/soc/actions/owl-socinfo.yaml
diff --git a/Documentation/devicetree/bindings/soc/actions/owl-socinfo.yaml b/Documentation/devicetree/bindings/soc/actions/owl-socinfo.yaml
new file mode 100644
index 000000000000..3fcb1f584fdf
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/actions/owl-socinfo.yaml
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/actions/owl-socinfo.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Actions Semi Owl SoC info module
+
+maintainers:
+ - Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
+
+description: |
+ Actions Semi Owl SoC info module provides access to various information
+ about the S500, S700 and S900 SoC variants, such as serial number or id.
+
+patternProperties:
+ "^soc(@[0-9a-f]+)?$":
+ type: object
+ properties:
+ compatible:
+ items:
+ - enum:
+ - actions,s500-soc
+ - actions,s700-soc
+ - actions,s900-soc
+ - const: simple-bus
+
+ "#address-cells":
+ enum: [1, 2]
+
+ "#size-cells":
+ enum: [1, 2]
+
+ ranges: true
+
+ actions,serial-number-addrs:
+ description: |
+ Contains the physical addresses in DDR memory where the two parts
+ of the serial number (low & high) can be read from.
+ This is currently supported only on the S500 SoC variant.
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ minItems: 2
+ maxItems: 2
+
+ required:
+ - compatible
+
+ additionalProperties:
+ type: object
+
+additionalProperties: true
+
+examples:
+ - |
+ / {
+ compatible = "roseapplepi,roseapplepi", "actions,s500";
+ model = "Roseapple Pi";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ soc {
+ compatible = "actions,s500-soc", "simple-bus";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+ actions,serial-number-addrs = <0x800>, /* S/N Low */
+ <0x804>; /* S/N High */
+ };
+ };
+
+...
--
2.31.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] soc: actions: Add Actions Semi Owl socinfo driver
2021-03-19 18:27 [PATCH 0/4] Add support for Actions Semi Owl soc info Cristian Ciocaltea
2021-03-19 18:27 ` [PATCH 1/4] dt-bindings: soc: actions: Add Actions Semi Owl socinfo binding Cristian Ciocaltea
@ 2021-03-19 18:28 ` Cristian Ciocaltea
2021-03-19 18:28 ` [PATCH 3/4] arm: dts: owl-s500: Add socinfo support Cristian Ciocaltea
2021-03-19 18:28 ` [PATCH 4/4] MAINTAINERS: Add entry for Actions Semi Owl socinfo binding Cristian Ciocaltea
3 siblings, 0 replies; 7+ messages in thread
From: Cristian Ciocaltea @ 2021-03-19 18:28 UTC (permalink / raw)
To: Rob Herring, Andreas Färber, Manivannan Sadhasivam
Cc: devicetree, linux-arm-kernel, linux-actions, linux-kernel
The driver provides information about the Action Semi Owl family of
SoCs (S500, S700 and S900) to user space via sysfs: machine, family,
soc_id, serial_number.
Note the serial number is currently provided only for the S500 SoC
variant.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
---
drivers/soc/actions/Kconfig | 8 ++
drivers/soc/actions/Makefile | 1 +
drivers/soc/actions/owl-socinfo.c | 133 ++++++++++++++++++++++++++++++
3 files changed, 142 insertions(+)
create mode 100644 drivers/soc/actions/owl-socinfo.c
diff --git a/drivers/soc/actions/Kconfig b/drivers/soc/actions/Kconfig
index 1aca2058a40c..15faade9282d 100644
--- a/drivers/soc/actions/Kconfig
+++ b/drivers/soc/actions/Kconfig
@@ -14,4 +14,12 @@ config OWL_PM_DOMAINS
power-gating on Actions Semiconductor S500, S700 and S900 SoCs.
If unsure, say 'n'.
+config OWL_SOCINFO
+ bool "Actions Semi Owl SoC info driver"
+ default ARCH_ACTIONS
+ select SOC_BUS
+ help
+ Say 'y' here to support the Action Semiconductor Owl socinfo
+ driver, providing information about the SoC to user space.
+
endif
diff --git a/drivers/soc/actions/Makefile b/drivers/soc/actions/Makefile
index 4db9e7b050e5..4b2591d3089f 100644
--- a/drivers/soc/actions/Makefile
+++ b/drivers/soc/actions/Makefile
@@ -2,3 +2,4 @@
obj-$(CONFIG_OWL_PM_DOMAINS_HELPER) += owl-sps-helper.o
obj-$(CONFIG_OWL_PM_DOMAINS) += owl-sps.o
+obj-$(CONFIG_OWL_SOCINFO) += owl-socinfo.o
diff --git a/drivers/soc/actions/owl-socinfo.c b/drivers/soc/actions/owl-socinfo.c
new file mode 100644
index 000000000000..2786c4fd261c
--- /dev/null
+++ b/drivers/soc/actions/owl-socinfo.c
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Actions Semi Owl SoC information driver
+ *
+ * Copyright (c) 2021 Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
+ */
+
+#include <linux/highmem.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/random.h>
+#include <linux/sys_soc.h>
+
+#include <asm/system_info.h>
+
+struct owl_soc_info {
+ char *name;
+ int (*get_system_serial)(struct device *dev);
+};
+
+static int __init owl_read_sn_from_mem(struct device *dev)
+{
+ int paddrs[2] = {0};
+ char *vaddr;
+ int ret;
+
+ ret = device_property_read_u32_array(dev,
+ "actions,serial-number-addrs",
+ paddrs, 2);
+ if (ret) {
+ dev_err(dev, "failed to read SoC S/N addresses: %d\n", ret);
+ return ret;
+ }
+
+ if (PHYS_PFN(paddrs[0]) != PHYS_PFN(paddrs[1])) {
+ dev_err(dev, "invalid SoC S/N addresses\n");
+ return -EINVAL;
+ }
+
+ vaddr = kmap_local_pfn(PHYS_PFN(paddrs[0]));
+
+ memcpy(&system_serial_low, vaddr + (paddrs[0] & (PAGE_SIZE - 1)),
+ sizeof(system_serial_low));
+ memcpy(&system_serial_high, vaddr + (paddrs[1] & (PAGE_SIZE - 1)),
+ sizeof(system_serial_high));
+
+ kunmap_local(vaddr);
+
+ return 0;
+}
+
+static int owl_socinfo_probe(struct platform_device *pdev)
+{
+ const struct owl_soc_info *soc_info;
+ struct soc_device_attribute *soc_dev_attr;
+ struct soc_device *soc_dev;
+ int ret;
+
+ soc_info = of_device_get_match_data(&pdev->dev);
+ if (!soc_info)
+ return -ENODEV;
+
+ soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr),
+ GFP_KERNEL);
+ if (!soc_dev_attr)
+ return -ENOMEM;
+
+ ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine);
+ if (ret)
+ return ret;
+
+ soc_dev_attr->family = "Actions Semi Owl";
+ soc_dev_attr->soc_id = soc_info->name;
+
+ if (soc_info->get_system_serial) {
+ ret = soc_info->get_system_serial(&pdev->dev);
+ if (!ret) {
+ soc_dev_attr->serial_number = devm_kasprintf(&pdev->dev,
+ GFP_KERNEL, "%08x%08x",
+ system_serial_high,
+ system_serial_low);
+ /* Feed the SoC unique data into entropy pool. */
+ add_device_randomness(soc_dev_attr->serial_number, 16);
+ }
+ }
+
+ soc_dev = soc_device_register(soc_dev_attr);
+ if (IS_ERR(soc_dev))
+ return dev_err_probe(&pdev->dev, PTR_ERR(soc_dev),
+ "failed to register soc device");
+
+ dev_info(soc_device_to_device(soc_dev),
+ "SoC: %s %s\n",
+ soc_dev_attr->family, soc_dev_attr->soc_id);
+
+ return 0;
+}
+
+static const struct owl_soc_info s500_soc_info = {
+ .name = "S500",
+ .get_system_serial = owl_read_sn_from_mem,
+};
+
+static const struct owl_soc_info s700_soc_info = {
+ .name = "S700",
+ /* FIXME: provide get_system_serial */
+};
+
+static const struct owl_soc_info s900_soc_info = {
+ .name = "S900",
+ /* FIXME: provide get_system_serial */
+};
+
+static const struct of_device_id owl_soc_of_match[] = {
+ { .compatible = "actions,s500-soc", .data = &s500_soc_info, },
+ { .compatible = "actions,s700-soc", .data = &s700_soc_info, },
+ { .compatible = "actions,s900-soc", .data = &s900_soc_info, },
+ { }
+};
+
+static struct platform_driver owl_socinfo_platform_driver = {
+ .probe = owl_socinfo_probe,
+ .driver = {
+ .name = "owl-socinfo",
+ .of_match_table = owl_soc_of_match,
+ },
+};
+
+static int __init owl_socinfo_init(void)
+{
+ return platform_driver_register(&owl_socinfo_platform_driver);
+}
+subsys_initcall(owl_socinfo_init);
--
2.31.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] arm: dts: owl-s500: Add socinfo support
2021-03-19 18:27 [PATCH 0/4] Add support for Actions Semi Owl soc info Cristian Ciocaltea
2021-03-19 18:27 ` [PATCH 1/4] dt-bindings: soc: actions: Add Actions Semi Owl socinfo binding Cristian Ciocaltea
2021-03-19 18:28 ` [PATCH 2/4] soc: actions: Add Actions Semi Owl socinfo driver Cristian Ciocaltea
@ 2021-03-19 18:28 ` Cristian Ciocaltea
2021-03-19 18:28 ` [PATCH 4/4] MAINTAINERS: Add entry for Actions Semi Owl socinfo binding Cristian Ciocaltea
3 siblings, 0 replies; 7+ messages in thread
From: Cristian Ciocaltea @ 2021-03-19 18:28 UTC (permalink / raw)
To: Rob Herring, Andreas Färber, Manivannan Sadhasivam
Cc: devicetree, linux-arm-kernel, linux-actions, linux-kernel
Update soc node compatible property to enable support for the Actions
Semi Owl soc info driver.
Additionally provide memory addresses where the serial number parts are
accessible.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
---
arch/arm/boot/dts/owl-s500.dtsi | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/owl-s500.dtsi b/arch/arm/boot/dts/owl-s500.dtsi
index 739b4b9cec8c..07a165918de9 100644
--- a/arch/arm/boot/dts/owl-s500.dtsi
+++ b/arch/arm/boot/dts/owl-s500.dtsi
@@ -80,10 +80,12 @@ losc: losc {
};
soc {
- compatible = "simple-bus";
+ compatible = "actions,s500-soc", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges;
+ actions,serial-number-addrs = <0x800>, /* S/N Low */
+ <0x804>; /* S/N High */
scu: scu@b0020000 {
compatible = "arm,cortex-a9-scu";
--
2.31.0
^ permalink raw reply related [flat|nested] 7+ messages in thread