hppb.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. **
  13. ** This Driver currently only supports the console (port 0) on the MUX.
  14. ** Additional work will be needed on this driver to enable the full
  15. ** functionality of the MUX.
  16. **
  17. */
  18. #include <linux/types.h>
  19. #include <linux/init.h>
  20. #include <linux/mm.h>
  21. #include <linux/slab.h>
  22. #include <linux/ioport.h>
  23. #include <asm/io.h>
  24. #include <asm/hardware.h>
  25. #include <asm/parisc-device.h>
  26. #include <linux/pci.h>
  27. struct hppb_card {
  28. unsigned long hpa;
  29. struct resource mmio_region;
  30. struct hppb_card *next;
  31. };
  32. struct hppb_card hppb_card_head = {
  33. .hpa = 0,
  34. .next = NULL,
  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. * hppb_probe - Determine if the hppb driver should claim this device.
  40. * @dev: The device which has been found
  41. *
  42. * Determine if hppb driver should claim this chip (return 0) or not
  43. * (return 1). If so, initialize the chip and tell other partners in crime
  44. * they have work to do.
  45. */
  46. static int hppb_probe(struct parisc_device *dev)
  47. {
  48. int status;
  49. struct hppb_card *card = &hppb_card_head;
  50. while(card->next) {
  51. card = card->next;
  52. }
  53. if(card->hpa) {
  54. card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL);
  55. if(!card->next) {
  56. printk(KERN_ERR "HP-PB: Unable to allocate memory.\n");
  57. return 1;
  58. }
  59. card = card->next;
  60. }
  61. printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa.start);
  62. card->hpa = dev->hpa.start;
  63. card->mmio_region.name = "HP-PB Bus";
  64. card->mmio_region.flags = IORESOURCE_MEM;
  65. card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW);
  66. card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1;
  67. status = ccio_request_resource(dev, &card->mmio_region);
  68. if(status < 0) {
  69. printk(KERN_ERR "%s: failed to claim HP-PB bus space (%08lx, %08lx)\n",
  70. __FILE__, card->mmio_region.start, card->mmio_region.end);
  71. }
  72. return 0;
  73. }
  74. static struct parisc_device_id hppb_tbl[] = {
  75. { HPHW_BCPORT, HVERSION_REV_ANY_ID, 0x500, 0xc },
  76. { 0, }
  77. };
  78. static struct parisc_driver hppb_driver = {
  79. .name = "gecko_boa",
  80. .id_table = hppb_tbl,
  81. .probe = hppb_probe,
  82. };
  83. /**
  84. * hppb_init - HP-PB bus initalization procedure.
  85. *
  86. * Register this driver.
  87. */
  88. void __init hppb_init(void)
  89. {
  90. register_parisc_driver(&hppb_driver);
  91. }