[U-Boot] [PATCH v2 02/14] sysreset: add syscon-reboot driver
Álvaro Fernández Rojas
noltari at gmail.com
Tue Apr 18 06:40:09 UTC 2017
I'm not sure, but I can't see any reference to uclass_get_device_by_phandle in https://github.com/u-boot/u-boot/blob/master/drivers/sysreset/sysreset-uclass.cSo I guess that the driver is never probed unless it's flagged as u-boot,dm-pre-reloc. Am I correct?
Appart from that, this also happens in bmips cpu driver, in which I had to do it in bind because probe was never called unless it was flagged as pre-reloc...
Is dm probing every driver or only specific ones such as serial?
Regards,Álvaro.
On Mon, Apr 17, 2017 at 7:46 PM +0200, "Simon Glass" <sjg at chromium.org> wrote:
Hi Alvaro,
On 17 April 2017 at 11:38, Álvaro Fernández Rojas wrote:
>
> Hi Simon,
>
> El 16/04/2017 a las 21:34, Simon Glass escribió:
> > Hi Alvaro,
> >
> > On 15 April 2017 at 16:03, Álvaro Fernández Rojas wrote:
> >> Add a new sysreset driver based on linux/drivers/power/reset/syscon-reboot.c,
> >> which provides a generic driver for platforms that only require writing a mask
> >> to a regmap offset.
> >>
> >> Signed-off-by: Álvaro Fernández Rojas
> >> ---
> >> v2: no changes
> >>
> >> drivers/sysreset/Kconfig | 8 +++++
> >> drivers/sysreset/Makefile | 1 +
> >> drivers/sysreset/sysreset_syscon.c | 60 ++++++++++++++++++++++++++++++++++++++
> >> 3 files changed, 69 insertions(+)
> >> create mode 100644 drivers/sysreset/sysreset_syscon.c
> >>
> >> diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
> >> index 05a37b9..0946c9d 100644
> >> --- a/drivers/sysreset/Kconfig
> >> +++ b/drivers/sysreset/Kconfig
> >> @@ -13,4 +13,12 @@ config SYSRESET
> >> to effect a reset. The uclass will try all available drivers when
> >> reset_walk() is called.
> >>
> >> +config SYSRESET_SYSCON
> >> + bool "Enable support for mfd syscon reboot driver"
> >> + depends on SYSRESET
> >> + select REGMAP
> >> + select SYSCON
> >> + help
> >> + Description here.
> >
> > Yes please!
> Sure, my fault :P
>
> >
> >> +
> >> endmenu
> >> diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
> >> index 49b8bb6..1205f47 100644
> >> --- a/drivers/sysreset/Makefile
> >> +++ b/drivers/sysreset/Makefile
> >> @@ -18,3 +18,4 @@ obj-$(CONFIG_ARCH_SNAPDRAGON) += sysreset_snapdragon.o
> >> obj-$(CONFIG_ARCH_STI) += sysreset_sti.o
> >> obj-$(CONFIG_TARGET_XTFPGA) += sysreset_xtfpga.o
> >> obj-$(CONFIG_ARCH_ASPEED) += sysreset_ast.o
> >> +obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
> >> diff --git a/drivers/sysreset/sysreset_syscon.c b/drivers/sysreset/sysreset_syscon.c
> >> new file mode 100644
> >> index 0000000..61aeb1d
> >> --- /dev/null
> >> +++ b/drivers/sysreset/sysreset_syscon.c
> >> @@ -0,0 +1,60 @@
> >> +/*
> >> + * Copyright (C) 2017 Álvaro Fernández Rojas
> >> + *
> >> + * Derived from linux/drivers/power/reset/syscon-reboot.c:
> >> + * Copyright (C) 2013, Applied Micro Circuits Corporation
> >> + * Author: Feng Kan
> >> + *
> >> + * SPDX-License-Identifier: GPL-2.0+
> >> + */
> >> +
> >> +#include
> >> +#include
> >> +#include
> >> +#include
> >
> > this should go at the end
> I will fix it.
>
> >
> >> +#include
> >> +#include
> >> +
> >> +DECLARE_GLOBAL_DATA_PTR;
> >> +
> >> +static int syscon_reboot_request(struct udevice *dev, enum sysreset_t type)
> >> +{
> >> + struct udevice *syscon;
> >> + struct regmap *regmap;
> >> + unsigned int offset, mask;
> >> + int err;
> >> +
> >> + err = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
> >> + "regmap", &syscon);
> >> + if (err) {
> >> + error("unable to find syscon device
");
> >> + return err;
> >> + }
> >> +
> >> + regmap = syscon_get_regmap(syscon);
> >> + if (!regmap) {
> >> + error("unable to find regmap
");
> >> + return -ENODEV;
> >> + }
> >> +
> >> + offset = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "offset", 0);
> >> + mask = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "mask", 0);
> >
> > You should do this in ofdata_to_platdata() or probe() and store it in
> > a local struct
> I tried doing it in probe:
> https://github.com/Noltari/u-boot/commit/37f45960f240c3e57fa70afe69d9b5782c9e6f9f
>
> However it looks like probe is never called with my current U_BOOT_DRIVER settings...
That is bad - you should figure out why. The
uclass_get_device_by_phandle() should call probe().
> Then I tried doing it in bind instead of probe and it looks like the syscon device isn't ready when syscon-reboot is binded...
> Any ideas? :$
Figure out why probe() doesn't happen.
>
> >
> >
> >> +
> >> + return regmap_write(regmap, offset, mask);
> >
> > Check error here, and either return -EINPROGRESS or some other error
> I will, but regmap_write returns always 0, so there's no error at all to check...
That's fine - you can return -EINPROGRESS if it returns 0, and the
error otherwise. Also please add function docs for regmap_read/write()
while you are there.
>
> >
> >> +}
> >> +
> >> +static struct sysreset_ops syscon_reboot_ops = {
> >> + .request = syscon_reboot_request,
> >> +};
> >> +
> >> +static const struct udevice_id syscon_reboot_ids[] = {
> >> + { .compatible = "syscon-reboot" },
> >> + { /* sentinel */ }
> >> +};
> >> +
> >> +U_BOOT_DRIVER(syscon_reboot) = {
> >> + .name = "syscon_reboot",
> >> + .id = UCLASS_SYSRESET,
> >> + .of_match = syscon_reboot_ids,
> >> + .ops = &syscon_reboot_ops,
> >> +};
> >> --
> >> 2.1.4
> >>
> >
> > Regards,
> > Simon
> >
Regards,
Simon
More information about the U-Boot
mailing list