Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Load Analog Devices SigmaStudio firmware files
0004  *
0005  * Copyright 2009-2011 Analog Devices Inc.
0006  */
0007 
0008 #include <linux/regmap.h>
0009 #include <linux/export.h>
0010 #include <linux/module.h>
0011 
0012 #include "sigmadsp.h"
0013 
0014 static int sigmadsp_write_regmap(void *control_data,
0015     unsigned int addr, const uint8_t data[], size_t len)
0016 {
0017     return regmap_raw_write(control_data, addr,
0018         data, len);
0019 }
0020 
0021 static int sigmadsp_read_regmap(void *control_data,
0022     unsigned int addr, uint8_t data[], size_t len)
0023 {
0024     return regmap_raw_read(control_data, addr,
0025         data, len);
0026 }
0027 
0028 /**
0029  * devm_sigmadsp_init_regmap() - Initialize SigmaDSP instance
0030  * @dev: The parent device
0031  * @regmap: Regmap instance to use
0032  * @ops: The sigmadsp_ops to use for this instance
0033  * @firmware_name: Name of the firmware file to load
0034  *
0035  * Allocates a SigmaDSP instance and loads the specified firmware file.
0036  *
0037  * Returns a pointer to a struct sigmadsp on success, or a PTR_ERR() on error.
0038  */
0039 struct sigmadsp *devm_sigmadsp_init_regmap(struct device *dev,
0040     struct regmap *regmap, const struct sigmadsp_ops *ops,
0041     const char *firmware_name)
0042 {
0043     struct sigmadsp *sigmadsp;
0044 
0045     sigmadsp = devm_sigmadsp_init(dev, ops, firmware_name);
0046     if (IS_ERR(sigmadsp))
0047         return sigmadsp;
0048 
0049     sigmadsp->control_data = regmap;
0050     sigmadsp->write = sigmadsp_write_regmap;
0051     sigmadsp->read = sigmadsp_read_regmap;
0052 
0053     return sigmadsp;
0054 }
0055 EXPORT_SYMBOL_GPL(devm_sigmadsp_init_regmap);
0056 
0057 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
0058 MODULE_DESCRIPTION("SigmaDSP regmap firmware loader");
0059 MODULE_LICENSE("GPL");