1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2014 NVIDIA CORPORATION. All rights reserved.
7 #include <linux/delay.h>
8 #include <linux/dma-mapping.h>
9 #include <linux/export.h>
10 #include <linux/interrupt.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
14 #include <linux/of_device.h>
15 #include <linux/platform_device.h>
16 #include <linux/slab.h>
17 #include <linux/sort.h>
19 #include <soc/tegra/fuse.h>
23 static const struct of_device_id tegra_mc_of_match[] = {
24 #ifdef CONFIG_ARCH_TEGRA_2x_SOC
25 { .compatible = "nvidia,tegra20-mc-gart", .data = &tegra20_mc_soc },
27 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
28 { .compatible = "nvidia,tegra30-mc", .data = &tegra30_mc_soc },
30 #ifdef CONFIG_ARCH_TEGRA_114_SOC
31 { .compatible = "nvidia,tegra114-mc", .data = &tegra114_mc_soc },
33 #ifdef CONFIG_ARCH_TEGRA_124_SOC
34 { .compatible = "nvidia,tegra124-mc", .data = &tegra124_mc_soc },
36 #ifdef CONFIG_ARCH_TEGRA_132_SOC
37 { .compatible = "nvidia,tegra132-mc", .data = &tegra132_mc_soc },
39 #ifdef CONFIG_ARCH_TEGRA_210_SOC
40 { .compatible = "nvidia,tegra210-mc", .data = &tegra210_mc_soc },
42 #ifdef CONFIG_ARCH_TEGRA_186_SOC
43 { .compatible = "nvidia,tegra186-mc", .data = &tegra186_mc_soc },
45 #ifdef CONFIG_ARCH_TEGRA_194_SOC
46 { .compatible = "nvidia,tegra194-mc", .data = &tegra194_mc_soc },
48 #ifdef CONFIG_ARCH_TEGRA_234_SOC
49 { .compatible = "nvidia,tegra234-mc", .data = &tegra234_mc_soc },
53 MODULE_DEVICE_TABLE(of, tegra_mc_of_match);
55 static void tegra_mc_devm_action_put_device(void *data)
57 struct tegra_mc *mc = data;
63 * devm_tegra_memory_controller_get() - get Tegra Memory Controller handle
64 * @dev: device pointer for the consumer device
66 * This function will search for the Memory Controller node in a device-tree
67 * and retrieve the Memory Controller handle.
69 * Return: ERR_PTR() on error or a valid pointer to a struct tegra_mc.
71 struct tegra_mc *devm_tegra_memory_controller_get(struct device *dev)
73 struct platform_device *pdev;
74 struct device_node *np;
78 np = of_parse_phandle(dev->of_node, "nvidia,memory-controller", 0);
80 return ERR_PTR(-ENOENT);
82 pdev = of_find_device_by_node(np);
85 return ERR_PTR(-ENODEV);
87 mc = platform_get_drvdata(pdev);
89 put_device(&pdev->dev);
90 return ERR_PTR(-EPROBE_DEFER);
93 err = devm_add_action_or_reset(dev, tegra_mc_devm_action_put_device, mc);
99 EXPORT_SYMBOL_GPL(devm_tegra_memory_controller_get);
101 int tegra_mc_probe_device(struct tegra_mc *mc, struct device *dev)
103 if (mc->soc->ops && mc->soc->ops->probe_device)
104 return mc->soc->ops->probe_device(mc, dev);
108 EXPORT_SYMBOL_GPL(tegra_mc_probe_device);
110 int tegra_mc_get_carveout_info(struct tegra_mc *mc, unsigned int id,
111 phys_addr_t *base, u64 *size)
115 if (id < 1 || id >= mc->soc->num_carveouts)
119 offset = 0xc0c + 0x50 * (id - 1);
121 offset = 0x2004 + 0x50 * (id - 6);
123 *base = mc_ch_readl(mc, MC_BROADCAST_CHANNEL, offset + 0x0);
124 #ifdef CONFIG_PHYS_ADDR_T_64BIT
125 *base |= (phys_addr_t)mc_ch_readl(mc, MC_BROADCAST_CHANNEL, offset + 0x4) << 32;
129 *size = mc_ch_readl(mc, MC_BROADCAST_CHANNEL, offset + 0x8) << 17;
133 EXPORT_SYMBOL_GPL(tegra_mc_get_carveout_info);
135 static int tegra_mc_block_dma_common(struct tegra_mc *mc,
136 const struct tegra_mc_reset *rst)
141 spin_lock_irqsave(&mc->lock, flags);
143 value = mc_readl(mc, rst->control) | BIT(rst->bit);
144 mc_writel(mc, value, rst->control);
146 spin_unlock_irqrestore(&mc->lock, flags);
151 static bool tegra_mc_dma_idling_common(struct tegra_mc *mc,
152 const struct tegra_mc_reset *rst)
154 return (mc_readl(mc, rst->status) & BIT(rst->bit)) != 0;
157 static int tegra_mc_unblock_dma_common(struct tegra_mc *mc,
158 const struct tegra_mc_reset *rst)
163 spin_lock_irqsave(&mc->lock, flags);
165 value = mc_readl(mc, rst->control) & ~BIT(rst->bit);
166 mc_writel(mc, value, rst->control);
168 spin_unlock_irqrestore(&mc->lock, flags);
173 static int tegra_mc_reset_status_common(struct tegra_mc *mc,
174 const struct tegra_mc_reset *rst)
176 return (mc_readl(mc, rst->control) & BIT(rst->bit)) != 0;
179 const struct tegra_mc_reset_ops tegra_mc_reset_ops_common = {
180 .block_dma = tegra_mc_block_dma_common,
181 .dma_idling = tegra_mc_dma_idling_common,
182 .unblock_dma = tegra_mc_unblock_dma_common,
183 .reset_status = tegra_mc_reset_status_common,
186 static inline struct tegra_mc *reset_to_mc(struct reset_controller_dev *rcdev)
188 return container_of(rcdev, struct tegra_mc, reset);
191 static const struct tegra_mc_reset *tegra_mc_reset_find(struct tegra_mc *mc,
196 for (i = 0; i < mc->soc->num_resets; i++)
197 if (mc->soc->resets[i].id == id)
198 return &mc->soc->resets[i];
203 static int tegra_mc_hotreset_assert(struct reset_controller_dev *rcdev,
206 struct tegra_mc *mc = reset_to_mc(rcdev);
207 const struct tegra_mc_reset_ops *rst_ops;
208 const struct tegra_mc_reset *rst;
212 rst = tegra_mc_reset_find(mc, id);
216 rst_ops = mc->soc->reset_ops;
220 /* DMA flushing will fail if reset is already asserted */
221 if (rst_ops->reset_status) {
222 /* check whether reset is asserted */
223 if (rst_ops->reset_status(mc, rst))
227 if (rst_ops->block_dma) {
228 /* block clients DMA requests */
229 err = rst_ops->block_dma(mc, rst);
231 dev_err(mc->dev, "failed to block %s DMA: %d\n",
237 if (rst_ops->dma_idling) {
238 /* wait for completion of the outstanding DMA requests */
239 while (!rst_ops->dma_idling(mc, rst)) {
241 dev_err(mc->dev, "failed to flush %s DMA\n",
246 usleep_range(10, 100);
250 if (rst_ops->hotreset_assert) {
251 /* clear clients DMA requests sitting before arbitration */
252 err = rst_ops->hotreset_assert(mc, rst);
254 dev_err(mc->dev, "failed to hot reset %s: %d\n",
263 static int tegra_mc_hotreset_deassert(struct reset_controller_dev *rcdev,
266 struct tegra_mc *mc = reset_to_mc(rcdev);
267 const struct tegra_mc_reset_ops *rst_ops;
268 const struct tegra_mc_reset *rst;
271 rst = tegra_mc_reset_find(mc, id);
275 rst_ops = mc->soc->reset_ops;
279 if (rst_ops->hotreset_deassert) {
280 /* take out client from hot reset */
281 err = rst_ops->hotreset_deassert(mc, rst);
283 dev_err(mc->dev, "failed to deassert hot reset %s: %d\n",
289 if (rst_ops->unblock_dma) {
290 /* allow new DMA requests to proceed to arbitration */
291 err = rst_ops->unblock_dma(mc, rst);
293 dev_err(mc->dev, "failed to unblock %s DMA : %d\n",
302 static int tegra_mc_hotreset_status(struct reset_controller_dev *rcdev,
305 struct tegra_mc *mc = reset_to_mc(rcdev);
306 const struct tegra_mc_reset_ops *rst_ops;
307 const struct tegra_mc_reset *rst;
309 rst = tegra_mc_reset_find(mc, id);
313 rst_ops = mc->soc->reset_ops;
317 return rst_ops->reset_status(mc, rst);
320 static const struct reset_control_ops tegra_mc_reset_ops = {
321 .assert = tegra_mc_hotreset_assert,
322 .deassert = tegra_mc_hotreset_deassert,
323 .status = tegra_mc_hotreset_status,
326 static int tegra_mc_reset_setup(struct tegra_mc *mc)
330 mc->reset.ops = &tegra_mc_reset_ops;
331 mc->reset.owner = THIS_MODULE;
332 mc->reset.of_node = mc->dev->of_node;
333 mc->reset.of_reset_n_cells = 1;
334 mc->reset.nr_resets = mc->soc->num_resets;
336 err = reset_controller_register(&mc->reset);
343 int tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate)
346 struct tegra_mc_timing *timing = NULL;
348 for (i = 0; i < mc->num_timings; i++) {
349 if (mc->timings[i].rate == rate) {
350 timing = &mc->timings[i];
356 dev_err(mc->dev, "no memory timing registered for rate %lu\n",
361 for (i = 0; i < mc->soc->num_emem_regs; ++i)
362 mc_writel(mc, timing->emem_data[i], mc->soc->emem_regs[i]);
366 EXPORT_SYMBOL_GPL(tegra_mc_write_emem_configuration);
368 unsigned int tegra_mc_get_emem_device_count(struct tegra_mc *mc)
372 dram_count = mc_readl(mc, MC_EMEM_ADR_CFG);
373 dram_count &= MC_EMEM_ADR_CFG_EMEM_NUMDEV;
378 EXPORT_SYMBOL_GPL(tegra_mc_get_emem_device_count);
380 #if defined(CONFIG_ARCH_TEGRA_3x_SOC) || \
381 defined(CONFIG_ARCH_TEGRA_114_SOC) || \
382 defined(CONFIG_ARCH_TEGRA_124_SOC) || \
383 defined(CONFIG_ARCH_TEGRA_132_SOC) || \
384 defined(CONFIG_ARCH_TEGRA_210_SOC)
385 static int tegra_mc_setup_latency_allowance(struct tegra_mc *mc)
387 unsigned long long tick;
391 /* compute the number of MC clock cycles per tick */
392 tick = (unsigned long long)mc->tick * clk_get_rate(mc->clk);
393 do_div(tick, NSEC_PER_SEC);
395 value = mc_readl(mc, MC_EMEM_ARB_CFG);
396 value &= ~MC_EMEM_ARB_CFG_CYCLES_PER_UPDATE_MASK;
397 value |= MC_EMEM_ARB_CFG_CYCLES_PER_UPDATE(tick);
398 mc_writel(mc, value, MC_EMEM_ARB_CFG);
400 /* write latency allowance defaults */
401 for (i = 0; i < mc->soc->num_clients; i++) {
402 const struct tegra_mc_client *client = &mc->soc->clients[i];
405 value = mc_readl(mc, client->regs.la.reg);
406 value &= ~(client->regs.la.mask << client->regs.la.shift);
407 value |= (client->regs.la.def & client->regs.la.mask) << client->regs.la.shift;
408 mc_writel(mc, value, client->regs.la.reg);
411 /* latch new values */
412 mc_writel(mc, MC_TIMING_UPDATE, MC_TIMING_CONTROL);
417 static int load_one_timing(struct tegra_mc *mc,
418 struct tegra_mc_timing *timing,
419 struct device_node *node)
424 err = of_property_read_u32(node, "clock-frequency", &tmp);
427 "timing %pOFn: failed to read rate\n", node);
432 timing->emem_data = devm_kcalloc(mc->dev, mc->soc->num_emem_regs,
433 sizeof(u32), GFP_KERNEL);
434 if (!timing->emem_data)
437 err = of_property_read_u32_array(node, "nvidia,emem-configuration",
439 mc->soc->num_emem_regs);
442 "timing %pOFn: failed to read EMEM configuration\n",
450 static int load_timings(struct tegra_mc *mc, struct device_node *node)
452 struct device_node *child;
453 struct tegra_mc_timing *timing;
454 int child_count = of_get_child_count(node);
457 mc->timings = devm_kcalloc(mc->dev, child_count, sizeof(*timing),
462 mc->num_timings = child_count;
464 for_each_child_of_node(node, child) {
465 timing = &mc->timings[i++];
467 err = load_one_timing(mc, timing, child);
477 static int tegra_mc_setup_timings(struct tegra_mc *mc)
479 struct device_node *node;
480 u32 ram_code, node_ram_code;
483 ram_code = tegra_read_ram_code();
487 for_each_child_of_node(mc->dev->of_node, node) {
488 err = of_property_read_u32(node, "nvidia,ram-code",
490 if (err || (node_ram_code != ram_code))
493 err = load_timings(mc, node);
500 if (mc->num_timings == 0)
502 "no memory timings for RAM code %u registered\n",
508 int tegra30_mc_probe(struct tegra_mc *mc)
512 mc->clk = devm_clk_get_optional(mc->dev, "mc");
513 if (IS_ERR(mc->clk)) {
514 dev_err(mc->dev, "failed to get MC clock: %ld\n", PTR_ERR(mc->clk));
515 return PTR_ERR(mc->clk);
518 /* ensure that debug features are disabled */
519 mc_writel(mc, 0x00000000, MC_TIMING_CONTROL_DBG);
521 err = tegra_mc_setup_latency_allowance(mc);
523 dev_err(mc->dev, "failed to setup latency allowance: %d\n", err);
527 err = tegra_mc_setup_timings(mc);
529 dev_err(mc->dev, "failed to setup timings: %d\n", err);
536 const struct tegra_mc_ops tegra30_mc_ops = {
537 .probe = tegra30_mc_probe,
538 .handle_irq = tegra30_mc_handle_irq,
542 static int mc_global_intstatus_to_channel(const struct tegra_mc *mc, u32 status,
543 unsigned int *mc_channel)
545 if ((status & mc->soc->ch_intmask) == 0)
548 *mc_channel = __ffs((status & mc->soc->ch_intmask) >>
549 mc->soc->global_intstatus_channel_shift);
554 static u32 mc_channel_to_global_intstatus(const struct tegra_mc *mc,
555 unsigned int channel)
557 return BIT(channel) << mc->soc->global_intstatus_channel_shift;
560 irqreturn_t tegra30_mc_handle_irq(int irq, void *data)
562 struct tegra_mc *mc = data;
563 unsigned int bit, channel;
564 unsigned long status;
566 if (mc->soc->num_channels) {
570 global_status = mc_ch_readl(mc, MC_BROADCAST_CHANNEL, MC_GLOBAL_INTSTATUS);
571 err = mc_global_intstatus_to_channel(mc, global_status, &channel);
573 dev_err_ratelimited(mc->dev, "unknown interrupt channel 0x%08x\n",
578 /* mask all interrupts to avoid flooding */
579 status = mc_ch_readl(mc, channel, MC_INTSTATUS) & mc->soc->intmask;
581 status = mc_readl(mc, MC_INTSTATUS) & mc->soc->intmask;
587 for_each_set_bit(bit, &status, 32) {
588 const char *error = tegra_mc_status_names[bit] ?: "unknown";
589 const char *client = "unknown", *desc;
590 const char *direction, *secure;
591 u32 status_reg, addr_reg;
592 u32 intmask = BIT(bit);
593 phys_addr_t addr = 0;
594 #ifdef CONFIG_PHYS_ADDR_T_64BIT
603 case MC_INT_DECERR_VPR:
604 status_reg = MC_ERR_VPR_STATUS;
605 addr_reg = MC_ERR_VPR_ADR;
608 case MC_INT_SECERR_SEC:
609 status_reg = MC_ERR_SEC_STATUS;
610 addr_reg = MC_ERR_SEC_ADR;
613 case MC_INT_DECERR_MTS:
614 status_reg = MC_ERR_MTS_STATUS;
615 addr_reg = MC_ERR_MTS_ADR;
618 case MC_INT_DECERR_GENERALIZED_CARVEOUT:
619 status_reg = MC_ERR_GENERALIZED_CARVEOUT_STATUS;
620 addr_reg = MC_ERR_GENERALIZED_CARVEOUT_ADR;
623 case MC_INT_DECERR_ROUTE_SANITY:
624 status_reg = MC_ERR_ROUTE_SANITY_STATUS;
625 addr_reg = MC_ERR_ROUTE_SANITY_ADR;
629 status_reg = MC_ERR_STATUS;
630 addr_reg = MC_ERR_ADR;
632 #ifdef CONFIG_PHYS_ADDR_T_64BIT
633 if (mc->soc->has_addr_hi_reg)
634 addr_hi_reg = MC_ERR_ADR_HI;
639 if (mc->soc->num_channels)
640 value = mc_ch_readl(mc, channel, status_reg);
642 value = mc_readl(mc, status_reg);
644 #ifdef CONFIG_PHYS_ADDR_T_64BIT
645 if (mc->soc->num_address_bits > 32) {
647 if (mc->soc->num_channels)
648 addr = mc_ch_readl(mc, channel, addr_hi_reg);
650 addr = mc_readl(mc, addr_hi_reg);
652 addr = ((value >> MC_ERR_STATUS_ADR_HI_SHIFT) &
653 MC_ERR_STATUS_ADR_HI_MASK);
659 if (value & MC_ERR_STATUS_RW)
664 if (value & MC_ERR_STATUS_SECURITY)
669 id = value & mc->soc->client_id_mask;
671 for (i = 0; i < mc->soc->num_clients; i++) {
672 if (mc->soc->clients[i].id == id) {
673 client = mc->soc->clients[i].name;
678 type = (value & MC_ERR_STATUS_TYPE_MASK) >>
679 MC_ERR_STATUS_TYPE_SHIFT;
680 desc = tegra_mc_error_names[type];
682 switch (value & MC_ERR_STATUS_TYPE_MASK) {
683 case MC_ERR_STATUS_TYPE_INVALID_SMMU_PAGE:
687 if (value & MC_ERR_STATUS_READABLE)
692 if (value & MC_ERR_STATUS_WRITABLE)
697 if (value & MC_ERR_STATUS_NONSECURE)
711 if (mc->soc->num_channels)
712 value = mc_ch_readl(mc, channel, addr_reg);
714 value = mc_readl(mc, addr_reg);
717 dev_err_ratelimited(mc->dev, "%s: %s%s @%pa: %s (%s%s)\n",
718 client, secure, direction, &addr, error,
722 /* clear interrupts */
723 if (mc->soc->num_channels) {
724 mc_ch_writel(mc, channel, status, MC_INTSTATUS);
725 mc_ch_writel(mc, MC_BROADCAST_CHANNEL,
726 mc_channel_to_global_intstatus(mc, channel),
727 MC_GLOBAL_INTSTATUS);
729 mc_writel(mc, status, MC_INTSTATUS);
735 const char *const tegra_mc_status_names[32] = {
736 [ 1] = "External interrupt",
737 [ 6] = "EMEM address decode error",
738 [ 7] = "GART page fault",
739 [ 8] = "Security violation",
740 [ 9] = "EMEM arbitration error",
742 [11] = "Invalid APB ASID update",
743 [12] = "VPR violation",
744 [13] = "Secure carveout violation",
745 [16] = "MTS carveout violation",
746 [17] = "Generalized carveout violation",
747 [20] = "Route Sanity error",
750 const char *const tegra_mc_error_names[8] = {
751 [2] = "EMEM decode error",
752 [3] = "TrustZone violation",
753 [4] = "Carveout violation",
754 [6] = "SMMU translation error",
758 * Memory Controller (MC) has few Memory Clients that are issuing memory
759 * bandwidth allocation requests to the MC interconnect provider. The MC
760 * provider aggregates the requests and then sends the aggregated request
761 * up to the External Memory Controller (EMC) interconnect provider which
762 * re-configures hardware interface to External Memory (EMEM) in accordance
763 * to the required bandwidth. Each MC interconnect node represents an
764 * individual Memory Client.
766 * Memory interconnect topology:
772 * | | +-----+ +------+
773 * ... | MC +--->+ EMC +--->+ EMEM |
774 * | | +-----+ +------+
780 static int tegra_mc_interconnect_setup(struct tegra_mc *mc)
782 struct icc_node *node;
786 /* older device-trees don't have interconnect properties */
787 if (!device_property_present(mc->dev, "#interconnect-cells") ||
791 mc->provider.dev = mc->dev;
792 mc->provider.data = &mc->provider;
793 mc->provider.set = mc->soc->icc_ops->set;
794 mc->provider.aggregate = mc->soc->icc_ops->aggregate;
795 mc->provider.xlate_extended = mc->soc->icc_ops->xlate_extended;
797 icc_provider_init(&mc->provider);
799 /* create Memory Controller node */
800 node = icc_node_create(TEGRA_ICC_MC);
802 return PTR_ERR(node);
804 node->name = "Memory Controller";
805 icc_node_add(node, &mc->provider);
807 /* link Memory Controller to External Memory Controller */
808 err = icc_link_create(node, TEGRA_ICC_EMC);
812 for (i = 0; i < mc->soc->num_clients; i++) {
813 /* create MC client node */
814 node = icc_node_create(mc->soc->clients[i].id);
820 node->name = mc->soc->clients[i].name;
821 icc_node_add(node, &mc->provider);
823 /* link Memory Client to Memory Controller */
824 err = icc_link_create(node, TEGRA_ICC_MC);
829 err = icc_provider_register(&mc->provider);
836 icc_nodes_remove(&mc->provider);
841 static int tegra_mc_probe(struct platform_device *pdev)
847 mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL);
851 platform_set_drvdata(pdev, mc);
852 spin_lock_init(&mc->lock);
853 mc->soc = of_device_get_match_data(&pdev->dev);
854 mc->dev = &pdev->dev;
856 mask = DMA_BIT_MASK(mc->soc->num_address_bits);
858 err = dma_coerce_mask_and_coherent(&pdev->dev, mask);
860 dev_err(&pdev->dev, "failed to set DMA mask: %d\n", err);
864 /* length of MC tick in nanoseconds */
867 mc->regs = devm_platform_ioremap_resource(pdev, 0);
868 if (IS_ERR(mc->regs))
869 return PTR_ERR(mc->regs);
871 mc->debugfs.root = debugfs_create_dir("mc", NULL);
873 if (mc->soc->ops && mc->soc->ops->probe) {
874 err = mc->soc->ops->probe(mc);
879 if (mc->soc->ops && mc->soc->ops->handle_irq) {
880 mc->irq = platform_get_irq(pdev, 0);
884 WARN(!mc->soc->client_id_mask, "missing client ID mask for this SoC\n");
886 if (mc->soc->num_channels)
887 mc_ch_writel(mc, MC_BROADCAST_CHANNEL, mc->soc->intmask,
890 mc_writel(mc, mc->soc->intmask, MC_INTMASK);
892 err = devm_request_irq(&pdev->dev, mc->irq, mc->soc->ops->handle_irq, 0,
893 dev_name(&pdev->dev), mc);
895 dev_err(&pdev->dev, "failed to request IRQ#%u: %d\n", mc->irq,
901 if (mc->soc->reset_ops) {
902 err = tegra_mc_reset_setup(mc);
904 dev_err(&pdev->dev, "failed to register reset controller: %d\n", err);
907 err = tegra_mc_interconnect_setup(mc);
909 dev_err(&pdev->dev, "failed to initialize interconnect: %d\n",
912 if (IS_ENABLED(CONFIG_TEGRA_IOMMU_SMMU) && mc->soc->smmu) {
913 mc->smmu = tegra_smmu_probe(&pdev->dev, mc->soc->smmu, mc);
914 if (IS_ERR(mc->smmu)) {
915 dev_err(&pdev->dev, "failed to probe SMMU: %ld\n",
921 if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && !mc->soc->smmu) {
922 mc->gart = tegra_gart_probe(&pdev->dev, mc);
923 if (IS_ERR(mc->gart)) {
924 dev_err(&pdev->dev, "failed to probe GART: %ld\n",
933 static int __maybe_unused tegra_mc_suspend(struct device *dev)
935 struct tegra_mc *mc = dev_get_drvdata(dev);
937 if (mc->soc->ops && mc->soc->ops->suspend)
938 return mc->soc->ops->suspend(mc);
943 static int __maybe_unused tegra_mc_resume(struct device *dev)
945 struct tegra_mc *mc = dev_get_drvdata(dev);
947 if (mc->soc->ops && mc->soc->ops->resume)
948 return mc->soc->ops->resume(mc);
953 static void tegra_mc_sync_state(struct device *dev)
955 struct tegra_mc *mc = dev_get_drvdata(dev);
957 /* check whether ICC provider is registered */
958 if (mc->provider.dev == dev)
962 static const struct dev_pm_ops tegra_mc_pm_ops = {
963 SET_SYSTEM_SLEEP_PM_OPS(tegra_mc_suspend, tegra_mc_resume)
966 static struct platform_driver tegra_mc_driver = {
969 .of_match_table = tegra_mc_of_match,
970 .pm = &tegra_mc_pm_ops,
971 .suppress_bind_attrs = true,
972 .sync_state = tegra_mc_sync_state,
974 .prevent_deferred_probe = true,
975 .probe = tegra_mc_probe,
978 static int tegra_mc_init(void)
980 return platform_driver_register(&tegra_mc_driver);
982 arch_initcall(tegra_mc_init);
985 MODULE_DESCRIPTION("NVIDIA Tegra Memory Controller driver");