blob: 07dc2b6d4e933e3ade9c442e308bd022fa3ac5dd [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**
13** This Driver currently only supports the console (port 0) on the MUX.
14** Additional work will be needed on this driver to enable the full
15** functionality of the MUX.
16**
17*/
18
19#include <linux/types.h>
20#include <linux/init.h>
21#include <linux/mm.h>
22#include <linux/slab.h>
23#include <linux/ioport.h>
24
25#include <asm/io.h>
26#include <asm/hardware.h>
27#include <asm/parisc-device.h>
28
29#include <linux/pci.h>
30
31struct hppb_card {
32 unsigned long hpa;
33 struct resource mmio_region;
34 struct hppb_card *next;
35};
36
37struct hppb_card hppb_card_head = {
38 .hpa = 0,
39 .next = NULL,
40};
41
42#define IO_IO_LOW offsetof(struct bc_module, io_io_low)
43#define IO_IO_HIGH offsetof(struct bc_module, io_io_high)
44
45/**
46 * hppb_probe - Determine if the hppb driver should claim this device.
47 * @dev: The device which has been found
48 *
49 * Determine if hppb driver should claim this chip (return 0) or not
50 * (return 1). If so, initialize the chip and tell other partners in crime
51 * they have work to do.
52 */
53static int hppb_probe(struct parisc_device *dev)
54{
55 int status;
56 struct hppb_card *card = &hppb_card_head;
57
58 while(card->next) {
59 card = card->next;
60 }
61
62 if(card->hpa) {
Helge Dellercb6fc182006-01-17 12:40:40 -070063 card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 if(!card->next) {
65 printk(KERN_ERR "HP-PB: Unable to allocate memory.\n");
66 return 1;
67 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 card = card->next;
69 }
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040070 printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa.start);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040072 card->hpa = dev->hpa.start;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 card->mmio_region.name = "HP-PB Bus";
74 card->mmio_region.flags = IORESOURCE_MEM;
75
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040076 card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW);
77 card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79 status = ccio_request_resource(dev, &card->mmio_region);
80 if(status < 0) {
81 printk(KERN_ERR "%s: failed to claim HP-PB bus space (%08lx, %08lx)\n",
82 __FILE__, card->mmio_region.start, card->mmio_region.end);
83 }
84
85 return 0;
86}
87
88
89static struct parisc_device_id hppb_tbl[] = {
90 { HPHW_BCPORT, HVERSION_REV_ANY_ID, 0x500, 0xc },
91 { 0, }
92};
93
94static struct parisc_driver hppb_driver = {
Matthew Wilcoxbdad1f82005-10-21 22:36:23 -040095 .name = "gecko_boa",
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 .id_table = hppb_tbl,
97 .probe = hppb_probe,
98};
99
100/**
101 * hppb_init - HP-PB bus initalization procedure.
102 *
103 * Register this driver.
104 */
105void __init hppb_init(void)
106{
107 register_parisc_driver(&hppb_driver);
108}