Lines Matching full:mbus
42 * - Provides a debugfs interface in /sys/kernel/debug/mvebu-mbus/ to
53 #include <linux/mbus.h>
126 * Used to store the state of one MBus window accross suspend/resume.
190 static bool mvebu_mbus_window_is_remappable(struct mvebu_mbus_state *mbus, in mvebu_mbus_window_is_remappable() argument
193 return mbus->soc->win_remap_offset(win) != MVEBU_MBUS_NO_REMAP; in mvebu_mbus_window_is_remappable()
200 static void mvebu_mbus_read_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_read_window() argument
205 void __iomem *addr = mbus->mbuswins_base + in mvebu_mbus_read_window()
206 mbus->soc->win_cfg_offset(win); in mvebu_mbus_read_window()
227 if (mvebu_mbus_window_is_remappable(mbus, win)) { in mvebu_mbus_read_window()
229 void __iomem *addr_rmp = mbus->mbuswins_base + in mvebu_mbus_read_window()
230 mbus->soc->win_remap_offset(win); in mvebu_mbus_read_window()
239 static void mvebu_mbus_disable_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_disable_window() argument
244 addr = mbus->mbuswins_base + mbus->soc->win_cfg_offset(win); in mvebu_mbus_disable_window()
248 if (mvebu_mbus_window_is_remappable(mbus, win)) { in mvebu_mbus_disable_window()
249 addr = mbus->mbuswins_base + mbus->soc->win_remap_offset(win); in mvebu_mbus_disable_window()
257 static int mvebu_mbus_window_is_free(struct mvebu_mbus_state *mbus, in mvebu_mbus_window_is_free() argument
260 void __iomem *addr = mbus->mbuswins_base + in mvebu_mbus_window_is_free()
261 mbus->soc->win_cfg_offset(win); in mvebu_mbus_window_is_free()
271 static int mvebu_mbus_window_conflicts(struct mvebu_mbus_state *mbus, in mvebu_mbus_window_conflicts() argument
278 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_mbus_window_conflicts()
284 mvebu_mbus_read_window(mbus, win, in mvebu_mbus_window_conflicts()
304 static int mvebu_mbus_find_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_find_window() argument
309 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_mbus_find_window()
314 mvebu_mbus_read_window(mbus, win, in mvebu_mbus_find_window()
328 static int mvebu_mbus_setup_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_setup_window() argument
333 void __iomem *addr = mbus->mbuswins_base + in mvebu_mbus_setup_window()
334 mbus->soc->win_cfg_offset(win); in mvebu_mbus_setup_window()
338 WARN(true, "Invalid MBus window size: 0x%zx\n", size); in mvebu_mbus_setup_window()
343 WARN(true, "Invalid MBus base/size: %pa len 0x%zx\n", &base, in mvebu_mbus_setup_window()
352 if (mbus->hw_io_coherency) in mvebu_mbus_setup_window()
358 if (mvebu_mbus_window_is_remappable(mbus, win)) { in mvebu_mbus_setup_window()
359 void __iomem *addr_rmp = mbus->mbuswins_base + in mvebu_mbus_setup_window()
360 mbus->soc->win_remap_offset(win); in mvebu_mbus_setup_window()
373 static int mvebu_mbus_alloc_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_alloc_window() argument
381 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_mbus_alloc_window()
382 if (mvebu_mbus_window_is_remappable(mbus, win)) in mvebu_mbus_alloc_window()
385 if (mvebu_mbus_window_is_free(mbus, win)) in mvebu_mbus_alloc_window()
386 return mvebu_mbus_setup_window(mbus, win, base, in mvebu_mbus_alloc_window()
392 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_mbus_alloc_window()
395 !mvebu_mbus_window_is_remappable(mbus, win)) in mvebu_mbus_alloc_window()
398 if (mvebu_mbus_window_is_free(mbus, win)) in mvebu_mbus_alloc_window()
399 return mvebu_mbus_setup_window(mbus, win, base, size, in mvebu_mbus_alloc_window()
411 static int mvebu_sdram_debug_show_orion(struct mvebu_mbus_state *mbus, in mvebu_sdram_debug_show_orion() argument
417 u32 basereg = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i)); in mvebu_sdram_debug_show_orion()
418 u32 sizereg = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i)); in mvebu_sdram_debug_show_orion()
441 static int mvebu_sdram_debug_show_dove(struct mvebu_mbus_state *mbus, in mvebu_sdram_debug_show_dove() argument
447 u32 map = readl(mbus->sdramwins_base + DOVE_DDR_BASE_CS_OFF(i)); in mvebu_sdram_debug_show_dove()
469 struct mvebu_mbus_state *mbus = &mbus_state; in mvebu_sdram_debug_show() local
470 return mbus->soc->show_cpu_target(mbus, seq, v); in mvebu_sdram_debug_show()
487 struct mvebu_mbus_state *mbus = &mbus_state; in mvebu_devs_debug_show() local
490 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_devs_debug_show()
496 mvebu_mbus_read_window(mbus, win, in mvebu_devs_debug_show()
513 if (mvebu_mbus_window_is_remappable(mbus, win)) { in mvebu_devs_debug_show()
607 * Use the memblock information to find the MBus bridge hole in the
619 * care for the MBus bridge hole. in mvebu_mbus_find_bridge_hole()
625 * The MBus bridge hole is at the end of the RAM under in mvebu_mbus_find_bridge_hole()
642 mvebu_mbus_setup_cpu_target_nooverlap(struct mvebu_mbus_state *mbus) in mvebu_mbus_setup_cpu_target_nooverlap() argument
660 * The CS is fully enclosed inside the MBus bridge in mvebu_mbus_setup_cpu_target_nooverlap()
667 * Beginning of CS overlaps with end of MBus, raise CS in mvebu_mbus_setup_cpu_target_nooverlap()
676 * End of CS overlaps with beginning of MBus, shrink in mvebu_mbus_setup_cpu_target_nooverlap()
685 if (mbus->hw_io_coherency) in mvebu_mbus_setup_cpu_target_nooverlap()
696 mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus) in mvebu_mbus_default_setup_cpu_target() argument
704 u32 base = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i)); in mvebu_mbus_default_setup_cpu_target()
705 u32 size = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i)); in mvebu_mbus_default_setup_cpu_target()
720 if (mbus->hw_io_coherency) in mvebu_mbus_default_setup_cpu_target()
730 mvebu_mbus_default_save_cpu_target(struct mvebu_mbus_state *mbus, in mvebu_mbus_default_save_cpu_target() argument
736 u32 base = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i)); in mvebu_mbus_default_save_cpu_target()
737 u32 size = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i)); in mvebu_mbus_default_save_cpu_target()
739 writel(mbus->sdramwins_phys_base + DDR_BASE_CS_OFF(i), in mvebu_mbus_default_save_cpu_target()
742 writel(mbus->sdramwins_phys_base + DDR_SIZE_CS_OFF(i), in mvebu_mbus_default_save_cpu_target()
752 mvebu_mbus_dove_setup_cpu_target(struct mvebu_mbus_state *mbus) in mvebu_mbus_dove_setup_cpu_target() argument
760 u32 map = readl(mbus->sdramwins_base + DOVE_DDR_BASE_CS_OFF(i)); in mvebu_mbus_dove_setup_cpu_target()
782 mvebu_mbus_dove_save_cpu_target(struct mvebu_mbus_state *mbus, in mvebu_mbus_dove_save_cpu_target() argument
788 u32 map = readl(mbus->sdramwins_base + DOVE_DDR_BASE_CS_OFF(i)); in mvebu_mbus_dove_save_cpu_target()
790 writel(mbus->sdramwins_phys_base + DOVE_DDR_BASE_CS_OFF(i), in mvebu_mbus_dove_save_cpu_target()
874 { .compatible = "marvell,armada370-mbus",
876 { .compatible = "marvell,armada375-mbus",
878 { .compatible = "marvell,armada380-mbus",
880 { .compatible = "marvell,armadaxp-mbus",
882 { .compatible = "marvell,kirkwood-mbus",
884 { .compatible = "marvell,dove-mbus",
886 { .compatible = "marvell,orion5x-88f5281-mbus",
888 { .compatible = "marvell,orion5x-88f5182-mbus",
890 { .compatible = "marvell,orion5x-88f5181-mbus",
892 { .compatible = "marvell,orion5x-88f6183-mbus",
894 { .compatible = "marvell,mv78xx0-mbus",
1015 s->debugfs_root = debugfs_create_dir("mvebu-mbus", NULL); in mvebu_mbus_debugfs_init()
1097 static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus, in mvebu_mbus_common_init() argument
1108 mbus->mbuswins_base = ioremap(mbuswins_phys_base, mbuswins_size); in mvebu_mbus_common_init()
1109 if (!mbus->mbuswins_base) in mvebu_mbus_common_init()
1112 mbus->sdramwins_base = ioremap(sdramwins_phys_base, sdramwins_size); in mvebu_mbus_common_init()
1113 if (!mbus->sdramwins_base) { in mvebu_mbus_common_init()
1118 mbus->sdramwins_phys_base = sdramwins_phys_base; in mvebu_mbus_common_init()
1121 mbus->mbusbridge_base = ioremap(mbusbridge_phys_base, in mvebu_mbus_common_init()
1123 if (!mbus->mbusbridge_base) { in mvebu_mbus_common_init()
1124 iounmap(mbus->sdramwins_base); in mvebu_mbus_common_init()
1125 iounmap(mbus->mbuswins_base); in mvebu_mbus_common_init()
1129 mbus->mbusbridge_base = NULL; in mvebu_mbus_common_init()
1131 for (win = 0; win < mbus->soc->num_wins; win++) in mvebu_mbus_common_init()
1132 mvebu_mbus_disable_window(mbus, win); in mvebu_mbus_common_init()
1134 mbus->soc->setup_cpu_target(mbus); in mvebu_mbus_common_init()
1135 mvebu_mbus_setup_cpu_target_nooverlap(mbus); in mvebu_mbus_common_init()
1139 mbus->mbuswins_base + UNIT_SYNC_BARRIER_OFF); in mvebu_mbus_common_init()
1174 * - bits 28 to 31: MBus custom field
1183 static int __init mbus_dt_setup_win(struct mvebu_mbus_state *mbus, in mbus_dt_setup_win() argument
1187 if (!mvebu_mbus_window_conflicts(mbus, base, size, target, attr)) { in mbus_dt_setup_win()
1193 if (mvebu_mbus_alloc_window(mbus, base, size, MVEBU_MBUS_NO_REMAP, in mbus_dt_setup_win()
1238 static int __init mbus_dt_setup(struct mvebu_mbus_state *mbus, in mbus_dt_setup() argument
1269 ret = mbus_dt_setup_win(mbus, base, size, target, attr); in mbus_dt_setup()
1331 pr_err("could not find an 'mbus-controller' node\n"); in mvebu_mbus_dt_init()
1336 pr_err("cannot get MBUS register address\n"); in mvebu_mbus_dt_init()
1355 pr_warn(FW_WARN "deprecated mbus-mvebu Device Tree, suspend/resume will not work\n"); in mvebu_mbus_dt_init()