Message ID | 20221117114818.v7.3.Ie23c217d69ff25d7354db942613f143bbc8ef891@changeid (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [v7,1/3] platform/chrome: cros_ec_uart: Add cros-ec-uart transport layer | expand |
On Thu, Nov 17, 2022 at 11:48:48AM -0700, Mark Hasemeyer wrote: > @@ -392,6 +393,12 @@ static int __maybe_unused cros_ec_uart_resume(struct device *dev) > static SIMPLE_DEV_PM_OPS(cros_ec_uart_pm_ops, cros_ec_uart_suspend, > cros_ec_uart_resume); > > +static const struct of_device_id cros_ec_uart_of_match[] = { > + { .compatible = "google,cros-ec-uart" }, > + {} > +}; > +MODULE_DEVICE_TABLE(of, cros_ec_uart_of_match); It would need a guard for checking CONFIG_OF. Similar to what `cros_ec_uart_acpi_id` does. > @@ -405,6 +412,7 @@ static struct serdev_device_driver cros_ec_uart_driver = { > .driver = { > .name = "cros-ec-uart", > .acpi_match_table = ACPI_PTR(cros_ec_uart_acpi_id), > + .of_match_table = cros_ec_uart_of_match, It would need be wrapped by `of_match_ptr()`. Similar to what `ACPI_PTR()` does.
> > @@ -392,6 +393,12 @@ static int __maybe_unused cros_ec_uart_resume(struct device *dev) > > static SIMPLE_DEV_PM_OPS(cros_ec_uart_pm_ops, cros_ec_uart_suspend, > > cros_ec_uart_resume); > > > > +static const struct of_device_id cros_ec_uart_of_match[] = { > > + { .compatible = "google,cros-ec-uart" }, > > + {} > > +}; > > +MODULE_DEVICE_TABLE(of, cros_ec_uart_of_match); > > It would need a guard for checking CONFIG_OF. Similar to what > `cros_ec_uart_acpi_id` does. > > > @@ -405,6 +412,7 @@ static struct serdev_device_driver cros_ec_uart_driver = { > > .driver = { > > .name = "cros-ec-uart", > > .acpi_match_table = ACPI_PTR(cros_ec_uart_acpi_id), > > + .of_match_table = cros_ec_uart_of_match, > > It would need be wrapped by `of_match_ptr()`. Similar to what > `ACPI_PTR()` does. I'm not sure we want a guard in this case because we compile the kernel without CONFIG_OF enabled for (most?) x86 platforms. Yet we still need the device tree code to enumerate using the PRP0001 _HID method.
On Tue, Nov 29, 2022 at 11:13:04AM -0700, Mark Hasemeyer wrote: > > > @@ -392,6 +393,12 @@ static int __maybe_unused cros_ec_uart_resume(struct device *dev) > > > static SIMPLE_DEV_PM_OPS(cros_ec_uart_pm_ops, cros_ec_uart_suspend, > > > cros_ec_uart_resume); > > > > > > +static const struct of_device_id cros_ec_uart_of_match[] = { > > > + { .compatible = "google,cros-ec-uart" }, > > > + {} > > > +}; > > > +MODULE_DEVICE_TABLE(of, cros_ec_uart_of_match); > > > > It would need a guard for checking CONFIG_OF. Similar to what > > `cros_ec_uart_acpi_id` does. > > > > > @@ -405,6 +412,7 @@ static struct serdev_device_driver cros_ec_uart_driver = { > > > .driver = { > > > .name = "cros-ec-uart", > > > .acpi_match_table = ACPI_PTR(cros_ec_uart_acpi_id), > > > + .of_match_table = cros_ec_uart_of_match, > > > > It would need be wrapped by `of_match_ptr()`. Similar to what > > `ACPI_PTR()` does. > > I'm not sure we want a guard in this case because we compile the kernel without > CONFIG_OF enabled for (most?) x86 platforms. Yet we still need the device > tree code to enumerate using the PRP0001 _HID method. I'm not familiar to ACPI. However, I thought it should add the compatible string in the _DSD instead of using of_match for the case. See example in [1]. [1]: https://www.kernel.org/doc/html/latest/firmware-guide/acpi/enumeration.html#device-tree-namespace-link-device-id
On Wed, Nov 30, 2022 at 12:10 AM Tzung-Bi Shih <tzungbi@kernel.org> wrote: > > On Tue, Nov 29, 2022 at 11:13:04AM -0700, Mark Hasemeyer wrote: > > > > @@ -392,6 +393,12 @@ static int __maybe_unused cros_ec_uart_resume(struct device *dev) > > > > static SIMPLE_DEV_PM_OPS(cros_ec_uart_pm_ops, cros_ec_uart_suspend, > > > > cros_ec_uart_resume); > > > > > > > > +static const struct of_device_id cros_ec_uart_of_match[] = { > > > > + { .compatible = "google,cros-ec-uart" }, > > > > + {} > > > > +}; > > > > +MODULE_DEVICE_TABLE(of, cros_ec_uart_of_match); > > > > > > It would need a guard for checking CONFIG_OF. Similar to what > > > `cros_ec_uart_acpi_id` does. > > > > > > > @@ -405,6 +412,7 @@ static struct serdev_device_driver cros_ec_uart_driver = { > > > > .driver = { > > > > .name = "cros-ec-uart", > > > > .acpi_match_table = ACPI_PTR(cros_ec_uart_acpi_id), > > > > + .of_match_table = cros_ec_uart_of_match, > > > > > > It would need be wrapped by `of_match_ptr()`. Similar to what > > > `ACPI_PTR()` does. > > > > I'm not sure we want a guard in this case because we compile the kernel without > > CONFIG_OF enabled for (most?) x86 platforms. Yet we still need the device > > tree code to enumerate using the PRP0001 _HID method. > > I'm not familiar to ACPI. However, I thought it should add the compatible > string in the _DSD instead of using of_match for the case. See example > in [1]. > > [1]: https://www.kernel.org/doc/html/latest/firmware-guide/acpi/enumeration.html#device-tree-namespace-link-device-id Correct, we need to add the compatible string inside the _DSD. This is what we currently do for all of our released devices: ``` Device (CRFP) { Name (_HID, "PRP0001") // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID Name (_DDN, "Fingerprint Reader") // _DDN: DOS Device Name Name (_DSD, Package (0x02) // _DSD: Device-Specific Data { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */, Package (0x03) { Package (0x02) { "compatible", "google,cros-ec-uart" }, ... } } } ``` Since we define our `_HID` as `PRP0001` we need the `of_match_table` so the ACPI node can bind.
On Wed, Nov 30, 2022 at 09:52:29AM -0700, Raul Rangel wrote: > On Wed, Nov 30, 2022 at 12:10 AM Tzung-Bi Shih <tzungbi@kernel.org> wrote: > > > > On Tue, Nov 29, 2022 at 11:13:04AM -0700, Mark Hasemeyer wrote: > > > > > @@ -392,6 +393,12 @@ static int __maybe_unused cros_ec_uart_resume(struct device *dev) > > > > > static SIMPLE_DEV_PM_OPS(cros_ec_uart_pm_ops, cros_ec_uart_suspend, > > > > > cros_ec_uart_resume); > > > > > > > > > > +static const struct of_device_id cros_ec_uart_of_match[] = { > > > > > + { .compatible = "google,cros-ec-uart" }, > > > > > + {} > > > > > +}; > > > > > +MODULE_DEVICE_TABLE(of, cros_ec_uart_of_match); > > > > > > > > It would need a guard for checking CONFIG_OF. Similar to what > > > > `cros_ec_uart_acpi_id` does. > > > > > > > > > @@ -405,6 +412,7 @@ static struct serdev_device_driver cros_ec_uart_driver = { > > > > > .driver = { > > > > > .name = "cros-ec-uart", > > > > > .acpi_match_table = ACPI_PTR(cros_ec_uart_acpi_id), > > > > > + .of_match_table = cros_ec_uart_of_match, > > > > > > > > It would need be wrapped by `of_match_ptr()`. Similar to what > > > > `ACPI_PTR()` does. > > > > > > I'm not sure we want a guard in this case because we compile the kernel without > > > CONFIG_OF enabled for (most?) x86 platforms. Yet we still need the device > > > tree code to enumerate using the PRP0001 _HID method. > > > > > I'm not familiar to ACPI. However, I thought it should add the compatible > > string in the _DSD instead of using of_match for the case. See example > > in [1]. > > > > [1]: https://www.kernel.org/doc/html/latest/firmware-guide/acpi/enumeration.html#device-tree-namespace-link-device-id > > Correct, we need to add the compatible string inside the _DSD. This is > what we currently do for all of our released devices: > ``` > Device (CRFP) > { > Name (_HID, "PRP0001") // _HID: Hardware ID > Name (_UID, Zero) // _UID: Unique ID > Name (_DDN, "Fingerprint Reader") // _DDN: DOS Device Name > Name (_DSD, Package (0x02) // _DSD: Device-Specific Data > { > ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device > Properties for _DSD */, > Package (0x03) > { > Package (0x02) > { > "compatible", > "google,cros-ec-uart" > }, > ... > } > } > } > ``` > > Since we define our `_HID` as `PRP0001` we need the `of_match_table` > so the ACPI node can bind. I see. I also found some more examples: - 3c3969a0c99b ("iio:adc:ti-adc12138: Switch to generic firmware properties and drop of_match_ptr") - a70bbbe387d0 ("nfc: pn533: drop of_match_ptr from device ID table")
diff --git a/drivers/platform/chrome/cros_ec_uart.c b/drivers/platform/chrome/cros_ec_uart.c index b5f72f0104985..d44efb78bc881 100644 --- a/drivers/platform/chrome/cros_ec_uart.c +++ b/drivers/platform/chrome/cros_ec_uart.c @@ -11,6 +11,7 @@ #include <linux/kernel.h> #include <linux/module.h> #include <linux/acpi.h> +#include <linux/of.h> #include <linux/platform_data/cros_ec_commands.h> #include <linux/platform_data/cros_ec_proto.h> #include <linux/serdev.h> @@ -392,6 +393,12 @@ static int __maybe_unused cros_ec_uart_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(cros_ec_uart_pm_ops, cros_ec_uart_suspend, cros_ec_uart_resume); +static const struct of_device_id cros_ec_uart_of_match[] = { + { .compatible = "google,cros-ec-uart" }, + {} +}; +MODULE_DEVICE_TABLE(of, cros_ec_uart_of_match); + #ifdef CONFIG_ACPI static const struct acpi_device_id cros_ec_uart_acpi_id[] = { { "GOOG0019", 0 }, @@ -405,6 +412,7 @@ static struct serdev_device_driver cros_ec_uart_driver = { .driver = { .name = "cros-ec-uart", .acpi_match_table = ACPI_PTR(cros_ec_uart_acpi_id), + .of_match_table = cros_ec_uart_of_match, .pm = &cros_ec_uart_pm_ops, }, .probe = cros_ec_uart_probe,