blob: a68b3b3761a229e0569a98d28cd29caa829aa519 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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**
Linus Torvalds1da177e2005-04-16 15:20:36 -070013*/
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070025struct hppb_card {
26 unsigned long hpa;
27 struct resource mmio_region;
28 struct hppb_card *next;
29};
30
31struct hppb_card hppb_card_head = {
32 .hpa = 0,
33 .next = NULL,
34};
35
36#define IO_IO_LOW offsetof(struct bc_module, io_io_low)
37#define IO_IO_HIGH offsetof(struct bc_module, io_io_high)
38
39/**
40 * hppb_probe - Determine if the hppb driver should claim this device.
41 * @dev: The device which has been found
42 *
43 * Determine if hppb driver should claim this chip (return 0) or not
44 * (return 1). If so, initialize the chip and tell other partners in crime
45 * they have work to do.
46 */
47static int hppb_probe(struct parisc_device *dev)
48{
49 int status;
50 struct hppb_card *card = &hppb_card_head;
51
52 while(card->next) {
53 card = card->next;
54 }
55
56 if(card->hpa) {
Helge Dellercb6fc182006-01-17 12:40:40 -070057 card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 if(!card->next) {
59 printk(KERN_ERR "HP-PB: Unable to allocate memory.\n");
60 return 1;
61 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 card = card->next;
63 }
Ryan Bradetich075b8782006-11-03 05:05:01 +000064 printk(KERN_INFO "Found GeckoBoa at 0x%x\n", dev->hpa.start);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040066 card->hpa = dev->hpa.start;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 card->mmio_region.name = "HP-PB Bus";
68 card->mmio_region.flags = IORESOURCE_MEM;
69
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040070 card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW);
71 card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73 status = ccio_request_resource(dev, &card->mmio_region);
74 if(status < 0) {
Ryan Bradetich075b8782006-11-03 05:05:01 +000075 printk(KERN_ERR "%s: failed to claim HP-PB bus space (%08x, %08x)\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 __FILE__, card->mmio_region.start, card->mmio_region.end);
77 }
78
79 return 0;
80}
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082static struct parisc_device_id hppb_tbl[] = {
Ryan Bradetich075b8782006-11-03 05:05:01 +000083 { HPHW_BCPORT, HVERSION_REV_ANY_ID, 0x500, 0xc }, /* E25 and K */
84 { HPHW_BCPORT, 0x0, 0x501, 0xc }, /* E35 */
85 { HPHW_BCPORT, 0x0, 0x502, 0xc }, /* E45 */
86 { HPHW_BCPORT, 0x0, 0x503, 0xc }, /* E55 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 { 0, }
88};
89
90static struct parisc_driver hppb_driver = {
Matthew Wilcoxbdad1f82005-10-21 22:36:23 -040091 .name = "gecko_boa",
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 .id_table = hppb_tbl,
93 .probe = hppb_probe,
94};
95
96/**
97 * hppb_init - HP-PB bus initalization procedure.
98 *
99 * Register this driver.
100 */
101void __init hppb_init(void)
102{
103 register_parisc_driver(&hppb_driver);
104}