Re: [PATCH 2/3] reset: Add Apple SoC CIO reset driver

"Joshua Peisach" <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.ports.arm.kernel,gmane.linux.drivers.devicetree
Message-ID <[email protected]>
On Sun Aug 9, 2026 at 8:16 AM EDT, Sven Peter wrote:
> Add a driver for the reset of the CIO (USB4/Thunderbolt) blocks on
> Apple Silicon SoCs which has to be deasserted before their
> co-processor can be booted. On t8103 each port comes with a dedicated
> register page while t600x uses a single register with one request bit
> per port shared by all ports of a die inside the PMGR MMIO region.
>
> Signed-off-by: Sven Peter <[email protected]>
> ---
>  MAINTAINERS                     |   1 +
>  drivers/reset/Kconfig           |  10 +++
>  drivers/reset/Makefile          |   1 +
>  drivers/reset/reset-apple-cio.c | 182 ++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 194 insertions(+)

> +
> +static int apple_cio_reset_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct apple_cio_reset *priv;
> +	int ret;
> +
> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	priv->variant = of_device_get_match_data(dev);

Might be a dumb question, but does priv->variant also need to be
checked? Because later priv->variant->pmgr_child is and I *think*
it could return NULL.

(Or is this not necessary since in theory the device should only run
this if detected... so this should never be an issue?)

> +
> +	ret = devm_mutex_init(dev, &priv->lock);
> +	if (ret)
> +		return ret;
> +
> +	if (priv->variant->pmgr_child) {
> +		priv->regmap = syscon_node_to_regmap(dev->of_node->parent);
> +		if (IS_ERR(priv->regmap))
> +			return dev_err_probe(dev, PTR_ERR(priv->regmap),
> +					     "Failed to get parent regmap");
> +
> +		ret = of_property_read_u32(dev->of_node, "reg", &priv->offset);
> +		if (ret)
> +			return dev_err_probe(dev, ret, "Failed to read reg offset");
> +	} else {
> +		void __iomem *base;
> +
> +		base = devm_platform_ioremap_resource(pdev, 0);
> +		if (IS_ERR(base))
> +			return PTR_ERR(base);
> +
> +		priv->regmap = devm_regmap_init_mmio(dev, base,
> +						     &apple_cio_reset_regmap_config);
> +		if (IS_ERR(priv->regmap))
> +			return dev_err_probe(dev, PTR_ERR(priv->regmap),
> +					     "Failed to init MMIO regmap");
> +	}
> +
> +	priv->rcdev.owner = THIS_MODULE;
> +	priv->rcdev.ops = &apple_cio_reset_ops;
> +	priv->rcdev.of_node = dev->of_node;
> +	priv->rcdev.nr_resets = priv->variant->nr_resets;
> +
> +	return devm_reset_controller_register(dev, &priv->rcdev);
> +}
> +
> +static const struct of_device_id apple_cio_reset_match[] = {
> +	{
> +		.compatible = "apple,t8103-cio-reset",
> +		.data = &apple_t8103_cio_reset,
> +	},
> +	{
> +		.compatible = "apple,t6000-cio-reset",
> +		.data = &apple_t6000_cio_reset,
> +	},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, apple_cio_reset_match);
> +
> +static struct platform_driver apple_cio_reset_driver = {
> +	.driver = {
> +		.name = "apple-cio-reset",
> +		.of_match_table = apple_cio_reset_match,
> +	},
> +	.probe = apple_cio_reset_probe,
> +};
> +module_platform_driver(apple_cio_reset_driver);
> +
> +MODULE_AUTHOR("Sven Peter <[email protected]>");
> +MODULE_DESCRIPTION("Apple SoC CIO block reset driver");
> +MODULE_LICENSE("Dual MIT/GPL");
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.