summaryrefslogtreecommitdiff
path: root/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
diff options
context:
space:
mode:
authorPhilippe Reynes <philippe.reynes@softathome.com>2019-03-15 15:14:36 +0100
committerTom Rini <trini@konsulko.com>2019-04-22 11:55:58 -0400
commit22daafba25592b79112d21d1662d7b8381827c56 (patch)
tree6e31e8388261f537195d50cc6b0aaa61adc61465 /drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
parent29c7169b7b24a8520ca9faf84edc33c89de6b7cc (diff)
drivers: nand: brcmnand: add initial support
The driver brcmnand come from linux kernel 4.18. Only SoC bcm6838 and bcm6858 are supported. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Diffstat (limited to 'drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c')
-rw-r--r--drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
new file mode 100644
index 0000000000..96b27e6e5a
--- /dev/null
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand_compat.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <common.h>
+#include "brcmnand_compat.h"
+
+struct clk *devm_clk_get(struct udevice *dev, const char *id)
+{
+ struct clk *clk;
+ int ret;
+
+ clk = devm_kzalloc(dev, sizeof(*clk), GFP_KERNEL);
+ if (!clk) {
+ debug("%s: can't allocate clock\n", __func__);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ ret = clk_get_by_name(dev, id, clk);
+ if (ret < 0) {
+ debug("%s: can't get clock (ret = %d)!\n", __func__, ret);
+ return ERR_PTR(ret);
+ }
+
+ return clk;
+}
+
+int clk_prepare_enable(struct clk *clk)
+{
+ return clk_enable(clk);
+}
+
+void clk_disable_unprepare(struct clk *clk)
+{
+ clk_disable(clk);
+}
+
+static char *devm_kvasprintf(struct udevice *dev, gfp_t gfp, const char *fmt,
+ va_list ap)
+{
+ unsigned int len;
+ char *p;
+ va_list aq;
+
+ va_copy(aq, ap);
+ len = vsnprintf(NULL, 0, fmt, aq);
+ va_end(aq);
+
+ p = devm_kmalloc(dev, len + 1, gfp);
+ if (!p)
+ return NULL;
+
+ vsnprintf(p, len + 1, fmt, ap);
+
+ return p;
+}
+
+char *devm_kasprintf(struct udevice *dev, gfp_t gfp, const char *fmt, ...)
+{
+ va_list ap;
+ char *p;
+
+ va_start(ap, fmt);
+ p = devm_kvasprintf(dev, gfp, fmt, ap);
+ va_end(ap);
+
+ return p;
+}