#include <common.h>
#include <clk.h>
#include <dm.h>
+#include <log.h>
+#include <malloc.h>
#include <spi.h>
#include <reset.h>
#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
if (cs >= priv->num_cs) {
printf("no cs %u\n", cs);
- return -ENODEV;
+ return -EINVAL;
}
return 0;
}
if (flags & SPI_XFER_END) {
- struct dm_spi_slave_platdata *plat =
- dev_get_parent_platdata(dev);
+ struct dm_spi_slave_plat *plat =
+ dev_get_parent_plat(dev);
uint16_t val, cmd;
int ret;
struct bcm63xx_spi_priv *priv = dev_get_priv(dev->parent);
const unsigned long *regs = priv->regs;
struct spi_slave *slave = dev_get_parent_priv(dev);
- struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
+ struct dm_spi_slave_plat *plat = dev_get_parent_plat(dev);
/* check cs */
if (plat->cs >= priv->num_cs) {
(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);
if (ret < 0)
return ret;
- ret = clk_free(&clk);
- if (ret < 0)
- return ret;
+ clk_free(&clk);
/* perform reset */
ret = reset_get_by_index(dev, 0, &rst_ctl);
.id = UCLASS_SPI,
.of_match = bcm63xx_spi_ids,
.ops = &bcm63xx_spi_ops,
- .priv_auto_alloc_size = sizeof(struct bcm63xx_spi_priv),
+ .priv_auto = sizeof(struct bcm63xx_spi_priv),
.child_pre_probe = bcm63xx_spi_child_pre_probe,
.probe = bcm63xx_spi_probe,
};