mic_x100.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Intel MIC Platform Software Stack (MPSS)
  3. *
  4. * Copyright(c) 2013 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License, version 2, as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Intel MIC Host driver.
  19. *
  20. */
  21. #include <linux/fs.h>
  22. #include <linux/pci.h>
  23. #include "../common/mic_device.h"
  24. #include "mic_device.h"
  25. #include "mic_x100.h"
  26. /**
  27. * mic_x100_write_spad - write to the scratchpad register
  28. * @mdev: pointer to mic_device instance
  29. * @idx: index to the scratchpad register, 0 based
  30. * @val: the data value to put into the register
  31. *
  32. * This function allows writing of a 32bit value to the indexed scratchpad
  33. * register.
  34. *
  35. * RETURNS: none.
  36. */
  37. static void
  38. mic_x100_write_spad(struct mic_device *mdev, unsigned int idx, u32 val)
  39. {
  40. dev_dbg(mdev->sdev->parent, "Writing 0x%x to scratch pad index %d\n",
  41. val, idx);
  42. mic_mmio_write(&mdev->mmio, val,
  43. MIC_X100_SBOX_BASE_ADDRESS +
  44. MIC_X100_SBOX_SPAD0 + idx * 4);
  45. }
  46. /**
  47. * mic_x100_read_spad - read from the scratchpad register
  48. * @mdev: pointer to mic_device instance
  49. * @idx: index to scratchpad register, 0 based
  50. *
  51. * This function allows reading of the 32bit scratchpad register.
  52. *
  53. * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
  54. */
  55. static u32
  56. mic_x100_read_spad(struct mic_device *mdev, unsigned int idx)
  57. {
  58. u32 val = mic_mmio_read(&mdev->mmio,
  59. MIC_X100_SBOX_BASE_ADDRESS +
  60. MIC_X100_SBOX_SPAD0 + idx * 4);
  61. dev_dbg(mdev->sdev->parent,
  62. "Reading 0x%x from scratch pad index %d\n", val, idx);
  63. return val;
  64. }
  65. struct mic_hw_ops mic_x100_ops = {
  66. .aper_bar = MIC_X100_APER_BAR,
  67. .mmio_bar = MIC_X100_MMIO_BAR,
  68. .read_spad = mic_x100_read_spad,
  69. .write_spad = mic_x100_write_spad,
  70. };