1 // SPDX-License-Identifier: GPL-2.0
3 * linux/drivers/serial/acorn.c
5 * Copyright (C) 1996-2003 Russell King.
7 #include <linux/module.h>
8 #include <linux/types.h>
10 #include <linux/serial_core.h>
11 #include <linux/errno.h>
12 #include <linux/ioport.h>
13 #include <linux/slab.h>
14 #include <linux/device.h>
15 #include <linux/init.h>
18 #include <asm/ecard.h>
19 #include <asm/string.h>
25 struct serial_card_type
{
26 unsigned int num_ports
;
29 unsigned int offset
[MAX_PORTS
];
32 struct serial_card_info
{
33 unsigned int num_ports
;
39 serial_card_probe(struct expansion_card
*ec
, const struct ecard_id
*id
)
41 struct serial_card_info
*info
;
42 struct serial_card_type
*type
= id
->data
;
43 struct uart_8250_port uart
;
44 unsigned long bus_addr
;
47 info
= kzalloc(sizeof(struct serial_card_info
), GFP_KERNEL
);
51 info
->num_ports
= type
->num_ports
;
53 bus_addr
= ecard_resource_start(ec
, type
->type
);
54 info
->vaddr
= ecardm_iomap(ec
, type
->type
, 0, 0);
60 ecard_set_drvdata(ec
, info
);
62 memset(&uart
, 0, sizeof(struct uart_8250_port
));
63 uart
.port
.irq
= ec
->irq
;
64 uart
.port
.flags
= UPF_BOOT_AUTOCONF
| UPF_SHARE_IRQ
;
65 uart
.port
.uartclk
= type
->uartclk
;
66 uart
.port
.iotype
= UPIO_MEM
;
67 uart
.port
.regshift
= 2;
68 uart
.port
.dev
= &ec
->dev
;
70 for (i
= 0; i
< info
->num_ports
; i
++) {
71 uart
.port
.membase
= info
->vaddr
+ type
->offset
[i
];
72 uart
.port
.mapbase
= bus_addr
+ type
->offset
[i
];
74 info
->ports
[i
] = serial8250_register_8250_port(&uart
);
80 static void serial_card_remove(struct expansion_card
*ec
)
82 struct serial_card_info
*info
= ecard_get_drvdata(ec
);
85 ecard_set_drvdata(ec
, NULL
);
87 for (i
= 0; i
< info
->num_ports
; i
++)
88 if (info
->ports
[i
] > 0)
89 serial8250_unregister_port(info
->ports
[i
]);
94 static struct serial_card_type atomwide_type
= {
97 .type
= ECARD_RES_IOCSLOW
,
98 .offset
= { 0x2800, 0x2400, 0x2000 },
101 static struct serial_card_type serport_type
= {
104 .type
= ECARD_RES_IOCSLOW
,
105 .offset
= { 0x2000, 0x2020 },
108 static const struct ecard_id serial_cids
[] = {
109 { MANU_ATOMWIDE
, PROD_ATOMWIDE_3PSERIAL
, &atomwide_type
},
110 { MANU_SERPORT
, PROD_SERPORT_DSPORT
, &serport_type
},
114 static struct ecard_driver serial_card_driver
= {
115 .probe
= serial_card_probe
,
116 .remove
= serial_card_remove
,
117 .id_table
= serial_cids
,
119 .name
= "8250_acorn",
123 static int __init
serial_card_init(void)
125 return ecard_register_driver(&serial_card_driver
);
128 static void __exit
serial_card_exit(void)
130 ecard_remove_driver(&serial_card_driver
);
133 MODULE_AUTHOR("Russell King");
134 MODULE_DESCRIPTION("Acorn 8250-compatible serial port expansion card driver");
135 MODULE_LICENSE("GPL");
137 module_init(serial_card_init
);
138 module_exit(serial_card_exit
);