Skip to contentSkip to conversation

CPM2 cleanups

PATCH In review Jason McMullan 3 participants 6 messages Mar 22, 2005 – Mar 23, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CPM2 cleanups

This patch cleans up CPM2 interrupt controller usage in the mpc8260/mpc8560, and adds the cpm_cp_command() convenience function.

Signature · 2 lines
Jason McMullan <[email protected]>
TimeSys Corporation

#### Auto-generated patch ####

Date:        Tue, 22 Mar 2005 15:23:34 -0500
Maintainer:  Jason McMullan <[email protected]>
Summary:     Freescale CPM2 device I/O processor, on MPC8xx and MPC8xxx CPUs
Description: Freescale CPM2 device I/O processor, on MPC8xx and MPC8xxx CPUs

###############################

Index of changes:

 arch/ppc/platforms/85xx/mpc8560_ads.c |    4 -
 arch/ppc/syslib/cpm2_common.c         |    4 -
 arch/ppc/syslib/cpm2_pic.c            |   69 ++++++++++++++++++----
 arch/ppc/syslib/cpm2_pic.h            |    3 
 arch/ppc/syslib/m8260_setup.c         |    5 -
 include/asm-ppc/cpm2.h                |   23 ++++++-
 include/asm-ppc/irq.h                 |  105 +++++++++++++++++-----------------
 7 files changed, 138 insertions(+), 75 deletions(-)
arch/ppc/platforms/85xx/mpc8560_ads.c +1 -3
@@ -135,7 +135,6 @@
 static void __init
 mpc8560_ads_init_IRQ(void)
 {
-	int i;
 	volatile cpm2_map_t *immap = cpm2_immr;
 
 	/* Setup OpenPIC */
@@ -145,8 +144,7 @@
 	immap->im_intctl.ic_simrh = 0x0;
 	immap->im_intctl.ic_simrl = 0x0;
 
-	for (i = CPM_IRQ_OFFSET; i < (NR_CPM_INTS + CPM_IRQ_OFFSET); i++)
-		irq_desc[i].handler = &cpm2_pic;
+        cpm2_init_IRQ();
 
 	/* Initialize the default interrupt mapping priorities,
 	 * in case the boot rom changed something on us.
arch/ppc/syslib/cpm2_common.c +2 -2
@@ -32,12 +32,12 @@
 #include <asm/rheap.h>
 
 static void cpm2_dpinit(void);
-cpm_cpm2_t	*cpmp;		/* Pointer to comm processor space */
+volatile cpm_cpm2_t     *cpmp;          /* Pointer to comm processor space */
 
 /* We allocate this here because it is used almost exclusively for
  * the communication processor devices.
  */
-cpm2_map_t *cpm2_immr;
+volatile cpm2_map_t *cpm2_immr;
 
 #define CPM_MAP_SIZE	(0x40000)	/* 256k - the PQ3 reserve this amount
 					   of space for CPM as it is larger
arch/ppc/syslib/cpm2_pic.c +56 -13

81 lines not on this page · raw message

arch/ppc/syslib/cpm2_pic.h +2 -1
@@ -1,7 +1,8 @@
 #ifndef _PPC_KERNEL_CPM2_H
 #define _PPC_KERNEL_CPM2_H
 
-extern struct hw_interrupt_type cpm2_pic;
 extern int cpm2_get_irq(struct pt_regs *regs);
 
+extern void cpm2_init_IRQ(void);
+
 #endif /* _PPC_KERNEL_CPM2_H */
arch/ppc/syslib/m8260_setup.c +1 -4
@@ -168,10 +168,7 @@
 static void __init
 m8260_init_IRQ(void)
 {
-	int i;
-
-        for ( i = 0 ; i < NR_SIU_INTS ; i++ )
-                irq_desc[i].handler = &cpm2_pic;
+	cpm2_init_IRQ();
 
 	/* Initialize the default interrupt mapping priorities,
 	 * in case the boot rom changed something on us.
include/asm-ppc/cpm2.h +21 -2
@@ -69,13 +69,14 @@
 #define CPM_CR_INIT_TX		((ushort)0x0002)
 #define CPM_CR_HUNT_MODE	((ushort)0x0003)
 #define CPM_CR_STOP_TX		((ushort)0x0004)
+#define CPM_CR_GRA_STOP_TX      ((ushort)0x0005)
 #define CPM_CR_RESTART_TX	((ushort)0x0006)
 #define CPM_CR_SET_GADDR	((ushort)0x0008)
 #define CPM_CR_START_IDMA	((ushort)0x0009)
 #define CPM_CR_STOP_IDMA	((ushort)0x000b)
 
 #define mk_cr_cmd(PG, SBC, MCN, OP) \
-	((PG << 26) | (SBC << 21) | (MCN << 6) | OP)
+	(((PG) << 26) | ((SBC) << 21) | ((MCN) << 6) | (OP))
 
 /* Dual Port RAM addresses.  The first 16K is available for almost
  * any CPM use, so we put the BDs there.  The first 128 bytes are
@@ -107,7 +108,7 @@
 /* Export the base address of the communication processor registers
  * and dual port ram.
  */
-extern		cpm_cpm2_t	*cpmp;	 /* Pointer to comm processor */
+extern volatile	cpm_cpm2_t	*cpmp;	 /* Pointer to comm processor */
 extern uint cpm_dpalloc(uint size, uint align);
 extern int cpm_dpfree(uint offset);
 extern uint cpm_dpalloc_fixed(uint offset, uint size, uint align);
@@ -115,7 +116,24 @@
 extern void *cpm_dpram_addr(uint offset);
 extern void cpm_setbrg(uint brg, uint rate);
 extern void cpm2_fastbrg(uint brg, uint rate, int div16);
+extern void cpm2_reset(void);
+
+#ifdef CONFIG_CPM2
+#define CPM_CP_FCC(line, mcn)	mk_cr_cmd(CPM_CR_FCC1_PAGE+(line),CPM_CR_FCC1_SBLOCK+(line), mcn, 0)
+#define CPM_CP_SCC(line)	mk_cr_cmd(CPM_CR_SCC1_PAGE+(line),CPM_CR_SCC1_SBLOCK+(line), 0, 0)
+#define CPM_CP_SMC(line)	mk_cr_cmd(CPM_CR_SMC1_PAGE+(line),CPM_CR_SMC1_SBLOCK+(line), 0, 0)
+#define CPM_CP_I2C		mk_cr_cmd(CPM_CR_I2C_PAGE,CPM_CR_I2C_SBLOCK, 0, 0)
 
+static inline void cpm_cp_command(uint32_t id, int op)
+{
+	cpmp->cp_cpcr = id | op | CPM_CR_FLG;
+
+	while (cpmp->cp_cpcr & CPM_CR_FLG);
+}
+#else
+#error Please define cpm_cp_command and the CPM_CP_* ids you will need.
+#endif
+
 /* Buffer descriptors used by many of the CPM protocols.
 */
 typedef struct cpm_buf_desc {
@@ -135,6 +153,7 @@
 #define BD_SC_BR	((ushort)0x0020)	/* Break received */
 #define BD_SC_FR	((ushort)0x0010)	/* Framing error */
 #define BD_SC_PR	((ushort)0x0008)	/* Parity error */
+#define BD_SC_NAK	((ushort)0x0004)	/* NAK - did not respond */
 #define BD_SC_OV	((ushort)0x0002)	/* Overrun */
 #define BD_SC_CD	((ushort)0x0001)	/* ?? */
 
include/asm-ppc/irq.h +55 -50

112 lines not on this page · raw message

#1 lore raw
Quoted 1 line · In message <[email protected]> you wrote:

...

arch/ppc/syslib/cpm2_pic.c line 112

Quoted 10 lines
arch/ppc/syslib/cpm2_pic.c +10 -0
+static unsigned int cpm2_startup_irq(unsigned int irq)
+{  
+       cpm2_unmask_irq(irq);
+       return 0;
+}
+
+static void cpm2_shutdown_irq(unsigned int irq)
+{
+       cpm2_mask_irq(irq);
+}

Why is cpm2_startup_irq() not void like cpm2_shutdown_irq() ?

Best regards,

Wolfgang Denk

Signature · 3 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
Overflow on /dev/null, please empty the bit bucket.
#2 lore raw

Jason, why did you bother to implement these functions, they dont=20 provide any value for us?

It looks like startup() & shutdown() are only used in IRQ probing code=20=

or code in which enable/disable will be used instead.

- kumar

Quoted 16 lines · Wolfgang Denk
Quoted 1 line · In message <[email protected]> you wrote:

...

arch/ppc/syslib/cpm2_pic.c line 112

Quoted 10 lines
arch/ppc/syslib/cpm2_pic.c +10 -0
+static unsigned int cpm2_startup_irq(unsigned int irq)
+{=A0
+=A0=A0=A0=A0=A0=A0 cpm2_unmask_irq(irq);
+=A0=A0=A0=A0=A0=A0 return 0;
+}
+
+static void cpm2_shutdown_irq(unsigned int irq)
+{
+=A0=A0=A0=A0=A0=A0 cpm2_mask_irq(irq);
+}

Why is cpm2_startup_irq() not void like cpm2_shutdown_irq() ?

Quoted 6 lines

Best regards,

Wolfgang Denk

--=20
Software Engineering:=A0 Embedded and Realtime Systems,=A0 Embedded =

Linux

Quoted 6 lines

Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected] Overflow on /dev/null, please empty the bit bucket.
_______________________________________________
Linuxppc-embedded mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

#3 lore raw
Quoted 5 lines · Kumar Gala

Jason, why did you bother to implement these functions, they dont provide any value for us?

It looks like startup() & shutdown() are only used in IRQ probing code or code in which enable/disable will be used instead.

startup/shutdown is used in the 'IRQ threads' patch we use at TimeSys.

Signature · 2 lines
Jason McMullan <[email protected]>
TimeSys Corporation
#4 lore raw
In reply to Jason McMullan

Some additional comments:

* Did you actually try setting CPM_IRQ_OFFSET to a non-zero value? I'm guessing this doesnt work since you are not offset the irq passed into the other functions. For example, if CPM_IRQ_OFFSET is 64, will cpm2_mask_irq() work?

* what is SA_NOTHREAD all about?

- kumar

Quoted 18 lines · Jason McMullan

_______________________________________________
Linuxppc-embedded mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

Date: March 22, 2005 2:28:51 PM CST
Subject:

Date: March 22, 2005 2:28:51 PM CST
Subject:

<ATT128341.txt><cpu-ppc-cpm2.patch>

<signature.asc>

#5 lore raw
Quoted 6 lines · Kumar Gala

Some additional comments:

* Did you actually try setting CPM_IRQ_OFFSET to a non-zero value? I'm guessing this doesnt work since you are not offset the irq passed into the other functions. For example, if CPM_IRQ_OFFSET is 64, will cpm2_mask_irq() work?

YAA! Good catch! (fix fix fix fix....)

Quoted 1 line

* what is SA_NOTHREAD all about?

Stale debugging code. Will be removed on the next patch.

Signature · 2 lines
Jason McMullan <[email protected]>
TimeSys Corporation