OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [armnommu/] [drivers/] [char/] [serial-card.c] - Blame information for rev 1622

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1622 jcastillo
/*
2
 * linux/arch/arm/drivers/char/serial-module.c
3
 *
4
 * Copyright (c) 1996 Russell King.
5
 *
6
 * A generic handler of serial expansion cards that use 16550s or
7
 * the like.
8
 *
9
 * Definitions:
10
 *  MY_PRODS            Product numbers to identify this card by
11
 *  MY_MANUS            Manufacturer numbers to identify this card by
12
 *  MY_NUMPORTS         Number of ports per card
13
 *  MY_BAUD_BASE        Baud base for the card
14
 *  MY_INIT             Initialisation routine name
15
 *  MY_BASE_ADDRESS(ec) Return base address for ports
16
 *  MY_PORT_ADDRESS
17
 *      (port,cardaddr) Return address for port using base address
18
 *                      from above.
19
 *
20
 * Changelog:
21
 *  30-07-1996  RMK     Created
22
 */
23
#include <linux/module.h>
24
#include <linux/serial.h>
25
#include <linux/errno.h>
26
#include <asm/ecard.h>
27
 
28
#ifndef NUM_SERIALS
29
#define NUM_SERIALS     MY_NUMPORTS * MAX_ECARDS
30
#endif
31
 
32
#ifdef MODULE
33
static int __serial_ports[NUM_SERIALS];
34
static int __serial_pcount;
35
static struct expansion_card *expcard[MAX_ECARDS];
36
#define ADD_ECARD(ec,card) expcard[(card)] = (ec)
37
#define ADD_PORT(port) __serial_ports[__serial_pcount++] = (port)
38
#define REGISTER(ss) register_serial(ss)
39
#undef MY_INIT
40
#define MY_INIT init_module
41
#else
42
#define ADD_ECARD(ec,card)
43
#define ADD_PORT(port)
44
#define REGISTER(ss) register_pre_init_serial(ss)
45
#endif
46
 
47
static const card_ids serial_cids[] = { MY_CARD_LIST, { 0xffff, 0xffff } };
48
 
49
static inline int serial_register_onedev (unsigned long port, int irq)
50
{
51
    struct serial_struct req;
52
 
53
    req.baud_base = MY_BAUD_BASE;
54
    req.irq = irq;
55
    req.port = port;
56
 
57
    return REGISTER (&req);
58
}
59
 
60
int MY_INIT (void)
61
{
62
    int card = 0;
63
 
64
    ecard_startfind ();
65
 
66
    do {
67
        struct expansion_card *ec;
68
        unsigned long cardaddr;
69
        int port;
70
 
71
        ec = ecard_find (0, serial_cids);
72
        if (!ec)
73
            break;
74
 
75
        cardaddr = MY_BASE_ADDRESS(ec);
76
 
77
        for (port = 0; port < MY_NUMPORTS; port ++) {
78
            int line;
79
 
80
            line = serial_register_onedev (MY_PORT_ADDRESS(port, cardaddr), ec->irq);
81
            if (line < 0)
82
                break;
83
            ADD_PORT(line);
84
        }
85
 
86
        if (port) {
87
            ecard_claim (ec);
88
            ADD_ECARD(ec, card);
89
        } else
90
            break;
91
    } while (++card < MAX_ECARDS);
92
    return card ? 0 : -ENODEV;
93
}
94
 
95
#ifdef MODULE
96
void cleanup_module (void)
97
{
98
    int i;
99
 
100
    for (i = 0; i < __serial_pcount; i++)
101
        unregister_serial (__serial_ports[i]);
102
 
103
    for (i = 0; i < MAX_ECARDS; i++)
104
        if (expcard[i])
105
            ecard_release (expcard[i]);
106
}
107
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.