Browse Source

Merge branch 'master' of git://git.denx.de/u-boot-mips

tags/2020-06-01
Tom Rini 2 years ago
parent
commit
2a046ff5e9
21 changed files with 198 additions and 166 deletions
  1. +2
    -6
      drivers/clk/clk_bcm6345.c
  2. +15
    -0
      drivers/core/fdtaddr.c
  3. +17
    -0
      drivers/core/read.c
  4. +3
    -9
      drivers/cpu/bmips_cpu.c
  5. +5
    -13
      drivers/gpio/bcm6345_gpio.c
  6. +17
    -35
      drivers/led/led_bcm6328.c
  7. +15
    -29
      drivers/led/led_bcm6358.c
  8. +3
    -7
      drivers/phy/bcm6318-usbh-phy.c
  9. +3
    -7
      drivers/phy/bcm6348-usbh-phy.c
  10. +3
    -7
      drivers/phy/bcm6358-usbh-phy.c
  11. +3
    -6
      drivers/phy/bcm6368-usbh-phy.c
  12. +2
    -6
      drivers/power/domain/bcm6328-power-domain.c
  13. +2
    -5
      drivers/ram/bmips_ram.c
  14. +2
    -6
      drivers/reset/reset-bcm6345.c
  15. +2
    -6
      drivers/serial/serial_bcm6345.c
  16. +3
    -9
      drivers/spi/bcm63xx_hsspi.c
  17. +3
    -9
      drivers/spi/bcm63xx_spi.c
  18. +2
    -6
      drivers/watchdog/bcm6345_wdt.c
  19. +22
    -0
      include/dm/fdtaddr.h
  20. +32
    -0
      include/dm/read.h
  21. +42
    -0
      test/dm/test-fdt.c

+ 2
- 6
drivers/clk/clk_bcm6345.c View File

@@ -55,15 +55,11 @@ static const struct udevice_id bcm6345_clk_ids[] = {
static int bcm63xx_clk_probe(struct udevice *dev)
{
struct bcm6345_clk_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
fdt_size_t size;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);

return 0;
}



+ 15
- 0
drivers/core/fdtaddr.c View File

@@ -136,6 +136,21 @@ void *devfdt_get_addr_ptr(struct udevice *dev)
return (void *)(uintptr_t)devfdt_get_addr_index(dev, 0);
}

void *devfdt_remap_addr_index(struct udevice *dev, int index)
{
fdt_addr_t addr = devfdt_get_addr(dev);

if (addr == FDT_ADDR_T_NONE)
return NULL;

return map_physmem(addr, 0, MAP_NOCACHE);
}

void *devfdt_remap_addr(struct udevice *dev)
{
return devfdt_remap_addr_index(dev, 0);
}

void *devfdt_map_physmem(struct udevice *dev, unsigned long size)
{
fdt_addr_t addr = devfdt_get_addr(dev);


+ 17
- 0
drivers/core/read.c View File

@@ -4,6 +4,8 @@
* Written by Simon Glass <sjg@chromium.org>
*/

#include <asm/types.h>
#include <asm/io.h>
#include <common.h>
#include <dm.h>
#include <mapmem.h>
@@ -57,6 +59,16 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index)
return devfdt_get_addr_index(dev, index);
}

void *dev_remap_addr_index(struct udevice *dev, int index)
{
fdt_addr_t addr = dev_read_addr_index(dev, index);

if (addr == FDT_ADDR_T_NONE)
return NULL;

return map_physmem(addr, 0, MAP_NOCACHE);
}

fdt_addr_t dev_read_addr(struct udevice *dev)
{
return dev_read_addr_index(dev, 0);
@@ -69,6 +81,11 @@ void *dev_read_addr_ptr(struct udevice *dev)
return (addr == FDT_ADDR_T_NONE) ? NULL : map_sysmem(addr, 0);
}

void *dev_remap_addr(struct udevice *dev)
{
return dev_remap_addr_index(dev, 0);
}

fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property,
fdt_size_t *sizep)
{


+ 3
- 9
drivers/cpu/bmips_cpu.c View File

@@ -13,8 +13,6 @@
#include <errno.h>
#include <asm/io.h>

DECLARE_GLOBAL_DATA_PTR;

#define REV_CHIPID_SHIFT 16
#define REV_CHIPID_MASK (0xffff << REV_CHIPID_SHIFT)
#define REV_LONG_CHIPID_SHIFT 12
@@ -397,8 +395,7 @@ int bmips_cpu_bind(struct udevice *dev)
{
struct cpu_platdata *plat = dev_get_parent_platdata(dev);

plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
"reg", -1);
plat->cpu_id = dev_read_u32_default(dev, "reg", -1);
plat->device_id = read_c0_prid();

return 0;
@@ -409,14 +406,11 @@ int bmips_cpu_probe(struct udevice *dev)
struct bmips_cpu_priv *priv = dev_get_priv(dev);
const struct bmips_cpu_hw *hw =
(const struct bmips_cpu_hw *)dev_get_driver_data(dev);
fdt_addr_t addr;
fdt_size_t size;

addr = devfdt_get_addr_size_index(dev_get_parent(dev), 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);
priv->hw = hw;

return 0;


+ 5
- 13
drivers/gpio/bcm6345_gpio.c View File

@@ -13,8 +13,6 @@
#include <asm/gpio.h>
#include <asm/io.h>

DECLARE_GLOBAL_DATA_PTR;

struct bcm6345_gpio_priv {
void __iomem *reg_dirout;
void __iomem *reg_data;
@@ -90,22 +88,16 @@ static int bcm6345_gpio_probe(struct udevice *dev)
{
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
struct bcm6345_gpio_priv *priv = dev_get_priv(dev);
fdt_addr_t data_addr, dirout_addr;
fdt_size_t data_size, dirout_size;

dirout_addr = devfdt_get_addr_size_index(dev, 0, &dirout_size);
if (dirout_addr == FDT_ADDR_T_NONE)
priv->reg_dirout = dev_remap_addr_index(dev, 0);
if (!priv->reg_dirout)
return -EINVAL;

data_addr = devfdt_get_addr_size_index(dev, 1, &data_size);
if (data_addr == FDT_ADDR_T_NONE)
priv->reg_data = dev_remap_addr_index(dev, 1);
if (!priv->reg_data)
return -EINVAL;

priv->reg_data = ioremap(data_addr, data_size);
priv->reg_dirout = ioremap(dirout_addr, dirout_size);

uc_priv->gpio_count = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
"ngpios", 32);
uc_priv->gpio_count = dev_read_u32_default(dev, "ngpios", 32);
uc_priv->bank_name = dev->name;

return 0;


+ 17
- 35
drivers/led/led_bcm6328.c View File

@@ -37,8 +37,6 @@
#define LED_MODE_OFF 3
#define LED_MODE_MASK 0x3

DECLARE_GLOBAL_DATA_PTR;

struct bcm6328_led_priv {
void __iomem *regs;
void __iomem *mode;
@@ -149,34 +147,25 @@ static const struct led_ops bcm6328_led_ops = {
static int bcm6328_led_probe(struct udevice *dev)
{
struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
fdt_addr_t addr;
fdt_size_t size;

/* Top-level LED node */
if (!uc_plat->label) {
void __iomem *regs;
u32 set_bits = 0;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
regs = dev_remap_addr(dev);
if (!regs)
return -EINVAL;

regs = ioremap(addr, size);

if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"brcm,serial-leds"))
if (dev_read_bool(dev, "brcm,serial-leds"))
set_bits |= LED_INIT_SLEDEN_MASK;
if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"brcm,serial-mux"))
if (dev_read_bool(dev, "brcm,serial-mux"))
set_bits |= LED_INIT_SLEDMUX_MASK;
if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"brcm,serial-clk-low"))
if (dev_read_bool(dev, "brcm,serial-clk-low"))
set_bits |= LED_INIT_SLEDCLKNPOL_MASK;
if (!fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"brcm,serial-dat-low"))
if (!dev_read_bool(dev, "brcm,serial-dat-low"))
set_bits |= LED_INIT_SLEDDATANPOL_MASK;
if (!fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"brcm,serial-shift-inv"))
if (!dev_read_bool(dev, "brcm,serial-shift-inv"))
set_bits |= LED_INIT_SLEDSHIFTDIR_MASK;

clrsetbits_be32(regs + LED_INIT_REG, ~0, set_bits);
@@ -184,17 +173,14 @@ static int bcm6328_led_probe(struct udevice *dev)
struct bcm6328_led_priv *priv = dev_get_priv(dev);
unsigned int pin;

addr = devfdt_get_addr_size_index(dev_get_parent(dev), 0,
&size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

pin = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "reg",
LEDS_MAX);
pin = dev_read_u32_default(dev, "reg", LEDS_MAX);
if (pin >= LEDS_MAX)
return -EINVAL;

priv->regs = ioremap(addr, size);
if (pin < 8) {
/* LEDs 0-7 (bits 47:32) */
priv->mode = priv->regs + LED_MODE_REG_HI;
@@ -205,8 +191,7 @@ static int bcm6328_led_probe(struct udevice *dev)
priv->shift = ((pin - 8) << 1);
}

if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"active-low"))
if (dev_read_bool(dev, "active-low"))
priv->active_low = true;
}

@@ -215,27 +200,24 @@ static int bcm6328_led_probe(struct udevice *dev)

static int bcm6328_led_bind(struct udevice *parent)
{
const void *blob = gd->fdt_blob;
int node;
ofnode node;

for (node = fdt_first_subnode(blob, dev_of_offset(parent));
node > 0;
node = fdt_next_subnode(blob, node)) {
dev_for_each_subnode(node, parent) {
struct led_uc_plat *uc_plat;
struct udevice *dev;
const char *label;
int ret;

label = fdt_getprop(blob, node, "label", NULL);
label = ofnode_read_string(node, "label");
if (!label) {
debug("%s: node %s has no label\n", __func__,
fdt_get_name(blob, node, NULL));
ofnode_get_name(node));
return -EINVAL;
}

ret = device_bind_driver_to_node(parent, "bcm6328-led",
fdt_get_name(blob, node, NULL),
offset_to_ofnode(node), &dev);
ofnode_get_name(node),
node, &dev);
if (ret)
return ret;



+ 15
- 29
drivers/led/led_bcm6358.c View File

@@ -31,8 +31,6 @@
#define LED_CTRL_BUSY_SHIFT 3
#define LED_CTRL_BUSY_MASK (1 << LED_CTRL_BUSY_SHIFT)

DECLARE_GLOBAL_DATA_PTR;

struct bcm6358_led_priv {
void __iomem *regs;
uint8_t pin;
@@ -114,8 +112,6 @@ static const struct led_ops bcm6358_led_ops = {
static int bcm6358_led_probe(struct udevice *dev)
{
struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
fdt_addr_t addr;
fdt_size_t size;

/* Top-level LED node */
if (!uc_plat->label) {
@@ -123,17 +119,14 @@ static int bcm6358_led_probe(struct udevice *dev)
unsigned int clk_div;
u32 set_bits = 0;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
regs = dev_remap_addr(dev);
if (!regs)
return -EINVAL;

regs = ioremap(addr, size);

if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"brcm,clk-dat-low"))
if (dev_read_bool(dev, "brcm,clk-dat-low"))
set_bits |= LED_CTRL_POL_MASK;
clk_div = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
"brcm,clk-div", LED_CTRL_CLK_1);
clk_div = dev_read_u32_default(dev, "brcm,clk-div",
LED_CTRL_CLK_1);
switch (clk_div) {
case 8:
set_bits |= LED_CTRL_CLK_8;
@@ -157,21 +150,17 @@ static int bcm6358_led_probe(struct udevice *dev)
struct bcm6358_led_priv *priv = dev_get_priv(dev);
unsigned int pin;

addr = devfdt_get_addr_size_index(dev_get_parent(dev), 0,
&size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

pin = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), "reg",
LEDS_MAX);
pin = dev_read_u32_default(dev, "reg", LEDS_MAX);
if (pin >= LEDS_MAX)
return -EINVAL;

priv->regs = ioremap(addr, size);
priv->pin = pin;

if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
"active-low"))
if (dev_read_bool(dev, "active-low"))
priv->active_low = true;
}

@@ -180,27 +169,24 @@ static int bcm6358_led_probe(struct udevice *dev)

static int bcm6358_led_bind(struct udevice *parent)
{
const void *blob = gd->fdt_blob;
int node;
ofnode node;

for (node = fdt_first_subnode(blob, dev_of_offset(parent));
node > 0;
node = fdt_next_subnode(blob, node)) {
dev_for_each_subnode(node, parent) {
struct led_uc_plat *uc_plat;
struct udevice *dev;
const char *label;
int ret;

label = fdt_getprop(blob, node, "label", NULL);
label = ofnode_read_string(node, "label");
if (!label) {
debug("%s: node %s has no label\n", __func__,
fdt_get_name(blob, node, NULL));
ofnode_get_name(node));
return -EINVAL;
}

ret = device_bind_driver_to_node(parent, "bcm6358-led",
fdt_get_name(blob, node, NULL),
offset_to_ofnode(node), &dev);
ofnode_get_name(node),
node, &dev);
if (ret)
return ret;



+ 3
- 7
drivers/phy/bcm6318-usbh-phy.c View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
* Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
*
* Derived from linux/arch/mips/bcm63xx/usb-common.c:
* Copyright 2008 Maxime Bizon <mbizon@freebox.fr>
@@ -79,16 +79,12 @@ static int bcm6318_usbh_probe(struct udevice *dev)
struct power_domain pwr_dom;
struct reset_ctl rst_ctl;
struct clk clk;
fdt_addr_t addr;
fdt_size_t size;
int ret;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);

/* enable usbh clock */
ret = clk_get_by_name(dev, "usbh", &clk);
if (ret < 0)


+ 3
- 7
drivers/phy/bcm6348-usbh-phy.c View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
* Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
*
* Derived from linux/arch/mips/bcm63xx/usb-common.c:
* Copyright 2008 Maxime Bizon <mbizon@freebox.fr>
@@ -44,16 +44,12 @@ static int bcm6348_usbh_probe(struct udevice *dev)
struct bcm6348_usbh_priv *priv = dev_get_priv(dev);
struct reset_ctl rst_ctl;
struct clk clk;
fdt_addr_t addr;
fdt_size_t size;
int ret;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);

/* enable usbh clock */
ret = clk_get_by_name(dev, "usbh", &clk);
if (ret < 0)


+ 3
- 7
drivers/phy/bcm6358-usbh-phy.c View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
* Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
*
* Derived from linux/arch/mips/bcm63xx/usb-common.c:
* Copyright 2008 Maxime Bizon <mbizon@freebox.fr>
@@ -57,16 +57,12 @@ static int bcm6358_usbh_probe(struct udevice *dev)
{
struct bcm6358_usbh_priv *priv = dev_get_priv(dev);
struct reset_ctl rst_ctl;
fdt_addr_t addr;
fdt_size_t size;
int ret;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);

/* perform reset */
ret = reset_get_by_index(dev, 0, &rst_ctl);
if (ret < 0)


+ 3
- 6
drivers/phy/bcm6368-usbh-phy.c View File

@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
* Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
*
* Derived from linux/arch/mips/bcm63xx/usb-common.c:
* Copyright 2008 Maxime Bizon <mbizon@freebox.fr>
@@ -116,15 +116,12 @@ static int bcm6368_usbh_probe(struct udevice *dev)
#endif
struct reset_ctl rst_ctl;
struct clk clk;
fdt_addr_t addr;
fdt_size_t size;
int ret;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);
priv->hw = hw;

/* enable usbh clock */


+ 2
- 6
drivers/power/domain/bcm6328-power-domain.c View File

@@ -48,15 +48,11 @@ static int bcm6328_power_domain_off(struct power_domain *power_domain)
static int bcm6328_power_domain_probe(struct udevice *dev)
{
struct bcm6328_power_domain *priv = dev_get_priv(dev);
fdt_addr_t addr;
fdt_size_t size;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);

return 0;
}



+ 2
- 5
drivers/ram/bmips_ram.c View File

@@ -150,14 +150,11 @@ static int bmips_ram_probe(struct udevice *dev)
struct bmips_ram_priv *priv = dev_get_priv(dev);
const struct bmips_ram_hw *hw =
(const struct bmips_ram_hw *)dev_get_driver_data(dev);
fdt_addr_t addr;
fdt_size_t size;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);
priv->hw = hw;

return 0;


+ 2
- 6
drivers/reset/reset-bcm6345.c View File

@@ -66,15 +66,11 @@ static const struct udevice_id bcm6345_reset_ids[] = {
static int bcm6345_reset_probe(struct udevice *dev)
{
struct bcm6345_reset_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
fdt_size_t size;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);

return 0;
}



+ 2
- 6
drivers/serial/serial_bcm6345.c View File

@@ -227,17 +227,13 @@ static int bcm6345_serial_probe(struct udevice *dev)
{
struct bcm6345_serial_priv *priv = dev_get_priv(dev);
struct clk clk;
fdt_addr_t addr;
fdt_size_t size;
int ret;

/* get address */
addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->base = dev_remap_addr(dev);
if (!priv->base)
return -EINVAL;

priv->base = ioremap(addr, size);

/* get clock rate */
ret = clk_get_by_index(dev, 0, &clk);
if (ret < 0)


+ 3
- 9
drivers/spi/bcm63xx_hsspi.c View File

@@ -15,8 +15,6 @@
#include <wait_bit.h>
#include <asm/io.h>

DECLARE_GLOBAL_DATA_PTR;

#define HSSPI_PP 0

#define SPI_MAX_SYNC_CLOCK 30000000
@@ -337,17 +335,13 @@ static int bcm63xx_hsspi_probe(struct udevice *dev)
struct bcm63xx_hsspi_priv *priv = dev_get_priv(dev);
struct reset_ctl rst_ctl;
struct clk clk;
fdt_addr_t addr;
fdt_size_t size;
int ret;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);
priv->num_cs = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
"num-cs", 8);
priv->num_cs = dev_read_u32_default(dev, "num-cs", 8);

/* enable clock */
ret = clk_get_by_name(dev, "hsspi", &clk);


+ 3
- 9
drivers/spi/bcm63xx_spi.c View File

@@ -15,8 +15,6 @@
#include <wait_bit.h>
#include <asm/io.h>

DECLARE_GLOBAL_DATA_PTR;

/* BCM6348 SPI core */
#define SPI_6348_CLK 0x06
#define SPI_6348_CMD 0x00
@@ -373,18 +371,14 @@ static int bcm63xx_spi_probe(struct udevice *dev)
(const unsigned long *)dev_get_driver_data(dev);
struct reset_ctl rst_ctl;
struct clk clk;
fdt_addr_t addr;
fdt_size_t size;
int ret;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->base = dev_remap_addr(dev);
if (!priv->base)
return -EINVAL;

priv->regs = regs;
priv->base = ioremap(addr, size);
priv->num_cs = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
"num-cs", 8);
priv->num_cs = dev_read_u32_default(dev, "num-cs", 8);

/* enable clock */
ret = clk_get_by_index(dev, 0, &clk);


+ 2
- 6
drivers/watchdog/bcm6345_wdt.c View File

@@ -85,15 +85,11 @@ static const struct udevice_id bcm6345_wdt_ids[] = {
static int bcm6345_wdt_probe(struct udevice *dev)
{
struct bcm6345_wdt_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
fdt_size_t size;

addr = devfdt_get_addr_size_index(dev, 0, &size);
if (addr == FDT_ADDR_T_NONE)
priv->regs = dev_remap_addr(dev);
if (!priv->regs)
return -EINVAL;

priv->regs = ioremap(addr, size);

bcm6345_wdt_stop(dev);

return 0;


+ 22
- 0
include/dm/fdtaddr.h View File

@@ -34,6 +34,28 @@ fdt_addr_t devfdt_get_addr(struct udevice *dev);
void *devfdt_get_addr_ptr(struct udevice *dev);

/**
* devfdt_remap_addr() - Return pointer to the memory-mapped I/O address
* of the reg property of a device
*
* @dev: Pointer to a device
*
* @return Pointer to addr, or NULL if there is no such property
*/
void *devfdt_remap_addr(struct udevice *dev);

/**
* devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped
* I/O address of the reg property of a device
* @index: the 'reg' property can hold a list of <addr, size> pairs
* and @index is used to select which one is required
*
* @dev: Pointer to a device
*
* @return Pointer to addr, or NULL if there is no such property
*/
void *devfdt_remap_addr_index(struct udevice *dev, int index);

/**
* devfdt_map_physmem() - Read device address from reg property of the
* device node and map the address into CPU address
* space.


+ 32
- 0
include/dm/read.h View File

@@ -113,6 +113,18 @@ int dev_read_size(struct udevice *dev, const char *propname);
fdt_addr_t dev_read_addr_index(struct udevice *dev, int index);

/**
* dev_remap_addr_index() - Get the indexed reg property of a device
* as a memory-mapped I/O pointer
*
* @dev: Device to read from
* @index: the 'reg' property can hold a list of <addr, size> pairs
* and @index is used to select which one is required
*
* @return pointer or NULL if not found
*/
void *dev_remap_addr_index(struct udevice *dev, int index);

/**
* dev_read_addr() - Get the reg property of a device
*
* @dev: Device to read from
@@ -132,6 +144,16 @@ fdt_addr_t dev_read_addr(struct udevice *dev);
void *dev_read_addr_ptr(struct udevice *dev);

/**
* dev_remap_addr() - Get the reg property of a device as a
* memory-mapped I/O pointer
*
* @dev: Device to read from
*
* @return pointer or NULL if not found
*/
void *dev_remap_addr(struct udevice *dev);

/**
* dev_read_addr_size() - get address and size from a device property
*
* This does no address translation. It simply reads an property that contains
@@ -482,6 +504,16 @@ static inline void *dev_read_addr_ptr(struct udevice *dev)
return devfdt_get_addr_ptr(dev);
}

static inline void *dev_remap_addr(struct udevice *dev)
{
return devfdt_remap_addr(dev);
}

static inline void *dev_remap_addr_index(struct udevice *dev, int index)
{
return devfdt_remap_addr_index(dev, index);
}

static inline fdt_addr_t dev_read_addr_size(struct udevice *dev,
const char *propname,
fdt_size_t *sizep)


+ 42
- 0
test/dm/test-fdt.c View File

@@ -461,3 +461,45 @@ static int dm_test_fdt_translation(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdt_translation, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);

/* Test devfdt_remap_addr_index() */
static int dm_test_fdt_remap_addr_flat(struct unit_test_state *uts)
{
struct udevice *dev;
fdt_addr_t addr;
void *paddr;

ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev));

addr = devfdt_get_addr(dev);
ut_asserteq(0x8000, addr);

paddr = map_physmem(addr, 0, MAP_NOCACHE);
ut_assertnonnull(paddr);
ut_asserteq_ptr(paddr, devfdt_remap_addr(dev));

return 0;
}
DM_TEST(dm_test_fdt_remap_addr_flat,
DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);

/* Test dev_remap_addr_index() */
static int dm_test_fdt_remap_addr_live(struct unit_test_state *uts)
{
struct udevice *dev;
fdt_addr_t addr;
void *paddr;

ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_DUMMY, 0, true, &dev));

addr = dev_read_addr(dev);
ut_asserteq(0x8000, addr);

paddr = map_physmem(addr, 0, MAP_NOCACHE);
ut_assertnonnull(paddr);
ut_asserteq_ptr(paddr, dev_remap_addr(dev));

return 0;
}
DM_TEST(dm_test_fdt_remap_addr_live,
DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);

Loading…
Cancel
Save