[U-Boot] [PATCH v2 2/5] rockchip: efuse: add (misc) driver for RK3399 non-secure efuse block

Simon Glass sjg at chromium.org
Wed May 3 10:06:41 UTC 2017


Hi Philipp,

On 29 April 2017 at 21:48, Simon Glass <sjg at chromium.org> wrote:
>
> Hi Philipp,
>
> On 28 April 2017 at 09:11, Philipp Tomsich
> <philipp.tomsich at theobroma-systems.com> wrote:
> > This adds a simple driver for reading the efuse block of the RK3399.
> > It should be easy enough to add drivers for other devices (e.g. the
> > RK3328, RK3368, etc.) by passing the device details via driver_data.
> >
> > Unlike the kernel driver (using the nvmem subsystem), we don't expose
> > the efuse as multiple named cells, but rather as a linear memory that
> > can be read using misc_read(...).
> >
> > The primary use case (as of today) is the generation of a 'serial#'
> > (and a 'cpuid#') environment variable for the RK3399-Q7 (Puma)
> > system-on-module.
> >
> > Note that this adds a debug-only (i.e. only if DEBUG is defined)
> > command 'rk3399_dump_efuses' that dumps the efuse block's content.
> > N.B.: The name 'rk3399_dump_efuses' was intentionally chosen to
> >       include a SoC-name (together with a comment in the function) to
> >       remind whoever adds support for additional SoCs that this
> >       function currently makes assumptions regarding the size of the
> >       fuse-box based on the RK3399. The hope is that the function is
> >       adjusted to reflect any changes resulting from generalising the
> >       driver for multiple SoCs and is then renamed.
> >
> > Signed-off-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
> > Tested-by: Klaus Goger <klaus.goger at theobroma-systems.com>
> > ---
> >
> > Changes in v2: None
> >
> >  drivers/misc/Kconfig          |  14 ++++
> >  drivers/misc/Makefile         |   1 +
> >  drivers/misc/rockchip-efuse.c | 163 ++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 178 insertions(+)
> >  create mode 100644 drivers/misc/rockchip-efuse.c
>
> Reviewed-by: Simon Glass <sjg at chromium.org>
>
> But please see below.
>
> >
> > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> > index 1aae4bc..ed57414 100644
> > --- a/drivers/misc/Kconfig
> > +++ b/drivers/misc/Kconfig
> > @@ -20,6 +20,19 @@ config ALTERA_SYSID
> >           Select this to enable a sysid for Altera devices. Please find
> >           details on the "Embedded Peripherals IP User Guide" of Altera.
> >
> > +config ROCKCHIP_EFUSE
> > +        bool "Rockchip e-fuse support"
> > +       depends on MISC
> > +       help
> > +         Enable (read-only) access for the e-fuse block found in Rockchip
> > +         SoCs: accesses can either be made using byte addressing and a length
> > +         or through child-nodes that are generated based on the e-fuse map
> > +         retrieved from the DTS.
> > +
> > +         This driver currently supports the RK3399 only, but can easily be
> > +         extended (by porting the read function from the Linux kernel sources)
> > +         to support other recent Rockchip devices.
> > +
> >  config CMD_CROS_EC
> >         bool "Enable crosec command"
> >         depends on CROS_EC
> > @@ -167,4 +180,5 @@ config I2C_EEPROM
> >         depends on MISC
> >         help
> >           Enable a generic driver for EEPROMs attached via I2C.
> > +
> >  endmenu
> > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> > index e3151ea..77196fd 100644
> > --- a/drivers/misc/Makefile
> > +++ b/drivers/misc/Makefile
> > @@ -51,3 +51,4 @@ obj-$(CONFIG_PCA9551_LED) += pca9551_led.o
> >  obj-$(CONFIG_FSL_DEVICE_DISABLE) += fsl_devdis.o
> >  obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
> >  obj-$(CONFIG_QFW) += qfw.o
> > +obj-$(CONFIG_ROCKCHIP_EFUSE) += rockchip-efuse.o
> > diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
> > new file mode 100644
> > index 0000000..6eb3616
> > --- /dev/null
> > +++ b/drivers/misc/rockchip-efuse.c
> > @@ -0,0 +1,163 @@
> > +/*
> > + * eFuse driver for Rockchip devices
> > + *
> > + * Copyright 2017, Theobroma Systems Design und Consulting GmbH
> > + * Written by Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
> > + *
> > + * SPDX-License-Identifier:    GPL-2.0+
> > + */
> > +
> > +#define DEBUG
> > +
> > +#include <common.h>
> > +#include <asm/io.h>
> > +#include <command.h>
> > +#include <display_options.h>
> > +#include <dm.h>
> > +#include <linux/bitops.h>
> > +#include <linux/delay.h>
> > +#include <misc.h>
> > +
> > +#define RK3399_A_SHIFT          16
> > +#define RK3399_A_MASK           0x3ff
> > +#define RK3399_NFUSES           32
> > +#define RK3399_BYTES_PER_FUSE   4
> > +#define RK3399_STROBSFTSEL      BIT(9)
> > +#define RK3399_RSB              BIT(7)
> > +#define RK3399_PD               BIT(5)
> > +#define RK3399_PGENB            BIT(3)
> > +#define RK3399_LOAD             BIT(2)
> > +#define RK3399_STROBE           BIT(1)
> > +#define RK3399_CSB              BIT(0)
> > +
> > +struct rockchip_efuse_regs {
> > +       u32 ctrl;      /* 0x00  efuse control register */
> > +       u32 dout;      /* 0x04  efuse data out register */
> > +       u32 rf;        /* 0x08  efuse redundancy bit used register */
> > +       u32 _rsvd0;
> > +       u32 jtag_pass; /* 0x10  JTAG password */
> > +       u32 strobe_finish_ctrl;
> > +                      /* 0x14  efuse strobe finish control register */
> > +};
> > +
> > +struct rockchip_efuse_platdata {
> > +       void __iomem *base;
> > +       struct clk *clk;
> > +};
> > +
> > +#if defined(DEBUG)
> > +static int dump_efuses(cmd_tbl_t *cmdtp, int flag,
> > +                      int argc, char * const argv[])
> > +{
> > +       /*
> > +        * N.B.: This function is tailored towards the RK3399 and assumes that
> > +        *       there's always 32 fuses x 32 bits (i.e. 128 bytes of data) to
> > +        *       be read.
> > +        */
> > +
> > +       struct udevice *dev;
> > +       u8 fuses[128];
> > +       int ret;
> > +
> > +       /* the first misc device will be used */
> > +       ret = uclass_first_device_err(UCLASS_MISC, &dev);
>
> This might pick up a different device. Can you use
> uclass_get_device_by_driver() perhaps?

I've applied just the first patch in this series for now. Let me know
if you would rather keep the driver finding as you have it.

Regards,
Simon


More information about the U-Boot mailing list