generic smc code patch
Hello all,
This patch for embedded-2.2.13 will make macros out of some SMC / SCC constants in commproc.h.
Creating generic SCC and SMC code will now be easier.
Instead of PROFF_SCC1 use PROFF_SCC(1), or PROFF_SCC(n).
Patch instructions:
$ pwd /xxx/yyy/zzz/embedded-2.2.13 $ cat smc_scc.diff | patch -p1
Comments ?
/ Magnus
arch/ppc/8xx_io/commproc.h +40 -18
@@ -14,7 +14,18 @@* bytes of the DP RAM and relocates the I2C parameter area to the * IDMA1 space. The remaining DP RAM is available for buffer descriptors * or other use. +* +* 17 Nov 1999: Magnus Damm <[email protected]> +* Converted some constants to macros for the SCC:s and SMC:s. +* +* CPM_CR_CH_SxCn -> CPM_CR_CH_SxC(n) +* PROFF_SxCn -> PROFF_SxC(n) +* CPMVEC_SxCn -> CPMVEC_SxC(n) +* +* Generic SCC/SMC code will now be smaller/faster/better. +* No bounds checking is done, be careful. */ +#ifndef __CPM_8XX__#define __CPM_8XX__
@@ -39,14 +50,17 @@/* Channel numbers. */ -#define CPM_CR_CH_SCC1 ((ushort)0x0000) +#define CPM_CR_CH_SCC (n) ((ushort)(((n)-1) << 2)) +#define CPM_CR_CH_SMC (n) ((ushort)(0x0009 | (((n)-1) << 2))) + +/* #define CPM_CR_CH_SCC1 ((ushort)0x0000) */ #define CPM_CR_CH_I2C ((ushort)0x0001)/* I2C and IDMA1 */ -#define CPM_CR_CH_SCC2 ((ushort)0x0004) +/* #define CPM_CR_CH_SCC2 ((ushort)0x0004) */ #define CPM_CR_CH_SPI ((ushort)0x0005)/* SPI / IDMA2 / Timers */ -#define CPM_CR_CH_SCC3 ((ushort)0x0008) -#define CPM_CR_CH_SMC1 ((ushort)0x0009)/* SMC1 / DSP1 */ -#define CPM_CR_CH_SCC4 ((ushort)0x000c) -#define CPM_CR_CH_SMC2 ((ushort)0x000d)/* SMC2 / DSP2 */ +/* #define CPM_CR_CH_SCC3 ((ushort)0x0008) */ +/* #define CPM_CR_CH_SMC1 ((ushort)0x0009) */ /* SMC1 / DSP1 */ +/* #define CPM_CR_CH_SCC4 ((ushort)0x000c) */ +/* #define CPM_CR_CH_SMC2 ((ushort)0x000d) */ /* SMC2 / DSP2 */ #define mk_cr_cmd (CH ,CMD ) ((CMD << 8) | (CH << 4))
@@ -91,14 +105,18 @@/* Parameter RAM offsets. */ -#define PROFF_SCC1 ((uint)0x0000) + +#define PROFF_SCC (n) ((uint)(((n)-1) << 8))/* SCC(1) -> SCC(4) */ +#define PROFF_SMC (n) ((uint)((((n)-1) << 8) + 0x280))/* SMC(1) -> SMC(2) */ + +/* #define PROFF_SCC1 ((uint)0x0000) */ #define PROFF_IIC ((uint)0x0080) -#define PROFF_SCC2 ((uint)0x0100) +/* #define PROFF_SCC2 ((uint)0x0100) */ #define PROFF_SPI ((uint)0x0180) -#define PROFF_SCC3 ((uint)0x0200) -#define PROFF_SMC1 ((uint)0x0280) -#define PROFF_SCC4 ((uint)0x0300) -#define PROFF_SMC2 ((uint)0x0380) +/* #define PROFF_SCC3 ((uint)0x0200) */ +/* #define PROFF_SMC1 ((uint)0x0280) */ +/* #define PROFF_SCC4 ((uint)0x0300) */ +/* #define PROFF_SMC2 ((uint)0x0380) */ /* Define enough so I can at least use the serial port as a UART. * The MBX uses SMC1 as the host serial port.
@@ -653,12 +671,16 @@* use the table as defined in the manuals (i.e. no special high * priority and SCC1 == SCCa, etc...). */ + +#define CPMVEC_SCC (n) ((ushort)(0x1f-(n)))/* SCC(1) -> SCC(4) */ +#define CPMVEC_SMC (n) ((ushort)(0x05-(n)))/* SMC(1) -> SMC(2) */ +#define CPMVEC_NR 32#define CPMVEC_PIO_PC15 ((ushort)0x1f) -#define CPMVEC_SCC1 ((ushort)0x1e) -#define CPMVEC_SCC2 ((ushort)0x1d) -#define CPMVEC_SCC3 ((ushort)0x1c) -#define CPMVEC_SCC4 ((ushort)0x1b) +/* #define CPMVEC_SCC1 ((ushort)0x1e) */ +/* #define CPMVEC_SCC2 ((ushort)0x1d) */ +/* #define CPMVEC_SCC3 ((ushort)0x1c) */ +/* #define CPMVEC_SCC4 ((ushort)0x1b) */ #define CPMVEC_PIO_PC14 ((ushort)0x1a)#define CPMVEC_TIMER1 ((ushort)0x19)#define CPMVEC_PIO_PC13 ((ushort)0x18)
@@ -678,8 +700,8 @@#define CPMVEC_TIMER4 ((ushort)0x07)#define CPMVEC_PIO_PC6 ((ushort)0x06)#define CPMVEC_SPI ((ushort)0x05) -#define CPMVEC_SMC1 ((ushort)0x04) -#define CPMVEC_SMC2 ((ushort)0x03) +/* #define CPMVEC_SMC1 ((ushort)0x04) */ +/* #define CPMVEC_SMC2 ((ushort)0x03) */ #define CPMVEC_PIO_PC5 ((ushort)0x02)#define CPMVEC_PIO_PC4 ((ushort)0x01)#define CPMVEC_ERROR ((ushort)0x00)
Only in embedded-2.2.13_smcp/arch/ppc/8xx_io: commproc.h~ Only in embedded-2.2.13_smcp/arch/ppc/8xx_io: commproc.o
arch/ppc/8xx_io/enet.c +21 -15
@@ -21,6 +21,8 @@* will be much more memory efficient and will easily handle lots of * small packets. * +* 17 Nov 1999: Magnus Damm <[email protected]> +* Converted some constants to macros for the SCC:s and SMC:s. */ #include <linux/kernel.h> #include <linux/sched.h>
@@ -167,18 +169,14 @@/* Typically, 860(T) boards use SCC1 for Ethernet, and other 8xx boards * use SCC2. This is easily extended if necessary. */ + +#ifdef CONFIG_SCC2_ENET -#define CPM_CR_ENET CPM_CR_CH_SCC2 -#define PROFF_ENET PROFF_SCC2 -#define SCC_ENET 1/* Index, not number! */ -#define CPMVEC_ENET CPMVEC_SCC2 +#define ENET_SCC 2#endif #ifdef CONFIG_SCC1_ENET -#define CPM_CR_ENET CPM_CR_CH_SCC1 -#define PROFF_ENET PROFF_SCC1 -#define SCC_ENET 0 -#define CPMVEC_ENET CPMVEC_SCC1 +#define ENET_SCC 1#endif static int
@@ -479,7 +477,9 @@*/ cp = cpmp; cp->cp_cpcr = -mk_cr_cmd (CPM_CR_ENET ,CPM_CR_RESTART_TX ) |CPM_CR_FLG ; +mk_cr_cmd (CPM_CR_CH_SCC (ENET_SCC ),CPM_CR_RESTART_TX ) + |CPM_CR_FLG ; +while (cp->cp_cpcr &CPM_CR_FLG ); } }
@@ -683,7 +683,10 @@/* Ask CPM to run CRC and set bit in * filter mask. */ - cpmp->cp_cpcr =mk_cr_cmd (CPM_CR_ENET ,CPM_CR_SET_GADDR ) |CPM_CR_FLG ; + cpmp->cp_cpcr =mk_cr_cmd ( +CPM_CR_CH_SCC (ENET_SCC ), +CPM_CR_SET_GADDR ) |CPM_CR_FLG ; +/* this delay is necessary here -- Cort */ udelay (10 );while (cpmp->cp_cpcr &CPM_CR_FLG );
@@ -731,11 +734,11 @@/* Get pointer to SCC area in parameter RAM. */ - ep = (scc_enet_t *)(&cp->cp_dparam[PROFF_ENET ]); + ep = (scc_enet_t *)(&cp->cp_dparam[PROFF_SCC (ENET_SCC )]);/* And another to the SCC register area. */ - sccp = (volatile scc_t *)(&cp->cp_scc[SCC_ENET ]); + sccp = (volatile scc_t *)(&cp->cp_scc[ENET_SCC -1 ]); cep->sccp = (scc_t *)sccp;/* Keep the pointer handy */ /* Disable receive and transmit in case EPPC-Bug started it.
@@ -799,7 +802,8 @@* already running. * In addition, we have to do it later because we don't yet have * all of the BD control/status set properly. -cp->cp_cpcr = mk_cr_cmd(CPM_CR_ENET, CPM_CR_INIT_RX) | CPM_CR_FLG; +cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SCC(ENET_SCC), +CPM_CR_INIT_RX) | CPM_CR_FLG; while (cp->cp_cpcr & CPM_CR_FLG); */
@@ -914,7 +918,9 @@* than the manual describes because we have just now finished * the BD initialization. */ - cp->cp_cpcr =mk_cr_cmd (CPM_CR_ENET ,CPM_CR_INIT_TRX ) |CPM_CR_FLG ; + cp->cp_cpcr =mk_cr_cmd (CPM_CR_CH_SCC (ENET_SCC ),CPM_CR_INIT_TRX ) + |CPM_CR_FLG ; +while (cp->cp_cpcr &CPM_CR_FLG ); cep->skb_cur = cep->skb_dirty =0 ;
@@ -929,7 +935,7 @@/* Install our interrupt handler. */ -cpm_install_handler (CPMVEC_ENET , cpm_enet_interrupt, dev); +cpm_install_handler (CPMVEC_SCC (ENET_SCC ), cpm_enet_interrupt, dev);/* Set GSMR_H to enable all normal operating modes. * Set GSMR_L to enable Ethernet to MC68160.
arch/ppc/8xx_io/uart.c +18 -40
107 lines not on this page · raw message
arch/ppc/mbxboot/m8xx_tty.c +8 -6
@@ -34,7 +34,7 @@ cp = cpmp; sp = (smc_t *)&(cp->cp_smc[0 ]); - up = (smc_uart_t *)&cp->cp_dparam[PROFF_SMC1 ]; + up = (smc_uart_t *)&cp->cp_dparam[PROFF_SMC (1 )];/* Disable transmitter/receiver. */
@@ -174,7 +174,7 @@/* Issue a stop transmit, and wait for it. */ - cp->cp_cpcr =mk_cr_cmd (CPM_CR_CH_SMC1 , + cp->cp_cpcr =mk_cr_cmd (CPM_CR_CH_SMC (1 ),CPM_CR_STOP_TX ) |CPM_CR_FLG ;while (cp->cp_cpcr &CPM_CR_FLG ); }
@@ -191,7 +191,9 @@/* Initialize Tx/Rx parameters. */ - cp->cp_cpcr =mk_cr_cmd (CPM_CR_CH_SMC1 ,CPM_CR_INIT_TRX ) |CPM_CR_FLG ; + cp->cp_cpcr =mk_cr_cmd (CPM_CR_CH_SMC (1 ),CPM_CR_INIT_TRX ) + |CPM_CR_FLG ; +while (cp->cp_cpcr &CPM_CR_FLG );/* Enable transmitter/receiver.
@@ -206,7 +208,7 @@volatile char *buf;volatile smc_uart_t *up; - up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC1 ]; + up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC (1 )]; tbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_tbase];/* Wait for last character to go.
@@ -227,7 +229,7 @@volatile smc_uart_t *up;char c; - up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC1 ]; + up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC (1 )]; rbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];/* Wait for character to show up.
@@ -246,7 +248,7 @@volatile cbd_t *rbdf;volatile smc_uart_t *up; - up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC1 ]; + up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC (1 )]; rbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];return (!(rbdf->cbd_sc &BD_SC_EMPTY ));