public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Michael Schmitz <schmitzmic@gmail.com>
To: geert@linux-m68k.org
Cc: linux-m68k@vger.kernel.org, debian-68k@lists.debian.org,
	Michael Schmitz <schmitz@debian.org>
Subject: [PATCH 06/14] m68k/atari: use dedicated irq_chip for timer D interrupts
Date: Mon, 25 Mar 2013 14:16:24 +1300	[thread overview]
Message-ID: <1364174192-25406-7-git-send-email-schmitz@debian.org> (raw)
In-Reply-To: <1364174192-25406-1-git-send-email-schmitz@debian.org>

The MFP timer D is used as a polling timer for EtherNEC and NetUSBee
on Atari. Set up a dedicated IRQ chip for timer D to simplify interrupt
sharing, and use the new 'polling' IRQ handler for its interrupts.

Signed-off-by: Michael Schmitz <schmitz@debian.org>
---
 arch/m68k/atari/ataints.c         |   70 +++++++++++++++++++++++++++++++++++++
 arch/m68k/include/asm/atariints.h |    9 +++++
 2 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/arch/m68k/atari/ataints.c b/arch/m68k/atari/ataints.c
index 3f41092..2cf7349 100644
--- a/arch/m68k/atari/ataints.c
+++ b/arch/m68k/atari/ataints.c
@@ -122,6 +122,62 @@ static struct irq_chip atari_irq_chip = {
 };
 
 /*
+ * ST-MFP timer D chained interrupts - each driver gets its own timer
+ * interrupt instance.
+ */
+
+struct mfptimerbase {
+	volatile struct MFP *mfp;
+	unsigned char mfp_mask, mfp_data;
+	unsigned short int_mask;
+	int handler_irq, mfptimer_irq, server_irq;
+	char *name;
+} stmfp_base = {
+	.mfp		= &st_mfp,
+	.int_mask	= 0x0,
+	.handler_irq	= IRQ_MFP_TIMD,
+	.mfptimer_irq	= IRQ_MFP_TIMER1,
+	.name		= "MFP Timer D"
+};
+
+static irqreturn_t mfptimer_handler(int irq, void *dev_id)
+{
+	struct mfptimerbase *base = dev_id;
+	int mach_irq;
+	unsigned char ints;
+
+	mach_irq = base->mfptimer_irq;
+	ints = base->int_mask;
+	for (; ints; mach_irq++, ints >>= 1) {
+		if (ints & 1)
+			generic_handle_irq(mach_irq);
+	}
+	return IRQ_HANDLED;
+}
+
+
+static void atari_mfptimer_enable(struct irq_data *data)
+{
+	int mfp_num = data->irq - IRQ_MFP_TIMER1;
+	stmfp_base.int_mask |= 1 << mfp_num;
+	atari_enable_irq(IRQ_MFP_TIMD);
+}
+
+static void atari_mfptimer_disable(struct irq_data *data)
+{
+	int mfp_num = data->irq - IRQ_MFP_TIMER1;
+	stmfp_base.int_mask &= ~(1 << mfp_num);
+	if (!stmfp_base.int_mask)
+		atari_disable_irq(IRQ_MFP_TIMD);
+}
+
+static struct irq_chip atari_mfptimer_chip = {
+	.name		= "timer_d",
+	.irq_enable	= atari_mfptimer_enable,
+	.irq_disable	= atari_mfptimer_disable,
+};
+
+/*
  * void atari_init_IRQ (void)
  *
  * Parameters:	None
@@ -198,6 +254,20 @@ void __init atari_init_IRQ(void)
 	/* Initialize the PSG: all sounds off, both ports output */
 	sound_ym.rd_data_reg_sel = 7;
 	sound_ym.wd_data = 0xff;
+
+	m68k_setup_irq_controller(&atari_mfptimer_chip, handle_polled_irq,
+				  IRQ_MFP_TIMER1, 8);
+
+	/* prepare timer D data for use as poll interrupt */
+	/* set Timer D data Register - needs to be > 0 */
+	st_mfp.tim_dt_d = 254;	/* < 100 Hz */
+	/* start timer D, div = 1:100 */
+	st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 0xf0) | 0x6;
+
+	/* request timer D dispatch handler */
+	if (request_irq(IRQ_MFP_TIMD, mfptimer_handler, IRQF_SHARED,
+			stmfp_base.name, &stmfp_base))
+		pr_err("Couldn't register %s interrupt\n", stmfp_base.name);
 }
 
 
diff --git a/arch/m68k/include/asm/atariints.h b/arch/m68k/include/asm/atariints.h
index 12c759a..953e0ac 100644
--- a/arch/m68k/include/asm/atariints.h
+++ b/arch/m68k/include/asm/atariints.h
@@ -94,6 +94,15 @@
 #define IRQ_SCCA_RX	     (52)
 #define IRQ_SCCA_SPCOND	     (54)
 
+/* shared MFP timer D interrupts - hires timer for EtherNEC et al. */
+#define IRQ_MFP_TIMER1       (64)
+#define IRQ_MFP_TIMER2       (65)
+#define IRQ_MFP_TIMER3       (66)
+#define IRQ_MFP_TIMER4       (67)
+#define IRQ_MFP_TIMER5       (68)
+#define IRQ_MFP_TIMER6       (69)
+#define IRQ_MFP_TIMER7       (70)
+#define IRQ_MFP_TIMER8       (71)
 
 #define INT_CLK   24576	    /* CLK while int_clk =2.456MHz and divide = 100 */
 #define INT_TICKS 246	    /* to make sched_time = 99.902... HZ */
-- 
1.7.0.4

  parent reply	other threads:[~2013-03-25  1:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25  1:16 (unknown), Michael Schmitz
2013-03-25  1:16 ` [PATCH 01/14] m68k/atari EtherNEC: remove original EtherNEC driver Michael Schmitz
2013-03-25  1:16 ` [PATCH 02/14] m68k/atari EtherNAT: remove original EtherNAT driver Michael Schmitz
2013-03-25  1:16 ` [PATCH 03/14] m68k/atari: use CONFIG_ATARI in smc91x.h Michael Schmitz
2013-03-25  1:16 ` [PATCH 04/14] m68k/atari: EtherNAT - change number of Atari interrupt sources Michael Schmitz
2013-03-25  1:16 ` [PATCH 05/14] m68k/irq: add handle_polled_irq() for timer based soft interrupts Michael Schmitz
2013-03-25  1:16 ` Michael Schmitz [this message]
2013-03-25  1:16 ` [PATCH 07/14] m68k/atari: EtherNEC - add platform device support Michael Schmitz
2013-03-25  1:16 ` [PATCH 08/14] m68k/atari: EtherNAT - ethernet support - new driver (smc91x) Michael Schmitz
2013-03-25  1:16 ` [PATCH 09/14] m68k/atari: EtherNEC - ethernet support - new driver (ne.c) Michael Schmitz
2013-03-25  1:16 ` [PATCH 10/14] m68k/atari: EtherNAT - add interrupt chip for Ethernet and USB interrupts Michael Schmitz
2013-03-25  1:16 ` [PATCH 11/14] m68k/atari: Implement 16 bit access macros for ROM port Michael Schmitz
2013-03-25  1:16 ` [PATCH 12/14] m68k: Implement ndelay() based on the existing udelay() logic Michael Schmitz
2013-03-25  1:16 ` [PATCH 13/14] m68k/atari: USB - add platform device definitions for ISP1160 HCD Michael Schmitz
2013-03-25  1:16 ` [PATCH 14/14] m68k/atari: USB - Add ISP1160 USB host controller support Michael Schmitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364174192-25406-7-git-send-email-schmitz@debian.org \
    --to=schmitzmic@gmail.com \
    --cc=debian-68k@lists.debian.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=schmitz@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox