File: serial.c

package info (click to toggle)
kernel-image-2.4.18-hppa 62.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 156,012 kB
  • ctags: 448,723
  • sloc: ansic: 2,586,445; asm: 145,047; makefile: 8,574; sh: 3,097; perl: 2,578; yacc: 1,177; tcl: 577; lex: 352; awk: 251; lisp: 218; sed: 72
file content (133 lines) | stat: -rw-r--r-- 3,655 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 *	Serial Device Initialisation for LASI/ASP/WAX/DINO
 *
 *	(c) Copyright 2000 The Puffin Group Inc.
 *	(c) Copyright 2000-2001 Helge Deller <deller@gmx.de>
 *
 *	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/config.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/signal.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/kernel_stat.h>
#include <linux/ioport.h>
#include <linux/timex.h>
#include <linux/module.h>
#include <linux/serial.h>
#include <linux/slab.h>

#include <asm/serial.h>
#include <asm/io.h>
#include <asm/hardware.h>
#include <asm/gsc.h>

#include "busdevice.h"

static void setup_parisc_serial(struct serial_struct *serial,
		unsigned long address, int irq, int line)
{
	memset(serial, 0, sizeof(struct serial_struct));

	/* autoconfig() sets state->type.  This sets info->type */
	serial->type = PORT_16550A;

	serial->line = line;
	serial->iomem_base = ioremap(address, 0x8);

	serial->irq = irq;
	serial->io_type = SERIAL_IO_MEM;	/* define access method */
	serial->flags = 0;
	serial->xmit_fifo_size = 16;
	serial->custom_divisor = 0;
	serial->baud_base = LASI_BASE_BAUD;
}

static int __init 
serial_init_chip(struct parisc_device *dev)
{
	static int serial_line_nr;
	unsigned long address;

	struct serial_struct *serial;

	if (!dev->irq) {
		if (dev->parent->id.hw_type != HPHW_IOA) {
			printk(KERN_INFO "Serial: device 0x%lx not configured.\n"
				"Enable support for Wax, Lasi, Asp or Dino.\n", dev->hpa);
		}
		return -ENODEV;
	}

	serial = kmalloc(sizeof(*serial), GFP_KERNEL);
	if (!serial)
		return -ENOMEM;

	address = dev->hpa;
	if (dev->id.sversion != 0x8d) {
		address += 0x800;
	}

	setup_parisc_serial(serial, address, dev->irq, serial_line_nr++);

	if (register_serial(serial) < 0) {
		printk(KERN_WARNING "register_serial returned error\n");
		kfree(serial);
		return -ENODEV;
	}

	return 0;
}

static struct parisc_device_id serial_tbl[] = {
	{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
	{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
	{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
	{ 0 }
};

/* Hack.  Dino's serial port will get listed first on some machines.
 * So we register this driver first which knows about Lasi's serial port.
 * This needs to get fixed properly somehow.
 */
static struct parisc_device_id serial1_tbl[] = {
	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
	{ 0 }
};


MODULE_DEVICE_TABLE(parisc, serial_tbl);

static struct parisc_driver serial1_driver = {
	name:		"Serial RS232",
	id_table:	serial1_tbl,
	probe:		serial_init_chip,
};

static struct parisc_driver serial_driver = {
	name:		"Serial RS232",
	id_table:	serial_tbl,
	probe:		serial_init_chip,
};

void __init probe_serial_gsc(void)
{
	register_parisc_driver(&serial1_driver);
	register_parisc_driver(&serial_driver);
}