Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | ** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <linux/types.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/mm.h> |
| 18 | #include <linux/slab.h> |
Frank Lichtenheld | bec85e8 | 2007-07-17 19:30:38 +0200 | [diff] [blame] | 19 | #include <linux/dma-mapping.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/ioport.h> |
| 21 | |
| 22 | #include <asm/io.h> |
| 23 | #include <asm/hardware.h> |
| 24 | #include <asm/parisc-device.h> |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | struct hppb_card { |
| 27 | unsigned long hpa; |
| 28 | struct resource mmio_region; |
| 29 | struct hppb_card *next; |
| 30 | }; |
| 31 | |
Adrian Bunk | df8e5bc | 2008-12-02 03:28:16 +0000 | [diff] [blame] | 32 | static struct hppb_card hppb_card_head = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 40 | /** |
| 41 | * hppb_probe - Determine if the hppb driver should claim this device. |
| 42 | * @dev: The device which has been found |
| 43 | * |
| 44 | * Determine if hppb driver should claim this chip (return 0) or not |
| 45 | * (return 1). If so, initialize the chip and tell other partners in crime |
| 46 | * they have work to do. |
| 47 | */ |
| 48 | static int hppb_probe(struct parisc_device *dev) |
| 49 | { |
| 50 | int status; |
| 51 | struct hppb_card *card = &hppb_card_head; |
| 52 | |
| 53 | while(card->next) { |
| 54 | card = card->next; |
| 55 | } |
| 56 | |
| 57 | if(card->hpa) { |
Helge Deller | cb6fc18 | 2006-01-17 12:40:40 -0700 | [diff] [blame] | 58 | card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | if(!card->next) { |
| 60 | printk(KERN_ERR "HP-PB: Unable to allocate memory.\n"); |
| 61 | return 1; |
| 62 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | card = card->next; |
| 64 | } |
Helge Deller | cae5a39 | 2009-08-02 15:42:39 +0200 | [diff] [blame] | 65 | printk(KERN_INFO "Found GeckoBoa at 0x%llx\n", |
| 66 | (unsigned long long) dev->hpa.start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Matthew Wilcox | 53f01bb | 2005-10-21 22:36:40 -0400 | [diff] [blame] | 68 | card->hpa = dev->hpa.start; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | card->mmio_region.name = "HP-PB Bus"; |
| 70 | card->mmio_region.flags = IORESOURCE_MEM; |
| 71 | |
Matthew Wilcox | 53f01bb | 2005-10-21 22:36:40 -0400 | [diff] [blame] | 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; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | status = ccio_request_resource(dev, &card->mmio_region); |
| 76 | if(status < 0) { |
Helge Deller | cae5a39 | 2009-08-02 15:42:39 +0200 | [diff] [blame] | 77 | printk(KERN_ERR "%s: failed to claim HP-PB " |
| 78 | "bus space (0x%08llx, 0x%08llx)\n", |
| 79 | __FILE__, (unsigned long long) card->mmio_region.start, |
| 80 | (unsigned long long) card->mmio_region.end); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | return 0; |
| 84 | } |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | static struct parisc_device_id hppb_tbl[] = { |
Ryan Bradetich | 075b878 | 2006-11-03 05:05:01 +0000 | [diff] [blame] | 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 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | { 0, } |
| 92 | }; |
| 93 | |
| 94 | static struct parisc_driver hppb_driver = { |
Matthew Wilcox | bdad1f8 | 2005-10-21 22:36:23 -0400 | [diff] [blame] | 95 | .name = "gecko_boa", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | .id_table = hppb_tbl, |
| 97 | .probe = hppb_probe, |
| 98 | }; |
| 99 | |
| 100 | /** |
Joe Perches | 4f63ba1 | 2008-02-03 17:24:37 +0200 | [diff] [blame] | 101 | * hppb_init - HP-PB bus initialization procedure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | * |
| 103 | * Register this driver. |
| 104 | */ |
| 105 | void __init hppb_init(void) |
| 106 | { |
| 107 | register_parisc_driver(&hppb_driver); |
| 108 | } |