summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Kconfig1
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/aiodev/Kconfig8
-rw-r--r--drivers/aiodev/Makefile1
-rw-r--r--drivers/aiodev/am335x_adc.c183
-rw-r--r--drivers/aiodev/core.c4
-rw-r--r--drivers/aiodev/lm75.c7
-rw-r--r--drivers/aiodev/ti_am335x_tscadc.h163
-rw-r--r--drivers/base/driver.c11
-rw-r--r--drivers/clk/clk-ar933x.c6
-rw-r--r--drivers/clk/clk-ar9344.c6
-rw-r--r--drivers/clk/clk-qoric.c2
-rw-r--r--drivers/clk/imx/clk-imx1.c6
-rw-r--r--drivers/clk/imx/clk-imx21.c6
-rw-r--r--drivers/clk/imx/clk-imx25.c6
-rw-r--r--drivers/clk/imx/clk-imx27.c6
-rw-r--r--drivers/clk/imx/clk-imx31.c6
-rw-r--r--drivers/clk/imx/clk-imx35.c6
-rw-r--r--drivers/clk/imx/clk-imx5.c27
-rw-r--r--drivers/clk/imx/clk-imx6.c6
-rw-r--r--drivers/clk/imx/clk-imx6sl.c6
-rw-r--r--drivers/clk/imx/clk-imx6sx.c6
-rw-r--r--drivers/clk/imx/clk-imx6ul.c6
-rw-r--r--drivers/clk/imx/clk-imx7.c6
-rw-r--r--drivers/clk/imx/clk-imx8mp.c4
-rw-r--r--drivers/clk/imx/clk-imx8mq.c5
-rw-r--r--drivers/clk/mvebu/common.c12
-rw-r--r--drivers/clk/mvebu/corediv.c6
-rw-r--r--drivers/clk/mxs/clk-imx23.c6
-rw-r--r--drivers/clk/mxs/clk-imx28.c6
-rw-r--r--drivers/clk/socfpga/clk.c6
-rw-r--r--drivers/clk/tegra/clk-tegra124.c6
-rw-r--r--drivers/clk/tegra/clk-tegra20.c6
-rw-r--r--drivers/clk/tegra/clk-tegra30.c6
-rw-r--r--drivers/clk/zynq/clkc.c6
-rw-r--r--drivers/clocksource/amba-sp804.c6
-rw-r--r--drivers/clocksource/arm_smp_twd.c6
-rw-r--r--drivers/clocksource/bcm2835.c6
-rw-r--r--drivers/clocksource/digic.c6
-rw-r--r--drivers/clocksource/efi.c7
-rw-r--r--drivers/clocksource/efi_x86.c7
-rw-r--r--drivers/clocksource/mvebu.c6
-rw-r--r--drivers/clocksource/nomadik.c6
-rw-r--r--drivers/clocksource/orion.c6
-rw-r--r--drivers/clocksource/rk_timer.c6
-rw-r--r--drivers/clocksource/timer-atmel-pit.c6
-rw-r--r--drivers/clocksource/timer-imx-gpt.c6
-rw-r--r--drivers/clocksource/timer-ti-32k.c6
-rw-r--r--drivers/clocksource/timer-ti-dm.c6
-rw-r--r--drivers/clocksource/uemd.c6
-rw-r--r--drivers/ddr/imx8m/ddr_init.c87
-rw-r--r--drivers/ddr/imx8m/ddrphy_train.c5
-rw-r--r--drivers/ddr/imx8m/ddrphy_utils.c169
-rw-r--r--drivers/dma/apbh_dma.c7
-rw-r--r--drivers/gpio/gpio-ath79.c6
-rw-r--r--drivers/gpio/gpio-davinci.c6
-rw-r--r--drivers/gpio/gpio-digic.c6
-rw-r--r--drivers/gpio/gpio-dw.c6
-rw-r--r--drivers/gpio/gpio-generic.c6
-rw-r--r--drivers/gpio/gpio-imx.c7
-rw-r--r--drivers/gpio/gpio-jz4740.c6
-rw-r--r--drivers/gpio/gpio-malta-fpga-i2c.c6
-rw-r--r--drivers/gpio/gpio-mpc8xxx.c6
-rw-r--r--drivers/gpio/gpio-mxs.c7
-rw-r--r--drivers/gpio/gpio-omap.c6
-rw-r--r--drivers/gpio/gpio-pl061.c6
-rw-r--r--drivers/gpio/gpio-stmpe.c6
-rw-r--r--drivers/gpio/gpio-tegra.c6
-rw-r--r--drivers/gpio/gpio-vf610.c6
-rw-r--r--drivers/hw_random/mxc-rngc.c2
-rw-r--r--drivers/led/led-pca955x.c83
-rw-r--r--drivers/mci/mci-bcm2835.c6
-rw-r--r--drivers/mci/stm32_sdmmc2.c7
-rw-r--r--drivers/memory/mc-tegra124.c6
-rw-r--r--drivers/mfd/da9063.c4
-rw-r--r--drivers/mfd/mc13xxx.c31
-rw-r--r--drivers/mfd/mc34704.c4
-rw-r--r--drivers/mfd/superio.c3
-rw-r--r--drivers/mfd/syscon.c6
-rw-r--r--drivers/misc/acpi-test.c2
-rw-r--r--drivers/mtd/nand/nand_imx.c15
-rw-r--r--drivers/mtd/nand/nand_mxs.c4
-rw-r--r--drivers/mtd/peb.c20
-rw-r--r--drivers/net/ar231x.c6
-rw-r--r--drivers/net/designware_tegra186.c5
-rw-r--r--drivers/net/macb.c55
-rw-r--r--drivers/net/phy/ar8327.c7
-rw-r--r--drivers/net/phy/at803x.c7
-rw-r--r--drivers/net/phy/davicom.c7
-rw-r--r--drivers/net/phy/dp83867.c6
-rw-r--r--drivers/net/phy/lxt.c7
-rw-r--r--drivers/net/phy/marvell.c7
-rw-r--r--drivers/net/phy/micrel.c7
-rw-r--r--drivers/net/phy/mv88e6xxx/port.c8
-rw-r--r--drivers/net/phy/national.c6
-rw-r--r--drivers/net/phy/phy.c6
-rw-r--r--drivers/net/phy/realtek.c7
-rw-r--r--drivers/net/phy/smsc.c6
-rw-r--r--drivers/net/usb/asix.c31
-rw-r--r--drivers/of/base.c116
-rw-r--r--drivers/of/platform.c2
-rw-r--r--drivers/pci/pci-layerscape.c5
-rw-r--r--drivers/phy/usb-nop-xceiv.c6
-rw-r--r--drivers/pinctrl/imx-iomux-v1.c8
-rw-r--r--drivers/pinctrl/imx-iomux-v2.c6
-rw-r--r--drivers/pinctrl/imx-iomux-v3.c10
-rw-r--r--drivers/pinctrl/mvebu/armada-370.c6
-rw-r--r--drivers/pinctrl/mvebu/armada-xp.c7
-rw-r--r--drivers/pinctrl/mvebu/dove.c6
-rw-r--r--drivers/pinctrl/mvebu/kirkwood.c6
-rw-r--r--drivers/pinctrl/pinctrl-at91-pio4.c10
-rw-r--r--drivers/pinctrl/pinctrl-at91.c12
-rw-r--r--drivers/pinctrl/pinctrl-bcm2835.c6
-rw-r--r--drivers/pinctrl/pinctrl-mxs.c6
-rw-r--r--drivers/pinctrl/pinctrl-single.c6
-rw-r--r--drivers/pinctrl/pinctrl-stm32.c6
-rw-r--r--drivers/pinctrl/pinctrl-tegra-xusb.c8
-rw-r--r--drivers/pinctrl/pinctrl-tegra20.c6
-rw-r--r--drivers/pinctrl/pinctrl-tegra30.c10
-rw-r--r--drivers/pinctrl/pinctrl-vf610.c6
-rw-r--r--drivers/power/Kconfig2
-rw-r--r--drivers/power/Makefile2
-rw-r--r--drivers/power/reset/Kconfig16
-rw-r--r--drivers/power/reset/Makefile3
-rw-r--r--drivers/power/reset/reboot-mode.c231
-rw-r--r--drivers/power/reset/syscon-reboot-mode.c129
-rw-r--r--drivers/regulator/anatop-regulator.c1
-rw-r--r--drivers/regulator/bcm2835.c24
-rw-r--r--drivers/regulator/core.c6
-rw-r--r--drivers/regulator/fixed.c1
-rw-r--r--drivers/regulator/pfuze.c13
-rw-r--r--drivers/regulator/stm32-pwr.c7
-rw-r--r--drivers/regulator/stpmic1_regulator.c8
-rw-r--r--drivers/remoteproc/imx_rproc.c251
-rw-r--r--drivers/reset/core.c2
-rw-r--r--drivers/reset/reset-socfpga.c6
-rw-r--r--drivers/reset/reset-stm32.c6
-rw-r--r--drivers/serial/serial_cadence.c6
-rw-r--r--drivers/serial/serial_ns16550.c6
-rw-r--r--drivers/spi/spi.c4
-rw-r--r--drivers/usb/core/usb.c8
-rw-r--r--drivers/usb/dwc2/dwc2.c16
-rw-r--r--drivers/usb/dwc2/dwc2.h4
-rw-r--r--drivers/usb/dwc2/gadget.c6
-rw-r--r--drivers/usb/dwc2/host.c13
-rw-r--r--drivers/usb/imx/chipidea-imx.c5
-rw-r--r--drivers/usb/imx/imx-usb-misc.c8
-rw-r--r--drivers/usb/imx/imx-usb-phy.c8
-rw-r--r--drivers/usb/musb/musb_core.c7
-rw-r--r--drivers/usb/musb/musb_host.c4
-rw-r--r--drivers/usb/musb/phy-am335x.c6
-rw-r--r--drivers/video/imx-ipu-v3/imx-hdmi.c39
-rw-r--r--drivers/video/imx-ipu-v3/imx-ldb.c8
-rw-r--r--drivers/video/imx-ipu-v3/ipu-common.c5
-rw-r--r--drivers/video/imx-ipu-v3/ipufb.c6
-rw-r--r--drivers/video/omap.c7
-rw-r--r--drivers/video/ssd1307fb.c2
-rw-r--r--drivers/watchdog/ar9344_wdt.c21
-rw-r--r--drivers/watchdog/at91sam9_wdt.c6
-rw-r--r--drivers/watchdog/bcm2835_wdt.c6
-rw-r--r--drivers/watchdog/dw_wdt.c19
-rw-r--r--drivers/watchdog/stm32_iwdg.c2
162 files changed, 1676 insertions, 886 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 09595433a0..dda2405780 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -42,5 +42,6 @@ source "drivers/memory/Kconfig"
source "drivers/soc/imx/Kconfig"
source "drivers/nvme/Kconfig"
source "drivers/ddr/Kconfig"
+source "drivers/power/Kconfig"
endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 08a17ff459..5a03bdceab 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -42,3 +42,4 @@ obj-y += memory/
obj-y += soc/imx/
obj-y += nvme/
obj-y += ddr/
+obj-y += power/
diff --git a/drivers/aiodev/Kconfig b/drivers/aiodev/Kconfig
index a4909d8ecd..5fb445c096 100644
--- a/drivers/aiodev/Kconfig
+++ b/drivers/aiodev/Kconfig
@@ -35,4 +35,12 @@ config MC13XXX_ADC
help
Support for MC13783, MC13892, MC34708 ADC
+config AM335X_ADC
+ tristate "AM335X ADC driver"
+ depends on ARCH_AM33XX
+ help
+ Support for ADC on TI AM335X SoCs. Supports simple one-shot readings
+ rather than continuous sampling with DMA, etc. ADC channels should be
+ configured via device tree, using the kernel bindings.
+
endif
diff --git a/drivers/aiodev/Makefile b/drivers/aiodev/Makefile
index d5318deeb0..5f48b2022a 100644
--- a/drivers/aiodev/Makefile
+++ b/drivers/aiodev/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o
obj-$(CONFIG_LM75) += lm75.o
obj-$(CONFIG_MC13XXX_ADC) += mc13xxx_adc.o
obj-$(CONFIG_QORIQ_THERMAL) += qoriq_thermal.o
+obj-$(CONFIG_AM335X_ADC) += am335x_adc.o
diff --git a/drivers/aiodev/am335x_adc.c b/drivers/aiodev/am335x_adc.c
new file mode 100644
index 0000000000..0d6cc426eb
--- /dev/null
+++ b/drivers/aiodev/am335x_adc.c
@@ -0,0 +1,183 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* am335x_adc.c
+ *
+ * Copyright © 2019 Synapse Product Development
+ *
+ * Author: Trent Piepho <trent.piepho@synapse.com>
+ *
+ * This is a simple driver for the ADC in TI's AM335x SoCs. It's designed to
+ * produce one-shot readings and doesn't use the more advanced features, like
+ * the FIFO, triggering, DMA, multi-channel scan programs, etc.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <malloc.h>
+#include <driver.h>
+#include <xfuncs.h>
+#include <errno.h>
+#include <io.h>
+#include <linux/log2.h>
+#include <aiodev.h>
+#include <mach/am33xx-clock.h>
+#include "ti_am335x_tscadc.h"
+
+struct am335x_adc_data {
+ struct aiodevice aiodev;
+ void __iomem *base;
+ struct aiochannel *channels;
+};
+
+static inline void tiadc_write(const struct am335x_adc_data *data, u32 value,
+ u32 reg)
+{
+ writel(value, data->base + reg);
+}
+
+static inline u32 tiadc_read(const struct am335x_adc_data *data, u32 reg)
+{
+ return readl(data->base + reg);
+}
+
+static int am335x_adc_read(struct aiochannel *chan, int *val)
+{
+ struct am335x_adc_data *data =
+ container_of(chan->aiodev, struct am335x_adc_data, aiodev);
+ int timeout = IDLE_TIMEOUT;
+ /* This assumes VREFN = 0V and VREFP = 1.8V */
+ const u32 vrefp = 1800; /* ceil(log2(vrefp)) = 11 */
+ /* Left shift vrefp/4095 by as much as possible without overflowing 32 bits */
+ const u32 shift = 32 - (const_ilog2(vrefp) + 1);
+ const u32 factor = (vrefp << shift) / 4095u;
+ u32 counts;
+
+ /* Make sure FIFO is empty before we start, so we don't get old data */
+ while ((tiadc_read(data, REG_FIFO1CNT) & 0x7f) > 0)
+ tiadc_read(data, REG_FIFO1);
+
+ tiadc_write(data, ENB(chan->index + 1), REG_SE); /* ENB(1) is 1st channel */
+ tiadc_write(data, CNTRLREG_TSCSSENB, REG_CTRL);
+
+ while ((tiadc_read(data, REG_FIFO1CNT) & 0x7f) == 0) {
+ if (--timeout == 0)
+ return -ETIMEDOUT;
+ mdelay(1);
+ }
+
+ counts = tiadc_read(data, REG_FIFO1) & FIFOREAD_DATA_MASK;
+ *val = (counts * factor) >> shift;
+
+ tiadc_write(data, 0, REG_CTRL);
+
+ return 0;
+}
+
+static int am335x_adc_probe(struct device_d *dev)
+{
+ struct device_node *node;
+ struct am335x_adc_data *data;
+ int i, ret;
+
+ data = xzalloc(sizeof(*data));
+ data->aiodev.hwdev = dev;
+ data->aiodev.read = am335x_adc_read;
+ data->base = dev_request_mem_region(dev, 0);
+ if (IS_ERR(data->base)) {
+ ret = PTR_ERR(data->base);
+ goto fail_data;
+ }
+
+ node = of_find_compatible_node(dev->device_node, NULL, "ti,am3359-adc");
+ if (!node) {
+ ret = -EINVAL;
+ goto fail_data;
+ }
+
+ if (!of_find_property(node, "ti,adc-channels",
+ &data->aiodev.num_channels))
+ return -EINVAL;
+ data->aiodev.num_channels /= sizeof(u32);
+
+ data->channels = xzalloc(sizeof(*data->channels) *
+ data->aiodev.num_channels);
+ data->aiodev.channels = xmalloc(sizeof(*data->aiodev.channels) *
+ data->aiodev.num_channels);
+
+ /* Max ADC clock is 24 MHz or 3 MHz, depending on if one looks at the
+ * reference manual or data sheet.
+ */
+ tiadc_write(data, DIV_ROUND_UP(am33xx_get_osc_clock(), ADC_CLK) - 1,
+ REG_CLKDIV);
+ tiadc_write(data, ~0, REG_IRQCLR);
+ tiadc_write(data, ~0, REG_IRQSTATUS);
+ tiadc_write(data, 0x3, REG_DMAENABLE_CLEAR);
+ tiadc_write(data, CNTRLREG_STEPCONFIGWRT, REG_CTRL);
+ tiadc_write(data,
+ STEPCONFIG_RFP_VREFP | STEPCONFIG_RFM_VREFN |
+ STEPCONFIG_INM_ADCREFM | STEPCONFIG_INP_ADCREFM,
+ REG_IDLECONFIG);
+
+
+ for (i = 0; i < data->aiodev.num_channels; i++) {
+ u32 config, delay, ain, odelay, sdelay, avg;
+
+ data->aiodev.channels[i] = &data->channels[i];
+ data->channels[i].unit = "mV";
+ ret = of_property_read_u32_index(node, "ti,adc-channels",
+ i, &ain);
+ if (ret)
+ goto fail_channels;
+
+ ret = of_property_read_u32_index(node, "ti,chan-step-opendelay",
+ i, &odelay);
+ odelay = ret ? STEPCONFIG_OPENDLY : STEPDELAY_OPEN(odelay);
+
+ ret = of_property_read_u32_index(node, "ti,chan-step-sampledelay",
+ i, &sdelay);
+ sdelay = ret ? STEPCONFIG_SAMPLEDLY : STEPDELAY_SAMPLE(sdelay);
+
+ ret = of_property_read_u32_index(node, "ti,chan-step-avg",
+ i, &avg);
+ avg = ret ? STEPCONFIG_AVG_16 : STEPCONFIG_AVG(ilog2(avg ? : 1));
+
+ /* We program each step with one of the channels in the DT */
+ config = STEPCONFIG_RFP_VREFP | STEPCONFIG_RFM_VREFN | /* External refs */
+ /* Internal reference, use STEPCONFIG_RFP(0) | STEPCONFIG_RFM(0) */
+ STEPCONFIG_INM_ADCREFM | /* Not important, SE rather than diff */
+ STEPCONFIG_MODE(0) | STEPCONFIG_FIFO1 | /* One-shot and data to FIFO1 */
+ avg | STEPCONFIG_INP(ain);
+ delay = odelay | sdelay;
+
+ tiadc_write(data, config, REG_STEPCONFIG(i));
+ tiadc_write(data, delay, REG_STEPDELAY(i));
+ }
+ tiadc_write(data, 0, REG_CTRL);
+
+ ret = aiodevice_register(&data->aiodev);
+ if (ret)
+ goto fail_channels;
+
+ dev_info(dev, "TI AM335x ADC (%d ch) registered as %s\n",
+ data->aiodev.num_channels, dev_name(&data->aiodev.dev));
+ return 0;
+
+ fail_channels:
+ kfree(data->channels);
+ kfree(data->aiodev.channels);
+
+ fail_data:
+ kfree(data);
+ return ret;
+}
+
+static const struct of_device_id of_am335x_adc_match[] = {
+ { .compatible = "ti,am3359-tscadc", },
+ { /* end */ }
+};
+
+static struct driver_d am335x_adc_driver = {
+ .name = "am335x_adc",
+ .probe = am335x_adc_probe,
+ .of_compatible = DRV_OF_COMPAT(of_am335x_adc_match),
+};
+device_platform_driver(am335x_adc_driver);
diff --git a/drivers/aiodev/core.c b/drivers/aiodev/core.c
index b8428346a3..7240de2c40 100644
--- a/drivers/aiodev/core.c
+++ b/drivers/aiodev/core.c
@@ -24,7 +24,7 @@
LIST_HEAD(aiodevices);
EXPORT_SYMBOL(aiodevices);
-struct aiochannel *aiochannel_get_by_name(const char *name)
+struct aiochannel *aiochannel_by_name(const char *name)
{
struct aiodevice *aiodev;
int i;
@@ -131,7 +131,7 @@ int aiodevice_register(struct aiodevice *aiodev)
aiochannel_param_get_value,
&aiochan->value, "%d", aiochan);
- aiochan->name = xasprintf("%s.%s", aiodev->name, name);
+ aiochan->name = xasprintf("%s.%s", dev_name(&aiodev->dev), name);
free(name);
}
diff --git a/drivers/aiodev/lm75.c b/drivers/aiodev/lm75.c
index 8186fd2c2b..8e5948f468 100644
--- a/drivers/aiodev/lm75.c
+++ b/drivers/aiodev/lm75.c
@@ -22,6 +22,7 @@
#define LM75_SHUTDOWN 0x01
enum lm75_type { /* keep sorted in alphabetical order */
+ unknown,
adt75,
ds1775,
ds75,
@@ -109,9 +110,9 @@ static int lm75_probe(struct device_d *dev)
int new, ret;
enum lm75_type kind;
- ret = dev_get_drvdata(dev, (const void **)&kind);
- if (ret)
- return ret;
+ kind = (enum lm75_type)device_get_match_data(dev);
+ if (kind == unknown)
+ return -ENODEV;
data = xzalloc(sizeof(*data));
diff --git a/drivers/aiodev/ti_am335x_tscadc.h b/drivers/aiodev/ti_am335x_tscadc.h
new file mode 100644
index 0000000000..36f3c17ac0
--- /dev/null
+++ b/drivers/aiodev/ti_am335x_tscadc.h
@@ -0,0 +1,163 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __LINUX_TI_AM335X_TSCADC_MFD_H
+#define __LINUX_TI_AM335X_TSCADC_MFD_H
+
+/*
+ * TI Touch Screen / ADC MFD driver
+ *
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.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 version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#define REG_RAWIRQSTATUS 0x024
+#define REG_IRQSTATUS 0x028
+#define REG_IRQENABLE 0x02C
+#define REG_IRQCLR 0x030
+#define REG_IRQWAKEUP 0x034
+#define REG_DMAENABLE_SET 0x038
+#define REG_DMAENABLE_CLEAR 0x03c
+#define REG_CTRL 0x040
+#define REG_ADCFSM 0x044
+#define REG_CLKDIV 0x04C
+#define REG_SE 0x054
+#define REG_IDLECONFIG 0x058
+#define REG_CHARGECONFIG 0x05C
+#define REG_CHARGEDELAY 0x060
+#define REG_STEPCONFIG(n) (0x64 + ((n) * 8))
+#define REG_STEPDELAY(n) (0x68 + ((n) * 8))
+#define REG_FIFO0CNT 0xE4
+#define REG_FIFO0THR 0xE8
+#define REG_FIFO1CNT 0xF0
+#define REG_FIFO1THR 0xF4
+#define REG_DMA1REQ 0xF8
+#define REG_FIFO0 0x100
+#define REG_FIFO1 0x200
+
+/* Register Bitfields */
+/* IRQ wakeup enable */
+#define IRQWKUP_ENB BIT(0)
+
+/* Step Enable */
+#define STEPENB_MASK (0x1FFFF << 0)
+#define STEPENB(val) ((val) << 0)
+#define ENB(val) (1 << (val))
+#define STPENB_STEPENB STEPENB(0x1FFFF)
+#define STPENB_STEPENB_TC STEPENB(0x1FFF)
+
+/* IRQ enable */
+#define IRQENB_HW_PEN BIT(0)
+#define IRQENB_EOS BIT(1)
+#define IRQENB_FIFO0THRES BIT(2)
+#define IRQENB_FIFO0OVRRUN BIT(3)
+#define IRQENB_FIFO0UNDRFLW BIT(4)
+#define IRQENB_FIFO1THRES BIT(5)
+#define IRQENB_FIFO1OVRRUN BIT(6)
+#define IRQENB_FIFO1UNDRFLW BIT(7)
+#define IRQENB_PENUP BIT(9)
+
+/* Step Configuration */
+#define STEPCONFIG_MODE_MASK (3 << 0)
+#define STEPCONFIG_MODE(val) ((val) << 0)
+#define STEPCONFIG_MODE_SWCNT STEPCONFIG_MODE(1)
+#define STEPCONFIG_MODE_HWSYNC STEPCONFIG_MODE(2)
+#define STEPCONFIG_AVG_MASK (7 << 2)
+#define STEPCONFIG_AVG(val) ((val) << 2)
+#define STEPCONFIG_AVG_16 STEPCONFIG_AVG(4)
+#define STEPCONFIG_XPP BIT(5)
+#define STEPCONFIG_XNN BIT(6)
+#define STEPCONFIG_YPP BIT(7)
+#define STEPCONFIG_YNN BIT(8)
+#define STEPCONFIG_XNP BIT(9)
+#define STEPCONFIG_YPN BIT(10)
+#define STEPCONFIG_RFP(val) ((val) << 12)
+#define STEPCONFIG_RFP_VREFP (0x3 << 12)
+#define STEPCONFIG_INM_MASK (0xF << 15)
+#define STEPCONFIG_INM(val) ((val) << 15)
+#define STEPCONFIG_INM_ADCREFM STEPCONFIG_INM(8)
+#define STEPCONFIG_INP_MASK (0xF << 19)
+#define STEPCONFIG_INP(val) ((val) << 19)
+#define STEPCONFIG_INP_AN4 STEPCONFIG_INP(4)
+#define STEPCONFIG_INP_ADCREFM STEPCONFIG_INP(8)
+#define STEPCONFIG_FIFO1 BIT(26)
+#define STEPCONFIG_RFM(val) ((val) << 23)
+#define STEPCONFIG_RFM_VREFN (0x3 << 23)
+
+/* Delay register */
+#define STEPDELAY_OPEN_MASK (0x3FFFF << 0)
+#define STEPDELAY_OPEN(val) ((val) << 0)
+#define STEPCONFIG_OPENDLY STEPDELAY_OPEN(0x098)
+#define STEPDELAY_SAMPLE_MASK (0xFF << 24)
+#define STEPDELAY_SAMPLE(val) ((val) << 24)
+#define STEPCONFIG_SAMPLEDLY STEPDELAY_SAMPLE(0)
+
+/* Charge Config */
+#define STEPCHARGE_RFP_MASK (7 << 12)
+#define STEPCHARGE_RFP(val) ((val) << 12)
+#define STEPCHARGE_RFP_XPUL STEPCHARGE_RFP(1)
+#define STEPCHARGE_INM_MASK (0xF << 15)
+#define STEPCHARGE_INM(val) ((val) << 15)
+#define STEPCHARGE_INM_AN1 STEPCHARGE_INM(1)
+#define STEPCHARGE_INP_MASK (0xF << 19)
+#define STEPCHARGE_INP(val) ((val) << 19)
+#define STEPCHARGE_RFM_MASK (3 << 23)
+#define STEPCHARGE_RFM(val) ((val) << 23)
+#define STEPCHARGE_RFM_XNUR STEPCHARGE_RFM(1)
+
+/* Charge delay */
+#define CHARGEDLY_OPEN_MASK (0x3FFFF << 0)
+#define CHARGEDLY_OPEN(val) ((val) << 0)
+#define CHARGEDLY_OPENDLY CHARGEDLY_OPEN(0x400)
+
+/* Control register */
+#define CNTRLREG_TSCSSENB BIT(0)
+#define CNTRLREG_STEPID BIT(1)
+#define CNTRLREG_STEPCONFIGWRT BIT(2)
+#define CNTRLREG_POWERDOWN BIT(4)
+#define CNTRLREG_AFE_CTRL_MASK (3 << 5)
+#define CNTRLREG_AFE_CTRL(val) ((val) << 5)
+#define CNTRLREG_4WIRE CNTRLREG_AFE_CTRL(1)
+#define CNTRLREG_5WIRE CNTRLREG_AFE_CTRL(2)
+#define CNTRLREG_8WIRE CNTRLREG_AFE_CTRL(3)
+#define CNTRLREG_TSCENB BIT(7)
+
+/* FIFO READ Register */
+#define FIFOREAD_DATA_BITS 12
+#define FIFOREAD_DATA_MASK (BIT(FIFOREAD_DATA_BITS) - 1)
+#define FIFOREAD_CHNLID_MASK (0xf << 16)
+
+/* DMA ENABLE/CLEAR Register */
+#define DMA_FIFO0 BIT(0)
+#define DMA_FIFO1 BIT(1)
+
+/* Sequencer Status */
+#define SEQ_STATUS BIT(5)
+#define CHARGE_STEP 0x11
+
+#define ADC_CLK 3000000
+#define TOTAL_STEPS 16
+#define TOTAL_CHANNELS 8
+#define FIFO1_THRESHOLD 19
+
+/*
+ * time in us for processing a single channel, calculated as follows:
+ *
+ * max num cycles = open delay + (sample delay + conv time) * averaging
+ *
+ * max num cycles: 262143 + (255 + 13) * 16 = 266431
+ *
+ * clock frequency: 26MHz / 8 = 3.25MHz
+ * clock period: 1 / 3.25MHz = 308ns
+ *
+ * max processing time: 266431 * 308ns = 83ms(approx)
+ */
+#define IDLE_TIMEOUT 83 /* milliseconds */
+
+#endif
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 412db6c406..3205bbc3c3 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -500,3 +500,14 @@ int dev_get_drvdata(struct device_d *dev, const void **data)
return -ENODEV;
}
+
+const void *device_get_match_data(struct device_d *dev)
+{
+ if (dev->of_id_entry)
+ return dev->of_id_entry->data;
+
+ if (dev->id_entry)
+ return (void *)dev->id_entry->driver_data;
+
+ return NULL;
+}
diff --git a/drivers/clk/clk-ar933x.c b/drivers/clk/clk-ar933x.c
index 875e9f506f..0e7f2d6a67 100644
--- a/drivers/clk/clk-ar933x.c
+++ b/drivers/clk/clk-ar933x.c
@@ -138,8 +138,4 @@ static struct driver_d ar933x_clk_driver = {
.of_compatible = DRV_OF_COMPAT(ar933x_clk_dt_ids),
};
-static int ar933x_clk_init(void)
-{
- return platform_driver_register(&ar933x_clk_driver);
-}
-postcore_initcall(ar933x_clk_init);
+postcore_platform_driver(ar933x_clk_driver);
diff --git a/drivers/clk/clk-ar9344.c b/drivers/clk/clk-ar9344.c
index ad0e5c10e9..829d4b1f91 100644
--- a/drivers/clk/clk-ar9344.c
+++ b/drivers/clk/clk-ar9344.c
@@ -133,8 +133,4 @@ static struct driver_d ar9344_clk_driver = {
.of_compatible = DRV_OF_COMPAT(ar9344_clk_dt_ids),
};
-static int ar9344_clk_init(void)
-{
- return platform_driver_register(&ar9344_clk_driver);
-}
-postcore_initcall(ar9344_clk_init);
+postcore_platform_driver(ar9344_clk_driver);
diff --git a/drivers/clk/clk-qoric.c b/drivers/clk/clk-qoric.c
index 2ffc7613fa..b3e0780bc8 100644
--- a/drivers/clk/clk-qoric.c
+++ b/drivers/clk/clk-qoric.c
@@ -589,7 +589,7 @@ static void __init clockgen_init(struct device_node *np,
clockgen.sysclk = of_clk_get(clockgen.node, 0);
if (IS_ERR(clockgen.sysclk)) {
- pr_err("sysclk not found: %s\n", strerrorp(clockgen.sysclk));
+ pr_err("sysclk not found: %pe\n", clockgen.sysclk);
return;
}
diff --git a/drivers/clk/imx/clk-imx1.c b/drivers/clk/imx/clk-imx1.c
index 258b9dd582..cff32c0f99 100644
--- a/drivers/clk/imx/clk-imx1.c
+++ b/drivers/clk/imx/clk-imx1.c
@@ -102,8 +102,4 @@ static struct driver_d imx1_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx1_ccm_dt_ids),
};
-static int imx1_ccm_init(void)
-{
- return platform_driver_register(&imx1_ccm_driver);
-}
-core_initcall(imx1_ccm_init);
+core_platform_driver(imx1_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx21.c b/drivers/clk/imx/clk-imx21.c
index 0026a55f86..7abd82eeb1 100644
--- a/drivers/clk/imx/clk-imx21.c
+++ b/drivers/clk/imx/clk-imx21.c
@@ -176,8 +176,4 @@ static struct driver_d imx21_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx21_ccm_dt_ids),
};
-static int imx21_ccm_init(void)
-{
- return platform_driver_register(&imx21_ccm_driver);
-}
-core_initcall(imx21_ccm_init);
+core_platform_driver(imx21_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx25.c b/drivers/clk/imx/clk-imx25.c
index 7c2140c215..8aa87a5200 100644
--- a/drivers/clk/imx/clk-imx25.c
+++ b/drivers/clk/imx/clk-imx25.c
@@ -186,8 +186,4 @@ static struct driver_d imx25_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx25_ccm_dt_ids),
};
-static int imx25_ccm_init(void)
-{
- return platform_driver_register(&imx25_ccm_driver);
-}
-core_initcall(imx25_ccm_init);
+core_platform_driver(imx25_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx27.c b/drivers/clk/imx/clk-imx27.c
index cba655c6fe..54894d1032 100644
--- a/drivers/clk/imx/clk-imx27.c
+++ b/drivers/clk/imx/clk-imx27.c
@@ -264,8 +264,4 @@ static struct driver_d imx27_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx27_ccm_dt_ids),
};
-static int imx27_ccm_init(void)
-{
- return platform_driver_register(&imx27_ccm_driver);
-}
-core_initcall(imx27_ccm_init);
+core_platform_driver(imx27_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx31.c b/drivers/clk/imx/clk-imx31.c
index 5fded58b11..fe241cba5f 100644
--- a/drivers/clk/imx/clk-imx31.c
+++ b/drivers/clk/imx/clk-imx31.c
@@ -145,8 +145,4 @@ static struct driver_d imx31_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx31_ccm_dt_ids),
};
-static int imx31_ccm_init(void)
-{
- return platform_driver_register(&imx31_ccm_driver);
-}
-core_initcall(imx31_ccm_init);
+core_platform_driver(imx31_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c
index 17e2ae5e69..9af149f68e 100644
--- a/drivers/clk/imx/clk-imx35.c
+++ b/drivers/clk/imx/clk-imx35.c
@@ -208,8 +208,4 @@ static struct driver_d imx35_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx35_ccm_dt_ids),
};
-static int imx35_ccm_init(void)
-{
- return platform_driver_register(&imx35_ccm_driver);
-}
-core_initcall(imx35_ccm_init);
+core_platform_driver(imx35_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx5.c b/drivers/clk/imx/clk-imx5.c
index 6a07816427..c7a1818bd7 100644
--- a/drivers/clk/imx/clk-imx5.c
+++ b/drivers/clk/imx/clk-imx5.c
@@ -339,7 +339,7 @@ static __maybe_unused struct of_device_id imx50_ccm_dt_ids[] = {
}
};
-static struct driver_d imx50_ccm_driver = {
+static __maybe_unused struct driver_d imx50_ccm_driver = {
.probe = imx50_ccm_probe,
.name = "imx50-ccm",
.of_compatible = DRV_OF_COMPAT(imx50_ccm_dt_ids),
@@ -426,7 +426,7 @@ static __maybe_unused struct of_device_id imx51_ccm_dt_ids[] = {
}
};
-static struct driver_d imx51_ccm_driver = {
+static __maybe_unused struct driver_d imx51_ccm_driver = {
.probe = imx51_ccm_probe,
.name = "imx51-ccm",
.of_compatible = DRV_OF_COMPAT(imx51_ccm_dt_ids),
@@ -522,21 +522,18 @@ static __maybe_unused struct of_device_id imx53_ccm_dt_ids[] = {
}
};
-static struct driver_d imx53_ccm_driver = {
+static __maybe_unused struct driver_d imx53_ccm_driver = {
.probe = imx53_ccm_probe,
.name = "imx53-ccm",
.of_compatible = DRV_OF_COMPAT(imx53_ccm_dt_ids),
};
-static int imx5_ccm_init(void)
-{
- if (IS_ENABLED(CONFIG_ARCH_IMX50))
- platform_driver_register(&imx50_ccm_driver);
- if (IS_ENABLED(CONFIG_ARCH_IMX51))
- platform_driver_register(&imx51_ccm_driver);
- if (IS_ENABLED(CONFIG_ARCH_IMX53))
- platform_driver_register(&imx53_ccm_driver);
-
- return 0;
-}
-core_initcall(imx5_ccm_init);
+#if IS_ENABLED(CONFIG_ARCH_IMX50)
+core_platform_driver(imx50_ccm_driver);
+#endif
+#if IS_ENABLED(CONFIG_ARCH_IMX51)
+core_platform_driver(imx51_ccm_driver);
+#endif
+#if IS_ENABLED(CONFIG_ARCH_IMX53)
+core_platform_driver(imx53_ccm_driver);
+#endif
diff --git a/drivers/clk/imx/clk-imx6.c b/drivers/clk/imx/clk-imx6.c
index b8b37a0c68..cb03024458 100644
--- a/drivers/clk/imx/clk-imx6.c
+++ b/drivers/clk/imx/clk-imx6.c
@@ -837,8 +837,4 @@ static struct driver_d imx6_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx6_ccm_dt_ids),
};
-static int imx6_ccm_init(void)
-{
- return platform_driver_register(&imx6_ccm_driver);
-}
-core_initcall(imx6_ccm_init);
+core_platform_driver(imx6_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx6sl.c b/drivers/clk/imx/clk-imx6sl.c
index 6ccc36e3b9..8d0766c055 100644
--- a/drivers/clk/imx/clk-imx6sl.c
+++ b/drivers/clk/imx/clk-imx6sl.c
@@ -316,8 +316,4 @@ static struct driver_d imx6sl_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx6sl_ccm_dt_ids),
};
-static int imx6sl_ccm_init(void)
-{
- return platform_driver_register(&imx6sl_ccm_driver);
-}
-core_initcall(imx6sl_ccm_init);
+core_platform_driver(imx6sl_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx6sx.c b/drivers/clk/imx/clk-imx6sx.c
index d682e41e7c..bacde8b893 100644
--- a/drivers/clk/imx/clk-imx6sx.c
+++ b/drivers/clk/imx/clk-imx6sx.c
@@ -470,8 +470,4 @@ static struct driver_d imx6sx_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx6sx_ccm_dt_ids),
};
-static int imx6sx_ccm_init(void)
-{
- return platform_driver_register(&imx6sx_ccm_driver);
-}
-core_initcall(imx6sx_ccm_init);
+core_platform_driver(imx6sx_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx6ul.c b/drivers/clk/imx/clk-imx6ul.c
index 79b52b7ce9..6668146860 100644
--- a/drivers/clk/imx/clk-imx6ul.c
+++ b/drivers/clk/imx/clk-imx6ul.c
@@ -466,8 +466,4 @@ static struct driver_d imx6_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx6_ccm_dt_ids),
};
-static int imx6_ccm_init(void)
-{
- return platform_driver_register(&imx6_ccm_driver);
-}
-core_initcall(imx6_ccm_init);
+core_platform_driver(imx6_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx7.c b/drivers/clk/imx/clk-imx7.c
index b6c7c2c3a8..ffa39d17b0 100644
--- a/drivers/clk/imx/clk-imx7.c
+++ b/drivers/clk/imx/clk-imx7.c
@@ -858,8 +858,4 @@ static struct driver_d imx7_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx7_ccm_dt_ids),
};
-static int imx7_ccm_init(void)
-{
- return platform_driver_register(&imx7_ccm_driver);
-}
-core_initcall(imx7_ccm_init);
+core_platform_driver(imx7_ccm_driver);
diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
index da63b5ce48..14770bd9a4 100644
--- a/drivers/clk/imx/clk-imx8mp.c
+++ b/drivers/clk/imx/clk-imx8mp.c
@@ -369,7 +369,7 @@ static const char * const imx8mp_media_cam2_pix_sels[] = {"osc_24m", "sys_pll1_2
"sys_pll3_out", "audio_pll2_out",
"video_pll1_out", };
-static const char * const imx8mp_media_mipi_phy2_ref_sels[] = {"osc_24m", "sys_pll2_333m", "sys_pll2_100m",
+static const char * const imx8mp_media_ldb_sels[] = {"osc_24m", "sys_pll2_333m", "sys_pll2_100m",
"sys_pll1_800m", "sys_pll2_1000m",
"clk_ext2", "audio_pll2_out",
"video_pll1_out", };
@@ -620,7 +620,7 @@ static int imx8mp_clocks_init(struct device_node *ccm_np)
hws[IMX8MP_CLK_MEDIA_MIPI_PHY1_REF] = imx8m_clk_hw_composite("media_mipi_phy1_ref", imx8mp_media_mipi_phy1_ref_sels, ccm_base + 0xbd80);
hws[IMX8MP_CLK_MEDIA_DISP1_PIX] = imx8m_clk_hw_composite("media_disp1_pix", imx8mp_media_disp1_pix_sels, ccm_base + 0xbe00);
hws[IMX8MP_CLK_MEDIA_CAM2_PIX] = imx8m_clk_hw_composite("media_cam2_pix", imx8mp_media_cam2_pix_sels, ccm_base + 0xbe80);
- hws[IMX8MP_CLK_MEDIA_MIPI_PHY2_REF] = imx8m_clk_hw_composite("media_mipi_phy2_ref", imx8mp_media_mipi_phy2_ref_sels, ccm_base + 0xbf00);
+ hws[IMX8MP_CLK_MEDIA_LDB] = imx8m_clk_hw_composite("media_ldb", imx8mp_media_ldb_sels, ccm_base + 0xbf00);
hws[IMX8MP_CLK_MEDIA_MIPI_CSI2_ESC] = imx8m_clk_hw_composite("media_mipi_csi2_esc", imx8mp_media_mipi_csi2_esc_sels, ccm_base + 0xbf80);
hws[IMX8MP_CLK_PCIE2_CTRL] = imx8m_clk_hw_composite("pcie2_ctrl", imx8mp_pcie2_ctrl_sels, ccm_base + 0xc000);
hws[IMX8MP_CLK_PCIE2_PHY] = imx8m_clk_hw_composite("pcie2_phy", imx8mp_pcie2_phy_sels, ccm_base + 0xc080);
diff --git a/drivers/clk/imx/clk-imx8mq.c b/drivers/clk/imx/clk-imx8mq.c
index 016d405e90..4072faacaf 100644
--- a/drivers/clk/imx/clk-imx8mq.c
+++ b/drivers/clk/imx/clk-imx8mq.c
@@ -255,6 +255,9 @@ static const char *imx8mq_dram_core_sels[] = {"dram_pll_out", "dram_alt_root", }
static const char *imx8mq_clko2_sels[] = {"osc_25m", "sys2_pll_200m", "sys1_pll_400m", "sys2_pll_166m", "audio_pll1_out",
"video_pll1_out", "ckil", };
+static const char * const imx8mq_arm_m4_sels[] = {"osc_25m", "sys2_pll_200m",
+ "sys2_pll_250m", "sys1_pll_266m", "sys1_pll_800m", "audio_pll1_out",
+ "video_pll1_out", "sys3_pll_out", };
static struct clk_onecell_data clk_data;
@@ -552,6 +555,8 @@ static int imx8mq_clocks_init(struct device_node *ccm_node)
clks[IMX8MQ_CLK_SDMA1_ROOT] = imx_clk_gate4("sdma1_clk", "ipg_root", base + 0x43a0, 0);
clks[IMX8MQ_CLK_SDMA2_ROOT] = imx_clk_gate4("sdma2_clk", "ipg_audio_root", base + 0x43b0, 0);
+ clks[IMX8MQ_CLK_M4_CORE] = imx8m_clk_hw_composite_core("arm_m4_core", imx8mq_arm_m4_sels, base + 0x8080);
+
clks[IMX8MQ_GPT_3M_CLK] = imx_clk_fixed_factor("gpt_3m", "osc_25m", 1, 8);
clks[IMX8MQ_CLK_DRAM_ALT_ROOT] = imx_clk_fixed_factor("dram_alt_root", "dram_alt", 1, 4);
diff --git a/drivers/clk/mvebu/common.c b/drivers/clk/mvebu/common.c
index c7de00ac77..3d924ccf4d 100644
--- a/drivers/clk/mvebu/common.c
+++ b/drivers/clk/mvebu/common.c
@@ -102,11 +102,7 @@ static struct driver_d mvebu_coreclk_driver = {
.of_compatible = DRV_OF_COMPAT(mvebu_coreclk_ids),
};
-static int mvebu_coreclk_init(void)
-{
- return platform_driver_register(&mvebu_coreclk_driver);
-}
-core_initcall(mvebu_coreclk_init);
+core_platform_driver(mvebu_coreclk_driver);
/*
* Clock Gating Control
@@ -207,8 +203,4 @@ static struct driver_d mvebu_clk_gating_driver = {
.of_compatible = DRV_OF_COMPAT(mvebu_clk_gating_ids),
};
-static int mvebu_clk_gating_init(void)
-{
- return platform_driver_register(&mvebu_clk_gating_driver);
-}
-postcore_initcall(mvebu_clk_gating_init);
+postcore_platform_driver(mvebu_clk_gating_driver);
diff --git a/drivers/clk/mvebu/corediv.c b/drivers/clk/mvebu/corediv.c
index f740161e45..1577a2149c 100644
--- a/drivers/clk/mvebu/corediv.c
+++ b/drivers/clk/mvebu/corediv.c
@@ -254,8 +254,4 @@ static struct driver_d mvebu_corediv_clk_driver = {
.of_compatible = DRV_OF_COMPAT(mvebu_corediv_clk_ids),
};
-static int mvebu_corediv_clk_init(void)
-{
- return platform_driver_register(&mvebu_corediv_clk_driver);
-}
-postcore_initcall(mvebu_corediv_clk_init);
+postcore_platform_driver(mvebu_corediv_clk_driver);
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index dae8e348e2..a211b64f2c 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -141,8 +141,4 @@ static struct driver_d imx23_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx23_ccm_dt_ids),
};
-static int imx23_ccm_init(void)
-{
- return platform_driver_register(&imx23_ccm_driver);
-}
-postcore_initcall(imx23_ccm_init);
+postcore_platform_driver(imx23_ccm_driver);
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index bf65a4a3b8..aa4ba99cd7 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -202,8 +202,4 @@ static struct driver_d imx28_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(imx28_ccm_dt_ids),
};
-static int imx28_ccm_init(void)
-{
- return platform_driver_register(&imx28_ccm_driver);
-}
-postcore_initcall(imx28_ccm_init);
+postcore_platform_driver(imx28_ccm_driver);
diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
index 1d34b15caf..09e2039bd5 100644
--- a/drivers/clk/socfpga/clk.c
+++ b/drivers/clk/socfpga/clk.c
@@ -428,8 +428,4 @@ static struct driver_d socfpga_ccm_driver = {
.of_compatible = DRV_OF_COMPAT(socfpga_ccm_dt_ids),
};
-static int socfpga_ccm_init(void)
-{
- return platform_driver_register(&socfpga_ccm_driver);
-}
-core_initcall(socfpga_ccm_init);
+core_platform_driver(socfpga_ccm_driver);
diff --git a/drivers/clk/tegra/clk-tegra124.c b/drivers/clk/tegra/clk-tegra124.c
index f5704b83c5..bdd822e296 100644
--- a/drivers/clk/tegra/clk-tegra124.c
+++ b/drivers/clk/tegra/clk-tegra124.c
@@ -368,8 +368,4 @@ static struct driver_d tegra124_car_driver = {
.of_compatible = DRV_OF_COMPAT(tegra124_car_dt_ids),
};
-static int tegra124_car_init(void)
-{
- return platform_driver_register(&tegra124_car_driver);
-}
-postcore_initcall(tegra124_car_init);
+postcore_platform_driver(tegra124_car_driver);
diff --git a/drivers/clk/tegra/clk-tegra20.c b/drivers/clk/tegra/clk-tegra20.c
index 9fccff6136..6e5fa144e4 100644
--- a/drivers/clk/tegra/clk-tegra20.c
+++ b/drivers/clk/tegra/clk-tegra20.c
@@ -371,8 +371,4 @@ static struct driver_d tegra20_car_driver = {
.of_compatible = DRV_OF_COMPAT(tegra20_car_dt_ids),
};
-static int tegra20_car_init(void)
-{
- return platform_driver_register(&tegra20_car_driver);
-}
-postcore_initcall(tegra20_car_init);
+postcore_platform_driver(tegra20_car_driver);
diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c
index 3d3a7854ff..505851f8f5 100644
--- a/drivers/clk/tegra/clk-tegra30.c
+++ b/drivers/clk/tegra/clk-tegra30.c
@@ -399,8 +399,4 @@ static struct driver_d tegra30_car_driver = {
.of_compatible = DRV_OF_COMPAT(tegra30_car_dt_ids),
};
-static int tegra30_car_init(void)
-{
- return platform_driver_register(&tegra30_car_driver);
-}
-postcore_initcall(tegra30_car_init);
+postcore_platform_driver(tegra30_car_driver);
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index 1d9d28ea14..23259a5324 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -490,8 +490,4 @@ static struct driver_d zynq_clock_driver = {
.of_compatible = DRV_OF_COMPAT(zynq_clock_dt_ids),
};
-static int zynq_clock_init(void)
-{
- return platform_driver_register(&zynq_clock_driver);
-}
-postcore_initcall(zynq_clock_init);
+postcore_platform_driver(zynq_clock_driver);
diff --git a/drivers/clocksource/amba-sp804.c b/drivers/clocksource/amba-sp804.c
index 66e3988b4c..8ed5ae4be0 100644
--- a/drivers/clocksource/amba-sp804.c
+++ b/drivers/clocksource/amba-sp804.c
@@ -85,8 +85,4 @@ struct amba_driver sp804_driver = {
.id_table = sp804_ids,
};
-static int sp804_init(void)
-{
- return amba_driver_register(&sp804_driver);
-}
-coredevice_initcall(sp804_init);
+coredevice_platform_driver(sp804_driver);
diff --git a/drivers/clocksource/arm_smp_twd.c b/drivers/clocksource/arm_smp_twd.c
index 226150aa42..5a1e5a7921 100644
--- a/drivers/clocksource/arm_smp_twd.c
+++ b/drivers/clocksource/arm_smp_twd.c
@@ -105,8 +105,4 @@ static struct driver_d smp_twd_driver = {
.of_compatible = DRV_OF_COMPAT(smp_twd_compatible),
};
-static int smp_twd_init(void)
-{
- return platform_driver_register(&smp_twd_driver);
-}
-coredevice_initcall(smp_twd_init);
+coredevice_platform_driver(smp_twd_driver);
diff --git a/drivers/clocksource/bcm2835.c b/drivers/clocksource/bcm2835.c
index 9130a4b14f..179109aee2 100644
--- a/drivers/clocksource/bcm2835.c
+++ b/drivers/clocksource/bcm2835.c
@@ -95,8 +95,4 @@ static struct driver_d bcm2835_cs_driver = {
.of_compatible = DRV_OF_COMPAT(bcm2835_cs_dt_ids),
};
-static int bcm2835_cs_init(void)
-{
- return platform_driver_register(&bcm2835_cs_driver);
-}
-core_initcall(bcm2835_cs_init);
+core_platform_driver(bcm2835_cs_driver);
diff --git a/drivers/clocksource/digic.c b/drivers/clocksource/digic.c
index 23e0d5b76b..9079733eba 100644
--- a/drivers/clocksource/digic.c
+++ b/drivers/clocksource/digic.c
@@ -88,8 +88,4 @@ static struct driver_d digic_timer_driver = {
.of_compatible = DRV_OF_COMPAT(digic_timer_dt_ids),
};
-static int digic_timer_init(void)
-{
- return platform_driver_register(&digic_timer_driver);
-}
-coredevice_initcall(digic_timer_init);
+coredevice_platform_driver(digic_timer_driver);
diff --git a/drivers/clocksource/efi.c b/drivers/clocksource/efi.c
index fb5b7ca63d..658d146fb5 100644
--- a/drivers/clocksource/efi.c
+++ b/drivers/clocksource/efi.c
@@ -106,9 +106,4 @@ static struct driver_d efi_cs_driver = {
.probe = efi_cs_probe,
};
-static int efi_cs_initcall(void)
-{
- return platform_driver_register(&efi_cs_driver);
-}
-/* for efi the time must be init at core initcall level */
-core_initcall(efi_cs_initcall);
+core_platform_driver(efi_cs_driver);
diff --git a/drivers/clocksource/efi_x86.c b/drivers/clocksource/efi_x86.c
index f8d3ff8a43..364e1ef8e1 100644
--- a/drivers/clocksource/efi_x86.c
+++ b/drivers/clocksource/efi_x86.c
@@ -71,9 +71,4 @@ static struct driver_d efi_x86_cs_driver = {
.probe = efi_x86_cs_probe,
};
-static int efi_x86_cs_initcall(void)
-{
- return platform_driver_register(&efi_x86_cs_driver);
-}
-/* for efi the time must be init at core initcall level */
-core_initcall(efi_x86_cs_initcall);
+core_platform_driver(efi_x86_cs_driver);
diff --git a/drivers/clocksource/mvebu.c b/drivers/clocksource/mvebu.c
index b55d72a343..5a47d6f217 100644
--- a/drivers/clocksource/mvebu.c
+++ b/drivers/clocksource/mvebu.c
@@ -105,8 +105,4 @@ static struct driver_d mvebu_timer_driver = {
.of_compatible = DRV_OF_COMPAT(mvebu_timer_dt_ids),
};
-static int mvebu_timer_init(void)
-{
- return platform_driver_register(&mvebu_timer_driver);
-}
-postcore_initcall(mvebu_timer_init);
+postcore_platform_driver(mvebu_timer_driver);
diff --git a/drivers/clocksource/nomadik.c b/drivers/clocksource/nomadik.c
index 9b20cbc946..7d5d9f9f77 100644
--- a/drivers/clocksource/nomadik.c
+++ b/drivers/clocksource/nomadik.c
@@ -142,8 +142,4 @@ static struct driver_d nmdk_mtu_driver = {
.probe = nmdk_mtu_probe,
};
-static int nmdk_mtu_init(void)
-{
- return platform_driver_register(&nmdk_mtu_driver);
-}
-coredevice_initcall(nmdk_mtu_init);
+coredevice_platform_driver(nmdk_mtu_driver);
diff --git a/drivers/clocksource/orion.c b/drivers/clocksource/orion.c
index 97008dabab..c9f50b729e 100644
--- a/drivers/clocksource/orion.c
+++ b/drivers/clocksource/orion.c
@@ -79,8 +79,4 @@ static struct driver_d orion_timer_driver = {
.of_compatible = DRV_OF_COMPAT(orion_timer_dt_ids),
};
-static int orion_timer_init(void)
-{
- return platform_driver_register(&orion_timer_driver);
-}
-postcore_initcall(orion_timer_init);
+postcore_platform_driver(orion_timer_driver);
diff --git a/drivers/clocksource/rk_timer.c b/drivers/clocksource/rk_timer.c
index baa517c62f..5cc8d32b60 100644
--- a/drivers/clocksource/rk_timer.c
+++ b/drivers/clocksource/rk_timer.c
@@ -66,8 +66,4 @@ static struct driver_d rktimer_driver = {
.of_compatible = DRV_OF_COMPAT(rktimer_dt_ids),
};
-static int rktimer_init(void)
-{
- return platform_driver_register(&rktimer_driver);
-}
-core_initcall(rktimer_init);
+core_platform_driver(rktimer_driver);
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index 50572ff5f8..368aae2450 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -112,8 +112,4 @@ static struct driver_d at91_pit_driver = {
.of_compatible = DRV_OF_COMPAT(at91_pit_dt_ids),
};
-static int at91_pit_init(void)
-{
- return platform_driver_register(&at91_pit_driver);
-}
-postcore_initcall(at91_pit_init);
+postcore_platform_driver(at91_pit_driver);
diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c
index 881065bf9f..6be0afed4d 100644
--- a/drivers/clocksource/timer-imx-gpt.c
+++ b/drivers/clocksource/timer-imx-gpt.c
@@ -182,8 +182,4 @@ static struct driver_d imx_gpt_driver = {
.id_table = imx_gpt_ids,
};
-static int imx_gpt_init(void)
-{
- return platform_driver_register(&imx_gpt_driver);
-}
-postcore_initcall(imx_gpt_init);
+postcore_platform_driver(imx_gpt_driver);
diff --git a/drivers/clocksource/timer-ti-32k.c b/drivers/clocksource/timer-ti-32k.c
index f93ab5bcff..755c78095f 100644
--- a/drivers/clocksource/timer-ti-32k.c
+++ b/drivers/clocksource/timer-ti-32k.c
@@ -99,8 +99,4 @@ static struct driver_d omap_32ktimer_driver = {
.of_compatible = DRV_OF_COMPAT(omap_32ktimer_dt_ids),
};
-static int omap_32ktimer_init(void)
-{
- return platform_driver_register(&omap_32ktimer_driver);
-}
-postcore_initcall(omap_32ktimer_init);
+postcore_platform_driver(omap_32ktimer_driver);
diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c
index f41f0bb423..86882fcaf5 100644
--- a/drivers/clocksource/timer-ti-dm.c
+++ b/drivers/clocksource/timer-ti-dm.c
@@ -112,8 +112,4 @@ static struct driver_d omap_dmtimer_driver = {
.of_compatible = DRV_OF_COMPAT(omap_dmtimer_dt_ids),
};
-static int omap_dmtimer_init(void)
-{
- return platform_driver_register(&omap_dmtimer_driver);
-}
-postcore_initcall(omap_dmtimer_init);
+postcore_platform_driver(omap_dmtimer_driver);
diff --git a/drivers/clocksource/uemd.c b/drivers/clocksource/uemd.c
index 5eacfdaf1b..02fa8a1c5b 100644
--- a/drivers/clocksource/uemd.c
+++ b/drivers/clocksource/uemd.c
@@ -123,8 +123,4 @@ static struct driver_d uemd_timer_driver = {
.of_compatible = DRV_OF_COMPAT(uemd_timer_dt_ids),
};
-static int uemd_timer_init(void)
-{
- return platform_driver_register(&uemd_timer_driver);
-}
-coredevice_initcall(uemd_timer_init);
+coredevice_platform_driver(uemd_timer_driver);
diff --git a/drivers/ddr/imx8m/ddr_init.c b/drivers/ddr/imx8m/ddr_init.c
index d4efee6133..1cd7b7406d 100644
--- a/drivers/ddr/imx8m/ddr_init.c
+++ b/drivers/ddr/imx8m/ddr_init.c
@@ -13,8 +13,6 @@
#include <mach/imx8m-regs.h>
#include <mach/imx8m-ccm-regs.h>
-#define SRC_DDRC_RCR_ADDR MX8MQ_SRC_DDRC_RCR_ADDR
-
static void ddr_cfg_umctl2(struct dram_cfg_param *ddrc_cfg, int num)
{
int i = 0;
@@ -25,14 +23,37 @@ static void ddr_cfg_umctl2(struct dram_cfg_param *ddrc_cfg, int num)
}
}
-static int imx8m_ddr_init(unsigned long src_ddrc_rcr,
- struct dram_timing_info *dram_timing)
+/*
+ * We store the timing parameters here. the TF-A will pick these up.
+ * Note that the timing used we leave the driver with is a PLL bypass 25MHz
+ * mode. So if your board runs horribly slow you'll likely have to provide a
+ * TF-A binary.
+ */
+#define IMX8M_SAVED_DRAM_TIMING_BASE 0x180000
+
+static int imx8m_ddr_init(struct dram_timing_info *dram_timing,
+ enum ddrc_type type)
{
+ unsigned long src_ddrc_rcr = MX8M_SRC_DDRC_RCR_ADDR;
unsigned int tmp, initial_drate, target_freq;
int ret;
pr_debug("start DRAM init\n");
+ /* Step1: Follow the power up procedure */
+ switch (type) {
+ case DDRC_TYPE_MQ:
+ reg32_write(src_ddrc_rcr + 0x04, 0x8f00000f);
+ reg32_write(src_ddrc_rcr, 0x8f00000f);
+ reg32_write(src_ddrc_rcr + 0x04, 0x8f000000);
+ break;
+ case DDRC_TYPE_MM:
+ case DDRC_TYPE_MP:
+ reg32_write(src_ddrc_rcr, 0x8f00001f);
+ reg32_write(src_ddrc_rcr, 0x8f00000f);
+ break;
+ }
+
pr_debug("cfg clk\n");
/* disable iso */
@@ -44,7 +65,7 @@ static int imx8m_ddr_init(unsigned long src_ddrc_rcr,
ddrphy_init_set_dfi_clk(initial_drate);
/* D-aasert the presetn */
- reg32_write(SRC_DDRC_RCR_ADDR, 0x8F000006);
+ reg32_write(src_ddrc_rcr, 0x8F000006);
/* Step2: Program the dwc_ddr_umctl2 registers */
pr_debug("ddrc config start\n");
@@ -52,8 +73,8 @@ static int imx8m_ddr_init(unsigned long src_ddrc_rcr,
pr_debug("ddrc config done\n");
/* Step3: De-assert reset signal(core_ddrc_rstn & aresetn_n) */
- reg32_write(SRC_DDRC_RCR_ADDR, 0x8F000004);
- reg32_write(SRC_DDRC_RCR_ADDR, 0x8F000000);
+ reg32_write(src_ddrc_rcr, 0x8F000004);
+ reg32_write(src_ddrc_rcr, 0x8F000000);
/*
* Step4: Disable auto-refreshes, self-refresh, powerdown, and
@@ -113,6 +134,9 @@ static int imx8m_ddr_init(unsigned long src_ddrc_rcr,
/* Step15: Set SWCTL.sw_done to 0 */
reg32_write(DDRC_SWCTL(0), 0x00000000);
+ /* Apply rank-to-rank workaround */
+ update_umctl2_rank_space_setting(dram_timing->fsp_msg_num - 1, type);
+
/* Step16: Set DFIMISC.dfi_init_start to 1 */
setbits_le32(DDRC_DFIMISC(0), (0x1 << 5));
@@ -156,58 +180,29 @@ static int imx8m_ddr_init(unsigned long src_ddrc_rcr,
/* Step26: Set back register in Step4 to the original values if desired */
reg32_write(DDRC_RFSHCTL3(0), 0x0000000);
/* enable selfref_en by default */
- setbits_le32(DDRC_PWRCTL(0), 0x1 << 3);
+ setbits_le32(DDRC_PWRCTL(0), 0x1);
/* enable port 0 */
reg32_write(DDRC_PCTRL_0(0), 0x00000001);
pr_debug(" ddrmix config done\n");
+ /* save the dram timing config into memory */
+ dram_config_save(dram_timing, IMX8M_SAVED_DRAM_TIMING_BASE);
+
return 0;
}
-/*
- * We store the timing parameters here. the TF-A will pick these up.
- * Note that the timing used we leave the driver with is a PLL bypass 25MHz
- * mode. So if your board runs horribly slow you'll likely have to provide a
- * TF-A binary.
- */
-#define IMX8M_SAVED_DRAM_TIMING_BASE 0x180000
-
int imx8mm_ddr_init(struct dram_timing_info *dram_timing)
{
- unsigned long src_ddrc_rcr = MX8M_SRC_DDRC_RCR_ADDR;
- int ret;
-
- /* Step1: Follow the power up procedure */
- reg32_write(src_ddrc_rcr, 0x8f00001f);
- reg32_write(src_ddrc_rcr, 0x8f00000f);
-
- ret = imx8m_ddr_init(src_ddrc_rcr, dram_timing);
- if (ret)
- return ret;
-
- /* save the dram timing config into memory */
- dram_config_save(dram_timing, IMX8M_SAVED_DRAM_TIMING_BASE);
-
- return 0;
+ return imx8m_ddr_init(dram_timing, DDRC_TYPE_MM);
}
int imx8mq_ddr_init(struct dram_timing_info *dram_timing)
{
- unsigned long src_ddrc_rcr = MX8MQ_SRC_DDRC_RCR_ADDR;
- int ret;
-
- /* Step1: Follow the power up procedure */
- reg32_write(src_ddrc_rcr + 0x04, 0x8f00000f);
- reg32_write(src_ddrc_rcr, 0x8f00000f);
- reg32_write(src_ddrc_rcr + 0x04, 0x8f000000);
-
- ret = imx8m_ddr_init(src_ddrc_rcr, dram_timing);
- if (ret)
- return ret;
-
- /* save the dram timing config into memory */
- dram_config_save(dram_timing, IMX8M_SAVED_DRAM_TIMING_BASE);
+ return imx8m_ddr_init(dram_timing, DDRC_TYPE_MQ);
+}
- return 0;
+int imx8mp_ddr_init(struct dram_timing_info *dram_timing)
+{
+ return imx8m_ddr_init(dram_timing, DDRC_TYPE_MP);
}
diff --git a/drivers/ddr/imx8m/ddrphy_train.c b/drivers/ddr/imx8m/ddrphy_train.c
index ca0bb2f57b..9280c853aa 100644
--- a/drivers/ddr/imx8m/ddrphy_train.c
+++ b/drivers/ddr/imx8m/ddrphy_train.c
@@ -93,7 +93,12 @@ int ddr_cfg_phy(struct dram_timing_info *dram_timing)
/* Read the Message Block results */
dwc_ddrphy_apb_wr(0xd0000, 0x0);
+
ddrphy_init_read_msg_block(fsp_msg->fw_type);
+
+ if (fsp_msg->fw_type != FW_2D_IMAGE)
+ get_trained_CDD(i);
+
dwc_ddrphy_apb_wr(0xd0000, 0x1);
fsp_msg++;
diff --git a/drivers/ddr/imx8m/ddrphy_utils.c b/drivers/ddr/imx8m/ddrphy_utils.c
index 222b61be3d..c483724910 100644
--- a/drivers/ddr/imx8m/ddrphy_utils.c
+++ b/drivers/ddr/imx8m/ddrphy_utils.c
@@ -306,3 +306,172 @@ void ddrphy_init_set_dfi_clk(unsigned int drate)
void ddrphy_init_read_msg_block(enum fw_type type)
{
}
+
+static unsigned int g_cdd_rr_max[4];
+static unsigned int g_cdd_rw_max[4];
+static unsigned int g_cdd_wr_max[4];
+static unsigned int g_cdd_ww_max[4];
+
+static unsigned int look_for_max(unsigned int data[], unsigned int addr_start,
+ unsigned int addr_end)
+{
+ unsigned int i, imax = 0;
+
+ for (i = addr_start; i <= addr_end; i++) {
+ if (((data[i] >> 7) == 0) && (data[i] > imax))
+ imax = data[i];
+ }
+
+ return imax;
+}
+
+void get_trained_CDD(u32 fsp)
+{
+ unsigned int i, ddr_type, tmp;
+ unsigned int cdd_cha[12], cdd_chb[12];
+ unsigned int cdd_cha_rr_max, cdd_cha_rw_max, cdd_cha_wr_max, cdd_cha_ww_max;
+ unsigned int cdd_chb_rr_max, cdd_chb_rw_max, cdd_chb_wr_max, cdd_chb_ww_max;
+
+ ddr_type = reg32_read(DDRC_MSTR(0)) & 0x3f;
+ if (ddr_type == 0x20) {
+ for (i = 0; i < 6; i++) {
+ tmp = reg32_read(IP2APB_DDRPHY_IPS_BASE_ADDR(0) +
+ (0x54013UL + i) * 4);
+ cdd_cha[i * 2] = tmp & 0xff;
+ cdd_cha[i * 2 + 1] = (tmp >> 8) & 0xff;
+ }
+
+ for (i = 0; i < 7; i++) {
+ tmp = reg32_read(IP2APB_DDRPHY_IPS_BASE_ADDR(0) +
+ (0x5402cUL + i) * 4);
+ if (i == 0) {
+ cdd_cha[0] = (tmp >> 8) & 0xff;
+ } else if (i == 6) {
+ cdd_cha[11] = tmp & 0xff;
+ } else {
+ cdd_chb[ i * 2 - 1] = tmp & 0xff;
+ cdd_chb[i * 2] = (tmp >> 8) & 0xff;
+ }
+ }
+
+ cdd_cha_rr_max = look_for_max(cdd_cha, 0, 1);
+ cdd_cha_rw_max = look_for_max(cdd_cha, 2, 5);
+ cdd_cha_wr_max = look_for_max(cdd_cha, 6, 9);
+ cdd_cha_ww_max = look_for_max(cdd_cha, 10, 11);
+ cdd_chb_rr_max = look_for_max(cdd_chb, 0, 1);
+ cdd_chb_rw_max = look_for_max(cdd_chb, 2, 5);
+ cdd_chb_wr_max = look_for_max(cdd_chb, 6, 9);
+ cdd_chb_ww_max = look_for_max(cdd_chb, 10, 11);
+ g_cdd_rr_max[fsp] = cdd_cha_rr_max > cdd_chb_rr_max ? cdd_cha_rr_max : cdd_chb_rr_max;
+ g_cdd_rw_max[fsp] = cdd_cha_rw_max > cdd_chb_rw_max ? cdd_cha_rw_max : cdd_chb_rw_max;
+ g_cdd_wr_max[fsp] = cdd_cha_wr_max > cdd_chb_wr_max ? cdd_cha_wr_max : cdd_chb_wr_max;
+ g_cdd_ww_max[fsp] = cdd_cha_ww_max > cdd_chb_ww_max ? cdd_cha_ww_max : cdd_chb_ww_max;
+ } else {
+ unsigned int ddr4_cdd[64];
+
+ for( i = 0; i < 29; i++) {
+ tmp = reg32_read(IP2APB_DDRPHY_IPS_BASE_ADDR(0) +
+ (0x54012UL + i) * 4);
+ ddr4_cdd[i * 2] = tmp & 0xff;
+ ddr4_cdd[i * 2 + 1] = (tmp >> 8) & 0xff;
+ }
+
+ g_cdd_rr_max[fsp] = look_for_max(ddr4_cdd, 1, 12);
+ g_cdd_ww_max[fsp] = look_for_max(ddr4_cdd, 13, 24);
+ g_cdd_rw_max[fsp] = look_for_max(ddr4_cdd, 25, 40);
+ g_cdd_wr_max[fsp] = look_for_max(ddr4_cdd, 41, 56);
+ }
+}
+
+void update_umctl2_rank_space_setting(unsigned int pstat_num,
+ enum ddrc_type type)
+{
+ unsigned int i,ddr_type;
+ unsigned int rdata, tmp, tmp_t;
+ unsigned int ddrc_w2r,ddrc_r2w,ddrc_wr_gap,ddrc_rd_gap;
+ unsigned long addr_slot;
+
+ ddr_type = reg32_read(DDRC_MSTR(0)) & 0x3f;
+ for (i = 0; i < pstat_num; i++) {
+ addr_slot = i ? (i + 1) * 0x1000 : 0;
+ if (ddr_type == 0x20) {
+ /* update r2w:[13:8], w2r:[5:0] */
+ rdata = reg32_read(DDRC_DRAMTMG2(0) + addr_slot);
+ ddrc_w2r = rdata & 0x3f;
+ if (type == DDRC_TYPE_MP)
+ tmp = ddrc_w2r + (g_cdd_wr_max[i] >> 1);
+ else
+ tmp = ddrc_w2r + (g_cdd_wr_max[i] >> 1) + 1;
+ ddrc_w2r = (tmp > 0x3f) ? 0x3f : tmp;
+
+ ddrc_r2w = (rdata >> 8) & 0x3f;
+ if (type == DDRC_TYPE_MP)
+ tmp = ddrc_r2w + (g_cdd_rw_max[i] >> 1);
+ else
+ tmp = ddrc_r2w + (g_cdd_rw_max[i] >> 1) + 1;
+ ddrc_r2w = (tmp > 0x3f) ? 0x3f : tmp;
+
+ tmp_t = (rdata & 0xffffc0c0) | (ddrc_r2w << 8) | ddrc_w2r;
+ reg32_write((DDRC_DRAMTMG2(0) + addr_slot), tmp_t);
+ } else {
+ /* update w2r:[5:0] */
+ rdata = reg32_read(DDRC_DRAMTMG9(0) + addr_slot);
+ ddrc_w2r = rdata & 0x3f;
+ if (type == DDRC_TYPE_MP)
+ tmp = ddrc_w2r + (g_cdd_wr_max[i] >> 1);
+ else
+ tmp = ddrc_w2r + (g_cdd_wr_max[i] >> 1) + 1;
+ ddrc_w2r = (tmp > 0x3f) ? 0x3f : tmp;
+ tmp_t = (rdata & 0xffffffc0) | ddrc_w2r;
+ reg32_write((DDRC_DRAMTMG9(0) + addr_slot), tmp_t);
+
+ /* update r2w:[13:8] */
+ rdata = reg32_read(DDRC_DRAMTMG2(0) + addr_slot);
+ ddrc_r2w = (rdata >> 8) & 0x3f;
+ if (type == DDRC_TYPE_MP)
+ tmp = ddrc_r2w + (g_cdd_rw_max[i] >> 1);
+ else
+ tmp = ddrc_r2w + (g_cdd_rw_max[i] >> 1) + 1;
+ ddrc_r2w = (tmp > 0x3f) ? 0x3f : tmp;
+
+ tmp_t = (rdata & 0xffffc0ff) | (ddrc_r2w << 8);
+ reg32_write((DDRC_DRAMTMG2(0) + addr_slot), tmp_t);
+ }
+
+ if (type != DDRC_TYPE_MQ) {
+ /* update rankctl: wr_gap:11:8; rd:gap:7:4; quasi-dymic, doc wrong(static) */
+ rdata = reg32_read(DDRC_RANKCTL(0) + addr_slot);
+ ddrc_wr_gap = (rdata >> 8) & 0xf;
+ if (type == DDRC_TYPE_MP)
+ tmp = ddrc_wr_gap + (g_cdd_ww_max[i] >> 1);
+ else
+ tmp = ddrc_wr_gap + (g_cdd_ww_max[i] >> 1) + 1;
+ ddrc_wr_gap = (tmp > 0xf) ? 0xf : tmp;
+
+ ddrc_rd_gap = (rdata >> 4) & 0xf;
+ if (type == DDRC_TYPE_MP)
+ tmp = ddrc_rd_gap + (g_cdd_rr_max[i] >> 1);
+ else
+ tmp = ddrc_rd_gap + (g_cdd_rr_max[i] >> 1) + 1;
+ ddrc_rd_gap = (tmp > 0xf) ? 0xf : tmp;
+
+ tmp_t = (rdata & 0xfffff00f) | (ddrc_wr_gap << 8) | (ddrc_rd_gap << 4);
+ reg32_write((DDRC_RANKCTL(0) + addr_slot), tmp_t);
+ }
+ }
+
+ if (type == DDRC_TYPE_MQ) {
+ /* update rankctl: wr_gap:11:8; rd:gap:7:4; quasi-dymic, doc wrong(static) */
+ rdata = reg32_read(DDRC_RANKCTL(0));
+ ddrc_wr_gap = (rdata >> 8) & 0xf;
+ tmp = ddrc_wr_gap + (g_cdd_ww_max[0] >> 1) + 1;
+ ddrc_wr_gap = (tmp > 0xf) ? 0xf : tmp;
+
+ ddrc_rd_gap = (rdata >> 4) & 0xf;
+ tmp = ddrc_rd_gap + (g_cdd_rr_max[0] >> 1) + 1;
+ ddrc_rd_gap = (tmp > 0xf) ? 0xf : tmp;
+
+ tmp_t = (rdata & 0xfffff00f) | (ddrc_wr_gap << 8) | (ddrc_rd_gap << 4);
+ reg32_write(DDRC_RANKCTL(0), tmp_t);
+ }
+}
diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index 3bee89f78b..0e4961f6cb 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -50,6 +50,7 @@
static struct mxs_dma_chan mxs_dma_channels[MXS_MAX_DMA_CHANNELS];
enum mxs_dma_id {
+ UNKNOWN_DMA_ID,
IMX23_DMA,
IMX28_DMA,
};
@@ -596,9 +597,9 @@ static int apbh_dma_probe(struct device_d *dev)
enum mxs_dma_id id;
int ret, channel;
- ret = dev_get_drvdata(dev, (const void **)&id);
- if (ret)
- return ret;
+ id = (enum mxs_dma_id)device_get_match_data(dev);
+ if (id == UNKNOWN_DMA_ID)
+ return -ENODEV;
apbh_dma = apbh = xzalloc(sizeof(*apbh));
iores = dev_request_mem_resource(dev, 0);
diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c
index d08d743b54..1e66107c84 100644
--- a/drivers/gpio/gpio-ath79.c
+++ b/drivers/gpio/gpio-ath79.c
@@ -151,8 +151,4 @@ static struct driver_d ath79_gpio_driver = {
.of_compatible = DRV_OF_COMPAT(ath79_gpio_of_match),
};
-static int ath79_gpio_init(void)
-{
- return platform_driver_register(&ath79_gpio_driver);
-}
-coredevice_initcall(ath79_gpio_init);
+coredevice_platform_driver(ath79_gpio_driver);
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 7c060a09b1..3346209f76 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -206,8 +206,4 @@ static struct driver_d davinci_gpio_driver = {
.of_compatible = DRV_OF_COMPAT(davinci_gpio_ids),
};
-static int davinci_gpio_drv_reg(void)
-{
- return platform_driver_register(&davinci_gpio_driver);
-}
-coredevice_initcall(davinci_gpio_drv_reg);
+coredevice_platform_driver(davinci_gpio_driver);
diff --git a/drivers/gpio/gpio-digic.c b/drivers/gpio/gpio-digic.c
index f7a68d09fc..9faa27c183 100644
--- a/drivers/gpio/gpio-digic.c
+++ b/drivers/gpio/gpio-digic.c
@@ -176,8 +176,4 @@ static struct driver_d digic_gpio_driver = {
.of_compatible = DRV_OF_COMPAT(digic_gpio_dt_ids),
};
-static int digic_gpio_init(void)
-{
- return platform_driver_register(&digic_gpio_driver);
-}
-coredevice_initcall(digic_gpio_init);
+coredevice_platform_driver(digic_gpio_driver);
diff --git a/drivers/gpio/gpio-dw.c b/drivers/gpio/gpio-dw.c
index b81e6a75c5..b7a61a8d90 100644
--- a/drivers/gpio/gpio-dw.c
+++ b/drivers/gpio/gpio-dw.c
@@ -195,8 +195,4 @@ static struct driver_d dwgpio_driver = {
.of_compatible = DRV_OF_COMPAT(dwgpio_match),
};
-static int __init dwgpio_init(void)
-{
- return platform_driver_register(&dwgpio_driver);
-}
-postcore_initcall(dwgpio_init);
+postcore_platform_driver(dwgpio_driver);
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index 2e0dad9974..a9ddf26fa4 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -424,11 +424,7 @@ static struct driver_d bgpio_driver = {
.remove = bgpio_dev_remove,
};
-static int bgpio_register(void)
-{
- return platform_driver_register(&bgpio_driver);
-}
-coredevice_initcall(bgpio_register);
+coredevice_platform_driver(bgpio_driver);
#endif
diff --git a/drivers/gpio/gpio-imx.c b/drivers/gpio/gpio-imx.c
index 2827e11e73..c7ebce0b86 100644
--- a/drivers/gpio/gpio-imx.c
+++ b/drivers/gpio/gpio-imx.c
@@ -217,9 +217,4 @@ static struct driver_d imx_gpio_driver = {
.id_table = imx_gpio_ids,
};
-static int imx_gpio_add(void)
-{
- platform_driver_register(&imx_gpio_driver);
- return 0;
-}
-postcore_initcall(imx_gpio_add);
+postcore_platform_driver(imx_gpio_driver);
diff --git a/drivers/gpio/gpio-jz4740.c b/drivers/gpio/gpio-jz4740.c
index 87e0716b06..bf99b718e8 100644
--- a/drivers/gpio/gpio-jz4740.c
+++ b/drivers/gpio/gpio-jz4740.c
@@ -136,8 +136,4 @@ static struct driver_d jz4740_gpio_driver = {
.of_compatible = DRV_OF_COMPAT(jz4740_gpio_dt_ids),
};
-static int jz4740_gpio_init(void)
-{
- return platform_driver_register(&jz4740_gpio_driver);
-}
-coredevice_initcall(jz4740_gpio_init);
+coredevice_platform_driver(jz4740_gpio_driver);
diff --git a/drivers/gpio/gpio-malta-fpga-i2c.c b/drivers/gpio/gpio-malta-fpga-i2c.c
index 9142248571..8002f7b73a 100644
--- a/drivers/gpio/gpio-malta-fpga-i2c.c
+++ b/drivers/gpio/gpio-malta-fpga-i2c.c
@@ -180,8 +180,4 @@ static struct driver_d malta_i2c_gpio_driver = {
.of_compatible = DRV_OF_COMPAT(malta_i2c_gpio_dt_ids),
};
-static int malta_i2c_gpio_driver_init(void)
-{
- return platform_driver_register(&malta_i2c_gpio_driver);
-}
-coredevice_initcall(malta_i2c_gpio_driver_init);
+coredevice_platform_driver(malta_i2c_gpio_driver);
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index 979f92ad30..710e5d1176 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -115,8 +115,4 @@ static struct driver_d mpc8xxx_driver = {
.of_compatible = DRV_OF_COMPAT(mpc8xxx_gpio_ids),
};
-static int __init mpc8xxx_init(void)
-{
- return platform_driver_register(&mpc8xxx_driver);
-}
-postcore_initcall(mpc8xxx_init);
+postcore_platform_driver(mpc8xxx_driver);
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index ef78873ad2..aca93f5b27 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -178,9 +178,4 @@ static struct driver_d mxs_gpio_driver = {
.id_table = mxs_gpio_ids,
};
-static int mxs_gpio_add(void)
-{
- platform_driver_register(&mxs_gpio_driver);
- return 0;
-}
-postcore_initcall(mxs_gpio_add);
+postcore_platform_driver(mxs_gpio_driver);
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index b00766a6aa..88fca4f68a 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -192,8 +192,4 @@ static struct driver_d omap_gpio_driver = {
.of_compatible = DRV_OF_COMPAT(omap_gpio_dt_ids),
};
-static int omap_gpio_add(void)
-{
- return platform_driver_register(&omap_gpio_driver);
-}
-coredevice_initcall(omap_gpio_add);
+coredevice_platform_driver(omap_gpio_driver);
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index f34aba9da9..c17c265440 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -147,11 +147,7 @@ static struct amba_driver pl061_gpio_driver = {
.probe = pl061_probe,
};
-static int __init pl061_gpio_init(void)
-{
- return amba_driver_register(&pl061_gpio_driver);
-}
-coredevice_initcall(pl061_gpio_init);
+coredevice_platform_driver(pl061_gpio_driver);
MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
MODULE_DESCRIPTION("PL061 GPIO driver");
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index d7e64045b4..ef37fe0dcf 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -154,8 +154,4 @@ static struct driver_d stmpe_gpio_driver = {
.probe = stmpe_gpio_probe,
};
-static int stmpe_gpio_add(void)
-{
- return platform_driver_register(&stmpe_gpio_driver);
-}
-coredevice_initcall(stmpe_gpio_add);
+coredevice_platform_driver(stmpe_gpio_driver);
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 56808b57e4..2348ce664a 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -201,8 +201,4 @@ static struct driver_d tegra_gpio_driver = {
.probe = tegra_gpio_probe,
};
-static int __init tegra_gpio_init(void)
-{
- return platform_driver_register(&tegra_gpio_driver);
-}
-coredevice_initcall(tegra_gpio_init);
+coredevice_platform_driver(tegra_gpio_driver);
diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
index ab35310fbe..b08b396a6e 100644
--- a/drivers/gpio/gpio-vf610.c
+++ b/drivers/gpio/gpio-vf610.c
@@ -156,8 +156,4 @@ static struct driver_d vf610_gpio_driver = {
.of_compatible = DRV_OF_COMPAT(vf610_gpio_dt_ids),
};
-static int __init gpio_vf610_init(void)
-{
- return platform_driver_register(&vf610_gpio_driver);
-}
-postcore_initcall(gpio_vf610_init);
+postcore_platform_driver(vf610_gpio_driver);
diff --git a/drivers/hw_random/mxc-rngc.c b/drivers/hw_random/mxc-rngc.c
index 3ed25aa61d..075c20e437 100644
--- a/drivers/hw_random/mxc-rngc.c
+++ b/drivers/hw_random/mxc-rngc.c
@@ -133,7 +133,7 @@ static int mxc_rngc_data_present(struct hwrng *rng)
static int mxc_rngc_read(struct hwrng *rng, void *buf, size_t max, bool wait)
{
struct mxc_rngc *rngc = container_of(rng, struct mxc_rngc, rng);
- unsigned int err;
+ unsigned int err = 0;
int count = 0;
u32 *data = buf;
diff --git a/drivers/led/led-pca955x.c b/drivers/led/led-pca955x.c
index 27fefce8d5..07bc26a50b 100644
--- a/drivers/led/led-pca955x.c
+++ b/drivers/led/led-pca955x.c
@@ -72,53 +72,47 @@ enum led_brightness {
LED_FULL = 255,
};
-enum pca955x_type {
- pca9550,
- pca9551,
- pca9552,
- pca9553,
-};
-
struct pca955x_chipdef {
int bits;
u8 slv_addr; /* 7-bit slave address mask */
int slv_addr_shift; /* Number of bits to ignore */
};
-static struct pca955x_chipdef pca955x_chipdefs[] = {
- [pca9550] = {
- .bits = 2,
- .slv_addr = /* 110000x */ 0x60,
- .slv_addr_shift = 1,
- },
- [pca9551] = {
- .bits = 8,
- .slv_addr = /* 1100xxx */ 0x60,
- .slv_addr_shift = 3,
- },
- [pca9552] = {
- .bits = 16,
- .slv_addr = /* 1100xxx */ 0x60,
- .slv_addr_shift = 3,
- },
- [pca9553] = {
- .bits = 4,
- .slv_addr = /* 110001x */ 0x62,
- .slv_addr_shift = 1,
- },
+static const struct pca955x_chipdef pca9550_chipdef = {
+ .bits = 2,
+ .slv_addr = /* 110000x */ 0x60,
+ .slv_addr_shift = 1,
+};
+
+static const struct pca955x_chipdef pca9551_chipdef = {
+ .bits = 8,
+ .slv_addr = /* 1100xxx */ 0x60,
+ .slv_addr_shift = 3,
+};
+
+static const struct pca955x_chipdef pca9552_chipdef = {
+ .bits = 16,
+ .slv_addr = /* 1100xxx */ 0x60,
+ .slv_addr_shift = 3,
+};
+
+static const struct pca955x_chipdef pca9553_chipdef = {
+ .bits = 4,
+ .slv_addr = /* 110001x */ 0x62,
+ .slv_addr_shift = 1,
};
static const struct platform_device_id led_pca955x_id[] = {
- { "pca9550", pca9550 },
- { "pca9551", pca9551 },
- { "pca9552", pca9552 },
- { "pca9553", pca9553 },
+ { "pca9550", (unsigned long) &pca9550_chipdef },
+ { "pca9551", (unsigned long) &pca9551_chipdef },
+ { "pca9552", (unsigned long) &pca9552_chipdef },
+ { "pca9553", (unsigned long) &pca9553_chipdef },
{ }
};
struct pca955x {
struct pca955x_led *leds;
- struct pca955x_chipdef *chipdef;
+ const struct pca955x_chipdef *chipdef;
struct i2c_client *client;
};
@@ -278,7 +272,7 @@ static struct pca955x_platform_data *
led_pca955x_pdata_of_init(struct device_node *np, struct pca955x *pca955x)
{
struct device_node *child;
- struct pca955x_chipdef *chip = pca955x->chipdef;
+ const struct pca955x_chipdef *chip = pca955x->chipdef;
struct pca955x_platform_data *pdata;
int count, err;
@@ -334,10 +328,10 @@ led_pca955x_pdata_of_init(struct device_node *np, struct pca955x *pca955x)
}
static const struct of_device_id of_pca955x_match[] = {
- { .compatible = "nxp,pca9550", .data = (void *)pca9550 },
- { .compatible = "nxp,pca9551", .data = (void *)pca9551 },
- { .compatible = "nxp,pca9552", .data = (void *)pca9552 },
- { .compatible = "nxp,pca9553", .data = (void *)pca9553 },
+ { .compatible = "nxp,pca9550", .data = &pca9550_chipdef },
+ { .compatible = "nxp,pca9551", .data = &pca9551_chipdef },
+ { .compatible = "nxp,pca9552", .data = &pca9552_chipdef },
+ { .compatible = "nxp,pca9553", .data = &pca9553_chipdef },
{},
};
@@ -345,12 +339,15 @@ static int led_pca955x_probe(struct device_d *dev)
{
struct pca955x *pca955x;
struct pca955x_led *pca955x_led;
- struct pca955x_chipdef *chip;
+ const struct pca955x_chipdef *chip;
struct i2c_client *client;
int err;
struct pca955x_platform_data *pdata;
- chip = &pca955x_chipdefs[dev->id_entry->driver_data];
+ chip = device_get_match_data(dev);
+ if (!chip)
+ return -ENODEV;
+
client = to_i2c_client(dev);
/* Make sure the slave address / chip type combo given is possible */
@@ -413,8 +410,4 @@ static struct driver_d led_pca955x_driver = {
.of_compatible = DRV_OF_COMPAT(of_pca955x_match),
};
-static int __init led_pca955x_init(void)
-{
- return i2c_driver_register(&led_pca955x_driver);
-}
-device_initcall(led_pca955x_init);
+device_i2c_driver(led_pca955x_driver);
diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
index c463c623e7..91027857be 100644
--- a/drivers/mci/mci-bcm2835.c
+++ b/drivers/mci/mci-bcm2835.c
@@ -447,8 +447,4 @@ static struct driver_d bcm2835_mci_driver = {
.of_compatible = DRV_OF_COMPAT(bcm2835_mci_compatible),
};
-static int bcm2835_mci_add(void)
-{
- return platform_driver_register(&bcm2835_mci_driver);
-}
-device_initcall(bcm2835_mci_add);
+device_platform_driver(bcm2835_mci_driver);
diff --git a/drivers/mci/stm32_sdmmc2.c b/drivers/mci/stm32_sdmmc2.c
index da2dc592ad..0c620427ee 100644
--- a/drivers/mci/stm32_sdmmc2.c
+++ b/drivers/mci/stm32_sdmmc2.c
@@ -633,11 +633,16 @@ priv_free:
}
static struct amba_id stm32_sdmmc2_ids[] = {
- /* ST Micro STM32MP157C */
+ /* ST Micro STM32MP15 v1.1 */
{
.id = 0x10153180,
.mask = 0xf0ffffff,
},
+ /* ST Micro STM32MP15 v2.0 */
+ {
+ .id = 0x00253180,
+ .mask = 0xf0ffffff,
+ },
{ 0, 0 },
};
diff --git a/drivers/memory/mc-tegra124.c b/drivers/memory/mc-tegra124.c
index a8d16094c6..09d9d89a49 100644
--- a/drivers/memory/mc-tegra124.c
+++ b/drivers/memory/mc-tegra124.c
@@ -68,8 +68,4 @@ static struct driver_d tegra124_mc_driver = {
.probe = tegra124_mc_probe,
};
-static int __init tegra124_mc_init(void)
-{
- return platform_driver_register(&tegra124_mc_driver);
-}
-device_initcall(tegra124_mc_init);
+device_platform_driver(tegra124_mc_driver);
diff --git a/drivers/mfd/da9063.c b/drivers/mfd/da9063.c
index e48c38affa..31359cf8b8 100644
--- a/drivers/mfd/da9063.c
+++ b/drivers/mfd/da9063.c
@@ -370,11 +370,9 @@ static int da9063_probe(struct device_d *dev)
{
struct da9063 *priv = NULL;
struct da906x_device_data const *dev_data;
- void const *dev_data_tmp;
int ret;
- ret = dev_get_drvdata(dev, &dev_data_tmp);
- dev_data = ret < 0 ? NULL : dev_data_tmp;
+ dev_data = device_get_match_data(dev);
priv = xzalloc(sizeof(struct da9063));
priv->wd.set_timeout = da9063_watchdog_set_timeout;
diff --git a/drivers/mfd/mc13xxx.c b/drivers/mfd/mc13xxx.c
index a5877dbda1..1f321a3272 100644
--- a/drivers/mfd/mc13xxx.c
+++ b/drivers/mfd/mc13xxx.c
@@ -399,37 +399,24 @@ static __maybe_unused struct of_device_id mc13xxx_dt_ids[] = {
{ }
};
-static struct driver_d mc13xxx_i2c_driver = {
+static __maybe_unused struct driver_d mc13xxx_i2c_driver = {
.name = "mc13xxx-i2c",
.probe = mc13xxx_probe,
.id_table = mc13xxx_ids,
.of_compatible = DRV_OF_COMPAT(mc13xxx_dt_ids),
};
-static struct driver_d mc13xxx_spi_driver = {
+#if IS_ENABLED(CONFIG_I2C)
+coredevice_i2c_driver(mc13xxx_i2c_driver);
+#endif
+
+static __maybe_unused struct driver_d mc13xxx_spi_driver = {
.name = "mc13xxx-spi",
.probe = mc13xxx_probe,
.id_table = mc13xxx_ids,
.of_compatible = DRV_OF_COMPAT(mc13xxx_dt_ids),
};
-static int __init mc13xxx_init(void)
-{
- int err_spi = 0, err_i2c = 0;
-
- if (IS_ENABLED(CONFIG_I2C))
- err_spi = i2c_driver_register(&mc13xxx_i2c_driver);
-
- if (IS_ENABLED(CONFIG_SPI))
- err_i2c = spi_driver_register(&mc13xxx_spi_driver);
-
- if (err_spi)
- return err_spi;
-
- if (err_i2c)
- return err_i2c;
-
- return 0;
-
-}
-coredevice_initcall(mc13xxx_init);
+#if IS_ENABLED(CONFIG_SPI)
+coredevice_spi_driver(mc13xxx_spi_driver);
+#endif
diff --git a/drivers/mfd/mc34704.c b/drivers/mfd/mc34704.c
index 4aa02b74ff..29071c5ccf 100644
--- a/drivers/mfd/mc34704.c
+++ b/drivers/mfd/mc34704.c
@@ -43,7 +43,7 @@ int mc34704_reg_read(struct mc34704 *mc34704, u8 reg, u8 *val)
{
int ret;
- ret = i2c_read_reg(mc34704->client, reg, val, 1);
+ ret = i2c_read_reg(mc34704->client, 1 << 7 | reg, val, 1);
return ret == 1 ? 0 : ret;
}
@@ -112,7 +112,7 @@ static int mc34704_probe(struct device_d *dev)
mc34704_dev = xzalloc(sizeof(struct mc34704));
mc34704_dev->cdev.name = DRIVERNAME;
mc34704_dev->client = to_i2c_client(dev);
- mc34704_dev->cdev.size = 256;
+ mc34704_dev->cdev.size = 128;
mc34704_dev->cdev.dev = dev;
mc34704_dev->cdev.ops = &mc34704_fops;
diff --git a/drivers/mfd/superio.c b/drivers/mfd/superio.c
index ab94a4fa8f..fff26968ea 100644
--- a/drivers/mfd/superio.c
+++ b/drivers/mfd/superio.c
@@ -87,8 +87,7 @@ void superio_chip_add(struct superio_chip *siochip)
regmap = regmap_init(siochip->dev, &superio_regmap_bus, siochip,
&superio_regmap_config);
if (IS_ERR(regmap))
- pr_warn("creating %s regmap failed: %s\n",
- chipname, strerrorp(regmap));
+ pr_warn("creating %s regmap failed: %pe\n", chipname, regmap);
ret = regmap_register_cdev(regmap, chipname);
if (ret)
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index a464dfc506..25e308b2d6 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -267,11 +267,7 @@ static struct driver_d syscon_driver = {
.id_table = syscon_ids,
};
-static int __init syscon_init(void)
-{
- return platform_driver_register(&syscon_driver);
-}
-core_initcall(syscon_init);
+core_platform_driver(syscon_driver);
MODULE_AUTHOR("Dong Aisheng <dong.aisheng@linaro.org>");
MODULE_DESCRIPTION("System Control driver");
diff --git a/drivers/misc/acpi-test.c b/drivers/misc/acpi-test.c
index 970b435a0e..1d6814ebcf 100644
--- a/drivers/misc/acpi-test.c
+++ b/drivers/misc/acpi-test.c
@@ -29,7 +29,7 @@ static int acpi_test_probe(struct device_d *dev)
sdt = (u8 __force *)dev_request_mem_region_by_name(dev, "SDT");
if (IS_ERR(sdt)) {
- dev_err(dev, "no SDT resource available: %s\n", strerrorp(sdt));
+ dev_err(dev, "no SDT resource available: %pe\n", sdt);
return PTR_ERR(sdt);
}
diff --git a/drivers/mtd/nand/nand_imx.c b/drivers/mtd/nand/nand_imx.c
index 5e4504a48e..3d4082fe18 100644
--- a/drivers/mtd/nand/nand_imx.c
+++ b/drivers/mtd/nand/nand_imx.c
@@ -1008,14 +1008,23 @@ static void imx_nand_command(struct nand_chip *chip, unsigned command,
else
host->buf_start = column + mtd->writesize;
- command = NAND_CMD_READ0;
-
- host->send_cmd(host, command);
+ host->send_cmd(host, NAND_CMD_READ0);
mxc_do_addr_cycle(chip, column, page_addr);
if (host->pagesize_2k)
/* send read confirm command */
host->send_cmd(host, NAND_CMD_READSTART);
+
+ /*
+ * After the core issued READOOB the result is read using
+ * .read_buf, so we have to make sure the data is actually
+ * there.
+ */
+ if (command == NAND_CMD_READOOB) {
+ host->send_page(host, NFC_OUTPUT);
+ copy_spare(mtd, 1, host->data_buf + mtd->writesize);
+ }
+
break;
case NAND_CMD_SEQIN:
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index 310ce92944..9f7ab14426 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -2143,9 +2143,7 @@ static int mxs_nand_probe(struct device_d *dev)
if (mxs_nand_mtd)
return -EBUSY;
- err = dev_get_drvdata(dev, (const void **)&type);
- if (err)
- type = GPMI_MXS;
+ type = (enum gpmi_type)device_get_match_data(dev);
nand_info = kzalloc(sizeof(struct mxs_nand_info), GFP_KERNEL);
if (!nand_info) {
diff --git a/drivers/mtd/peb.c b/drivers/mtd/peb.c
index 1b5605d1f4..f3c51a61b4 100644
--- a/drivers/mtd/peb.c
+++ b/drivers/mtd/peb.c
@@ -88,18 +88,14 @@ static int mtd_peb_debug_init(void)
}
device_initcall(mtd_peb_debug_init);
-BAREBOX_MAGICVAR_NAMED(global_mtd_peb_emulate_bitflip,
- global.mtd_peb.emulate_bitflip,
- "random bitflips, on average every #nth access returns -EUCLEAN");
-BAREBOX_MAGICVAR_NAMED(global_mtd_peb_emulate_write_failure,
- global.mtd_peb.emulate_write_failure,
- "random write failures, on average every #nth access returns write failure");
-BAREBOX_MAGICVAR_NAMED(global_mtd_peb_emulate_erase_failures,
- global.mtd_peb.emulate_erase_failures,
- "random erase failures, on average every #nth access returns erase failure");
-BAREBOX_MAGICVAR_NAMED(global_mtd_peb_chk_io,
- global.mtd_peb.chk_io,
- "If true, written data will be verified");
+BAREBOX_MAGICVAR(global.mtd_peb.emulate_bitflip,
+ "random bitflips, on average every #nth access returns -EUCLEAN");
+BAREBOX_MAGICVAR(global.mtd_peb.emulate_write_failure,
+ "random write failures, on average every #nth access returns write failure");
+BAREBOX_MAGICVAR(global.mtd_peb.emulate_erase_failures,
+ "random erase failures, on average every #nth access returns erase failure");
+BAREBOX_MAGICVAR(global.mtd_peb.chk_io,
+ "If true, written data will be verified");
#endif
diff --git a/drivers/net/ar231x.c b/drivers/net/ar231x.c
index 48d41b8cb2..6d1a90684c 100644
--- a/drivers/net/ar231x.c
+++ b/drivers/net/ar231x.c
@@ -424,8 +424,4 @@ static struct driver_d ar231x_eth_driver = {
.probe = ar231x_eth_probe,
};
-static int ar231x_eth_driver_init(void)
-{
- return platform_driver_register(&ar231x_eth_driver);
-}
-device_initcall(ar231x_eth_driver_init);
+device_platform_driver(ar231x_eth_driver);
diff --git a/drivers/net/designware_tegra186.c b/drivers/net/designware_tegra186.c
index 5348f65c41..f3b37be3ce 100644
--- a/drivers/net/designware_tegra186.c
+++ b/drivers/net/designware_tegra186.c
@@ -213,9 +213,8 @@ static int eqos_init_tegra186(struct device_d *dev, struct eqos *eqos)
priv->rst = reset_control_get(dev, "eqos");
if (IS_ERR(priv->rst)) {
- ret = PTR_ERR(priv->rst);
- dev_err(dev, "reset_get_by_name(rst) failed: %s\n", strerror(-ret));
- return ret;
+ dev_err(dev, "reset_get_by_name(rst) failed: %pe\n", priv->rst);
+ return PTR_ERR(priv->rst);
}
phy_reset = of_get_named_gpio(dev->device_node, "phy-reset-gpios", 0);
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index e3e039f679..188dbf2d8c 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -144,8 +144,6 @@ static void reclaim_rx_buffers(struct macb_device *macb,
{
unsigned int i;
- dev_dbg(macb->dev, "%s\n", __func__);
-
i = macb->rx_tail;
while (i > new_tail) {
macb->rx_ring[i].addr &= ~MACB_BIT(RX_USED);
@@ -170,8 +168,6 @@ static int gem_recv(struct eth_device *edev)
int length;
u32 status;
- dev_dbg(macb->dev, "%s\n", __func__);
-
for (;;) {
barrier();
if (!(macb->rx_ring[macb->rx_tail].addr & MACB_BIT(RX_USED)))
@@ -206,8 +202,6 @@ static int macb_recv(struct eth_device *edev)
int wrapped = 0;
u32 status;
- dev_dbg(macb->dev, "%s\n", __func__);
-
for (;;) {
barrier();
if (!(macb->rx_ring[rx_tail].addr & MACB_BIT(RX_USED)))
@@ -264,9 +258,38 @@ static int macb_recv(struct eth_device *edev)
return 0;
}
+static int macb_set_tx_clk(struct macb_device *macb, int speed)
+{
+ int rate;
+ int rate_rounded;
+
+ if (!macb->txclk) {
+ dev_dbg(macb->dev, "txclk not available\n");
+ return 0;
+ }
+
+ switch (speed) {
+ case SPEED_100:
+ rate = 25000000;
+ break;
+ case SPEED_1000:
+ rate = 125000000;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ rate_rounded = clk_round_rate(macb->txclk, rate);
+ if (rate_rounded <= 0)
+ return -EINVAL;
+
+ return clk_set_rate(macb->txclk, rate_rounded);
+}
+
static void macb_adjust_link(struct eth_device *edev)
{
struct macb_device *macb = edev->priv;
+ int err;
u32 reg;
reg = macb_readl(macb, NCFGR);
@@ -282,14 +305,16 @@ static void macb_adjust_link(struct eth_device *edev)
reg |= GEM_BIT(GBE);
macb_or_gem_writel(macb, NCFGR, reg);
+
+ err = macb_set_tx_clk(macb, edev->phydev->speed);
+ if (err)
+ dev_warn(macb->dev, "cannot set txclk\n");
}
static int macb_open(struct eth_device *edev)
{
struct macb_device *macb = edev->priv;
- dev_dbg(macb->dev, "%s\n", __func__);
-
/* Enable TX and RX */
macb_writel(macb, NCR, MACB_BIT(TE) | MACB_BIT(RE));
@@ -340,7 +365,7 @@ static int gmac_init_dummy_tx_queues(struct macb_device *macb)
MACB_BIT(TX_LAST) | MACB_BIT(TX_USED);
for (i = 1; i < num_queues; i++)
- gem_writel_queue_TBQP(macb, &macb->gem_q1_descs[0], i - 1);
+ gem_writel_queue_TBQP(macb, (ulong)macb->gem_q1_descs, i - 1);
return 0;
}
@@ -350,8 +375,6 @@ static void macb_init(struct macb_device *macb)
unsigned long paddr, val = 0;
int i;
- dev_dbg(macb->dev, "%s\n", __func__);
-
/*
* macb_halt should have been called at some point before now,
* so we'll assume the controller is idle.
@@ -441,8 +464,6 @@ static int macb_phy_read(struct mii_bus *bus, int addr, int reg)
int value;
uint64_t start;
- dev_dbg(macb->dev, "%s\n", __func__);
-
netctl = macb_readl(macb, NCR);
netctl |= MACB_BIT(MPE);
macb_writel(macb, NCR, netctl);
@@ -478,8 +499,6 @@ static int macb_phy_write(struct mii_bus *bus, int addr, int reg, u16 value)
unsigned long netctl;
unsigned long frame;
- dev_dbg(macb->dev, "%s\n", __func__);
-
netctl = macb_readl(macb, NCR);
netctl |= MACB_BIT(MPE);
macb_writel(macb, NCR, netctl);
@@ -510,8 +529,6 @@ static int macb_get_ethaddr(struct eth_device *edev, unsigned char *adr)
u8 addr[6];
int i;
- dev_dbg(macb->dev, "%s\n", __func__);
-
/* Check all 4 address register for vaild address */
for (i = 0; i < 4; i++) {
bottom = macb_or_gem_readl(macb, SA1B + i * 8);
@@ -537,8 +554,6 @@ static int macb_set_ethaddr(struct eth_device *edev, const unsigned char *adr)
{
struct macb_device *macb = edev->priv;
- dev_dbg(macb->dev, "%s\n", __func__);
-
/* set hardware address */
macb_or_gem_writel(macb, SA1B, adr[0] | adr[1] << 8 | adr[2] << 16 | adr[3] << 24);
macb_or_gem_writel(macb, SA1T, adr[4] | adr[5] << 8);
@@ -742,6 +757,8 @@ static int macb_probe(struct device_d *dev)
macb->txclk = clk_get(dev, "tx_clk");
if (!IS_ERR(macb->txclk))
clk_enable(macb->txclk);
+ else
+ macb->txclk = NULL;
macb->rxclk = clk_get(dev, "rx_clk");
if (!IS_ERR(macb->rxclk))
diff --git a/drivers/net/phy/ar8327.c b/drivers/net/phy/ar8327.c
index 5f3a2e2cf2..f13d574b30 100644
--- a/drivers/net/phy/ar8327.c
+++ b/drivers/net/phy/ar8327.c
@@ -268,9 +268,4 @@ static struct phy_driver ar8327n_driver[] = {
.aneg_done = &ar8327n_aneg_done,
}};
-static int atheros_phy_init(void)
-{
- return phy_drivers_register(ar8327n_driver,
- ARRAY_SIZE(ar8327n_driver));
-}
-fs_initcall(atheros_phy_init);
+device_phy_drivers(ar8327n_driver);
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index de053a36fb..016ed97020 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -243,9 +243,4 @@ static struct phy_driver at803x_driver[] = {
.read_status = &genphy_read_status,
} };
-static int atheros_phy_init(void)
-{
- return phy_drivers_register(at803x_driver,
- ARRAY_SIZE(at803x_driver));
-}
-fs_initcall(atheros_phy_init);
+device_phy_drivers(at803x_driver);
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
index febaffa52c..794e5f2c96 100644
--- a/drivers/net/phy/davicom.c
+++ b/drivers/net/phy/davicom.c
@@ -127,9 +127,4 @@ static struct phy_driver dm91xx_driver[] = {
.features = PHY_BASIC_FEATURES,
} };
-static int dm9161_init(void)
-{
- return phy_drivers_register(dm91xx_driver,
- ARRAY_SIZE(dm91xx_driver));
-}
-fs_initcall(dm9161_init);
+device_phy_drivers(dm91xx_driver);
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 929a407b09..8131e8c9d6 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -311,8 +311,4 @@ static struct phy_driver dp83867_driver[] = {
},
};
-static int dp83867_phy_init(void)
-{
- return phy_drivers_register(dp83867_driver, ARRAY_SIZE(dp83867_driver));
-}
-fs_initcall(dp83867_phy_init);
+device_phy_drivers(dp83867_driver);
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index b661ae7316..9b023c8c40 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -19,9 +19,4 @@ static struct phy_driver lxt97x_driver[] = {
.features = PHY_BASIC_FEATURES,
} };
-static int lxt97x_phy_init(void)
-{
- return phy_drivers_register(lxt97x_driver,
- ARRAY_SIZE(lxt97x_driver));
-}
-fs_initcall(lxt97x_phy_init);
+device_phy_drivers(lxt97x_driver);
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index af39ed68fd..3bf0fef34b 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -733,9 +733,4 @@ static struct phy_driver marvell_drivers[] = {
},
};
-static int __init marvell_phy_init(void)
-{
- return phy_drivers_register(marvell_drivers,
- ARRAY_SIZE(marvell_drivers));
-}
-fs_initcall(marvell_phy_init);
+device_phy_drivers(marvell_drivers);
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 4655430573..4e46370241 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -537,9 +537,4 @@ static struct phy_driver ksphy_driver[] = {
.read_status = ksz8873mll_read_status,
} };
-static int ksphy_init(void)
-{
- return phy_drivers_register(ksphy_driver,
- ARRAY_SIZE(ksphy_driver));
-}
-fs_initcall(ksphy_init);
+device_phy_drivers(ksphy_driver);
diff --git a/drivers/net/phy/mv88e6xxx/port.c b/drivers/net/phy/mv88e6xxx/port.c
index 52f95d622c..3f10719d9a 100644
--- a/drivers/net/phy/mv88e6xxx/port.c
+++ b/drivers/net/phy/mv88e6xxx/port.c
@@ -547,11 +547,7 @@ static struct phy_driver mv88e6xxx_port_driver = {
.read_status = mv88e6xxx_port_read_status,
};
-static int __init mv88e6xxx_port_driver_register(void)
-{
- return phy_driver_register(&mv88e6xxx_port_driver);
-}
-fs_initcall(mv88e6xxx_port_driver_register);
+device_phy_driver(mv88e6xxx_port_driver);
int mv88e6xxx_port_probe(struct mv88e6xxx_chip *chip)
{
@@ -660,4 +656,4 @@ int mv88e6xxx_port_probe(struct mv88e6xxx_chip *chip)
}
return 0;
-} \ No newline at end of file
+}
diff --git a/drivers/net/phy/national.c b/drivers/net/phy/national.c
index 83390b99ab..d74cd81933 100644
--- a/drivers/net/phy/national.c
+++ b/drivers/net/phy/national.c
@@ -84,8 +84,4 @@ static struct phy_driver dp83865_driver = {
.config_init = ns_config_init,
};
-static int ns_phy_init(void)
-{
- return phy_driver_register(&dp83865_driver);
-}
-fs_initcall(ns_phy_init);
+device_phy_driver(dp83865_driver);
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 57c2f8044f..622acbe40d 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -981,8 +981,4 @@ static struct phy_driver genphy_driver = {
SUPPORTED_BNC,
};
-static int generic_phy_register(void)
-{
- return phy_driver_register(&genphy_driver);
-}
-device_initcall(generic_phy_register);
+device_phy_driver(genphy_driver);
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 695a6c384d..9ba0495d41 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -196,9 +196,4 @@ static struct phy_driver realtek_drvs[] = {
},
};
-static int __init realtek_phy_init(void)
-{
- return phy_drivers_register(realtek_drvs,
- ARRAY_SIZE(realtek_drvs));
-}
-fs_initcall(realtek_phy_init);
+device_phy_drivers(realtek_drvs);
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index d6705e4fe2..1e1f3d5274 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -135,8 +135,4 @@ static struct phy_driver smsc_phy_driver[] = {
.config_init = lan87xx_config_init,
} };
-static int __init smsc_init(void)
-{
- return phy_drivers_register(smsc_phy_driver, ARRAY_SIZE(smsc_phy_driver));
-}
-fs_initcall(smsc_init);
+device_phy_drivers(smsc_phy_driver);
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 3ca27ff027..1140be9d16 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -252,11 +252,19 @@ static int asix_mdio_read(struct mii_bus *bus, int phy_id, int loc)
{
struct usbnet *dev = bus->priv;
__le16 res;
+ int ret;
- asix_set_sw_mii(dev);
- asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
- (__u16)loc, 2, &res);
- asix_set_hw_mii(dev);
+ ret = asix_set_sw_mii(dev);
+ if (ret < 0)
+ return ret;
+
+ ret = asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, &res);
+ if (ret < 0)
+ return ret;
+
+ ret = asix_set_hw_mii(dev);
+ if (ret < 0)
+ return ret;
dev_dbg(&dev->edev.dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
phy_id, loc, le16_to_cpu(res));
@@ -268,13 +276,22 @@ static int asix_mdio_write(struct mii_bus *bus, int phy_id, int loc, u16 val)
{
struct usbnet *dev = bus->priv;
__le16 res = cpu_to_le16(val);
+ int ret;
dev_dbg(&dev->edev.dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n",
phy_id, loc, val);
- asix_set_sw_mii(dev);
- asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
- asix_set_hw_mii(dev);
+ ret = asix_set_sw_mii(dev);
+ if (ret < 0)
+ return ret;
+
+ ret = asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
+ if (ret < 0)
+ return ret;
+
+ ret = asix_set_hw_mii(dev);
+ if (ret < 0)
+ return ret;
return 0;
}
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 0a2632f963..c39da558d1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -23,6 +23,7 @@
#include <memory.h>
#include <linux/sizes.h>
#include <of_graph.h>
+#include <string.h>
#include <linux/ctype.h>
#include <linux/amba/bus.h>
#include <linux/err.h>
@@ -893,6 +894,43 @@ int of_property_read_u64(const struct device_node *np, const char *propname,
EXPORT_SYMBOL_GPL(of_property_read_u64);
/**
+ * of_property_read_u64_array - Find and read an array of 64 bit integers
+ * from a property.
+ *
+ * @np: device node from which the property value is to be read.
+ * @propname: name of the property to be searched.
+ * @out_value: pointer to return value, modified only if return value is 0.
+ * @sz: number of array elements to read
+ *
+ * Search for a property in a device node and read 64-bit value(s) from
+ * it. Returns 0 on success, -EINVAL if the property does not exist,
+ * -ENODATA if property does not have a value, and -EOVERFLOW if the
+ * property data isn't large enough.
+ *
+ * The out_value is modified only if a valid u64 value can be decoded.
+ */
+int of_property_read_variable_u64_array(const struct device_node *np,
+ const char *propname, u64 *out_values,
+ size_t sz)
+{
+ size_t count;
+ const __be32 *val = of_find_property_value_of_size(np, propname,
+ (sz * sizeof(*out_values)));
+
+ if (IS_ERR(val))
+ return PTR_ERR(val);
+
+ count = sz;
+ while (count--) {
+ *out_values++ = of_read_number(val, 2);
+ val += 2;
+ }
+
+ return sz;
+}
+EXPORT_SYMBOL_GPL(of_property_read_variable_u64_array);
+
+/**
* of_property_read_string - Find and read a string from a property
* @np: device node from which the property value is to be read.
* @propname: name of the property to be searched.
@@ -1183,6 +1221,53 @@ int of_property_write_u64_array(struct device_node *np,
}
/**
+ * of_property_write_strings - Write strings to a property. If
+ * the property does not exist, it will be created and appended to the given
+ * device node.
+ *
+ * @np: device node to which the property value is to be written.
+ * @propname: name of the property to be written.
+ * @...: pointers to strings to write
+ *
+ * Search for a property in a device node and write a string to
+ * it. If the property does not exist, it will be created and appended to
+ * the device node. Returns 0 on success, -ENOMEM if the property or array
+ * of elements cannot be created, -EINVAL if no strings specified.
+ */
+int of_property_write_strings(struct device_node *np,
+ const char *propname, ...)
+{
+ const char *val;
+ char *buf = NULL, *next;
+ size_t len = 0;
+ va_list ap;
+ int ret = 0;
+
+ va_start(ap, propname);
+ for (val = va_arg(ap, char *); val; val = va_arg(ap, char *))
+ len += strlen(val) + 1;
+ va_end(ap);
+
+ if (!len)
+ return -EINVAL;
+
+ buf = malloc(len);
+ if (!buf)
+ return -ENOMEM;
+
+ next = buf;
+
+ va_start(ap, propname);
+ for (val = va_arg(ap, char *); val; val = va_arg(ap, char *))
+ next = stpcpy(next, val) + 1;
+ va_end(ap);
+
+ ret = of_set_property(np, propname, buf, len, 1);
+ free(buf);
+ return ret;
+}
+
+/**
* of_property_write_string - Write a string to a property. If
* the property does not exist, it will be created and appended to the given
* device node.
@@ -1567,6 +1652,34 @@ int of_set_root_node(struct device_node *node)
return 0;
}
+void barebox_register_of(struct device_node *root)
+{
+ if (root_node)
+ return;
+
+ of_fix_tree(root);
+ of_set_root_node(root);
+
+ if (IS_ENABLED(CONFIG_OFDEVICE))
+ of_probe();
+}
+
+void barebox_register_fdt(const void *dtb)
+{
+ struct device_node *root;
+
+ if (root_node)
+ return;
+
+ root = of_unflatten_dtb(dtb);
+ if (IS_ERR(root)) {
+ pr_err("Cannot unflatten dtb: %pe\n", root);
+ return;
+ }
+
+ barebox_register_of(root);
+}
+
/**
* of_device_is_available - check if a device is available for use
*
@@ -2090,6 +2203,9 @@ int of_add_memory(struct device_node *node, bool dump)
if (!resource_size(&res))
continue;
+ if (!of_device_is_available(node))
+ continue;
+
of_add_memory_bank(node, dump, mem_bank_num,
res.start, resource_size(&res));
mem_bank_num++;
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index ca84cede23..21c7cce1a5 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -282,7 +282,7 @@ amba_err_free:
return NULL;
}
#else /* CONFIG_ARM_AMBA */
-static inline struct amba_device *of_amba_device_create(struct device_node *np)
+static inline struct device_d *of_amba_device_create(struct device_node *np)
{
return NULL;
}
diff --git a/drivers/pci/pci-layerscape.c b/drivers/pci/pci-layerscape.c
index 53be43b28f..d8f03fa599 100644
--- a/drivers/pci/pci-layerscape.c
+++ b/drivers/pci/pci-layerscape.c
@@ -363,9 +363,8 @@ static phandle ls_pcie_get_iommu_handle(struct device_node *np, phandle *handle)
*/
static int ls_pcie_share_stream_id;
-BAREBOX_MAGICVAR_NAMED(global_ls_pcie_share_stream_id,
- global.layerscape_pcie.share_stream_ids,
- "If true, use a stream_id per host controller and not per device");
+BAREBOX_MAGICVAR(global.layerscape_pcie.share_stream_ids,
+ "If true, use a stream_id per host controller and not per device");
static int ls_pcie_of_fixup(struct device_node *root, void *ctx)
{
diff --git a/drivers/phy/usb-nop-xceiv.c b/drivers/phy/usb-nop-xceiv.c
index a9031fa7f8..7ea7d28a21 100644
--- a/drivers/phy/usb-nop-xceiv.c
+++ b/drivers/phy/usb-nop-xceiv.c
@@ -146,8 +146,4 @@ static struct driver_d nop_usbphy_driver = {
.of_compatible = DRV_OF_COMPAT(nop_usbphy_dt_ids),
};
-static int nop_usbphy_driver_init(void)
-{
- return platform_driver_register(&nop_usbphy_driver);
-}
-fs_initcall(nop_usbphy_driver_init);
+fs_platform_driver(nop_usbphy_driver);
diff --git a/drivers/pinctrl/imx-iomux-v1.c b/drivers/pinctrl/imx-iomux-v1.c
index 81925f2fd4..d48707db7d 100644
--- a/drivers/pinctrl/imx-iomux-v1.c
+++ b/drivers/pinctrl/imx-iomux-v1.c
@@ -302,10 +302,6 @@ static struct driver_d imx_iomux_v1_driver = {
.of_compatible = DRV_OF_COMPAT(imx_iomux_v1_dt_ids),
};
-static int imx_iomux_v1_init(void)
-{
- return platform_driver_register(&imx_iomux_v1_driver);
-}
-core_initcall(imx_iomux_v1_init);
+core_platform_driver(imx_iomux_v1_driver);
-#endif \ No newline at end of file
+#endif
diff --git a/drivers/pinctrl/imx-iomux-v2.c b/drivers/pinctrl/imx-iomux-v2.c
index 60b635a8a8..b6ffb7508a 100644
--- a/drivers/pinctrl/imx-iomux-v2.c
+++ b/drivers/pinctrl/imx-iomux-v2.c
@@ -150,8 +150,4 @@ static struct driver_d imx_iomux_driver = {
.id_table = imx_iomux_ids,
};
-static int imx_iomux_init(void)
-{
- return platform_driver_register(&imx_iomux_driver);
-}
-core_initcall(imx_iomux_init);
+core_platform_driver(imx_iomux_driver);
diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c
index fd05274512..cec2414a03 100644
--- a/drivers/pinctrl/imx-iomux-v3.c
+++ b/drivers/pinctrl/imx-iomux-v3.c
@@ -168,10 +168,10 @@ static struct pinctrl_ops imx_iomux_v3_ops = {
static int imx_pinctrl_dt(struct device_d *dev, void __iomem *base)
{
struct imx_iomux_v3 *iomux;
- struct imx_iomux_v3_data *drvdata = NULL;
+ const struct imx_iomux_v3_data *drvdata;
int ret;
- dev_get_drvdata(dev, (const void **)&drvdata);
+ drvdata = device_get_match_data(dev);
iomux = xzalloc(sizeof(*iomux));
iomux->base = base;
@@ -265,8 +265,4 @@ static struct driver_d imx_iomux_v3_driver = {
.of_compatible = DRV_OF_COMPAT(imx_iomux_v3_dt_ids),
};
-static int imx_iomux_v3_init(void)
-{
- return platform_driver_register(&imx_iomux_v3_driver);
-}
-core_initcall(imx_iomux_v3_init);
+core_platform_driver(imx_iomux_v3_driver);
diff --git a/drivers/pinctrl/mvebu/armada-370.c b/drivers/pinctrl/mvebu/armada-370.c
index 4fde16ab5d..24ad7f5860 100644
--- a/drivers/pinctrl/mvebu/armada-370.c
+++ b/drivers/pinctrl/mvebu/armada-370.c
@@ -411,8 +411,4 @@ static struct driver_d armada_370_pinctrl_driver = {
.of_compatible = armada_370_pinctrl_of_match,
};
-static int armada_370_pinctrl_init(void)
-{
- return platform_driver_register(&armada_370_pinctrl_driver);
-}
-core_initcall(armada_370_pinctrl_init);
+core_platform_driver(armada_370_pinctrl_driver);
diff --git a/drivers/pinctrl/mvebu/armada-xp.c b/drivers/pinctrl/mvebu/armada-xp.c
index 089942d696..25faabdf05 100644
--- a/drivers/pinctrl/mvebu/armada-xp.c
+++ b/drivers/pinctrl/mvebu/armada-xp.c
@@ -400,9 +400,4 @@ static struct driver_d armada_xp_pinctrl_driver = {
.probe = armada_xp_pinctrl_probe,
.of_compatible = armada_xp_pinctrl_of_match,
};
-
-static int armada_xp_pinctrl_init(void)
-{
- return platform_driver_register(&armada_xp_pinctrl_driver);
-}
-core_initcall(armada_xp_pinctrl_init);
+core_platform_driver(armada_xp_pinctrl_driver);
diff --git a/drivers/pinctrl/mvebu/dove.c b/drivers/pinctrl/mvebu/dove.c
index 2d9d8094f8..e02501d744 100644
--- a/drivers/pinctrl/mvebu/dove.c
+++ b/drivers/pinctrl/mvebu/dove.c
@@ -738,8 +738,4 @@ static struct driver_d dove_pinctrl_driver = {
.of_compatible = dove_pinctrl_of_match,
};
-static int dove_pinctrl_init(void)
-{
- return platform_driver_register(&dove_pinctrl_driver);
-}
-core_initcall(dove_pinctrl_init);
+core_platform_driver(dove_pinctrl_driver);
diff --git a/drivers/pinctrl/mvebu/kirkwood.c b/drivers/pinctrl/mvebu/kirkwood.c
index a347239028..91bef76270 100644
--- a/drivers/pinctrl/mvebu/kirkwood.c
+++ b/drivers/pinctrl/mvebu/kirkwood.c
@@ -452,8 +452,4 @@ static struct driver_d kirkwood_pinctrl_driver = {
.of_compatible = kirkwood_pinctrl_of_match,
};
-static int kirkwood_pinctrl_init(void)
-{
- return platform_driver_register(&kirkwood_pinctrl_driver);
-}
-core_initcall(kirkwood_pinctrl_init);
+core_platform_driver(kirkwood_pinctrl_driver);
diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index b527114f1b..40bc573e31 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -229,7 +229,7 @@ static struct gpio_ops at91_gpio4_ops = {
static int pinctrl_at91_pio4_gpiochip_add(struct device_d *dev,
struct pinctrl_at91_pio4 *pinctrl)
{
- struct at91_pinctrl_data *drvdata;
+ const struct at91_pinctrl_data *drvdata;
struct clk *clk;
int ret;
@@ -247,7 +247,7 @@ static int pinctrl_at91_pio4_gpiochip_add(struct device_d *dev,
return ret;
}
- dev_get_drvdata(dev, (const void **)&drvdata);
+ drvdata = device_get_match_data(dev);
pinctrl->gpiochip.ops = &at91_gpio4_ops;
pinctrl->gpiochip.base = 0;
@@ -313,8 +313,4 @@ static struct driver_d pinctrl_at91_pio4_driver = {
.of_compatible = DRV_OF_COMPAT(pinctrl_at91_pio4_dt_ids),
};
-static int pinctrl_at91_pio4_init(void)
-{
- return platform_driver_register(&pinctrl_at91_pio4_driver);
-}
-core_initcall(pinctrl_at91_pio4_init);
+core_platform_driver(pinctrl_at91_pio4_driver);
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 13add1ffee..ad64f7da6d 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -526,11 +526,7 @@ static struct driver_d at91_pinctrl_driver = {
.of_compatible = DRV_OF_COMPAT(at91_pinctrl_dt_ids),
};
-static int at91_pinctrl_init(void)
-{
- return platform_driver_register(&at91_pinctrl_driver);
-}
-core_initcall(at91_pinctrl_init);
+core_platform_driver(at91_pinctrl_driver);
static int at91_gpio_get(struct gpio_chip *chip, unsigned offset)
{
@@ -706,8 +702,4 @@ static struct driver_d at91_gpio_driver = {
.of_compatible = DRV_OF_COMPAT(at91_gpio_dt_ids),
};
-static int at91_gpio_init(void)
-{
- return platform_driver_register(&at91_gpio_driver);
-}
-core_initcall(at91_gpio_init);
+core_platform_driver(at91_gpio_driver);
diff --git a/drivers/pinctrl/pinctrl-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c
index b8e9b60372..d62c735181 100644
--- a/drivers/pinctrl/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/pinctrl-bcm2835.c
@@ -205,8 +205,4 @@ static struct driver_d bcm2835_gpio_driver = {
.of_compatible = DRV_OF_COMPAT(bcm2835_gpio_dt_ids),
};
-static int bcm2835_gpio_add(void)
-{
- return platform_driver_register(&bcm2835_gpio_driver);
-}
-coredevice_initcall(bcm2835_gpio_add);
+coredevice_platform_driver(bcm2835_gpio_driver);
diff --git a/drivers/pinctrl/pinctrl-mxs.c b/drivers/pinctrl/pinctrl-mxs.c
index 96f30bf95b..7c5d54c9ac 100644
--- a/drivers/pinctrl/pinctrl-mxs.c
+++ b/drivers/pinctrl/pinctrl-mxs.c
@@ -161,8 +161,4 @@ static struct driver_d mxs_pinctrl_driver = {
.of_compatible = DRV_OF_COMPAT(mxs_pinctrl_dt_ids),
};
-static int mxs_pinctrl_init(void)
-{
- return platform_driver_register(&mxs_pinctrl_driver);
-}
-core_initcall(mxs_pinctrl_init);
+core_platform_driver(mxs_pinctrl_driver);
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index c31b7e0365..c774660232 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -219,8 +219,4 @@ static struct driver_d pcs_driver = {
.of_compatible = DRV_OF_COMPAT(pcs_dt_ids),
};
-static int pcs_init(void)
-{
- return platform_driver_register(&pcs_driver);
-}
-core_initcall(pcs_init);
+core_platform_driver(pcs_driver);
diff --git a/drivers/pinctrl/pinctrl-stm32.c b/drivers/pinctrl/pinctrl-stm32.c
index cdaed510c5..09b62309f6 100644
--- a/drivers/pinctrl/pinctrl-stm32.c
+++ b/drivers/pinctrl/pinctrl-stm32.c
@@ -440,8 +440,4 @@ static struct driver_d stm32_pinctrl_driver = {
.of_compatible = DRV_OF_COMPAT(stm32_pinctrl_dt_ids),
};
-static int stm32_pinctrl_init(void)
-{
- return platform_driver_register(&stm32_pinctrl_driver);
-}
-core_initcall(stm32_pinctrl_init);
+core_platform_driver(stm32_pinctrl_driver);
diff --git a/drivers/pinctrl/pinctrl-tegra-xusb.c b/drivers/pinctrl/pinctrl-tegra-xusb.c
index c4d3bbe8d4..37d77e5ef6 100644
--- a/drivers/pinctrl/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/pinctrl-tegra-xusb.c
@@ -388,7 +388,7 @@ static int pinctrl_tegra_xusb_probe(struct device_d *dev)
dev->priv = padctl;
padctl->dev = dev;
- dev_get_drvdata(dev, (const void **)&padctl->soc);
+ padctl->soc = device_get_match_data(dev);
iores = dev_request_mem_resource(dev, 0);
if (IS_ERR(iores)) {
@@ -514,8 +514,4 @@ static struct driver_d pinctrl_tegra_xusb_driver = {
.of_compatible = DRV_OF_COMPAT(pinctrl_tegra_xusb_dt_ids),
};
-static int pinctrl_tegra_xusb_init(void)
-{
- return platform_driver_register(&pinctrl_tegra_xusb_driver);
-}
-core_initcall(pinctrl_tegra_xusb_init);
+core_platform_driver(pinctrl_tegra_xusb_driver);
diff --git a/drivers/pinctrl/pinctrl-tegra20.c b/drivers/pinctrl/pinctrl-tegra20.c
index 337992c21f..256aea1860 100644
--- a/drivers/pinctrl/pinctrl-tegra20.c
+++ b/drivers/pinctrl/pinctrl-tegra20.c
@@ -346,8 +346,4 @@ static struct driver_d pinctrl_tegra20_driver = {
.of_compatible = DRV_OF_COMPAT(pinctrl_tegra20_dt_ids),
};
-static int pinctrl_tegra20_init(void)
-{
- return platform_driver_register(&pinctrl_tegra20_driver);
-}
-core_initcall(pinctrl_tegra20_init);
+core_platform_driver(pinctrl_tegra20_driver);
diff --git a/drivers/pinctrl/pinctrl-tegra30.c b/drivers/pinctrl/pinctrl-tegra30.c
index 278ea8c4a0..e9f35e0c9d 100644
--- a/drivers/pinctrl/pinctrl-tegra30.c
+++ b/drivers/pinctrl/pinctrl-tegra30.c
@@ -32,7 +32,7 @@ struct pinctrl_tegra30 {
u32 __iomem *mux;
} regs;
struct pinctrl_device pinctrl;
- struct pinctrl_tegra30_drvdata *drvdata;
+ const struct pinctrl_tegra30_drvdata *drvdata;
};
struct tegra_pingroup {
@@ -893,7 +893,7 @@ static int pinctrl_tegra30_probe(struct device_d *dev)
regs[i] = IOMEM(iores->start);
}
- dev_get_drvdata(dev, (const void **)&ctrl->drvdata);
+ ctrl->drvdata = device_get_match_data(dev);
ctrl->pinctrl.dev = dev;
ctrl->pinctrl.ops = &pinctrl_tegra30_ops;
@@ -931,8 +931,4 @@ static struct driver_d pinctrl_tegra30_driver = {
.of_compatible = DRV_OF_COMPAT(pinctrl_tegra30_dt_ids),
};
-static int pinctrl_tegra30_init(void)
-{
- return platform_driver_register(&pinctrl_tegra30_driver);
-}
-core_initcall(pinctrl_tegra30_init);
+core_platform_driver(pinctrl_tegra30_driver);
diff --git a/drivers/pinctrl/pinctrl-vf610.c b/drivers/pinctrl/pinctrl-vf610.c
index 9a8ce0caa2..02dea60ac2 100644
--- a/drivers/pinctrl/pinctrl-vf610.c
+++ b/drivers/pinctrl/pinctrl-vf610.c
@@ -158,8 +158,4 @@ static struct driver_d pinctrl_vf610_driver = {
.of_compatible = DRV_OF_COMPAT(pinctrl_vf610_dt_ids),
};
-static int pinctrl_vf610_init(void)
-{
- return platform_driver_register(&pinctrl_vf610_driver);
-}
-core_initcall(pinctrl_vf610_init);
+core_platform_driver(pinctrl_vf610_driver);
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
new file mode 100644
index 0000000000..b56414c497
--- /dev/null
+++ b/drivers/power/Kconfig
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+source "drivers/power/reset/Kconfig"
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
new file mode 100644
index 0000000000..3009da59bf
--- /dev/null
+++ b/drivers/power/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-y += reset/
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
new file mode 100644
index 0000000000..f65e1f67fd
--- /dev/null
+++ b/drivers/power/reset/Kconfig
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+config REBOOT_MODE
+ bool
+
+config SYSCON_REBOOT_MODE
+ bool "Generic SYSCON regmap reboot mode driver"
+ depends on OFDEVICE
+ depends on MFD_SYSCON
+ select REBOOT_MODE
+ help
+ Say y here will enable reboot mode driver. This will
+ get reboot mode arguments and store it in SYSCON mapped
+ register, then the bootloader can read it to take different
+ action according to the mode.
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
new file mode 100644
index 0000000000..56feec78cf
--- /dev/null
+++ b/drivers/power/reset/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_REBOOT_MODE) += reboot-mode.o
+obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o
diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
new file mode 100644
index 0000000000..df3be03edf
--- /dev/null
+++ b/drivers/power/reset/reboot-mode.c
@@ -0,0 +1,231 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
+ * Copyright (c) 2019, Ahmad Fatoum, Pengutronix
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <init.h>
+#include <of.h>
+#include <linux/reboot-mode.h>
+#include <globalvar.h>
+#include <magicvar.h>
+
+#define PREFIX "mode-"
+
+static int __priority;
+static struct reboot_mode_driver *__boot_mode;
+
+static int reboot_mode_param_set(struct param_d *p, void *priv)
+{
+ struct reboot_mode_driver *reboot = priv;
+ size_t i = reboot->reboot_mode_next * reboot->nelems;
+
+ return reboot->write(reboot, &reboot->magics[i]);
+}
+
+static int reboot_mode_add_param(struct device_d *dev,
+ const char *prefix,
+ struct reboot_mode_driver *reboot)
+{
+ char name[sizeof "system.reboot_mode.when"];
+ struct param_d *param;
+
+ scnprintf(name, sizeof(name), "%sprev", prefix);
+
+ param = dev_add_param_enum_ro(dev, name,
+ &reboot->reboot_mode_prev, reboot->modes,
+ reboot->nmodes);
+ if (IS_ERR(param))
+ return PTR_ERR(param);
+
+ scnprintf(name, sizeof(name), "%snext", prefix);
+
+ param = dev_add_param_enum(dev, name,
+ reboot_mode_param_set, NULL,
+ &reboot->reboot_mode_next, reboot->modes,
+ reboot->nmodes, reboot);
+
+ return PTR_ERR_OR_ZERO(param);
+}
+
+static struct device_node *of_get_node_by_reproducible_name(struct device_node *dstroot,
+ struct device_node *srcnp)
+{
+ struct device_node *dstnp;
+ char *name;
+
+ name = of_get_reproducible_name(srcnp);
+ dstnp = of_find_node_by_reproducible_name(dstroot, name);
+ free(name);
+
+ return dstnp;
+}
+
+static int of_reboot_mode_fixup(struct device_node *root, void *ctx)
+{
+ struct reboot_mode_driver *reboot = ctx;
+ struct device_node *dstnp, *srcnp, *dstparent;
+
+ srcnp = reboot->dev->device_node;
+ dstnp = of_get_node_by_reproducible_name(root, srcnp);
+
+ /* nothing to do when called on barebox-internal tree */
+ if (srcnp == dstnp)
+ return 0;
+
+ if (dstnp) {
+ dstparent = dstnp->parent;
+ of_delete_node(dstnp);
+ } else {
+ dstparent = of_get_node_by_reproducible_name(root, srcnp->parent);
+ }
+
+ if (!dstparent)
+ return -EINVAL;
+
+ of_copy_node(dstparent, srcnp);
+
+ return 0;
+}
+
+static int reboot_mode_add_globalvar(void)
+{
+ struct reboot_mode_driver *reboot = __boot_mode;
+
+ if (!reboot)
+ return 0;
+
+ if (!reboot->no_fixup)
+ of_register_fixup(of_reboot_mode_fixup, reboot);
+
+ return reboot_mode_add_param(&global_device, "system.reboot_mode.", reboot);
+}
+late_initcall(reboot_mode_add_globalvar);
+
+
+static void reboot_mode_print(struct reboot_mode_driver *reboot,
+ const char *prefix, const u32 *arr)
+{
+ size_t i;
+ dev_dbg(reboot->dev, "%s: ", prefix);
+ for (i = 0; i < reboot->nelems; i++)
+ __pr_printk(7, "%08x ", arr[i]);
+ __pr_printk(7, "\n");
+}
+
+/**
+ * reboot_mode_register - register a reboot mode driver
+ * @reboot: reboot mode driver
+ * @reboot_mode: reboot mode read from hardware
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+int reboot_mode_register(struct reboot_mode_driver *reboot,
+ const u32 *reboot_mode, size_t nelems)
+{
+ struct property *prop;
+ struct device_node *np = reboot->dev->device_node;
+ size_t len = strlen(PREFIX);
+ const char *alias;
+ size_t nmodes = 0;
+ int i = 0;
+ int ret;
+
+ for_each_property_of_node(np, prop) {
+ u32 magic;
+
+ if (strncmp(prop->name, PREFIX, len))
+ continue;
+ if (of_property_read_u32(np, prop->name, &magic))
+ continue;
+
+ nmodes++;
+ }
+
+ reboot->nmodes = nmodes;
+ reboot->nelems = nelems;
+ reboot->magics = xzalloc(nmodes * nelems * sizeof(u32));
+ reboot->modes = xzalloc(nmodes * sizeof(const char *));
+
+ reboot_mode_print(reboot, "registering magic", reboot_mode);
+
+ for_each_property_of_node(np, prop) {
+ const char **mode;
+ u32 *magic;
+
+ magic = &reboot->magics[i * nelems];
+ mode = &reboot->modes[i];
+
+ if (strncmp(prop->name, PREFIX, len))
+ continue;
+
+ if (of_property_read_u32_array(np, prop->name, magic, nelems)) {
+ dev_err(reboot->dev, "reboot mode %s without magic number\n",
+ *mode);
+ continue;
+ }
+
+ *mode = prop->name + len;
+ if (*mode[0] == '\0') {
+ ret = -EINVAL;
+ dev_err(reboot->dev, "invalid mode name(%s): too short!\n",
+ prop->name);
+ goto error;
+ }
+
+ reboot_mode_print(reboot, *mode, magic);
+
+ i++;
+ }
+
+ for (i = 0; i < reboot->nmodes; i++) {
+ if (memcmp(&reboot->magics[i * nelems], reboot_mode, nelems * sizeof(u32)))
+ continue;
+
+ reboot->reboot_mode_prev = i;
+ break;
+ }
+
+ reboot_mode_add_param(reboot->dev, "", reboot);
+
+ /* clear mode for next reboot */
+ reboot->write(reboot, &(u32) { 0 });
+
+ if (!reboot->priority)
+ reboot->priority = REBOOT_MODE_DEFAULT_PRIORITY;
+
+ if (reboot->priority >= __priority) {
+ __priority = reboot->priority;
+ __boot_mode = reboot;
+ }
+
+
+ alias = of_alias_get(np);
+ if (alias)
+ dev_set_name(reboot->dev, alias);
+
+ return 0;
+
+error:
+ free(reboot->magics);
+ free(reboot->modes);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(reboot_mode_register);
+
+const char *reboot_mode_get(void)
+{
+ if (!__boot_mode)
+ return NULL;
+
+ return __boot_mode->modes[__boot_mode->reboot_mode_prev];
+}
+EXPORT_SYMBOL_GPL(reboot_mode_get);
+
+BAREBOX_MAGICVAR(global.system.reboot_mode.prev,
+ "reboot-mode: Mode set previously, before barebox start");
+BAREBOX_MAGICVAR(global.system.reboot_mode.next,
+ "reboot-mode: Mode to set next, to be evaluated after reset");
diff --git a/drivers/power/reset/syscon-reboot-mode.c b/drivers/power/reset/syscon-reboot-mode.c
new file mode 100644
index 0000000000..0cbc9d0803
--- /dev/null
+++ b/drivers/power/reset/syscon-reboot-mode.c
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
+ */
+
+#include <common.h>
+#include <init.h>
+#include <driver.h>
+#include <of.h>
+#include <regmap.h>
+#include <mfd/syscon.h>
+#include <linux/reboot-mode.h>
+#include <linux/overflow.h>
+
+struct mode_reg {
+ u32 offset;
+ u32 mask;
+};
+
+struct syscon_reboot_mode {
+ struct regmap *map;
+ struct reboot_mode_driver reboot;
+ struct mode_reg reg[];
+};
+
+static int syscon_reboot_mode_write(struct reboot_mode_driver *reboot,
+ const u32 *magic)
+{
+ struct syscon_reboot_mode *syscon_rbm;
+ size_t i;
+ int ret = 0;
+
+ syscon_rbm = container_of(reboot, struct syscon_reboot_mode, reboot);
+
+ for (i = 0; i < reboot->nelems; i++) {
+ struct mode_reg *reg = &syscon_rbm->reg[i];
+
+ ret = regmap_update_bits(syscon_rbm->map, reg->offset,
+ reg->mask, *magic++);
+ if (ret < 0) {
+ dev_err(reboot->dev, "update reboot mode bits failed\n");
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static int syscon_reboot_mode_probe(struct device_d *dev)
+{
+ int ret, i, nelems;
+ struct syscon_reboot_mode *syscon_rbm;
+ struct reboot_mode_driver *reboot_template;
+ struct device_node *np = dev->device_node;
+ u32 *magic;
+
+ nelems = of_property_count_elems_of_size(np, "offset", sizeof(__be32));
+ if (nelems <= 0)
+ return -EINVAL;
+
+ syscon_rbm = xzalloc(struct_size(syscon_rbm, reg, nelems));
+
+ ret = dev_get_drvdata(dev, (const void **)&reboot_template);
+ if (ret)
+ return ret;
+
+ syscon_rbm->reboot = *reboot_template;
+ syscon_rbm->reboot.dev = dev;
+
+ syscon_rbm->map = syscon_node_to_regmap(dev->parent->device_node);
+ if (IS_ERR(syscon_rbm->map))
+ return PTR_ERR(syscon_rbm->map);
+
+ magic = xzalloc(nelems * sizeof(*magic));
+
+ for (i = 0; i < nelems; i++) {
+ struct mode_reg *reg = &syscon_rbm->reg[i];
+
+ ret = of_property_read_u32_index(np, "offset", i, &reg->offset);
+ if (ret)
+ goto free_magic;
+
+ reg->mask = 0xffffffff;
+ of_property_read_u32_index(np, "mask", i, &reg->mask);
+
+ ret = regmap_read(syscon_rbm->map, reg->offset, &magic[i]);
+ if (ret) {
+ dev_err(dev, "error reading reboot mode: %s\n",
+ strerror(-ret));
+ goto free_magic;
+ }
+
+ magic[i] &= reg->mask;
+ }
+
+ ret = reboot_mode_register(&syscon_rbm->reboot, magic, nelems);
+ if (ret)
+ dev_err(dev, "can't register reboot mode\n");
+
+free_magic:
+ free(magic);
+ return ret;
+
+}
+
+static struct reboot_mode_driver reboot_fixup = {
+ .write = syscon_reboot_mode_write,
+ .priority = 100,
+ .no_fixup = false,
+};
+
+static struct reboot_mode_driver reboot_nofixup = {
+ .write = syscon_reboot_mode_write,
+ .priority = 50,
+ .no_fixup = true,
+};
+
+static const struct of_device_id syscon_reboot_mode_of_match[] = {
+ { .compatible = "syscon-reboot-mode", .data = &reboot_fixup },
+ { .compatible = "barebox,syscon-reboot-mode", .data = &reboot_nofixup },
+ { /* sentinel */ }
+};
+
+static struct driver_d syscon_reboot_mode_driver = {
+ .probe = syscon_reboot_mode_probe,
+ .name = "syscon-reboot-mode",
+ .of_compatible = syscon_reboot_mode_of_match,
+};
+coredevice_platform_driver(syscon_reboot_mode_driver);
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 7ec9446a0a..917f7e8fdd 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -67,6 +67,7 @@ static int anatop_regulator_probe(struct device_d *dev)
rdev->desc = rdesc;
rdev->regmap = syscon_node_to_regmap(anatop_np);
+ rdev->dev = dev;
if (IS_ERR(rdev->regmap))
return PTR_ERR(rdev->regmap);
diff --git a/drivers/regulator/bcm2835.c b/drivers/regulator/bcm2835.c
index ea7cf7fe1e..6423b8a834 100644
--- a/drivers/regulator/bcm2835.c
+++ b/drivers/regulator/bcm2835.c
@@ -14,7 +14,7 @@
#define REG_DEV(_id, _name) \
{ \
- .id = _id, \
+ .id = _id, \
.devname = _name,\
}
@@ -22,7 +22,6 @@ static struct regulator_bcm2835 {
int id;
char *devname;
- struct device_d *dev;
struct regulator_dev rdev;
struct regulator_desc rdesc;
} regs[] = {
@@ -43,8 +42,9 @@ struct msg_set_power_state {
u32 end_tag;
};
-static int regulator_bcm2835_set(struct regulator_bcm2835 *rb, int state)
+static int regulator_bcm2835_set(struct regulator_dev *rdev, int state)
{
+ struct regulator_bcm2835 *rb = container_of(rdev, struct regulator_bcm2835, rdev);
BCM2835_MBOX_STACK_ALIGN(struct msg_set_power_state, msg_pwr);
int ret;
@@ -59,8 +59,8 @@ static int regulator_bcm2835_set(struct regulator_bcm2835 *rb, int state)
ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN,
&msg_pwr->hdr);
if (ret) {
- dev_err(rb->dev ,"bcm2835: Could not set module %u power state\n",
- rb->id);
+ dev_err(rdev->dev, "bcm2835: Could not set module %u power state\n",
+ rb->id);
return ret;
}
@@ -69,16 +69,12 @@ static int regulator_bcm2835_set(struct regulator_bcm2835 *rb, int state)
static int regulator_bcm2835_enable(struct regulator_dev *rdev)
{
- struct regulator_bcm2835 *rb = container_of(rdev, struct regulator_bcm2835, rdev);
-
- return regulator_bcm2835_set(rb, BCM2835_MBOX_SET_POWER_STATE_REQ_ON);
+ return regulator_bcm2835_set(rdev, BCM2835_MBOX_SET_POWER_STATE_REQ_ON);
}
static int regulator_bcm2835_disable(struct regulator_dev *rdev)
{
- struct regulator_bcm2835 *rb = container_of(rdev, struct regulator_bcm2835, rdev);
-
- return regulator_bcm2835_set(rb, BCM2835_MBOX_SET_POWER_STATE_REQ_OFF);
+ return regulator_bcm2835_set(rdev, BCM2835_MBOX_SET_POWER_STATE_REQ_OFF);
}
struct msg_get_power_state {
@@ -101,8 +97,8 @@ static int regulator_bcm2835_is_enabled(struct regulator_dev *rdev)
ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN,
&msg_pwr->hdr);
if (ret) {
- dev_err(rb->dev ,"bcm2835: Could not get module %u power state\n",
- rb->id);
+ dev_err(rdev->dev, "bcm2835: Could not get module %u power state\n",
+ rb->id);
return ret;
}
@@ -125,7 +121,7 @@ static int regulator_bcm2835_probe(struct device_d *dev)
rb->rdesc.ops = &bcm2835_ops;
rb->rdev.desc = &rb->rdesc;
- rb->dev = dev;
+ rb->rdev.dev = dev;
ret = dev_regulator_register(&rb->rdev, rb->devname, NULL);
if (ret)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 74e00d7791..6ea21a4609 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -163,11 +163,17 @@ int of_regulator_register(struct regulator_dev *rd, struct device_node *node)
struct regulator_internal *ri;
const char *name;
+ if (!rd || !node)
+ return -EINVAL;
+
rd->boot_on = of_property_read_bool(node, "regulator-boot-on");
name = of_get_property(node, "regulator-name", NULL);
ri = __regulator_register(rd, name);
+ if (IS_ERR(ri))
+ return PTR_ERR(ri);
+
ri->node = node;
of_property_read_u32(node, "regulator-enable-ramp-delay",
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 0b1c752493..160a55163f 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -82,6 +82,7 @@ static int regulator_fixed_probe(struct device_d *dev)
fix->rdesc.ops = &fixed_ops;
fix->rdev.desc = &fix->rdesc;
+ fix->rdev.dev = dev;
if (of_find_property(dev->device_node, "regulator-always-on", NULL) ||
of_find_property(dev->device_node, "regulator-boot-on", NULL)) {
diff --git a/drivers/regulator/pfuze.c b/drivers/regulator/pfuze.c
index 91aaec0e7e..1983ec91f6 100644
--- a/drivers/regulator/pfuze.c
+++ b/drivers/regulator/pfuze.c
@@ -206,15 +206,4 @@ static struct driver_d pfuze_i2c_driver = {
.of_compatible = DRV_OF_COMPAT(pfuze_dt_ids),
};
-static int __init pfuze_init(void)
-{
- int ret;
-
- ret = i2c_driver_register(&pfuze_i2c_driver);
- if (ret)
- return ret;
-
- return 0;
-
-}
-late_initcall(pfuze_init);
+device_i2c_driver(pfuze_i2c_driver);
diff --git a/drivers/regulator/stm32-pwr.c b/drivers/regulator/stm32-pwr.c
index 296f95bc4c..54ba716a8f 100644
--- a/drivers/regulator/stm32-pwr.c
+++ b/drivers/regulator/stm32-pwr.c
@@ -44,7 +44,6 @@ static u32 ready_mask_table[STM32PWR_REG_NUM_REGS] = {
struct stm32_pwr_reg {
void __iomem *base;
- struct device_d *dev;
u32 ready_mask;
struct regulator_dev rdev;
struct regulator *supply;
@@ -97,7 +96,7 @@ static int stm32_pwr_reg_enable(struct regulator_dev *rdev)
ret = readx_poll_timeout(stm32_pwr_reg_is_ready, rdev, val, val,
20 * USEC_PER_MSEC);
if (ret)
- dev_err(priv->dev, "%s: regulator enable timed out!\n",
+ dev_err(rdev->dev, "%s: regulator enable timed out!\n",
desc->name);
return ret;
@@ -118,7 +117,7 @@ static int stm32_pwr_reg_disable(struct regulator_dev *rdev)
ret = readx_poll_timeout(stm32_pwr_reg_is_ready, rdev, val, !val,
20 * USEC_PER_MSEC);
if (ret)
- dev_err(priv->dev, "%s: regulator disable timed out!\n",
+ dev_err(rdev->dev, "%s: regulator disable timed out!\n",
desc->name);
regulator_disable(priv->supply);
@@ -179,9 +178,9 @@ static int stm32_pwr_regulator_probe(struct device_d *dev)
priv = xzalloc(sizeof(*priv));
priv->base = IOMEM(iores->start);
priv->ready_mask = ready_mask_table[i];
- priv->dev = dev;
priv->rdev.desc = &desc->desc;
+ priv->rdev.dev = dev;
priv->supply = regulator_get(dev, desc->supply_name);
if (IS_ERR(priv->supply))
diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c
index 71a4ae80c3..61227e0855 100644
--- a/drivers/regulator/stpmic1_regulator.c
+++ b/drivers/regulator/stpmic1_regulator.c
@@ -21,7 +21,6 @@
* @icc_mask: icc register mask
*/
struct stpmic1_regulator_cfg {
- struct device_d *dev;
struct regulator_dev rdev;
struct regulator_desc desc;
u8 mask_reset_reg;
@@ -383,8 +382,13 @@ static int stpmic1_regulator_register(struct device_d *dev, int id,
{
int ret;
- cfg->dev = dev;
+ if (!match->of_node) {
+ dev_dbg(dev, "Skip missing DTB regulator %s", match->name);
+ return 0;
+ }
+
cfg->rdev.desc = &cfg->desc;
+ cfg->rdev.dev = dev;
cfg->rdev.regmap = dev_get_regmap(dev->parent, NULL);
if (IS_ERR(cfg->rdev.regmap))
return PTR_ERR(cfg->rdev.regmap);
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 370bebe6e2..61f862a911 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -43,9 +43,6 @@
#define IMX6SX_SW_M4C_NON_SCLR_RST BIT(4)
#define IMX6SX_SW_M4C_RST BIT(3)
-#define IMX6SX_M4_START (IMX6SX_ENABLE_M4 | IMX6SX_SW_M4P_RST \
- | IMX6SX_SW_M4C_RST)
-#define IMX6SX_M4_STOP IMX6SX_SW_M4C_NON_SCLR_RST
#define IMX6SX_M4_RST_MASK (IMX6SX_ENABLE_M4 | IMX6SX_SW_M4P_RST \
| IMX6SX_SW_M4C_NON_SCLR_RST \
| IMX6SX_SW_M4C_RST)
@@ -77,23 +74,44 @@ struct imx_rproc_att {
};
struct imx_rproc_dcfg {
- u32 src_reg;
- u32 src_mask;
- u32 src_start;
- u32 src_stop;
const struct imx_rproc_att *att;
size_t att_size;
+ int (*rproc_init)(struct rproc *rproc);
+ int (*rproc_start)(struct rproc *rproc);
+ int (*rproc_stop)(struct rproc *rproc);
};
struct imx_rproc {
struct device_d *dev;
struct regmap *regmap;
+ struct regmap *gpr;
struct rproc *rproc;
const struct imx_rproc_dcfg *dcfg;
struct imx_rproc_mem mem[IMX7D_RPROC_MEM_MAX];
struct clk *clk;
};
+static const struct imx_rproc_att imx_rproc_att_imx6sx[] = {
+ /* dev addr , sys addr , size , flags */
+ /* TCML (M4 Boot Code) - alias */
+ { 0x00000000, 0x007F8000, 0x00008000, 0 },
+ /* OCRAM_S (Code) */
+ { 0x00180000, 0x008F8000, 0x00004000, 0 },
+ /* OCRAM_S (Code) - alias */
+ { 0x00180000, 0x008FC000, 0x00004000, 0 },
+ /* TCML (Code) */
+ { 0x1FFF8000, 0x007F8000, 0x00008000, ATT_OWN },
+ /* DDR (Code) - alias, first part of DDR (Data) */
+ { 0x10000000, 0x80000000, 0x0FFF8000, 0 },
+
+ /* TCMU (Data) */
+ { 0x20000000, 0x00800000, 0x00008000, ATT_OWN },
+ /* OCRAM_S (Data) - alias? */
+ { 0x208F8000, 0x008F8000, 0x00004000, 0 },
+ /* DDR (Data) */
+ { 0x80000000, 0x80000000, 0x60000000, 0 },
+};
+
static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
/* dev addr , sys addr , size , flags */
/* OCRAM_S (M4 Boot code) - alias */
@@ -123,73 +141,188 @@ static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
{ 0x80000000, 0x80000000, 0x60000000, 0 },
};
-static const struct imx_rproc_att imx_rproc_att_imx6sx[] = {
- /* dev addr , sys addr , size , flags */
- /* TCML (M4 Boot Code) - alias */
- { 0x00000000, 0x007F8000, 0x00008000, 0 },
- /* OCRAM_S (Code) */
- { 0x00180000, 0x008F8000, 0x00004000, 0 },
- /* OCRAM_S (Code) - alias */
- { 0x00180000, 0x008FC000, 0x00004000, 0 },
- /* TCML (Code) */
- { 0x1FFF8000, 0x007F8000, 0x00008000, ATT_OWN },
- /* DDR (Code) - alias, first part of DDR (Data) */
- { 0x10000000, 0x80000000, 0x0FFF8000, 0 },
+static const struct imx_rproc_att imx_rproc_att_imx8mn[] = {
+ /* dev addr , sys addr , size , flags */
+ { 0x00000000, 0x007e0000, 0x00020000, ATT_OWN }, /* ITCM */
+ { 0x00180000, 0x00180000, 0x00009000, 0 }, /* OCRAM_S */
+ { 0x00900000, 0x00900000, 0x00020000, 0 }, /* OCRAM */
+ { 0x00920000, 0x00920000, 0x00020000, 0 }, /* OCRAM */
+ { 0x00940000, 0x00940000, 0x00050000, 0 }, /* OCRAM */
+ { 0x08000000, 0x08000000, 0x08000000, 0 }, /* QSPI Code - alias */
+ { 0x10000000, 0x80000000, 0x0ffe0000, 0 }, /* DDR (Code) - alias */
+ { 0x20000000, 0x00800000, 0x00020000, ATT_OWN }, /* DTCM */
+ { 0x20180000, 0x00180000, 0x00008000, ATT_OWN }, /* OCRAM_S - alias */
+ { 0x20200000, 0x00900000, 0x00020000, ATT_OWN }, /* OCRAM */
+ { 0x20220000, 0x00920000, 0x00020000, ATT_OWN }, /* OCRAM */
+ { 0x20240000, 0x00940000, 0x00040000, ATT_OWN }, /* OCRAM */
+ { 0x40000000, 0x40000000, 0x80000000, 0 }, /* DDR (Data) */
+};
- /* TCMU (Data) */
- { 0x20000000, 0x00800000, 0x00008000, ATT_OWN },
- /* OCRAM_S (Data) - alias? */
- { 0x208F8000, 0x008F8000, 0x00004000, 0 },
- /* DDR (Data) */
- { 0x80000000, 0x80000000, 0x60000000, 0 },
+static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
+ /* dev addr , sys addr , size , flags */
+ { 0x00000000, 0x007e0000, 0x00020000, 0 }, /* TCML - alias */
+ { 0x00180000, 0x00180000, 0x00008000, 0 }, /* OCRAM_S */
+ { 0x00900000, 0x00900000, 0x00020000, 0 }, /* OCRAM */
+ { 0x00920000, 0x00920000, 0x00020000, 0 }, /* OCRAM */
+ { 0x08000000, 0x08000000, 0x08000000, 0 }, /* QSPI Code - alias */
+ { 0x10000000, 0x80000000, 0x0ffe0000, 0 }, /* DDR (Code) - alias */
+ { 0x1ffe0000, 0x007e0000, 0x00020000, ATT_OWN }, /* TCML */
+ { 0x20000000, 0x00800000, 0x00020000, ATT_OWN }, /* TCMU */
+ { 0x20180000, 0x00180000, 0x00008000, ATT_OWN }, /* OCRAM_S */
+ { 0x20200000, 0x00900000, 0x00020000, ATT_OWN }, /* OCRAM */
+ { 0x20220000, 0x00920000, 0x00020000, ATT_OWN }, /* OCRAM */
+ { 0x40000000, 0x40000000, 0x80000000, 0 }, /* DDR (Data) */
+};
+
+static int imx6sx_rproc_start(struct rproc *rproc)
+{
+ struct imx_rproc *priv = rproc->priv;
+
+ return regmap_update_bits(priv->regmap,
+ IMX6SX_SRC_SCR,
+ IMX6SX_M4_RST_MASK,
+ IMX6SX_ENABLE_M4 | IMX6SX_SW_M4P_RST | IMX6SX_SW_M4C_RST);
+}
+
+static int imx6sx_rproc_stop(struct rproc *rproc)
+{
+ struct imx_rproc *priv = rproc->priv;
+
+ return regmap_update_bits(priv->regmap,
+ IMX6SX_SRC_SCR,
+ IMX6SX_M4_RST_MASK,
+ IMX6SX_SW_M4C_NON_SCLR_RST);
+}
+
+static int imx7d_rproc_start(struct rproc *rproc)
+{
+ struct imx_rproc *priv = rproc->priv;
+
+ return regmap_update_bits(priv->regmap,
+ IMX7D_SRC_SCR,
+ IMX7D_M4_RST_MASK,
+ IMX7D_M4_START);
+}
+
+static int imx7d_rproc_stop(struct rproc *rproc)
+{
+ struct imx_rproc *priv = rproc->priv;
+
+ return regmap_update_bits(priv->regmap,
+ IMX7D_SRC_SCR,
+ IMX7D_M4_RST_MASK,
+ IMX7D_M4_STOP);
+}
+
+#define IOMUXC_GPR22 0x58
+#define IOMUXC_GPR22_CM7_CPUWAIT BIT(0)
+
+static int imx8mn_cm7_wait(struct rproc *rproc, bool wait)
+{
+ struct imx_rproc *priv = rproc->priv;
+
+ return regmap_update_bits(priv->gpr,
+ IOMUXC_GPR22,
+ IOMUXC_GPR22_CM7_CPUWAIT,
+ wait ? IOMUXC_GPR22_CM7_CPUWAIT : 0);
+}
+
+static int imx8mn_rproc_start(struct rproc *rproc)
+{
+ struct imx_rproc *priv = rproc->priv;
+ int ret;
+
+ ret = regmap_update_bits(priv->regmap,
+ IMX7D_SRC_SCR,
+ IMX7D_M4_RST_MASK,
+ IMX7D_ENABLE_M4 | IMX7D_SW_M4C_RST);
+ if (ret)
+ return ret;
+
+ ret = imx8mn_cm7_wait(rproc, false);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int imx8mn_rproc_stop(struct rproc *rproc)
+{
+ struct imx_rproc *priv = rproc->priv;
+ int ret;
+
+ ret = imx8mn_cm7_wait(rproc, true);
+ if (ret)
+ return ret;
+
+ return regmap_update_bits(priv->regmap,
+ IMX7D_SRC_SCR,
+ IMX7D_M4_RST_MASK,
+ IMX7D_ENABLE_M4 | IMX7D_SW_M4C_RST | IMX7D_SW_M4C_NON_SCLR_RST);
+}
+
+static int imx8mn_rproc_init(struct rproc *rproc)
+{
+ struct imx_rproc *priv = rproc->priv;
+ int ret;
+
+ priv->gpr = syscon_regmap_lookup_by_compatible("fsl,imx8mp-iomuxc-gpr");
+ if (IS_ERR(priv->gpr))
+ return PTR_ERR(priv->gpr);
+
+ ret = imx8mn_cm7_wait(rproc, true);
+ if (ret)
+ return ret;
+
+ return regmap_update_bits(priv->regmap,
+ IMX7D_SRC_SCR,
+ IMX7D_M4_RST_MASK,
+ IMX7D_ENABLE_M4 | IMX7D_SW_M4C_RST);
+}
+
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
+ .att = imx_rproc_att_imx6sx,
+ .att_size = ARRAY_SIZE(imx_rproc_att_imx6sx),
+ .rproc_start = imx6sx_rproc_start,
+ .rproc_stop = imx6sx_rproc_stop,
};
static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
- .src_reg = IMX7D_SRC_SCR,
- .src_mask = IMX7D_M4_RST_MASK,
- .src_start = IMX7D_M4_START,
- .src_stop = IMX7D_M4_STOP,
.att = imx_rproc_att_imx7d,
.att_size = ARRAY_SIZE(imx_rproc_att_imx7d),
+ .rproc_start = imx7d_rproc_start,
+ .rproc_stop = imx7d_rproc_stop,
};
-static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
- .src_reg = IMX6SX_SRC_SCR,
- .src_mask = IMX6SX_M4_RST_MASK,
- .src_start = IMX6SX_M4_START,
- .src_stop = IMX6SX_M4_STOP,
- .att = imx_rproc_att_imx6sx,
- .att_size = ARRAY_SIZE(imx_rproc_att_imx6sx),
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mn = {
+ .att = imx_rproc_att_imx8mn,
+ .att_size = ARRAY_SIZE(imx_rproc_att_imx8mn),
+ .rproc_init = imx8mn_rproc_init,
+ .rproc_start = imx8mn_rproc_start,
+ .rproc_stop = imx8mn_rproc_stop,
+};
+
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
+ .att = imx_rproc_att_imx8mq,
+ .att_size = ARRAY_SIZE(imx_rproc_att_imx8mq),
+ .rproc_start = imx7d_rproc_start,
+ .rproc_stop = imx7d_rproc_stop,
};
static int imx_rproc_start(struct rproc *rproc)
{
struct imx_rproc *priv = rproc->priv;
const struct imx_rproc_dcfg *dcfg = priv->dcfg;
- struct device_d *dev = priv->dev;
- int ret;
- ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
- dcfg->src_mask, dcfg->src_start);
- if (ret)
- dev_err(dev, "Failed to enable M4!\n");
-
- return ret;
+ return dcfg->rproc_start(rproc);
}
static int imx_rproc_stop(struct rproc *rproc)
{
struct imx_rproc *priv = rproc->priv;
const struct imx_rproc_dcfg *dcfg = priv->dcfg;
- struct device_d *dev = priv->dev;
- int ret;
- ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
- dcfg->src_mask, dcfg->src_stop);
- if (ret)
- dev_err(dev, "Failed to stop M4!\n");
-
- return ret;
+ return dcfg->rproc_stop(rproc);
}
static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,
@@ -305,7 +438,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
break;
res_cpu = request_sdram_region(dev_name(dev), res.start,
- res.end - res.start);
+ resource_size(&res));
if (!res_cpu) {
dev_err(dev, "remap optional addresses failed\n");
return -ENOMEM;
@@ -374,6 +507,12 @@ static int imx_rproc_probe(struct device_d *dev)
goto err_put_rproc;
}
+ if (dcfg->rproc_init) {
+ ret = dcfg->rproc_init(rproc);
+ if (ret)
+ goto err_put_clk;
+ }
+
ret = rproc_add(rproc);
if (ret) {
dev_err(dev, "rproc_add failed\n");
@@ -389,8 +528,12 @@ err_put_rproc:
}
static const struct of_device_id imx_rproc_of_match[] = {
- { .compatible = "fsl,imx7d-cm4", .data = &imx_rproc_cfg_imx7d },
{ .compatible = "fsl,imx6sx-cm4", .data = &imx_rproc_cfg_imx6sx },
+ { .compatible = "fsl,imx7d-cm4", .data = &imx_rproc_cfg_imx7d },
+ { .compatible = "fsl,imx8mm-cm4", .data = &imx_rproc_cfg_imx8mq },
+ { .compatible = "fsl,imx8mn-cm7", .data = &imx_rproc_cfg_imx8mn },
+ { .compatible = "fsl,imx8mp-cm7", .data = &imx_rproc_cfg_imx8mn },
+ { .compatible = "fsl,imx8mq-cm4", .data = &imx_rproc_cfg_imx8mq },
{},
};
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 99b9c80655..26a54f21df 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -150,7 +150,7 @@ EXPORT_SYMBOL_GPL(reset_control_deassert);
static struct reset_control *of_reset_control_get(struct device_node *node,
const char *id)
{
- struct reset_control *rstc = ERR_PTR(-ENODEV);
+ struct reset_control *rstc;
struct reset_controller_dev *r, *rcdev;
struct of_phandle_args args;
int index = 0;
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 9b499f23c5..073f8faea8 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -118,8 +118,4 @@ static struct driver_d socfpga_reset_driver = {
.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);
+postcore_platform_driver(socfpga_reset_driver);
diff --git a/drivers/reset/reset-stm32.c b/drivers/reset/reset-stm32.c
index 6c62633563..a4498f573b 100644
--- a/drivers/reset/reset-stm32.c
+++ b/drivers/reset/reset-stm32.c
@@ -211,8 +211,4 @@ static struct driver_d stm32_rcc_reset_driver = {
.of_compatible = DRV_OF_COMPAT(stm32_rcc_reset_dt_ids),
};
-static int stm32_rcc_reset_init(void)
-{
- return platform_driver_register(&stm32_rcc_reset_driver);
-}
-postcore_initcall(stm32_rcc_reset_init);
+postcore_platform_driver(stm32_rcc_reset_driver);
diff --git a/drivers/serial/serial_cadence.c b/drivers/serial/serial_cadence.c
index 416800b847..e86dccbbc1 100644
--- a/drivers/serial/serial_cadence.c
+++ b/drivers/serial/serial_cadence.c
@@ -261,8 +261,4 @@ static struct driver_d cadence_serial_driver = {
.id_table = cadence_serial_ids,
};
-static int cadence_serial_init(void)
-{
- return platform_driver_register(&cadence_serial_driver);
-}
-console_initcall(cadence_serial_init);
+console_platform_driver(cadence_serial_driver);
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index f117ab9dc1..fc6fa7dc3e 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -468,12 +468,10 @@ static int ns16550_probe(struct device_d *dev)
struct ns16550_priv *priv;
struct console_device *cdev;
struct NS16550_plat *plat = (struct NS16550_plat *)dev->platform_data;
- struct ns16550_drvdata *devtype;
+ const struct ns16550_drvdata *devtype;
int ret;
- ret = dev_get_drvdata(dev, (const void **)&devtype);
- if (ret)
- devtype = &ns16550_drvdata;
+ devtype = device_get_match_data(dev) ?: &ns16550_drvdata;
priv = xzalloc(sizeof(*priv));
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 0694f14c39..8421d9d7c1 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -103,7 +103,9 @@ struct spi_device *spi_new_device(struct spi_controller *ctrl,
goto fail;
}
- register_device(&proxy->dev);
+ status = register_device(&proxy->dev);
+ if (status)
+ goto fail;
return proxy;
fail:
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index c068c64c6b..ea244d4bcf 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -332,6 +332,8 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)
dev->descriptor->bMaxPacketSize0 = 64;
dev->maxpacketsize = PACKET_SIZE_64;
}
+ dev->epmaxpacketin[0] = dev->descriptor->bMaxPacketSize0;
+ dev->epmaxpacketout[0] = dev->descriptor->bMaxPacketSize0;
if (do_read && dev->speed == USB_SPEED_FULL) {
int err;
@@ -355,10 +357,10 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)
err = get_descriptor_len(dev, 64, 8);
if (err)
return err;
- }
- dev->epmaxpacketin[0] = dev->descriptor->bMaxPacketSize0;
- dev->epmaxpacketout[0] = dev->descriptor->bMaxPacketSize0;
+ dev->epmaxpacketin[0] = dev->descriptor->bMaxPacketSize0;
+ dev->epmaxpacketout[0] = dev->descriptor->bMaxPacketSize0;
+ }
switch (dev->descriptor->bMaxPacketSize0) {
case 8:
diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index 908d624794..282e6754b0 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -15,19 +15,6 @@
#include "dwc2.h"
-static void dwc2_uninit_common(struct dwc2 *dwc2)
-{
- uint32_t hprt0;
-
- hprt0 = dwc2_readl(dwc2, HPRT0);
-
- /* Put everything in reset. */
- hprt0 &= ~(HPRT0_ENA | HPRT0_ENACHG | HPRT0_CONNDET | HPRT0_OVRCURRCHG);
- hprt0 |= HPRT0_RST;
-
- dwc2_writel(dwc2, hprt0, HPRT0);
-}
-
static int dwc2_set_mode(void *ctx, enum usb_dr_mode mode)
{
struct dwc2 *dwc2 = ctx;
@@ -98,7 +85,8 @@ static void dwc2_remove(struct device_d *dev)
{
struct dwc2 *dwc2 = dev->priv;
- dwc2_uninit_common(dwc2);
+ dwc2_host_uninit(dwc2);
+ dwc2_gadget_uninit(dwc2);
}
static const struct of_device_id dwc2_platform_dt_ids[] = {
diff --git a/drivers/usb/dwc2/dwc2.h b/drivers/usb/dwc2/dwc2.h
index 5e845f3491..30ad906656 100644
--- a/drivers/usb/dwc2/dwc2.h
+++ b/drivers/usb/dwc2/dwc2.h
@@ -34,13 +34,17 @@ int dwc2_submit_roothub(struct dwc2 *dwc2, struct usb_device *dev,
unsigned long pipe, void *buf, int len,
struct devrequest *setup);
int dwc2_register_host(struct dwc2 *dwc2);
+void dwc2_host_uninit(struct dwc2 *dwc2);
#else
static inline int dwc2_register_host(struct dwc2 *dwc2) { return -ENODEV; }
+static inline void dwc2_host_uninit(struct dwc2 *dwc2) {};
#endif
/* Gadget functions */
#ifdef CONFIG_USB_DWC2_GADGET
int dwc2_gadget_init(struct dwc2 *dwc2);
+void dwc2_gadget_uninit(struct dwc2 *dwc2);
#else
static inline int dwc2_gadget_init(struct dwc2 *dwc2) { return -ENODEV; }
+static inline void dwc2_gadget_uninit(struct dwc2 *dwc2) {};
#endif
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 6a65b9b117..aa7447c9b4 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2734,3 +2734,9 @@ int dwc2_gadget_init(struct dwc2 *dwc2)
return 0;
}
+
+void dwc2_gadget_uninit(struct dwc2 *dwc2)
+{
+ dwc2_core_disconnect(dwc2);
+ dwc2_gadget_disconnect(dwc2);
+}
diff --git a/drivers/usb/dwc2/host.c b/drivers/usb/dwc2/host.c
index 13cb3472d7..510a07dfb9 100644
--- a/drivers/usb/dwc2/host.c
+++ b/drivers/usb/dwc2/host.c
@@ -788,3 +788,16 @@ int dwc2_register_host(struct dwc2 *dwc2)
return usb_register_host(host);
}
+
+void dwc2_host_uninit(struct dwc2 *dwc2)
+{
+ uint32_t hprt0;
+
+ hprt0 = dwc2_readl(dwc2, HPRT0);
+
+ /* Put everything in reset. */
+ hprt0 &= ~(HPRT0_ENA | HPRT0_ENACHG | HPRT0_CONNDET | HPRT0_OVRCURRCHG);
+ hprt0 |= HPRT0_RST;
+
+ dwc2_writel(dwc2, hprt0, HPRT0);
+}
diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
index 635be02929..b1a77a1637 100644
--- a/drivers/usb/imx/chipidea-imx.c
+++ b/drivers/usb/imx/chipidea-imx.c
@@ -277,9 +277,8 @@ static int imx_chipidea_probe(struct device_d *dev)
if (of_property_read_bool(dev->device_node, "fsl,usbphy")) {
ci->phy = of_phy_get_by_phandle(dev, "fsl,usbphy", 0);
if (IS_ERR(ci->phy)) {
- ret = PTR_ERR(ci->phy);
- dev_err(dev, "Cannot get phy: %s\n", strerror(-ret));
- return ret;
+ dev_err(dev, "Cannot get phy: %pe\n", ci->phy);
+ return PTR_ERR(ci->phy);
} else {
ci->usbphy = phy_to_usbphy(ci->phy);
if (IS_ERR(ci->usbphy))
diff --git a/drivers/usb/imx/imx-usb-misc.c b/drivers/usb/imx/imx-usb-misc.c
index aa4485ccba..3a5ec236e5 100644
--- a/drivers/usb/imx/imx-usb-misc.c
+++ b/drivers/usb/imx/imx-usb-misc.c
@@ -673,10 +673,4 @@ static struct driver_d imx_usbmisc_driver = {
.of_compatible = DRV_OF_COMPAT(imx_usbmisc_dt_ids),
};
-static int imx_usbmisc_init(void)
-{
- platform_driver_register(&imx_usbmisc_driver);
- return 0;
-}
-
-coredevice_initcall(imx_usbmisc_init);
+coredevice_platform_driver(imx_usbmisc_driver);
diff --git a/drivers/usb/imx/imx-usb-phy.c b/drivers/usb/imx/imx-usb-phy.c
index c23a747d0b..32098ef248 100644
--- a/drivers/usb/imx/imx-usb-phy.c
+++ b/drivers/usb/imx/imx-usb-phy.c
@@ -165,7 +165,7 @@ static int imx_usbphy_probe(struct device_d *dev)
imxphy->clk = clk_get(dev, NULL);
if (IS_ERR(imxphy->clk)) {
- dev_err(dev, "could not get clk: %s\n", strerrorp(imxphy->clk));
+ dev_err(dev, "could not get clk: %pe\n", imxphy->clk);
ret = PTR_ERR(imxphy->clk);
goto err_clk;
}
@@ -216,8 +216,4 @@ static struct driver_d imx_usbphy_driver = {
.of_compatible = DRV_OF_COMPAT(imx_usbphy_dt_ids),
};
-static int imx_usbphy_init(void)
-{
- return platform_driver_register(&imx_usbphy_driver);
-}
-fs_initcall(imx_usbphy_init);
+fs_platform_driver(imx_usbphy_driver);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 9fdef8679b..266663a9b0 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -330,7 +330,6 @@ void musb_load_testpacket(struct musb *musb)
static void musb_generic_disable(struct musb *musb)
{
void __iomem *mbase = musb->mregs;
- u16 temp;
/* disable interrupts */
musb_writeb(mbase, MUSB_INTRUSBE, 0);
@@ -343,9 +342,9 @@ static void musb_generic_disable(struct musb *musb)
musb_writeb(mbase, MUSB_DEVCTL, 0);
/* flush pending interrupts */
- temp = musb_readb(mbase, MUSB_INTRUSB);
- temp = musb_readw(mbase, MUSB_INTRTX);
- temp = musb_readw(mbase, MUSB_INTRRX);
+ (void)musb_readb(mbase, MUSB_INTRUSB);
+ (void)musb_readw(mbase, MUSB_INTRTX);
+ (void)musb_readw(mbase, MUSB_INTRRX);
}
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 68d819af2c..be9651b049 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1189,8 +1189,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
pipe = urb->pipe;
- dev_dbg(musb->controller, "<== hw %d rxcsr %04x, urb actual %d (+dma %zu)\n",
- epnum, rx_csr, urb->actual_length, 0);
+ dev_dbg(musb->controller, "<== hw %d rxcsr %04x, urb actual %d (+dma 0)\n",
+ epnum, rx_csr, urb->actual_length);
/* check for errors, concurrent stall & unlink is not really
* handled yet! */
diff --git a/drivers/usb/musb/phy-am335x.c b/drivers/usb/musb/phy-am335x.c
index f2e870d7ee..b0b4bebbff 100644
--- a/drivers/usb/musb/phy-am335x.c
+++ b/drivers/usb/musb/phy-am335x.c
@@ -78,8 +78,4 @@ static struct driver_d am335x_phy_driver = {
.of_compatible = DRV_OF_COMPAT(am335x_phy_dt_ids),
};
-static int am335x_phy_init(void)
-{
- return platform_driver_register(&am335x_phy_driver);
-}
-fs_initcall(am335x_phy_init);
+fs_platform_driver(am335x_phy_driver);
diff --git a/drivers/video/imx-ipu-v3/imx-hdmi.c b/drivers/video/imx-ipu-v3/imx-hdmi.c
index 17b6e4cc25..1e55c97d24 100644
--- a/drivers/video/imx-ipu-v3/imx-hdmi.c
+++ b/drivers/video/imx-ipu-v3/imx-hdmi.c
@@ -1083,19 +1083,18 @@ static void dw_hdmi_enable_video_path(struct dw_hdmi *hdmi)
/* Workaround to clear the overflow condition */
static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi)
{
- int count;
+ int count = 4;
u8 val;
/* TMDS software reset */
hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, HDMI_MC_SWRSTZ);
val = hdmi_readb(hdmi, HDMI_FC_INVIDCONF);
- if (hdmi->dev_type == IMX6DL_HDMI) {
- hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF);
- return;
- }
- for (count = 0; count < 4; count++)
+ if (hdmi->dev_type == IMX6DL_HDMI)
+ count = 1;
+
+ while (count--)
hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF);
}
@@ -1193,28 +1192,13 @@ static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi)
hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE);
}
-struct dw_hdmi_data {
- unsigned ipu_mask;
- enum dw_hdmi_devtype devtype;
-};
-
-static struct dw_hdmi_data imx6q_hdmi_data = {
- .ipu_mask = 0xf,
- .devtype = IMX6Q_HDMI,
-};
-
-static struct dw_hdmi_data imx6dl_hdmi_data = {
- .ipu_mask = 0x3,
- .devtype = IMX6DL_HDMI,
-};
-
static struct of_device_id dw_hdmi_dt_ids[] = {
{
.compatible = "fsl,imx6q-hdmi",
- .data = &imx6q_hdmi_data,
+ .data = (void *)IMX6Q_HDMI,
}, {
.compatible = "fsl,imx6dl-hdmi",
- .data = &imx6dl_hdmi_data,
+ .data = (void *)IMX6DL_HDMI,
}, {
/* sentinel */
}
@@ -1276,11 +1260,6 @@ static int dw_hdmi_probe(struct device_d *dev)
struct device_node *np = dev->device_node;
struct dw_hdmi *hdmi;
int ret;
- const struct dw_hdmi_data *devtype;
-
- ret = dev_get_drvdata(dev, (const void **)&devtype);
- if (ret)
- return ret;
hdmi = xzalloc(sizeof(*hdmi));
@@ -1289,9 +1268,7 @@ static int dw_hdmi_probe(struct device_d *dev)
hdmi->sample_rate = 48000;
hdmi->ratio = 100;
- ret = dev_get_drvdata(dev, (const void **)&hdmi->dev_type);
- if (ret)
- return ret;
+ hdmi->dev_type = (enum dw_hdmi_devtype)device_get_match_data(dev);
hdmi->ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
diff --git a/drivers/video/imx-ipu-v3/imx-ldb.c b/drivers/video/imx-ipu-v3/imx-ldb.c
index 9b4524274c..d7793bdc0e 100644
--- a/drivers/video/imx-ipu-v3/imx-ldb.c
+++ b/drivers/video/imx-ipu-v3/imx-ldb.c
@@ -162,7 +162,7 @@ static int imx6q_set_clock(struct imx_ldb *ldb, int ipuno, int dino, int chno, u
diclk = clk_lookup(clkname);
free(clkname);
if (IS_ERR(diclk)) {
- dev_err(ldb->dev, "failed to get di clk: %s\n", strerrorp(diclk));
+ dev_err(ldb->dev, "failed to get di clk: %pe\n", diclk);
return PTR_ERR(diclk);
}
@@ -170,7 +170,7 @@ static int imx6q_set_clock(struct imx_ldb *ldb, int ipuno, int dino, int chno, u
ldbclk = clk_lookup(clkname);
free(clkname);
if (IS_ERR(ldbclk)) {
- dev_err(ldb->dev, "failed to get ldb clk: %s\n", strerrorp(ldbclk));
+ dev_err(ldb->dev, "failed to get ldb clk: %pe\n", ldbclk);
return PTR_ERR(ldbclk);
}
@@ -233,7 +233,7 @@ static int imx53_ldb_prepare(struct imx_ldb_channel *imx_ldb_ch, int di,
diclk = clk_lookup(clkname);
free(clkname);
if (IS_ERR(diclk)) {
- dev_err(ldb->dev, "failed to get di clk: %s\n", strerrorp(diclk));
+ dev_err(ldb->dev, "failed to get di clk: %pe\n", diclk);
return PTR_ERR(diclk);
}
@@ -241,7 +241,7 @@ static int imx53_ldb_prepare(struct imx_ldb_channel *imx_ldb_ch, int di,
ldbclk = clk_lookup(clkname);
free(clkname);
if (IS_ERR(ldbclk)) {
- dev_err(ldb->dev, "failed to get ldb clk: %s\n", strerrorp(ldbclk));
+ dev_err(ldb->dev, "failed to get ldb clk: %pe\n", ldbclk);
return PTR_ERR(ldbclk);
}
diff --git a/drivers/video/imx-ipu-v3/ipu-common.c b/drivers/video/imx-ipu-v3/ipu-common.c
index 1811e50227..b31edcdd55 100644
--- a/drivers/video/imx-ipu-v3/ipu-common.c
+++ b/drivers/video/imx-ipu-v3/ipu-common.c
@@ -804,9 +804,8 @@ static int ipu_probe(struct device_d *dev)
ipu->clk = clk_get(dev, "bus");
if (IS_ERR(ipu->clk)) {
- ret = PTR_ERR(ipu->clk);
- dev_err(dev, "clk_get failed: %s\n", strerror(-ret));
- return ret;
+ dev_err(dev, "clk_get failed: %pe\n", ipu->clk);
+ return PTR_ERR(ipu->clk);
}
dev->priv = ipu;
diff --git a/drivers/video/imx-ipu-v3/ipufb.c b/drivers/video/imx-ipu-v3/ipufb.c
index 683f298e76..dd54d9df31 100644
--- a/drivers/video/imx-ipu-v3/ipufb.c
+++ b/drivers/video/imx-ipu-v3/ipufb.c
@@ -356,8 +356,4 @@ static struct driver_d ipufb_driver = {
.remove = ipufb_remove,
};
-static int ipufb_register(void)
-{
- return platform_driver_register(&ipufb_driver);
-}
-late_initcall(ipufb_register);
+late_platform_driver(ipufb_driver);
diff --git a/drivers/video/omap.c b/drivers/video/omap.c
index 67b31522ae..009626fefc 100644
--- a/drivers/video/omap.c
+++ b/drivers/video/omap.c
@@ -514,9 +514,4 @@ static struct driver_d omapfb_driver = {
.probe = omapfb_probe,
};
-static int omapfb_init(void)
-{
- return platform_driver_register(&omapfb_driver);
-}
-
-device_initcall(omapfb_init);
+device_platform_driver(omapfb_driver);
diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c
index 0709399358..994f43dc5c 100644
--- a/drivers/video/ssd1307fb.c
+++ b/drivers/video/ssd1307fb.c
@@ -421,7 +421,7 @@ static int ssd1307fb_probe(struct device_d *dev)
goto fb_alloc_error;
}
- par->vbat = regulator_get(&client->dev, "vbat-supply");
+ par->vbat = regulator_get(&client->dev, "vbat");
if (IS_ERR(par->vbat)) {
dev_info(&client->dev, "Will not use VBAT");
par->vbat = NULL;
diff --git a/drivers/watchdog/ar9344_wdt.c b/drivers/watchdog/ar9344_wdt.c
index 4615288631..c7cd552dc7 100644
--- a/drivers/watchdog/ar9344_wdt.c
+++ b/drivers/watchdog/ar9344_wdt.c
@@ -34,8 +34,8 @@
struct ar9344_wd {
struct watchdog wd;
void __iomem *base;
- struct clk *clk;
struct device_d *dev;
+ unsigned int rate;
};
static int ar9344_watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
@@ -45,7 +45,7 @@ static int ar9344_watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
if (timeout) {
ctrl = AR9344_WD_CTRL_ACTION_FCR;
- val = timeout * clk_get_rate(priv->clk);
+ val = timeout * priv->rate;
} else {
ctrl = AR9344_WD_CTRL_ACTION_NONE;
val = U32_MAX;
@@ -74,6 +74,7 @@ static int ar9344_wdt_probe(struct device_d *dev)
{
struct resource *iores;
struct ar9344_wd *priv;
+ struct clk *clk;
int ret;
priv = xzalloc(sizeof(struct ar9344_wd));
@@ -93,16 +94,22 @@ static int ar9344_wdt_probe(struct device_d *dev)
ar9344_watchdog_detect_reset_source(priv);
- priv->clk = clk_get(dev, NULL);
- if (IS_ERR(priv->clk)) {
+ clk = clk_get(dev, NULL);
+ if (IS_ERR(clk)) {
dev_err(dev, "could not get clk\n");
- ret = PTR_ERR(priv->clk);
+ ret = PTR_ERR(clk);
goto on_error;
}
- clk_enable(priv->clk);
+ clk_enable(clk);
- priv->wd.timeout_max = U32_MAX / clk_get_rate(priv->clk);
+ priv->rate = clk_get_rate(clk);
+ if (priv->rate == 0) {
+ ret = -EINVAL;
+ goto on_error;
+ }
+
+ priv->wd.timeout_max = U32_MAX / priv->rate;
ret = watchdog_register(&priv->wd);
if (ret)
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 3f554bf47b..fe6f2e0408 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -102,8 +102,4 @@ static struct driver_d at91sam9x_wdt_driver = {
.probe = at91sam9x_wdt_probe,
};
-static int __init at91sam9x_wdt_init(void)
-{
- return platform_driver_register(&at91sam9x_wdt_driver);
-}
-device_initcall(at91sam9x_wdt_init);
+device_platform_driver(at91sam9x_wdt_driver);
diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c
index 781626fa0f..233eaa85c1 100644
--- a/drivers/watchdog/bcm2835_wdt.c
+++ b/drivers/watchdog/bcm2835_wdt.c
@@ -139,8 +139,4 @@ static struct driver_d bcm2835_wd_driver = {
.probe = bcm2835_wd_probe,
};
-static int __init bcm2835_wd_init(void)
-{
- return platform_driver_register(&bcm2835_wd_driver);
-}
-device_initcall(bcm2835_wd_init);
+device_platform_driver(bcm2835_wd_driver);
diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index cb0d17e361..17771c7126 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -41,10 +41,10 @@
struct dw_wdt {
void __iomem *regs;
- struct clk *clk;
struct restart_handler restart;
struct watchdog wdd;
struct reset_control *rst;
+ unsigned int rate;
};
#define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd)
@@ -55,7 +55,7 @@ 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);
+ return (1U << (16 + top)) / dw_wdt->rate;
}
static int dw_wdt_start(struct watchdog *wdd)
@@ -134,6 +134,7 @@ static int dw_wdt_drv_probe(struct device_d *dev)
struct watchdog *wdd;
struct dw_wdt *dw_wdt;
struct resource *mem;
+ struct clk *clk;
int ret;
dw_wdt = xzalloc(sizeof(*dw_wdt));
@@ -143,11 +144,11 @@ static int dw_wdt_drv_probe(struct device_d *dev)
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);
+ clk = clk_get(dev, NULL);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
- ret = clk_enable(dw_wdt->clk);
+ ret = clk_enable(clk);
if (ret)
return ret;
@@ -160,6 +161,10 @@ static int dw_wdt_drv_probe(struct device_d *dev)
wdd->hwdev = dev;
wdd->set_timeout = dw_wdt_set_timeout;
+ dw_wdt->rate = clk_get_rate(clk);
+ if (dw_wdt->rate == 0)
+ return -EINVAL;
+
ret = watchdog_register(wdd);
if (ret)
goto out_disable_clk;
@@ -179,7 +184,7 @@ static int dw_wdt_drv_probe(struct device_d *dev)
return 0;
out_disable_clk:
- clk_disable(dw_wdt->clk);
+ clk_disable(clk);
return ret;
}
diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
index 9e38f1a669..4d7a263b7e 100644
--- a/drivers/watchdog/stm32_iwdg.c
+++ b/drivers/watchdog/stm32_iwdg.c
@@ -157,6 +157,8 @@ static int stm32_iwdg_probe(struct device_d *dev)
return ret;
wd->rate = clk_get_rate(clk);
+ if (wd->rate == 0)
+ return -EINVAL;
if (data->has_pclk) {
clk = clk_get(dev, "pclk");