LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   /dev/lp0 doesn't exists (https://www.linuxquestions.org/questions/linux-hardware-18/dev-lp0-doesnt-exists-281133/)

business_kid 09-30-2010 08:43 AM

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!"

RBEmerson 09-30-2010 09:02 AM

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!"...:)

business_kid 10-01-2010 03:09 AM

Every I/O card I had used 0x0378 for the port. Can you tweak things to try it?

RBEmerson 10-01-2010 08:17 AM

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. :)

business_kid 10-02-2010 09:14 AM

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)

RBEmerson 10-04-2010 06:55 PM

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. :)

smith283 01-11-2013 08:15 AM

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...................

business_kid 01-12-2013 03:34 AM

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

smith283 01-12-2013 11:07 AM

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 :D) 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?

smith283 01-12-2013 11:10 AM

Quote:

echo "options parport0 irq=7" >> /etc/modprobe.d/parport.conf
How this is helpful to me :/

smith283 01-12-2013 11:23 AM

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.

smith283 01-12-2013 11:28 AM

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,
write:pport_write,
read:pport_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;
}


All times are GMT -5. The time now is 08:14 PM.