xref: /linux/drivers/parisc/hppb.c (revision c537b994505099b7197e7d3125b942ecbcc51eb6)
1 /*
2 ** hppb.c:
3 **      HP-PB bus driver for the NOVA and K-Class systems.
4 **
5 **      (c) Copyright 2002 Ryan Bradetich
6 **      (c) Copyright 2002 Hewlett-Packard Company
7 **
8 ** This program is free software; you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License as published by
10 ** the Free Software Foundation; either version 2 of the License, or
11 ** (at your option) any later version.
12 **
13 */
14 
15 #include <linux/types.h>
16 #include <linux/init.h>
17 #include <linux/mm.h>
18 #include <linux/slab.h>
19 #include <linux/ioport.h>
20 
21 #include <asm/io.h>
22 #include <asm/hardware.h>
23 #include <asm/parisc-device.h>
24 
25 #include <linux/pci.h>
26 
27 struct hppb_card {
28 	unsigned long hpa;
29 	struct resource mmio_region;
30 	struct hppb_card *next;
31 };
32 
33 struct hppb_card hppb_card_head = {
34 	.hpa = 0,
35 	.next = NULL,
36 };
37 
38 #define IO_IO_LOW  offsetof(struct bc_module, io_io_low)
39 #define IO_IO_HIGH offsetof(struct bc_module, io_io_high)
40 
41 /**
42  * hppb_probe - Determine if the hppb driver should claim this device.
43  * @dev: The device which has been found
44  *
45  * Determine if hppb driver should claim this chip (return 0) or not
46  * (return 1). If so, initialize the chip and tell other partners in crime
47  * they have work to do.
48  */
49 static int hppb_probe(struct parisc_device *dev)
50 {
51 	int status;
52 	struct hppb_card *card = &hppb_card_head;
53 
54 	while(card->next) {
55 		card = card->next;
56 	}
57 
58 	if(card->hpa) {
59 		card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL);
60 		if(!card->next) {
61 			printk(KERN_ERR "HP-PB: Unable to allocate memory.\n");
62 			return 1;
63 		}
64 		card = card->next;
65 	}
66         printk(KERN_INFO "Found GeckoBoa at 0x%x\n", dev->hpa.start);
67 
68 	card->hpa = dev->hpa.start;
69 	card->mmio_region.name = "HP-PB Bus";
70 	card->mmio_region.flags = IORESOURCE_MEM;
71 
72 	card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW);
73 	card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1;
74 
75 	status = ccio_request_resource(dev, &card->mmio_region);
76 	if(status < 0) {
77 		printk(KERN_ERR "%s: failed to claim HP-PB bus space (%08x, %08x)\n",
78 			__FILE__, card->mmio_region.start, card->mmio_region.end);
79 	}
80 
81         return 0;
82 }
83 
84 static struct parisc_device_id hppb_tbl[] = {
85         { HPHW_BCPORT, HVERSION_REV_ANY_ID, 0x500, 0xc }, /* E25 and K */
86         { HPHW_BCPORT, 0x0, 0x501, 0xc }, /* E35 */
87         { HPHW_BCPORT, 0x0, 0x502, 0xc }, /* E45 */
88         { HPHW_BCPORT, 0x0, 0x503, 0xc }, /* E55 */
89         { 0, }
90 };
91 
92 static struct parisc_driver hppb_driver = {
93         .name =         "gecko_boa",
94         .id_table =     hppb_tbl,
95 	.probe =        hppb_probe,
96 };
97 
98 /**
99  * hppb_init - HP-PB bus initalization procedure.
100  *
101  * Register this driver.
102  */
103 void __init hppb_init(void)
104 {
105         register_parisc_driver(&hppb_driver);
106 }
107