platform/kernel/u-boot.git
3 years agoMerge branch '2020-09-30-add-new-apis' into next
Tom Rini [Wed, 30 Sep 2020 20:11:11 +0000 (16:11 -0400)]
Merge branch '2020-09-30-add-new-apis' into next

- SCMI firmware support
- regmap, GPIO, reset API enhancements

3 years agofirmware: smci: sandbox test for SCMI reset controllers
Etienne Carriere [Wed, 9 Sep 2020 16:44:07 +0000 (18:44 +0200)]
firmware: smci: sandbox test for SCMI reset controllers

Add tests for SCMI reset controllers. A test device driver
sandbox-scmi_devices.c is used to get reset resources, allowing further
resets manipulation.

Change sandbox-smci_agent to emulate 1 reset controller exposed through
an agent. Add DM test scmi_resets to test this reset controller.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoreset: add reset controller driver for SCMI agents
Etienne Carriere [Wed, 9 Sep 2020 16:44:06 +0000 (18:44 +0200)]
reset: add reset controller driver for SCMI agents

This change introduces a reset controller driver for SCMI agent devices.
When SCMI agent and SCMI reset domain drivers are enabled, SCMI agent
binds a reset controller device for each SCMI reset domain protocol
devices enabled in the FDT.

SCMI reset driver is embedded upon CONFIG_RESET_SCMI=y. If enabled,
CONFIG_SCMI_AGENT is also enabled.

SCMI Reset Domain protocol is defined in the SCMI specification [1].

Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agofirmware: scmi: sandbox test for SCMI clocks
Etienne Carriere [Wed, 9 Sep 2020 16:44:05 +0000 (18:44 +0200)]
firmware: scmi: sandbox test for SCMI clocks

Add tests for SCMI clocks. A test device driver sandbox-scmi_devices.c
is used to get clock resources, allowing further clock manipulation.

Change sandbox-smci_agent to emulate 3 clocks exposed through 2 agents.
Add DM test scmi_clocks to test these 3 clocks.
Update DM test sandbox_scmi_agent with load/remove test sequences
factorized by {load|remove}_sandbox_scmi_test_devices() helper functions.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoclk: add clock driver for SCMI agents
Etienne Carriere [Wed, 9 Sep 2020 16:44:04 +0000 (18:44 +0200)]
clk: add clock driver for SCMI agents

This change introduces a clock driver for SCMI agent devices. When
SCMI agent and SCMI clock drivers are enabled, SCMI agent binds a
clock device for each SCMI clock protocol devices enabled in the FDT.

SCMI clock driver is embedded upon CONFIG_CLK_SCMI=y. If enabled,
CONFIG_SCMI_AGENT is also enabled.

SCMI Clock protocol is defined in the SCMI specification [1].

Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agodt-bindings: arm: SCMI bindings documentation
Etienne Carriere [Wed, 9 Sep 2020 16:44:03 +0000 (18:44 +0200)]
dt-bindings: arm: SCMI bindings documentation

Dump SCMI DT bindings documentation from Linux kernel source
tree v5.8-rc1.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agofirmware: scmi: support Arm SMCCC transport
Etienne Carriere [Wed, 9 Sep 2020 16:44:02 +0000 (18:44 +0200)]
firmware: scmi: support Arm SMCCC transport

This change implements a SMCCC transport for SCMI exchanges. This
implementation follows the Linux kernel as references implementation
for SCMI message processing, using the SMT format for communication
channel meta-data.

Use of SMCCC transport in SCMI FDT bindings are defined in the Linux
kernel DT bindings since v5.8. SMCCC with SMT is implemented in OP-TEE
from tag 3.9.0 [2].

Links: [2] https://github.com/OP-TEE/optee_os/commit/a58c4d706d23
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agofirmware: scmi: mailbox/smt agent device
Etienne Carriere [Wed, 9 Sep 2020 16:44:01 +0000 (18:44 +0200)]
firmware: scmi: mailbox/smt agent device

This change implements a mailbox transport using SMT format for SCMI
exchanges. This implementation follows the Linux kernel and
SCP-firmware [1] as references implementation for SCMI message
processing using SMT format for communication channel meta-data.

Use of mailboxes in SCMI FDT bindings are defined in the Linux kernel
DT bindings since v4.17.

Links: [1] https://github.com/ARM-software/SCP-firmware
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agofirmware: add SCMI agent uclass
Etienne Carriere [Wed, 9 Sep 2020 16:44:00 +0000 (18:44 +0200)]
firmware: add SCMI agent uclass

This change introduces SCMI agent uclass to interact with a firmware
using the SCMI protocols [1].

SCMI agent uclass currently supports a single method to request
processing of the SCMI message by an identified server. A SCMI message
is made of a byte payload associated to a protocol ID and a message ID,
all defined by the SCMI specification [1]. On return from process_msg()
method, the caller gets the service response.

SCMI agent uclass defines a post bind generic sequence for all devices.
The sequence binds all the SCMI protocols listed in the FDT for that
SCMI agent device. Currently none, but later change will introduce
protocols.

This change implements a simple sandbox device for the SCMI agent uclass.
The sandbox nicely answers SCMI_NOT_SUPPORTED to SCMI messages.
To prepare for further test support, the sandbox exposes a architecture
function for test application to read the sandbox emulated devices state.
Currently supports 2 SCMI agents, identified by an ID in the FDT device
name. The simplistic DM test does nothing yet.

SCMI agent uclass is designed for platforms that embed a SCMI server in
a firmware hosted somewhere, for example in a companion co-processor or
in the secure world of the executing processor. SCMI protocols allow an
SCMI agent to discover and access external resources as clock, reset
controllers and more. SCMI agent and server communicate following the
SCMI specification [1]. This SCMI agent implementation complies with
the DT bindings defined in the Linux kernel source tree regarding
SCMI agent description since v5.8.

Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agotest: dm: Add tests for regmap managed API and regmap fields
Jean-Jacques Hiblot [Thu, 24 Sep 2020 04:34:18 +0000 (10:04 +0530)]
test: dm: Add tests for regmap managed API and regmap fields

The tests rely on a dummy driver to allocate and initialize the regmaps
and the regmap fields using the managed API. The first test checks if
the regmap config fields like width, reg_offset_shift, range specifiers,
etc work. The second test checks if regmap fields behave properly (mask
and shift are ok) by peeking into the regmap.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agotest/py: allow multi-digit index in in_tree()
Pratyush Yadav [Thu, 24 Sep 2020 04:34:17 +0000 (10:04 +0530)]
test/py: allow multi-digit index in in_tree()

When more nodes are added for a uclass the index might go into two or
more digits. This means that there are less spaces printed because they
are used up by the extra digits. Update the regular expression to allow
variable-length spacing between the class name and and index.

This was discovered when adding a simple_bus node in test.dts made
test_bind_unbind_with_uclass() fail because the index went up to 10.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
3 years agoregmap: Add support for regmap fields
Jean-Jacques Hiblot [Thu, 24 Sep 2020 04:34:16 +0000 (10:04 +0530)]
regmap: Add support for regmap fields

A regmap field is an abstraction available in Linux. It provides to access
bitfields in a regmap without having to worry about shifts and masks.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
3 years agoregmap: Allow devices to specify regmap range start and size in config
Pratyush Yadav [Thu, 24 Sep 2020 04:34:15 +0000 (10:04 +0530)]
regmap: Allow devices to specify regmap range start and size in config

Some devices need to calculate the regmap base address at runtime. This
makes it impossible to use device tree to get the regmap base. Instead,
allow devices to specify it in the regmap config. This will create a
regmap with a single range that corresponds to the start and size given
by the driver.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoregmap: Add regmap_init_mem_range()
Pratyush Yadav [Thu, 24 Sep 2020 04:34:14 +0000 (10:04 +0530)]
regmap: Add regmap_init_mem_range()

Right now, the base of a regmap can only be obtained from the device
tree. This makes it impossible for devices which calculate the base at
runtime to use a regmap. An example of such a device is the Cadence
Sierra PHY.

Allow creating a regmap with one range whose start and size can be
specified by the driver based on calculations at runtime.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoregmap: Allow left shifting register offset before access
Pratyush Yadav [Thu, 24 Sep 2020 04:34:13 +0000 (10:04 +0530)]
regmap: Allow left shifting register offset before access

Drivers can configure it to adjust the final read/write location.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoregmap: Allow specifying read/write width
Pratyush Yadav [Thu, 24 Sep 2020 04:34:12 +0000 (10:04 +0530)]
regmap: Allow specifying read/write width

Right now, regmap_read() and regmap_write() read/write a 32-bit value
only. To write other lengths, regmap_raw_read() and regmap_raw_write()
need to be used.

This means that any driver ported from Linux that relies on
regmap_{read,write}() to know the size already has to be updated at each
callsite. This makes the port harder to maintain.

So, allow specifying the read/write width to make it easier to port the
drivers, since now the only change needed is when initializing the
regmap.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoregmap: zero out the regmap on allocation
Pratyush Yadav [Thu, 24 Sep 2020 04:34:11 +0000 (10:04 +0530)]
regmap: zero out the regmap on allocation

Some fields will be introduced in the regmap structure that should be
set to 0 by default. So, once we allocate a regmap, make sure it is
zeroed out to avoid unexpected defaults for those values.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoregmap: Add devm_regmap_init()
Jean-Jacques Hiblot [Thu, 24 Sep 2020 04:34:10 +0000 (10:04 +0530)]
regmap: Add devm_regmap_init()

Most of new linux drivers are using managed-API to allocate resources. To
ease porting drivers from linux to U-Boot, introduce devm_regmap_init() as
a managed API to get a regmap from the device tree.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
3 years agotest: gpio: Add tests for the managed API
Jean-Jacques Hiblot [Fri, 11 Sep 2020 08:13:35 +0000 (13:43 +0530)]
test: gpio: Add tests for the managed API

Add a test to verify that GPIOs can be acquired/released using the managed
API. Also check that the GPIOs are released when the consumer device is
removed.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
3 years agodrivers: gpio: Add a managed API to get a GPIO from the device-tree
Jean-Jacques Hiblot [Fri, 11 Sep 2020 08:13:34 +0000 (13:43 +0530)]
drivers: gpio: Add a managed API to get a GPIO from the device-tree

Add managed functions to get a gpio from the devce-tree, based on a
property name (minus the '-gpios' suffix) and optionally an index.

When the device is unbound, the GPIO is automatically released and the
data structure is freed.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
3 years agotest: reset: Add tests for the managed API
Jean-Jacques Hiblot [Wed, 9 Sep 2020 10:07:04 +0000 (15:37 +0530)]
test: reset: Add tests for the managed API

The tests are basically the same as for the regular API. Except that
the reset are initialized using the managed API, and no freed manually.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
3 years agodrivers: reset: Add a managed API to get reset controllers from the DT
Jean-Jacques Hiblot [Wed, 9 Sep 2020 10:07:03 +0000 (15:37 +0530)]
drivers: reset: Add a managed API to get reset controllers from the DT

Add managed functions to get a reset_ctl from the device-tree, based on a
name or an index.
Also add a managed functions to get a reset_ctl_bulk (array of reset_ctl)
from the device-tree.

When the device is unbound, the reset controllers are automatically
released and the data structure is freed.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
3 years agoMerge branch 'next' of https://gitlab.denx.de/u-boot/custodians/u-boot-riscv into...
Tom Rini [Wed, 30 Sep 2020 13:21:43 +0000 (09:21 -0400)]
Merge branch 'next' of https://gitlab.denx.de/u-boot/custodians/u-boot-riscv into next

- Disable CMD_IRQ for RISC-V.
- Update sipeed/maix doc
- Obtain reg of SiFive RAM via dev_read_addr_index() instead of regmap API.
- Cleans up RISC-V timer drivers and converts them to DM.
- Correctly handle IPIs already pending upon prior stage bootloader (on the K210)

3 years agoMerge branch '2020-09-29-dev_xxx-print-improvement' into next
Tom Rini [Wed, 30 Sep 2020 13:07:06 +0000 (09:07 -0400)]
Merge branch '2020-09-29-dev_xxx-print-improvement' into next

- Improve our dev_xxx(..) wrappers to be generally used and available
  rather than discarded at link/compile time.

3 years agodm: Print device name in dev_xxx like Linux
Sean Anderson [Tue, 15 Sep 2020 14:45:22 +0000 (10:45 -0400)]
dm: Print device name in dev_xxx like Linux

This adorns messages generated by dev_xxx with the device and driver
names. It also redirects dev_xxx to log when it is available. The names
of these functions very roughly take inspiration from Linux, but there is
no deeper correlation.

Both struct udevice and struct device are supported when logging, though
logging with struct device is no better than using log_xxx. The latter is
supported because of the large amount of existing code which logs with
struct device.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agodm: Use symbolic constants for log levels in dev_xxx
Sean Anderson [Tue, 15 Sep 2020 14:45:21 +0000 (10:45 -0400)]
dm: Use symbolic constants for log levels in dev_xxx

This substitutes literal log levels with their symbolic constants.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agovideo: stm32: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:20 +0000 (10:45 -0400)]
video: stm32: Fix not calling dev_xxx with a device

There is no member `dev` in dw_mipi_dsi, but there is one in mipi_dsi_host,
so use that.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agousb: musb-new: sunxi: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:19 +0000 (10:45 -0400)]
usb: musb-new: sunxi: Fix not calling dev_err with a device

This driver does not use DM, so we need to use a struct device instead of a
struct udevice. Not ideal, but it'll have to do for now.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agousb: dwc3: Don't include asm-generic/io.h
Sean Anderson [Tue, 15 Sep 2020 14:45:18 +0000 (10:45 -0400)]
usb: dwc3: Don't include asm-generic/io.h

This can conflict with asm/io.h on some archs, and it isn't needed to build
dwc3-generic.c

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agousb: dwc3: ti: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:17 +0000 (10:45 -0400)]
usb: dwc3: ti: Fix not calling dev_err with a device

This driver does not use DM, so use log_xxx instead.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agousb: dwc3: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:16 +0000 (10:45 -0400)]
usb: dwc3: Fix not calling dev_xxx with a device

This logs with the device from struct dwc3. Some files also need to include
dm.h so fields in udevice can be accessed.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agousb: dwc2: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:15 +0000 (10:45 -0400)]
usb: dwc2: Fix not calling dev_xxx with a device

This adds a dev argument to some functions so dev_xxx always has a device
to log with. In one instance we must use use a different log function when
we are compiled without DM_USB.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agousb: cdns3: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:14 +0000 (10:45 -0400)]
usb: cdns3: Fix not calling dev_xxx with a device

ep0.c also need to include dm.h so dev_xxx can access udevice fields.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agosysreset: ti: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:13 +0000 (10:45 -0400)]
sysreset: ti: Fix not calling dev_err with a device

The rst variable doesn't exist.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agospi: zynqmp_gqspi: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:12 +0000 (10:45 -0400)]
spi: zynqmp_gqspi: Fix not calling dev_err with a device

Use `bus` instead of `dev`.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agospi: sunxi: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:11 +0000 (10:45 -0400)]
spi: sunxi: Fix not calling dev_err with a device

Use `bus` and not `dev`.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agosoc: qualcomm: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:10 +0000 (10:45 -0400)]
soc: qualcomm: Fix not calling dev_err with a device

Remove the indirection.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agoremoteproc: k3: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:09 +0000 (10:45 -0400)]
remoteproc: k3: Fix not calling dev_xxx with a device

Pass a device to functions which log with one.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agoremoteproc: k3-r5: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:08 +0000 (10:45 -0400)]
remoteproc: k3-r5: Fix not calling dev_xxx with a device

Usually we can get a device from the current core, but some dev_dbg calls
have been converted to debug, since we are called on a cluster.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agoremoteproc: Remove unused function rproc_elf_sanity_check
Sean Anderson [Tue, 15 Sep 2020 14:45:07 +0000 (10:45 -0400)]
remoteproc: Remove unused function rproc_elf_sanity_check

This function is never used anywhere, and it also tries to log with a
nonexistant device.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agophy: usbphyc: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:06 +0000 (10:45 -0400)]
phy: usbphyc: Fix not calling dev_err with a device

Use the phy's device.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agophy: ti: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:05 +0000 (10:45 -0400)]
phy: ti: Fix not calling dev_err with a device

`phy` doesn't exist; we need to use `x` instead.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agophy: sun4i-usb: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:04 +0000 (10:45 -0400)]
phy: sun4i-usb: Fix not calling dev_err with a device

This uses phy's device

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agophy: rockchip: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:03 +0000 (10:45 -0400)]
phy: rockchip: Fix not calling dev_err with a device

Get the device from phy, or pass the phy in.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agophy: marvell: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:02 +0000 (10:45 -0400)]
phy: marvell: Fix not calling dev_err with a device

No need for indirection here.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonet: ti: cpsw: Fix not calling dev_dbg with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:01 +0000 (10:45 -0400)]
net: ti: cpsw: Fix not calling dev_dbg with a device

Without DM_ETH, cpsw_priv.dev is an eth_device. Just use its name instead.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonet: sun8i_emac: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:45:00 +0000 (10:45 -0400)]
net: sun8i_emac: Fix not calling dev_xxx with a device

Pass a udevice into a few functions so `dev` is defined.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonet: sunxi: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:59 +0000 (10:44 -0400)]
net: sunxi: Fix not calling dev_xxx with a device

There's no dev to log with, so pass the device along with the priv data.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agolinux/compat.h: Remove netdev_xxx functions
Sean Anderson [Tue, 15 Sep 2020 14:44:58 +0000 (10:44 -0400)]
linux/compat.h: Remove netdev_xxx functions

No drivers in U-Boot use these functions.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonet: mvpp2: Convert netdev_xxx to dev_xxx
Sean Anderson [Tue, 15 Sep 2020 14:44:57 +0000 (10:44 -0400)]
net: mvpp2: Convert netdev_xxx to dev_xxx

netdev_xxx evaluates to printf in U-Boot, so there is no extra info
printed. mvpp2 one of only two drivers which use these functions in U-Boot.
Convert these functions to dev_xxx where possible (and to log_xxx where
not).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonet: mvpp2: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:56 +0000 (10:44 -0400)]
net: mvpp2: Fix not calling dev_xxx with a device

Remove some prefixes, or get the device from the phy.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonet: mvneta: Convert netdev_xxx to dev_xxx
Sean Anderson [Tue, 15 Sep 2020 14:44:55 +0000 (10:44 -0400)]
net: mvneta: Convert netdev_xxx to dev_xxx

netdev_xxx evaluates to printf in U-Boot, so there is no extra info
printed. mvneta is one of two drivers which use these functions in U-Boot.
Convert these functions to dev_xxx where possible (and to log_xxx where
not).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonet: mvneta: Fix not always calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:54 +0000 (10:44 -0400)]
net: mvneta: Fix not always calling dev_err with a device

No need for indirection here.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonet: mdio: Fix not calling dev_dbg with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:53 +0000 (10:44 -0400)]
net: mdio: Fix not calling dev_dbg with a device

The name of the device we are working on is `ethdev` and not just `dev`.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonet: bcm6368: Fix not calling dev_info with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:52 +0000 (10:44 -0400)]
net: bcm6368: Fix not calling dev_info with a device

Remove the pdev indirection.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonand: vybrid: Re-introduce vf610_nfc.dev
Sean Anderson [Tue, 15 Sep 2020 14:44:51 +0000 (10:44 -0400)]
nand: vybrid: Re-introduce vf610_nfc.dev

This member was presumably dropped when this driver was converted from
Linux. However, it is still used in log statements during initialization.
This patch adds the member back. In addition, allocation of struct
vf610_nfc has been moved to the callers of vf610_nfc_nand_init. This allows
it to be allocated by DM (if it is being used) and for dev to be
initialized.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonand: brcmnand: Fix not calling dev_err() with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:50 +0000 (10:44 -0400)]
nand: brcmnand: Fix not calling dev_err() with a device

There are too many levels of indirection when calling dev_err. This is an
artifact of the conversion of brcmnand_host.pdev from a struct
platform_device (which has a member `dev` pointing to a struct device) to
struct udevice.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agonand: atmel: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:49 +0000 (10:44 -0400)]
nand: atmel: Fix not calling dev_xxx with a device

Use mtd_info to get a device to log with.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agomailbox: k3: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:48 +0000 (10:44 -0400)]
mailbox: k3: Fix not calling dev_err with a device

dev needs to be gotten from mbox_chan

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agommc: mtk-sd: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:47 +0000 (10:44 -0400)]
mmc: mtk-sd: Fix not calling dev_err with a device

This adds a udevice parameter to get_best_delay and msdc_set_mclk so they
can call dev_err properly.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agommc: bcm2835-host: Fix not calling dev_dbg with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:46 +0000 (10:44 -0400)]
mmc: bcm2835-host: Fix not calling dev_dbg with a device

dev needs to be qualified as a member of host.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agommc: Add mmc_dev()
Sean Anderson [Tue, 15 Sep 2020 14:44:45 +0000 (10:44 -0400)]
mmc: Add mmc_dev()

This macro is necessary for arasan_zynqmp_dll_reset to compile.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agomtd: spi-nand: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:44 +0000 (10:44 -0400)]
mtd: spi-nand: Fix not calling dev_err with a device

Get it from spinand->slave->dev. Another option would be to use
spinand_to_mtd(spinand)->dev, but this is what the existing code uses.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agomtd: spi: Fix logging in spi-nor-tiny
Sean Anderson [Tue, 15 Sep 2020 14:44:43 +0000 (10:44 -0400)]
mtd: spi: Fix logging in spi-nor-tiny

This fixes dev_xxx() not always being called with a device. In
spi_nor_reg_read, a the slave device may not always be available, so we use
bus and cs instead.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agomtd: spi: Include dm.h in spi-nor-core.c
Sean Anderson [Tue, 15 Sep 2020 14:44:42 +0000 (10:44 -0400)]
mtd: spi: Include dm.h in spi-nor-core.c

This header is needed so struct udevice can be used in dev_xxx().

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agomtd: nand: sunxi: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:41 +0000 (10:44 -0400)]
mtd: nand: sunxi: Fix not calling dev_err with a device

Usually the device is gotten from sunxi_nfc. This is a struct device and
not a struct udevice, but the whole driver seems to be written wihout DM
anyway...

In a few instances, this patch modifies functions to take an nfc to log
with. In once instance we use mtd_info's device since there is no nfc.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agomtd: nand: pxa3xx: Fix not calling dev_xxx with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:40 +0000 (10:44 -0400)]
mtd: nand: pxa3xx: Fix not calling dev_xxx with a device

Use the device from any mtd already available, or from the active mtd via
pxa3xx_nand_info if one is not.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agoi2c: mxc: Fix dev_err being called on a nonexistant variable
Sean Anderson [Tue, 15 Sep 2020 14:44:39 +0000 (10:44 -0400)]
i2c: mxc: Fix dev_err being called on a nonexistant variable

The udevice we are working with is called `bus` and not `dev`.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agofirmware: ti_sci: Fix not calling dev_err with a device
Sean Anderson [Tue, 15 Sep 2020 14:44:38 +0000 (10:44 -0400)]
firmware: ti_sci: Fix not calling dev_err with a device

This converts calls to dev_err to get the device from ti_sci_info where
appropriate.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Nishanth Menon <nm@ti.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agodm: syscon: Fix calling dev_dbg with an uninitialized device
Sean Anderson [Tue, 15 Sep 2020 14:44:37 +0000 (10:44 -0400)]
dm: syscon: Fix calling dev_dbg with an uninitialized device

We can't use dev_dbg here because we haven't bound to the device yet. Use
log_debug instead.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
3 years agoriscv: Add some comments to start.S
Sean Anderson [Mon, 21 Sep 2020 11:51:41 +0000 (07:51 -0400)]
riscv: Add some comments to start.S

This adds comments regarding the ordering and purpose of certain
instructions as I understand them.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
Reviewed-by: Leo Liang <ycliang@andestech.com>
3 years agoriscv: Ensure gp is NULL or points to valid data
Sean Anderson [Mon, 21 Sep 2020 11:51:40 +0000 (07:51 -0400)]
riscv: Ensure gp is NULL or points to valid data

This ensures constructs like `if (gd & gd->...) { ... }` work when
accessing the global data pointer. Without this change, it was possible for
a very early trap to cause _exit_trap to directly or indirectly (through
printf) to read arbitrary memory. This could cause a second trap,
preventing show_regs from being printed.

printf (and specifically puts) uses gd to determine what function to print
with. These functions in turn use gd to find the serial device, etc.
However, before accessing gd, puts first checks to see if it is non-NULL.
This indicates an existing (perhaps undocumented) assumption that either gd
is NULL or it is completely valid.

Before this patch, gd either points to unexpected data (because it retains
the value it did from the prior-stage) or points to uninitialized data
(because it has not yet been initialized by board_init_f_init_reserve)
until the hart has acquired available_harts_lock. This can cause two
problems, depending on the value of gd->flags. If GD_FLG_SERIAL_READY is
unset, then some garbage data will be printed to stdout, but there will not
be a second trap. However, if GD_FLG_SERIAL_READY is set, then puts will
try to print with serial_puts, which will likely cause a second trap.

After this patch, gd is zero up until either a hart has set it in
wait_for_gd_init, or until it is set by arch_init_gd. This prevents its
usage before its data is initialized because both handle_trap and puts
ensure that gd is nonzero before using it. After gd has been set, it is OK
to access it because its data has been cleared (and so flags is valid).

XIP cannot use locks because flash is not writable. This leaves it
vulnerable to the same class of bugs regarding already-pending IPIs as
before this series. Fixing that would require finding another method of
synchronization, which is outside the scope of this series.

Fixes: 7c6ca03eae ("riscv: additional crash information")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
3 years agoriscv: Consolidate fences into AMOs for available_harts_lock
Sean Anderson [Mon, 21 Sep 2020 11:51:39 +0000 (07:51 -0400)]
riscv: Consolidate fences into AMOs for available_harts_lock

We can reduce the number of instructions needed to use available_harts_lock
by using the aq and rl suffixes for AMOs.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
3 years agoriscv: Clear pending IPIs on initialization
Sean Anderson [Mon, 21 Sep 2020 11:51:38 +0000 (07:51 -0400)]
riscv: Clear pending IPIs on initialization

Even though we no longer call smp_function if an IPI was not sent by
U-Boot, we still need to clear any IPIs which were pending from the
execution environment. Otherwise, secondary harts will busy-wait in
secondary_hart_loop, instead of relaxing.

Along with the previous commit ("riscv: Use a valid bit to ignore
already-pending IPIs"), this fixes SMP booting on the Kendryte K210.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
3 years agoriscv: Use a valid bit to ignore already-pending IPIs
Sean Anderson [Mon, 21 Sep 2020 11:51:37 +0000 (07:51 -0400)]
riscv: Use a valid bit to ignore already-pending IPIs

Some IPIs may already be pending when U-Boot is started. This could be a
problem if a secondary hart tries to handle an IPI before the boot hart has
initialized the IPI device.

To be specific, the Kendryte K210 ROM-based bootloader does not clear IPIs
before passing control to U-Boot. Without this patch, the secondary hart
jumps to address 0x0 as soon as it enters secondary_hart_loop, and then
hangs in its trap handler.

This commit introduces a valid bit so secondary harts know when and IPI
originates from U-Boot, and it is safe to use the IPI API. The valid bit is
initialized to 0 by board_init_f_init_reserve. Before this, secondary harts
wait in wait_for_gd_init.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
Reviewed-by: Leo Liang <ycliang@andestech.com>
3 years agoriscv: Match memory barriers between send_ipi_many and handle_ipi
Sean Anderson [Mon, 21 Sep 2020 11:51:36 +0000 (07:51 -0400)]
riscv: Match memory barriers between send_ipi_many and handle_ipi

Without a matching barrier on the write side, the barrier in handle_ipi
does nothing. It was entirely possible for the boot hart to write to addr,
arg0, and arg1 *after* sending the IPI, because there was no barrier on the
sending side.

Fixes: 90ae281437 ("riscv: add option to wait for ack from secondary harts in smp functions")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
Reviewed-by: Leo Liang <ycliang@andestech.com>
3 years agoRevert "riscv: Clear pending interrupts before enabling IPIs"
Sean Anderson [Mon, 21 Sep 2020 11:51:35 +0000 (07:51 -0400)]
Revert "riscv: Clear pending interrupts before enabling IPIs"

Clearing MIP.MSIP is not guaranteed to do anything by the spec. In
addition, most existing RISC-V hardware does nothing when this bit is set.

The following commits "riscv: Use a valid bit to ignore already-pending
IPIs" and "riscv: Clear pending IPIs on initialization" should implement
the original intent of the reverted commit in a more robust manner.

This reverts commit 9472630337e7c4ac442066b5a752aaa8c3b4d4a6.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
3 years agoriscv: Update SiFive device tree for new CLINT driver
Sean Anderson [Mon, 28 Sep 2020 14:52:29 +0000 (10:52 -0400)]
riscv: Update SiFive device tree for new CLINT driver

We currently do this in a u-boot specific dts, but hopefully we can get
these bindings added in Linux in the future.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Pragnesh Patel <pragnesh.patel@openfive.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
3 years agoriscv: Update Kendryte device tree for new CLINT driver
Sean Anderson [Mon, 28 Sep 2020 14:52:28 +0000 (10:52 -0400)]
riscv: Update Kendryte device tree for new CLINT driver

The interrupt controller property is removed from the clint binding because
the clint is not an interrupt-controller. That is, no other devices have an
interrupt which is controlled by the clint.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
3 years agoriscv: clk: Add CLINT clock to kendryte clock driver
Sean Anderson [Mon, 28 Sep 2020 14:52:27 +0000 (10:52 -0400)]
riscv: clk: Add CLINT clock to kendryte clock driver

Another "virtual" clock (in the sense that it isn't configurable). This
could possibly be done as a clock in the device tree, but I think this is a
bit cleaner.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
3 years agoriscv: Rework Sifive CLINT as UCLASS_TIMER driver
Sean Anderson [Mon, 28 Sep 2020 14:52:26 +0000 (10:52 -0400)]
riscv: Rework Sifive CLINT as UCLASS_TIMER driver

This converts the clint driver from the riscv-specific interface to be a
DM-based UCLASS_TIMER driver. In addition, the SiFive DDR driver previously
implicitly depended on the CLINT to select REGMAP.

Unlike Andes's PLMT/PLIC (which AFAIK never have anything pass it a dtb),
the SiFive CLINT is part of the device tree passed in by qemu. This device
tree doesn't have a clocks or clock-frequency property on clint, so we need
to fall back on the timebase-frequency property. Perhaps in the future we
can get a clock-frequency property added to the qemu dtb.

Unlike with the Andes PLMT, the Sifive CLINT is also an IPI controller.
RISCV_SYSCON_CLINT is retained for this purpose.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Pragnesh Patel <pragnesh.patel@openfive.com>
3 years agoriscv: Clean up initialization in Andes PLIC
Sean Anderson [Mon, 28 Sep 2020 14:52:25 +0000 (10:52 -0400)]
riscv: Clean up initialization in Andes PLIC

This merges the PLIC initialization code from two functions into one.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
3 years agoriscv: Rework Andes PLMT as a UCLASS_TIMER driver
Sean Anderson [Mon, 28 Sep 2020 14:52:24 +0000 (10:52 -0400)]
riscv: Rework Andes PLMT as a UCLASS_TIMER driver

This converts the PLMT driver from the riscv-specific timer interface to be
a DM-based UCLASS_TIMER driver.

The clock-frequency/clocks properties are preferred over timebase-frequency
for two reasons. First, properties which affect a device should be located
near its binding in the device tree. Using timebase-frequency only really
makes sense when the cpu itself is the timer device. This is the case when
we read the time from a CSR, but not when there is a separate device.
Second, it lets the device use the clock subsystem which adds flexibility.
If the device is configured for a different clock speed, the timer can
adjust itself.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Rick Chen <rick@andestech.com>
3 years agotimer: Add a test for timer_timebase_fallback
Sean Anderson [Mon, 28 Sep 2020 14:52:23 +0000 (10:52 -0400)]
timer: Add a test for timer_timebase_fallback

To test this function, sandbox CPU must set cpu_platdata.timebase_freq on
bind. It also needs to expose a method to set the current cpu. I also make
some most members of cpu_sandbox_ops static.

On the timer side, the device tree property
sandbox,timebase-frequency-fallback controls whether sandbox_timer_probe
falls back to time_timebase_fallback or to SANDBOX_TIMER_RATE.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agotimer: Add helper for drivers using timebase fallback
Sean Anderson [Mon, 28 Sep 2020 14:52:22 +0000 (10:52 -0400)]
timer: Add helper for drivers using timebase fallback

This function is designed to be used when a timer used to be initialized by
the cpu (e.g. RISC-V timers), but now is initialized by dm_timer_init. In
such a case, the timer may prefer to use the clocks and clock-frequency
properties, but should be able to fall back on using the cpu's
timebase-frequency.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
3 years agoriscv: Rework riscv timer driver to only support S-mode
Sean Anderson [Mon, 28 Sep 2020 14:52:21 +0000 (10:52 -0400)]
riscv: Rework riscv timer driver to only support S-mode

The riscv-timer driver currently serves as a shim for several riscv timer
drivers. This is not too desirable because it bypasses the usual timer
selection via the driver model. There is no easy way to specify an
alternate timing driver, or have the tick rate depend on the cpu's
configured frequency. The timer drivers also do not have device structs,
and so have to rely on storing parameters in gd_t. Lastly, there is no
initialization call, so driver init is done in the same function which
reads the time. This can result in confusing error messages. To a user, it
looks like the driver failed when trying to read the time, whereas it may
have failed while initializing.

This patch removes the shim functionality from the riscv-timer driver, and
has it instead implement the former rdtime.c timer driver. This is because
existing u-boot users who pass in a device tree (e.g. qemu) do not create a
timer device for S-mode u-boot. The existing behavior of creating the
riscv-timer device in the riscv cpu driver must be kept. The actual reading
of the CSRs has been redone in the style of Linux's get_cycles64.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
3 years agoram: sifive: Remove regmap dependency
Bin Meng [Tue, 15 Sep 2020 08:05:07 +0000 (16:05 +0800)]
ram: sifive: Remove regmap dependency

The usage of regmap API in the SiFive RAM driver is not correct.
The reg address should be obtained via dev_read_addr_index() API.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
3 years agoram: sifive: Check return value on clk_enable()
Bin Meng [Tue, 15 Sep 2020 08:05:06 +0000 (16:05 +0800)]
ram: sifive: Check return value on clk_enable()

The return value should be checked otherwise it's useless to
assign the return value to 'ret'.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
3 years agodoc/sipeed/maix: describe RESET and BOOT button
Heinrich Schuchardt [Sat, 5 Sep 2020 10:46:46 +0000 (12:46 +0200)]
doc/sipeed/maix: describe RESET and BOOT button

In the boot flow description add the RESET and BOOT button as well as the
function of the DTR and RTS lines of the serial interface.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agodoc: correct kflash settings for Maix One Dock
Heinrich Schuchardt [Sat, 5 Sep 2020 10:37:49 +0000 (12:37 +0200)]
doc: correct kflash settings for Maix One Dock

The correct kflash parameter value for the Maix One Dock is "dan".

See:
https://github.com/sipeed/platform-kendryte210/blob/master/boards/sipeed-maix-one-dock.json#L22

Fixes: 137dc153fda9 ("doc: riscv: Update documentation for Sipeed MAIX boards")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agocmd: irq: disable CMD_IRQ for riscv arch
Pragnesh Patel [Mon, 24 Aug 2020 15:08:55 +0000 (20:38 +0530)]
cmd: irq: disable CMD_IRQ for riscv arch

For RISC-V arch, no need for CMD_IRQ so disable the same.

Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Rick Chen <rick@andestech.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
3 years agoMerge branch 'next' of https://gitlab.denx.de/u-boot/custodians/u-boot-x86 into next
Tom Rini [Fri, 25 Sep 2020 13:04:01 +0000 (09:04 -0400)]
Merge branch 'next' of https://gitlab.denx.de/u-boot/custodians/u-boot-x86 into next

- Enhance the 'zboot' command to be more like 'bootm' with sub-commands
- The last series of ACPI core changes for programmatic generation of
  ACPI tables
- Add all required ACPI tables for ApolloLake and enable ACPIGEN on
  Chromebook Coral
- A feature minor enhancements to the 'hob' command
- Intel edison: Support for writing an xFSTK image via binman

3 years agox86: edison: Add documentation for using am xFSTK image
Simon Glass [Sun, 6 Sep 2020 16:35:35 +0000 (10:35 -0600)]
x86: edison: Add documentation for using am xFSTK image

Add a description of how to flash Edison using the xFSTK tool.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agox86: edison: Generate an image suitable for xFSTK
Simon Glass [Sun, 6 Sep 2020 16:35:34 +0000 (10:35 -0600)]
x86: edison: Generate an image suitable for xFSTK

It is useful to be able to flash Edison directly without relying on the
installed U-Boot being functional.

Add a binman image for this. It includes a 'OSIP' header (which happens to
look like an MBR / (Master-Boot Record), U-Boot binary and an environment.

I am not able to find a specification for OSIP.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agobinman: Support adding a U-Boot environment
Simon Glass [Sun, 6 Sep 2020 16:35:33 +0000 (10:35 -0600)]
binman: Support adding a U-Boot environment

In some cases it is useful to include a U-Boot environment region in an
image. This allows the board to start up with an environment ready to go.

Add a new entry type for this. The input is a text file containing the
environment entries, one per line, in the format:

   var=value

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agobinman: Show an error when a file is missing
Simon Glass [Sun, 6 Sep 2020 16:35:32 +0000 (10:35 -0600)]
binman: Show an error when a file is missing

The recent support for missing external binaries does not show an error
message when a file is genuinely missing (i.e. it is missing but not
marked as 'external'). This means that when -m is passed to binman, it
will never report a missing file.

Fix this and add a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agox86: Use multiple images
Simon Glass [Sun, 6 Sep 2020 16:35:31 +0000 (10:35 -0600)]
x86: Use multiple images

We already use binman's 'multiple-images' feature with Chrome OS and we
want to use it for Edison. There is no real down-side.

Adjust x86 to always use multiple-images.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agox86: video: Show information about each video device
Simon Glass [Wed, 23 Sep 2020 03:16:40 +0000 (21:16 -0600)]
x86: video: Show information about each video device

At present the 'bdinfo' command shows the framebuffer address, but not the
address of the copy framebuffer, if present. Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agox86: Add support for more than 8 MTRRs
Simon Glass [Tue, 22 Sep 2020 20:54:51 +0000 (14:54 -0600)]
x86: Add support for more than 8 MTRRs

At present the mtrr command only support 8 MTRRs. Some SoCs have more than
that. Update the implementation to support up to 10. Read the number of
MTRRs dynamically instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
3 years agox86: Allow showing details about a HOB entry
Simon Glass [Tue, 22 Sep 2020 20:54:50 +0000 (14:54 -0600)]
x86: Allow showing details about a HOB entry

Some HOBs include information that can be decoded. Add a -v option to the
hob command, to allow this to be displayed. Add the ability to decode a
resource descriptor.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>