Filedes is not a tty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear serial folks,
I am currently trying to port an out-of-tree 8250-driver to be ready for
upstreaming. The UART port we have in our FPGA is a 16550, and the driver is an
MCB-Driver. 
In my system I got two ports. serial8250_register_8250_port() returns
"8" and "9". If I understood things right, these would be associated to
/dev/ttyS8 and /dev/ttyS9. However, if I try to open a terminal (picocom
in my case), I get an error: "Filedes is not a tty".

My dmesg output shows my prints, but nothing about the tty's.
I don't know what I am doing wrong here, I don't see relevant difference
to our legacy driver, which always worked.

I hope someone can point me to the right direction, and I would really
appreciate any hint or help.

The current state of the driver is attached below.

Best regards,
Michael



#define DEBUG
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mcb.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
#include <linux/serial_8250.h>

struct serial_8250_men_mcb_data {
        struct uart_8250_port uart;
	struct resource *mem;
        int line;
};

/*
 * The Z125 16550-compatible UART has no fixed base clock assigned
 * So, depending on the board we're on, we need to adjust the
 * parameter in order to really set the correct baudrate, and
 * do so if possible without user interaction
 */
static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
{
	/* use default value if board is not available below */
	u32 clkval = 1041666;

	dev_info(&mdev->dev, "%s on board %s\n",
		 dev_name(&mdev->dev),
		 mdev->bus->name);
	if  (strncmp(mdev->bus->name, "F075", 4) == 0)
		clkval = 1041666;
	else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
		clkval = 1843200;
	else if (strncmp(mdev->bus->name, "G215", 4) == 0)
		clkval = 1843200;
	else
		dev_info(&mdev->dev,
			 "board not detected, using default uartclk\n");

	clkval = clkval  << 4;
	dev_dbg(&mdev->dev, "using uartclk: %d\n", clkval);

	return clkval;
}

static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
			  const struct mcb_device_id *id)
{
        struct serial_8250_men_mcb_data *data;

        data = devm_kzalloc(&mdev->dev,
                        sizeof(struct serial_8250_men_mcb_data),
                        GFP_KERNEL);
        if (!data)
                return -ENOMEM;

        mcb_set_drvdata(mdev, data);
        data->uart.port.dev = mdev->dma_dev;
        spin_lock_init(&data->uart.port.lock);

	data->uart.port.type = PORT_16550;
        data->uart.port.flags = UPF_SKIP_TEST|UPF_SHARE_IRQ|UPF_BOOT_AUTOCONF;
        data->uart.port.iotype = UPIO_MEM;
	data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
	data->uart.port.regshift = 0;

	data->mem = mcb_get_resource(mdev, IORESOURCE_MEM);
	if (data->mem == NULL)
		return -ENXIO;
	dev_dbg(&mdev->dev, "got memory address: 0x%x\n", data->mem->start);

        data->uart.port.irq = mcb_get_irq(mdev);

        data->uart.port.membase = devm_ioremap_resource(&mdev->dev, data->mem);
	if(IS_ERR(data->uart.port.membase))
		return PTR_ERR_OR_ZERO(data->uart.port.membase);

	data->uart.port.mapbase = (unsigned long) data->mem->start;
	data->uart.port.iobase = data->uart.port.mapbase ;

	dev_dbg(&mdev->dev, "mapbase = 0x%x\n", data->uart.port.mapbase);
	dev_dbg(&mdev->dev, "iobase  = 0x%x\n", data->uart.port.iobase);

	/* ok, register the port */
	data->line = serial8250_register_8250_port(&data->uart);
	if (data->line < 0)
		return data->line;

	dev_dbg(&mdev->dev, "got line: %d\n", data->line);

	return 0;
}

static void serial_8250_men_mcb_remove(struct mcb_device *mdev)
{
        struct serial_8250_men_mcb_data *data = mcb_get_drvdata(mdev);

        if (data)
                serial8250_unregister_port(data->line);
}

static const struct mcb_device_id serial_8250_men_mcb_ids[] = {
        { .device = 0x7d },
        { }
};
MODULE_DEVICE_TABLE(mcb, serial_8250_men_mcb_ids);

static struct mcb_driver mcb_driver = {
        .driver = {
                .name = "8250_men_mcb",
                .owner = THIS_MODULE,
        },
        .probe = serial_8250_men_mcb_probe,
        .remove = serial_8250_men_mcb_remove,
        .id_table = serial_8250_men_mcb_ids,
};
module_mcb_driver(mcb_driver);

MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION( "MEN 16z125 8250 UART driver" );
MODULE_AUTHOR("Michael Moese <michael.moese@xxxxxx");
MODULE_ALIAS("mcb:16z125");
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux