Skip to content
Permalink
Browse files
memory: tegra: Add support for mc interrupts
Implement new structure for function related to mc interrupts.
Move handle_irq into this structure.
Add support for clearing interrupts.

Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
  • Loading branch information
ashishmhetre8 authored and intel-lab-lkp committed Jan 11, 2022
1 parent 707b886 commit 71553a1a735ae07293d43df685262f85e6453170
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 5 deletions.
@@ -605,9 +605,12 @@ static irqreturn_t tegra30_mc_handle_irq(int irq, void *data)
return IRQ_HANDLED;
}

const struct tegra_mc_interrupt_ops tegra30_mc_interrupt_ops = {
.handle_irq = tegra30_mc_handle_irq,
};

const struct tegra_mc_ops tegra30_mc_ops = {
.probe = tegra30_mc_probe,
.handle_irq = tegra30_mc_handle_irq,
};
#endif

@@ -757,16 +760,21 @@ static int tegra_mc_probe(struct platform_device *pdev)
return err;
}

if (mc->soc->ops && mc->soc->ops->handle_irq) {
if (mc->soc->interrupt_ops && mc->soc->interrupt_ops->handle_irq) {
mc->irq = platform_get_irq(pdev, 0);
if (mc->irq < 0)
return mc->irq;

WARN(!mc->soc->client_id_mask, "missing client ID mask for this SoC\n");

/* clear any mc-errs that occurred before. */
if (mc->soc->interrupt_ops->clear_interrupt)
mc->soc->interrupt_ops->clear_interrupt(mc);

mc_writel(mc, mc->soc->intmask, MC_INTMASK);

err = devm_request_irq(&pdev->dev, mc->irq, mc->soc->ops->handle_irq, 0,
err = devm_request_irq(&pdev->dev, mc->irq,
mc->soc->interrupt_ops->handle_irq, 0,
dev_name(&pdev->dev), mc);
if (err < 0) {
dev_err(&pdev->dev, "failed to request IRQ#%u: %d\n", mc->irq,
@@ -148,6 +148,7 @@ extern const struct tegra_mc_soc tegra234_mc_soc;
defined(CONFIG_ARCH_TEGRA_210_SOC)
int tegra30_mc_probe(struct tegra_mc *mc);
extern const struct tegra_mc_ops tegra30_mc_ops;
extern const struct tegra_mc_interrupt_ops tegra30_mc_interrupt_ops;
#endif

#if defined(CONFIG_ARCH_TEGRA_186_SOC) || \
@@ -1114,4 +1114,5 @@ const struct tegra_mc_soc tegra114_mc_soc = {
.resets = tegra114_mc_resets,
.num_resets = ARRAY_SIZE(tegra114_mc_resets),
.ops = &tegra30_mc_ops,
.interrupt_ops = &tegra30_mc_interrupt_ops,
};
@@ -1275,6 +1275,7 @@ const struct tegra_mc_soc tegra124_mc_soc = {
.num_resets = ARRAY_SIZE(tegra124_mc_resets),
.icc_ops = &tegra124_mc_icc_ops,
.ops = &tegra30_mc_ops,
.interrupt_ops = &tegra30_mc_interrupt_ops,
};
#endif /* CONFIG_ARCH_TEGRA_124_SOC */

@@ -1307,5 +1308,6 @@ const struct tegra_mc_soc tegra132_mc_soc = {
.num_resets = ARRAY_SIZE(tegra124_mc_resets),
.icc_ops = &tegra124_mc_icc_ops,
.ops = &tegra30_mc_ops,
.interrupt_ops = &tegra30_mc_interrupt_ops,
};
#endif /* CONFIG_ARCH_TEGRA_132_SOC */
@@ -12,6 +12,8 @@

#include <soc/tegra/mc.h>

#include "mc.h"

#if defined(CONFIG_ARCH_TEGRA_186_SOC)
#include <dt-bindings/memory/tegra186-mc.h>
#endif
@@ -20,6 +22,8 @@
#define MC_SID_STREAMID_SECURITY_WRITE_ACCESS_DISABLED BIT(16)
#define MC_SID_STREAMID_SECURITY_OVERRIDE BIT(8)

#define MC_INTSTATUS_CLEAR 0x00033340

static void tegra186_mc_program_sid(struct tegra_mc *mc)
{
unsigned int i;
@@ -139,6 +143,15 @@ static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev)
return 0;
}

static void tegra186_mc_clear_interrupt(struct tegra_mc *mc)
{
mc_writel(mc, MC_INTSTATUS_CLEAR, MC_INTSTATUS);
}

const struct tegra_mc_interrupt_ops tegra186_mc_interrupt_ops = {
.clear_interrupt = tegra186_mc_clear_interrupt,
};

const struct tegra_mc_ops tegra186_mc_ops = {
.probe = tegra186_mc_probe,
.remove = tegra186_mc_remove,
@@ -876,5 +889,6 @@ const struct tegra_mc_soc tegra186_mc_soc = {
.clients = tegra186_mc_clients,
.num_address_bits = 40,
.ops = &tegra186_mc_ops,
.interrupt_ops = &tegra186_mc_interrupt_ops,
};
#endif
@@ -9,6 +9,17 @@

#include "mc.h"

#define MC_INTSTATUS_CLEAR 0x00133340

static void tegra194_mc_clear_interrupt(struct tegra_mc *mc)
{
mc_writel(mc, MC_INTSTATUS_CLEAR, MC_INTSTATUS);
}

const struct tegra_mc_interrupt_ops tegra194_mc_interrupt_ops = {
.clear_interrupt = tegra194_mc_clear_interrupt,
};

static const struct tegra_mc_client tegra194_mc_clients[] = {
{
.id = TEGRA194_MEMORY_CLIENT_PTCR,
@@ -1348,4 +1359,5 @@ const struct tegra_mc_soc tegra194_mc_soc = {
.clients = tegra194_mc_clients,
.num_address_bits = 40,
.ops = &tegra186_mc_ops,
.interrupt_ops = &tegra194_mc_interrupt_ops,
};
@@ -786,11 +786,15 @@ static irqreturn_t tegra20_mc_handle_irq(int irq, void *data)
return IRQ_HANDLED;
}

static const struct tegra_mc_interrupt_ops tegra20_mc_interrupt_ops = {
.handle_irq = tegra20_mc_handle_irq,
};

static const struct tegra_mc_ops tegra20_mc_ops = {
.probe = tegra20_mc_probe,
.suspend = tegra20_mc_suspend,
.resume = tegra20_mc_resume,
.handle_irq = tegra20_mc_handle_irq,
.interrupt_ops = tegra20_mc_interrupt_ops,
};

const struct tegra_mc_soc tegra20_mc_soc = {
@@ -1287,4 +1287,5 @@ const struct tegra_mc_soc tegra210_mc_soc = {
.resets = tegra210_mc_resets,
.num_resets = ARRAY_SIZE(tegra210_mc_resets),
.ops = &tegra30_mc_ops,
.interrupt_ops = &tegra30_mc_interrupt_ops,
};
@@ -1400,4 +1400,5 @@ const struct tegra_mc_soc tegra30_mc_soc = {
.num_resets = ARRAY_SIZE(tegra30_mc_resets),
.icc_ops = &tegra30_mc_icc_ops,
.ops = &tegra30_mc_ops,
.interrupt_ops = &tegra30_mc_interrupt_ops,
};
@@ -170,6 +170,11 @@ struct tegra_mc_icc_ops {
void *data);
};

struct tegra_mc_interrupt_ops {
void (*clear_interrupt)(struct tegra_mc *mc);
irqreturn_t (*handle_irq)(int irq, void *data);
};

struct tegra_mc_ops {
/*
* @probe: Callback to set up SoC-specific bits of the memory controller. This is called
@@ -179,7 +184,6 @@ struct tegra_mc_ops {
void (*remove)(struct tegra_mc *mc);
int (*suspend)(struct tegra_mc *mc);
int (*resume)(struct tegra_mc *mc);
irqreturn_t (*handle_irq)(int irq, void *data);
int (*probe_device)(struct tegra_mc *mc, struct device *dev);
};

@@ -205,6 +209,7 @@ struct tegra_mc_soc {

const struct tegra_mc_icc_ops *icc_ops;
const struct tegra_mc_ops *ops;
const struct tegra_mc_interrupt_ops *interrupt_ops;
};

struct tegra_mc {

0 comments on commit 71553a1

Please sign in to comment.