Lines Matching full:mbus
39 * - Provides a debugfs interface in /sys/kernel/debug/mvebu-mbus/ to
50 #include <linux/mbus.h>
123 * Used to store the state of one MBus window across suspend/resume.
187 static bool mvebu_mbus_window_is_remappable(struct mvebu_mbus_state *mbus, in mvebu_mbus_window_is_remappable() argument
190 return mbus->soc->win_remap_offset(win) != MVEBU_MBUS_NO_REMAP; in mvebu_mbus_window_is_remappable()
197 static void mvebu_mbus_read_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_read_window() argument
202 void __iomem *addr = mbus->mbuswins_base + in mvebu_mbus_read_window()
203 mbus->soc->win_cfg_offset(win); in mvebu_mbus_read_window()
224 if (mvebu_mbus_window_is_remappable(mbus, win)) { in mvebu_mbus_read_window()
226 void __iomem *addr_rmp = mbus->mbuswins_base + in mvebu_mbus_read_window()
227 mbus->soc->win_remap_offset(win); in mvebu_mbus_read_window()
236 static void mvebu_mbus_disable_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_disable_window() argument
241 addr = mbus->mbuswins_base + mbus->soc->win_cfg_offset(win); in mvebu_mbus_disable_window()
245 if (mvebu_mbus_window_is_remappable(mbus, win)) { in mvebu_mbus_disable_window()
246 addr = mbus->mbuswins_base + mbus->soc->win_remap_offset(win); in mvebu_mbus_disable_window()
254 static int mvebu_mbus_window_is_free(struct mvebu_mbus_state *mbus, in mvebu_mbus_window_is_free() argument
257 void __iomem *addr = mbus->mbuswins_base + in mvebu_mbus_window_is_free()
258 mbus->soc->win_cfg_offset(win); in mvebu_mbus_window_is_free()
268 static int mvebu_mbus_window_conflicts(struct mvebu_mbus_state *mbus, in mvebu_mbus_window_conflicts() argument
275 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_mbus_window_conflicts()
281 mvebu_mbus_read_window(mbus, win, in mvebu_mbus_window_conflicts()
301 static int mvebu_mbus_find_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_find_window() argument
306 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_mbus_find_window()
311 mvebu_mbus_read_window(mbus, win, in mvebu_mbus_find_window()
325 static int mvebu_mbus_setup_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_setup_window() argument
330 void __iomem *addr = mbus->mbuswins_base + in mvebu_mbus_setup_window()
331 mbus->soc->win_cfg_offset(win); in mvebu_mbus_setup_window()
335 WARN(true, "Invalid MBus window size: 0x%zx\n", size); in mvebu_mbus_setup_window()
340 WARN(true, "Invalid MBus base/size: %pa len 0x%zx\n", &base, in mvebu_mbus_setup_window()
349 if (mbus->hw_io_coherency) in mvebu_mbus_setup_window()
355 if (mvebu_mbus_window_is_remappable(mbus, win)) { in mvebu_mbus_setup_window()
356 void __iomem *addr_rmp = mbus->mbuswins_base + in mvebu_mbus_setup_window()
357 mbus->soc->win_remap_offset(win); in mvebu_mbus_setup_window()
370 static int mvebu_mbus_alloc_window(struct mvebu_mbus_state *mbus, in mvebu_mbus_alloc_window() argument
378 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_mbus_alloc_window()
379 if (mvebu_mbus_window_is_remappable(mbus, win)) in mvebu_mbus_alloc_window()
382 if (mvebu_mbus_window_is_free(mbus, win)) in mvebu_mbus_alloc_window()
383 return mvebu_mbus_setup_window(mbus, win, base, in mvebu_mbus_alloc_window()
389 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_mbus_alloc_window()
392 !mvebu_mbus_window_is_remappable(mbus, win)) in mvebu_mbus_alloc_window()
395 if (mvebu_mbus_window_is_free(mbus, win)) in mvebu_mbus_alloc_window()
396 return mvebu_mbus_setup_window(mbus, win, base, size, in mvebu_mbus_alloc_window()
408 static int mvebu_sdram_debug_show_orion(struct mvebu_mbus_state *mbus, in mvebu_sdram_debug_show_orion() argument
414 u32 basereg = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i)); in mvebu_sdram_debug_show_orion()
415 u32 sizereg = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i)); in mvebu_sdram_debug_show_orion()
438 static int mvebu_sdram_debug_show_dove(struct mvebu_mbus_state *mbus, in mvebu_sdram_debug_show_dove() argument
444 u32 map = readl(mbus->sdramwins_base + DOVE_DDR_BASE_CS_OFF(i)); in mvebu_sdram_debug_show_dove()
466 struct mvebu_mbus_state *mbus = &mbus_state; in mvebu_sdram_debug_show() local
467 return mbus->soc->show_cpu_target(mbus, seq, v); in mvebu_sdram_debug_show()
473 struct mvebu_mbus_state *mbus = &mbus_state; in mvebu_devs_debug_show() local
476 for (win = 0; win < mbus->soc->num_wins; win++) { in mvebu_devs_debug_show()
482 mvebu_mbus_read_window(mbus, win, in mvebu_devs_debug_show()
499 if (mvebu_mbus_window_is_remappable(mbus, win)) { in mvebu_devs_debug_show()
582 * Use the memblock information to find the MBus bridge hole in the
594 * care for the MBus bridge hole. in mvebu_mbus_find_bridge_hole()
600 * The MBus bridge hole is at the end of the RAM under in mvebu_mbus_find_bridge_hole()
617 mvebu_mbus_setup_cpu_target_nooverlap(struct mvebu_mbus_state *mbus) in mvebu_mbus_setup_cpu_target_nooverlap() argument
635 * The CS is fully enclosed inside the MBus bridge in mvebu_mbus_setup_cpu_target_nooverlap()
642 * Beginning of CS overlaps with end of MBus, raise CS in mvebu_mbus_setup_cpu_target_nooverlap()
651 * End of CS overlaps with beginning of MBus, shrink in mvebu_mbus_setup_cpu_target_nooverlap()
660 if (mbus->hw_io_coherency) in mvebu_mbus_setup_cpu_target_nooverlap()
671 mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus) in mvebu_mbus_default_setup_cpu_target() argument
679 u32 base = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i)); in mvebu_mbus_default_setup_cpu_target()
680 u32 size = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i)); in mvebu_mbus_default_setup_cpu_target()
695 if (mbus->hw_io_coherency) in mvebu_mbus_default_setup_cpu_target()
705 mvebu_mbus_default_save_cpu_target(struct mvebu_mbus_state *mbus, in mvebu_mbus_default_save_cpu_target() argument
711 u32 base = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i)); in mvebu_mbus_default_save_cpu_target()
712 u32 size = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i)); in mvebu_mbus_default_save_cpu_target()
714 writel(mbus->sdramwins_phys_base + DDR_BASE_CS_OFF(i), in mvebu_mbus_default_save_cpu_target()
717 writel(mbus->sdramwins_phys_base + DDR_SIZE_CS_OFF(i), in mvebu_mbus_default_save_cpu_target()
727 mvebu_mbus_dove_setup_cpu_target(struct mvebu_mbus_state *mbus) in mvebu_mbus_dove_setup_cpu_target() argument
735 u32 map = readl(mbus->sdramwins_base + DOVE_DDR_BASE_CS_OFF(i)); in mvebu_mbus_dove_setup_cpu_target()
757 mvebu_mbus_dove_save_cpu_target(struct mvebu_mbus_state *mbus, in mvebu_mbus_dove_save_cpu_target() argument
763 u32 map = readl(mbus->sdramwins_base + DOVE_DDR_BASE_CS_OFF(i)); in mvebu_mbus_dove_save_cpu_target()
765 writel(mbus->sdramwins_phys_base + DOVE_DDR_BASE_CS_OFF(i), in mvebu_mbus_dove_save_cpu_target()
849 { .compatible = "marvell,armada370-mbus",
851 { .compatible = "marvell,armada375-mbus",
853 { .compatible = "marvell,armada380-mbus",
855 { .compatible = "marvell,armadaxp-mbus",
857 { .compatible = "marvell,kirkwood-mbus",
859 { .compatible = "marvell,dove-mbus",
861 { .compatible = "marvell,orion5x-88f5281-mbus",
863 { .compatible = "marvell,orion5x-88f5182-mbus",
865 { .compatible = "marvell,orion5x-88f5181-mbus",
867 { .compatible = "marvell,orion5x-88f6183-mbus",
869 { .compatible = "marvell,mv78xx0-mbus",
995 s->debugfs_root = debugfs_create_dir("mvebu-mbus", NULL); in mvebu_mbus_debugfs_init()
1077 static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus, in mvebu_mbus_common_init() argument
1088 mbus->mbuswins_base = ioremap(mbuswins_phys_base, mbuswins_size); in mvebu_mbus_common_init()
1089 if (!mbus->mbuswins_base) in mvebu_mbus_common_init()
1092 mbus->sdramwins_base = ioremap(sdramwins_phys_base, sdramwins_size); in mvebu_mbus_common_init()
1093 if (!mbus->sdramwins_base) { in mvebu_mbus_common_init()
1094 iounmap(mbus->mbuswins_base); in mvebu_mbus_common_init()
1098 mbus->sdramwins_phys_base = sdramwins_phys_base; in mvebu_mbus_common_init()
1101 mbus->mbusbridge_base = ioremap(mbusbridge_phys_base, in mvebu_mbus_common_init()
1103 if (!mbus->mbusbridge_base) { in mvebu_mbus_common_init()
1104 iounmap(mbus->sdramwins_base); in mvebu_mbus_common_init()
1105 iounmap(mbus->mbuswins_base); in mvebu_mbus_common_init()
1109 mbus->mbusbridge_base = NULL; in mvebu_mbus_common_init()
1111 for (win = 0; win < mbus->soc->num_wins; win++) in mvebu_mbus_common_init()
1112 mvebu_mbus_disable_window(mbus, win); in mvebu_mbus_common_init()
1114 mbus->soc->setup_cpu_target(mbus); in mvebu_mbus_common_init()
1115 mvebu_mbus_setup_cpu_target_nooverlap(mbus); in mvebu_mbus_common_init()
1119 mbus->mbuswins_base + UNIT_SYNC_BARRIER_OFF); in mvebu_mbus_common_init()
1154 * - bits 28 to 31: MBus custom field
1163 static int __init mbus_dt_setup_win(struct mvebu_mbus_state *mbus, in mbus_dt_setup_win() argument
1167 if (!mvebu_mbus_window_conflicts(mbus, base, size, target, attr)) { in mbus_dt_setup_win()
1173 if (mvebu_mbus_alloc_window(mbus, base, size, MVEBU_MBUS_NO_REMAP, in mbus_dt_setup_win()
1182 static int __init mbus_dt_setup(struct mvebu_mbus_state *mbus, in mbus_dt_setup() argument
1207 ret = mbus_dt_setup_win(mbus, range.cpu_addr, range.size, target, attr); in mbus_dt_setup()
1269 pr_err("could not find an 'mbus-controller' node\n"); in mvebu_mbus_dt_init()
1274 pr_err("cannot get MBUS register address\n"); in mvebu_mbus_dt_init()
1293 pr_warn(FW_WARN "deprecated mbus-mvebu Device Tree, suspend/resume will not work\n"); in mvebu_mbus_dt_init()