Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003 ** hppb.c:
0004 **      HP-PB bus driver for the NOVA and K-Class systems.
0005 **
0006 **      (c) Copyright 2002 Ryan Bradetich
0007 **      (c) Copyright 2002 Hewlett-Packard Company
0008 **
0009 **
0010 */
0011 
0012 #include <linux/types.h>
0013 #include <linux/init.h>
0014 #include <linux/mm.h>
0015 #include <linux/slab.h>
0016 #include <linux/dma-mapping.h>
0017 #include <linux/ioport.h>
0018 
0019 #include <asm/io.h>
0020 #include <asm/hardware.h>
0021 #include <asm/parisc-device.h>
0022 
0023 #include "iommu.h"
0024 
0025 struct hppb_card {
0026     unsigned long hpa;
0027     struct resource mmio_region;
0028     struct hppb_card *next;
0029 };
0030 
0031 static struct hppb_card hppb_card_head = {
0032     .hpa = 0,
0033     .next = NULL,
0034 };
0035 
0036 #define IO_IO_LOW  offsetof(struct bc_module, io_io_low)
0037 #define IO_IO_HIGH offsetof(struct bc_module, io_io_high)
0038 
0039 /**
0040  * hppb_probe - Determine if the hppb driver should claim this device.
0041  * @dev: The device which has been found
0042  *
0043  * Determine if hppb driver should claim this chip (return 0) or not 
0044  * (return 1). If so, initialize the chip and tell other partners in crime 
0045  * they have work to do.
0046  */
0047 static int __init hppb_probe(struct parisc_device *dev)
0048 {
0049     int status;
0050     struct hppb_card *card = &hppb_card_head;
0051 
0052     while(card->next) {
0053         card = card->next;
0054     }
0055 
0056     if(card->hpa) {
0057         card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL);
0058         if(!card->next) {
0059             printk(KERN_ERR "HP-PB: Unable to allocate memory.\n");
0060             return 1;
0061         }
0062         card = card->next;
0063     }
0064 
0065     card->hpa = dev->hpa.start;
0066     card->mmio_region.name = "HP-PB Bus";
0067     card->mmio_region.flags = IORESOURCE_MEM;
0068 
0069     card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW);
0070     card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1;
0071 
0072     status = ccio_request_resource(dev, &card->mmio_region);
0073 
0074     pr_info("Found GeckoBoa at %pap, bus space %pR,%s claimed.\n",
0075             &dev->hpa.start,
0076             &card->mmio_region,
0077             (status < 0) ? " not":"" );
0078 
0079         return 0;
0080 }
0081 
0082 static const struct parisc_device_id hppb_tbl[] __initconst = {
0083         { HPHW_BCPORT, HVERSION_REV_ANY_ID, 0x500, 0xc }, /* E25 and K */
0084         { HPHW_BCPORT, 0x0, 0x501, 0xc }, /* E35 */
0085         { HPHW_BCPORT, 0x0, 0x502, 0xc }, /* E45 */
0086         { HPHW_BCPORT, 0x0, 0x503, 0xc }, /* E55 */
0087         { 0, }
0088 };
0089 
0090 static struct parisc_driver hppb_driver __refdata = {
0091         .name =         "gecko_boa",
0092         .id_table =     hppb_tbl,
0093     .probe =        hppb_probe,
0094 };
0095 
0096 /**
0097  * hppb_init - HP-PB bus initialization procedure.
0098  *
0099  * Register this driver.   
0100  */
0101 void __init hppb_init(void)
0102 {
0103         register_parisc_driver(&hppb_driver);
0104 }