aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hvc_vio.c
diff options
context:
space:
mode:
authorMilton Miller <miltonm@bga.com>2005-07-07 20:56:24 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-07 21:23:39 -0400
commitacad9559f1054487292eb10d7bb81f256e9d8f2d (patch)
tree9496b1c81c776ab5c8af37246697052226a345a6 /drivers/char/hvc_vio.c
parentd5ee257c3342185ba8ab642d125d192eb99ea8f2 (diff)
[PATCH] hvc_console: Separate hvc_console and vio code 2
Remove all the vio device driver code from hvc_console.c This will allow us to separate hvsi, hvc, and allow hvc_console to be used without the ppc64 vio layer. Signed-off-by: Milton Miller <miltonm@bga.com> Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/hvc_vio.c')
-rw-r--r--drivers/char/hvc_vio.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c
new file mode 100644
index 000000000000..d2928f90ab51
--- /dev/null
+++ b/drivers/char/hvc_vio.c
@@ -0,0 +1,125 @@
1/*
2 * vio driver interface to hvc_console.c
3 *
4 * This code was moved here to allow the remaing code to be reused as a
5 * generic polling mode with semi-reliable transport driver core to the
6 * console and tty subsystems.
7 *
8 *
9 * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
10 * Copyright (C) 2001 Paul Mackerras <paulus@au.ibm.com>, IBM
11 * Copyright (C) 2004 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
12 * Copyright (C) 2004 IBM Corporation
13 *
14 * Additional Author(s):
15 * Ryan S. Arnold <rsa@us.ibm.com>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 */
31
32#include <linux/types.h>
33#include <linux/init.h>
34#include <asm/hvconsole.h>
35#include <asm/vio.h>
36#include <asm/prom.h>
37
38char hvc_driver_name[] = "hvc_console";
39
40static struct vio_device_id hvc_driver_table[] __devinitdata = {
41 {"serial", "hvterm1"},
42 { NULL, }
43};
44MODULE_DEVICE_TABLE(vio, hvc_driver_table);
45
46static int __devinit hvc_vio_probe(struct vio_dev *vdev,
47 const struct vio_device_id *id)
48{
49 struct hvc_struct *hp;
50
51 /* probed with invalid parameters. */
52 if (!vdev || !id)
53 return -EPERM;
54
55 hp = hvc_alloc(vdev->unit_address, vdev->irq);
56 if (IS_ERR(hp))
57 return PTR_ERR(hp);
58 dev_set_drvdata(&vdev->dev, hp);
59
60 return 0;
61}
62
63static int __devexit hvc_vio_remove(struct vio_dev *vdev)
64{
65 struct hvc_struct *hp = dev_get_drvdata(&vdev->dev);
66
67 return hvc_remove(hp);
68}
69
70static struct vio_driver hvc_vio_driver = {
71 .name = hvc_driver_name,
72 .id_table = hvc_driver_table,
73 .probe = hvc_vio_probe,
74 .remove = hvc_vio_remove,
75 .driver = {
76 .owner = THIS_MODULE,
77 }
78};
79
80static int hvc_vio_init(void)
81{
82 int rc;
83
84 /* Register as a vio device to receive callbacks */
85 rc = vio_register_driver(&hvc_vio_driver);
86
87 return rc;
88}
89module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */
90
91static void hvc_vio_exit(void)
92{
93 vio_unregister_driver(&hvc_vio_driver);
94}
95module_exit(hvc_vio_exit);
96
97/* the device tree order defines our numbering */
98static int hvc_find_vtys(void)
99{
100 struct device_node *vty;
101 int num_found = 0;
102
103 for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL;
104 vty = of_find_node_by_name(vty, "vty")) {
105 uint32_t *vtermno;
106
107 /* We have statically defined space for only a certain number
108 * of console adapters.
109 */
110 if (num_found >= MAX_NR_HVC_CONSOLES)
111 break;
112
113 vtermno = (uint32_t *)get_property(vty, "reg", NULL);
114 if (!vtermno)
115 continue;
116
117 if (device_is_compatible(vty, "hvterm1")) {
118 hvc_instantiate(*vtermno, num_found);
119 ++num_found;
120 }
121 }
122
123 return num_found;
124}
125console_initcall(hvc_find_vtys);