summaryrefslogtreecommitdiffstats
path: root/arch/sandbox/board
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sandbox/board')
-rw-r--r--arch/sandbox/board/.gitignore1
-rw-r--r--arch/sandbox/board/Makefile7
-rw-r--r--arch/sandbox/board/barebox.lds.S2
-rw-r--r--arch/sandbox/board/board.c10
-rw-r--r--arch/sandbox/board/console.c4
-rw-r--r--arch/sandbox/board/devices.c4
-rw-r--r--arch/sandbox/board/hostfile.c87
-rw-r--r--arch/sandbox/board/led.c9
-rw-r--r--arch/sandbox/board/power.c22
-rw-r--r--arch/sandbox/board/stickypage.S3
-rw-r--r--arch/sandbox/board/watchdog.c34
11 files changed, 99 insertions, 84 deletions
diff --git a/arch/sandbox/board/.gitignore b/arch/sandbox/board/.gitignore
index c0acd24b98..03987a7009 100644
--- a/arch/sandbox/board/.gitignore
+++ b/arch/sandbox/board/.gitignore
@@ -1,4 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
barebox.lds
-stickypage.bin
diff --git a/arch/sandbox/board/Makefile b/arch/sandbox/board/Makefile
index 11688c5aba..b4bab02163 100644
--- a/arch/sandbox/board/Makefile
+++ b/arch/sandbox/board/Makefile
@@ -13,9 +13,4 @@ obj-$(CONFIG_LED) += led.o
extra-y += barebox.lds
-extra-y += stickypage.bin
-
-OBJCOPYFLAGS_stickypage.bin = -O binary
-
-%.bin: %.o
- $(call if_changed,objcopy)
+obj-y += stickypage.o
diff --git a/arch/sandbox/board/barebox.lds.S b/arch/sandbox/board/barebox.lds.S
index 84d085a259..ab2801f3d2 100644
--- a/arch/sandbox/board/barebox.lds.S
+++ b/arch/sandbox/board/barebox.lds.S
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include <asm-generic/barebox.lds.h>
+#include <asm/barebox.lds.h>
SECTIONS
{
diff --git a/arch/sandbox/board/board.c b/arch/sandbox/board/board.c
index 43e355afe8..c8d1c99897 100644
--- a/arch/sandbox/board/board.c
+++ b/arch/sandbox/board/board.c
@@ -29,23 +29,23 @@ struct fb_videomode mode = {
.yres = 480,
};
-static struct device_d tap_device = {
+static struct device tap_device = {
.id = DEVICE_ID_DYNAMIC,
.name = "tap",
};
-static struct device_d sdl_device = {
+static struct device sdl_device = {
.id = DEVICE_ID_DYNAMIC,
.name = "sdlfb",
.platform_data = &mode,
};
-static struct device_d devrandom_device = {
+static struct device devrandom_device = {
.id = DEVICE_ID_DYNAMIC,
.name = "devrandom",
};
-static int devices_init(struct device_d *dev)
+static int devices_init(struct device *dev)
{
platform_device_register(&tap_device);
@@ -68,7 +68,7 @@ static struct of_device_id sandbox_dt_ids[] = {
};
BAREBOX_DEEP_PROBE_ENABLE(sandbox_dt_ids);
-static struct driver_d sandbox_board_drv = {
+static struct driver sandbox_board_drv = {
.name = "sandbox-board",
.of_compatible = sandbox_dt_ids,
.probe = devices_init,
diff --git a/arch/sandbox/board/console.c b/arch/sandbox/board/console.c
index cea62d57b1..274ef67aef 100644
--- a/arch/sandbox/board/console.c
+++ b/arch/sandbox/board/console.c
@@ -21,10 +21,10 @@
int barebox_register_console(int stdinfd, int stdoutfd)
{
- struct device_d *dev;
+ struct device *dev;
struct linux_console_data *data;
- dev = xzalloc(sizeof(struct device_d) + sizeof(struct linux_console_data));
+ dev = xzalloc(sizeof(struct device) + sizeof(struct linux_console_data));
data = (struct linux_console_data *)(dev + 1);
diff --git a/arch/sandbox/board/devices.c b/arch/sandbox/board/devices.c
index f7305a8ead..ecd24e9207 100644
--- a/arch/sandbox/board/devices.c
+++ b/arch/sandbox/board/devices.c
@@ -14,7 +14,7 @@ unsigned char __pci_iobase[IO_SPACE_LIMIT];
static LIST_HEAD(sandbox_device_list);
-int sandbox_add_device(struct device_d *dev)
+int sandbox_add_device(struct device *dev)
{
list_add(&dev->list, &sandbox_device_list);
@@ -23,7 +23,7 @@ int sandbox_add_device(struct device_d *dev)
static int sandbox_device_init(void)
{
- struct device_d *dev, *tmp;
+ struct device *dev, *tmp;
list_for_each_entry_safe(dev, tmp, &sandbox_device_list, list) {
/* reset the list_head before registering for real */
diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 52165adec8..7afad95b6d 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <linux/err.h>
#include <mach/hostfile.h>
+#include <featctrl.h>
#include <xfuncs.h>
struct hf_priv {
@@ -33,6 +34,7 @@ struct hf_priv {
};
const char *filename;
int fd;
+ struct feature_controller feat;
};
static ssize_t hf_read(struct hf_priv *priv, void *buf, size_t count, loff_t offset, ulong flags)
@@ -89,25 +91,48 @@ static struct block_device_ops hf_blk_ops = {
.write = hf_blk_write,
};
-static void hf_info(struct device_d *dev)
+static void hf_info(struct device *dev)
{
struct hf_priv *priv = dev->priv;
printf("file: %s\n", priv->filename);
}
-static int hf_probe(struct device_d *dev)
+static int hostfile_feat_check(struct feature_controller *feat, int idx)
{
- struct device_node *np = dev->device_node;
+ struct hf_priv *priv = container_of(feat, struct hf_priv, feat);
+
+ return priv->fd >= 0 ? FEATCTRL_OKAY : FEATCTRL_GATED;
+}
+
+static int hf_probe(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
struct hf_priv *priv = xzalloc(sizeof(*priv));
struct cdev *cdev;
- bool is_blockdev;
+ bool is_featctrl = false, is_blockdev;
u64 reg[2];
int err;
if (!np)
return -ENODEV;
+ dev->priv = priv;
+ priv->fd = -1;
+
+ if (IS_ENABLED(CONFIG_FEATURE_CONTROLLER) &&
+ of_property_read_bool(np, "barebox,feature-controller")) {
+ priv->feat.dev = dev;
+ priv->feat.check = hostfile_feat_check;
+
+ err = feature_controller_register(&priv->feat);
+ if (err)
+ return err;
+
+ is_featctrl = true;
+ }
+
+
err = of_property_read_u64_array(np, "reg", reg, ARRAY_SIZE(reg));
if (err)
return err;
@@ -120,16 +145,15 @@ static int hf_probe(struct device_d *dev)
return err;
if (priv->fd < 0)
- return priv->fd;
+ return is_featctrl ? 0 : priv->fd;
dev->info = hf_info;
- dev->priv = priv;
is_blockdev = of_property_read_bool(np, "barebox,blockdev");
cdev = is_blockdev ? &priv->blk.cdev : &priv->cdev;
- cdev->device_node = np;
+ cdev_set_of_node(cdev, np);
if (is_blockdev) {
cdev->name = np->name;
@@ -137,15 +161,12 @@ static int hf_probe(struct device_d *dev)
priv->blk.ops = &hf_blk_ops;
priv->blk.blockbits = SECTOR_SHIFT;
priv->blk.num_blocks = reg[1] / SECTOR_SIZE;
+ priv->blk.type = BLK_TYPE_VIRTUAL;
err = blockdevice_register(&priv->blk);
if (err)
return err;
- err = parse_partition_table(&priv->blk);
- if (err)
- dev_warn(dev, "No partition table found\n");
-
dev_info(dev, "registered as block device\n");
} else {
cdev->name = np->name;
@@ -164,7 +185,7 @@ static int hf_probe(struct device_d *dev)
of_parse_partitions(cdev, np);
of_partitions_register_fixup(cdev);
- return 0;
+ return of_platform_populate(np, NULL, dev);
}
static __maybe_unused struct of_device_id hostfile_dt_ids[] = {
@@ -174,8 +195,9 @@ static __maybe_unused struct of_device_id hostfile_dt_ids[] = {
/* sentinel */
}
};
+MODULE_DEVICE_TABLE(of, hostfile_dt_ids);
-static struct driver_d hf_drv = {
+static struct driver hf_drv = {
.name = "hostfile",
.of_compatible = DRV_OF_COMPAT(hostfile_dt_ids),
.probe = hf_probe,
@@ -227,7 +249,20 @@ static int of_hostfile_map_fixup(struct device_node *root, void *ctx)
struct device_node *node;
int ret;
- for_each_compatible_node_from(node, root, NULL, hostfile_dt_ids->compatible) {
+ for_each_compatible_node_from(node, root, NULL, "barebox,stickypage") {
+ char *filename;
+
+ filename = linux_get_stickypage_path();
+ if (!filename) {
+ pr_err("error allocating stickypage\n");
+ continue;
+ }
+
+ of_property_write_string(node, "barebox,filename", filename);
+ of_property_write_string(node, "compatible", "barebox,hostfile");
+ }
+
+ for_each_compatible_node_from(node, root, NULL, "barebox,hostfile") {
struct hf_info hf = {};
uint64_t reg[2] = {};
@@ -239,13 +274,6 @@ static int of_hostfile_map_fixup(struct device_node *root, void *ctx)
continue;
}
- if (memcmp(hf.filename, "$build/", 7) == 0) {
- char *fullpath = xasprintf("%s/%s", linux_get_builddir(),
- hf.filename + sizeof "$build/" - 1);
-
- hf.filename = fullpath;
- }
-
hf.is_blockdev = of_property_read_bool(node, "barebox,blockdev");
hf.is_cdev = of_property_read_bool(node, "barebox,cdev");
hf.is_readonly = of_property_read_bool(node, "barebox,read-only");
@@ -257,23 +285,14 @@ static int of_hostfile_map_fixup(struct device_node *root, void *ctx)
ret = linux_open_hostfile(&hf);
if (ret)
- goto out;
+ continue;
reg[0] = hf.base;
reg[1] = hf.size;
- ret = of_property_write_u64_array(node, "reg", reg, ARRAY_SIZE(reg));
- if (ret)
- goto out;
-
- ret = of_property_write_bool(node, "barebox,blockdev", hf.is_blockdev);
- if (ret)
- goto out;
-
- ret = of_property_write_u32(node, "barebox,fd", hf.fd);
-out:
- if (ret)
- pr_err("error fixing up %s: %pe\n", hf.devname, ERR_PTR(ret));
+ of_property_write_u64_array(node, "reg", reg, ARRAY_SIZE(reg));
+ of_property_write_bool(node, "barebox,blockdev", hf.is_blockdev);
+ of_property_write_u32(node, "barebox,fd", hf.fd);
}
return 0;
diff --git a/arch/sandbox/board/led.c b/arch/sandbox/board/led.c
index b7ab81112b..ced7e82f99 100644
--- a/arch/sandbox/board/led.c
+++ b/arch/sandbox/board/led.c
@@ -26,9 +26,9 @@ static void sandbox_led_set(struct led *led, unsigned int brightness)
sandbox_led.active = true;
}
-static int sandbox_led_of_probe(struct device_d *dev)
+static int sandbox_led_of_probe(struct device *dev)
{
- struct device_node *np = dev->device_node;
+ struct device_node *np = dev->of_node;
int ret;
if (sandbox_led.led.set)
@@ -47,7 +47,7 @@ static int sandbox_led_of_probe(struct device_d *dev)
return 0;
}
-static void sandbox_led_of_remove(struct device_d *dev)
+static void sandbox_led_of_remove(struct device *dev)
{
if (sandbox_led.active)
sandbox_led_set(NULL, 0);
@@ -57,8 +57,9 @@ static struct of_device_id sandbox_led_of_ids[] = {
{ .compatible = "barebox,sandbox-led", },
{ }
};
+MODULE_DEVICE_TABLE(of, sandbox_led_of_ids);
-static struct driver_d sandbox_led_of_driver = {
+static struct driver sandbox_led_of_driver = {
.name = "sandbox-led",
.probe = sandbox_led_of_probe,
.remove = sandbox_led_of_remove,
diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c
index 009b410eaa..8300c589c7 100644
--- a/arch/sandbox/board/power.c
+++ b/arch/sandbox/board/power.c
@@ -5,7 +5,7 @@
#include <poweroff.h>
#include <restart.h>
#include <mach/linux.h>
-#include <reset_source.h>
+#include <asm/reset_source.h>
#include <linux/nvmem-consumer.h>
struct sandbox_power {
@@ -18,7 +18,8 @@ static void sandbox_poweroff(struct poweroff_handler *poweroff)
{
struct sandbox_power *power = container_of(poweroff, struct sandbox_power, poweroff);
- nvmem_cell_write(power->reset_source_cell, &(u8) { RESET_POR }, 1);
+ sandbox_save_reset_source(power->reset_source_cell, RESET_POR);
+
linux_exit();
}
@@ -29,16 +30,14 @@ static void sandbox_rst_hang(struct restart_handler *rst)
static void sandbox_rst_reexec(struct restart_handler *rst)
{
- u8 reason = RESET_RST;
struct sandbox_power *power = container_of(rst, struct sandbox_power, rst_reexec);
- if (!IS_ERR(power->reset_source_cell))
- WARN_ON(nvmem_cell_write(power->reset_source_cell, &reason, 1) <= 0);
+ sandbox_save_reset_source(power->reset_source_cell, RESET_RST);
linux_reexec();
}
-static int sandbox_power_probe(struct device_d *dev)
+static int sandbox_power_probe(struct device *dev)
{
struct sandbox_power *power = xzalloc(sizeof(*power));
size_t len;
@@ -66,9 +65,13 @@ static int sandbox_power_probe(struct device_d *dev)
if (IS_ENABLED(CONFIG_SANDBOX_REEXEC))
restart_handler_register(&power->rst_reexec);
- power->reset_source_cell = of_nvmem_cell_get(dev->device_node, "reset-source");
+ power->reset_source_cell = of_nvmem_cell_get(dev->of_node,
+ "reset-source");
if (IS_ERR(power->reset_source_cell)) {
- dev_warn(dev, "No reset source info available: %pe\n", power->reset_source_cell);
+ if (PTR_ERR(power->reset_source_cell) != -EPROBE_DEFER)
+ dev_warn(dev, "No reset source info available: %pe\n",
+ power->reset_source_cell);
+ power->reset_source_cell = NULL;
return 0;
}
@@ -86,8 +89,9 @@ static __maybe_unused struct of_device_id sandbox_power_dt_ids[] = {
{ .compatible = "barebox,sandbox-power" },
{ /* sentinel */ }
};
+MODULE_DEVICE_TABLE(of, sandbox_power_dt_ids);
-static struct driver_d sandbox_power_drv = {
+static struct driver sandbox_power_drv = {
.name = "sandbox-power",
.of_compatible = sandbox_power_dt_ids,
.probe = sandbox_power_probe,
diff --git a/arch/sandbox/board/stickypage.S b/arch/sandbox/board/stickypage.S
index f1915ab986..1d3861c373 100644
--- a/arch/sandbox/board/stickypage.S
+++ b/arch/sandbox/board/stickypage.S
@@ -1,5 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */
+.section .note.GNU-stack,"",%progbits
+.section .rodata.stickypage,"a"
+
.globl stickypage;
stickypage:
diff --git a/arch/sandbox/board/watchdog.c b/arch/sandbox/board/watchdog.c
index daaf549642..074c96a8a9 100644
--- a/arch/sandbox/board/watchdog.c
+++ b/arch/sandbox/board/watchdog.c
@@ -7,7 +7,7 @@
#include <of.h>
#include <watchdog.h>
#include <linux/nvmem-consumer.h>
-#include <reset_source.h>
+#include <asm/reset_source.h>
struct sandbox_watchdog {
struct watchdog wdd;
@@ -30,18 +30,17 @@ static int sandbox_watchdog_set_timeout(struct watchdog *wdd, unsigned int timeo
if (timeout > wdd->timeout_max)
return -EINVAL;
- nvmem_cell_write(wd->reset_source_cell, &(u8) { RESET_WDG }, 1);
+ sandbox_save_reset_source(wd->reset_source_cell, RESET_WDG);
linux_watchdog_set_timeout(timeout);
return 0;
}
-static int sandbox_watchdog_probe(struct device_d *dev)
+static int sandbox_watchdog_probe(struct device *dev)
{
- struct device_node *np = dev->device_node;
+ struct device_node *np = dev->of_node;
struct sandbox_watchdog *wd;
struct watchdog *wdd;
- int ret;
wd = xzalloc(sizeof(*wd));
@@ -50,23 +49,17 @@ static int sandbox_watchdog_probe(struct device_d *dev)
wdd->set_timeout = sandbox_watchdog_set_timeout;
wdd->timeout_max = 1000;
- wd->cant_disable = of_property_read_bool(np, "barebox,cant-disable");
-
- ret = watchdog_register(wdd);
- if (ret) {
- dev_err(dev, "Failed to register watchdog device\n");
- return ret;
- }
-
- wd->reset_source_cell = of_nvmem_cell_get(dev->device_node, "reset-source");
+ wd->reset_source_cell = of_nvmem_cell_get(np, "reset-source");
if (IS_ERR(wd->reset_source_cell)) {
- dev_warn(dev, "No reset source info available: %pe\n", wd->reset_source_cell);
- goto out;
+ if (PTR_ERR(wd->reset_source_cell) != -EPROBE_DEFER)
+ dev_warn(dev, "No reset source info available: %pe\n",
+ wd->reset_source_cell);
+ wd->reset_source_cell = NULL;
}
-out:
- dev_info(dev, "probed\n");
- return 0;
+ wd->cant_disable = of_property_read_bool(np, "barebox,cant-disable");
+
+ return watchdog_register(wdd);
}
@@ -74,8 +67,9 @@ static __maybe_unused struct of_device_id sandbox_watchdog_dt_ids[] = {
{ .compatible = "barebox,sandbox-watchdog" },
{ /* sentinel */ }
};
+MODULE_DEVICE_TABLE(of, sandbox_watchdog_dt_ids);
-static struct driver_d sandbox_watchdog_drv = {
+static struct driver sandbox_watchdog_drv = {
.name = "sandbox-watchdog",
.of_compatible = sandbox_watchdog_dt_ids,
.probe = sandbox_watchdog_probe,