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

Commit dd72a35f authored by Raghavendra Kakarla's avatar Raghavendra Kakarla Committed by Gerrit - the friendly Code Review server
Browse files

drivers: irqchip: mpm: Add support to set irq type



Add support to set irq set type in mpm enter sleep sequence.

Change-Id: If52b0edd7a25206eca402ad4ee3cc7df468e64fa
Signed-off-by: default avatarRaghavendra Kakarla <rkakarla@codeaurora.org>
parent 1c8627ef
Loading
Loading
Loading
Loading
+28 −15
Original line number Diff line number Diff line
@@ -162,13 +162,26 @@ static inline void msm_mpm_enable_irq(struct irq_data *d, bool on)
	}
}

static inline void msm_mpm_set_type(struct irq_data *d,
static void msm_mpm_program_set_type(bool set, unsigned int reg,
					unsigned int index, unsigned int mask)
{
	u32 type;

	type = msm_mpm_read(reg, index);
	if (set)
		type = ENABLE_TYPE(type, mask);
	else
		type = CLEAR_TYPE(type, mask);

	msm_mpm_write(reg, index, type);
}

static void msm_mpm_set_type(struct irq_data *d,
					unsigned int flowtype)
{
	int mpm_pin[MAX_MPM_PIN_PER_IRQ] = {-1, -1};
	unsigned long flags;
	int i = 0;
	u32 type;
	unsigned int index, mask;
	unsigned int reg = 0;

@@ -180,24 +193,24 @@ static inline void msm_mpm_set_type(struct irq_data *d,
		index = mpm_pin[i]/32;
		mask = mpm_pin[i]%32;

		if (flowtype & IRQ_TYPE_LEVEL_HIGH)
			reg = MPM_REG_FALLING_EDGE;

		if (flowtype & IRQ_TYPE_EDGE_RISING)
		spin_lock_irqsave(&mpm_lock, flags);
		reg = MPM_REG_RISING_EDGE;
		if (flowtype & IRQ_TYPE_EDGE_RISING)
			msm_mpm_program_set_type(1, reg, index, mask);
		else
			msm_mpm_program_set_type(0, reg, index, mask);

		reg = MPM_REG_FALLING_EDGE;
		if (flowtype & IRQ_TYPE_EDGE_FALLING)
			reg = MPM_REG_POLARITY;

		spin_lock_irqsave(&mpm_lock, flags);
		type = msm_mpm_read(reg, index);

		if (flowtype)
			type = ENABLE_TYPE(type, mask);
			msm_mpm_program_set_type(1, reg, index, mask);
		else
			type = CLEAR_TYPE(type, mask);
			msm_mpm_program_set_type(0, reg, index, mask);

		msm_mpm_write(reg, index, type);
		reg = MPM_REG_POLARITY;
		if (flowtype & IRQ_TYPE_LEVEL_HIGH)
			msm_mpm_program_set_type(1, reg, index, mask);
		else
			msm_mpm_program_set_type(0, reg, index, mask);
		spin_unlock_irqrestore(&mpm_lock, flags);
	}
}