nark.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Adaptec AAC series RAID controller driver
  3. *
  4. * based on the old aacraid driver that is..
  5. * Adaptec aacraid device driver for Linux.
  6. *
  7. * Copyright (c) 2000-2010 Adaptec, Inc.
  8. * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
  9. * 2016-2017 Microsemi Corp. (aacraid@microsemi.com)
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2, or (at your option)
  14. * any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; see the file COPYING. If not, write to
  23. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24. *
  25. * Module Name:
  26. * nark.c
  27. *
  28. * Abstract: Hardware Device Interface for NEMER/ARK
  29. *
  30. */
  31. #include <linux/pci.h>
  32. #include <linux/blkdev.h>
  33. #include <scsi/scsi_host.h>
  34. #include "aacraid.h"
  35. /**
  36. * aac_nark_ioremap
  37. * @size: mapping resize request
  38. *
  39. */
  40. static int aac_nark_ioremap(struct aac_dev * dev, u32 size)
  41. {
  42. if (!size) {
  43. iounmap(dev->regs.rx);
  44. dev->regs.rx = NULL;
  45. iounmap(dev->base);
  46. dev->base = NULL;
  47. return 0;
  48. }
  49. dev->base_start = pci_resource_start(dev->pdev, 2);
  50. dev->regs.rx = ioremap((u64)pci_resource_start(dev->pdev, 0) |
  51. ((u64)pci_resource_start(dev->pdev, 1) << 32),
  52. sizeof(struct rx_registers) - sizeof(struct rx_inbound));
  53. dev->base = NULL;
  54. if (dev->regs.rx == NULL)
  55. return -1;
  56. dev->base = ioremap(dev->base_start, size);
  57. if (dev->base == NULL) {
  58. iounmap(dev->regs.rx);
  59. dev->regs.rx = NULL;
  60. return -1;
  61. }
  62. dev->IndexRegs = &((struct rx_registers __iomem *)dev->base)->IndexRegs;
  63. return 0;
  64. }
  65. /**
  66. * aac_nark_init - initialize an NEMER/ARK Split Bar card
  67. * @dev: device to configure
  68. *
  69. */
  70. int aac_nark_init(struct aac_dev * dev)
  71. {
  72. /*
  73. * Fill in the function dispatch table.
  74. */
  75. dev->a_ops.adapter_ioremap = aac_nark_ioremap;
  76. dev->a_ops.adapter_comm = aac_rx_select_comm;
  77. return _aac_rx_init(dev);
  78. }