* [PATCH] ARM: bootm: Fix free_mem calculation when initrd is given
From: Sascha Hauer @ 2016-10-18 7:50 UTC (permalink / raw)
To: Barebox List
When a initrd is given we calculate the next free memory position
as:
free_mem = PAGE_ALIGN(initrd_end);
This is wrong when initrd_end exactly falls on a page boundary.
In this case PAGE_ALIGN() does nothing and free_mem becomes
initrd_end and the following bootm_load_devicetree() and thus
booting fails with -ENOMEM.
Fix this by correctly advancing to the next free memory position.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/lib/bootm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 56663fe..9f3d950 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -158,7 +158,7 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int
initrd_start = data->initrd_res->start;
initrd_end = data->initrd_res->end;
initrd_size = resource_size(data->initrd_res);
- free_mem = PAGE_ALIGN(initrd_end);
+ free_mem = PAGE_ALIGN(initrd_end + 1);
}
ret = bootm_load_devicetree(data, free_mem);
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* Re: [PATCH 4/4] mci: add MBR write and read function to block devices
From: Sascha Hauer @ 2016-10-18 6:23 UTC (permalink / raw)
To: Michael Grzeschik; +Cc: barebox
In-Reply-To: <20161017132923.31834-5-m.grzeschik@pengutronix.de>
On Mon, Oct 17, 2016 at 03:29:23PM +0200, Michael Grzeschik wrote:
> With this patch it is possible to write an mbr partition table to the
> mci block device. By setting the device property "dos_partitions" of the
> mmc device node, it is possible to write back the new partition layout
> in the common cmdlinepart notation. The property can also be read back.
>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
> drivers/mci/mci-core.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 122 insertions(+)
>
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 4e176f7..c0013a1 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -33,9 +33,11 @@
> #include <asm-generic/div64.h>
> #include <asm/byteorder.h>
> #include <block.h>
> +#include <fcntl.h>
> #include <disks.h>
> #include <of.h>
> #include <linux/err.h>
> +#include <cmdlinepart.h>
>
> #define MAX_BUFFER_NUMBER 0xffffffff
>
> @@ -1527,6 +1529,122 @@ static void mci_info(struct device_d *dev)
> extract_mtd_year(mci));
> }
>
> +static char *print_size(uint64_t s)
> +{
> + if (!(s & ((1 << 20) - 1)))
> + return basprintf("%lldM", s >> 20);
> + if (!(s & ((1 << 10) - 1)))
> + return basprintf("%lldk", s >> 10);
> + return basprintf("0x%lld", s);
s/lld/llx/
> +}
> +
> +static int print_part(char *buf, int bufsize, struct cdev *cdev, int is_last)
> +{
> + char *size = print_size(cdev->size);
> + int ret;
> +
> + if (!size) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + ret = snprintf(buf, bufsize, "%s(%s)%s", size,
> + cdev->partname,
> + is_last ? "" : ",");
> +out:
> + free(size);
> +
> + return ret;
> +}
> +
> +static int print_parts(char *buf, int bufsize, struct mci *mci)
> +{
> + struct cdev *cdev, *ct;
> + int ret = 0;
> +
> + list_for_each_entry_safe(cdev, ct, &mci->dev.cdevs, devices_list) {
safe_?
> + if ((cdev->flags & DEVFS_IS_PARTITION) &&
> + (cdev->flags & DEVFS_PARTITION_IN_PT)) {
> + int now;
> + int is_last = 0;
> + struct list_head *nh = (cdev)->devices_list.next;
> + struct cdev *next = container_of(nh, typeof(*(cdev)), devices_list);
> +
> + if (list_is_last(&cdev->devices_list, &mci->dev.cdevs) ||
> + !(next->flags & DEVFS_PARTITION_IN_PT))
> + is_last = 1;
Is this test safe? What if the next partition does not have the
DEVFS_PARTITION_IN_PT flag set, but the one after that has? Maybe you
have to count the number of partitions in a first pass.
> +
> + now = print_part(buf, bufsize, cdev, is_last);
> + if (now < 0)
> + return now;
> +
> + if (buf && bufsize) {
> + buf += now;
> + bufsize -= now;
> + }
> + ret += now;
> + }
> + }
> +
> + return ret;
> +}
> +
> +static const char *mci_partition_get(struct device_d *dev, struct param_d *p)
> +{
> + struct mci *mci = container_of(dev, struct mci, dev);
> + int len = 0;
> +
> + free(p->value);
> +
> + len = print_parts(NULL, 0, mci);
> + p->value = xzalloc(len + 1);
> + print_parts(p->value, len + 1, mci);
> +
> + return p->value;
> +}
> +
> +#ifdef CONFIG_BLOCK_WRITE
> +static int mci_partition_set(struct device_d *dev, struct param_d *p, const char *val)
> +{
> + struct mci *mci = container_of(dev, struct mci, dev);
> + struct cdev *cdev, *ct;
> + int ret;
> +
> + if (!val)
> + return -EINVAL;
> +
> + /* remove all partition cdevs with DEVFS_IS_PARTITION set */
> + list_for_each_entry_safe(cdev, ct, &mci->dev.cdevs, devices_list) {
> + if ((cdev->flags & DEVFS_IS_PARTITION) &&
> + (cdev->flags & DEVFS_PARTITION_IN_PT))
> + ret = devfs_del_partition(cdev->name);
> + if (ret)
> + return ret;
> + }
> +
> + /* read back the prepared partition layot from dos_partitions param */
s/layot/layout/
> + ret = cmdlinepart_do_parse(mci->cdevname, val, mci->capacity,
> + CMDLINEPART_ADD_DEVNAME | CMDLINEPART_ADD_TO_PT);
> + if (ret)
> + return ret;
> +
> + /* write the MBR partition layout based on cdevs with DEVFS_IS_PARTITION set */
> + for (int i = 0; i < mci->nr_parts; i++) {
> + struct mci_part *part = &mci->part[i];
> + if (part->area_type == MMC_BLK_DATA_AREA_MAIN) {
> + ret = write_dos_partition_table(&part->blk,
> + &mci->dev.cdevs);
> + if (ret != 0) {
> + dev_warn(&mci->dev, "Could not write partition table\n");
> + return ret;
> + }
> + }
> + }
> +
> + return ret;
> +}
> +#endif
> +
> /**
> * Check if the MCI card is already probed
> * @param mci MCI device instance
> @@ -1786,6 +1904,10 @@ int mci_register(struct mci_host *host)
> mci->param_probe = dev_add_param_bool(&mci->dev, "probe",
> mci_set_probe, NULL, &mci->probe, mci);
>
> +#ifdef CONFIG_BLOCK_WRITE
> + dev_add_param(&mci->dev, "dos_partitions", mci_partition_set, mci_partition_get, 0);
> +#endif
Use IS_ENABLED()
Other than that this code should be attached to parse_partition_table()
rather than making this mci specific.
We probably can safely write a dos partition table to an unpartitioned
device, but should refuse to create/manipulate a dos partition table
when a EFI partition table exists.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* Re: [PATCH 3/4] partitions/dos: add function to write partition table
From: Sascha Hauer @ 2016-10-18 6:07 UTC (permalink / raw)
To: Michael Grzeschik; +Cc: barebox
In-Reply-To: <20161017132923.31834-4-m.grzeschik@pengutronix.de>
Hi Michael,
On Mon, Oct 17, 2016 at 03:29:22PM +0200, Michael Grzeschik wrote:
> The function can be used to write an partition layout to the block device
> based on its cdev layout. Only cdevs with flag DEVFS_PARTITION_IN_PT set
> get written. The function also adds an static offset of 0x200000 to
> ensure the mbr and bootloader will not be overwritten.
>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
> common/partitions/dos.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++
> include/disks.h | 1 +
> 2 files changed, 72 insertions(+)
>
> diff --git a/common/partitions/dos.c b/common/partitions/dos.c
> index 5f08e25..d7fa538 100644
> --- a/common/partitions/dos.c
> +++ b/common/partitions/dos.c
> @@ -256,6 +256,77 @@ static void dos_partition(void *buf, struct block_device *blk,
> &dsp->signature, "%08x", dsp);
> }
>
> +static inline void hdimage_setup_chs(unsigned int lba, unsigned char *chs)
> +{
> + const unsigned int hpc = 255;
> + const unsigned int spt = 63;
> + unsigned int s, c;
> +
> + chs[0] = (lba/spt)%hpc;
Please run checkpatch over this. There are some stylistic flaws like
missing whitespaces left and right of operators.
> + c = (lba/(spt * hpc));
> + s = (lba > 0) ?(lba%spt + 1) : 0;
> + chs[1] = ((c & 0x300) >> 2) | (s & 0xff);
> + chs[2] = (c & 0xff);
> +}
> +
> +int write_dos_partition_table(struct block_device *blk, struct list_head *cdevs)
> +{
> + char part_table[6+4*sizeof(struct partition_entry)+2];
> + struct cdev *cdev, *ct;
> + void *buf;
> + int ret;
> + int n = 0;
> + char *ptr;
> +
> + /* prepare partition table entry */
> + ptr = part_table;
> + memset(ptr, 0, sizeof(part_table));
> +
> + /* skip disk signature */
> + ptr += 6;
It's even more important to skip this in the output buffer. This code
should not change the disk signature.
> + list_for_each_entry_safe(cdev, ct, cdevs, devices_list) {
Why _safe? You do not remove entries, do you?
> + if ((cdev->flags & DEVFS_IS_PARTITION) &&
> + (cdev->flags & DEVFS_PARTITION_IN_PT)) {
In a multiline if clause the second line should either start directly
under the opening brace or indented with at least two more tabs than the
opening if(), but using the same indention level as the conditional code
makes it hard to read.
> + struct partition_entry *entry;
Instead of the silent test below, do a:
if (n == 4) {
pr_warn("Only 4 partitions written to MBR\n");
break;
}
> + entry = (struct partition_entry *)
> + (ptr + n * sizeof(struct partition_entry));
> +
> + /* add static offset to skip the mbr and bootloader */
> + cdev->offset += 4096 * SECTOR_SIZE;
> +
> + entry->type = 0x83;
> + entry->partition_start = cdev->offset / SECTOR_SIZE;
> + entry->partition_size = cdev->size / SECTOR_SIZE;
We should have a test if offset and/or size exceed the 32bit limit.
> +
> + hdimage_setup_chs(entry->partition_start,
> + entry->chs_begin);
> + hdimage_setup_chs(entry->partition_start +
> + entry->partition_size - 1,
> + entry->chs_end);
> + n++;
> + }
> + if (n == 4)
> + break;
> + }
> +
> + ptr += 4 * sizeof(struct partition_entry);
> + ptr[0] = 0x55;
> + ptr[1] = 0xaa;
> +
> + buf = read_mbr(blk);
> + if (!buf)
> + return -EIO;
You could move this to the top of the function and directly manipulate
the input buffer.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* Re: [PATCH] of: fix typos
From: Sascha Hauer @ 2016-10-18 5:40 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
In-Reply-To: <20161017115758.7778-1-antonynpavlov@gmail.com>
On Mon, Oct 17, 2016 at 02:57:58PM +0300, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> drivers/of/base.c | 2 +-
> drivers/of/fdt.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* Re: [PATCH v3 1/3] reset: import socfpga-reset driver from linux
From: Sascha Hauer @ 2016-10-18 5:39 UTC (permalink / raw)
To: Steffen Trumtrar; +Cc: barebox
In-Reply-To: <20161017075052.30802-1-s.trumtrar@pengutronix.de>
On Mon, Oct 17, 2016 at 09:50:50AM +0200, Steffen Trumtrar wrote:
> Port the linux v4.8-rc1 reset-socfpga driver to barebox.
>
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
> drivers/reset/Makefile | 1 +
> drivers/reset/reset-socfpga.c | 124 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 125 insertions(+)
> create mode 100644 drivers/reset/reset-socfpga.c
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* Re: Loading kernel issues
From: Sascha Hauer @ 2016-10-18 5:37 UTC (permalink / raw)
To: Javier Fileiv; +Cc: barebox
In-Reply-To: <CABvwO2ARpHSzYE6Y3JrfFAQ2jEzw3EXfP36goL6kPogcBbNLKQ@mail.gmail.com>
Hi Javier,
On Sun, Oct 16, 2016 at 11:06:15PM +0200, Javier Fileiv wrote:
> Hi everyone, I've just flashed barebox on my Mini2440. I have 2
> questions/issues now
>
> 1) When trying to load the kernel from TFTP, everything is ok but when
> it's trying to mount the rootfs something is not working, even though
> I set the rootdelay param to 5 secs.
>
> 2) I tried also the boot from nand and is working just fine, but there
> no is auto boot when reseting the board... it just give me the barebox
> prompt each time, and if i run from there boot nand it works OK, but
> no automaGically. :)
>
> Any suggestions? Thank you very much
>
>
> LOG FOR TFTP BOOT:
>
> mini2440:/ boot tftp
> warning: No MAC address set. Using random address A2:50:1F:24:DF:AB
> phy0: Link is up - 100/Full
> T DHCP client bound to address 192.168.0.15
> TFTP from server 192.168.0.10 ('uImage-mini2440' -> '/dev/ram0.kernel')
> #################################################################
> #################################################################
> #################################################################
> #################################################################
> #################################################################
> ################################################
> booting kernel of type uimage from /dev/ram0.kernel
> Verifying Checksum ... OK
> Image Name: Linux-3.16.7-ptx-master
> Created: 2016-10-13 20:23:14 UTC
> Image Type: <NULL> <NULL> <NULL> (<NULL>)
> Data Size: 1910288 Bytes = 1.8 MB
> Load Address: 30008000
> Entry Point: 30008000
> OK
> commandline: console=ttySAC0,115200 mini2440=0tbc rootdelay=5 ip=dhcp
> root=/dev/nfs nfsroot=/path/to/nfs/root,v3,tcp noinitrd
You have to replace nfsroot=/path/to/nfs/root with some valid path.
Since your dhcp server does not pass a root server ip you'll have to add
that aswell, so your nfsroot should look like
nfsroot=192.168.x.y:/path/to/nfsroot. Try 'edit /env/config' to edit
the parameter to your needs. Do not forget saveenv afterwards.
To boot from Nand also edit /env/config and adjust the kernel_loc and
rootfs_loc variables.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* [PATCH 0/4] Add support to modify mbr partition layout
From: Michael Grzeschik @ 2016-10-17 13:29 UTC (permalink / raw)
To: barebox
This patchset adds the param dos_partitions to the mci device
node. By setting this param with the standard cmdlinepart notation,
it is possible to rewrite the MBR partition layout on runtime.
Michael Grzeschik (4):
partitions: add DEVFS_PARTITION_IN_PT flag
cmdlinepart: add option to set DEVFS_PARTITION_IN_PT flag
partitions/dos: add function to write partition table
mci: add MBR write and read function to block devices
common/partitions.c | 2 +-
common/partitions/dos.c | 71 ++++++++++++++++++++++++++++
drivers/mci/mci-core.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++
include/cmdlinepart.h | 1 +
include/disks.h | 1 +
include/driver.h | 1 +
lib/cmdlinepart.c | 3 ++
7 files changed, 200 insertions(+), 1 deletion(-)
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* [PATCH 4/4] mci: add MBR write and read function to block devices
From: Michael Grzeschik @ 2016-10-17 13:29 UTC (permalink / raw)
To: barebox
In-Reply-To: <20161017132923.31834-1-m.grzeschik@pengutronix.de>
With this patch it is possible to write an mbr partition table to the
mci block device. By setting the device property "dos_partitions" of the
mmc device node, it is possible to write back the new partition layout
in the common cmdlinepart notation. The property can also be read back.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
drivers/mci/mci-core.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 122 insertions(+)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 4e176f7..c0013a1 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -33,9 +33,11 @@
#include <asm-generic/div64.h>
#include <asm/byteorder.h>
#include <block.h>
+#include <fcntl.h>
#include <disks.h>
#include <of.h>
#include <linux/err.h>
+#include <cmdlinepart.h>
#define MAX_BUFFER_NUMBER 0xffffffff
@@ -1527,6 +1529,122 @@ static void mci_info(struct device_d *dev)
extract_mtd_year(mci));
}
+static char *print_size(uint64_t s)
+{
+ if (!(s & ((1 << 20) - 1)))
+ return basprintf("%lldM", s >> 20);
+ if (!(s & ((1 << 10) - 1)))
+ return basprintf("%lldk", s >> 10);
+ return basprintf("0x%lld", s);
+}
+
+static int print_part(char *buf, int bufsize, struct cdev *cdev, int is_last)
+{
+ char *size = print_size(cdev->size);
+ int ret;
+
+ if (!size) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ ret = snprintf(buf, bufsize, "%s(%s)%s", size,
+ cdev->partname,
+ is_last ? "" : ",");
+out:
+ free(size);
+
+ return ret;
+}
+
+static int print_parts(char *buf, int bufsize, struct mci *mci)
+{
+ struct cdev *cdev, *ct;
+ int ret = 0;
+
+ list_for_each_entry_safe(cdev, ct, &mci->dev.cdevs, devices_list) {
+ if ((cdev->flags & DEVFS_IS_PARTITION) &&
+ (cdev->flags & DEVFS_PARTITION_IN_PT)) {
+ int now;
+ int is_last = 0;
+ struct list_head *nh = (cdev)->devices_list.next;
+ struct cdev *next = container_of(nh, typeof(*(cdev)), devices_list);
+
+ if (list_is_last(&cdev->devices_list, &mci->dev.cdevs) ||
+ !(next->flags & DEVFS_PARTITION_IN_PT))
+ is_last = 1;
+
+ now = print_part(buf, bufsize, cdev, is_last);
+ if (now < 0)
+ return now;
+
+ if (buf && bufsize) {
+ buf += now;
+ bufsize -= now;
+ }
+ ret += now;
+ }
+ }
+
+ return ret;
+}
+
+static const char *mci_partition_get(struct device_d *dev, struct param_d *p)
+{
+ struct mci *mci = container_of(dev, struct mci, dev);
+ int len = 0;
+
+ free(p->value);
+
+ len = print_parts(NULL, 0, mci);
+ p->value = xzalloc(len + 1);
+ print_parts(p->value, len + 1, mci);
+
+ return p->value;
+}
+
+#ifdef CONFIG_BLOCK_WRITE
+static int mci_partition_set(struct device_d *dev, struct param_d *p, const char *val)
+{
+ struct mci *mci = container_of(dev, struct mci, dev);
+ struct cdev *cdev, *ct;
+ int ret;
+
+ if (!val)
+ return -EINVAL;
+
+ /* remove all partition cdevs with DEVFS_IS_PARTITION set */
+ list_for_each_entry_safe(cdev, ct, &mci->dev.cdevs, devices_list) {
+ if ((cdev->flags & DEVFS_IS_PARTITION) &&
+ (cdev->flags & DEVFS_PARTITION_IN_PT))
+ ret = devfs_del_partition(cdev->name);
+ if (ret)
+ return ret;
+ }
+
+ /* read back the prepared partition layot from dos_partitions param */
+ ret = cmdlinepart_do_parse(mci->cdevname, val, mci->capacity,
+ CMDLINEPART_ADD_DEVNAME | CMDLINEPART_ADD_TO_PT);
+ if (ret)
+ return ret;
+
+ /* write the MBR partition layout based on cdevs with DEVFS_IS_PARTITION set */
+ for (int i = 0; i < mci->nr_parts; i++) {
+ struct mci_part *part = &mci->part[i];
+ if (part->area_type == MMC_BLK_DATA_AREA_MAIN) {
+ ret = write_dos_partition_table(&part->blk,
+ &mci->dev.cdevs);
+ if (ret != 0) {
+ dev_warn(&mci->dev, "Could not write partition table\n");
+ return ret;
+ }
+ }
+ }
+
+ return ret;
+}
+#endif
+
/**
* Check if the MCI card is already probed
* @param mci MCI device instance
@@ -1786,6 +1904,10 @@ int mci_register(struct mci_host *host)
mci->param_probe = dev_add_param_bool(&mci->dev, "probe",
mci_set_probe, NULL, &mci->probe, mci);
+#ifdef CONFIG_BLOCK_WRITE
+ dev_add_param(&mci->dev, "dos_partitions", mci_partition_set, mci_partition_get, 0);
+#endif
+
if (IS_ERR(mci->param_probe) && PTR_ERR(mci->param_probe) != -ENOSYS) {
ret = PTR_ERR(mci->param_probe);
dev_dbg(&mci->dev, "Failed to add 'probe' parameter to the MCI device\n");
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH 3/4] partitions/dos: add function to write partition table
From: Michael Grzeschik @ 2016-10-17 13:29 UTC (permalink / raw)
To: barebox
In-Reply-To: <20161017132923.31834-1-m.grzeschik@pengutronix.de>
The function can be used to write an partition layout to the block device
based on its cdev layout. Only cdevs with flag DEVFS_PARTITION_IN_PT set
get written. The function also adds an static offset of 0x200000 to
ensure the mbr and bootloader will not be overwritten.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
common/partitions/dos.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++
include/disks.h | 1 +
2 files changed, 72 insertions(+)
diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 5f08e25..d7fa538 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -256,6 +256,77 @@ static void dos_partition(void *buf, struct block_device *blk,
&dsp->signature, "%08x", dsp);
}
+static inline void hdimage_setup_chs(unsigned int lba, unsigned char *chs)
+{
+ const unsigned int hpc = 255;
+ const unsigned int spt = 63;
+ unsigned int s, c;
+
+ chs[0] = (lba/spt)%hpc;
+ c = (lba/(spt * hpc));
+ s = (lba > 0) ?(lba%spt + 1) : 0;
+ chs[1] = ((c & 0x300) >> 2) | (s & 0xff);
+ chs[2] = (c & 0xff);
+}
+
+int write_dos_partition_table(struct block_device *blk, struct list_head *cdevs)
+{
+ char part_table[6+4*sizeof(struct partition_entry)+2];
+ struct cdev *cdev, *ct;
+ void *buf;
+ int ret;
+ int n = 0;
+ char *ptr;
+
+ /* prepare partition table entry */
+ ptr = part_table;
+ memset(ptr, 0, sizeof(part_table));
+
+ /* skip disk signature */
+ ptr += 6;
+ list_for_each_entry_safe(cdev, ct, cdevs, devices_list) {
+ if ((cdev->flags & DEVFS_IS_PARTITION) &&
+ (cdev->flags & DEVFS_PARTITION_IN_PT)) {
+ struct partition_entry *entry;
+ entry = (struct partition_entry *)
+ (ptr + n * sizeof(struct partition_entry));
+
+ /* add static offset to skip the mbr and bootloader */
+ cdev->offset += 4096 * SECTOR_SIZE;
+
+ entry->type = 0x83;
+ entry->partition_start = cdev->offset / SECTOR_SIZE;
+ entry->partition_size = cdev->size / SECTOR_SIZE;
+
+ hdimage_setup_chs(entry->partition_start,
+ entry->chs_begin);
+ hdimage_setup_chs(entry->partition_start +
+ entry->partition_size - 1,
+ entry->chs_end);
+ n++;
+ }
+ if (n == 4)
+ break;
+ }
+
+ ptr += 4 * sizeof(struct partition_entry);
+ ptr[0] = 0x55;
+ ptr[1] = 0xaa;
+
+ buf = read_mbr(blk);
+ if (!buf)
+ return -EIO;
+
+ /* manipulate block with prepared partition table */
+ memcpy(buf + 440, part_table, sizeof(part_table));
+
+ ret = write_mbr(blk, buf);
+
+ free(buf);
+
+ return ret;
+}
+
static struct partition_parser dos = {
.parse = dos_partition,
.type = filetype_mbr,
diff --git a/include/disks.h b/include/disks.h
index 9932750..432fb23 100644
--- a/include/disks.h
+++ b/include/disks.h
@@ -37,5 +37,6 @@ struct partition_entry {
} __attribute__ ((packed));
extern int parse_partition_table(struct block_device*);
+extern int write_dos_partition_table(struct block_device *blk, struct list_head *cdevs);
#endif /* DISKS_H */
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH 2/4] cmdlinepart: add option to set DEVFS_PARTITION_IN_PT flag
From: Michael Grzeschik @ 2016-10-17 13:29 UTC (permalink / raw)
To: barebox
In-Reply-To: <20161017132923.31834-1-m.grzeschik@pengutronix.de>
With this option it is possible to flag cdev partitions, which will also
be written to the partition table of its backing device.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
include/cmdlinepart.h | 1 +
lib/cmdlinepart.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/include/cmdlinepart.h b/include/cmdlinepart.h
index bf8cdfa..3363a74 100644
--- a/include/cmdlinepart.h
+++ b/include/cmdlinepart.h
@@ -2,6 +2,7 @@
#define __CMD_LINE_PART_H
#define CMDLINEPART_ADD_DEVNAME (1 << 0)
+#define CMDLINEPART_ADD_TO_PT (2 << 0)
int cmdlinepart_do_parse_one(const char *devname, const char *partstr,
const char **endp, loff_t *offset,
diff --git a/lib/cmdlinepart.c b/lib/cmdlinepart.c
index d7d4441..8633e82 100644
--- a/lib/cmdlinepart.c
+++ b/lib/cmdlinepart.c
@@ -81,6 +81,9 @@ int cmdlinepart_do_parse_one(const char *devname, const char *partstr,
end = (char *)(partstr + 2);
}
+ if (partition_flags & CMDLINEPART_ADD_TO_PT)
+ flags |= DEVFS_PARTITION_IN_PT;
+
if (endp)
*endp = end;
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH 1/4] partitions: add DEVFS_PARTITION_IN_PT flag
From: Michael Grzeschik @ 2016-10-17 13:29 UTC (permalink / raw)
To: barebox
In-Reply-To: <20161017132923.31834-1-m.grzeschik@pengutronix.de>
This flag is used to represent the current status of the partition. When
it is set, the current partition layout is also available in the
partition table of the device. We use it after the partition table was
parsed.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
common/partitions.c | 2 +-
include/driver.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/partitions.c b/common/partitions.c
index 69a2b1f..62ffaef 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -57,7 +57,7 @@ static int register_one_partition(struct block_device *blk,
dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
partition_name, blk->cdev.name);
cdev = devfs_add_partition(blk->cdev.name,
- start, size, 0, partition_name);
+ start, size, DEVFS_PARTITION_IN_PT, partition_name);
if (IS_ERR(cdev)) {
ret = PTR_ERR(cdev);
goto out;
diff --git a/include/driver.h b/include/driver.h
index 80aa8d8..4ff2f77 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -482,6 +482,7 @@ int cdev_erase(struct cdev *cdev, loff_t count, loff_t offset);
#define DEVFS_PARTITION_READONLY (1U << 1)
#define DEVFS_IS_PARTITION (1 << 2)
#define DEVFS_IS_CHARACTER_DEV (1 << 3)
+#define DEVFS_PARTITION_IN_PT (1 << 4)
struct cdev *devfs_add_partition(const char *devname, loff_t offset,
loff_t size, unsigned int flags, const char *name);
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH] of: fix typos
From: Antony Pavlov @ 2016-10-17 11:57 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/of/base.c | 2 +-
drivers/of/fdt.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 1e6c33d..767d4e1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1631,7 +1631,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
EXPORT_SYMBOL(of_get_next_available_child);
/**
- * of_get_next_child - Iterate a node childs
+ * of_get_next_child - Iterate a node children
* @node: parent node
* @prev: previous child of the parent node, or NULL to get first
*
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index b2253aa..614e136 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -525,7 +525,7 @@ void of_clean_reserve_map(void)
* fdt_add_reserve_map - Add reserve map entries to a devicetree binary
* @__fdt: The devicetree blob
*
- * This adds the reservemap entries previously colllected in
+ * This adds the reservemap entries previously collected in
* of_add_reserve_entry() to a devicetree binary blob. This also
* adds the devicetree itself to the reserved list, so after calling
* this function the tree should not be relocated anymore.
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH v3 2/3] watchdog: add designware driver
From: Steffen Trumtrar @ 2016-10-17 7:50 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
In-Reply-To: <20161017075052.30802-1-s.trumtrar@pengutronix.de>
Port the linux v4.8-rc1 Synopsys DesignWare watchdog driver to barebox.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
drivers/watchdog/Kconfig | 6 ++
drivers/watchdog/Makefile | 1 +
drivers/watchdog/dw_wdt.c | 193 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 200 insertions(+)
create mode 100644 drivers/watchdog/dw_wdt.c
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 60a56bf4b030..63fb1a8c5701 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -16,6 +16,12 @@ config WATCHDOG_DAVINCI
help
Add support for watchdog on the TI Davinci SoC.
+config WATCHDOG_DW
+ bool "Synopsys DesignWare watchdog"
+ select RESET_CONTROLLER
+ help
+ Add support for the Synopsys DesignWare watchdog timer.
+
config WATCHDOG_MXS28
bool "i.MX28"
depends on ARCH_IMX28
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index e3afe1c27efb..5fca4c368c40 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -2,5 +2,6 @@ obj-$(CONFIG_WATCHDOG) += wd_core.o
obj-$(CONFIG_WATCHDOG_DAVINCI) += davinci_wdt.o
obj-$(CONFIG_WATCHDOG_OMAP) += omap_wdt.o
obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
+obj-$(CONFIG_WATCHDOG_DW) += dw_wdt.o
obj-$(CONFIG_WATCHDOG_JZ4740) += jz4740.o
obj-$(CONFIG_WATCHDOG_IMX_RESET_SOURCE) += imxwd.o
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
new file mode 100644
index 000000000000..fa2752896c2f
--- /dev/null
+++ b/drivers/watchdog/dw_wdt.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2010-2011 Picochip Ltd., Jamie Iles
+ * http://www.picochip.com
+ *
+ * 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 file implements a driver for the Synopsys DesignWare watchdog device
+ * in the many subsystems. The watchdog has 16 different timeout periods
+ * and these are a function of the input clock frequency.
+ *
+ * The DesignWare watchdog cannot be stopped once it has been started so we
+ * do not implement a stop function. The watchdog core will continue to send
+ * heartbeat requests after the watchdog device has been closed.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <of.h>
+#include <restart.h>
+#include <watchdog.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/reset.h>
+
+#define WDOG_CONTROL_REG_OFFSET 0x00
+#define WDOG_CONTROL_REG_WDT_EN_MASK 0x01
+#define WDOG_TIMEOUT_RANGE_REG_OFFSET 0x04
+#define WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT 4
+#define WDOG_CURRENT_COUNT_REG_OFFSET 0x08
+#define WDOG_COUNTER_RESTART_REG_OFFSET 0x0c
+#define WDOG_COUNTER_RESTART_KICK_VALUE 0x76
+
+/* The maximum TOP (timeout period) value that can be set in the watchdog. */
+#define DW_WDT_MAX_TOP 15
+
+#define DW_WDT_DEFAULT_SECONDS 30
+
+struct dw_wdt {
+ void __iomem *regs;
+ struct clk *clk;
+ struct restart_handler restart;
+ struct watchdog wdd;
+ struct reset_control *rst;
+};
+
+#define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd)
+
+static inline int dw_wdt_top_in_seconds(struct dw_wdt *dw_wdt, unsigned top)
+{
+ /*
+ * There are 16 possible timeout values in 0..15 where the number of
+ * cycles is 2 ^ (16 + i) and the watchdog counts down.
+ */
+ return (1U << (16 + top)) / clk_get_rate(dw_wdt->clk);
+}
+
+static int dw_wdt_start(struct watchdog *wdd)
+{
+ struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
+
+ writel(WDOG_CONTROL_REG_WDT_EN_MASK,
+ dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
+
+ return 0;
+}
+
+static int dw_wdt_stop(struct watchdog *wdd)
+{
+ struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
+
+ if (IS_ERR(dw_wdt->rst)) {
+ dev_warn(dw_wdt->wdd.dev, "No reset line. Will not stop.\n");
+ return PTR_ERR(dw_wdt->rst);
+ }
+
+ reset_control_assert(dw_wdt->rst);
+ reset_control_deassert(dw_wdt->rst);
+
+ return 0;
+}
+
+static int dw_wdt_set_timeout(struct watchdog *wdd, unsigned int top_s)
+{
+ struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
+ int i, top_val = DW_WDT_MAX_TOP;
+
+ if (top_s == 0)
+ return dw_wdt_stop(wdd);
+
+ /*
+ * Iterate over the timeout values until we find the closest match. We
+ * always look for >=.
+ */
+ for (i = 0; i <= DW_WDT_MAX_TOP; ++i) {
+ if (dw_wdt_top_in_seconds(dw_wdt, i) >= top_s) {
+ top_val = i;
+ break;
+ }
+ }
+
+ /*
+ * Set the new value in the watchdog. Some versions of dw_wdt
+ * have have TOPINIT in the TIMEOUT_RANGE register (as per
+ * CP_WDT_DUAL_TOP in WDT_COMP_PARAMS_1). On those we
+ * effectively get a pat of the watchdog right here.
+ */
+ writel(top_val | top_val << WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT,
+ dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
+
+ dw_wdt_start(wdd);
+
+ return 0;
+}
+
+static void __noreturn dw_wdt_restart_handle(struct restart_handler *rst)
+{
+ struct dw_wdt *dw_wdt;
+
+ dw_wdt = container_of(rst, struct dw_wdt, restart);
+
+ dw_wdt->wdd.set_timeout(&dw_wdt->wdd, -1);
+
+ mdelay(1000);
+
+ hang();
+}
+
+static int dw_wdt_drv_probe(struct device_d *dev)
+{
+ struct watchdog *wdd;
+ struct dw_wdt *dw_wdt;
+ struct resource *mem;
+ int ret;
+
+ dw_wdt = xzalloc(sizeof(*dw_wdt));
+
+ mem = dev_request_mem_resource(dev, 0);
+ dw_wdt->regs = IOMEM(mem->start);
+ if (IS_ERR(dw_wdt->regs))
+ return PTR_ERR(dw_wdt->regs);
+
+ dw_wdt->clk = clk_get(dev, NULL);
+ if (IS_ERR(dw_wdt->clk))
+ return PTR_ERR(dw_wdt->clk);
+
+ ret = clk_enable(dw_wdt->clk);
+ if (ret)
+ return ret;
+
+ dw_wdt->rst = reset_control_get(dev, "dw-wdt");
+ if (IS_ERR(dw_wdt->rst))
+ dev_warn(dev, "No reset lines. Will not be able to stop once started.\n");
+
+ wdd = &dw_wdt->wdd;
+ wdd->name = "dw_wdt";
+ wdd->dev = dev;
+ wdd->set_timeout = dw_wdt_set_timeout;
+
+ ret = watchdog_register(wdd);
+ if (ret)
+ goto out_disable_clk;
+
+ dw_wdt->restart.name = "dw_wdt";
+ dw_wdt->restart.restart = dw_wdt_restart_handle;
+
+ ret = restart_handler_register(&dw_wdt->restart);
+ if (ret)
+ dev_warn(dev, "cannot register restart handler\n");
+
+ if (!IS_ERR(dw_wdt->rst))
+ reset_control_deassert(dw_wdt->rst);
+
+ return 0;
+
+out_disable_clk:
+ clk_disable(dw_wdt->clk);
+ return ret;
+}
+
+static struct of_device_id dw_wdt_of_match[] = {
+ { .compatible = "snps,dw-wdt", },
+ { /* sentinel */ }
+};
+
+static struct driver_d dw_wdt_driver = {
+ .probe = dw_wdt_drv_probe,
+ .of_compatible = DRV_OF_COMPAT(dw_wdt_of_match),
+};
+device_platform_driver(dw_wdt_driver);
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH v3 1/3] reset: import socfpga-reset driver from linux
From: Steffen Trumtrar @ 2016-10-17 7:50 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Port the linux v4.8-rc1 reset-socfpga driver to barebox.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
drivers/reset/Makefile | 1 +
drivers/reset/reset-socfpga.c | 124 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 125 insertions(+)
create mode 100644 drivers/reset/reset-socfpga.c
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 1e2d83f2b995..52b10cd48055 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -1 +1,2 @@
obj-$(CONFIG_RESET_CONTROLLER) += core.o
+obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
new file mode 100644
index 000000000000..9214197e627d
--- /dev/null
+++ b/drivers/reset/reset-socfpga.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2014 Steffen Trumtrar <s.trumtrar@pengutronix.de>
+ *
+ * based on
+ * Allwinner SoCs Reset Controller driver
+ *
+ * Copyright 2013 Maxime Ripard
+ *
+ * Maxime Ripard <maxime.ripard@free-electrons.com>
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <linux/err.h>
+#include <linux/reset-controller.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+
+#define NR_BANKS 4
+
+struct socfpga_reset_data {
+ spinlock_t lock;
+ void __iomem *membase;
+ u32 modrst_offset;
+ struct reset_controller_dev rcdev;
+};
+
+static int socfpga_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct socfpga_reset_data *data = container_of(rcdev,
+ struct socfpga_reset_data,
+ rcdev);
+ int bank = id / BITS_PER_LONG;
+ int offset = id % BITS_PER_LONG;
+ unsigned long flags;
+ u32 reg;
+
+ spin_lock_irqsave(&data->lock, flags);
+
+ reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+ writel(reg | BIT(offset), data->membase + data->modrst_offset +
+ (bank * NR_BANKS));
+ spin_unlock_irqrestore(&data->lock, flags);
+
+ return 0;
+}
+
+static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct socfpga_reset_data *data = container_of(rcdev,
+ struct socfpga_reset_data,
+ rcdev);
+
+ int bank = id / BITS_PER_LONG;
+ int offset = id % BITS_PER_LONG;
+ unsigned long flags;
+ u32 reg;
+
+ spin_lock_irqsave(&data->lock, flags);
+
+ reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+ writel(reg & ~BIT(offset), data->membase + data->modrst_offset +
+ (bank * NR_BANKS));
+
+ spin_unlock_irqrestore(&data->lock, flags);
+
+ return 0;
+}
+
+static struct reset_control_ops socfpga_reset_ops = {
+ .assert = socfpga_reset_assert,
+ .deassert = socfpga_reset_deassert,
+};
+
+static int socfpga_reset_probe(struct device_d *dev)
+{
+ struct socfpga_reset_data *data;
+ struct resource *res;
+ struct device_node *np = dev->device_node;
+
+ data = xzalloc(sizeof(*data));
+
+ res = dev_request_mem_resource(dev, 0);
+ data->membase = IOMEM(res->start);
+ if (IS_ERR(data->membase))
+ return PTR_ERR(data->membase);
+
+ if (of_property_read_u32(np, "altr,modrst-offset", &data->modrst_offset)) {
+ dev_warn(dev, "missing altr,modrst-offset property, assuming 0x10!\n");
+ data->modrst_offset = 0x10;
+ }
+
+ spin_lock_init(&data->lock);
+
+ data->rcdev.nr_resets = NR_BANKS * BITS_PER_LONG;
+ data->rcdev.ops = &socfpga_reset_ops;
+ data->rcdev.of_node = np;
+
+ return reset_controller_register(&data->rcdev);
+}
+
+static const struct of_device_id socfpga_reset_dt_ids[] = {
+ { .compatible = "altr,rst-mgr", },
+ { /* sentinel */ },
+};
+
+static struct driver_d socfpga_reset_driver = {
+ .probe = socfpga_reset_probe,
+ .of_compatible = DRV_OF_COMPAT(socfpga_reset_dt_ids),
+};
+
+static int socfpga_reset_init(void)
+{
+ return platform_driver_register(&socfpga_reset_driver);
+}
+postcore_initcall(socfpga_reset_init);
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH v3 3/3] ARM: socfpga: dtsi: add dw-wdt reset lines
From: Steffen Trumtrar @ 2016-10-17 7:50 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
In-Reply-To: <20161017075052.30802-1-s.trumtrar@pengutronix.de>
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/dts/socfpga.dtsi | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/arm/dts/socfpga.dtsi b/arch/arm/dts/socfpga.dtsi
index d16758fdab46..66d7f21dc6a3 100644
--- a/arch/arm/dts/socfpga.dtsi
+++ b/arch/arm/dts/socfpga.dtsi
@@ -49,3 +49,13 @@
&f2s_sdram_ref_clk {
clock-frequency = <0>;
};
+
+&watchdog0 {
+ resets = <&rst L4WD0_RESET>;
+ reset-names = "dw-wdt";
+};
+
+&watchdog1 {
+ resets = <&rst L4WD1_RESET>;
+ reset-names = "dw-wdt";
+};
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* Re: [PATCH v2 2/3] watchdog: add designware driver
From: Steffen Trumtrar @ 2016-10-17 7:48 UTC (permalink / raw)
To: barebox
In-Reply-To: <20161014092715.4257-2-s.trumtrar@pengutronix.de>
On Fri, Oct 14, 2016 at 11:27:14AM +0200, Steffen Trumtrar wrote:
> Port the linux v4.8-rc1 Synopsys DesignWare watchdog driver to barebox.
>
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
> Changes since v1:
> - change usages of pr_warn in favor of dev_warn
>
> drivers/watchdog/Kconfig | 6 ++
> drivers/watchdog/Makefile | 1 +
> drivers/watchdog/dw_wdt.c | 193 ++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 200 insertions(+)
> create mode 100644 drivers/watchdog/dw_wdt.c
>
(...)
> +struct dw_wdt {
> + void __iomem *regs;
> + struct clk *clk;
> + struct restart_handler restart;
> + struct watchdog wdd;
> + struct reset_control *rst;
> +};
> +
(...)
> +static int dw_wdt_stop(struct watchdog *wdd)
> +{
> + struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
> +
> + if (IS_ERR(dw_wdt->rst)) {
> + dev_warn(dw_wdt->dev, "No reset line. Will not stop.\n");
^^^^^^^^^^^
Meh, I sent the wrong version :-(
Let's try again.
Regards,
Steffen
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* [PATCH] ARM: i.MX Freescale Sabrelite: Use correct device tree for dl variant
From: Sascha Hauer @ 2016-10-17 6:24 UTC (permalink / raw)
To: Barebox List
The i.MX6dl variant also uses the i.MX6q device tree which is wrong.
Use the correct one.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/boards/freescale-mx6-sabrelite/lowlevel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boards/freescale-mx6-sabrelite/lowlevel.c b/arch/arm/boards/freescale-mx6-sabrelite/lowlevel.c
index 3b51e01..c2d7a3c 100644
--- a/arch/arm/boards/freescale-mx6-sabrelite/lowlevel.c
+++ b/arch/arm/boards/freescale-mx6-sabrelite/lowlevel.c
@@ -53,9 +53,9 @@ static noinline void imx6dl_sabrelite_start(void)
imx6_uart_setup(uart);
pbl_set_putc(imx_uart_putc, uart);
- pr_debug("Freescale i.MX6q SabreLite\n");
+ pr_debug("Freescale i.MX6dl SabreLite\n");
- imx6q_barebox_entry(__dtb_imx6q_sabrelite_start);
+ imx6q_barebox_entry(__dtb_imx6dl_sabrelite_start);
}
ENTRY_FUNCTION(start_imx6dl_sabrelite, r0, r1, r2)
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* Re: How to configure and enable the barebox state?
From: Sascha Hauer @ 2016-10-14 9:58 UTC (permalink / raw)
To: Trostel Alain; +Cc: barebox@lists.infradead.org
In-Reply-To: <F6D4D53A3E6A8043A8517794EE9C52320CE989@HRSRV03.haslerrail.net>
Hi Alain,
On Thu, Oct 13, 2016 at 01:38:36PM +0000, Trostel Alain wrote:
> Hi,
>
> I would like to configure and enable the barebox state. My assumption is
> that I need to change the following device tree for my Phytec AM335x
> SOM:
>
> arch/arm/dts/am335x-phytec-phycore-som.dts
>
> But from the documentation
> (http://www.barebox.org/doc/latest/devicetree/bindings/barebox/barebox,state.html)
> it is not clear to me where exactly I need to add the variable node
> example.
You can put it anywhere in the device tree that is parsed by the device
parser. I would recommend putting it directly in the root node.
> Furthermore, I have check that the 'CONFIG_OFDEVICE' is
> enabled.
> So, where is the correct place to add the variable node configuration
> and what needs to be enabled in barebox?
for using the state framework you'll need:
CONFIG_STATE
CONFIG_STATE_DRV
CONFIG_CMD_STATE
If you want to use the bootchooser ontop of state you'll also need:
CONFIG_BOOTCHOOSER
CONFIG_CMD_BOOTCHOOSER
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* Re: Compressed DTB - builtin DTB
From: Sascha Hauer @ 2016-10-14 9:52 UTC (permalink / raw)
To: Daniel Krüger; +Cc: barebox
In-Reply-To: <03214122-b05b-fc45-1e32-ad2832ca36d3@systec-electronic.com>
Hi Daniel,
On Thu, Oct 13, 2016 at 12:32:31PM +0200, Daniel Krüger wrote:
> Hello,
>
> I'm currently porting our board support to device tree. Currently, I don't
> use multi-PBL, but include the device tree via CONFIG_BUILTIN_DTB. This
> works, but the DTB seems to be included twice in the image: once as plain
> DTB and once as compressed DTB. I think this isn't intended this way.
>
> Extract from System.map:
> 87e82b80 R __dtb_imx35_systec_hmi_start
> 87e82b80 R __dtb_start
> 87e8501c R __dtb_imx35_systec_hmi_end
> 87e85020 R __dtb_z_imx35_systec_hmi_start
> 87e85ad0 R __dtb_z_imx35_systec_hmi_end
> 87e85b00 B __bss_start
> 87e85b00 R __dtb_end
No, indeed that's not intended. Could you test the appended patch? It
should solve this.
>
> Just using the compressed DTB would be really good. Because it makes the
> image much smaller. However, how should that be done? The extract code might
> be simple. But I don't have an idea how to let the linker select the right
> version.
If you are using uncompressed binary you should switch to PBL support to
get a compressed binary. Then, if you are using PBL the dtb is
compressed already as part of the whole binary.
Sascha
------------------------------------8<--------------------------------
From c24a6bd6eabc3f73375080e6fc500aa955795a27 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Fri, 14 Oct 2016 11:42:00 +0200
Subject: [PATCH] gen-dtb-s: Put compressed dtb in different section
For builtin dtbs all compiled dtbs matching section .dtb.rodata.*
are collected in a single section. Since every dtb is compiled as
uncompressed and also as compressed binary each dtb ends up twice
in the section. Let's put the compressed variants in .dtbz.rodata.*
sections rather than .dtb.rodata.*.z so they end up in the binary
only once.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
scripts/gen-dtb-s | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
index 40c6085..4215461 100755
--- a/scripts/gen-dtb-s
+++ b/scripts/gen-dtb-s
@@ -58,7 +58,7 @@ fi
compressed=$(stat $dtb.lzo -c "%s")
uncompressed=$(stat $dtb -c "%s")
-echo ".section .dtb.rodata.${name}.z,\"a\""
+echo ".section .dtbz.rodata.${name},\"a\""
echo ".balign STRUCT_ALIGNMENT"
echo ".global __dtb_z_${name}_start"
echo "__dtb_z_${name}_start:"
--
2.9.3
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH v2 2/3] watchdog: add designware driver
From: Steffen Trumtrar @ 2016-10-14 9:27 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
In-Reply-To: <20161014092715.4257-1-s.trumtrar@pengutronix.de>
Port the linux v4.8-rc1 Synopsys DesignWare watchdog driver to barebox.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
Changes since v1:
- change usages of pr_warn in favor of dev_warn
drivers/watchdog/Kconfig | 6 ++
drivers/watchdog/Makefile | 1 +
drivers/watchdog/dw_wdt.c | 193 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 200 insertions(+)
create mode 100644 drivers/watchdog/dw_wdt.c
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 60a56bf4b030..63fb1a8c5701 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -16,6 +16,12 @@ config WATCHDOG_DAVINCI
help
Add support for watchdog on the TI Davinci SoC.
+config WATCHDOG_DW
+ bool "Synopsys DesignWare watchdog"
+ select RESET_CONTROLLER
+ help
+ Add support for the Synopsys DesignWare watchdog timer.
+
config WATCHDOG_MXS28
bool "i.MX28"
depends on ARCH_IMX28
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index e3afe1c27efb..5fca4c368c40 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -2,5 +2,6 @@ obj-$(CONFIG_WATCHDOG) += wd_core.o
obj-$(CONFIG_WATCHDOG_DAVINCI) += davinci_wdt.o
obj-$(CONFIG_WATCHDOG_OMAP) += omap_wdt.o
obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
+obj-$(CONFIG_WATCHDOG_DW) += dw_wdt.o
obj-$(CONFIG_WATCHDOG_JZ4740) += jz4740.o
obj-$(CONFIG_WATCHDOG_IMX_RESET_SOURCE) += imxwd.o
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
new file mode 100644
index 000000000000..6de2b84356dc
--- /dev/null
+++ b/drivers/watchdog/dw_wdt.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2010-2011 Picochip Ltd., Jamie Iles
+ * http://www.picochip.com
+ *
+ * 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 file implements a driver for the Synopsys DesignWare watchdog device
+ * in the many subsystems. The watchdog has 16 different timeout periods
+ * and these are a function of the input clock frequency.
+ *
+ * The DesignWare watchdog cannot be stopped once it has been started so we
+ * do not implement a stop function. The watchdog core will continue to send
+ * heartbeat requests after the watchdog device has been closed.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <of.h>
+#include <restart.h>
+#include <watchdog.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/reset.h>
+
+#define WDOG_CONTROL_REG_OFFSET 0x00
+#define WDOG_CONTROL_REG_WDT_EN_MASK 0x01
+#define WDOG_TIMEOUT_RANGE_REG_OFFSET 0x04
+#define WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT 4
+#define WDOG_CURRENT_COUNT_REG_OFFSET 0x08
+#define WDOG_COUNTER_RESTART_REG_OFFSET 0x0c
+#define WDOG_COUNTER_RESTART_KICK_VALUE 0x76
+
+/* The maximum TOP (timeout period) value that can be set in the watchdog. */
+#define DW_WDT_MAX_TOP 15
+
+#define DW_WDT_DEFAULT_SECONDS 30
+
+struct dw_wdt {
+ void __iomem *regs;
+ struct clk *clk;
+ struct restart_handler restart;
+ struct watchdog wdd;
+ struct reset_control *rst;
+};
+
+#define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd)
+
+static inline int dw_wdt_top_in_seconds(struct dw_wdt *dw_wdt, unsigned top)
+{
+ /*
+ * There are 16 possible timeout values in 0..15 where the number of
+ * cycles is 2 ^ (16 + i) and the watchdog counts down.
+ */
+ return (1U << (16 + top)) / clk_get_rate(dw_wdt->clk);
+}
+
+static int dw_wdt_start(struct watchdog *wdd)
+{
+ struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
+
+ writel(WDOG_CONTROL_REG_WDT_EN_MASK,
+ dw_wdt->regs + WDOG_CONTROL_REG_OFFSET);
+
+ return 0;
+}
+
+static int dw_wdt_stop(struct watchdog *wdd)
+{
+ struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
+
+ if (IS_ERR(dw_wdt->rst)) {
+ dev_warn(dw_wdt->dev, "No reset line. Will not stop.\n");
+ return PTR_ERR(dw_wdt->rst);
+ }
+
+ reset_control_assert(dw_wdt->rst);
+ reset_control_deassert(dw_wdt->rst);
+
+ return 0;
+}
+
+static int dw_wdt_set_timeout(struct watchdog *wdd, unsigned int top_s)
+{
+ struct dw_wdt *dw_wdt = to_dw_wdt(wdd);
+ int i, top_val = DW_WDT_MAX_TOP;
+
+ if (top_s == 0)
+ return dw_wdt_stop(wdd);
+
+ /*
+ * Iterate over the timeout values until we find the closest match. We
+ * always look for >=.
+ */
+ for (i = 0; i <= DW_WDT_MAX_TOP; ++i) {
+ if (dw_wdt_top_in_seconds(dw_wdt, i) >= top_s) {
+ top_val = i;
+ break;
+ }
+ }
+
+ /*
+ * Set the new value in the watchdog. Some versions of dw_wdt
+ * have have TOPINIT in the TIMEOUT_RANGE register (as per
+ * CP_WDT_DUAL_TOP in WDT_COMP_PARAMS_1). On those we
+ * effectively get a pat of the watchdog right here.
+ */
+ writel(top_val | top_val << WDOG_TIMEOUT_RANGE_TOPINIT_SHIFT,
+ dw_wdt->regs + WDOG_TIMEOUT_RANGE_REG_OFFSET);
+
+ dw_wdt_start(wdd);
+
+ return 0;
+}
+
+static void __noreturn dw_wdt_restart_handle(struct restart_handler *rst)
+{
+ struct dw_wdt *dw_wdt;
+
+ dw_wdt = container_of(rst, struct dw_wdt, restart);
+
+ dw_wdt->wdd.set_timeout(&dw_wdt->wdd, -1);
+
+ mdelay(1000);
+
+ hang();
+}
+
+static int dw_wdt_drv_probe(struct device_d *dev)
+{
+ struct watchdog *wdd;
+ struct dw_wdt *dw_wdt;
+ struct resource *mem;
+ int ret;
+
+ dw_wdt = xzalloc(sizeof(*dw_wdt));
+
+ mem = dev_request_mem_resource(dev, 0);
+ dw_wdt->regs = IOMEM(mem->start);
+ if (IS_ERR(dw_wdt->regs))
+ return PTR_ERR(dw_wdt->regs);
+
+ dw_wdt->clk = clk_get(dev, NULL);
+ if (IS_ERR(dw_wdt->clk))
+ return PTR_ERR(dw_wdt->clk);
+
+ ret = clk_enable(dw_wdt->clk);
+ if (ret)
+ return ret;
+
+ dw_wdt->rst = reset_control_get(dev, "dw-wdt");
+ if (IS_ERR(dw_wdt->rst))
+ dev_warn(dev, "No reset lines. Will not be able to stop once started.\n");
+
+ wdd = &dw_wdt->wdd;
+ wdd->name = "dw_wdt";
+ wdd->dev = dev;
+ wdd->set_timeout = dw_wdt_set_timeout;
+
+ ret = watchdog_register(wdd);
+ if (ret)
+ goto out_disable_clk;
+
+ dw_wdt->restart.name = "dw_wdt";
+ dw_wdt->restart.restart = dw_wdt_restart_handle;
+
+ ret = restart_handler_register(&dw_wdt->restart);
+ if (ret)
+ dev_warn(dev, "cannot register restart handler\n");
+
+ if (!IS_ERR(dw_wdt->rst))
+ reset_control_deassert(dw_wdt->rst);
+
+ return 0;
+
+out_disable_clk:
+ clk_disable(dw_wdt->clk);
+ return ret;
+}
+
+static struct of_device_id dw_wdt_of_match[] = {
+ { .compatible = "snps,dw-wdt", },
+ { /* sentinel */ }
+};
+
+static struct driver_d dw_wdt_driver = {
+ .probe = dw_wdt_drv_probe,
+ .of_compatible = DRV_OF_COMPAT(dw_wdt_of_match),
+};
+device_platform_driver(dw_wdt_driver);
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH v2 1/3] reset: import socfpga-reset driver from linux
From: Steffen Trumtrar @ 2016-10-14 9:27 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Port the linux v4.8-rc1 reset-socfpga driver to barebox.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
Changes since v1:
- use dev_request_mem_resource
drivers/reset/Makefile | 1 +
drivers/reset/reset-socfpga.c | 124 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 125 insertions(+)
create mode 100644 drivers/reset/reset-socfpga.c
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 1e2d83f2b995..52b10cd48055 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -1 +1,2 @@
obj-$(CONFIG_RESET_CONTROLLER) += core.o
+obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
new file mode 100644
index 000000000000..9214197e627d
--- /dev/null
+++ b/drivers/reset/reset-socfpga.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2014 Steffen Trumtrar <s.trumtrar@pengutronix.de>
+ *
+ * based on
+ * Allwinner SoCs Reset Controller driver
+ *
+ * Copyright 2013 Maxime Ripard
+ *
+ * Maxime Ripard <maxime.ripard@free-electrons.com>
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <io.h>
+#include <linux/err.h>
+#include <linux/reset-controller.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+
+#define NR_BANKS 4
+
+struct socfpga_reset_data {
+ spinlock_t lock;
+ void __iomem *membase;
+ u32 modrst_offset;
+ struct reset_controller_dev rcdev;
+};
+
+static int socfpga_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct socfpga_reset_data *data = container_of(rcdev,
+ struct socfpga_reset_data,
+ rcdev);
+ int bank = id / BITS_PER_LONG;
+ int offset = id % BITS_PER_LONG;
+ unsigned long flags;
+ u32 reg;
+
+ spin_lock_irqsave(&data->lock, flags);
+
+ reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+ writel(reg | BIT(offset), data->membase + data->modrst_offset +
+ (bank * NR_BANKS));
+ spin_unlock_irqrestore(&data->lock, flags);
+
+ return 0;
+}
+
+static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ struct socfpga_reset_data *data = container_of(rcdev,
+ struct socfpga_reset_data,
+ rcdev);
+
+ int bank = id / BITS_PER_LONG;
+ int offset = id % BITS_PER_LONG;
+ unsigned long flags;
+ u32 reg;
+
+ spin_lock_irqsave(&data->lock, flags);
+
+ reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+ writel(reg & ~BIT(offset), data->membase + data->modrst_offset +
+ (bank * NR_BANKS));
+
+ spin_unlock_irqrestore(&data->lock, flags);
+
+ return 0;
+}
+
+static struct reset_control_ops socfpga_reset_ops = {
+ .assert = socfpga_reset_assert,
+ .deassert = socfpga_reset_deassert,
+};
+
+static int socfpga_reset_probe(struct device_d *dev)
+{
+ struct socfpga_reset_data *data;
+ struct resource *res;
+ struct device_node *np = dev->device_node;
+
+ data = xzalloc(sizeof(*data));
+
+ res = dev_request_mem_resource(dev, 0);
+ data->membase = IOMEM(res->start);
+ if (IS_ERR(data->membase))
+ return PTR_ERR(data->membase);
+
+ if (of_property_read_u32(np, "altr,modrst-offset", &data->modrst_offset)) {
+ dev_warn(dev, "missing altr,modrst-offset property, assuming 0x10!\n");
+ data->modrst_offset = 0x10;
+ }
+
+ spin_lock_init(&data->lock);
+
+ data->rcdev.nr_resets = NR_BANKS * BITS_PER_LONG;
+ data->rcdev.ops = &socfpga_reset_ops;
+ data->rcdev.of_node = np;
+
+ return reset_controller_register(&data->rcdev);
+}
+
+static const struct of_device_id socfpga_reset_dt_ids[] = {
+ { .compatible = "altr,rst-mgr", },
+ { /* sentinel */ },
+};
+
+static struct driver_d socfpga_reset_driver = {
+ .probe = socfpga_reset_probe,
+ .of_compatible = DRV_OF_COMPAT(socfpga_reset_dt_ids),
+};
+
+static int socfpga_reset_init(void)
+{
+ return platform_driver_register(&socfpga_reset_driver);
+}
+postcore_initcall(socfpga_reset_init);
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* [PATCH v2 3/3] ARM: socfpga: dtsi: add dw-wdt reset lines
From: Steffen Trumtrar @ 2016-10-14 9:27 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
In-Reply-To: <20161014092715.4257-1-s.trumtrar@pengutronix.de>
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/dts/socfpga.dtsi | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/arm/dts/socfpga.dtsi b/arch/arm/dts/socfpga.dtsi
index d16758fdab46..66d7f21dc6a3 100644
--- a/arch/arm/dts/socfpga.dtsi
+++ b/arch/arm/dts/socfpga.dtsi
@@ -49,3 +49,13 @@
&f2s_sdram_ref_clk {
clock-frequency = <0>;
};
+
+&watchdog0 {
+ resets = <&rst L4WD0_RESET>;
+ reset-names = "dw-wdt";
+};
+
+&watchdog1 {
+ resets = <&rst L4WD1_RESET>;
+ reset-names = "dw-wdt";
+};
--
2.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply related
* How to configure and enable the barebox state?
From: Trostel Alain @ 2016-10-13 13:38 UTC (permalink / raw)
To: barebox@lists.infradead.org
Hi,
I would like to configure and enable the barebox state. My assumption is
that I need to change the following device tree for my Phytec AM335x
SOM:
arch/arm/dts/am335x-phytec-phycore-som.dts
But from the documentation
(http://www.barebox.org/doc/latest/devicetree/bindings/barebox/barebox,state.html) it is not clear to me where exactly I need to add the variable node example. Furthermore, I have check that the 'CONFIG_OFDEVICE' is enabled.
So, where is the correct place to add the variable node configuration
and what needs to be enabled in barebox?
Best regards,
Alain
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* Compressed DTB - builtin DTB
From: Daniel Krüger @ 2016-10-13 10:32 UTC (permalink / raw)
To: barebox
Hello,
I'm currently porting our board support to device tree. Currently, I
don't use multi-PBL, but include the device tree via CONFIG_BUILTIN_DTB.
This works, but the DTB seems to be included twice in the image: once as
plain DTB and once as compressed DTB. I think this isn't intended this way.
Extract from System.map:
87e82b80 R __dtb_imx35_systec_hmi_start
87e82b80 R __dtb_start
87e8501c R __dtb_imx35_systec_hmi_end
87e85020 R __dtb_z_imx35_systec_hmi_start
87e85ad0 R __dtb_z_imx35_systec_hmi_end
87e85b00 B __bss_start
87e85b00 R __dtb_end
Just using the compressed DTB would be really good. Because it makes the
image much smaller. However, how should that be done? The extract code
might be simple. But I don't have an idea how to let the linker select
the right version.
Thanks for any kind of support,
Daniel
--
SYS TEC electronic GmbH
Am Windrad 2
08468 Heinsdorfergrund
Telefon : +49 (0) 3765 38600-0
Fax : +49 (0) 3765 38600-4100
Email : daniel.krueger@systec-electronic.com
Website : http://www.systec-electronic.com
Managing Directors :
Dipl.-Phys. Siegmar Schmidt, Dipl. Ing. (FH) Armin von Collrepp
Commercial registry : Amtsgericht Chemnitz, HRB 28082
USt.-Id Nr. : DE150534010
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
* Re: [RFC] add riscv support
From: Robert Schwebel @ 2016-10-13 10:18 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
In-Reply-To: <20161013091127.3130-1-antonynpavlov@gmail.com>
On Thu, Oct 13, 2016 at 12:11:27PM +0300, Antony Pavlov wrote:
> This patch adds initial RISC-V architecture support for barebox.
Great to see this; could you add some documentation? We have a nice
documentation framework in the meantime. Most of your cover letter could
for example go into the docs.
rsc
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox