[PARPORT] Parport patch for amiga


Joerg Dorchain (joerg@dorchain.net)
Sun, 5 Dec 1999 18:17:56 +0100


Hi all,

this makes the parport driver work again for 2.3.22. It patches both
parport_amiga (builtin port) and parport_mfc3 (MFC 3 port).
To be applied after Geert's Zorro-resource-patches.
Also this time works-or-not-reports are very desired (or does nobody use
a printer out there?)

Bye,

Joerg

--- linux-2.3.22/drivers/parport/init.c.org Sun Dec 5 18:10:24 1999
+++ linux-2.3.22/drivers/parport/init.c Sun Dec 5 18:36:27 1999
@@ -26,6 +26,8 @@
 
 extern int parport_pc_init(int *io, int *io_hi, int *irq, int *dma);
 extern int parport_sunbpp_init(void);
+extern int parport_amiga_init(void);
+extern int parport_mfc3_init(void);
 
 static int parport_setup_ptr __initdata = 0;
 
--- linux-2.3.22/drivers/parport/parport_amiga.c.org Sun Dec 5 16:28:47 1999
+++ linux-2.3.22/drivers/parport/parport_amiga.c Sun Dec 5 18:45:09 1999
@@ -1,6 +1,6 @@
 /* Low-level parallel port routines for the Amiga buildin port
  *
- * Author: Joerg Dorchain <dorchain@wirbel.com>
+ * Author: Joerg Dorchain <joerg@dorchain.net>
  *
  * This is a complete rewrite of the code, but based heaviy upon the old
  * lp_intern. code.
@@ -25,7 +25,7 @@
 #ifdef DEBUG
 #define DPRINTK printk
 #else
-#define DPRINTK(format, args...)
+static inline void DPRINTK(void *nothing, ...) {}
 #endif
 
 static struct parport *this_port = NULL;
@@ -90,7 +90,7 @@
         return old;
 }
 
-
+#if 0 /* currently unused */
 static unsigned char status_pc_to_amiga(unsigned char status)
 {
         unsigned char ret = 1;
@@ -107,6 +107,7 @@
                 /* not connected */;
         return ret;
 }
+#endif
 
 static unsigned char status_amiga_to_pc(unsigned char status)
 {
@@ -138,6 +139,28 @@
         parport_generic_irq(irq, (struct parport *) dev_id, regs);
 }
 
+static void amiga_enable_irq(struct parport *p)
+{
+ enable_irq(IRQ_AMIGA_CIAA_FLG);
+}
+
+static void amiga_disable_irq(struct parport *p)
+{
+ disable_irq(IRQ_AMIGA_CIAA_FLG);
+}
+
+static void amiga_data_forward(struct parport *p)
+{
+ DPRINTK("forward\n");
+ ciaa.ddrb = 0xff; /* all pins output */
+}
+
+static void amiga_data_reverse(struct parport *p)
+{
+ DPRINTK("reverse\n");
+ ciaa.ddrb = 0; /* all pins input */
+}
+
 static void amiga_init_state(struct pardevice *dev, struct parport_state *s)
 {
         s->u.amiga.data = 0;
@@ -162,16 +185,6 @@
         ciab.ddra |= (ciab.ddra & 0xf8) | s->u.amiga.statusdir;
 }
 
-static void amiga_enable_irq(struct parport *p)
-{
- enable_irq(IRQ_AMIGA_CIAA_FLG);
-}
-
-static void amiga_disable_irq(struct parport *p)
-{
- disable_irq(IRQ_AMIGA_CIAA_FLG);
-}
-
 static void amiga_inc_use_count(void)
 {
         MOD_INC_USE_COUNT;
@@ -195,8 +208,8 @@
         amiga_enable_irq,
         amiga_disable_irq,
 
- NULL, /* data_forward */
- NULL, /* data_reverse */
+ amiga_data_forward,
+ amiga_data_reverse,
 
         amiga_init_state,
         amiga_save_state,
@@ -205,18 +218,18 @@
         amiga_inc_use_count,
         amiga_dec_use_count,
 
- NULL, /* epp_write_data */
- NULL, /* epp_read_data */
- NULL, /* epp_write_addr */
- NULL, /* epp_read_addr */
-
- NULL, /* ecp_write_data */
- NULL, /* ecp_read_data */
- NULL, /* ecp_write_addr */
-
- NULL, /* compat_write_data */
- NULL, /* nibble_read_data */
- NULL, /* byte_read_data */
+ parport_ieee1284_epp_write_data,
+ parport_ieee1284_epp_read_data,
+ parport_ieee1284_epp_write_addr,
+ parport_ieee1284_epp_read_addr,
+
+ parport_ieee1284_ecp_write_data,
+ parport_ieee1284_ecp_read_data,
+ parport_ieee1284_ecp_write_addr,
+
+ parport_ieee1284_write_compat,
+ parport_ieee1284_read_nibble,
+ parport_ieee1284_read_byte,
 };
 
 /* ----------- Initialisation code --------------------------------- */
@@ -252,7 +265,7 @@
 
 #ifdef MODULE
 
-MODULE_AUTHOR("Joerg Dorchain");
+MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
 MODULE_DESCRIPTION("Parport Driver for Amiga builtin Port");
 MODULE_SUPPORTED_DEVICE("Amiga builtin Parallel Port");
 
--- linux-2.3.22/drivers/parport/parport_mfc3.c.org Sun Dec 5 16:28:35 1999
+++ linux-2.3.22/drivers/parport/parport_mfc3.c Sun Dec 5 18:44:30 1999
@@ -1,6 +1,6 @@
 /* Low-level parallel port routines for the Multiface 3 card
  *
- * Author: Joerg Dorchain <dorchain@wirbel.com>
+ * Author: Joerg Dorchain <joerg@dorchain.net>
  *
  * (C) The elitist m68k Users(TM)
  *
@@ -46,6 +46,10 @@
  * -------+-----+-----+---------------------------------------------------------
  *
  * Should be enough to understand some of the driver.
+ *
+ * Per convention for normal use the port registers are visible.
+ * If you need the data direction registers, restore the value in the
+ * control register.
  */
 
 #include "multiface.h"
@@ -67,7 +71,7 @@
 #ifdef DEBUG
 #define DPRINTK printk
 #else
-static inline int DPRINTK() {return 0;}
+static inline int DPRINTK(void *nothing, ...) {return 0;}
 #endif
 
 static struct parport *this_port[MAX_MFC] = {NULL, };
@@ -95,10 +99,6 @@
 {
         unsigned char ret = 32|64;
 
- if (control & PARPORT_CONTROL_DIRECTION) /* XXX: What is this? */
- ;
- if (control & PARPORT_CONTROL_INTEN) /* XXX: What is INTEN? */
- ;
         if (control & PARPORT_CONTROL_SELECT) /* XXX: What is SELECP? */
                 ret &= ~32; /* /SELECT_IN */
         if (control & PARPORT_CONTROL_INIT) /* INITP */
@@ -112,7 +112,7 @@
 
 static unsigned char control_mfc3_to_pc(unsigned char control)
 {
- unsigned char ret = PARPORT_CONTROL_INTEN | PARPORT_CONTROL_STROBE
+ unsigned char ret = PARPORT_CONTROL_STROBE
                           | PARPORT_CONTROL_AUTOFD | PARPORT_CONTROL_SELECT;
 
         if (control & 128) /* /INITP */
@@ -146,7 +146,7 @@
         return old;
 }
 
-
+#if 0 /* currently unused */
 static unsigned char status_pc_to_mfc3(unsigned char status)
 {
         unsigned char ret = 1;
@@ -163,6 +163,7 @@
                 ret |= 16;
         return ret;
 }
+#endif
 
 static unsigned char status_mfc3_to_pc(unsigned char status)
 {
@@ -182,11 +183,13 @@
         return ret;
 }
 
+#if 0 /* currently unused */
 static void mfc3_write_status( struct parport *p, unsigned char status)
 {
 DPRINTK("write_status %02x\n",status);
         pia(p)->ppra = (pia(p)->ppra & 0xe0) | status_pc_to_mfc3(status);
 }
+#endif
 
 static unsigned char mfc3_read_status(struct parport *p)
 {
@@ -197,11 +200,13 @@
         return status;
 }
 
+#if 0 /* currently unused */
 static void mfc3_change_mode( struct parport *p, int m)
 {
         /* XXX: This port only has one mode, and I am
         not sure about the corresponding PC-style mode*/
 }
+#endif
 
 static int use_cnt = 0;
 
@@ -217,12 +222,33 @@
                         }
 }
 
-static int mfc3_claim_resources(struct parport *p)
+static void mfc3_enable_irq(struct parport *p)
+{
+ pia(p)->crb |= PIA_C1_ENABLE_IRQ;
+}
+
+static void mfc3_disable_irq(struct parport *p)
+{
+ pia(p)->crb &= ~PIA_C1_ENABLE_IRQ;
+}
+
+static void mfc3_data_forward(struct parport *p)
+{
+ DPRINTK("forward\n");
+ pia(p)->crb &= ~PIA_DDR; /* make data direction register visible */
+ pia(p)->pddrb = 255; /* all pins output */
+ pia(p)->crb |= PIA_DDR; /* make data register visible - default */
+}
+
+static void mfc3_data_reverse(struct parport *p)
 {
-DPRINTK("claim_resources\n");
+ DPRINTK("reverse\n");
+ pia(p)->crb &= ~PIA_DDR; /* make data direction register visible */
+ pia(p)->pddrb = 0; /* all pins input */
+ pia(p)->crb |= PIA_DDR; /* make data register visible - default */
 }
 
-static void mfc3_init_state(struct parport_state *s)
+static void mfc3_init_state(struct pardevice *dev, struct parport_state *s)
 {
         s->u.amiga.data = 0;
         s->u.amiga.datadir = 255;
@@ -254,16 +280,6 @@
         pia(p)->cra |= PIA_DDR;
 }
 
-static void mfc3_enable_irq(struct parport *p)
-{
- pia(p)->crb |= PIA_C1_ENABLE_IRQ;
-}
-
-static void mfc3_disable_irq(struct parport *p)
-{
- pia(p)->crb &= ~PIA_C1_ENABLE_IRQ;
-}
-
 static void mfc3_inc_use_count(void)
 {
         MOD_INC_USE_COUNT;
@@ -287,8 +303,8 @@
         mfc3_enable_irq,
         mfc3_disable_irq,
 
- NULL, /* data_forward - FIXME */
- NULL, /* data_reverse - FIXME */
+ mfc3_data_forward,
+ mfc3_data_reverse,
 
         mfc3_init_state,
         mfc3_save_state,
@@ -323,11 +339,11 @@
         if (!MACH_IS_AMIGA)
                 return 0;
 
- while ((z = zorro_find(ZORRO_PROD_BSC_MULTIFACE_III, z))) {
+ while ((z = zorro_find_device(ZORRO_PROD_BSC_MULTIFACE_III, z))) {
                 unsigned long piabase = z->resource.start+PIABASE;
                 if (!request_mem_region(piabase, sizeof(struct pia), "PIA"))
                         continue;
- strcpy(z->name, "MultiFace III Multi I/O");
+ strcpy(z->name, "MultiFace III MC6821 PIA");
                 pp = (struct pia *)ZTWO_VADDR(piabase);
                 if (pias < MAX_MFC) {
                         pp->crb = 0;
@@ -353,8 +369,6 @@
                                                 if (request_irq(IRQ_AMIGA_PORTS, mfc3_interrupt, SA_SHIRQ, p->name, &pp_mfc3_ops))
                                                         use_cnt--;
 
- if (parport_probe_hook)
- (*parport_probe_hook)(p);
                                 p->private_data = (void *)piabase;
                                 parport_announce_port (p);
                         }
@@ -365,7 +379,7 @@
 
 #ifdef MODULE
 
-MODULE_AUTHOR("Joerg Dorchain");
+MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
 MODULE_DESCRIPTION("Parport Driver for Multiface 3 expansion cards Paralllel Port");
 MODULE_SUPPORTED_DEVICE("Multiface 3 Parallel Port");
 

-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --



This archive was generated by hypermail 2.0b3 on Sun 05 Dec 1999 - 12:56:15 EST