Path: blob/master/arch/arm/mach-mv78xx0/addr-map.c
10817 views
/*1* arch/arm/mach-mv78xx0/addr-map.c2*3* Address map functions for Marvell MV78xx0 SoCs4*5* This file is licensed under the terms of the GNU General Public6* License version 2. This program is licensed "as is" without any7* warranty of any kind, whether express or implied.8*/910#include <linux/kernel.h>11#include <linux/init.h>12#include <linux/mbus.h>13#include <linux/io.h>14#include "common.h"1516/*17* Generic Address Decode Windows bit settings18*/19#define TARGET_DDR 020#define TARGET_DEV_BUS 121#define TARGET_PCIE0 422#define TARGET_PCIE1 823#define TARGET_PCIE(i) ((i) ? TARGET_PCIE1 : TARGET_PCIE0)24#define ATTR_DEV_SPI_ROM 0x1f25#define ATTR_DEV_BOOT 0x2f26#define ATTR_DEV_CS3 0x3727#define ATTR_DEV_CS2 0x3b28#define ATTR_DEV_CS1 0x3d29#define ATTR_DEV_CS0 0x3e30#define ATTR_PCIE_IO(l) (0xf0 & ~(0x10 << (l)))31#define ATTR_PCIE_MEM(l) (0xf8 & ~(0x10 << (l)))3233/*34* Helpers to get DDR bank info35*/36#define DDR_BASE_CS_OFF(n) (0x0000 + ((n) << 3))37#define DDR_SIZE_CS_OFF(n) (0x0004 + ((n) << 3))3839/*40* CPU Address Decode Windows registers41*/42#define WIN0_OFF(n) (BRIDGE_VIRT_BASE + 0x0000 + ((n) << 4))43#define WIN8_OFF(n) (BRIDGE_VIRT_BASE + 0x0900 + (((n) - 8) << 4))44#define WIN_CTRL_OFF 0x000045#define WIN_BASE_OFF 0x000446#define WIN_REMAP_LO_OFF 0x000847#define WIN_REMAP_HI_OFF 0x000c484950struct mbus_dram_target_info mv78xx0_mbus_dram_info;5152static void __init __iomem *win_cfg_base(int win)53{54/*55* Find the control register base address for this window.56*57* BRIDGE_VIRT_BASE points to the right (CPU0's or CPU1's)58* MBUS bridge depending on which CPU core we're running on,59* so we don't need to take that into account here.60*/6162return (void __iomem *)((win < 8) ? WIN0_OFF(win) : WIN8_OFF(win));63}6465static int __init cpu_win_can_remap(int win)66{67if (win < 8)68return 1;6970return 0;71}7273static void __init setup_cpu_win(int win, u32 base, u32 size,74u8 target, u8 attr, int remap)75{76void __iomem *addr = win_cfg_base(win);77u32 ctrl;7879base &= 0xffff0000;80ctrl = ((size - 1) & 0xffff0000) | (attr << 8) | (target << 4) | 1;8182writel(base, addr + WIN_BASE_OFF);83writel(ctrl, addr + WIN_CTRL_OFF);84if (cpu_win_can_remap(win)) {85if (remap < 0)86remap = base;8788writel(remap & 0xffff0000, addr + WIN_REMAP_LO_OFF);89writel(0, addr + WIN_REMAP_HI_OFF);90}91}9293void __init mv78xx0_setup_cpu_mbus(void)94{95void __iomem *addr;96int i;97int cs;9899/*100* First, disable and clear windows.101*/102for (i = 0; i < 14; i++) {103addr = win_cfg_base(i);104105writel(0, addr + WIN_BASE_OFF);106writel(0, addr + WIN_CTRL_OFF);107if (cpu_win_can_remap(i)) {108writel(0, addr + WIN_REMAP_LO_OFF);109writel(0, addr + WIN_REMAP_HI_OFF);110}111}112113/*114* Setup MBUS dram target info.115*/116mv78xx0_mbus_dram_info.mbus_dram_target_id = TARGET_DDR;117118if (mv78xx0_core_index() == 0)119addr = (void __iomem *)DDR_WINDOW_CPU0_BASE;120else121addr = (void __iomem *)DDR_WINDOW_CPU1_BASE;122123for (i = 0, cs = 0; i < 4; i++) {124u32 base = readl(addr + DDR_BASE_CS_OFF(i));125u32 size = readl(addr + DDR_SIZE_CS_OFF(i));126127/*128* Chip select enabled?129*/130if (size & 1) {131struct mbus_dram_window *w;132133w = &mv78xx0_mbus_dram_info.cs[cs++];134w->cs_index = i;135w->mbus_attr = 0xf & ~(1 << i);136w->base = base & 0xffff0000;137w->size = (size | 0x0000ffff) + 1;138}139}140mv78xx0_mbus_dram_info.num_cs = cs;141}142143void __init mv78xx0_setup_pcie_io_win(int window, u32 base, u32 size,144int maj, int min)145{146setup_cpu_win(window, base, size, TARGET_PCIE(maj),147ATTR_PCIE_IO(min), -1);148}149150void __init mv78xx0_setup_pcie_mem_win(int window, u32 base, u32 size,151int maj, int min)152{153setup_cpu_win(window, base, size, TARGET_PCIE(maj),154ATTR_PCIE_MEM(min), -1);155}156157158