Lines Matching full:mc

13 #include <dt-bindings/memory/tegra20-mc.h>
15 #include "mc.h"
74 const struct tegra_mc *mc; member
278 static int tegra20_mc_hotreset_assert(struct tegra_mc *mc, in tegra20_mc_hotreset_assert() argument
284 spin_lock_irqsave(&mc->lock, flags); in tegra20_mc_hotreset_assert()
286 value = mc_readl(mc, rst->reset); in tegra20_mc_hotreset_assert()
287 mc_writel(mc, value & ~BIT(rst->bit), rst->reset); in tegra20_mc_hotreset_assert()
289 spin_unlock_irqrestore(&mc->lock, flags); in tegra20_mc_hotreset_assert()
294 static int tegra20_mc_hotreset_deassert(struct tegra_mc *mc, in tegra20_mc_hotreset_deassert() argument
300 spin_lock_irqsave(&mc->lock, flags); in tegra20_mc_hotreset_deassert()
302 value = mc_readl(mc, rst->reset); in tegra20_mc_hotreset_deassert()
303 mc_writel(mc, value | BIT(rst->bit), rst->reset); in tegra20_mc_hotreset_deassert()
305 spin_unlock_irqrestore(&mc->lock, flags); in tegra20_mc_hotreset_deassert()
310 static int tegra20_mc_block_dma(struct tegra_mc *mc, in tegra20_mc_block_dma() argument
316 spin_lock_irqsave(&mc->lock, flags); in tegra20_mc_block_dma()
318 value = mc_readl(mc, rst->control) & ~BIT(rst->bit); in tegra20_mc_block_dma()
319 mc_writel(mc, value, rst->control); in tegra20_mc_block_dma()
321 spin_unlock_irqrestore(&mc->lock, flags); in tegra20_mc_block_dma()
326 static bool tegra20_mc_dma_idling(struct tegra_mc *mc, in tegra20_mc_dma_idling() argument
329 return mc_readl(mc, rst->status) == 0; in tegra20_mc_dma_idling()
332 static int tegra20_mc_reset_status(struct tegra_mc *mc, in tegra20_mc_reset_status() argument
335 return (mc_readl(mc, rst->reset) & BIT(rst->bit)) == 0; in tegra20_mc_reset_status()
338 static int tegra20_mc_unblock_dma(struct tegra_mc *mc, in tegra20_mc_unblock_dma() argument
344 spin_lock_irqsave(&mc->lock, flags); in tegra20_mc_unblock_dma()
346 value = mc_readl(mc, rst->control) | BIT(rst->bit); in tegra20_mc_unblock_dma()
347 mc_writel(mc, value, rst->control); in tegra20_mc_unblock_dma()
349 spin_unlock_irqrestore(&mc->lock, flags); in tegra20_mc_unblock_dma()
394 struct tegra_mc *mc = icc_provider_to_tegra_mc(data); in tegra20_mc_of_icc_xlate_extended() local
399 list_for_each_entry(node, &mc->provider.nodes, node_list) { in tegra20_mc_of_icc_xlate_extended()
419 for (i = 0; i < mc->soc->num_clients; i++) { in tegra20_mc_of_icc_xlate_extended()
420 if (mc->soc->clients[i].id == idx) in tegra20_mc_of_icc_xlate_extended()
424 dev_err(mc->dev, "invalid ICC client ID %u\n", idx); in tegra20_mc_of_icc_xlate_extended()
451 const struct tegra_mc *mc = stat->mc; in tegra20_mc_stat_gather() local
460 mc_writel(mc, 0x00000000, MC_STAT_CONTROL); in tegra20_mc_stat_gather()
461 mc_writel(mc, control_0, MC_STAT_EMC_CONTROL_0); in tegra20_mc_stat_gather()
462 mc_writel(mc, control_1, MC_STAT_EMC_CONTROL_1); in tegra20_mc_stat_gather()
463 mc_writel(mc, 0xffffffff, MC_STAT_EMC_CLOCK_LIMIT); in tegra20_mc_stat_gather()
465 mc_writel(mc, EMC_GATHER_ENABLE, MC_STAT_CONTROL); in tegra20_mc_stat_gather()
467 mc_writel(mc, EMC_GATHER_DISABLE, MC_STAT_CONTROL); in tegra20_mc_stat_gather()
469 count0 = mc_readl(mc, MC_STAT_EMC_COUNT_0); in tegra20_mc_stat_gather()
470 count1 = mc_readl(mc, MC_STAT_EMC_COUNT_1); in tegra20_mc_stat_gather()
471 clocks = mc_readl(mc, MC_STAT_EMC_CLOCKS); in tegra20_mc_stat_gather()
478 static void tegra20_mc_stat_events(const struct tegra_mc *mc, in tegra20_mc_stat_events() argument
502 stat.mc = mc; in tegra20_mc_stat_events()
510 static void tegra20_mc_collect_stats(const struct tegra_mc *mc, in tegra20_mc_collect_stats() argument
517 for (i = 0; i < mc->soc->num_clients; i += 2) { in tegra20_mc_collect_stats()
518 client0 = &mc->soc->clients[i]; in tegra20_mc_collect_stats()
519 client1 = &mc->soc->clients[i + 1]; in tegra20_mc_collect_stats()
521 if (i + 1 == mc->soc->num_clients) in tegra20_mc_collect_stats()
524 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
533 for (i = 0; i < mc->soc->num_clients; i++) { in tegra20_mc_collect_stats()
534 unsigned int clienta, clientb = mc->soc->num_clients; in tegra20_mc_collect_stats()
536 for (client0 = NULL; i < mc->soc->num_clients; i++) { in tegra20_mc_collect_stats()
538 client0 = &mc->soc->clients[i]; in tegra20_mc_collect_stats()
544 for (client1 = NULL; i < mc->soc->num_clients; i++) { in tegra20_mc_collect_stats()
546 client1 = &mc->soc->clients[i]; in tegra20_mc_collect_stats()
555 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
562 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
569 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
576 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
583 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
590 tegra20_mc_stat_events(mc, client0, client1, in tegra20_mc_collect_stats()
613 const struct tegra_mc *mc = dev_get_drvdata(s->private); in tegra20_mc_stats_show() local
617 stats = kcalloc(mc->soc->num_clients + 1, sizeof(*stats), GFP_KERNEL); in tegra20_mc_stats_show()
623 tegra20_mc_collect_stats(mc, stats); in tegra20_mc_stats_show()
630 for (i = 0; i < mc->soc->num_clients; i++) { in tegra20_mc_stats_show()
631 seq_printf(s, "%-14s ", mc->soc->clients[i].name); in tegra20_mc_stats_show()
682 static int tegra20_mc_probe(struct tegra_mc *mc) in tegra20_mc_probe() argument
684 debugfs_create_devm_seqfile(mc->dev, "stats", mc->debugfs.root, in tegra20_mc_probe()
690 static int tegra20_mc_suspend(struct tegra_mc *mc) in tegra20_mc_suspend() argument
694 if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) { in tegra20_mc_suspend()
695 err = tegra_gart_suspend(mc->gart); in tegra20_mc_suspend()
703 static int tegra20_mc_resume(struct tegra_mc *mc) in tegra20_mc_resume() argument
707 if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) { in tegra20_mc_resume()
708 err = tegra_gart_resume(mc->gart); in tegra20_mc_resume()
718 struct tegra_mc *mc = data; in tegra20_mc_handle_irq() local
723 status = mc_readl(mc, MC_INTSTATUS) & mc->soc->intmask; in tegra20_mc_handle_irq()
738 value = mc_readl(mc, reg); in tegra20_mc_handle_irq()
740 id = value & mc->soc->client_id_mask; in tegra20_mc_handle_irq()
749 value = mc_readl(mc, reg); in tegra20_mc_handle_irq()
751 id = (value >> 1) & mc->soc->client_id_mask; in tegra20_mc_handle_irq()
760 value = mc_readl(mc, reg); in tegra20_mc_handle_irq()
762 id = value & mc->soc->client_id_mask; in tegra20_mc_handle_irq()
775 client = mc->soc->clients[id].name; in tegra20_mc_handle_irq()
776 addr = mc_readl(mc, reg + sizeof(u32)); in tegra20_mc_handle_irq()
778 dev_err_ratelimited(mc->dev, "%s: %s%s @%pa: %s (%s)\n", in tegra20_mc_handle_irq()
784 mc_writel(mc, status, MC_INTSTATUS); in tegra20_mc_handle_irq()