sigmadsp-regmap.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Load Analog Devices SigmaStudio firmware files
  4. *
  5. * Copyright 2009-2011 Analog Devices Inc.
  6. */
  7. #include <linux/regmap.h>
  8. #include <linux/export.h>
  9. #include <linux/module.h>
  10. #include "sigmadsp.h"
  11. static int sigmadsp_write_regmap(void *control_data,
  12. unsigned int addr, const uint8_t data[], size_t len)
  13. {
  14. return regmap_raw_write(control_data, addr,
  15. data, len);
  16. }
  17. static int sigmadsp_read_regmap(void *control_data,
  18. unsigned int addr, uint8_t data[], size_t len)
  19. {
  20. return regmap_raw_read(control_data, addr,
  21. data, len);
  22. }
  23. /**
  24. * devm_sigmadsp_init_i2c() - Initialize SigmaDSP instance
  25. * @dev: The parent device
  26. * @regmap: Regmap instance to use
  27. * @ops: The sigmadsp_ops to use for this instance
  28. * @firmware_name: Name of the firmware file to load
  29. *
  30. * Allocates a SigmaDSP instance and loads the specified firmware file.
  31. *
  32. * Returns a pointer to a struct sigmadsp on success, or a PTR_ERR() on error.
  33. */
  34. struct sigmadsp *devm_sigmadsp_init_regmap(struct device *dev,
  35. struct regmap *regmap, const struct sigmadsp_ops *ops,
  36. const char *firmware_name)
  37. {
  38. struct sigmadsp *sigmadsp;
  39. sigmadsp = devm_sigmadsp_init(dev, ops, firmware_name);
  40. if (IS_ERR(sigmadsp))
  41. return sigmadsp;
  42. sigmadsp->control_data = regmap;
  43. sigmadsp->write = sigmadsp_write_regmap;
  44. sigmadsp->read = sigmadsp_read_regmap;
  45. return sigmadsp;
  46. }
  47. EXPORT_SYMBOL_GPL(devm_sigmadsp_init_regmap);
  48. MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
  49. MODULE_DESCRIPTION("SigmaDSP regmap firmware loader");
  50. MODULE_LICENSE("GPL");