blob: 44e12c83cfa85eb2e9ad54211aa4cbe535b223c0 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3** hppb.c:
4** HP-PB bus driver for the NOVA and K-Class systems.
5**
6** (c) Copyright 2002 Ryan Bradetich
7** (c) Copyright 2002 Hewlett-Packard Company
8**
Linus Torvalds1da177e2005-04-16 15:20:36 -07009**
Linus Torvalds1da177e2005-04-16 15:20:36 -070010*/
11
12#include <linux/types.h>
13#include <linux/init.h>
14#include <linux/mm.h>
15#include <linux/slab.h>
Frank Lichtenheldbec85e82007-07-17 19:30:38 +020016#include <linux/dma-mapping.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/ioport.h>
18
19#include <asm/io.h>
20#include <asm/hardware.h>
21#include <asm/parisc-device.h>
22
Christoph Hellwig9b8eeab2019-01-29 19:13:04 +010023#include "iommu.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
Adrian Bunkdf8e5bc2008-12-02 03:28:16 +000031static struct hppb_card hppb_card_head = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 .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 */
Helge Dellercfe4fbf2017-08-21 22:02:19 +020047static int __init hppb_probe(struct parisc_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048{
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 }
Helge Dellercae5a392009-08-02 15:42:39 +020064 printk(KERN_INFO "Found GeckoBoa at 0x%llx\n",
65 (unsigned long long) dev->hpa.start);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040067 card->hpa = dev->hpa.start;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 card->mmio_region.name = "HP-PB Bus";
69 card->mmio_region.flags = IORESOURCE_MEM;
70
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040071 card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW);
72 card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74 status = ccio_request_resource(dev, &card->mmio_region);
75 if(status < 0) {
Joe Perches3fad9b82010-11-12 21:38:00 +000076 printk(KERN_ERR "%s: failed to claim HP-PB bus space (%pR)\n",
77 __FILE__, &card->mmio_region);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 }
79
80 return 0;
81}
82
Helge Dellercfe4fbf2017-08-21 22:02:19 +020083static const struct parisc_device_id hppb_tbl[] __initconst = {
Ryan Bradetich075b8782006-11-03 05:05:01 +000084 { HPHW_BCPORT, HVERSION_REV_ANY_ID, 0x500, 0xc }, /* E25 and K */
85 { HPHW_BCPORT, 0x0, 0x501, 0xc }, /* E35 */
86 { HPHW_BCPORT, 0x0, 0x502, 0xc }, /* E45 */
87 { HPHW_BCPORT, 0x0, 0x503, 0xc }, /* E55 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 { 0, }
89};
90
Helge Dellercfe4fbf2017-08-21 22:02:19 +020091static struct parisc_driver hppb_driver __refdata = {
Matthew Wilcoxbdad1f82005-10-21 22:36:23 -040092 .name = "gecko_boa",
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 .id_table = hppb_tbl,
94 .probe = hppb_probe,
95};
96
97/**
Joe Perches4f63ba12008-02-03 17:24:37 +020098 * hppb_init - HP-PB bus initialization procedure.
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 *
100 * Register this driver.
101 */
102void __init hppb_init(void)
103{
104 register_parisc_driver(&hppb_driver);
105}