diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-02-03 09:55:54 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-02-03 09:55:54 +0100 |
commit | 601bf0fcc62854af68b35d857696be9a4a9e567d (patch) | |
tree | 39e6eb29bdd79e49b474a64558d81f6fb9d34c94 /drivers | |
parent | 701d565c2a1c50e84e7035048968bc81fd869c87 (diff) | |
parent | a4d39ca0f1e0ceeab4e1f817a9c32b9c0a4f01c2 (diff) | |
download | barebox-601bf0fcc62854af68b35d857696be9a4a9e567d.tar.gz barebox-601bf0fcc62854af68b35d857696be9a4a9e567d.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/Kconfig | 14 | ||||
-rw-r--r-- | drivers/misc/Makefile | 1 | ||||
-rw-r--r-- | drivers/misc/sram.c | 75 | ||||
-rw-r--r-- | drivers/of/barebox.c | 2 | ||||
-rw-r--r-- | drivers/of/base.c | 23 | ||||
-rw-r--r-- | drivers/serial/serial_imx.c | 1 | ||||
-rw-r--r-- | drivers/serial/serial_ns16550.c | 3 |
7 files changed, 110 insertions, 9 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 606490b54e..c34a4af512 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -2,12 +2,7 @@ # Misc strange devices # -menuconfig MISC_DEVICES - bool "Misc devices" - help - Add support for misc strange devices - -if MISC_DEVICES +menu "Misc devices" config JTAG tristate "JTAG Bitbang driver" @@ -15,4 +10,9 @@ config JTAG help Controls JTAG chains connected to I/O pins -endif # MISC_DEVICES +config SRAM + bool "Generic SRAM driver" + help + This driver adds support for memory mapped SRAM. + +endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index b0855777a9..908c8cb708 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_JTAG) += jtag.o +obj-$(CONFIG_SRAM) += sram.o diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c new file mode 100644 index 0000000000..7ea23b7b0c --- /dev/null +++ b/drivers/misc/sram.c @@ -0,0 +1,75 @@ +/* + * drivers/misc/sram.c - generic memory mapped SRAM driver + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <common.h> +#include <errno.h> +#include <driver.h> +#include <malloc.h> +#include <init.h> + +struct sram { + struct resource *res; + char *name; + struct cdev cdev; +}; + +static struct file_operations memops = { + .read = mem_read, + .write = mem_write, + .memmap = generic_memmap_rw, + .lseek = dev_lseek_default, +}; + +static int sram_probe(struct device_d *dev) +{ + struct sram *sram; + struct resource *res; + void __iomem *base; + int ret; + + base = dev_request_mem_region(dev, 0); + if (!base) + return -EBUSY; + + sram = xzalloc(sizeof(*sram)); + + sram->cdev.name = asprintf("sram%d", + cdev_find_free_index("sram")); + + res = dev_get_resource(dev, 0); + + sram->cdev.size = (unsigned long)resource_size(res); + sram->cdev.ops = &memops; + sram->cdev.dev = dev; + + ret = devfs_create(&sram->cdev); + if (ret) + return ret; + + return 0; +} + +static __maybe_unused struct of_device_id sram_dt_ids[] = { + { + .compatible = "mmio-sram", + }, { + }, +}; + +static struct driver_d sram_driver = { + .name = "mmio-sram", + .probe = sram_probe, + .of_compatible = sram_dt_ids, +}; +device_platform_driver(sram_driver); diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c index 8977158992..44ec820ec5 100644 --- a/drivers/of/barebox.c +++ b/drivers/of/barebox.c @@ -59,7 +59,7 @@ static int environment_probe(struct device_d *dev) dev_info(dev, "setting default environment path to %s\n", path); - default_environment_path = path; + default_environment_path_set(path); return 0; } diff --git a/drivers/of/base.c b/drivers/of/base.c index ea2d879be4..6e5e7d6e76 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1378,11 +1378,32 @@ EXPORT_SYMBOL(of_find_node_by_path); struct device_node *of_find_node_by_path_or_alias(struct device_node *root, const char *str) { + struct device_node *node; + const char *slash; + char *alias; + size_t len = 0; + if (*str == '/') return of_find_node_by_path_from(root, str); - else + + slash = strchr(str, '/'); + + if (!slash) return of_find_node_by_alias(root, str); + len = slash - str + 1; + alias = xmalloc(len); + strlcpy(alias, str, len); + + node = of_find_node_by_alias(root, alias); + + if (!node) + goto out; + + node = of_find_node_by_path_from(node, slash); +out: + free(alias); + return node; } EXPORT_SYMBOL(of_find_node_by_path_or_alias); diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c index 8468fa0adc..e0bd185c8b 100644 --- a/drivers/serial/serial_imx.c +++ b/drivers/serial/serial_imx.c @@ -336,6 +336,7 @@ static int imx_serial_probe(struct device_d *dev) cdev->getc = imx_serial_getc; cdev->flush = imx_serial_flush; cdev->setbrg = imx_serial_setbaudrate; + cdev->linux_console_name = "ttymxc"; imx_serial_init_port(cdev); diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index a8487b0ed3..f1da44b7f7 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -57,6 +57,7 @@ static inline struct ns16550_priv *to_ns16550_priv(struct console_device *cdev) struct ns16550_drvdata { void (*init_port)(struct console_device *cdev); + const char *linux_console_name; }; /** @@ -251,6 +252,7 @@ static struct ns16550_drvdata ns16550_drvdata = { static __maybe_unused struct ns16550_drvdata omap_drvdata = { .init_port = ns16550_omap_init_port, + .linux_console_name = "ttyO", }; /** @@ -312,6 +314,7 @@ static int ns16550_probe(struct device_d *dev) cdev->putc = ns16550_putc; cdev->getc = ns16550_getc; cdev->setbrg = ns16550_setbaudrate; + cdev->linux_console_name = devtype->linux_console_name; devtype->init_port(cdev); |