sigmadsp-regmap.c 1.5 KB

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