blob: 7a1747b4528e326c94b726ce20a6774356056859 [file] [log] [blame]
Nicholas Flintham9fafe902014-03-31 13:51:31 +01001/*
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/dma-mapping.h>
20#include <linux/ioport.h>
21
22#include <asm/io.h>
23#include <asm/hardware.h>
24#include <asm/parisc-device.h>
25
26struct hppb_card {
27 unsigned long hpa;
28 struct resource mmio_region;
29 struct hppb_card *next;
30};
31
32static struct hppb_card hppb_card_head = {
33 .hpa = 0,
34 .next = NULL,
35};
36
37#define IO_IO_LOW offsetof(struct bc_module, io_io_low)
38#define IO_IO_HIGH offsetof(struct bc_module, io_io_high)
39
40static int hppb_probe(struct parisc_device *dev)
41{
42 int status;
43 struct hppb_card *card = &hppb_card_head;
44
45 while(card->next) {
46 card = card->next;
47 }
48
49 if(card->hpa) {
50 card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL);
51 if(!card->next) {
52 printk(KERN_ERR "HP-PB: Unable to allocate memory.\n");
53 return 1;
54 }
55 card = card->next;
56 }
57 printk(KERN_INFO "Found GeckoBoa at 0x%llx\n",
58 (unsigned long long) dev->hpa.start);
59
60 card->hpa = dev->hpa.start;
61 card->mmio_region.name = "HP-PB Bus";
62 card->mmio_region.flags = IORESOURCE_MEM;
63
64 card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW);
65 card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1;
66
67 status = ccio_request_resource(dev, &card->mmio_region);
68 if(status < 0) {
69 printk(KERN_ERR "%s: failed to claim HP-PB "
70 "bus space (0x%08llx, 0x%08llx)\n",
71 __FILE__, (unsigned long long) card->mmio_region.start,
72 (unsigned long long) card->mmio_region.end);
73 }
74
75 return 0;
76}
77
78static struct parisc_device_id hppb_tbl[] = {
79 { HPHW_BCPORT, HVERSION_REV_ANY_ID, 0x500, 0xc },
80 { HPHW_BCPORT, 0x0, 0x501, 0xc },
81 { HPHW_BCPORT, 0x0, 0x502, 0xc },
82 { HPHW_BCPORT, 0x0, 0x503, 0xc },
83 { 0, }
84};
85
86static struct parisc_driver hppb_driver = {
87 .name = "gecko_boa",
88 .id_table = hppb_tbl,
89 .probe = hppb_probe,
90};
91
92void __init hppb_init(void)
93{
94 register_parisc_driver(&hppb_driver);
95}