fci_hpi.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*****************************************************************************
  2. Copyright(c) 2013 FCI Inc. All Rights Reserved
  3. File name : fci_hpi.c
  4. Description : source of internal hpi driver
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. History :
  17. ----------------------------------------------------------------------
  18. *******************************************************************************/
  19. #include <linux/slab.h>
  20. #include "fci_types.h"
  21. #include "fci_hal.h"
  22. #include "fc8300_regs.h" /* deprecated */
  23. static DEFINE_MUTEX(fci_hpi_lock);
  24. s32 fci_hpi_init(HANDLE handle, DEVICEID devid, s32 speed, s32 slaveaddr)
  25. {
  26. return BBM_OK;
  27. }
  28. s32 fci_hpi_read(HANDLE handle, DEVICEID devid,
  29. u8 chip, u8 addr, u8 alen, u8 *data, u8 len)
  30. {
  31. s32 res;
  32. mutex_lock(&fci_hpi_lock);
  33. res = bbm_bulk_read(handle, devid, 0x0f00 | addr, data, len);
  34. mutex_unlock(&fci_hpi_lock);
  35. return res;
  36. }
  37. s32 fci_hpi_write(HANDLE handle, DEVICEID devid,
  38. u8 chip, u8 addr, u8 alen, u8 *data, u8 len)
  39. {
  40. #if !defined(BBM_I2C_SPI) && !defined(BBM_I2C_TSIF) /* ONLY ES SPI */
  41. s32 i;
  42. mutex_lock(&fci_hpi_lock);
  43. for (i = 0; i < len; i++, data++)
  44. bbm_word_write(handle, devid, 0x0f00 | addr,
  45. (*data << 8) | *data);
  46. mutex_unlock(&fci_hpi_lock);
  47. #else
  48. s32 i;
  49. mutex_lock(&fci_hpi_lock);
  50. for (i = 0; i < len; i++, data++)
  51. bbm_write(handle, devid, 0x0f00 | addr, *data);
  52. mutex_unlock(&fci_hpi_lock);
  53. #endif
  54. return BBM_OK;
  55. }
  56. s32 fci_hpi_deinit(HANDLE handle, DEVICEID devid)
  57. {
  58. return BBM_OK;
  59. }