mirror of
https://github.com/sjlongland/adv950.git
synced 2025-09-13 18:53:15 +10:00
Initial check-in, Advantech ADV950 serial driver v3.33.
This is a check-in of the Advantech ADV950 serial driver, used with the UNO-1150 series of industrial computers, as sourced from: http://support.advantech.com/support/DownloadSRDetail_New.aspx?SR_ID=1-GLBRCD&Doc_Source=Download This builds with kernel 3.0.1, but does not build with contemporary kernels (i.e. ones that are still in support). I suspect this is a hacked up version of Russel King's 8250 serial driver from 2001. First step, let's get it building against the current kernel (v4.10.1) and then we'll look at integrating this into 8250 proper.
This commit is contained in:
parent
4edd4fc438
commit
98f879a253
80
2.4/Makefile
Normal file
80
2.4/Makefile
Normal file
@ -0,0 +1,80 @@
|
||||
#
|
||||
# Makefile for the PCI-954/16C950 serial drivers
|
||||
#
|
||||
# Advantech eAutomation Division
|
||||
#
|
||||
|
||||
ADVMOD := adv950
|
||||
UNAME := $(shell uname -r)
|
||||
ifeq "$(UNAME)""2.4.27-2-386"
|
||||
LINUX_SRC= /usr/src/kernel-headers-2.4.27-2-386
|
||||
else
|
||||
LINUX_SRC= /usr/src/linux-2.4
|
||||
endif
|
||||
|
||||
CONFIG_PATH = config-$(shell uname -r)
|
||||
RESULT = $(shell grep CONFIG_DEVFS_FS=y /boot/$(CONFIG_PATH))
|
||||
|
||||
ifeq ($(RESULT),CONFIG_DEVFS_FS=y)
|
||||
SERIAL_NAME = ttap
|
||||
SERIAL_FOLDER = ttap/%d
|
||||
CALLOUT_NAME= ttac
|
||||
CALLOUT_FOLDER = ttac/%d
|
||||
TEST_NAME = ttap/
|
||||
else
|
||||
SERIAL_NAME = ttyAP
|
||||
SERIAL_FOLDER = ttyAP
|
||||
CALLOUT_NAME= ttyAC
|
||||
CALLOUT_FOLDER = ttyAC
|
||||
TEST_NAME = ttyAP
|
||||
endif
|
||||
|
||||
MAX_TTY= 16
|
||||
MAX_TTY= 16
|
||||
ADV_TTY_MAJOR= 30
|
||||
ADV_TTY_CUMAJOR= 35
|
||||
|
||||
ARCH_FLAGS= $(I386_FLAGS)
|
||||
INCL_FLAGS= -I. -I$(LINUX_SRC)/include -I$(LINUX_SRC)/drivers/char
|
||||
DEF_FLAGS= -D__KERNEL__ -DLINUX \
|
||||
-DCONFIG_PCI -DCONFIG_SERIAL_MULTIPORT \
|
||||
-DEXPORT_SYMTAB
|
||||
I386_FLAGS= -march=i686 -O2 -Wall
|
||||
SERIAL_FLAGS= -DSERIAL_NAME=\"$(SERIAL_NAME)\" \
|
||||
-DCALLOUT_NAME=\"$(CALLOUT_NAME)\" \
|
||||
-DADV_TTY_MAJOR=$(ADV_TTY_MAJOR) \
|
||||
-DADV_TTY_CUMAJOR=$(ADV_TTY_CUMAJOR)
|
||||
CFLAGS= $(ARCH_FLAGS) $(INCL_FLAGS) $(DEF_FLAGS) $(SERIAL_FLAGS) -DMODULE
|
||||
CC= gcc
|
||||
|
||||
default: $(ADVMOD).o
|
||||
|
||||
$(ADVMOD).o: serial.c
|
||||
$(CC) $(CFLAGS) -c serial.c -o $(ADVMOD).o
|
||||
|
||||
install: default
|
||||
$(shell if grep $(ADVMOD) /proc/modules > /dev/null ; then \
|
||||
rmmod $(ADVMOD) ; fi)
|
||||
@insmod $(ADVMOD).o
|
||||
|
||||
node: default install
|
||||
@echo "Creating serial device nodes $(SERIAL_NAME) ..."
|
||||
@echo "The Result is $(RESULT)"
|
||||
@../advmknod $(SERIAL_NAME) \
|
||||
$$(awk '$$2=="$(SERIAL_FOLDER)" {print $$1}' /proc/devices) $(MAX_TTY)
|
||||
@echo "Creating callout device nodes $(CALLOUT_NAME) ..."
|
||||
@../advmknod $(CALLOUT_NAME) \
|
||||
$$(awk '$$2=="$(CALLOUT_FOLDER)" {print $$1}' /proc/devices) $(MAX_TTY)
|
||||
@echo "Done"
|
||||
|
||||
uninstall:
|
||||
$(shell if grep $(ADVMOD) /proc/modules > /dev/null ; then \
|
||||
rmmod $(ADVMOD) ; fi)
|
||||
|
||||
test:
|
||||
@cd ../getconfig; make; ./getconfig $(TEST_NAME) $(MAX_TTY)
|
||||
|
||||
clean:
|
||||
@rm -f $(ADVMOD).o
|
||||
@rm -f *~
|
||||
@cd ../getconfig; make clean
|
6105
2.4/serial.c
Normal file
6105
2.4/serial.c
Normal file
File diff suppressed because it is too large
Load Diff
3178
2.6/8250.c
Normal file
3178
2.6/8250.c
Normal file
File diff suppressed because it is too large
Load Diff
122
2.6/8250.h
Normal file
122
2.6/8250.h
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* linux/drivers/char/8250.h
|
||||
*
|
||||
* Driver for 8250/16550-type serial ports
|
||||
*
|
||||
* Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
|
||||
*
|
||||
* Copyright (C) 2001 Russell King.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* $Id: 8250.h,v 1.8 2002/07/21 21:32:30 rmk Exp $
|
||||
*/
|
||||
|
||||
//lipeng add at 2006/06/08
|
||||
#include <linux/version.h>
|
||||
|
||||
#ifndef KERNEL_VERSION
|
||||
#define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c))
|
||||
#endif
|
||||
//lipeng add end
|
||||
|
||||
//lipeng modify at 2007/09/07
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
|
||||
#include <linux/config.h>
|
||||
#endif
|
||||
//lipeng modify end
|
||||
|
||||
//jinxin added to support DMA
|
||||
#include <linux/pci.h>
|
||||
#define TX_BUF_TOT_LEN 128
|
||||
#define RX_BUF_TOT_LEN 128
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
//DMA registers
|
||||
#define DMAADL (0x100 + 0x00) //DMA Address Low
|
||||
#define DMAADH (0x100 + 0x04) //DMA Address High
|
||||
#define DMATL (0x100 + 0x08) //DMA Transfer Length
|
||||
#define DMASTA (0x100 + 0x0c) //DMA Status
|
||||
|
||||
//DMA Status
|
||||
#define DMAREAD (1UL << 31)
|
||||
#define DMAACT (1UL << 0)
|
||||
#define DMAERR (1UL << 1)
|
||||
#define DMADONE (1UL << 2)
|
||||
//jinxin added to support dtrdsr flow control
|
||||
#ifndef CDTRDSR
|
||||
#define CDTRDSR 004000000000 /* DTR/DSR flow control */
|
||||
#endif
|
||||
|
||||
//jinxin added end
|
||||
void adv_serial8250_get_irq_map(unsigned int *map);
|
||||
void adv_serial8250_suspend_port(int line);
|
||||
void adv_serial8250_resume_port(int line);
|
||||
|
||||
struct uart_8250_port {
|
||||
struct uart_port port;
|
||||
struct timer_list timer; /* "no irq" timer */
|
||||
struct list_head list; /* ports on this IRQ */
|
||||
unsigned int capabilities; /* port capabilities */
|
||||
unsigned short rev;
|
||||
unsigned char acr;
|
||||
unsigned char ier;
|
||||
unsigned char lcr;
|
||||
unsigned char mcr;
|
||||
unsigned char mcr_mask; /* mask of user bits */
|
||||
unsigned char mcr_force; /* mask of forced bits */
|
||||
unsigned char lsr_break_flag;
|
||||
//jinxin added to support DMA
|
||||
dma_addr_t rx_ring_dma;
|
||||
dma_addr_t tx_ring_dma;
|
||||
unsigned char *rx_ring;
|
||||
unsigned char *tx_ring;
|
||||
|
||||
|
||||
/*
|
||||
* We provide a per-port pm hook.
|
||||
*/
|
||||
void (*pm)(struct uart_port *port,
|
||||
unsigned int state, unsigned int old);
|
||||
};
|
||||
|
||||
struct old_serial_port {
|
||||
unsigned int uart;
|
||||
unsigned int baud_base;
|
||||
unsigned int port;
|
||||
unsigned int irq;
|
||||
unsigned int flags;
|
||||
unsigned char hub6;
|
||||
unsigned char io_type;
|
||||
unsigned char *iomem_base;
|
||||
unsigned short iomem_reg_shift;
|
||||
};
|
||||
|
||||
#undef SERIAL_DEBUG_PCI
|
||||
|
||||
#if defined(__i386__) && (defined(CONFIG_M386) || defined(CONFIG_M486))
|
||||
#define SERIAL_INLINE
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_INLINE
|
||||
#define _INLINE_ inline
|
||||
#else
|
||||
#define _INLINE_
|
||||
#endif
|
||||
|
||||
#define PROBE_RSA (1 << 0)
|
||||
#define PROBE_ANY (~0)
|
||||
|
||||
#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
|
||||
|
||||
#ifdef CONFIG_SERIAL_8250_SHARE_IRQ
|
||||
#define SERIAL8250_SHARE_IRQS 1
|
||||
#else
|
||||
#define SERIAL8250_SHARE_IRQS 0
|
||||
#endif
|
1802
2.6/8250_pci.c
Normal file
1802
2.6/8250_pci.c
Normal file
File diff suppressed because it is too large
Load Diff
74
2.6/Makefile
Normal file
74
2.6/Makefile
Normal file
@ -0,0 +1,74 @@
|
||||
#
|
||||
# Makefile for the kernel serial device drivers.
|
||||
#
|
||||
# Advantech eAutomation Division
|
||||
#
|
||||
|
||||
|
||||
UNAME := $(shell uname -r)
|
||||
PWD := $(shell pwd)
|
||||
ADVMOD := adv950
|
||||
|
||||
|
||||
SERIAL_NAME= ttyAP
|
||||
MAX_TTY= 64
|
||||
ADV_TTY_MAJOR= 30
|
||||
|
||||
SERIAL_FLAGS= -DSERIAL_NAME=\"$(SERIAL_NAME)\" \
|
||||
-DADV_TTY_MAJOR=$(ADV_TTY_MAJOR) \
|
||||
-DADV_TTY_CUMAJOR=$(ADV_TTY_CUMAJOR)
|
||||
|
||||
|
||||
ifeq "$(UNAME)""2.6.15-26-386"
|
||||
SERIAL_FLAGS:= $(SERIAL_FLAGS) -DUBUNTU_2_6_15=1
|
||||
else
|
||||
ifeq "$(UNAME)""2.6.9-34.EL"
|
||||
SERIAL_FLAGS:= $(SERIAL_FLAGS) -DRHE4SMP=0
|
||||
else
|
||||
ifeq "$(UNAME)""2.6.9-34.ELsmp"
|
||||
SERIAL_FLAGS:= $(SERIAL_FLAGS) -DRHE4SMP=1
|
||||
else
|
||||
SERIAL_FLAGS:= $(SERIAL_FLAGS) -DUBUNTU_2_6_15=0
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
EXTRA_CFLAGS = $(SERIAL_FLAGS)
|
||||
obj-m := adv950.o
|
||||
adv950-objs := 8250.o 8250_pci.o serial_core.o
|
||||
else
|
||||
KDIR := /lib/modules/$(shell uname -r)/build/
|
||||
PWD := $(shell pwd)
|
||||
all:
|
||||
$(MAKE) -w -C $(KDIR) SUBDIRS=$(PWD) modules
|
||||
endif
|
||||
|
||||
|
||||
install:
|
||||
$(shell if grep $(ADVMOD) /proc/modules > /dev/null ; then \
|
||||
rmmod $(ADVMOD) ; fi)
|
||||
@insmod $(ADVMOD).ko
|
||||
|
||||
node: default install
|
||||
@echo "Creating serial device nodes $(SERIAL_NAME) ..."
|
||||
@chmod 777 ../advmknod
|
||||
@../advmknod $(SERIAL_NAME) \
|
||||
$$(awk '$$2=="$(SERIAL_NAME)" {print $$1}' /proc/devices) $(MAX_TTY)
|
||||
@echo "Done"
|
||||
|
||||
uninstall:
|
||||
$(shell if grep $(ADVMOD) /proc/modules > /dev/null ; then \
|
||||
rmmod $(ADVMOD) ; fi)
|
||||
|
||||
test:
|
||||
@cd ../getconfig; make; ./getconfig $(SERIAL_NAME) $(MAX_TTY)
|
||||
|
||||
clean:
|
||||
@rm -f *.o
|
||||
@rm -f *.ko
|
||||
@rm -f *.mod.c modules.order Module.symvers Module.markers
|
||||
@rm -f .*.cmd
|
||||
@rm -rf .tmp_versions
|
||||
@rm -rf *~
|
||||
@cd ../getconfig; make clean
|
5120
2.6/serial_core.c
Normal file
5120
2.6/serial_core.c
Normal file
File diff suppressed because it is too large
Load Diff
3286
3.x/8250.c
Normal file
3286
3.x/8250.c
Normal file
File diff suppressed because it is too large
Load Diff
114
3.x/8250.h
Normal file
114
3.x/8250.h
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Driver for 8250/16550-type serial ports
|
||||
*
|
||||
* Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
|
||||
*
|
||||
* Copyright (C) 2001 Russell King.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <linux/serial_8250.h>
|
||||
void adv_uart_write_wakeup(struct uart_port *port);
|
||||
int adv_uart_resume_port(struct uart_driver *drv, struct uart_port *uport);
|
||||
void adv_serial8250_resume_port(int line);
|
||||
int adv_uart_suspend_port(struct uart_driver *drv, struct uart_port *uport);
|
||||
void adv_serial8250_suspend_port(int line);
|
||||
void adv_uart_configure_port(struct uart_driver *drv, struct uart_state *state,
|
||||
struct uart_port *port);
|
||||
int adv_uart_match_port(struct uart_port *port1, struct uart_port *port2);
|
||||
int adv_serial8250_register_port(struct uart_port *port);
|
||||
int __init adv_serial8250_init(void);
|
||||
int adv_uart_register_driver(struct uart_driver *drv);
|
||||
int adv_uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport);
|
||||
int adv_uart_register_driver(struct uart_driver *drv);
|
||||
int adv_uart_add_one_port(struct uart_driver *drv, struct uart_port *uport);
|
||||
void __exit adv_serial8250_exit(void);
|
||||
void adv_uart_unregister_driver(struct uart_driver *drv);
|
||||
void adv_serial8250_unregister_port(int line);
|
||||
unsigned int
|
||||
adv_uart_get_divisor(struct uart_port *port, unsigned int baud);
|
||||
void uart_configure_port(struct uart_driver *drv, struct uart_state *state,
|
||||
struct uart_port *port);
|
||||
|
||||
struct old_serial_port {
|
||||
unsigned int uart;
|
||||
unsigned int baud_base;
|
||||
unsigned int port;
|
||||
unsigned int irq;
|
||||
unsigned int flags;
|
||||
unsigned char hub6;
|
||||
unsigned char io_type;
|
||||
unsigned char *iomem_base;
|
||||
unsigned short iomem_reg_shift;
|
||||
unsigned long irqflags;
|
||||
};
|
||||
|
||||
/*
|
||||
* This replaces serial_uart_config in include/linux/serial.h
|
||||
*/
|
||||
struct serial8250_config {
|
||||
const char *name;
|
||||
unsigned short fifo_size;
|
||||
unsigned short tx_loadsz;
|
||||
unsigned char fcr;
|
||||
unsigned int flags;
|
||||
};
|
||||
/////////////
|
||||
#define TX_BUF_TOT_LEN 128
|
||||
#define RX_BUF_TOT_LEN 128
|
||||
//DMA registers
|
||||
#define DMAADL (0x100 + 0x00) //DMA Address Low
|
||||
#define DMAADH (0x100 + 0x04) //DMA Address High
|
||||
#define DMATL (0x100 + 0x08) //DMA Transfer Length
|
||||
#define DMASTA (0x100 + 0x0c) //DMA Status
|
||||
|
||||
//DMA Status
|
||||
#define DMAREAD (1UL << 31)
|
||||
#define DMAACT (1UL << 0)
|
||||
#define DMAERR (1UL << 1)
|
||||
#define DMADONE (1UL << 2)
|
||||
//////////////
|
||||
#define UART_CAP_FIFO (1 << 8) /* UART has FIFO */
|
||||
#define UART_CAP_EFR (1 << 9) /* UART has EFR */
|
||||
#define UART_CAP_SLEEP (1 << 10) /* UART has IER sleep */
|
||||
#define UART_CAP_AFE (1 << 11) /* MCR-based hw flow control */
|
||||
#define UART_CAP_UUE (1 << 12) /* UART needs IER bit 6 set (Xscale) */
|
||||
#define UART_CAP_RTOIE (1 << 13) /* UART needs IER bit 4 set (Xscale, Tegra) */
|
||||
|
||||
#define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */
|
||||
#define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */
|
||||
#define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */
|
||||
#define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */
|
||||
|
||||
#define PROBE_RSA (1 << 0)
|
||||
#define PROBE_ANY (~0)
|
||||
|
||||
#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
|
||||
|
||||
#ifdef CONFIG_SERIAL_8250_SHARE_IRQ
|
||||
#define SERIAL8250_SHARE_IRQS 1
|
||||
#else
|
||||
#define SERIAL8250_SHARE_IRQS 0
|
||||
#endif
|
||||
|
||||
#if defined(__alpha__) && !defined(CONFIG_PCI)
|
||||
/*
|
||||
* Digital did something really horribly wrong with the OUT1 and OUT2
|
||||
* lines on at least some ALPHA's. The failure mode is that if either
|
||||
* is cleared, the machine locks up with endless interrupts.
|
||||
*/
|
||||
#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
|
||||
#elif defined(CONFIG_SBC8560)
|
||||
/*
|
||||
* WindRiver did something similarly broken on their SBC8560 board. The
|
||||
* UART tristates its IRQ output while OUT2 is clear, but they pulled
|
||||
* the interrupt line _up_ instead of down, so if we register the IRQ
|
||||
* while the UART is in that state, we die in an IRQ storm. */
|
||||
#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
|
||||
#else
|
||||
#define ALPHA_KLUDGE_MCR 0
|
||||
#endif
|
1872
3.x/8250_pci.c
Normal file
1872
3.x/8250_pci.c
Normal file
File diff suppressed because it is too large
Load Diff
62
3.x/Makefile
Normal file
62
3.x/Makefile
Normal file
@ -0,0 +1,62 @@
|
||||
#
|
||||
# Makefile for the kernel serial device drivers.
|
||||
#
|
||||
# Advantech eAutomation Division
|
||||
#
|
||||
|
||||
|
||||
UNAME := $(shell uname -r)
|
||||
PWD := $(shell pwd)
|
||||
ADVMOD := adv950
|
||||
|
||||
|
||||
SERIAL_NAME= ttyAP
|
||||
MAX_TTY= 64
|
||||
ADV_TTY_MAJOR= 30
|
||||
|
||||
SERIAL_FLAGS= -DSERIAL_NAME=\"$(SERIAL_NAME)\" \
|
||||
-DADV_TTY_MAJOR=$(ADV_TTY_MAJOR) \
|
||||
-DADV_TTY_CUMAJOR=$(ADV_TTY_CUMAJOR)
|
||||
|
||||
|
||||
SERIAL_FLAGS:= $(SERIAL_FLAGS)
|
||||
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
EXTRA_CFLAGS = $(SERIAL_FLAGS)
|
||||
obj-m := adv950.o
|
||||
adv950-objs := 8250.o 8250_pci.o serial_core.o
|
||||
else
|
||||
KDIR := /lib/modules/$(shell uname -r)/build/
|
||||
PWD := $(shell pwd)
|
||||
all:
|
||||
$(MAKE) -w -C $(KDIR) SUBDIRS=$(PWD) modules
|
||||
endif
|
||||
|
||||
|
||||
install:
|
||||
$(shell if grep $(ADVMOD) /proc/modules > /dev/null ; then \
|
||||
rmmod $(ADVMOD) ; fi)
|
||||
@insmod $(ADVMOD).ko
|
||||
|
||||
node: default install
|
||||
@echo "Creating serial device nodes $(SERIAL_NAME) ..."
|
||||
@chmod 777 ../advmknod
|
||||
@../advmknod $(SERIAL_NAME) \
|
||||
$$(awk '$$2=="$(SERIAL_NAME)" {print $$1}' /proc/devices) $(MAX_TTY)
|
||||
@echo "Done"
|
||||
|
||||
uninstall:
|
||||
$(shell if grep $(ADVMOD) /proc/modules > /dev/null ; then \
|
||||
rmmod $(ADVMOD) ; fi)
|
||||
|
||||
test:
|
||||
@cd ../getconfig; make; ./getconfig $(SERIAL_NAME) $(MAX_TTY)
|
||||
|
||||
clean:
|
||||
@rm -f *.o
|
||||
@rm -f *.ko
|
||||
@rm -f *.mod.c modules.order Module.symvers Module.markers
|
||||
@rm -f .*.cmd
|
||||
@rm -rf .tmp_versions
|
||||
@rm -rf *~
|
||||
@cd ../getconfig; make clean
|
2509
3.x/serial_core.c
Normal file
2509
3.x/serial_core.c
Normal file
File diff suppressed because it is too large
Load Diff
199
README
Normal file
199
README
Normal file
@ -0,0 +1,199 @@
|
||||
=============================================================================
|
||||
ADVANTECH industrial comunication cards device driver
|
||||
Installation Guide
|
||||
for Linux Kernel 2.4.x,2.6.x,3.x
|
||||
Copyright (C) 2011, Advantech eAutomation Division.
|
||||
=============================================================================
|
||||
|
||||
This README file describes the HOW-TOs of driver installation.
|
||||
|
||||
1. Change Logs
|
||||
|
||||
Version 3.00 <2004-11-29>
|
||||
- Moved code from 2.4.x
|
||||
Version 3.01 <2004-12-02>
|
||||
- Fixed UNO-2050 function 1 offset typing error
|
||||
Version 3.02 <2004-12-03>
|
||||
- Support FC3
|
||||
Version 3.03 <2004-12-15>
|
||||
- Support UART types can be specified by each port to support
|
||||
some kind of devices did not fully implement with auto detection
|
||||
Version 3.04 <2004-12-30>
|
||||
- Support serial port ioctl TIOCGSERIAL to get serial port jumper
|
||||
setting and store at reserved_char[0]. If value is zero, that
|
||||
means jumper switch to RS232. Otherwise, it would be RS422/485.
|
||||
|
||||
struct serial_struct serinfo;
|
||||
// get serial port information
|
||||
serinfo.reserved_char[0] = 0;
|
||||
if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0) {
|
||||
perror("Cannot get serial info");
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
// get serial port type configuration
|
||||
if (serinfo.reserved_char[0] == 0)
|
||||
{
|
||||
// RS232
|
||||
}
|
||||
else
|
||||
{
|
||||
// RS422/485
|
||||
}
|
||||
Version 3.05 <2005-2-17>
|
||||
- Porting serial driver to 2.4 kernel
|
||||
- Enhance 2.4 and 2.6 serial drivers, Makefile and script file
|
||||
Version 3.06 <2005-4-25>
|
||||
- Remove the folder of 'pclterm' from the package
|
||||
- Test in SuSE 9.2, Mandrake 10.1 and Debian 3.0r2
|
||||
Version 3.07 <2005-5-31>
|
||||
- Add ICOM cards support
|
||||
PCI-1601A/B/AU/BU, PCI-1602A/B/AU/BU/UP,
|
||||
PCI-1603, PCI-1604UP and PCI-1622CU
|
||||
Version 3.08 <2005-6-14>
|
||||
- Correct PCI-952 2nd port start base address(BAR1)
|
||||
Version 3.09 <2005-6-22>
|
||||
- Fix 2.4 driver which did not set auto DTR correctly
|
||||
Version 3.10 <2005-6-24>
|
||||
- Add code to setup auto DTR after detection
|
||||
Version 3.11 <2005-6-29>
|
||||
- Fix PCI-1622 ports on function 1 detection problem
|
||||
Version 3.12 <2005-7-22>
|
||||
- Add support for UNOB-2201CB carrier board
|
||||
- Add MIC-3612 and MIC-3620 to 2.6 pci_serial_quirks table
|
||||
- Change the value of UART_NR to 64 in the driver for 2.6 kernel
|
||||
Version 3.13 <2005-8-9>
|
||||
- Fix UNOB-2201CB ports on function 1 detection problem
|
||||
Version 3.14 <2005-11-07>
|
||||
- Add support for MIC-3611
|
||||
Version 3.15 <2006-2-16>
|
||||
- Add support for Mandriva Linux 2006
|
||||
Version 3.16 <2006-2-16>
|
||||
- Change the SERIAL_NAME to support devfs.
|
||||
Version 3.17 <2006-5-24>
|
||||
- Add support for Debian 3.1r0a (kernel version 2.6.8-2-686)
|
||||
Version 3.18 <2006-6-8>
|
||||
- Add support for SuSE LINUX 10.1 and Fedora Core 5
|
||||
Verson 3.19 <2006-11-10>
|
||||
-Add support for UNO-2176
|
||||
Version 3.20 <2007-03-06>
|
||||
- Fix bug in low active type for 485 mode(kernel 2.6)
|
||||
- Support Ubuntu 6.06(add UBUNTU_2_6_15) and RedHat Enterprise Server 4(kernel 2.6)
|
||||
- Support quick response(use setserial to change uart type)
|
||||
- Enable 16C950 trigger level and hardware and software flow control
|
||||
Version 3.21 <2007-05-21>
|
||||
- Add support for PCM-3614P PCM-3618P PCM-3681P PCM-3641P
|
||||
Version 3.22 <2007-09-14>
|
||||
- Support FC6
|
||||
Version 3.23 <2007-09-30>
|
||||
- Fix the bug in serial8250_get_mctrl
|
||||
Version 3.24 <2007-12-06>
|
||||
- Fix software flow control in 2.4 kernel version for MIC-3612
|
||||
Version 3.25 <2007-12-06>
|
||||
- Fix bug about flow control in 2.6 kernel
|
||||
- Fix bug about change_speed in 2.4 kernel
|
||||
Version 3.26 <2008-07-07>
|
||||
- to support FC7 and FC8
|
||||
- to support UNO-1150
|
||||
- to support MIC-3621
|
||||
- to support ubuntu 8.04
|
||||
Version 3.27 <2008-10-08>
|
||||
- Source headers comply with GPL
|
||||
- modify the driver readme
|
||||
Version 3.28 <2008-12-08>
|
||||
- to support UNO-2679, UNO-4672
|
||||
Version 3.29 <2009-06-03>
|
||||
- to support debian 5.0
|
||||
- to support patch CONFIG_PREEMPT_RT in kernel
|
||||
- to support A001 A002 A004 A101 A102 A104 devices
|
||||
- to support F001 F002 F004 F101 F102 F104 deivces
|
||||
Version 3.30 <2010-05-06>
|
||||
- to support FC10,FC11,FC12,SUSE 11.2 Madriva 2010
|
||||
- to support Advantech General COM port
|
||||
Version 3.31 <2010-08-11>
|
||||
- updata to support kernel-2.6.32 and kernel-2.6.33
|
||||
- to support ubuntu 10.04 and Fedora core 13
|
||||
Version 3.32 <2010-08-11>
|
||||
- updata to support redhat 7.2
|
||||
- fix bug for general COM port information
|
||||
- add support Fedora 14
|
||||
- fix bug about stty
|
||||
Version 3.33 <2010-11-07>
|
||||
- support 2.6.37,2.6.38,2.6.39 and 3.x kernel
|
||||
- support PCIe-1620
|
||||
|
||||
|
||||
2. Test environment
|
||||
|
||||
+--------------------------+-------------------------+
|
||||
| Distribution | kernel version |
|
||||
+--------------------------+-------------------------+
|
||||
| Red Hat 7.2 | 2.4.7-10 |
|
||||
| Red Hat 9 | 2.4.20-8 |
|
||||
| RedHat Enterprise 4 | 2.6.9-34.EL |
|
||||
| Redhat Enterprise 5.4 | 2.6.18-164.el5 |
|
||||
| Fedora Core 6 | 2.6.18-1.2798.fc6 |
|
||||
| Fedora Core 8 | 2.6.23.1-42.fc8 |
|
||||
| Fedora Core 9 | 2.6.25-14.fc9 |
|
||||
| Fedora Core 10 | 2.6.27.5-117.fc10 |
|
||||
| Fedora Core 11 | 2.6.29.4-167.fc11 |
|
||||
| Fedora Core 12 | 2.6.31.5-127.fc12 |
|
||||
| Fedora Core 13 | 2.6.33.3-85.fc13 |
|
||||
| Fedora Core 14 | 2.6.35.6-45.fc14 |
|
||||
| Fedora Core 15 | 2.6.38/2.6.40 |
|
||||
| SUSE 10.1 | 2.6.16.13-4-default |
|
||||
| SUSE 10.3 | 2.6.22.5-31-default |
|
||||
| SUSE 11.2 | 2.6.31.5-0.1-desktop |
|
||||
| SUSE 11.4 | 2.6.37 |
|
||||
| Mandriva 2010 | 2.6.31.5-desktop-1mnb |
|
||||
| Debian 5.0.4 | 2.6.26-2-686 |
|
||||
| Debian 6.0.2 | 2.6.32 |
|
||||
| Ubuntu 8.04 | 2.6.24-19-generic |
|
||||
| ubuntu 9.04 | 2.6.28-11-generic |
|
||||
| Ubuntu 9.10 | 2.6.31-14-generic |
|
||||
| Ubuntu 10.04 | 2.6.32-21-generic |
|
||||
| Ubuntu 11.10 | 3.0.2 |
|
||||
+--------------------------+-------------------------+
|
||||
|
||||
3. Installation
|
||||
|
||||
3.1. Login as 'root' before executing the following instructions.
|
||||
|
||||
3.2. Uncompress the driver
|
||||
# tar zxvf adv950_vM_NN.tar.gz
|
||||
|
||||
3.3. Build the driver
|
||||
a. Build driver for 2.4 kernel
|
||||
# cd adv950_vM_NN/2.4
|
||||
# make
|
||||
b. Build driver for 2.6 kernel
|
||||
# cd adv950_vM_NN/2.6
|
||||
# make
|
||||
Note:
|
||||
To compile the source code, you must install kernel development header file package,"gcc" and "make" command.
|
||||
In 2.4 kernel version, you should use "ln" command to make a link named "linux-2.4" in /usr/src/, it link to you kernel development header installed folder.
|
||||
|
||||
|
||||
3.4. Install the driver module
|
||||
# make install
|
||||
to see whether ttyAP0~ttyAP7 exist in /dev/ folder,
|
||||
if not,please execute the following command,
|
||||
# make node
|
||||
|
||||
3.5. Test driver and get serial port type configuration
|
||||
# make test
|
||||
|
||||
3.6. If you want the Linux bring up module at each boot,
|
||||
please follow the steps showing below
|
||||
a. Build driver
|
||||
b. For 2.4 kernel, add "insmod /YOURLOCATION/adv950_vM_NN/2.4/adv950.o" to
|
||||
to boot up shell script.
|
||||
c. For 2.6 kernel, add "insmod /YOURLOCATION/adv950_vM_NN/2.6/adv950.ko" to
|
||||
to boot up shell script.
|
||||
Fedora core 6 for example:
|
||||
add "insmod /YOURLOCATION/adv950_vM_NN/2.6/adv950.ko" to /etc/rc.d/rc.local
|
||||
|
||||
3.7. Uninstall the driver module and clean
|
||||
# make uninstall
|
||||
# make clean
|
63
advmknod
Normal file
63
advmknod
Normal file
@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Advantech IAG eAutomation PCI-954/16C950 device node utility
|
||||
#
|
||||
|
||||
|
||||
TTYNAME="$1"
|
||||
MAJOR="$2"
|
||||
TTYNUM="$3"
|
||||
|
||||
if [ "$1" = "" ] ; then
|
||||
echo "Invalid TTYNAME"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$2" = "" ] ; then
|
||||
echo "Invalid MAJOR number"
|
||||
exit 2
|
||||
fi
|
||||
if [ "$3" = "" ] ; then
|
||||
echo "Invalid tty number"
|
||||
exit 3
|
||||
fi
|
||||
#echo "TTYNAME is $TTYNAME"
|
||||
if [ $TTYNAME = "ttap" ] ; then
|
||||
[ -d /dev/$TTYNAME ] && rm -rf /dev/$TTYNAME
|
||||
mkdir /dev/$TTYNAME
|
||||
fi
|
||||
if [ $TTYNAME = "ttac" ] ; then
|
||||
[ -d /dev/$TTYNAME ] && rm -rf /dev/$TTYNAME
|
||||
mkdir /dev/$TTYNAME
|
||||
fi
|
||||
|
||||
port=0
|
||||
minor=0
|
||||
while [ $port -lt $TTYNUM ]
|
||||
do
|
||||
mport=`expr $port`
|
||||
|
||||
if [ $TTYNAME = "ttap" ] ; then
|
||||
#[ -d /dev/$TTYNAME ] && rm -rf /dev/$TTYNAME
|
||||
#mkdir /dev/$TTYNAME
|
||||
ttydev=/dev/$TTYNAME/$mport
|
||||
fi
|
||||
if [ $TTYNAME = "ttyAP" ] ; then
|
||||
[ -c /dev/$TTYNAME$mport ] && rm -rf /dev/$TTYNAME$mport
|
||||
ttydev=/dev/$TTYNAME$mport
|
||||
fi
|
||||
if [ $TTYNAME = "ttac" ] ; then
|
||||
#[ -d /dev/$TTYNAME ] && rm -rf /dev/$TTYNAME
|
||||
#mkdir /dev/$TTYNAME
|
||||
ttydev=/dev/$TTYNAME/$mport
|
||||
fi
|
||||
if [ $TTYNAME = "ttyAC" ] ; then
|
||||
[ -c /dev/$TTYNAME$mport ] && rm -rf /dev/$TTYNAME$mport
|
||||
ttydev=/dev/$TTYNAME$mport
|
||||
fi
|
||||
|
||||
mknod $ttydev c $MAJOR $minor
|
||||
chmod a+wx $ttydev
|
||||
|
||||
port=`expr $port + 1`
|
||||
minor=`expr $minor + 1`
|
||||
done
|
11
getconfig/Makefile
Normal file
11
getconfig/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
CC = gcc
|
||||
CFLAGS = -O
|
||||
GETCONFIG = getconfig
|
||||
|
||||
all: $(GETCONFIG)
|
||||
|
||||
$(GETCONFIG): $(GETCONFIG).c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
clean:
|
||||
@rm -f *.o $(GETCONFIG)
|
89
getconfig/getconfig.c
Normal file
89
getconfig/getconfig.c
Normal file
@ -0,0 +1,89 @@
|
||||
//******************************************************************************
|
||||
//
|
||||
// Copyright (c) 2008 Advantech Industrial Automation Group.
|
||||
//
|
||||
// Oxford PCI-954/952/16C950 with Advantech RS232/422/485 capacities
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
// more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
// Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
//
|
||||
//
|
||||
//
|
||||
//******************************************************************************
|
||||
|
||||
//***********************************************************************
|
||||
// File: getconfig.c
|
||||
// Version: 1.01.1
|
||||
// Author: Po-Cheng Chen
|
||||
// Purpose: Get serial port configuration, such as RS232 or RS422/485
|
||||
//***********************************************************************
|
||||
//***********************************************************************
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <asm/ioctls.h>
|
||||
#include <linux/serial.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, ttynum, fd;
|
||||
char ttyname[80];
|
||||
struct serial_struct serinfo;
|
||||
|
||||
if(argc < 3)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf("%s TTYNAME TTYNUM", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ttynum = atoi(argv[2]);
|
||||
for(i=0;i<ttynum;i++)
|
||||
{
|
||||
sprintf(ttyname, "/dev/%s%d", argv[1], i);
|
||||
if((fd = open(ttyname, O_RDWR | O_NDELAY)) == -1)
|
||||
break;
|
||||
|
||||
// test serial port exist or not
|
||||
if(write(fd, ttyname, strlen(ttyname)) == -1)
|
||||
break;
|
||||
|
||||
// get serial port information
|
||||
serinfo.reserved_char[0] = 0;
|
||||
if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0)
|
||||
{
|
||||
printf("Cannot get serial info\n");
|
||||
close(fd);
|
||||
return 2;
|
||||
}
|
||||
|
||||
// get serial port type configuration
|
||||
if (serinfo.reserved_char[0] == 0)
|
||||
{
|
||||
// RS232
|
||||
printf("%s is RS232\n", ttyname);
|
||||
}
|
||||
else
|
||||
{
|
||||
// RS422/485
|
||||
printf("%s is RS422/485\n", ttyname);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user