Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db09974c authored by Lina Iyer's avatar Lina Iyer
Browse files

drivers: irqchip: pdc: add IPC logging support



Add IPC logging support for debugging PDC interrupts.

Change-Id: I541acccc44cdc617a72d44ac8b3528bbc05b2e69
Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
parent bdf5d1bd
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@

#include <linux/err.h>
#include <linux/init.h>
#include <linux/ipc_logging.h>
#include <linux/irq.h>
#include <linux/irqchip.h>
#include <linux/irqdomain.h>
@@ -18,6 +19,8 @@
#include <linux/slab.h>
#include <linux/types.h>

#define PDC_IPC_LOG_SZ		2

#define PDC_MAX_IRQS		138
#define PDC_MAX_GPIO_IRQS	256

@@ -40,6 +43,7 @@ static void __iomem *pdc_base, *pdc_cfg_base;
static struct pdc_pin_region *pdc_region;
static int pdc_region_cnt;
static resource_size_t pdc_cfg_size;
static void *pdc_ipc_log;

static void pdc_reg_write(int reg, u32 i, u32 val)
{
@@ -64,6 +68,7 @@ static void pdc_enable_intr(struct irq_data *d, bool on)
	enable = pdc_reg_read(IRQ_ENABLE_BANK, index);
	enable = on ? ENABLE_INTR(enable, mask) : CLEAR_INTR(enable, mask);
	pdc_reg_write(IRQ_ENABLE_BANK, index, enable);
	ipc_log_string(pdc_ipc_log, "PIN=%d enable=%d", d->hwirq, on);
	raw_spin_unlock(&pdc_lock);
}

@@ -90,6 +95,7 @@ static void qcom_pdc_gic_mask(struct irq_data *d)
	if (d->hwirq == GPIO_NO_WAKE_IRQ)
		return;

	ipc_log_string(pdc_ipc_log, "PIN=%d mask", d->hwirq);
	irq_chip_mask_parent(d);
}

@@ -98,6 +104,7 @@ static void qcom_pdc_gic_unmask(struct irq_data *d)
	if (d->hwirq == GPIO_NO_WAKE_IRQ)
		return;

	ipc_log_string(pdc_ipc_log, "PIN=%d unmask", d->hwirq);
	irq_chip_unmask_parent(d);
}

@@ -120,6 +127,9 @@ static int spi_configure_type(irq_hw_number_t hwirq, unsigned int type)
	if (type & IRQ_TYPE_LEVEL_MASK)
		val |= mask;
	writel_relaxed(val, cfg_reg);
	ipc_log_string(pdc_ipc_log,
		       "SPI config: GIC-SPI=%d (reg=%d,bit=%d) val=%d",
		       spi, pin, spi % 32, type & IRQ_TYPE_LEVEL_MASK);
	raw_spin_unlock_irqrestore(&pdc_lock, flags);

	return 0;
@@ -194,6 +204,8 @@ static int qcom_pdc_gic_set_type(struct irq_data *d, unsigned int type)
	}

	pdc_reg_write(IRQ_i_CFG, pin_out, pdc_type);
	ipc_log_string(pdc_ipc_log, "Set type: PIN=%d pdc_type=%d gic_type=%d",
		       pin_out, pdc_type, type);

	/* Additionally, configure (only) the GPIO in the f/w */
	if (d->domain->host_data) {
@@ -285,6 +297,8 @@ static int qcom_pdc_alloc(struct irq_domain *domain, unsigned int virq,
	parent_fwspec.param[1]    = parent_hwirq;
	parent_fwspec.param[2]    = type;

	ipc_log_string(pdc_ipc_log, "Alloc: PIN=%d GIC-SPI=%d",
		       hwirq, parent_hwirq);
	return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,
					    &parent_fwspec);
}
@@ -342,6 +356,8 @@ static int qcom_pdc_gpio_alloc(struct irq_domain *domain, unsigned int virq,
	parent_fwspec.param[1]    = parent_hwirq;
	parent_fwspec.param[2]    = type;

	ipc_log_string(pdc_ipc_log, "GPIO alloc: PIN=%d GIC-SPI=%d",
		       hwirq, parent_hwirq);
	return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,
					    &parent_fwspec);
}
@@ -395,6 +411,15 @@ static int pdc_setup_pin_mapping(struct device_node *np)
	return 0;
}

static int __init qcom_pdc_early_init(void)
{
	pdc_ipc_log = ipc_log_context_create(PDC_IPC_LOG_SZ, "pdc", 0);

	return 0;

}
core_initcall(qcom_pdc_early_init);

static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
{
	struct irq_domain *parent_domain, *pdc_domain, *pdc_gpio_domain;