parport: add parallel port support for SGI O2
PATCH v2 1/1 parport: add parallel port support for SGI O2
From: Arnaud Giersch <[email protected]>
Add support for the built-in parallel port on SGI O2 (a.k.a. IP32). Define a new configuration option: PARPORT_IP32. The module is named parport_ip32.
Hardware support for SPP, EPP and ECP modes along with DMA support when available are currently implemented.
---
Changes since previous version sent on January 9, 2006
(http://marc.theaimsgroup.com/?l=linux-kernel&m=113684000618245):
* Address comments from Randy Dunlap <rdunlap_at_xenotime.net>, that is:
- Remove useless memory barriers.
- Review function inlining.
- Review kernel docs.
- Fix style.
- Fix typos.
* Remove useless parport_ip32_{in,out} functions.
* Review locking in DMA operations.
* Simplify parport_ip32_ecp_supported().
* Fix includes.
drivers/parport/Kconfig | 9 drivers/parport/Makefile | 1 drivers/parport/parport_ip32.c | 2217 +++++++++++++++++++++++++++++++ include/linux/parport.h | 6 4 files changed, 2233 insertions(+)
drivers/parport/Kconfig +9 -0
@@ -90,6 +90,15 @@ config PARPORT_ARC depends on ARM && PARPORT select PARPORT_NOT_PC +config PARPORT_IP32 + tristate "SGI IP32 builtin port (EXPERIMENTAL)" + depends on SGI_IP32 && PARPORT && EXPERIMENTAL + select PARPORT_NOT_PC + help + Say Y here if you need support for the parallel port on + SGI O2 machines. This code is also available as a module (say M), + called parport_ip32. If in doubt, saying N is the safe plan. + config PARPORT_AMIGA tristate "Amiga builtin port" depends on AMIGA && PARPORT
drivers/parport/Makefile +1 -0
@@ -17,3 +17,4 @@ obj-$(CONFIG_PARPORT_MFC3) += parport_mf obj-$(CONFIG_PARPORT_ATARI) += parport_atari.o obj-$(CONFIG_PARPORT_SUNBPP) += parport_sunbpp.o obj-$(CONFIG_PARPORT_GSC) += parport_gsc.o +obj-$(CONFIG_PARPORT_IP32) += parport_ip32.o
drivers/parport/parport_ip32.c +2217 -0
2,217 lines not on this page · raw message
include/linux/parport.h +6 -0
@@ -128,6 +128,11 @@ struct amiga_parport_state {unsigned char statusdir;/* ciab.ddrb & 7 */ }; +struct ip32_parport_state { +unsigned int dcr; +unsigned int ecr; +}; + struct parport_state { union { struct pc_parport_state pc;
@@ -135,6 +140,7 @@ struct parport_state {struct ax_parport_state ax;struct amiga_parport_state amiga;/* Atari has not state. */ +struct ip32_parport_state ip32;void *misc; } u; };
Quoted 9 lines · Arnaud Giersch
From: Arnaud Giersch <[email protected]>
Add support for the built-in parallel port on SGI O2 (a.k.a. IP32). Define a new configuration option:
PARPORT_IP32. The module is namedparport_ip32.Hardware support for SPP, EPP and ECP modes along with DMA support when available are currently implemented.
Nice looking driver. Big.
It does rather a lot of
if (foo) do_something();
whereas we prefer
if (foo) do_something();
but if that was a blocker, we wouldn't have any drivers.
drivers/parport/parport_ip32.c line 474
Quoted 9 lines
drivers/parport/parport_ip32.c +9
-0+static void parport_ip32_dma_setup_context (unsigned int limit) +{ +unsigned long flags; + +spin_lock_irqsave (&parport_ip32_dma.lock, flags); +if (parport_ip32_dma.left >0 ) { +volatile u64 __iomem *ctxreg = (parport_ip32_dma.ctx ==0 ) ? + &mace->perif.ctrl.parport.context_a : + &mace->perif.ctrl.parport.context_b;
Does this need to be volatile? writeq() should do the right thing.
drivers/parport/parport_ip32.c line 1088
Quoted 11 lines
drivers/parport/parport_ip32.c +11
-0+static size_t parport_ip32_epp_read (void __iomem *eppreg, +struct parport *p,void *buf, +size_t len,int flags) +{ +struct parport_ip32_private *const priv = p->physport->private_data; +size_t got; +parport_ip32_set_mode (p,ECR_MODE_EPP ); +parport_ip32_data_reverse (p); +parport_ip32_write_control (p, DCR_nINIT); +if ((flags &PARPORT_EPP_FAST ) && (len >1 )) { +readsb (eppreg, buf, len);
readsb() is a mips thing, and doesn't seem to be documented. What does it do, and why does the driver use it (only) here?
Quoted 6 lines
drivers/parport/parport_ip32.c +5
-0+writesb (eppreg, buf, len); +static unsigned int parport_ip32_fifo_wait_break (struct parport *p, +unsigned long expire) +{ +cond_resched ();
drivers/parport/parport_ip32.c line 1230
Quoted 10 lines
drivers/parport/parport_ip32.c +10
-0+if (time_after (jiffies, expire)) { + printk(KERN_DEBUG PPIP32 + "%s: FIFO write timed out\n", p->name); +return 1 ; + } +if (signal_pending (current)) { + printk(KERN_DEBUG PPIP32 + "%s: Signal pending\n", p->name); +return 1 ; + }
This printk could be a bit noisy, if someone hoses a signal stream at a printing program.
Quoted 7 lines · Andrew Morton
Quoted 5 lines
From: Arnaud Giersch <[email protected]>
Add support for the built-in parallel port on SGI O2 (a.k.a. IP32). Define a new configuration option:
PARPORT_IP32. The module is namedparport_ip32.Nice looking driver. Big.
Thanks.
Quoted 8 lines
It does rather a lot of
if (foo) do_something();whereas we prefer
if (foo) do_something();
Those are limited to the parport_ip32_dump_state() function. The rationale is that this function is only here for debugging purpose, and I did not want to make it longer than it already is.
I will correct the style.
Quoted 1 line
Quoted 1 line
+static void
parport_ip32_dma_setup_context(unsigned int limit)
[...]
Quoted 5 lines
drivers/parport/parport_ip32.c line 474
Quoted 3 lines
drivers/parport/parport_ip32.c +3
-0+volatile u64 __iomem *ctxreg = (parport_ip32_dma.ctx ==0 ) ? + &mace->perif.ctrl.parport.context_a : + &mace->perif.ctrl.parport.context_b;Does this need to be volatile?
writeq()should do the right thing.
The "volatile" is here for type consistency. Both variables "mace->perif.ctrl.parport.context_a" and "context_b" (defined in include/asm-mips/ip32/mace.h) are from type "volatile u64". Omitting the "volatile" qualifier for "ctxreg" would make gcc and sparse complain.
I will add a comment to explain it in the code.
Quoted 1 line
Quoted 1 line
+static
size_tparport_ip32_epp_read(void__iomem*eppreg,
[...]
Quoted 7 lines
drivers/parport/parport_ip32.c line 1088
Quoted 2 lines
drivers/parport/parport_ip32.c +2
-0+if ((flags &PARPORT_EPP_FAST ) && (len >1 )) { +readsb (eppreg, buf, len);
readsb()is a mips thing, and doesn't seem to be documented. What does it do, and why does the driver use it (only) here?drivers/parport/parport_ip32.c line 1127
Quoted 1 line
drivers/parport/parport_ip32.c +1
-0+writesb (eppreg, buf, len);
readsb() and writesb() are like ioread8_rep() and iowrite8_rep(). The io{read,write} family functions are however not available in the linux-mips.org tree.
The usage of readsb() here is similar to that of insb() in the corresponding code of the parport_pc driver.
Quoted 1 line
Quoted 1 line
+static unsigned int parport_ip32_fifo_wait_break(struct parport *p,
[...]
Quoted 8 lines
drivers/parport/parport_ip32.c line 1230
Quoted 5 lines
drivers/parport/parport_ip32.c +5
-0+if (signal_pending (current)) { + printk(KERN_DEBUG PPIP32 + "%s: Signal pending\n", p->name); +return 1 ; + }This printk could be a bit noisy, if someone hoses a signal stream at a printing program.
I did not realized that. I will try to correct the problem.
Thank you for your attention.
Arnaud
Mardi 24 janvier 2006, vers 00:38:57 (+0100), j'ai écrit:
Quoted 1 line
I will correct the style.
[...]
Quoted 1 line
I will add a comment to explain it in the code.
[...]
Quoted 1 line
I did not realized that. I will try to correct the problem.
An updated version is available at
http://arnaud.giersch.free.fr/parport_ip32/parport_ip32-0.6.patch.gz
Since all changes are non-functional ones, I did not want to flood the lists again with the full patch.
Changes are:
* Address comments from Andrew Morton <akpm_at_osdl.org>:
- Style: avoid single line "if" and "case" statements.
- Turn some printk() into pr_debug1(), so that they only exist in debugging mode.
- Add a comment about "volatile".
- Add a comment about readsb() and writesb().
* Only define DEBUG_PARPORT_IP32 if it is not already defined.
* Remove the CVS $Id$ line.
Arnaud