* [RFC][PATCH 2.6.12-rc2 2/3] FCC Ethernet PlatformDevice support for 82xx
@ 2005-05-04 14:35 Vitaly Bordug
2005-05-04 23:08 ` Dan Malek
0 siblings, 1 reply; 2+ messages in thread
From: Vitaly Bordug @ 2005-05-04 14:35 UTC (permalink / raw)
To: linuxppc-embedded list
[-- Attachment #1: Type: text/plain, Size: 203 bytes --]
This patch adds some helper functions to the common CPM2 code in order
to prevent
direct *immr usage within network driver.
Signed-off-by: Vitaly Bordug<vbordug@ru.mvista.com>
--
Sincerely,
Vitaly
[-- Attachment #2: cpm2_addition.patch --]
[-- Type: text/x-patch, Size: 2793 bytes --]
diff -Nru a/arch/ppc/syslib/cpm2_common.c b/arch/ppc/syslib/cpm2_common.c
--- a/arch/ppc/syslib/cpm2_common.c 2005-05-04 16:52:10 +04:00
+++ b/arch/ppc/syslib/cpm2_common.c 2005-05-04 16:52:10 +04:00
@@ -112,6 +112,62 @@
*bp |= CPM_BRG_DIV16;
}
+void cpm2_cmd(uint cmd)
+{
+ cpmp->cp_cpcr = cmd | CPM_CR_FLG;
+ while(cpmp->cp_cpcr & CPM_CR_FLG)
+ cpu_relax();
+
+}
+
+s_iop* cpm2_pin_read(enum ioports port)
+{
+ s_iop* iop;
+ iop = (s_iop*)(&cpm2_immr->im_ioport);
+ return &iop[port];
+}
+
+void cpm2_pin_program(enum ioports port, int set, u32 par, u32 odr, u32 dir, u32 sor, u32 dat)
+{
+ s_iop *ioport = cpm2_pin_read(port);
+
+ pr_debug("Modified: iop[%d]: par %x odr %x dir %x sor %x dat %x\n",
+ par,odr,dir,sor,dat);
+
+ if(set)
+ {
+ if(dir)
+ ioport->pdir |= dir;
+ if(par)
+ ioport->ppar |= par;
+ if(par)
+ ioport->podr |= odr;
+ if(sor)
+ ioport->psor |= sor;
+ if(dat)
+ ioport->pdat |= dat;
+ } else {
+ if(dir)
+ ioport->pdir &= ~dir;
+ if(par)
+ ioport->ppar &= ~par;
+ if(odr)
+ ioport->podr &= ~odr;
+ if(sor)
+ ioport->psor &= ~sor;
+ if(dat)
+ ioport->pdat &= ~dat;
+ }
+}
+
+void cpm2_cpmux_alter_fcr(u32 set, u32 clear)
+{
+ u32 tmpval = cpm2_immr->im_cpmux.cmx_fcr;
+ tmpval &= ~clear;
+ tmpval |= set;
+ cpm2_immr->im_cpmux.cmx_fcr = tmpval;
+}
+
/*
* dpalloc / dpfree bits.
*/
diff -Nru a/include/asm-ppc/cpm2.h b/include/asm-ppc/cpm2.h
--- a/include/asm-ppc/cpm2.h 2005-05-04 16:52:10 +04:00
+++ b/include/asm-ppc/cpm2.h 2005-05-04 16:52:10 +04:00
@@ -75,6 +75,11 @@
#define CPM_CR_START_IDMA ((ushort)0x0009)
#define CPM_CR_STOP_IDMA ((ushort)0x000b)
+#define CPM_MCN_HDLC 0x00
+#define CPM_MCN_ATM 0x0A
+#define CPM_MCN_ETHERNET 0x0C
+#define CPM_MCN_TRANSPARENT 0x0F
+
#define mk_cr_cmd(PG, SBC, MCN, OP) \
((PG << 26) | (SBC << 21) | (MCN << 6) | OP)
@@ -116,6 +121,7 @@
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_cmd(uint cmd);
/* Buffer descriptors used by many of the CPM protocols.
*/
@@ -1038,6 +1044,28 @@
#define CMXSCR_TS4CS_CLK6 0x00000005 /* SCC4 Tx Clock Source is CLK6 */
#define CMXSCR_TS4CS_CLK7 0x00000006 /* SCC4 Tx Clock Source is CLK7 */
#define CMXSCR_TS4CS_CLK8 0x00000007 /* SCC4 Tx Clock Source is CLK8 */
+
+/* IOport stuff*/
+
+enum ioports{
+ PORTA,
+ PORTB,
+ PORTC,
+ PORTD,
+};
+
+typedef struct single_ioport{
+ u32 pdir;
+ u32 ppar;
+ u32 psor;
+ u32 podr;
+ u32 pdat;
+ u8 res1[12];
+}s_iop;
+
+void cpm2_pin_program(enum ioports port, int set, u32 par, u32 odr, u32 dir, u32 sor, u32 dat);
+void cpm2_cpmux_alter_fcr(u32 set, u32 clear);
+s_iop* cpm2_pin_read(enum ioports port);
#endif /* __CPM2__ */
#endif /* __KERNEL__ */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC][PATCH 2.6.12-rc2 2/3] FCC Ethernet PlatformDevice support for 82xx
2005-05-04 14:35 [RFC][PATCH 2.6.12-rc2 2/3] FCC Ethernet PlatformDevice support for 82xx Vitaly Bordug
@ 2005-05-04 23:08 ` Dan Malek
0 siblings, 0 replies; 2+ messages in thread
From: Dan Malek @ 2005-05-04 23:08 UTC (permalink / raw)
To: Vitaly Bordug; +Cc: linuxppc-embedded list
On May 4, 2005, at 10:35 AM, Vitaly Bordug wrote:
> This patch adds some helper functions to the common CPM2 code in order
> to prevent
> direct *immr usage within network driver.
No, please don't do this.
We don't need "helper" functions for the IO port in this manner.
I've got a new scheme that's been discussed, I just need a few
more "free" hours to finish it. Suffer with the current situation
for a little longer, we'll get this fixed the right way shortly.
Thanks.
-- Dan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-05-04 23:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-04 14:35 [RFC][PATCH 2.6.12-rc2 2/3] FCC Ethernet PlatformDevice support for 82xx Vitaly Bordug
2005-05-04 23:08 ` Dan Malek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).