rkt.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Adaptec AAC series RAID controller driver
  3. * (c) Copyright 2001 Red Hat Inc.
  4. *
  5. * based on the old aacraid driver that is..
  6. * Adaptec aacraid device driver for Linux.
  7. *
  8. * Copyright (c) 2000-2010 Adaptec, Inc.
  9. * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
  10. * 2016-2017 Microsemi Corp. (aacraid@microsemi.com)
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2, or (at your option)
  15. * any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; see the file COPYING. If not, write to
  24. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25. *
  26. * Module Name:
  27. * rkt.c
  28. *
  29. * Abstract: Hardware miniport for Drawbridge specific hardware functions.
  30. *
  31. */
  32. #include <linux/blkdev.h>
  33. #include <scsi/scsi_host.h>
  34. #include "aacraid.h"
  35. #define AAC_NUM_IO_FIB_RKT (246 - AAC_NUM_MGT_FIB)
  36. /**
  37. * aac_rkt_select_comm - Select communications method
  38. * @dev: Adapter
  39. * @comm: communications method
  40. */
  41. static int aac_rkt_select_comm(struct aac_dev *dev, int comm)
  42. {
  43. int retval;
  44. retval = aac_rx_select_comm(dev, comm);
  45. if (comm == AAC_COMM_MESSAGE) {
  46. /*
  47. * FIB Setup has already been done, but we can minimize the
  48. * damage by at least ensuring the OS never issues more
  49. * commands than we can handle. The Rocket adapters currently
  50. * can only handle 246 commands and 8 AIFs at the same time,
  51. * and in fact do notify us accordingly if we negotiate the
  52. * FIB size. The problem that causes us to add this check is
  53. * to ensure that we do not overdo it with the adapter when a
  54. * hard coded FIB override is being utilized. This special
  55. * case warrants this half baked, but convenient, check here.
  56. */
  57. if (dev->scsi_host_ptr->can_queue > AAC_NUM_IO_FIB_RKT) {
  58. dev->init->r7.max_io_commands =
  59. cpu_to_le32(AAC_NUM_IO_FIB_RKT + AAC_NUM_MGT_FIB);
  60. dev->scsi_host_ptr->can_queue = AAC_NUM_IO_FIB_RKT;
  61. }
  62. }
  63. return retval;
  64. }
  65. /**
  66. * aac_rkt_ioremap
  67. * @size: mapping resize request
  68. *
  69. */
  70. static int aac_rkt_ioremap(struct aac_dev * dev, u32 size)
  71. {
  72. if (!size) {
  73. iounmap(dev->regs.rkt);
  74. return 0;
  75. }
  76. dev->base = dev->regs.rkt = ioremap(dev->base_start, size);
  77. if (dev->base == NULL)
  78. return -1;
  79. dev->IndexRegs = &dev->regs.rkt->IndexRegs;
  80. return 0;
  81. }
  82. /**
  83. * aac_rkt_init - initialize an i960 based AAC card
  84. * @dev: device to configure
  85. *
  86. * Allocate and set up resources for the i960 based AAC variants. The
  87. * device_interface in the commregion will be allocated and linked
  88. * to the comm region.
  89. */
  90. int aac_rkt_init(struct aac_dev *dev)
  91. {
  92. /*
  93. * Fill in the function dispatch table.
  94. */
  95. dev->a_ops.adapter_ioremap = aac_rkt_ioremap;
  96. dev->a_ops.adapter_comm = aac_rkt_select_comm;
  97. return _aac_rx_init(dev);
  98. }