2 * Load Analog Devices SigmaStudio firmware files
4 * Copyright 2009-2011 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
9 #include <linux/export.h>
10 #include <linux/i2c.h>
11 #include <linux/module.h>
12 #include <linux/slab.h>
13 #include <asm/unaligned.h>
17 static int sigmadsp_write_i2c(void *control_data
,
18 unsigned int addr
, const uint8_t data
[], size_t len
)
23 buf
= kzalloc(2 + len
, GFP_KERNEL
| GFP_DMA
);
27 put_unaligned_be16(addr
, buf
);
28 memcpy(buf
+ 2, data
, len
);
30 ret
= i2c_master_send(control_data
, buf
, len
+ 2);
38 * devm_sigmadsp_init_i2c() - Initialize SigmaDSP instance
39 * @client: The parent I2C device
40 * @ops: The sigmadsp_ops to use for this instance
41 * @firmware_name: Name of the firmware file to load
43 * Allocates a SigmaDSP instance and loads the specified firmware file.
45 * Returns a pointer to a struct sigmadsp on success, or a PTR_ERR() on error.
47 struct sigmadsp
*devm_sigmadsp_init_i2c(struct i2c_client
*client
,
48 const struct sigmadsp_ops
*ops
, const char *firmware_name
)
50 struct sigmadsp
*sigmadsp
;
52 sigmadsp
= devm_sigmadsp_init(&client
->dev
, ops
, firmware_name
);
56 sigmadsp
->control_data
= client
;
57 sigmadsp
->write
= sigmadsp_write_i2c
;
61 EXPORT_SYMBOL_GPL(devm_sigmadsp_init_i2c
);
63 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
64 MODULE_DESCRIPTION("SigmaDSP I2C firmware loader");
65 MODULE_LICENSE("GPL");
This page took 0.03837 seconds and 5 git commands to generate.