9feea59a373c114acc7b51b202ed929189e78734
[openwrt/staging/pepe2k.git] /
1 From 7069072c10f54de136613947a5b82f504e5f8478 Mon Sep 17 00:00:00 2001
2 From: "maxime@cerno.tech" <maxime@cerno.tech>
3 Date: Thu, 20 Oct 2022 11:12:09 +0200
4 Subject: [PATCH] firmware: raspberrypi: Introduce
5 rpi_firmware_find_node()
6
7 A significant number of RaspberryPi drivers using the firmware don't
8 have a phandle to it, so end up scanning the device tree to find a node
9 with the firmware compatible.
10
11 That code is duplicated everywhere, so let's introduce a helper instead.
12
13 Link: https://lore.kernel.org/r/20220815-rpi-fix-4k-60-v4-1-a1b40526df3e@cerno.tech
14 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
15 ---
16 drivers/firmware/raspberrypi.c | 18 ++++++++++++------
17 include/soc/bcm2835/raspberrypi-firmware.h | 7 +++++++
18 2 files changed, 19 insertions(+), 6 deletions(-)
19
20 --- a/drivers/firmware/raspberrypi.c
21 +++ b/drivers/firmware/raspberrypi.c
22 @@ -429,6 +429,18 @@ static int rpi_firmware_remove(struct pl
23 return 0;
24 }
25
26 +static const struct of_device_id rpi_firmware_of_match[] = {
27 + { .compatible = "raspberrypi,bcm2835-firmware", },
28 + {},
29 +};
30 +MODULE_DEVICE_TABLE(of, rpi_firmware_of_match);
31 +
32 +struct device_node *rpi_firmware_find_node(void)
33 +{
34 + return of_find_matching_node(NULL, rpi_firmware_of_match);
35 +}
36 +EXPORT_SYMBOL_GPL(rpi_firmware_find_node);
37 +
38 /**
39 * rpi_firmware_get - Get pointer to rpi_firmware structure.
40 * @firmware_node: Pointer to the firmware Device Tree node.
41 @@ -484,12 +496,6 @@ struct rpi_firmware *devm_rpi_firmware_g
42 }
43 EXPORT_SYMBOL_GPL(devm_rpi_firmware_get);
44
45 -static const struct of_device_id rpi_firmware_of_match[] = {
46 - { .compatible = "raspberrypi,bcm2835-firmware", },
47 - {},
48 -};
49 -MODULE_DEVICE_TABLE(of, rpi_firmware_of_match);
50 -
51 static struct platform_driver rpi_firmware_driver = {
52 .driver = {
53 .name = "raspberrypi-firmware",
54 --- a/include/soc/bcm2835/raspberrypi-firmware.h
55 +++ b/include/soc/bcm2835/raspberrypi-firmware.h
56 @@ -168,6 +168,7 @@ int rpi_firmware_property(struct rpi_fir
57 int rpi_firmware_property_list(struct rpi_firmware *fw,
58 void *data, size_t tag_size);
59 void rpi_firmware_put(struct rpi_firmware *fw);
60 +struct device_node *rpi_firmware_find_node(void);
61 struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node);
62 struct rpi_firmware *devm_rpi_firmware_get(struct device *dev,
63 struct device_node *firmware_node);
64 @@ -185,6 +186,12 @@ static inline int rpi_firmware_property_
65 }
66
67 static inline void rpi_firmware_put(struct rpi_firmware *fw) { }
68 +
69 +static inline struct device_node *rpi_firmware_find_node(void)
70 +{
71 + return NULL;
72 +}
73 +
74 static inline struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node)
75 {
76 return NULL;