hppb.c 2.5 KB

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