Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
[linux-block.git] / drivers / parisc / hppb.c
CommitLineData
1da177e4
LT
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**
1da177e4
LT
13*/
14
15#include <linux/types.h>
16#include <linux/init.h>
17#include <linux/mm.h>
18#include <linux/slab.h>
bec85e80 19#include <linux/dma-mapping.h>
1da177e4
LT
20#include <linux/ioport.h>
21
22#include <asm/io.h>
23#include <asm/hardware.h>
24#include <asm/parisc-device.h>
25
9b8eeab0
CH
26#include "iommu.h"
27
1da177e4
LT
28struct hppb_card {
29 unsigned long hpa;
30 struct resource mmio_region;
31 struct hppb_card *next;
32};
33
df8e5bc6 34static struct hppb_card hppb_card_head = {
1da177e4
LT
35 .hpa = 0,
36 .next = NULL,
37};
38
39#define IO_IO_LOW offsetof(struct bc_module, io_io_low)
40#define IO_IO_HIGH offsetof(struct bc_module, io_io_high)
41
42/**
43 * hppb_probe - Determine if the hppb driver should claim this device.
44 * @dev: The device which has been found
45 *
46 * Determine if hppb driver should claim this chip (return 0) or not
47 * (return 1). If so, initialize the chip and tell other partners in crime
48 * they have work to do.
49 */
cfe4fbfb 50static int __init hppb_probe(struct parisc_device *dev)
1da177e4
LT
51{
52 int status;
53 struct hppb_card *card = &hppb_card_head;
54
55 while(card->next) {
56 card = card->next;
57 }
58
59 if(card->hpa) {
cb6fc18e 60 card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL);
1da177e4
LT
61 if(!card->next) {
62 printk(KERN_ERR "HP-PB: Unable to allocate memory.\n");
63 return 1;
64 }
1da177e4
LT
65 card = card->next;
66 }
cae5a39f
HD
67 printk(KERN_INFO "Found GeckoBoa at 0x%llx\n",
68 (unsigned long long) dev->hpa.start);
1da177e4 69
53f01bba 70 card->hpa = dev->hpa.start;
1da177e4
LT
71 card->mmio_region.name = "HP-PB Bus";
72 card->mmio_region.flags = IORESOURCE_MEM;
73
53f01bba
MW
74 card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW);
75 card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1;
1da177e4
LT
76
77 status = ccio_request_resource(dev, &card->mmio_region);
78 if(status < 0) {
3fad9b8d
JP
79 printk(KERN_ERR "%s: failed to claim HP-PB bus space (%pR)\n",
80 __FILE__, &card->mmio_region);
1da177e4
LT
81 }
82
83 return 0;
84}
85
cfe4fbfb 86static const struct parisc_device_id hppb_tbl[] __initconst = {
075b8783
RB
87 { HPHW_BCPORT, HVERSION_REV_ANY_ID, 0x500, 0xc }, /* E25 and K */
88 { HPHW_BCPORT, 0x0, 0x501, 0xc }, /* E35 */
89 { HPHW_BCPORT, 0x0, 0x502, 0xc }, /* E45 */
90 { HPHW_BCPORT, 0x0, 0x503, 0xc }, /* E55 */
1da177e4
LT
91 { 0, }
92};
93
cfe4fbfb 94static struct parisc_driver hppb_driver __refdata = {
bdad1f83 95 .name = "gecko_boa",
1da177e4
LT
96 .id_table = hppb_tbl,
97 .probe = hppb_probe,
98};
99
100/**
4f63ba17 101 * hppb_init - HP-PB bus initialization procedure.
1da177e4
LT
102 *
103 * Register this driver.
104 */
105void __init hppb_init(void)
106{
107 register_parisc_driver(&hppb_driver);
108}