hppb.c 2.8 KB

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