summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-09-25 08:06:23 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-25 08:06:23 +0200
commitcbfaec5633457fb5dae949be1665ca427bbad067 (patch)
tree2b3bceb479d7e9c75186dedc43922385f2ad6b59 /drivers
parent92e98809ffb521ae3b170538bc6984c000928971 (diff)
parent0f2f2d390b6ed1fe56898b4e5615b636c97d0b22 (diff)
downloadbarebox-master.tar.gz
Merge branch 'for-next/protonic' into masterHEADmaster
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpiolib.c31
-rw-r--r--drivers/of/base.c17
-rw-r--r--drivers/of/device.c12
3 files changed, 60 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 27674af..6088cad 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -381,6 +381,37 @@ void gpio_free_array(const struct gpio *array, size_t num)
}
EXPORT_SYMBOL_GPL(gpio_free_array);
+int gpio_array_to_id(const struct gpio *array, size_t num, u32 *val)
+{
+ u32 id = 0;
+ int ret, i;
+
+ if (num > 32)
+ return -EOVERFLOW;
+
+ ret = gpio_request_array(array, num);
+ if (ret)
+ return ret;
+
+ /* Wait until logic level will be stable */
+ udelay(5);
+ for (i = 0; i < num; i++) {
+ ret = gpio_is_active(array[i].gpio);
+ if (ret < 0)
+ goto free_array;
+ if (ret)
+ id |= 1UL << i;
+ }
+
+ *val = id;
+ ret = 0;
+
+free_array:
+ gpio_free_array(array, num);
+ return ret;
+}
+EXPORT_SYMBOL(gpio_array_to_id);
+
static int gpiochip_find_base(int start, int ngpio)
{
int i;
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 4c633bc..0a2632f 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2130,6 +2130,21 @@ static void of_probe_memory(void)
}
}
+static void of_platform_device_create_root(struct device_node *np)
+{
+ struct device_d *dev;
+ int ret;
+
+ dev = xzalloc(sizeof(*dev));
+ dev->id = DEVICE_ID_SINGLE;
+ dev->device_node = np;
+ dev_set_name(dev, "machine");
+
+ ret = platform_device_register(dev);
+ if (ret)
+ free(dev);
+}
+
int of_probe(void)
{
struct device_node *firmware;
@@ -2149,6 +2164,8 @@ int of_probe(void)
if (firmware)
of_platform_populate(firmware, NULL, NULL);
+ of_platform_device_create_root(root_node);
+
of_clk_init(root_node, NULL);
of_platform_populate(root_node, of_default_bus_match_table, NULL);
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 67a67bd..b3f522e 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -31,3 +31,15 @@ const void *of_device_get_match_data(const struct device_d *dev)
return match->data;
}
EXPORT_SYMBOL(of_device_get_match_data);
+
+const char *of_device_get_match_compatible(const struct device_d *dev)
+{
+ const struct of_device_id *match;
+
+ match = of_match_device(dev->driver->of_compatible, dev);
+ if (!match)
+ return NULL;
+
+ return match->compatible;
+}
+EXPORT_SYMBOL(of_device_get_match_compatible);