public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Maximilian Luz <luzmaximilian@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Konrad Dybcio <konradybcio@kernel.org>
Cc: "Rob Herring" <robh@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jiri Slaby" <jirislaby@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Len Brown" <lenb@kernel.org>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Marijn Suijten" <marijn.suijten@somainline.org>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-acpi@vger.kernel.org,
	platform-driver-x86@vger.kernel.org,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Konrad Dybcio" <quic_kdybcio@quicinc.com>
Subject: Re: [PATCH v3 3/3] platform/surface: Add OF support
Date: Wed, 28 Aug 2024 11:10:42 +0200	[thread overview]
Message-ID: <d08d41ad-edcb-48ad-a848-53edc45ab8eb@gmail.com> (raw)
In-Reply-To: <ZszrjQChQ2aS5YjV@surfacebook.localdomain>

Hi,

I thought I should provide some context:

Am 26/08/2024 um 22:54 schrieb Andy Shevchenko:
> Wed, Aug 14, 2024 at 12:27:27PM +0200, Konrad Dybcio kirjoitti:
>> From: Konrad Dybcio <quic_kdybcio@quicinc.com>

[...]

>> +	/*
>> +	 * When using DT, we have to register the platform hub driver manually,
>> +	 * as it can't be matched based on top-level board compatible (like it
>> +	 * does the ACPI case).
>> +	 */
>> +	if (!ssh) {
>> +		struct platform_device *ph_pdev =
>> +			platform_device_register_simple("surface_aggregator_platform_hub",
>> +							0, NULL, 0);
>> +		if (IS_ERR(ph_pdev))
>> +			return dev_err_probe(dev, PTR_ERR(ph_pdev),
>> +					     "Failed to register the platform hub driver\n"); 
>> +	}

[...]

>>   static int ssam_platform_hub_probe(struct platform_device *pdev)
>>   {
>>   	const struct software_node **nodes;
>> +	const struct of_device_id *match;
>> +	struct device_node *fdt_root;
>>   	struct ssam_controller *ctrl;
>>   	struct fwnode_handle *root;
>>   	int status;
>>   
>>   	nodes = (const struct software_node **)acpi_device_get_match_data(&pdev->dev);
> 
> Hmm... Why this doesn't use simple device_get_match_data()?
> 
>> -	if (!nodes)
>> -		return -ENODEV;
>> +	if (!nodes) {
>> +		fdt_root = of_find_node_by_path("/");
>> +		if (!fdt_root)
>> +			return -ENODEV;
>> +
>> +		match = of_match_node(ssam_platform_hub_of_match, fdt_root);
>> +		of_node_put(fdt_root);
>> +		if (!match)
>> +			return -ENODEV;
>> +
>> +		nodes = (const struct software_node **)match->data;
> 
> This is quite strange! Where are they being defined?

Essentially, this whole module is a giant workaround because there
doesn't seem to be a way to auto-discover which functions or subdevices
the EC actually supports. So this module builds a registry of software
nodes and matches against a Surface-model-specific ACPI ID (in ACPI
mode). Based on that ID, we retrieve the tree of software nodes that
define the EC subdevices and register them using a (virtual) platform
hub device.

The snippet way above registers the platform hub device for DT,
because there we don't have an equivalent ACPI device that we can
use. The code here retrieves the respective nodes.

>> +		if (!nodes)
>> +			return -ENODEV;
>> +	}
> 
> ...
> 
>> +MODULE_ALIAS("platform:surface_aggregator_platform_hub");
> 
> Can it be platfrom device ID table instead? But do you really need it?
> 

I think the explanation above already kind of answers this, but the
module is named differently than the driver (so that they reflect the
specific nature of each, registry vs hub device). And the platform hub
device added in the snippet I left above is named after the driver. So
for the registry module to load when the platform hub driver is
requested, it is needed.

Regards,
Max

  parent reply	other threads:[~2024-08-28  9:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 10:27 [PATCH v3 0/3] OF support for Surface System Aggregator Module Konrad Dybcio
2024-08-14 10:27 ` [PATCH v3 1/3] dt-bindings: serial: Allow embedded-controller as child node Konrad Dybcio
2024-08-14 10:27 ` [PATCH v3 2/3] dt-bindings: platform: Add Surface System Aggregator Module Konrad Dybcio
2024-08-14 14:06   ` Krzysztof Kozlowski
2024-08-14 10:27 ` [PATCH v3 3/3] platform/surface: Add OF support Konrad Dybcio
2024-08-16 18:23   ` Maximilian Luz
2024-08-26 20:54   ` Andy Shevchenko
2024-08-27  9:07     ` Hans de Goede
2024-08-27 13:52       ` Konrad Dybcio
2024-08-27 14:04         ` Hans de Goede
2024-08-28  9:10     ` Maximilian Luz [this message]
2024-08-28 16:56       ` Andy Shevchenko
2024-08-28 17:40         ` Maximilian Luz
2024-08-28 19:06           ` Andy Shevchenko
2024-08-30 12:57             ` Konrad Dybcio
2024-08-19 11:57 ` [PATCH v3 0/3] OF support for Surface System Aggregator Module Hans de Goede
2024-08-19 13:27   ` Konrad Dybcio
2024-08-19 20:07   ` Maximilian Luz
2024-08-26 20:55 ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d08d41ad-edcb-48ad-a848-53edc45ab8eb@gmail.com \
    --to=luzmaximilian@gmail.com \
    --cc=andersson@kernel.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=quic_kdybcio@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox