Lines Matching full:mc
14 #include <dt-bindings/memory/tegra20-mc.h>
16 #include "mc.h"
75 const struct tegra_mc *mc; member
279 static int tegra20_mc_hotreset_assert(struct tegra_mc *mc, in tegra20_mc_hotreset_assert() argument
285 spin_lock_irqsave(&mc->lock, flags); in tegra20_mc_hotreset_assert()
287 value = mc_readl(mc, rst->reset); in tegra20_mc_hotreset_assert()
288 mc_writel(mc, value & ~BIT(rst->bit), rst->reset); in tegra20_mc_hotreset_assert()
290 spin_unlock_irqrestore(&mc->lock, flags); in tegra20_mc_hotreset_assert()
295 static int tegra20_mc_hotreset_deassert(struct tegra_mc *mc, in tegra20_mc_hotreset_deassert() argument
301 spin_lock_irqsave(&mc->lock, flags); in tegra20_mc_hotreset_deassert()
303 value = mc_readl(mc, rst->reset); in tegra20_mc_hotreset_deassert()
304 mc_writel(mc, value | BIT(rst->bit), rst->reset); in tegra20_mc_hotreset_deassert()
306 spin_unlock_irqrestore(&mc->lock, flags); in tegra20_mc_hotreset_deassert()
311 static int tegra20_mc_block_dma(struct tegra_mc *mc, in tegra20_mc_block_dma() argument
317 spin_lock_irqsave(&mc->lock, flags); in tegra20_mc_block_dma()
319 value = mc_readl(mc, rst->control) & ~BIT(rst->bit); in tegra20_mc_block_dma()
320 mc_writel(mc, value, rst->control); in tegra20_mc_block_dma()
322 spin_unlock_irqrestore(&mc->lock, flags); in tegra20_mc_block_dma()
327 static bool tegra20_mc_dma_idling(struct tegra_mc *mc, in tegra20_mc_dma_idling() argument
330 return mc_readl(mc, rst->status) == 0; in tegra20_mc_dma_idling()
333 static int tegra20_mc_reset_status(struct tegra_mc *mc, in tegra20_mc_reset_status() argument
336 return (mc_readl(mc, rst->reset) & BIT(rst->bit)) == 0; in tegra20_mc_reset_status()
339 static int tegra20_mc_unblock_dma(struct tegra_mc *mc, in tegra20_mc_unblock_dma() argument
345 spin_lock_irqsave(&mc->lock, flags); in tegra20_mc_unblock_dma()
347 value = mc_readl(mc, rst->control) | BIT(rst->bit); in tegra20_mc_unblock_dma()
348 mc_writel(mc, value, rst->control); in tegra20_mc_unblock_dma()
350 spin_unlock_irqrestore(&mc->lock, flags); in tegra20_mc_unblock_dma()
395 struct tegra_mc *mc = icc_provider_to_tegra_mc(data); in tegra20_mc_of_icc_xlate_extended() local
400 list_for_each_entry(node, &mc->provider.nodes, node_list) { in tegra20_mc_of_icc_xlate_extended()
420 for (i = 0; i < mc->soc->num_clients; i++) { in tegra20_mc_of_icc_xlate_extended()
421 if (mc->soc->clients[i].id == idx) in tegra20_mc_of_icc_xlate_extended()
425 dev_err(mc->dev, "invalid ICC client ID %u\n", idx); in tegra20_mc_of_icc_xlate_extended()
452 const struct tegra_mc *mc = stat->mc; in tegra20_mc_stat_gather() local
461 mc_writel(mc, 0x00000000, MC_STAT_CONTROL); in tegra20_mc_stat_gather()
462 mc_writel(mc, control_0, MC_STAT_EMC_CONTROL_0); in tegra20_mc_stat_gather()
463 mc_writel(mc, control_1, MC_STAT_EMC_CONTROL_1); in tegra20_mc_stat_gather()
464 mc_writel(mc, 0xffffffff, MC_STAT_EMC_CLOCK_LIMIT); in tegra20_mc_stat_gather()
466 mc_writel(mc, EMC_GATHER_ENABLE, MC_STAT_CONTROL); in tegra20_mc_stat_gather()
468 mc_writel(mc, EMC_GATHER_DISABLE, MC_STAT_CONTROL); in tegra20_mc_stat_gather()
470 count0 = mc_readl(mc, MC_STAT_EMC_COUNT_0); in tegra20_mc_stat_gather()
471 count1 = mc_readl(mc, MC_STAT_EMC_COUNT_1); in tegra20_mc_stat_gather()
472 clocks = mc_readl(mc, MC_STAT_EMC_CLOCKS); in tegra20_mc_stat_gather()
479 static void tegra20_mc_stat_events(const struct tegra_mc *mc, in tegra20_mc_stat_events() argument
503 stat.mc = mc; in tegra20_mc_stat_events()
511 static void tegra20_mc_collect_stats(const struct tegra_mc *mc, in tegra20_mc_collect_stats() argument
518 for (i = 0; i < mc->soc->num_clients; i += 2) { in tegra20_mc_collect_stats()
519 client0 = &mc->soc->clients[i]; in tegra20_mc_collect_stats()
520 client1 = &mc->soc->clients[i + 1]; in tegra20_mc_collect_stats()
522 if (i + 1 == mc->soc->num_clients) in tegra20_mc_collect_stats()
525 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
534 for (i = 0; i < mc->soc->num_clients; i++) { in tegra20_mc_collect_stats()
535 unsigned int clienta, clientb = mc->soc->num_clients; in tegra20_mc_collect_stats()
537 for (client0 = NULL; i < mc->soc->num_clients; i++) { in tegra20_mc_collect_stats()
539 client0 = &mc->soc->clients[i]; in tegra20_mc_collect_stats()
545 for (client1 = NULL; i < mc->soc->num_clients; i++) { in tegra20_mc_collect_stats()
547 client1 = &mc->soc->clients[i]; in tegra20_mc_collect_stats()
556 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
563 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
570 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
577 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
584 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
591 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
614 const struct tegra_mc *mc = dev_get_drvdata(s->private); in tegra20_mc_stats_show() local
618 stats = kcalloc(mc->soc->num_clients + 1, sizeof(*stats), GFP_KERNEL); in tegra20_mc_stats_show()
624 tegra20_mc_collect_stats(mc, stats); in tegra20_mc_stats_show()
631 for (i = 0; i < mc->soc->num_clients; i++) { in tegra20_mc_stats_show()
632 seq_printf(s, "%-14s ", mc->soc->clients[i].name); in tegra20_mc_stats_show()
683 static int tegra20_mc_probe(struct tegra_mc *mc) in tegra20_mc_probe() argument
685 debugfs_create_devm_seqfile(mc->dev, "stats", mc->debugfs.root, in tegra20_mc_probe()
691 static int tegra20_mc_suspend(struct tegra_mc *mc) in tegra20_mc_suspend() argument
695 if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) { in tegra20_mc_suspend()
696 err = tegra_gart_suspend(mc->gart); in tegra20_mc_suspend()
704 static int tegra20_mc_resume(struct tegra_mc *mc) in tegra20_mc_resume() argument
708 if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) { in tegra20_mc_resume()
709 err = tegra_gart_resume(mc->gart); in tegra20_mc_resume()
719 struct tegra_mc *mc = data; in tegra20_mc_handle_irq() local
724 status = mc_readl(mc, MC_INTSTATUS) & mc->soc->intmask; in tegra20_mc_handle_irq()
739 value = mc_readl(mc, reg); in tegra20_mc_handle_irq()
741 id = value & mc->soc->client_id_mask; in tegra20_mc_handle_irq()
750 value = mc_readl(mc, reg); in tegra20_mc_handle_irq()
752 id = (value >> 1) & mc->soc->client_id_mask; in tegra20_mc_handle_irq()
761 value = mc_readl(mc, reg); in tegra20_mc_handle_irq()
763 id = value & mc->soc->client_id_mask; in tegra20_mc_handle_irq()
776 client = mc->soc->clients[id].name; in tegra20_mc_handle_irq()
777 addr = mc_readl(mc, reg + sizeof(u32)); in tegra20_mc_handle_irq()
779 dev_err_ratelimited(mc->dev, "%s: %s%s @%pa: %s (%s)\n", in tegra20_mc_handle_irq()
785 mc_writel(mc, status, MC_INTSTATUS); in tegra20_mc_handle_irq()