diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ddr/marvell/axp/ddr3_axp_config.h | 2 | ||||
-rw-r--r-- | drivers/ddr/marvell/axp/xor.c | 3 | ||||
-rw-r--r-- | drivers/ddr/marvell/axp/xor.h | 1 | ||||
-rw-r--r-- | drivers/i2c/lpc32xx_i2c.c | 14 | ||||
-rw-r--r-- | drivers/net/mvneta.c | 1 | ||||
-rw-r--r-- | drivers/pci/Makefile | 1 | ||||
-rw-r--r-- | drivers/pci/pci_mvebu.c | 423 | ||||
-rw-r--r-- | drivers/spi/exynos_spi.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/ehci-marvell.c | 28 |
9 files changed, 455 insertions, 20 deletions
diff --git a/drivers/ddr/marvell/axp/ddr3_axp_config.h b/drivers/ddr/marvell/axp/ddr3_axp_config.h index 800d2d1476..a6720442ff 100644 --- a/drivers/ddr/marvell/axp/ddr3_axp_config.h +++ b/drivers/ddr/marvell/axp/ddr3_axp_config.h @@ -44,7 +44,7 @@ * DDR3_TRAINING_DEBUG - Debug prints of internal code */ #define DDR_TARGET_FABRIC 5 -#define DRAM_ECC 0 +#define DRAM_ECC 1 #ifdef MV_DDR_32BIT #define BUS_WIDTH 32 diff --git a/drivers/ddr/marvell/axp/xor.c b/drivers/ddr/marvell/axp/xor.c index 66c96aef4e..54924cac3c 100644 --- a/drivers/ddr/marvell/axp/xor.c +++ b/drivers/ddr/marvell/axp/xor.c @@ -18,7 +18,6 @@ static u32 xor_regs_ctrl_backup; static u32 xor_regs_base_backup[MAX_CS]; static u32 xor_regs_mask_backup[MAX_CS]; -static void mv_xor_hal_init(u32 chan_num); static int mv_xor_cmd_set(u32 chan, int command); static int mv_xor_ctrl_set(u32 chan, u32 xor_ctrl); @@ -110,7 +109,7 @@ void mv_sys_xor_finish(void) * RETURN: * MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise. */ -static void mv_xor_hal_init(u32 chan_num) +void mv_xor_hal_init(u32 chan_num) { u32 i; diff --git a/drivers/ddr/marvell/axp/xor.h b/drivers/ddr/marvell/axp/xor.h index 353648758a..3ff784d7a9 100644 --- a/drivers/ddr/marvell/axp/xor.h +++ b/drivers/ddr/marvell/axp/xor.h @@ -60,6 +60,7 @@ struct crc_dma_desc { u32 src_addr1; /* Mode: Source Block address pointer */ } __packed; +void mv_xor_hal_init(u32 chan_num); int mv_xor_state_get(u32 chan); void mv_sys_xor_init(MV_DRAM_INFO *dram_info); void mv_sys_xor_finish(void); diff --git a/drivers/i2c/lpc32xx_i2c.c b/drivers/i2c/lpc32xx_i2c.c index 78d26e48c3..7f4eccdf53 100644 --- a/drivers/i2c/lpc32xx_i2c.c +++ b/drivers/i2c/lpc32xx_i2c.c @@ -72,7 +72,7 @@ static unsigned int lpc32xx_i2c_set_bus_speed(struct i2c_adapter *adap, if (speed == 0) return -EINVAL; - half_period = (105000000 / speed) / 2; + half_period = (get_hclk_clk_rate() / speed) / 2; if ((half_period > 255) || (half_period < 0)) return -EINVAL; @@ -172,12 +172,12 @@ static int lpc32xx_i2c_read(struct i2c_adapter *adap, u8 dev, uint addr, *(data++) = readl(&i2c->rx); } } + /* wait for end of transation */ + while (!((stat = readl(&i2c->stat)) & LPC32XX_I2C_STAT_TDI)) + ; + /* clear end-of-transaction flag */ + writel(1, &i2c->stat); } - /* wait for end of transation */ - while (!((stat = readl(&i2c->stat)) & LPC32XX_I2C_STAT_TDI)) - ; - /* clear end-of-transaction flag */ - writel(1, &i2c->stat); /* success */ return 0; } @@ -200,6 +200,8 @@ static int lpc32xx_i2c_write(struct i2c_adapter *adap, u8 dev, uint addr, if (alen | length) /* Address slave in write mode */ writel((dev<<1) | LPC32XX_I2C_TX_START, &i2c->tx); + else + return 0; /* write address bytes */ while (alen) { /* wait for transmit fifo not full */ diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c index efaae167fe..38ad14eff9 100644 --- a/drivers/net/mvneta.c +++ b/drivers/net/mvneta.c @@ -41,7 +41,6 @@ printf(fmt, ##args) #define CONFIG_NR_CPUS 1 -#define BIT(nr) (1UL << (nr)) #define ETH_HLEN 14 /* Total octets in header */ /* 2(HW hdr) 14(MAC hdr) 4(CRC) 32(extra for cache prefetch) */ diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index adc238f0f0..bcf8127b98 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_PCI_GT64120) += pci_gt64120.o obj-$(CONFIG_PCI_MSC01) += pci_msc01.o obj-$(CONFIG_PCIE_IMX) += pcie_imx.o obj-$(CONFIG_FTPCI100) += pci_ftpci100.o +obj-$(CONFIG_PCI_MVEBU) += pci_mvebu.o obj-$(CONFIG_SH4_PCI) += pci_sh4.o obj-$(CONFIG_SH7751_PCI) +=pci_sh7751.o obj-$(CONFIG_SH7780_PCI) +=pci_sh7780.o diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c new file mode 100644 index 0000000000..fd2744dbd4 --- /dev/null +++ b/drivers/pci/pci_mvebu.c @@ -0,0 +1,423 @@ +/* + * PCIe driver for Marvell MVEBU SoCs + * + * Based on Barebox drivers/pci/pci-mvebu.c + * + * Ported to U-Boot by: + * Anton Schubert <anton.schubert@gmx.de> + * Stefan Roese <sr@denx.de> + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include <common.h> +#include <pci.h> +#include <asm/errno.h> +#include <asm/io.h> +#include <asm/arch/cpu.h> +#include <asm/arch/soc.h> +#include <linux/mbus.h> + +DECLARE_GLOBAL_DATA_PTR; + +/* PCIe unit register offsets */ +#define SELECT(x, n) ((x >> n) & 1UL) + +#define PCIE_DEV_ID_OFF 0x0000 +#define PCIE_CMD_OFF 0x0004 +#define PCIE_DEV_REV_OFF 0x0008 +#define PCIE_BAR_LO_OFF(n) (0x0010 + ((n) << 3)) +#define PCIE_BAR_HI_OFF(n) (0x0014 + ((n) << 3)) +#define PCIE_CAPAB_OFF 0x0060 +#define PCIE_CTRL_STAT_OFF 0x0068 +#define PCIE_HEADER_LOG_4_OFF 0x0128 +#define PCIE_BAR_CTRL_OFF(n) (0x1804 + (((n) - 1) * 4)) +#define PCIE_WIN04_CTRL_OFF(n) (0x1820 + ((n) << 4)) +#define PCIE_WIN04_BASE_OFF(n) (0x1824 + ((n) << 4)) +#define PCIE_WIN04_REMAP_OFF(n) (0x182c + ((n) << 4)) +#define PCIE_WIN5_CTRL_OFF 0x1880 +#define PCIE_WIN5_BASE_OFF 0x1884 +#define PCIE_WIN5_REMAP_OFF 0x188c +#define PCIE_CONF_ADDR_OFF 0x18f8 +#define PCIE_CONF_ADDR_EN BIT(31) +#define PCIE_CONF_REG(r) ((((r) & 0xf00) << 16) | ((r) & 0xfc)) +#define PCIE_CONF_BUS(b) (((b) & 0xff) << 16) +#define PCIE_CONF_DEV(d) (((d) & 0x1f) << 11) +#define PCIE_CONF_FUNC(f) (((f) & 0x7) << 8) +#define PCIE_CONF_ADDR(dev, reg) \ + (PCIE_CONF_BUS(PCI_BUS(dev)) | PCIE_CONF_DEV(PCI_DEV(dev)) | \ + PCIE_CONF_FUNC(PCI_FUNC(dev)) | PCIE_CONF_REG(reg) | \ + PCIE_CONF_ADDR_EN) +#define PCIE_CONF_DATA_OFF 0x18fc +#define PCIE_MASK_OFF 0x1910 +#define PCIE_MASK_ENABLE_INTS (0xf << 24) +#define PCIE_CTRL_OFF 0x1a00 +#define PCIE_CTRL_X1_MODE BIT(0) +#define PCIE_STAT_OFF 0x1a04 +#define PCIE_STAT_BUS (0xff << 8) +#define PCIE_STAT_DEV (0x1f << 16) +#define PCIE_STAT_LINK_DOWN BIT(0) +#define PCIE_DEBUG_CTRL 0x1a60 +#define PCIE_DEBUG_SOFT_RESET BIT(20) + +struct resource { + u32 start; + u32 end; +}; + +struct mvebu_pcie { + struct pci_controller hose; + char *name; + void __iomem *base; + void __iomem *membase; + struct resource mem; + void __iomem *iobase; + u32 port; + u32 lane; + u32 lane_mask; + pci_dev_t dev; +}; + +#define to_pcie(_hc) container_of(_hc, struct mvebu_pcie, pci) + +/* + * MVEBU PCIe controller needs MEMORY and I/O BARs to be mapped + * into SoCs address space. Each controller will map 32M of MEM + * and 64K of I/O space when registered. + */ +static void __iomem *mvebu_pcie_membase = (void __iomem *)MBUS_PCI_MEM_BASE; +#define PCIE_MEM_SIZE (32 << 20) + +#if defined(CONFIG_ARMADA_38X) +#define PCIE_BASE(if) \ + ((if) == 0 ? \ + MVEBU_REG_PCIE_BASE + 0x40000 : \ + MVEBU_REG_PCIE_BASE + 0x4000 * (if)) + +/* + * On A38x MV6820 these PEX ports are supported: + * 0 - Port 0.0 + * 1 - Port 0.1 + * 2 - Port 0.2 + */ +#define MAX_PEX 3 +static struct mvebu_pcie pcie_bus[MAX_PEX]; + +static void mvebu_get_port_lane(struct mvebu_pcie *pcie, int pex_idx, + int *mem_target, int *mem_attr) +{ + u8 port[] = { 0, 1, 2 }; + u8 lane[] = { 0, 0, 0 }; + u8 target[] = { 8, 4, 4 }; + u8 attr[] = { 0xe8, 0xe8, 0xd8 }; + + pcie->port = port[pex_idx]; + pcie->lane = lane[pex_idx]; + *mem_target = target[pex_idx]; + *mem_attr = attr[pex_idx]; +} +#else +#define PCIE_BASE(if) \ + ((if) < 8 ? \ + (MVEBU_REG_PCIE_BASE + ((if) / 4) * 0x40000 + ((if) % 4) * 0x4000) : \ + (MVEBU_REG_PCIE_BASE + 0x2000 + ((if) % 8) * 0x40000)) + +/* + * On AXP MV78460 these PEX ports are supported: + * 0 - Port 0.0 + * 1 - Port 0.1 + * 2 - Port 0.2 + * 3 - Port 0.3 + * 4 - Port 1.0 + * 5 - Port 1.1 + * 6 - Port 1.2 + * 7 - Port 1.3 + * 8 - Port 2.0 + * 9 - Port 3.0 + */ +#define MAX_PEX 10 +static struct mvebu_pcie pcie_bus[MAX_PEX]; + +static void mvebu_get_port_lane(struct mvebu_pcie *pcie, int pex_idx, + int *mem_target, int *mem_attr) +{ + u8 port[] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 3 }; + u8 lane[] = { 0, 1, 2, 3, 0, 1, 2, 3, 0, 0 }; + u8 target[] = { 4, 4, 4, 4, 8, 8, 8, 8, 4, 8 }; + u8 attr[] = { 0xe8, 0xd8, 0xb8, 0x78, + 0xe8, 0xd8, 0xb8, 0x78, + 0xf8, 0xf8 }; + + pcie->port = port[pex_idx]; + pcie->lane = lane[pex_idx]; + *mem_target = target[pex_idx]; + *mem_attr = attr[pex_idx]; +} +#endif + +static inline bool mvebu_pcie_link_up(struct mvebu_pcie *pcie) +{ + u32 val; + val = readl(pcie->base + PCIE_STAT_OFF); + return !(val & PCIE_STAT_LINK_DOWN); +} + +static void mvebu_pcie_set_local_bus_nr(struct mvebu_pcie *pcie, int busno) +{ + u32 stat; + + stat = readl(pcie->base + PCIE_STAT_OFF); + stat &= ~PCIE_STAT_BUS; + stat |= busno << 8; + writel(stat, pcie->base + PCIE_STAT_OFF); +} + +static void mvebu_pcie_set_local_dev_nr(struct mvebu_pcie *pcie, int devno) +{ + u32 stat; + + stat = readl(pcie->base + PCIE_STAT_OFF); + stat &= ~PCIE_STAT_DEV; + stat |= devno << 16; + writel(stat, pcie->base + PCIE_STAT_OFF); +} + +static int mvebu_pcie_get_local_bus_nr(struct mvebu_pcie *pcie) +{ + u32 stat; + + stat = readl(pcie->base + PCIE_STAT_OFF); + return (stat & PCIE_STAT_BUS) >> 8; +} + +static int mvebu_pcie_get_local_dev_nr(struct mvebu_pcie *pcie) +{ + u32 stat; + + stat = readl(pcie->base + PCIE_STAT_OFF); + return (stat & PCIE_STAT_DEV) >> 16; +} + +static inline struct mvebu_pcie *hose_to_pcie(struct pci_controller *hose) +{ + return container_of(hose, struct mvebu_pcie, hose); +} + +static int mvebu_pcie_read_config_dword(struct pci_controller *hose, + pci_dev_t dev, int offset, u32 *val) +{ + struct mvebu_pcie *pcie = hose_to_pcie(hose); + int local_bus = PCI_BUS(pcie->dev); + int local_dev = PCI_DEV(pcie->dev); + u32 reg; + + /* Only allow one other device besides the local one on the local bus */ + if (PCI_BUS(dev) == local_bus && PCI_DEV(dev) != local_dev) { + if (local_dev == 0 && PCI_DEV(dev) != 1) { + /* + * If local dev is 0, the first other dev can + * only be 1 + */ + *val = 0xffffffff; + return 1; + } else if (local_dev != 0 && PCI_DEV(dev) != 0) { + /* + * If local dev is not 0, the first other dev can + * only be 0 + */ + *val = 0xffffffff; + return 1; + } + } + + /* write address */ + reg = PCIE_CONF_ADDR(dev, offset); + writel(reg, pcie->base + PCIE_CONF_ADDR_OFF); + *val = readl(pcie->base + PCIE_CONF_DATA_OFF); + + return 0; +} + +static int mvebu_pcie_write_config_dword(struct pci_controller *hose, + pci_dev_t dev, int offset, u32 val) +{ + struct mvebu_pcie *pcie = hose_to_pcie(hose); + int local_bus = PCI_BUS(pcie->dev); + int local_dev = PCI_DEV(pcie->dev); + + /* Only allow one other device besides the local one on the local bus */ + if (PCI_BUS(dev) == local_bus && PCI_DEV(dev) != local_dev) { + if (local_dev == 0 && PCI_DEV(dev) != 1) { + /* + * If local dev is 0, the first other dev can + * only be 1 + */ + return 1; + } else if (local_dev != 0 && PCI_DEV(dev) != 0) { + /* + * If local dev is not 0, the first other dev can + * only be 0 + */ + return 1; + } + } + + writel(PCIE_CONF_ADDR(dev, offset), pcie->base + PCIE_CONF_ADDR_OFF); + writel(val, pcie->base + PCIE_CONF_DATA_OFF); + + return 0; +} + +/* + * Setup PCIE BARs and Address Decode Wins: + * BAR[0,2] -> disabled, BAR[1] -> covers all DRAM banks + * WIN[0-3] -> DRAM bank[0-3] + */ +static void mvebu_pcie_setup_wins(struct mvebu_pcie *pcie) +{ + const struct mbus_dram_target_info *dram = mvebu_mbus_dram_info(); + u32 size; + int i; + + /* First, disable and clear BARs and windows. */ + for (i = 1; i < 3; i++) { + writel(0, pcie->base + PCIE_BAR_CTRL_OFF(i)); + writel(0, pcie->base + PCIE_BAR_LO_OFF(i)); + writel(0, pcie->base + PCIE_BAR_HI_OFF(i)); + } + + for (i = 0; i < 5; i++) { + writel(0, pcie->base + PCIE_WIN04_CTRL_OFF(i)); + writel(0, pcie->base + PCIE_WIN04_BASE_OFF(i)); + writel(0, pcie->base + PCIE_WIN04_REMAP_OFF(i)); + } + + writel(0, pcie->base + PCIE_WIN5_CTRL_OFF); + writel(0, pcie->base + PCIE_WIN5_BASE_OFF); + writel(0, pcie->base + PCIE_WIN5_REMAP_OFF); + + /* Setup windows for DDR banks. Count total DDR size on the fly. */ + size = 0; + for (i = 0; i < dram->num_cs; i++) { + const struct mbus_dram_window *cs = dram->cs + i; + + writel(cs->base & 0xffff0000, + pcie->base + PCIE_WIN04_BASE_OFF(i)); + writel(0, pcie->base + PCIE_WIN04_REMAP_OFF(i)); + writel(((cs->size - 1) & 0xffff0000) | + (cs->mbus_attr << 8) | + (dram->mbus_dram_target_id << 4) | 1, + pcie->base + PCIE_WIN04_CTRL_OFF(i)); + + size += cs->size; + } + + /* Round up 'size' to the nearest power of two. */ + if ((size & (size - 1)) != 0) + size = 1 << fls(size); + + /* Setup BAR[1] to all DRAM banks. */ + writel(dram->cs[0].base | 0xc, pcie->base + PCIE_BAR_LO_OFF(1)); + writel(0, pcie->base + PCIE_BAR_HI_OFF(1)); + writel(((size - 1) & 0xffff0000) | 0x1, + pcie->base + PCIE_BAR_CTRL_OFF(1)); +} + +void pci_init_board(void) +{ + int mem_target, mem_attr, i; + int bus = 0; + u32 reg; + u32 soc_ctrl = readl(MVEBU_SYSTEM_REG_BASE + 0x4); + + /* Check SoC Control Power State */ + debug("%s: SoC Control %08x, 0en %01lx, 1en %01lx, 2en %01lx\n", + __func__, soc_ctrl, SELECT(soc_ctrl, 0), SELECT(soc_ctrl, 1), + SELECT(soc_ctrl, 2)); + + for (i = 0; i < MAX_PEX; i++) { + struct mvebu_pcie *pcie = &pcie_bus[i]; + struct pci_controller *hose = &pcie->hose; + + /* Get port number, lane number and memory target / attr */ + mvebu_get_port_lane(pcie, i, &mem_target, &mem_attr); + + /* Don't read at all from pci registers if port power is down */ + if (pcie->lane == 0 && SELECT(soc_ctrl, pcie->port) == 0) { + i += 3; + debug("%s: skipping port %d\n", __func__, pcie->port); + continue; + } + + pcie->base = (void __iomem *)PCIE_BASE(i); + + /* Check link and skip ports that have no link */ + if (!mvebu_pcie_link_up(pcie)) { + debug("%s: PCIe %d.%d - down\n", __func__, + pcie->port, pcie->lane); + continue; + } + debug("%s: PCIe %d.%d - up, base %08x\n", __func__, + pcie->port, pcie->lane, (u32)pcie->base); + + /* Read Id info and local bus/dev */ + debug("direct conf read %08x, local bus %d, local dev %d\n", + readl(pcie->base), mvebu_pcie_get_local_bus_nr(pcie), + mvebu_pcie_get_local_dev_nr(pcie)); + + mvebu_pcie_set_local_bus_nr(pcie, bus); + mvebu_pcie_set_local_dev_nr(pcie, 0); + pcie->dev = PCI_BDF(bus, 0, 0); + + pcie->mem.start = (u32)mvebu_pcie_membase; + pcie->mem.end = pcie->mem.start + PCIE_MEM_SIZE - 1; + mvebu_pcie_membase += PCIE_MEM_SIZE; + + if (mvebu_mbus_add_window_by_id(mem_target, mem_attr, + (phys_addr_t)pcie->mem.start, + PCIE_MEM_SIZE)) { + printf("PCIe unable to add mbus window for mem at %08x+%08x\n", + (u32)pcie->mem.start, PCIE_MEM_SIZE); + } + + /* Setup windows and configure host bridge */ + mvebu_pcie_setup_wins(pcie); + + /* Master + slave enable. */ + reg = readl(pcie->base + PCIE_CMD_OFF); + reg |= PCI_COMMAND_MEMORY; + reg |= PCI_COMMAND_MASTER; + reg |= BIT(10); /* disable interrupts */ + writel(reg, pcie->base + PCIE_CMD_OFF); + + /* Setup U-Boot PCI Controller */ + hose->first_busno = 0; + hose->current_busno = bus; + + /* PCI memory space */ + pci_set_region(hose->regions + 0, pcie->mem.start, + pcie->mem.start, PCIE_MEM_SIZE, PCI_REGION_MEM); + pci_set_region(hose->regions + 1, + 0, 0, + gd->ram_size, + PCI_REGION_MEM | PCI_REGION_SYS_MEMORY); + hose->region_count = 2; + + pci_set_ops(hose, + pci_hose_read_config_byte_via_dword, + pci_hose_read_config_word_via_dword, + mvebu_pcie_read_config_dword, + pci_hose_write_config_byte_via_dword, + pci_hose_write_config_word_via_dword, + mvebu_pcie_write_config_dword); + pci_register_hose(hose); + + hose->last_busno = pci_hose_scan(hose); + + /* Set BAR0 to internal registers */ + writel(SOC_REGS_PHY_BASE, pcie->base + PCIE_BAR_LO_OFF(0)); + writel(0, pcie->base + PCIE_BAR_HI_OFF(0)); + + bus = hose->last_busno + 1; + } +} diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index 6d77c319e7..418b48120a 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -16,7 +16,7 @@ #include <asm/arch/cpu.h> #include <asm/arch/gpio.h> #include <asm/arch/pinmux.h> -#include <asm/arch-exynos/spi.h> +#include <asm/arch/spi.h> #include <asm/io.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c index 3a9f60f169..50fa01c079 100644 --- a/drivers/usb/host/ehci-marvell.c +++ b/drivers/usb/host/ehci-marvell.c @@ -30,14 +30,22 @@ DECLARE_GLOBAL_DATA_PTR; */ #ifdef CONFIG_ARMADA_XP -#define MVUSB0_BASE MVEBU_USB20_BASE +/* + * Armada XP and Armada 38x have different base addresses for + * the USB 2.0 EHCI host controller. So we need to provide + * a mechnism to support both here. + */ +#define MVUSB0_BASE \ + (mvebu_soc_family() == MVEBU_SOC_A38X ? \ + MVEBU_USB20_BASE : MVEBU_AXP_USB_BASE) +#define MVUSB_BASE(port) MVUSB0_BASE + ((port) << 12) /* * Once all the older Marvell SoC's (Orion, Kirkwood) are converted * to the common mvebu archticture including the mbus setup, this * will be the only function needed to configure the access windows */ -static void usb_brg_adrdec_setup(void) +static void usb_brg_adrdec_setup(int index) { const struct mbus_dram_target_info *dram; int i; @@ -45,8 +53,8 @@ static void usb_brg_adrdec_setup(void) dram = mvebu_mbus_dram_info(); for (i = 0; i < 4; i++) { - writel(0, MVUSB0_BASE + USB_WINDOW_CTRL(i)); - writel(0, MVUSB0_BASE + USB_WINDOW_BASE(i)); + writel(0, MVUSB_BASE(index) + USB_WINDOW_CTRL(i)); + writel(0, MVUSB_BASE(index) + USB_WINDOW_BASE(i)); } for (i = 0; i < dram->num_cs; i++) { @@ -55,14 +63,16 @@ static void usb_brg_adrdec_setup(void) /* Write size, attributes and target id to control register */ writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) | (dram->mbus_dram_target_id << 4) | 1, - MVUSB0_BASE + USB_WINDOW_CTRL(i)); + MVUSB_BASE(index) + USB_WINDOW_CTRL(i)); /* Write base address to base register */ - writel(cs->base, MVUSB0_BASE + USB_WINDOW_BASE(i)); + writel(cs->base, MVUSB_BASE(index) + USB_WINDOW_BASE(i)); } } #else -static void usb_brg_adrdec_setup(void) +#define MVUSB_BASE(port) MVUSB0_BASE + +static void usb_brg_adrdec_setup(int index) { int i; u32 size, base, attrib; @@ -111,9 +121,9 @@ static void usb_brg_adrdec_setup(void) int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { - usb_brg_adrdec_setup(); + usb_brg_adrdec_setup(index); - *hccr = (struct ehci_hccr *)(MVUSB0_BASE + 0x100); + *hccr = (struct ehci_hccr *)(MVUSB_BASE(index) + 0x100); *hcor = (struct ehci_hcor *)((uint32_t) *hccr + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); |