LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 09-30-2010, 08:43 AM   #16
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,980

Rep: Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630

Ran this for years, and trying to remember...

Depending on your parallel port mode it should be parport_pc (bidirectional) lp(?) (unidirectional). Parallel ports like irq 7, and 0x0378 as an i/o address. To quote Luc Picard (Startrek)

"Make it so!"
 
Old 09-30-2010, 09:02 AM   #17
RBEmerson
Member
 
Registered: May 2006
Location: Skippack
Distribution: SuSE Linux 11.1
Posts: 63

Rep: Reputation: 15
IRQ 7 and port 0x378 is fine for a built-in parallel port. It's what I used in the old machine. The new machine doesn't have any serial or parallel ports, just USB and a single Firewire port (plus ethernet and audio, of course), which is why I'm using a PCI card to supply the needed port. Dmseg keeps saying a parallel port was found at 0xc800 and IRQ 19. That seems to be close to right because I can cram ASCII into /dev/lp0 and at least see the printer respond. The problem is the output is consistently unusable. As things stand now, Picard's commands would become "make it sew! Enrage!"...
 
Old 10-01-2010, 03:09 AM   #18
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,980

Rep: Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630
Every I/O card I had used 0x0378 for the port. Can you tweak things to try it?
 
Old 10-01-2010, 08:17 AM   #19
RBEmerson
Member
 
Registered: May 2006
Location: Skippack
Distribution: SuSE Linux 11.1
Posts: 63

Rep: Reputation: 15
Remember this is a PCI card and doesn't use the 0x378.

This is a good place to wrap up the story. I decided I need a parallel port like a Ferrari needs a buggy whip socket and replaced the LJ-5P with a Brother HL-5370DW, now sitting on my wired net. End of problem. (Anyone in the Phila., PA area wanting a nicely broken in LP-5J is encouraged to PM me.)

My recollection of the old server is three modules were used, lp, parport, and parport_pc. Lsmod kept saying the new server was loading lp, ppdev, parport_pc, and parport. Something seems odd in that. Keep in mind that things seemed to work well enough that YaST2 saw the right port(s) and IRQ but any attempt to print failed. The "hello, world" experiment shows that something is chewing up even a simple ASCII stream. Fixing this is above my skill level and, frankly, I haven't the time to make a career of fixing the problem. My thanks for all of the suggestions and advice.
 
Old 10-02-2010, 09:14 AM   #20
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,980

Rep: Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630
OK, does your parport show in /proc/ioports and /proc/interrupts?

If so, look at lshal. You can fiddle things there, but I'm not the man to ask - I just know it can be done.
FWIW, here's the output from lshal on my box (Parallel port shows but never used)
Quote:
udi = '/org/freedesktop/Hal/devices/pnp_PNP0401'
info.linux.driver = 'parport_pc' (string)
info.parent = '/org/freedesktop/Hal/devices/computer' (string)
info.product = 'ECP printer port' (string)
info.subsystem = 'pnp' (string)
info.udi = '/org/freedesktop/Hal/devices/pnp_PNP0401' (string)
linux.hotplug_type = 2 (0x2) (int)
linux.subsystem = 'pnp' (string)
linux.sysfs_path = '/sys/devices/pnp0/00:08' (string)
pnp.description = 'ECP printer port' (string)
pnp.id = 'PNP0401' (string)

udi = '/org/freedesktop/Hal/devices/ppdev_parport0'
info.capabilities = {'ppdev'} (string list)
info.category = 'ppdev' (string)
info.parent = '/org/freedesktop/Hal/devices/pnp_PNP0401' (string)
info.product = 'Parallel Port Device' (string)
info.subsystem = 'ppdev' (string)
info.udi = '/org/freedesktop/Hal/devices/ppdev_parport0' (string)
linux.device_file = '/dev/parport0' (string)
linux.hotplug_type = 2 (0x2) (int)
linux.subsystem = 'ppdev' (string)
linux.sysfs_path = '/sys/devices/pnp0/00:08/ppdev/parport0' (string)
 
Old 10-04-2010, 06:55 PM   #21
RBEmerson
Member
 
Registered: May 2006
Location: Skippack
Distribution: SuSE Linux 11.1
Posts: 63

Rep: Reputation: 15
Thanks for the pointers. However, I literally pulled the plug on the whole issue and went with a networked printer. Hardly the hero's way out, I admit, but the press of other projects forced me to the quick solution of changing the printer.
 
Old 01-11-2013, 08:15 AM   #22
smith283
Member
 
Registered: Aug 2012
Posts: 39

Rep: Reputation: Disabled
Hey mates,
Can anybody tell me how can i unregister the parport interrupt handler at IRQ7 from /proc/interrupts.
cz i hv to register my handler at irq7

thnx, reply fast plzzzzzzzzzzzzzzzzzzzzzzzz...................
 
Old 01-12-2013, 03:34 AM   #23
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,980

Rep: Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630
Spare us this.
Quote:
thnx, reply fast plzzzzzzzzzzzzzzzzzzzzzzzz...................


To deal with your issue, irq7 or IRQ7 will usually be read as the same thing. My /proc/interrupts doesn't have either
Quote:
0: 128 0 14 1 IO-APIC-edge timer
1: 2222 36 5212 48 IO-APIC-edge i8042
8: 1 1 7 0 IO-APIC-edge rtc0
If you really think it matters have you tried specifying it as an option in modprobe.d? Something like
Quote:
echo "options parport0 irq=7" >> /etc/modprobe.d/parport.conf
 
Old 01-12-2013, 11:07 AM   #24
smith283
Member
 
Registered: Aug 2012
Posts: 39

Rep: Reputation: Disabled
Actually im working with hardware Interrupts on parallel port.
So, for that i hv to register my handler at IRQ7 (and i know irq7 = IRQ7 ) but call to request_irq() is failing as the original parallel port handler has already acquired irq7.
What should i do to register my handler???

Quote:
echo "options parport0 irq=7" >> /etc/modprobe.d/parport.conf
And what the above line will do?
 
Old 01-12-2013, 11:10 AM   #25
smith283
Member
 
Registered: Aug 2012
Posts: 39

Rep: Reputation: Disabled
Quote:
echo "options parport0 irq=7" >> /etc/modprobe.d/parport.conf
How this is helpful to me :/
 
Old 01-12-2013, 11:23 AM   #26
smith283
Member
 
Registered: Aug 2012
Posts: 39

Rep: Reputation: Disabled
Quote:
static int __init init_func(void)
{
struct resource *ret_ptr;
int ret=0;
int i=0;
ret_ptr = NULL;

#ifdef smith
printk(KERN_INFO "\nBEGIN: %s\n",__func__);
#endif

#ifdef smith
printk(KERN_INFO "registring device.....\n");
#endif

if(majorno==0)
{
ret=alloc_chrdev_region(&dev,MINORNO,NO_OF_DEV,DEV_NAME);
if(ret!=0)
{
#ifdef smith
printk(KERN_ERR "device registration failure\n");
#endif
goto OUT;
}
else
{
#ifdef smith
printk(KERN_INFO "Regisration successfull\n");
#endif

minorno=MINOR(dev);
majorno=MAJOR(dev);

#ifdef smith
printk(KERN_INFO "MAJOR_NO %d\n",majorno);
printk(KERN_INFO "MINOR_NO %d\n",minorno);
#endif

new_dev=dev;
}
}
else
{
ret=register_chrdev_region(new_dev,nod,DEV_NAME);
if(ret<0)
{
#ifdef smith
printk(KERN_ERR "device reregistration failed\n");
#endif
}
else
#ifdef smith
printk(KERN_INFO "Reregistration successfull.....\n");
#endif
}

sculldev=(struct SCULLDEV *)kmalloc(sizeof(struct SCULLDEV) * nod,GFP_KERNEL);
if(!sculldev)
{
#ifdef smith
printk(KERN_ERR"kmalloc failure\n");
#endif
goto OUT;

}
else
{
#ifdef smith
printk(KERN_INFO"kmalloc succesfull...\n");
#endif
}

memset(sculldev,'\0',sizeof(struct SCULLDEV) * nod);
#ifdef smith
printk(KERN_INFO "memset is succesfull\n");
#endif

sema_init(&sculldev[0].sem, 1);
sculldev[0].irq = 7;

#ifdef smith
printk(KERN_INFO "sema_init: Semaphore is initialised...\n");
#endif

cdev_init(&sculldev[0].cdev,&myops);
#ifdef smith
printk(KERN_INFO "cdev_init: initializing...\n");
#endif
cdev_add(&sculldev[0].cdev,dev,1);

for(i=0;i<(nod-1);i++)
{
sculldev[i+1].irq = 7;
sema_init(&sculldev[i+1].sem,1);
cdev_func(&sculldev[i+1],i);
}

ret = check_region(DATA, 3);
if(ret<0)
{
#ifdef smith
printk(KERN_INFO "Ports not available\n");
#endif

release_region(DATA,3);

#ifdef smith
printk(KERN_INFO "Ports released\n");
#endif
}

ret_ptr = request_region(DATA,3,DEV_NAME);
if(ret_ptr==NULL)
{
#ifdef smith
printk(KERN_INFO "Ports allocation failure\n");
#endif
}
else
{
#ifdef smith
printk(KERN_INFO "Ports allocated\n");
#endif
}

if(sculldev->irq >= 0)
{
ret = request_irq(sculldev->irq,(irq_handler_t)driver_interrupt,IRQF_SHARED,DEV_NAME,(void *)sculldev);
if(ret)
{
printk(KERN_INFO "cant assign irq %i\n",sculldev->irq);
// sculldev->irq = -1;
// return -EBUSY;
}
else
{
printk(KERN_INFO "Handler registered\n");
printk(KERN_INFO "enables interrupts\n");
outb(0x10,DATA+2);
}
}

#ifdef smith
printk(KERN_INFO "END: %s\n",__func__);
#endif

return 0;

OUT:
return -1;
}
This is my init function. And the request_irq() call fails.
 
Old 01-12-2013, 11:28 AM   #27
smith283
Member
 
Registered: Aug 2012
Posts: 39

Rep: Reputation: Disabled
My header file....

Quote:
#include<linux/init.h>
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/fs.h>
#include<linux/slab.h>
#include<linux/cdev.h>
#include<asm/uaccess.h>
#include<linux/semaphore.h>
#include<linux/completion.h>
#include<linux/ioport.h>
#include<linux/io.h>
#include<linux/interrupt.h>
#include<linux/sched.h>
#include<linux/wait.h>
#include<linux/delay.h>
#include<linux/irq.h>
#include<linux/irqnr.h>
#include<linux/irqdesc.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("smith");
MODULE_DESCRIPTION("Parallel Port Driver");

#ifndef smith
#define smith
#endif

#ifndef MINORNO
#define MINORNO 0
#endif

#ifndef DEV_NAME
#define DEV_NAME "smith_devis"
#endif

#ifndef NO_OF_DEV
#define NO_OF_DEV 5
#endif

#ifndef MAJORNO
#define MAJORNO 0
#endif

#ifndef DATA
#define DATA 0x378
#endif

#ifndef STATUS
#define STATUS 0x379
#endif

#ifndef CONTROL
#define CONTROL 0x37a
#endif

dev_t dev;
dev_t new_dev;
int ret=0;
int flag=0;

int minorno=MINORNO;
int nod=NO_OF_DEV;
int majorno=MAJORNO;

static DECLARE_WAIT_QUEUE_HEAD(queue);

struct SCULLDEV
{
int irq;
struct cdev cdev;
struct semaphore sem;
};

struct SCULLDEV *sculldev;
struct irq_desc *desc;

irqreturn_t driver_interrupt(int, void *, struct pt_regs *);
int scull_open(struct inode *, struct file *);
int scull_release(struct inode *, struct file *);

ssize_t pport_write(struct file *, const char __user *, size_t, loff_t *);
ssize_t pport_read(struct file *, char __user *, size_t, loff_t *);

struct file_operations myops=
{
open:scull_open,
release:scull_release,
writeport_write,
readport_read,
};



int cdev_func(struct SCULLDEV *, int);

int cdev_func(struct SCULLDEV *local_sculldev,int val)
{
new_dev=MKDEV(MAJOR(new_dev),(MINOR(new_dev)) + 1);

cdev_init(&local_sculldev->cdev,&myops);
#ifdef smith
printk(KERN_INFO "cdev_init: initializing...\n");
#endif

ret=cdev_add(&local_sculldev->cdev,new_dev,1);
if(ret!=0)
{
printk(KERN_ERR "cdev_add: failure\n");
}
else
{
printk(KERN_INFO "cdev_add: addtion successful\n");

minorno=MINOR(new_dev);
majorno=MAJOR(new_dev);

#ifdef smith
printk(KERN_INFO "MAJOR_NO %d\n",majorno);
printk(KERN_INFO "MINOR_NO %d\n",minorno);
#endif

}

return 0;
}
My handler function...

Quote:
irqreturn_t driver_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
#ifdef smith
printk(KERN_INFO "Interrupt Handler executing:\n");
#endif

flag = 1;
wake_up_interruptible(&queue);

return (irqreturn_t)IRQ_HANDLED;
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why no /dev/lp0 in CUPS sharper Slackware 0 12-25-2004 07:19 PM
/dev/lp0 not recognized tiagobt Linux - General 8 09-27-2004 01:26 PM
Who stole my /dev/lp0 ? Timer Linux - Hardware 0 07-13-2004 03:26 PM
No /dev/lp0 in Gentoo 1.4 darin3200 Linux - General 2 12-28-2003 06:54 PM
Redirection > /dev/lp0 XT8088 Linux - Newbie 2 09-20-2003 06:36 PM


All times are GMT -5. The time now is 07:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration