hppb.c 2.7 KB

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