Commit 8b880f48 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'asoc/fix/ab8500' into asoc-linus

parents 5e01dc7b 63e6d43b
CS42L73 audio CODEC
Required properties:
- compatible : "cirrus,cs42l73"
- reg : the I2C address of the device for I2C
Optional properties:
- reset_gpio : a GPIO spec for the reset pin.
- chgfreq : Charge Pump Frequency values 0x00-0x0F
Example:
codec: cs42l73@4a {
compatible = "cirrus,cs42l73";
reg = <0x4a>;
reset_gpio = <&gpio 10 0>;
chgfreq = <0x05>;
};
\ No newline at end of file
* Texas Instruments SoC audio setups with TLV320AIC3X Codec
Required properties:
- compatible : "ti,da830-evm-audio" : forDM365/DA8xx/OMAPL1x/AM33xx
- ti,model : The user-visible name of this sound complex.
- ti,audio-codec : The phandle of the TLV320AIC3x audio codec
- ti,mcasp-controller : The phandle of the McASP controller
- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec
- ti,audio-routing : A list of the connections between audio components.
Each entry is a pair of strings, the first being the connection's sink,
the second being the connection's source. Valid names for sources and
sinks are the codec's pins, and the jacks on the board:
Board connectors:
* Headphone Jack
* Line Out
* Mic Jack
* Line In
Example:
sound {
compatible = "ti,da830-evm-audio";
ti,model = "DA830 EVM";
ti,audio-codec = <&tlv320aic3x>;
ti,mcasp-controller = <&mcasp1>;
ti,codec-clock-rate = <12000000>;
ti,audio-routing =
"Headphone Jack", "HPLOUT",
"Headphone Jack", "HPROUT",
"Line Out", "LLOUT",
"Line Out", "RLOUT",
"MIC3L", "Mic Bias 2V",
"MIC3R", "Mic Bias 2V",
"Mic Bias 2V", "Mic Jack",
"LINE1L", "Line In",
"LINE2L", "Line In",
"LINE1R", "Line In",
"LINE2R", "Line In";
};
...@@ -4,17 +4,25 @@ Required properties: ...@@ -4,17 +4,25 @@ Required properties:
- compatible : - compatible :
"ti,dm646x-mcasp-audio" : for DM646x platforms "ti,dm646x-mcasp-audio" : for DM646x platforms
"ti,da830-mcasp-audio" : for both DA830 & DA850 platforms "ti,da830-mcasp-audio" : for both DA830 & DA850 platforms
"ti,omap2-mcasp-audio" : for OMAP2 platforms (TI81xx, AM33xx) "ti,am33xx-mcasp-audio" : for AM33xx platforms (AM33xx, TI81xx)
- reg : Should contain McASP registers offset and length
- interrupts : Interrupt number for McASP
- op-mode : I2S/DIT ops mode.
- tdm-slots : Slots for TDM operation.
- num-serializer : Serializers used by McASP.
- serial-dir : A list of serializer pin mode. The list number should be equal
to "num-serializer" parameter. Each entry is a number indication
serializer pin direction. (0 - INACTIVE, 1 - TX, 2 - RX)
- reg : Should contain reg specifiers for the entries in the reg-names property.
- reg-names : Should contain:
* "mpu" for the main registers (required). For compatibility with
existing software, it is recommended this is the first entry.
* "dat" for separate data port register access (optional).
- op-mode : I2S/DIT ops mode. 0 for I2S mode. 1 for DIT mode used for S/PDIF,
IEC60958-1, and AES-3 formats.
- tdm-slots : Slots for TDM operation. Indicates number of channels transmitted
or received over one serializer.
- serial-dir : A list of serializer configuration. Each entry is a number
indication for serializer pin direction.
(0 - INACTIVE, 1 - TX, 2 - RX)
- dmas: two element list of DMA controller phandles and DMA request line
ordered pairs.
- dma-names: identifier string for each DMA request line in the dmas property.
These strings correspond 1:1 with the ordered pairs in dmas. The dma
identifiers must be "rx" and "tx".
Optional properties: Optional properties:
...@@ -23,18 +31,23 @@ Optional properties: ...@@ -23,18 +31,23 @@ Optional properties:
- rx-num-evt : FIFO levels. - rx-num-evt : FIFO levels.
- sram-size-playback : size of sram to be allocated during playback - sram-size-playback : size of sram to be allocated during playback
- sram-size-capture : size of sram to be allocated during capture - sram-size-capture : size of sram to be allocated during capture
- interrupts : Interrupt numbers for McASP, currently not used by the driver
- interrupt-names : Known interrupt names are "tx" and "rx"
- pinctrl-0: Should specify pin control group used for this controller.
- pinctrl-names: Should contain only one value - "default", for more details
please refer to pinctrl-bindings.txt
Example: Example:
mcasp0: mcasp0@1d00000 { mcasp0: mcasp0@1d00000 {
compatible = "ti,da830-mcasp-audio"; compatible = "ti,da830-mcasp-audio";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x100000 0x3000>; reg = <0x100000 0x3000>;
interrupts = <82 83>; reg-names "mpu";
interrupts = <82>, <83>;
interrupts-names = "tx", "rx";
op-mode = <0>; /* MCASP_IIS_MODE */ op-mode = <0>; /* MCASP_IIS_MODE */
tdm-slots = <2>; tdm-slots = <2>;
num-serializer = <16>;
serial-dir = < serial-dir = <
0 0 0 0 /* 0: INACTIVE, 1: TX, 2: RX */ 0 0 0 0 /* 0: INACTIVE, 1: TX, 2: RX */
0 0 0 0 0 0 0 0
......
...@@ -24,10 +24,36 @@ Optional properties: ...@@ -24,10 +24,36 @@ Optional properties:
3 - MICBIAS output is connected to AVDD, 3 - MICBIAS output is connected to AVDD,
If this node is not mentioned or if the value is incorrect, then MicBias If this node is not mentioned or if the value is incorrect, then MicBias
is powered down. is powered down.
- AVDD-supply, IOVDD-supply, DRVDD-supply, DVDD-supply : power supplies for the
device as covered in Documentation/devicetree/bindings/regulator/regulator.txt
CODEC output pins:
* LLOUT
* RLOUT
* MONO_LOUT
* HPLOUT
* HPROUT
* HPLCOM
* HPRCOM
CODEC input pins:
* MIC3L
* MIC3R
* LINE1L
* LINE2L
* LINE1R
* LINE2R
The pins can be used in referring sound node's audio-routing property.
Example: Example:
tlv320aic3x: tlv320aic3x@1b { tlv320aic3x: tlv320aic3x@1b {
compatible = "ti,tlv320aic3x"; compatible = "ti,tlv320aic3x";
reg = <0x1b>; reg = <0x1b>;
AVDD-supply = <&regulator>;
IOVDD-supply = <&regulator>;
DRVDD-supply = <&regulator>;
DVDD-supply = <&regulator>;
}; };
Texas Instruments - tpa6130a2 Codec module
The tpa6130a2 serial control bus communicates through I2C protocols
Required properties:
- compatible - "string" - One of:
"ti,tpa6130a2" - TPA6130A2
"ti,tpa6140a2" - TPA6140A2
- reg - <int> - I2C slave address
- Vdd-supply - <phandle> - power supply regulator
Optional properties:
- power-gpio - gpio pin to power the device
Example:
tpa6130a2: tpa6130a2@60 {
compatible = "ti,tpa6130a2";
reg = <0x60>;
Vdd-supply = <&vmmc2>;
power-gpio = <&gpio4 2 GPIO_ACTIVE_HIGH>;
};
This diff is collapsed.
ASoC Codec Driver ASoC Codec Class Driver
================= =======================
The codec driver is generic and hardware independent code that configures the The codec class driver is generic and hardware independent code that configures
codec to provide audio capture and playback. It should contain no code that is the codec, FM, MODEM, BT or external DSP to provide audio capture and playback.
specific to the target platform or machine. All platform and machine specific It should contain no code that is specific to the target platform or machine.
code should be added to the platform and machine drivers respectively. All platform and machine specific code should be added to the platform and
machine drivers respectively.
Each codec driver *must* provide the following features:- Each codec class driver *must* provide the following features:-
1) Codec DAI and PCM configuration 1) Codec DAI and PCM configuration
2) Codec control IO - using I2C, 3 Wire(SPI) or both APIs 2) Codec control IO - using RegMap API
3) Mixers and audio controls 3) Mixers and audio controls
4) Codec audio operations 4) Codec audio operations
5) DAPM description.
6) DAPM event handler.
Optionally, codec drivers can also provide:- Optionally, codec drivers can also provide:-
5) DAPM description.
6) DAPM event handler.
7) DAC Digital mute control. 7) DAC Digital mute control.
Its probably best to use this guide in conjunction with the existing codec Its probably best to use this guide in conjunction with the existing codec
...@@ -64,26 +65,9 @@ struct snd_soc_dai_driver wm8731_dai = { ...@@ -64,26 +65,9 @@ struct snd_soc_dai_driver wm8731_dai = {
2 - Codec control IO 2 - Codec control IO
-------------------- --------------------
The codec can usually be controlled via an I2C or SPI style interface The codec can usually be controlled via an I2C or SPI style interface
(AC97 combines control with data in the DAI). The codec drivers provide (AC97 combines control with data in the DAI). The codec driver should use the
functions to read and write the codec registers along with supplying a Regmap API for all codec IO. Please see include/linux/regmap.h and existing
register cache:- codec drivers for example regmap usage.
/* IO control data and register cache */
void *control_data; /* codec control (i2c/3wire) data */
void *reg_cache;
Codec read/write should do any data formatting and call the hardware
read write below to perform the IO. These functions are called by the
core and ALSA when performing DAPM or changing the mixer:-
unsigned int (*read)(struct snd_soc_codec *, unsigned int);
int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
Codec hardware IO functions - usually points to either the I2C, SPI or AC97
read/write:-
hw_write_t hw_write;
hw_read_t hw_read;
3 - Mixers and audio controls 3 - Mixers and audio controls
...@@ -127,7 +111,7 @@ Defines a stereo enumerated control ...@@ -127,7 +111,7 @@ Defines a stereo enumerated control
4 - Codec Audio Operations 4 - Codec Audio Operations
-------------------------- --------------------------
The codec driver also supports the following ALSA operations:- The codec driver also supports the following ALSA PCM operations:-
/* SoC audio ops */ /* SoC audio ops */
struct snd_soc_ops { struct snd_soc_ops {
......
...@@ -21,7 +21,7 @@ level power systems. ...@@ -21,7 +21,7 @@ level power systems.
There are 4 power domains within DAPM There are 4 power domains within DAPM
1. Codec domain - VREF, VMID (core codec and audio power) 1. Codec bias domain - VREF, VMID (core codec and audio power)
Usually controlled at codec probe/remove and suspend/resume, although Usually controlled at codec probe/remove and suspend/resume, although
can be set at stream time if power is not needed for sidetone, etc. can be set at stream time if power is not needed for sidetone, etc.
...@@ -63,14 +63,22 @@ Audio DAPM widgets fall into a number of types:- ...@@ -63,14 +63,22 @@ Audio DAPM widgets fall into a number of types:-
o Line - Line Input/Output (and optional Jack) o Line - Line Input/Output (and optional Jack)
o Speaker - Speaker o Speaker - Speaker
o Supply - Power or clock supply widget used by other widgets. o Supply - Power or clock supply widget used by other widgets.
o Regulator - External regulator that supplies power to audio components.
o Clock - External clock that supplies clock to audio componnents.
o AIF IN - Audio Interface Input (with TDM slot mask).
o AIF OUT - Audio Interface Output (with TDM slot mask).
o Siggen - Signal Generator.
o DAI IN - Digital Audio Interface Input.
o DAI OUT - Digital Audio Interface Output.
o DAI Link - DAI Link between two DAI structures */
o Pre - Special PRE widget (exec before all others) o Pre - Special PRE widget (exec before all others)
o Post - Special POST widget (exec after all others) o Post - Special POST widget (exec after all others)
(Widgets are defined in include/sound/soc-dapm.h) (Widgets are defined in include/sound/soc-dapm.h)
Widgets are usually added in the codec driver and the machine driver. There are Widgets can be added to the sound card by any of the component driver types.
convenience macros defined in soc-dapm.h that can be used to quickly build a There are convenience macros defined in soc-dapm.h that can be used to quickly
list of widgets of the codecs and machines DAPM widgets. build a list of widgets of the codecs and machines DAPM widgets.
Most widgets have a name, register, shift and invert. Some widgets have extra Most widgets have a name, register, shift and invert. Some widgets have extra
parameters for stream name and kcontrols. parameters for stream name and kcontrols.
...@@ -80,11 +88,13 @@ parameters for stream name and kcontrols. ...@@ -80,11 +88,13 @@ parameters for stream name and kcontrols.
------------------------- -------------------------
Stream Widgets relate to the stream power domain and only consist of ADCs Stream Widgets relate to the stream power domain and only consist of ADCs
(analog to digital converters) and DACs (digital to analog converters). (analog to digital converters), DACs (digital to analog converters),
AIF IN and AIF OUT.
Stream widgets have the following format:- Stream widgets have the following format:-
SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert), SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert),
SND_SOC_DAPM_AIF_IN(name, stream, slot, reg, shift, invert)
NOTE: the stream name must match the corresponding stream name in your codec NOTE: the stream name must match the corresponding stream name in your codec
snd_soc_codec_dai. snd_soc_codec_dai.
...@@ -94,6 +104,11 @@ e.g. stream widgets for HiFi playback and capture ...@@ -94,6 +104,11 @@ e.g. stream widgets for HiFi playback and capture
SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1), SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1),
SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1), SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1),
e.g. stream widgets for AIF
SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
2.2 Path Domain Widgets 2.2 Path Domain Widgets
----------------------- -----------------------
...@@ -121,12 +136,14 @@ If you dont want the mixer elements prefixed with the name of the mixer widget, ...@@ -121,12 +136,14 @@ If you dont want the mixer elements prefixed with the name of the mixer widget,
you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same
as for SND_SOC_DAPM_MIXER. as for SND_SOC_DAPM_MIXER.
2.3 Platform/Machine domain Widgets
----------------------------------- 2.3 Machine domain Widgets
--------------------------
Machine widgets are different from codec widgets in that they don't have a Machine widgets are different from codec widgets in that they don't have a
codec register bit associated with them. A machine widget is assigned to each codec register bit associated with them. A machine widget is assigned to each
machine audio component (non codec) that can be independently powered. e.g. machine audio component (non codec or DSP) that can be independently
powered. e.g.
o Speaker Amp o Speaker Amp
o Microphone Bias o Microphone Bias
...@@ -146,12 +163,12 @@ static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event) ...@@ -146,12 +163,12 @@ static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event)
SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias),
2.4 Codec Domain 2.4 Codec (BIAS) Domain
---------------- -----------------------
The codec power domain has no widgets and is handled by the codecs DAPM event The codec bias power domain has no widgets and is handled by the codecs DAPM
handler. This handler is called when the codec powerstate is changed wrt to any event handler. This handler is called when the codec powerstate is changed wrt
stream event or by kernel PM events. to any stream event or by kernel PM events.
2.5 Virtual Widgets 2.5 Virtual Widgets
...@@ -169,15 +186,16 @@ After all the widgets have been defined, they can then be added to the DAPM ...@@ -169,15 +186,16 @@ After all the widgets have been defined, they can then be added to the DAPM
subsystem individually with a call to snd_soc_dapm_new_control(). subsystem individually with a call to snd_soc_dapm_new_control().
3. Codec Widget Interconnections 3. Codec/DSP Widget Interconnections
================================ ====================================
Widgets are connected to each other within the codec and machine by audio paths Widgets are connected to each other within the codec, platform and machine by
(called interconnections). Each interconnection must be defined in order to audio paths (called interconnections). Each interconnection must be defined in
create a map of all audio paths between widgets. order to create a map of all audio paths between widgets.
This is easiest with a diagram of the codec (and schematic of the machine audio This is easiest with a diagram of the codec or DSP (and schematic of the machine
system), as it requires joining widgets together via their audio signal paths. audio system), as it requires joining widgets together via their audio signal
paths.
e.g., from the WM8731 output mixer (wm8731.c) e.g., from the WM8731 output mixer (wm8731.c)
...@@ -247,16 +265,9 @@ machine and includes the codec. e.g. ...@@ -247,16 +265,9 @@ machine and includes the codec. e.g.
o Mic Jack o Mic Jack
o Codec Pins o Codec Pins
When a codec pin is NC it can be marked as not used with a call to Endpoints are added to the DAPM graph so that their usage can be determined in
order to save power. e.g. NC codecs pins will be switched OFF, unconnected
snd_soc_dapm_set_endpoint(codec, "Widget Name", 0); jacks can also be switched OFF.
The last argument is 0 for inactive and 1 for active. This way the pin and its
input widget will never be powered up and consume power.
This also applies to machine widgets. e.g. if a headphone is connected to a
jack then the jack can be marked active. If the headphone is removed, then
the headphone jack can be marked inactive.
5 DAPM Widget Events 5 DAPM Widget Events
......
ASoC Machine Driver ASoC Machine Driver
=================== ===================
The ASoC machine (or board) driver is the code that glues together the platform The ASoC machine (or board) driver is the code that glues together all the
and codec drivers. component drivers (e.g. codecs, platforms and DAIs). It also describes the
relationships between each componnent which include audio paths, GPIOs,
interrupts, clocking, jacks and voltage regulators.
The machine driver can contain codec and platform specific code. It registers The machine driver can contain codec and platform specific code. It registers
the audio subsystem with the kernel as a platform device and is represented by the audio subsystem with the kernel as a platform device and is represented by
......
ASoC Platform Driver ASoC Platform Driver
==================== ====================
An ASoC platform driver can be divided into audio DMA and SoC DAI configuration An ASoC platform driver class can be divided into audio DMA drivers, SoC DAI
and control. The platform drivers only target the SoC CPU and must have no board drivers and DSP drivers. The platform drivers only target the SoC CPU and must
specific code. have no board specific code.
Audio DMA Audio DMA
========= =========
...@@ -64,3 +64,16 @@ Each SoC DAI driver must provide the following features:- ...@@ -64,3 +64,16 @@ Each SoC DAI driver must provide the following features:-
5) Suspend and resume (optional) 5) Suspend and resume (optional)
Please see codec.txt for a description of items 1 - 4. Please see codec.txt for a description of items 1 - 4.
SoC DSP Drivers
===============
Each SoC DSP driver usually supplies the following features :-
1) DAPM graph
2) Mixer controls
3) DMA IO to/from DSP buffers (if applicable)
4) Definition of DSP front end (FE) PCM devices.
Please see DPCM.txt for a description of item 4.
...@@ -44,7 +44,6 @@ struct regmap_format { ...@@ -44,7 +44,6 @@ struct regmap_format {
struct regmap_async { struct regmap_async {
struct list_head list; struct list_head list;
struct work_struct cleanup;
struct regmap *map; struct regmap *map;
void *work_buf; void *work_buf;
}; };
...@@ -64,9 +63,11 @@ struct regmap { ...@@ -64,9 +63,11 @@ struct regmap {
void *bus_context; void *bus_context;
const char *name; const char *name;
bool async;
spinlock_t async_lock; spinlock_t async_lock;
wait_queue_head_t async_waitq; wait_queue_head_t async_waitq;
struct list_head async_list; struct list_head async_list;
struct list_head async_free;
int async_ret; int async_ret;
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
...@@ -179,6 +180,9 @@ struct regmap_field { ...@@ -179,6 +180,9 @@ struct regmap_field {
/* lsb */ /* lsb */
unsigned int shift; unsigned int shift;
unsigned int reg; unsigned int reg;
unsigned int id_size;
unsigned int id_offset;
}; };
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
...@@ -218,7 +222,7 @@ bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, ...@@ -218,7 +222,7 @@ bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
int regcache_lookup_reg(struct regmap *map, unsigned int reg); int regcache_lookup_reg(struct regmap *map, unsigned int reg);
int _regmap_raw_write(struct regmap *map, unsigned int reg, int _regmap_raw_write(struct regmap *map, unsigned int reg,
const void *val, size_t val_len, bool async); const void *val, size_t val_len);
void regmap_async_complete_cb(struct regmap_async *async, int ret); void regmap_async_complete_cb(struct regmap_async *async, int ret);
......
...@@ -631,8 +631,7 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data, ...@@ -631,8 +631,7 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data,
map->cache_bypass = 1; map->cache_bypass = 1;
ret = _regmap_raw_write(map, base, *data, count * val_bytes, ret = _regmap_raw_write(map, base, *data, count * val_bytes);
false);
map->cache_bypass = 0; map->cache_bypass = 0;
......
This diff is collapsed.
...@@ -158,8 +158,6 @@ int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val) ...@@ -158,8 +158,6 @@ int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val)
{ {
int ret; int ret;
BUG_ON(!mutex_is_locked(&mc13xxx->lock));
if (offset > MC13XXX_NUMREGS) if (offset > MC13XXX_NUMREGS)
return -EINVAL; return -EINVAL;
...@@ -172,8 +170,6 @@ EXPORT_SYMBOL(mc13xxx_reg_read); ...@@ -172,8 +170,6 @@ EXPORT_SYMBOL(mc13xxx_reg_read);
int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val) int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val)
{ {
BUG_ON(!mutex_is_locked(&mc13xxx->lock));
dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val); dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val);
if (offset > MC13XXX_NUMREGS || val > 0xffffff) if (offset > MC13XXX_NUMREGS || val > 0xffffff)
...@@ -186,7 +182,6 @@ EXPORT_SYMBOL(mc13xxx_reg_write); ...@@ -186,7 +182,6 @@ EXPORT_SYMBOL(mc13xxx_reg_write);
int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset, int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset,
u32 mask, u32 val) u32 mask, u32 val)
{ {
BUG_ON(!mutex_is_locked(&mc13xxx->lock));
BUG_ON(val & ~mask); BUG_ON(val & ~mask);
dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x (mask: 0x%06x)\n", dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x (mask: 0x%06x)\n",
offset, val, mask); offset, val, mask);
......
...@@ -94,10 +94,15 @@ static int mc13xxx_spi_write(void *context, const void *data, size_t count) ...@@ -94,10 +94,15 @@ static int mc13xxx_spi_write(void *context, const void *data, size_t count)
{ {
struct device *dev = context; struct device *dev = context;
struct spi_device *spi = to_spi_device(dev); struct spi_device *spi = to_spi_device(dev);
const char *reg = data;
if (count != 4) if (count != 4)
return -ENOTSUPP; return -ENOTSUPP;
/* include errata fix for spi audio problems */
if (*reg == MC13783_AUDIO_CODEC || *reg == MC13783_AUDIO_DAC)
spi_write(spi, data, count);
return spi_write(spi, data, count); return spi_write(spi, data, count);
} }
......
...@@ -41,6 +41,13 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, ...@@ -41,6 +41,13 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
unsigned int mode, unsigned int channel, unsigned int mode, unsigned int channel,
u8 ato, bool atox, unsigned int *sample); u8 ato, bool atox, unsigned int *sample);
#define MC13783_AUDIO_RX0 36
#define MC13783_AUDIO_RX1 37
#define MC13783_AUDIO_TX 38
#define MC13783_SSI_NETWORK 39
#define MC13783_AUDIO_CODEC 40
#define MC13783_AUDIO_DAC 41
#define MC13XXX_IRQ_ADCDONE 0 #define MC13XXX_IRQ_ADCDONE 0
#define MC13XXX_IRQ_ADCBISDONE 1 #define MC13XXX_IRQ_ADCBISDONE 1
#define MC13XXX_IRQ_TS 2 #define MC13XXX_IRQ_TS 2
......
...@@ -84,6 +84,8 @@ struct snd_platform_data { ...@@ -84,6 +84,8 @@ struct snd_platform_data {
u8 version; u8 version;
u8 txnumevt; u8 txnumevt;
u8 rxnumevt; u8 rxnumevt;
int tx_dma_channel;
int rx_dma_channel;
}; };
enum { enum {
......
...@@ -374,6 +374,7 @@ int regmap_reinit_cache(struct regmap *map, ...@@ -374,6 +374,7 @@ int regmap_reinit_cache(struct regmap *map,
const struct regmap_config *config); const struct regmap_config *config);
struct regmap *dev_get_regmap(struct device *dev, const char *name); struct regmap *dev_get_regmap(struct device *dev, const char *name);
int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);
int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val);
int regmap_raw_write(struct regmap *map, unsigned int reg, int regmap_raw_write(struct regmap *map, unsigned int reg,
const void *val, size_t val_len); const void *val, size_t val_len);
int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
...@@ -387,9 +388,14 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, ...@@ -387,9 +388,14 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
size_t val_count); size_t val_count);
int regmap_update_bits(struct regmap *map, unsigned int reg, int regmap_update_bits(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val); unsigned int mask, unsigned int val);
int regmap_update_bits_async(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val);
int regmap_update_bits_check(struct regmap *map, unsigned int reg, int regmap_update_bits_check(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val, unsigned int mask, unsigned int val,
bool *change); bool *change);
int regmap_update_bits_check_async(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change);
int regmap_get_val_bytes(struct regmap *map); int regmap_get_val_bytes(struct regmap *map);
int regmap_async_complete(struct regmap *map); int regmap_async_complete(struct regmap *map);
bool regmap_can_raw_write(struct regmap *map); bool regmap_can_raw_write(struct regmap *map);
...@@ -425,11 +431,15 @@ bool regmap_reg_in_ranges(unsigned int reg, ...@@ -425,11 +431,15 @@ bool regmap_reg_in_ranges(unsigned int reg,
* @reg: Offset of the register within the regmap bank * @reg: Offset of the register within the regmap bank
* @lsb: lsb of the register field. * @lsb: lsb of the register field.
* @reg: msb of the register field. * @reg: msb of the register field.
* @id_size: port size if it has some ports
* @id_offset: address offset for each ports
*/ */
struct reg_field { struct reg_field {
unsigned int reg; unsigned int reg;
unsigned int lsb; unsigned int lsb;
unsigned int msb; unsigned int msb;
unsigned int id_size;
unsigned int id_offset;
}; };
#define REG_FIELD(_reg, _lsb, _msb) { \ #define REG_FIELD(_reg, _lsb, _msb) { \
...@@ -448,6 +458,15 @@ void devm_regmap_field_free(struct device *dev, struct regmap_field *field); ...@@ -448,6 +458,15 @@ void devm_regmap_field_free(struct device *dev, struct regmap_field *field);
int regmap_field_read(struct regmap_field *field, unsigned int *val); int regmap_field_read(struct regmap_field *field, unsigned int *val);
int regmap_field_write(struct regmap_field *field, unsigned int val); int regmap_field_write(struct regmap_field *field, unsigned int val);
int regmap_field_update_bits(struct regmap_field *field,
unsigned int mask, unsigned int val);
int regmap_fields_write(struct regmap_field *field, unsigned int id,
unsigned int val);
int regmap_fields_read(struct regmap_field *field, unsigned int id,
unsigned int *val);
int regmap_fields_update_bits(struct regmap_field *field, unsigned int id,
unsigned int mask, unsigned int val);
/** /**
* Description of an IRQ for the generic regmap irq_chip. * Description of an IRQ for the generic regmap irq_chip.
...@@ -527,6 +546,13 @@ static inline int regmap_write(struct regmap *map, unsigned int reg, ...@@ -527,6 +546,13 @@ static inline int regmap_write(struct regmap *map, unsigned int reg,
return -EINVAL; return -EINVAL;
} }
static inline int regmap_write_async(struct regmap *map, unsigned int reg,
unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_raw_write(struct regmap *map, unsigned int reg, static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
const void *val, size_t val_len) const void *val, size_t val_len)
{ {
...@@ -576,6 +602,14 @@ static inline int regmap_update_bits(struct regmap *map, unsigned int reg, ...@@ -576,6 +602,14 @@ static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
return -EINVAL; return -EINVAL;
} }
static inline int regmap_update_bits_async(struct regmap *map,
unsigned int reg,
unsigned int mask, unsigned int val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_update_bits_check(struct regmap *map, static inline int regmap_update_bits_check(struct regmap *map,
unsigned int reg, unsigned int reg,
unsigned int mask, unsigned int val, unsigned int mask, unsigned int val,
...@@ -585,6 +619,16 @@ static inline int regmap_update_bits_check(struct regmap *map, ...@@ -585,6 +619,16 @@ static inline int regmap_update_bits_check(struct regmap *map,
return -EINVAL; return -EINVAL;
} }
static inline int regmap_update_bits_check_async(struct regmap *map,
unsigned int reg,
unsigned int mask,
unsigned int val,
bool *change)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_get_val_bytes(struct regmap *map) static inline int regmap_get_val_bytes(struct regmap *map)
{ {
WARN_ONCE(1, "regmap API is disabled"); WARN_ONCE(1, "regmap API is disabled");
......
/*
* linux/sound/cs42l73.h -- Platform data for CS42L73
*
* Copyright (c) 2012 Cirrus Logic Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __CS42L73_H
#define __CS42L73_H
struct cs42l73_platform_data {
/* RST GPIO */
unsigned int reset_gpio;
unsigned int chgfreq;
int jack_detection;
unsigned int mclk_freq;
};
#endif /* __CS42L73_H */
...@@ -61,6 +61,8 @@ struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream) ...@@ -61,6 +61,8 @@ struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream)
* @slave_id: Slave requester id for the DMA channel. * @slave_id: Slave requester id for the DMA channel.
* @filter_data: Custom DMA channel filter data, this will usually be used when * @filter_data: Custom DMA channel filter data, this will usually be used when
* requesting the DMA channel. * requesting the DMA channel.
* @chan_name: Custom channel name to use when requesting DMA channel.
* @fifo_size: FIFO size of the DAI controller in bytes
*/ */
struct snd_dmaengine_dai_dma_data { struct snd_dmaengine_dai_dma_data {
dma_addr_t addr; dma_addr_t addr;
...@@ -68,6 +70,8 @@ struct snd_dmaengine_dai_dma_data { ...@@ -68,6 +70,8 @@ struct snd_dmaengine_dai_dma_data {
u32 maxburst; u32 maxburst;
unsigned int slave_id; unsigned int slave_id;
void *filter_data; void *filter_data;
const char *chan_name;
unsigned int fifo_size;
}; };
void snd_dmaengine_pcm_set_config_from_dai_data( void snd_dmaengine_pcm_set_config_from_dai_data(
...@@ -96,6 +100,10 @@ void snd_dmaengine_pcm_set_config_from_dai_data( ...@@ -96,6 +100,10 @@ void snd_dmaengine_pcm_set_config_from_dai_data(
* playback. * playback.
*/ */
#define SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX BIT(3) #define SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX BIT(3)
/*
* The PCM streams have custom channel names specified.
*/
#define SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME BIT(4)
/** /**
* struct snd_dmaengine_pcm_config - Configuration data for dmaengine based PCM * struct snd_dmaengine_pcm_config - Configuration data for dmaengine based PCM
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#define RSND_SSI_CLK_PIN_SHARE (1 << 31) #define RSND_SSI_CLK_PIN_SHARE (1 << 31)
#define RSND_SSI_CLK_FROM_ADG (1 << 30) /* clock parent is master */ #define RSND_SSI_CLK_FROM_ADG (1 << 30) /* clock parent is master */
#define RSND_SSI_SYNC (1 << 29) /* SSI34_sync etc */ #define RSND_SSI_SYNC (1 << 29) /* SSI34_sync etc */
#define RSND_SSI_DEPENDENT (1 << 28) /* SSI needs SRU/SCU */
#define RSND_SSI_PLAY (1 << 24) #define RSND_SSI_PLAY (1 << 24)
......
...@@ -105,6 +105,8 @@ int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, ...@@ -105,6 +105,8 @@ int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
int pll_id, int source, unsigned int freq_in, unsigned int freq_out); int pll_id, int source, unsigned int freq_in, unsigned int freq_out);
int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio);
/* Digital Audio interface formatting */ /* Digital Audio interface formatting */
int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt); int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
...@@ -131,6 +133,7 @@ struct snd_soc_dai_ops { ...@@ -131,6 +133,7 @@ struct snd_soc_dai_ops {
int (*set_pll)(struct snd_soc_dai *dai, int pll_id, int source, int (*set_pll)(struct snd_soc_dai *dai, int pll_id, int source,
unsigned int freq_in, unsigned int freq_out); unsigned int freq_in, unsigned int freq_out);
int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div); int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
int (*set_bclk_ratio)(struct snd_soc_dai *dai, unsigned int ratio);
/* /*
* DAI format configuration * DAI format configuration
...@@ -166,6 +169,13 @@ struct snd_soc_dai_ops { ...@@ -166,6 +169,13 @@ struct snd_soc_dai_ops {
struct snd_soc_dai *); struct snd_soc_dai *);
int (*prepare)(struct snd_pcm_substream *, int (*prepare)(struct snd_pcm_substream *,
struct snd_soc_dai *); struct snd_soc_dai *);
/*
* NOTE: Commands passed to the trigger function are not necessarily
* compatible with the current state of the dai. For example this
* sequence of commands is possible: START STOP STOP.
* So do not unconditionally use refcounting functions in the trigger
* function, e.g. clk_enable/disable.
*/
int (*trigger)(struct snd_pcm_substream *, int, int (*trigger)(struct snd_pcm_substream *, int,
struct snd_soc_dai *); struct snd_soc_dai *);
int (*bespoke_trigger)(struct snd_pcm_substream *, int, int (*bespoke_trigger)(struct snd_pcm_substream *, int,
...@@ -276,6 +286,13 @@ static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai, ...@@ -276,6 +286,13 @@ static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai,
dai->capture_dma_data = data; dai->capture_dma_data = data;
} }
static inline void snd_soc_dai_init_dma_data(struct snd_soc_dai *dai,
void *playback, void *capture)
{
dai->playback_dma_data = playback;
dai->capture_dma_data = capture;
}
static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai, static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai,
void *data) void *data)
{ {
......
...@@ -286,6 +286,8 @@ struct device; ...@@ -286,6 +286,8 @@ struct device;
.info = snd_soc_info_volsw, \ .info = snd_soc_info_volsw, \
.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) } .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) }
#define SOC_DAPM_SINGLE_VIRT(xname, max) \
SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0)
#define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
.info = snd_soc_info_volsw, \ .info = snd_soc_info_volsw, \
...@@ -300,6 +302,8 @@ struct device; ...@@ -300,6 +302,8 @@ struct device;
.tlv.p = (tlv_array), \ .tlv.p = (tlv_array), \
.get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
.private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) } .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
#define SOC_DAPM_SINGLE_TLV_VIRT(xname, max, tlv_array) \
SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0, tlv_array)
#define SOC_DAPM_ENUM(xname, xenum) \ #define SOC_DAPM_ENUM(xname, xenum) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
.info = snd_soc_info_enum_double, \ .info = snd_soc_info_enum_double, \
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#ifndef __LINUX_SND_SOC_H #ifndef __LINUX_SND_SOC_H
#define __LINUX_SND_SOC_H #define __LINUX_SND_SOC_H
#include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/notifier.h> #include <linux/notifier.h>
...@@ -330,7 +331,6 @@ struct soc_enum; ...@@ -330,7 +331,6 @@ struct soc_enum;
struct snd_soc_jack; struct snd_soc_jack;
struct snd_soc_jack_zone; struct snd_soc_jack_zone;
struct snd_soc_jack_pin; struct snd_soc_jack_pin;
struct snd_soc_cache_ops;
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include <sound/soc-dpcm.h> #include <sound/soc-dpcm.h>
...@@ -348,10 +348,6 @@ enum snd_soc_control_type { ...@@ -348,10 +348,6 @@ enum snd_soc_control_type {
SND_SOC_REGMAP, SND_SOC_REGMAP,
}; };
enum snd_soc_compress_type {
SND_SOC_FLAT_COMPRESSION = 1,
};
enum snd_soc_pcm_subclass { enum snd_soc_pcm_subclass {
SND_SOC_PCM_CLASS_PCM = 0, SND_SOC_PCM_CLASS_PCM = 0,
SND_SOC_PCM_CLASS_BE = 1, SND_SOC_PCM_CLASS_BE = 1,
...@@ -369,6 +365,7 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, ...@@ -369,6 +365,7 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
int snd_soc_register_card(struct snd_soc_card *card); int snd_soc_register_card(struct snd_soc_card *card);
int snd_soc_unregister_card(struct snd_soc_card *card); int snd_soc_unregister_card(struct snd_soc_card *card);
int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
int snd_soc_suspend(struct device *dev); int snd_soc_suspend(struct device *dev);
int snd_soc_resume(struct device *dev); int snd_soc_resume(struct device *dev);
int snd_soc_poweroff(struct device *dev); int snd_soc_poweroff(struct device *dev);
...@@ -386,6 +383,9 @@ void snd_soc_unregister_codec(struct device *dev); ...@@ -386,6 +383,9 @@ void snd_soc_unregister_codec(struct device *dev);
int snd_soc_register_component(struct device *dev, int snd_soc_register_component(struct device *dev,
const struct snd_soc_component_driver *cmpnt_drv, const struct snd_soc_component_driver *cmpnt_drv,
struct snd_soc_dai_driver *dai_drv, int num_dai); struct snd_soc_dai_driver *dai_drv, int num_dai);
int devm_snd_soc_register_component(struct device *dev,
const struct snd_soc_component_driver *cmpnt_drv,
struct snd_soc_dai_driver *dai_drv, int num_dai);
void snd_soc_unregister_component(struct device *dev); void snd_soc_unregister_component(struct device *dev);
int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
unsigned int reg); unsigned int reg);
...@@ -403,12 +403,6 @@ int snd_soc_cache_write(struct snd_soc_codec *codec, ...@@ -403,12 +403,6 @@ int snd_soc_cache_write(struct snd_soc_codec *codec,
unsigned int reg, unsigned int value); unsigned int reg, unsigned int value);
int snd_soc_cache_read(struct snd_soc_codec *codec, int snd_soc_cache_read(struct snd_soc_codec *codec,
unsigned int reg, unsigned int *value); unsigned int reg, unsigned int *value);
int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
unsigned int reg);
int snd_soc_default_readable_register(struct snd_soc_codec *codec,
unsigned int reg);
int snd_soc_default_writable_register(struct snd_soc_codec *codec,
unsigned int reg);
int snd_soc_platform_read(struct snd_soc_platform *platform, int snd_soc_platform_read(struct snd_soc_platform *platform,
unsigned int reg); unsigned int reg);
int snd_soc_platform_write(struct snd_soc_platform *platform, int snd_soc_platform_write(struct snd_soc_platform *platform,
...@@ -541,22 +535,6 @@ int snd_soc_get_strobe(struct snd_kcontrol *kcontrol, ...@@ -541,22 +535,6 @@ int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
int snd_soc_put_strobe(struct snd_kcontrol *kcontrol, int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol); struct snd_ctl_elem_value *ucontrol);
/**
* struct snd_soc_reg_access - Describes whether a given register is
* readable, writable or volatile.
*
* @reg: the register number
* @read: whether this register is readable
* @write: whether this register is writable
* @vol: whether this register is volatile
*/
struct snd_soc_reg_access {
u16 reg;
u16 read;
u16 write;
u16 vol;
};
/** /**
* struct snd_soc_jack_pin - Describes a pin to update based on jack detection * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
* *
...@@ -657,17 +635,26 @@ struct snd_soc_compr_ops { ...@@ -657,17 +635,26 @@ struct snd_soc_compr_ops {
int (*trigger)(struct snd_compr_stream *); int (*trigger)(struct snd_compr_stream *);
}; };
/* SoC cache ops */ /* component interface */
struct snd_soc_cache_ops { struct snd_soc_component_driver {
const char *name; const char *name;
enum snd_soc_compress_type id;
int (*init)(struct snd_soc_codec *codec); /* DT */
int (*exit)(struct snd_soc_codec *codec); int (*of_xlate_dai_name)(struct snd_soc_component *component,
int (*read)(struct snd_soc_codec *codec, unsigned int reg, struct of_phandle_args *args,
unsigned int *value); const char **dai_name);
int (*write)(struct snd_soc_codec *codec, unsigned int reg, };
unsigned int value);
int (*sync)(struct snd_soc_codec *codec); struct snd_soc_component {
const char *name;
int id;
struct device *dev;
struct list_head list;
struct snd_soc_dai_driver *dai_drv;
int num_dai;
const struct snd_soc_component_driver *driver;
}; };
/* SoC Audio Codec device */ /* SoC Audio Codec device */
...@@ -683,8 +670,6 @@ struct snd_soc_codec { ...@@ -683,8 +670,6 @@ struct snd_soc_codec {
struct list_head list; struct list_head list;
struct list_head card_list; struct list_head card_list;
int num_dai; int num_dai;
enum snd_soc_compress_type compress_type;
size_t reg_size; /* reg_cache_size * reg_word_size */
int (*volatile_register)(struct snd_soc_codec *, unsigned int); int (*volatile_register)(struct snd_soc_codec *, unsigned int);
int (*readable_register)(struct snd_soc_codec *, unsigned int); int (*readable_register)(struct snd_soc_codec *, unsigned int);
int (*writable_register)(struct snd_soc_codec *, unsigned int); int (*writable_register)(struct snd_soc_codec *, unsigned int);
...@@ -708,13 +693,13 @@ struct snd_soc_codec { ...@@ -708,13 +693,13 @@ struct snd_soc_codec {
unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
unsigned int (*read)(struct snd_soc_codec *, unsigned int); unsigned int (*read)(struct snd_soc_codec *, unsigned int);
int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
int (*bulk_write_raw)(struct snd_soc_codec *, unsigned int, const void *, size_t);
void *reg_cache; void *reg_cache;
const void *reg_def_copy;
const struct snd_soc_cache_ops *cache_ops;
struct mutex cache_rw_mutex; struct mutex cache_rw_mutex;
int val_bytes; int val_bytes;
/* component */
struct snd_soc_component component;
/* dapm */ /* dapm */
struct snd_soc_dapm_context dapm; struct snd_soc_dapm_context dapm;
unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
...@@ -733,6 +718,7 @@ struct snd_soc_codec_driver { ...@@ -733,6 +718,7 @@ struct snd_soc_codec_driver {
int (*remove)(struct snd_soc_codec *); int (*remove)(struct snd_soc_codec *);
int (*suspend)(struct snd_soc_codec *); int (*suspend)(struct snd_soc_codec *);
int (*resume)(struct snd_soc_codec *); int (*resume)(struct snd_soc_codec *);
struct snd_soc_component_driver component_driver;
/* Default control and setup, added after probe() is run */ /* Default control and setup, added after probe() is run */
const struct snd_kcontrol_new *controls; const struct snd_kcontrol_new *controls;
...@@ -760,9 +746,6 @@ struct snd_soc_codec_driver { ...@@ -760,9 +746,6 @@ struct snd_soc_codec_driver {
short reg_cache_step; short reg_cache_step;
short reg_word_size; short reg_word_size;
const void *reg_cache_default; const void *reg_cache_default;
short reg_access_size;
const struct snd_soc_reg_access *reg_access_default;
enum snd_soc_compress_type compress_type;
/* codec bias level */ /* codec bias level */
int (*set_bias_level)(struct snd_soc_codec *, int (*set_bias_level)(struct snd_soc_codec *,
...@@ -849,20 +832,6 @@ struct snd_soc_platform { ...@@ -849,20 +832,6 @@ struct snd_soc_platform {
#endif #endif
}; };
struct snd_soc_component_driver {
const char *name;
};
struct snd_soc_component {
const char *name;
int id;
int num_dai;
struct device *dev;
struct list_head list;
const struct snd_soc_component_driver *driver;
};
struct snd_soc_dai_link { struct snd_soc_dai_link {
/* config - must be set by machine driver */ /* config - must be set by machine driver */
const char *name; /* Codec name */ const char *name; /* Codec name */
...@@ -944,12 +913,6 @@ struct snd_soc_codec_conf { ...@@ -944,12 +913,6 @@ struct snd_soc_codec_conf {
* associated per device * associated per device
*/ */
const char *name_prefix; const char *name_prefix;
/*
* set this to the desired compression type if you want to
* override the one supplied in codec->driver->compress_type
*/
enum snd_soc_compress_type compress_type;
}; };
struct snd_soc_aux_dev { struct snd_soc_aux_dev {
...@@ -1088,7 +1051,8 @@ struct snd_soc_pcm_runtime { ...@@ -1088,7 +1051,8 @@ struct snd_soc_pcm_runtime {
/* mixer control */ /* mixer control */
struct soc_mixer_control { struct soc_mixer_control {
int min, max, platform_max; int min, max, platform_max;
unsigned int reg, rreg, shift, rshift; int reg, rreg;
unsigned int shift, rshift;
unsigned int invert:1; unsigned int invert:1;
unsigned int autodisable:1; unsigned int autodisable:1;
}; };
...@@ -1121,8 +1085,6 @@ struct soc_enum { ...@@ -1121,8 +1085,6 @@ struct soc_enum {
unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
unsigned int snd_soc_write(struct snd_soc_codec *codec, unsigned int snd_soc_write(struct snd_soc_codec *codec,
unsigned int reg, unsigned int val); unsigned int reg, unsigned int val);
unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec,
unsigned int reg, const void *data, size_t len);
/* device driver data */ /* device driver data */
...@@ -1201,6 +1163,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, ...@@ -1201,6 +1163,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
const char *propname); const char *propname);
unsigned int snd_soc_of_parse_daifmt(struct device_node *np, unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
const char *prefix); const char *prefix);
int snd_soc_of_get_dai_name(struct device_node *of_node,
const char **dai_name);
#include <sound/soc-dai.h> #include <sound/soc-dai.h>
......
...@@ -14,6 +14,7 @@ struct snd_soc_codec; ...@@ -14,6 +14,7 @@ struct snd_soc_codec;
struct snd_soc_platform; struct snd_soc_platform;
struct snd_soc_card; struct snd_soc_card;
struct snd_soc_dapm_widget; struct snd_soc_dapm_widget;
struct snd_soc_dapm_path;
/* /*
* Log register events * Log register events
......
...@@ -117,8 +117,7 @@ static inline void pxa_ac97_warm_pxa25x(void) ...@@ -117,8 +117,7 @@ static inline void pxa_ac97_warm_pxa25x(void)
{ {
gsr_bits = 0; gsr_bits = 0;
GCR |= GCR_WARM_RST | GCR_PRIRDY_IEN | GCR_SECRDY_IEN; GCR |= GCR_WARM_RST;
wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
} }
static inline void pxa_ac97_cold_pxa25x(void) static inline void pxa_ac97_cold_pxa25x(void)
...@@ -129,8 +128,6 @@ static inline void pxa_ac97_cold_pxa25x(void) ...@@ -129,8 +128,6 @@ static inline void pxa_ac97_cold_pxa25x(void)
gsr_bits = 0; gsr_bits = 0;
GCR = GCR_COLD_RST; GCR = GCR_COLD_RST;
GCR |= GCR_CDONE_IE|GCR_SDONE_IE;
wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
} }
#endif #endif
...@@ -149,8 +146,6 @@ static inline void pxa_ac97_warm_pxa27x(void) ...@@ -149,8 +146,6 @@ static inline void pxa_ac97_warm_pxa27x(void)
static inline void pxa_ac97_cold_pxa27x(void) static inline void pxa_ac97_cold_pxa27x(void)
{ {
unsigned int timeout;
GCR &= GCR_COLD_RST; /* clear everything but nCRST */ GCR &= GCR_COLD_RST; /* clear everything but nCRST */
GCR &= ~GCR_COLD_RST; /* then assert nCRST */ GCR &= ~GCR_COLD_RST; /* then assert nCRST */
...@@ -161,29 +156,20 @@ static inline void pxa_ac97_cold_pxa27x(void) ...@@ -161,29 +156,20 @@ static inline void pxa_ac97_cold_pxa27x(void)
udelay(5); udelay(5);
clk_disable(ac97conf_clk); clk_disable(ac97conf_clk);
GCR = GCR_COLD_RST | GCR_WARM_RST; GCR = GCR_COLD_RST | GCR_WARM_RST;
timeout = 100; /* wait for the codec-ready bit to be set */
while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
mdelay(1);
} }
#endif #endif
#ifdef CONFIG_PXA3xx #ifdef CONFIG_PXA3xx
static inline void pxa_ac97_warm_pxa3xx(void) static inline void pxa_ac97_warm_pxa3xx(void)
{ {
int timeout = 100;
gsr_bits = 0; gsr_bits = 0;
/* Can't use interrupts */ /* Can't use interrupts */
GCR |= GCR_WARM_RST; GCR |= GCR_WARM_RST;
while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
mdelay(1);
} }
static inline void pxa_ac97_cold_pxa3xx(void) static inline void pxa_ac97_cold_pxa3xx(void)
{ {
int timeout = 1000;
/* Hold CLKBPB for 100us */ /* Hold CLKBPB for 100us */
GCR = 0; GCR = 0;
GCR = GCR_CLKBPB; GCR = GCR_CLKBPB;
...@@ -199,14 +185,13 @@ static inline void pxa_ac97_cold_pxa3xx(void) ...@@ -199,14 +185,13 @@ static inline void pxa_ac97_cold_pxa3xx(void)
GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
GCR = GCR_WARM_RST | GCR_COLD_RST; GCR = GCR_WARM_RST | GCR_COLD_RST;
while (!(GSR & (GSR_PCR | GSR_SCR)) && timeout--)
mdelay(10);
} }
#endif #endif
bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
{ {
unsigned long gsr; unsigned long gsr;
unsigned int timeout = 100;
#ifdef CONFIG_PXA25x #ifdef CONFIG_PXA25x
if (cpu_is_pxa25x()) if (cpu_is_pxa25x())
...@@ -224,6 +209,10 @@ bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) ...@@ -224,6 +209,10 @@ bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
else else
#endif #endif
BUG(); BUG();
while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
mdelay(1);
gsr = GSR | gsr_bits; gsr = GSR | gsr_bits;
if (!(gsr & (GSR_PCR | GSR_SCR))) { if (!(gsr & (GSR_PCR | GSR_SCR))) {
printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n", printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",
...@@ -239,6 +228,7 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_warm_reset); ...@@ -239,6 +228,7 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_warm_reset);
bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
{ {
unsigned long gsr; unsigned long gsr;
unsigned int timeout = 1000;
#ifdef CONFIG_PXA25x #ifdef CONFIG_PXA25x
if (cpu_is_pxa25x()) if (cpu_is_pxa25x())
...@@ -257,6 +247,9 @@ bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) ...@@ -257,6 +247,9 @@ bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
#endif #endif
BUG(); BUG();
while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
mdelay(1);
gsr = GSR | gsr_bits; gsr = GSR | gsr_bits;
if (!(gsr & (GSR_PCR | GSR_SCR))) { if (!(gsr & (GSR_PCR | GSR_SCR))) {
printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n", printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",
......
snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o
snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o
ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),)
snd-soc-core-objs += soc-generic-dmaengine-pcm.o snd-soc-core-objs += soc-generic-dmaengine-pcm.o
......
...@@ -50,7 +50,7 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, ...@@ -50,7 +50,7 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
buf->area = dma_alloc_coherent(pcm->card->dev, size, buf->area = dma_alloc_coherent(pcm->card->dev, size,
&buf->addr, GFP_KERNEL); &buf->addr, GFP_KERNEL);
pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%zu\n", pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%zu\n",
(void *)buf->area, (void *)buf->addr, size); (void *)buf->area, (void *)(long)buf->addr, size);
if (!buf->area) if (!buf->area)
return -ENOMEM; return -ENOMEM;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/pinctrl/consumer.h>
#include <sound/soc.h> #include <sound/soc.h>
...@@ -155,15 +154,8 @@ static int atmel_asoc_wm8904_probe(struct platform_device *pdev) ...@@ -155,15 +154,8 @@ static int atmel_asoc_wm8904_probe(struct platform_device *pdev)
struct snd_soc_card *card = &atmel_asoc_wm8904_card; struct snd_soc_card *card = &atmel_asoc_wm8904_card;
struct snd_soc_dai_link *dailink = &atmel_asoc_wm8904_dailink; struct snd_soc_dai_link *dailink = &atmel_asoc_wm8904_dailink;
struct clk *clk_src; struct clk *clk_src;
struct pinctrl *pinctrl;
int id, ret; int id, ret;
pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
if (IS_ERR(pinctrl)) {
dev_err(&pdev->dev, "failed to request pinctrl\n");
return PTR_ERR(pinctrl);
}
card->dev = &pdev->dev; card->dev = &pdev->dev;
ret = atmel_asoc_wm8904_dt_init(pdev); ret = atmel_asoc_wm8904_dt_init(pdev);
if (ret) { if (ret) {
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/of.h>
#include <linux/atmel-ssc.h> #include <linux/atmel-ssc.h>
......
config SND_EP93XX_SOC config SND_EP93XX_SOC
tristate "SoC Audio support for the Cirrus Logic EP93xx series" tristate "SoC Audio support for the Cirrus Logic EP93xx series"
depends on ARCH_EP93XX && SND_SOC depends on (ARCH_EP93XX || COMPILE_TEST) && SND_SOC
select SND_SOC_GENERIC_DMAENGINE_PCM select SND_SOC_GENERIC_DMAENGINE_PCM
help help
Say Y or M if you want to add support for codecs attached to Say Y or M if you want to add support for codecs attached to
......
...@@ -57,9 +57,22 @@ static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param) ...@@ -57,9 +57,22 @@ static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
return false; return false;
} }
static struct dma_chan *ep93xx_compat_request_channel(
struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_substream *substream)
{
struct snd_dmaengine_dai_dma_data *dma_data;
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter,
dma_data);
}
static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = { static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
.pcm_hardware = &ep93xx_pcm_hardware, .pcm_hardware = &ep93xx_pcm_hardware,
.compat_filter_fn = ep93xx_pcm_dma_filter, .compat_filter_fn = ep93xx_pcm_dma_filter,
.compat_request_channel = ep93xx_compat_request_channel,
.prealloc_buffer_size = 131072, .prealloc_buffer_size = 131072,
}; };
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/mfd/88pm860x.h> #include <linux/mfd/88pm860x.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/regmap.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
...@@ -140,6 +141,7 @@ struct pm860x_priv { ...@@ -140,6 +141,7 @@ struct pm860x_priv {
unsigned int filter; unsigned int filter;
struct snd_soc_codec *codec; struct snd_soc_codec *codec;
struct i2c_client *i2c; struct i2c_client *i2c;
struct regmap *regmap;
struct pm860x_chip *chip; struct pm860x_chip *chip;
struct pm860x_det det; struct pm860x_det det;
...@@ -269,48 +271,6 @@ static struct st_gain st_table[] = { ...@@ -269,48 +271,6 @@ static struct st_gain st_table[] = {
{ -86, 29, 0}, { -56, 30, 0}, { -28, 31, 0}, { 0, 0, 0}, { -86, 29, 0}, { -56, 30, 0}, { -28, 31, 0}, { 0, 0, 0},
}; };
static int pm860x_volatile(unsigned int reg)
{
BUG_ON(reg >= REG_CACHE_SIZE);
switch (reg) {
case PM860X_AUDIO_SUPPLIES_2:
return 1;
}
return 0;
}
static unsigned int pm860x_read_reg_cache(struct snd_soc_codec *codec,
unsigned int reg)
{
unsigned char *cache = codec->reg_cache;
BUG_ON(reg >= REG_CACHE_SIZE);
if (pm860x_volatile(reg))
return cache[reg];
reg += REG_CACHE_BASE;
return pm860x_reg_read(codec->control_data, reg);
}
static int pm860x_write_reg_cache(struct snd_soc_codec *codec,
unsigned int reg, unsigned int value)
{
unsigned char *cache = codec->reg_cache;
BUG_ON(reg >= REG_CACHE_SIZE);
if (!pm860x_volatile(reg))
cache[reg] = (unsigned char)value;
reg += REG_CACHE_BASE;
return pm860x_reg_write(codec->control_data, reg, value);
}
static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
...@@ -1169,6 +1129,7 @@ static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -1169,6 +1129,7 @@ static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
static int pm860x_set_bias_level(struct snd_soc_codec *codec, static int pm860x_set_bias_level(struct snd_soc_codec *codec,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec);
int data; int data;
switch (level) { switch (level) {
...@@ -1182,17 +1143,17 @@ static int pm860x_set_bias_level(struct snd_soc_codec *codec, ...@@ -1182,17 +1143,17 @@ static int pm860x_set_bias_level(struct snd_soc_codec *codec,
if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
/* Enable Audio PLL & Audio section */ /* Enable Audio PLL & Audio section */
data = AUDIO_PLL | AUDIO_SECTION_ON; data = AUDIO_PLL | AUDIO_SECTION_ON;
pm860x_reg_write(codec->control_data, REG_MISC2, data); pm860x_reg_write(pm860x->i2c, REG_MISC2, data);
udelay(300); udelay(300);
data = AUDIO_PLL | AUDIO_SECTION_RESET data = AUDIO_PLL | AUDIO_SECTION_RESET
| AUDIO_SECTION_ON; | AUDIO_SECTION_ON;
pm860x_reg_write(codec->control_data, REG_MISC2, data); pm860x_reg_write(pm860x->i2c, REG_MISC2, data);
} }
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
data = AUDIO_PLL | AUDIO_SECTION_RESET | AUDIO_SECTION_ON; data = AUDIO_PLL | AUDIO_SECTION_RESET | AUDIO_SECTION_ON;
pm860x_set_bits(codec->control_data, REG_MISC2, data, 0); pm860x_set_bits(pm860x->i2c, REG_MISC2, data, 0);
break; break;
} }
codec->dapm.bias_level = level; codec->dapm.bias_level = level;
...@@ -1322,17 +1283,17 @@ int pm860x_hs_jack_detect(struct snd_soc_codec *codec, ...@@ -1322,17 +1283,17 @@ int pm860x_hs_jack_detect(struct snd_soc_codec *codec,
pm860x->det.lo_shrt = lo_shrt; pm860x->det.lo_shrt = lo_shrt;
if (det & SND_JACK_HEADPHONE) if (det & SND_JACK_HEADPHONE)
pm860x_set_bits(codec->control_data, REG_HS_DET, pm860x_set_bits(pm860x->i2c, REG_HS_DET,
EN_HS_DET, EN_HS_DET); EN_HS_DET, EN_HS_DET);
/* headset short detect */ /* headset short detect */
if (hs_shrt) { if (hs_shrt) {
data = CLR_SHORT_HS2 | CLR_SHORT_HS1; data = CLR_SHORT_HS2 | CLR_SHORT_HS1;
pm860x_set_bits(codec->control_data, REG_SHORTS, data, data); pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data);
} }
/* Lineout short detect */ /* Lineout short detect */
if (lo_shrt) { if (lo_shrt) {
data = CLR_SHORT_LO2 | CLR_SHORT_LO1; data = CLR_SHORT_LO2 | CLR_SHORT_LO1;
pm860x_set_bits(codec->control_data, REG_SHORTS, data, data); pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data);
} }
/* sync status */ /* sync status */
...@@ -1350,7 +1311,7 @@ int pm860x_mic_jack_detect(struct snd_soc_codec *codec, ...@@ -1350,7 +1311,7 @@ int pm860x_mic_jack_detect(struct snd_soc_codec *codec,
pm860x->det.mic_det = det; pm860x->det.mic_det = det;
if (det & SND_JACK_MICROPHONE) if (det & SND_JACK_MICROPHONE)
pm860x_set_bits(codec->control_data, REG_MIC_DET, pm860x_set_bits(pm860x->i2c, REG_MIC_DET,
MICDET_MASK, MICDET_MASK); MICDET_MASK, MICDET_MASK);
/* sync status */ /* sync status */
...@@ -1366,7 +1327,7 @@ static int pm860x_probe(struct snd_soc_codec *codec) ...@@ -1366,7 +1327,7 @@ static int pm860x_probe(struct snd_soc_codec *codec)
pm860x->codec = codec; pm860x->codec = codec;
codec->control_data = pm860x->i2c; codec->control_data = pm860x->regmap;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
ret = request_threaded_irq(pm860x->irq[i], NULL, ret = request_threaded_irq(pm860x->irq[i], NULL,
...@@ -1380,14 +1341,6 @@ static int pm860x_probe(struct snd_soc_codec *codec) ...@@ -1380,14 +1341,6 @@ static int pm860x_probe(struct snd_soc_codec *codec)
pm860x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); pm860x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
ret = pm860x_bulk_read(codec->control_data, REG_CACHE_BASE,
REG_CACHE_SIZE, codec->reg_cache);
if (ret < 0) {
dev_err(codec->dev, "Failed to fill register cache: %d\n",
ret);
goto out;
}
return 0; return 0;
out: out:
...@@ -1410,10 +1363,6 @@ static int pm860x_remove(struct snd_soc_codec *codec) ...@@ -1410,10 +1363,6 @@ static int pm860x_remove(struct snd_soc_codec *codec)
static struct snd_soc_codec_driver soc_codec_dev_pm860x = { static struct snd_soc_codec_driver soc_codec_dev_pm860x = {
.probe = pm860x_probe, .probe = pm860x_probe,
.remove = pm860x_remove, .remove = pm860x_remove,
.read = pm860x_read_reg_cache,
.write = pm860x_write_reg_cache,
.reg_cache_size = REG_CACHE_SIZE,
.reg_word_size = sizeof(u8),
.set_bias_level = pm860x_set_bias_level, .set_bias_level = pm860x_set_bias_level,
.controls = pm860x_snd_controls, .controls = pm860x_snd_controls,
...@@ -1439,6 +1388,8 @@ static int pm860x_codec_probe(struct platform_device *pdev) ...@@ -1439,6 +1388,8 @@ static int pm860x_codec_probe(struct platform_device *pdev)
pm860x->chip = chip; pm860x->chip = chip;
pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client
: chip->companion; : chip->companion;
pm860x->regmap = (chip->id == CHIP_PM8607) ? chip->regmap
: chip->regmap_companion;
platform_set_drvdata(pdev, pm860x); platform_set_drvdata(pdev, pm860x);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
......
...@@ -12,67 +12,66 @@ ...@@ -12,67 +12,66 @@
#ifndef __88PM860X_H #ifndef __88PM860X_H
#define __88PM860X_H #define __88PM860X_H
/* The offset of these registers are 0xb0 */ #define PM860X_PCM_IFACE_1 0xb0
#define PM860X_PCM_IFACE_1 0x00 #define PM860X_PCM_IFACE_2 0xb1
#define PM860X_PCM_IFACE_2 0x01 #define PM860X_PCM_IFACE_3 0xb2
#define PM860X_PCM_IFACE_3 0x02 #define PM860X_PCM_RATE 0xb3
#define PM860X_PCM_RATE 0x03 #define PM860X_EC_PATH 0xb4
#define PM860X_EC_PATH 0x04 #define PM860X_SIDETONE_L_GAIN 0xb5
#define PM860X_SIDETONE_L_GAIN 0x05 #define PM860X_SIDETONE_R_GAIN 0xb6
#define PM860X_SIDETONE_R_GAIN 0x06 #define PM860X_SIDETONE_SHIFT 0xb7
#define PM860X_SIDETONE_SHIFT 0x07 #define PM860X_ADC_OFFSET_1 0xb8
#define PM860X_ADC_OFFSET_1 0x08 #define PM860X_ADC_OFFSET_2 0xb9
#define PM860X_ADC_OFFSET_2 0x09 #define PM860X_DMIC_DELAY 0xba
#define PM860X_DMIC_DELAY 0x0a
#define PM860X_I2S_IFACE_1 0x0b #define PM860X_I2S_IFACE_1 0xbb
#define PM860X_I2S_IFACE_2 0x0c #define PM860X_I2S_IFACE_2 0xbc
#define PM860X_I2S_IFACE_3 0x0d #define PM860X_I2S_IFACE_3 0xbd
#define PM860X_I2S_IFACE_4 0x0e #define PM860X_I2S_IFACE_4 0xbe
#define PM860X_EQUALIZER_N0_1 0x0f #define PM860X_EQUALIZER_N0_1 0xbf
#define PM860X_EQUALIZER_N0_2 0x10 #define PM860X_EQUALIZER_N0_2 0xc0
#define PM860X_EQUALIZER_N1_1 0x11 #define PM860X_EQUALIZER_N1_1 0xc1
#define PM860X_EQUALIZER_N1_2 0x12 #define PM860X_EQUALIZER_N1_2 0xc2
#define PM860X_EQUALIZER_D1_1 0x13 #define PM860X_EQUALIZER_D1_1 0xc3
#define PM860X_EQUALIZER_D1_2 0x14 #define PM860X_EQUALIZER_D1_2 0xc4
#define PM860X_LOFI_GAIN_LEFT 0x15 #define PM860X_LOFI_GAIN_LEFT 0xc5
#define PM860X_LOFI_GAIN_RIGHT 0x16 #define PM860X_LOFI_GAIN_RIGHT 0xc6
#define PM860X_HIFIL_GAIN_LEFT 0x17 #define PM860X_HIFIL_GAIN_LEFT 0xc7
#define PM860X_HIFIL_GAIN_RIGHT 0x18 #define PM860X_HIFIL_GAIN_RIGHT 0xc8
#define PM860X_HIFIR_GAIN_LEFT 0x19 #define PM860X_HIFIR_GAIN_LEFT 0xc9
#define PM860X_HIFIR_GAIN_RIGHT 0x1a #define PM860X_HIFIR_GAIN_RIGHT 0xca
#define PM860X_DAC_OFFSET 0x1b #define PM860X_DAC_OFFSET 0xcb
#define PM860X_OFFSET_LEFT_1 0x1c #define PM860X_OFFSET_LEFT_1 0xcc
#define PM860X_OFFSET_LEFT_2 0x1d #define PM860X_OFFSET_LEFT_2 0xcd
#define PM860X_OFFSET_RIGHT_1 0x1e #define PM860X_OFFSET_RIGHT_1 0xce
#define PM860X_OFFSET_RIGHT_2 0x1f #define PM860X_OFFSET_RIGHT_2 0xcf
#define PM860X_ADC_ANA_1 0x20 #define PM860X_ADC_ANA_1 0xd0
#define PM860X_ADC_ANA_2 0x21 #define PM860X_ADC_ANA_2 0xd1
#define PM860X_ADC_ANA_3 0x22 #define PM860X_ADC_ANA_3 0xd2
#define PM860X_ADC_ANA_4 0x23 #define PM860X_ADC_ANA_4 0xd3
#define PM860X_ANA_TO_ANA 0x24 #define PM860X_ANA_TO_ANA 0xd4
#define PM860X_HS1_CTRL 0x25 #define PM860X_HS1_CTRL 0xd5
#define PM860X_HS2_CTRL 0x26 #define PM860X_HS2_CTRL 0xd6
#define PM860X_LO1_CTRL 0x27 #define PM860X_LO1_CTRL 0xd7
#define PM860X_LO2_CTRL 0x28 #define PM860X_LO2_CTRL 0xd8
#define PM860X_EAR_CTRL_1 0x29 #define PM860X_EAR_CTRL_1 0xd9
#define PM860X_EAR_CTRL_2 0x2a #define PM860X_EAR_CTRL_2 0xda
#define PM860X_AUDIO_SUPPLIES_1 0x2b #define PM860X_AUDIO_SUPPLIES_1 0xdb
#define PM860X_AUDIO_SUPPLIES_2 0x2c #define PM860X_AUDIO_SUPPLIES_2 0xdc
#define PM860X_ADC_EN_1 0x2d #define PM860X_ADC_EN_1 0xdd
#define PM860X_ADC_EN_2 0x2e #define PM860X_ADC_EN_2 0xde
#define PM860X_DAC_EN_1 0x2f #define PM860X_DAC_EN_1 0xdf
#define PM860X_DAC_EN_2 0x31 #define PM860X_DAC_EN_2 0xe1
#define PM860X_AUDIO_CAL_1 0x32 #define PM860X_AUDIO_CAL_1 0xe2
#define PM860X_AUDIO_CAL_2 0x33 #define PM860X_AUDIO_CAL_2 0xe3
#define PM860X_AUDIO_CAL_3 0x34 #define PM860X_AUDIO_CAL_3 0xe4
#define PM860X_AUDIO_CAL_4 0x35 #define PM860X_AUDIO_CAL_4 0xe5
#define PM860X_AUDIO_CAL_5 0x36 #define PM860X_AUDIO_CAL_5 0xe6
#define PM860X_ANA_INPUT_SEL_1 0x37 #define PM860X_ANA_INPUT_SEL_1 0xe7
#define PM860X_ANA_INPUT_SEL_2 0x38 #define PM860X_ANA_INPUT_SEL_2 0xe8
#define PM860X_PCM_IFACE_4 0x39 #define PM860X_PCM_IFACE_4 0xe9
#define PM860X_I2S_IFACE_5 0x3a #define PM860X_I2S_IFACE_5 0xea
#define PM860X_SHORTS 0x3b #define PM860X_SHORTS 0x3b
#define PM860X_PLL_ADJ_1 0x3c #define PM860X_PLL_ADJ_1 0x3c
......
...@@ -2532,11 +2532,9 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) ...@@ -2532,11 +2532,9 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec)
} }
/* Override HW-defaults */ /* Override HW-defaults */
ab8500_codec_write_reg(codec, snd_soc_write(codec, AB8500_ANACONF5,
AB8500_ANACONF5,
BIT(AB8500_ANACONF5_HSAUTOEN)); BIT(AB8500_ANACONF5_HSAUTOEN));
ab8500_codec_write_reg(codec, snd_soc_write(codec, AB8500_SHORTCIRCONF,
AB8500_SHORTCIRCONF,
BIT(AB8500_SHORTCIRCONF_HSZCDDIS)); BIT(AB8500_SHORTCIRCONF_HSZCDDIS));
/* Add filter controls */ /* Add filter controls */
...@@ -2606,7 +2604,7 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) ...@@ -2606,7 +2604,7 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev)
static int ab8500_codec_driver_remove(struct platform_device *pdev) static int ab8500_codec_driver_remove(struct platform_device *pdev)
{ {
dev_info(&pdev->dev, "%s Enter.\n", __func__); dev_dbg(&pdev->dev, "%s Enter.\n", __func__);
snd_soc_unregister_codec(&pdev->dev); snd_soc_unregister_codec(&pdev->dev);
......
This diff is collapsed.
This diff is collapsed.
...@@ -45,8 +45,6 @@ ...@@ -45,8 +45,6 @@
#define AK4104_TX_TXE (1 << 0) #define AK4104_TX_TXE (1 << 0)
#define AK4104_TX_V (1 << 1) #define AK4104_TX_V (1 << 1)
#define DRV_NAME "ak4104-codec"
struct ak4104_private { struct ak4104_private {
struct regmap *regmap; struct regmap *regmap;
}; };
...@@ -291,12 +289,19 @@ static const struct of_device_id ak4104_of_match[] = { ...@@ -291,12 +289,19 @@ static const struct of_device_id ak4104_of_match[] = {
}; };
MODULE_DEVICE_TABLE(of, ak4104_of_match); MODULE_DEVICE_TABLE(of, ak4104_of_match);
static const struct spi_device_id ak4104_id_table[] = {
{ "ak4104", 0 },
{ }
};
MODULE_DEVICE_TABLE(spi, ak4104_id_table);
static struct spi_driver ak4104_spi_driver = { static struct spi_driver ak4104_spi_driver = {
.driver = { .driver = {
.name = DRV_NAME, .name = "ak4104",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = ak4104_of_match, .of_match_table = ak4104_of_match,
}, },
.id_table = ak4104_id_table,
.probe = ak4104_spi_probe, .probe = ak4104_spi_probe,
.remove = ak4104_spi_remove, .remove = ak4104_spi_remove,
}; };
......
...@@ -352,7 +352,6 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -352,7 +352,6 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
*/ */
default: default:
return -EINVAL; return -EINVAL;
break;
} }
snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data); snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data);
...@@ -405,7 +404,6 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -405,7 +404,6 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream,
break; break;
default: default:
return -EINVAL; return -EINVAL;
break;
} }
snd_soc_update_bits(codec, MD_CTL2, FS_MASK, rate); snd_soc_update_bits(codec, MD_CTL2, FS_MASK, rate);
......
...@@ -1477,21 +1477,25 @@ static void arizona_enable_fll(struct arizona_fll *fll, ...@@ -1477,21 +1477,25 @@ static void arizona_enable_fll(struct arizona_fll *fll,
{ {
struct arizona *arizona = fll->arizona; struct arizona *arizona = fll->arizona;
int ret; int ret;
bool use_sync = false;
/* /*
* If we have both REFCLK and SYNCCLK then enable both, * If we have both REFCLK and SYNCCLK then enable both,
* otherwise apply the SYNCCLK settings to REFCLK. * otherwise apply the SYNCCLK settings to REFCLK.
*/ */
if (fll->ref_src >= 0 && fll->ref_src != fll->sync_src) { if (fll->ref_src >= 0 && fll->ref_freq &&
fll->ref_src != fll->sync_src) {
regmap_update_bits(arizona->regmap, fll->base + 5, regmap_update_bits(arizona->regmap, fll->base + 5,
ARIZONA_FLL1_OUTDIV_MASK, ARIZONA_FLL1_OUTDIV_MASK,
ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT);
arizona_apply_fll(arizona, fll->base, ref, fll->ref_src, arizona_apply_fll(arizona, fll->base, ref, fll->ref_src,
false); false);
if (fll->sync_src >= 0) if (fll->sync_src >= 0) {
arizona_apply_fll(arizona, fll->base + 0x10, sync, arizona_apply_fll(arizona, fll->base + 0x10, sync,
fll->sync_src, true); fll->sync_src, true);
use_sync = true;
}
} else if (fll->sync_src >= 0) { } else if (fll->sync_src >= 0) {
regmap_update_bits(arizona->regmap, fll->base + 5, regmap_update_bits(arizona->regmap, fll->base + 5,
ARIZONA_FLL1_OUTDIV_MASK, ARIZONA_FLL1_OUTDIV_MASK,
...@@ -1511,7 +1515,7 @@ static void arizona_enable_fll(struct arizona_fll *fll, ...@@ -1511,7 +1515,7 @@ static void arizona_enable_fll(struct arizona_fll *fll,
* Increase the bandwidth if we're not using a low frequency * Increase the bandwidth if we're not using a low frequency
* sync source. * sync source.
*/ */
if (fll->sync_src >= 0 && fll->sync_freq > 100000) if (use_sync && fll->sync_freq > 100000)
regmap_update_bits(arizona->regmap, fll->base + 0x17, regmap_update_bits(arizona->regmap, fll->base + 0x17,
ARIZONA_FLL1_SYNC_BW, 0); ARIZONA_FLL1_SYNC_BW, 0);
else else
...@@ -1526,8 +1530,7 @@ static void arizona_enable_fll(struct arizona_fll *fll, ...@@ -1526,8 +1530,7 @@ static void arizona_enable_fll(struct arizona_fll *fll,
regmap_update_bits(arizona->regmap, fll->base + 1, regmap_update_bits(arizona->regmap, fll->base + 1,
ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA);
if (fll->ref_src >= 0 && fll->sync_src >= 0 && if (use_sync)
fll->ref_src != fll->sync_src)
regmap_update_bits(arizona->regmap, fll->base + 0x11, regmap_update_bits(arizona->regmap, fll->base + 0x11,
ARIZONA_FLL1_SYNC_ENA, ARIZONA_FLL1_SYNC_ENA,
ARIZONA_FLL1_SYNC_ENA); ARIZONA_FLL1_SYNC_ENA);
...@@ -1561,10 +1564,12 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source, ...@@ -1561,10 +1564,12 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
if (fll->ref_src == source && fll->ref_freq == Fref) if (fll->ref_src == source && fll->ref_freq == Fref)
return 0; return 0;
if (fll->fout && Fref > 0) { if (fll->fout) {
if (Fref > 0) {
ret = arizona_calc_fll(fll, &ref, Fref, fll->fout); ret = arizona_calc_fll(fll, &ref, Fref, fll->fout);
if (ret != 0) if (ret != 0)
return ret; return ret;
}
if (fll->sync_src >= 0) { if (fll->sync_src >= 0) {
ret = arizona_calc_fll(fll, &sync, fll->sync_freq, ret = arizona_calc_fll(fll, &sync, fll->sync_freq,
......
...@@ -38,24 +38,6 @@ ...@@ -38,24 +38,6 @@
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/initval.h> #include <sound/initval.h>
static inline unsigned int cq93vc_read(struct snd_soc_codec *codec,
unsigned int reg)
{
struct davinci_vc *davinci_vc = codec->control_data;
return readl(davinci_vc->base + reg);
}
static inline int cq93vc_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value)
{
struct davinci_vc *davinci_vc = codec->control_data;
writel(value, davinci_vc->base + reg);
return 0;
}
static const struct snd_kcontrol_new cq93vc_snd_controls[] = { static const struct snd_kcontrol_new cq93vc_snd_controls[] = {
SOC_SINGLE("PGA Capture Volume", DAVINCI_VC_REG05, 0, 0x03, 0), SOC_SINGLE("PGA Capture Volume", DAVINCI_VC_REG05, 0, 0x03, 0),
SOC_SINGLE("Mono DAC Playback Volume", DAVINCI_VC_REG09, 0, 0x3f, 0), SOC_SINGLE("Mono DAC Playback Volume", DAVINCI_VC_REG09, 0, 0x3f, 0),
...@@ -64,13 +46,15 @@ static const struct snd_kcontrol_new cq93vc_snd_controls[] = { ...@@ -64,13 +46,15 @@ static const struct snd_kcontrol_new cq93vc_snd_controls[] = {
static int cq93vc_mute(struct snd_soc_dai *dai, int mute) static int cq93vc_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_codec *codec = dai->codec;
u8 reg = cq93vc_read(codec, DAVINCI_VC_REG09) & ~DAVINCI_VC_REG09_MUTE; u8 reg;
if (mute) if (mute)
cq93vc_write(codec, DAVINCI_VC_REG09, reg = DAVINCI_VC_REG09_MUTE;
reg | DAVINCI_VC_REG09_MUTE);
else else
cq93vc_write(codec, DAVINCI_VC_REG09, reg); reg = 0;
snd_soc_update_bits(codec, DAVINCI_VC_REG09, DAVINCI_VC_REG09_MUTE,
reg);
return 0; return 0;
} }
...@@ -79,7 +63,7 @@ static int cq93vc_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -79,7 +63,7 @@ static int cq93vc_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_codec *codec = codec_dai->codec;
struct davinci_vc *davinci_vc = codec->control_data; struct davinci_vc *davinci_vc = codec->dev->platform_data;
switch (freq) { switch (freq) {
case 22579200: case 22579200:
...@@ -97,18 +81,18 @@ static int cq93vc_set_bias_level(struct snd_soc_codec *codec, ...@@ -97,18 +81,18 @@ static int cq93vc_set_bias_level(struct snd_soc_codec *codec,
{ {
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
cq93vc_write(codec, DAVINCI_VC_REG12, snd_soc_write(codec, DAVINCI_VC_REG12,
DAVINCI_VC_REG12_POWER_ALL_ON); DAVINCI_VC_REG12_POWER_ALL_ON);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
cq93vc_write(codec, DAVINCI_VC_REG12, snd_soc_write(codec, DAVINCI_VC_REG12,
DAVINCI_VC_REG12_POWER_ALL_OFF); DAVINCI_VC_REG12_POWER_ALL_OFF);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* force all power off */ /* force all power off */
cq93vc_write(codec, DAVINCI_VC_REG12, snd_soc_write(codec, DAVINCI_VC_REG12,
DAVINCI_VC_REG12_POWER_ALL_OFF); DAVINCI_VC_REG12_POWER_ALL_OFF);
break; break;
} }
...@@ -154,11 +138,9 @@ static int cq93vc_probe(struct snd_soc_codec *codec) ...@@ -154,11 +138,9 @@ static int cq93vc_probe(struct snd_soc_codec *codec)
struct davinci_vc *davinci_vc = codec->dev->platform_data; struct davinci_vc *davinci_vc = codec->dev->platform_data;
davinci_vc->cq93vc.codec = codec; davinci_vc->cq93vc.codec = codec;
codec->control_data = davinci_vc; codec->control_data = davinci_vc->regmap;
/* Set controls */ snd_soc_codec_set_cache_io(codec, 32, 32, SND_SOC_REGMAP);
snd_soc_add_codec_controls(codec, cq93vc_snd_controls,
ARRAY_SIZE(cq93vc_snd_controls));
/* Off, with power on */ /* Off, with power on */
cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY); cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
...@@ -174,12 +156,12 @@ static int cq93vc_remove(struct snd_soc_codec *codec) ...@@ -174,12 +156,12 @@ static int cq93vc_remove(struct snd_soc_codec *codec)
} }
static struct snd_soc_codec_driver soc_codec_dev_cq93vc = { static struct snd_soc_codec_driver soc_codec_dev_cq93vc = {
.read = cq93vc_read,
.write = cq93vc_write,
.set_bias_level = cq93vc_set_bias_level, .set_bias_level = cq93vc_set_bias_level,
.probe = cq93vc_probe, .probe = cq93vc_probe,
.remove = cq93vc_remove, .remove = cq93vc_remove,
.resume = cq93vc_resume, .resume = cq93vc_resume,
.controls = cq93vc_snd_controls,
.num_controls = ARRAY_SIZE(cq93vc_snd_controls),
}; };
static int cq93vc_platform_probe(struct platform_device *pdev) static int cq93vc_platform_probe(struct platform_device *pdev)
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <sound/pcm.h> #include <sound/pcm.h>
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/of_gpio.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/regmap.h> #include <linux/regmap.h>
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#include <sound/initval.h> #include <sound/initval.h>
#include <sound/tlv.h> #include <sound/tlv.h>
#include <sound/cs42l73.h>
#include "cs42l73.h" #include "cs42l73.h"
struct sp_config { struct sp_config {
...@@ -35,6 +37,7 @@ struct sp_config { ...@@ -35,6 +37,7 @@ struct sp_config {
u32 srate; u32 srate;
}; };
struct cs42l73_private { struct cs42l73_private {
struct cs42l73_platform_data pdata;
struct sp_config config[3]; struct sp_config config[3];
struct regmap *regmap; struct regmap *regmap;
u32 sysclk; u32 sysclk;
...@@ -310,15 +313,6 @@ static const struct soc_enum ng_delay_enum = ...@@ -310,15 +313,6 @@ static const struct soc_enum ng_delay_enum =
SOC_ENUM_SINGLE(CS42L73_NGCAB, 0, SOC_ENUM_SINGLE(CS42L73_NGCAB, 0,
ARRAY_SIZE(cs42l73_ng_delay_text), cs42l73_ng_delay_text); ARRAY_SIZE(cs42l73_ng_delay_text), cs42l73_ng_delay_text);
static const char * const charge_pump_freq_text[] = {
"0", "1", "2", "3", "4",
"5", "6", "7", "8", "9",
"10", "11", "12", "13", "14", "15" };
static const struct soc_enum charge_pump_enum =
SOC_ENUM_SINGLE(CS42L73_CPFCHC, 4,
ARRAY_SIZE(charge_pump_freq_text), charge_pump_freq_text);
static const char * const cs42l73_mono_mix_texts[] = { static const char * const cs42l73_mono_mix_texts[] = {
"Left", "Right", "Mono Mix"}; "Left", "Right", "Mono Mix"};
...@@ -511,8 +505,6 @@ static const struct snd_kcontrol_new cs42l73_snd_controls[] = { ...@@ -511,8 +505,6 @@ static const struct snd_kcontrol_new cs42l73_snd_controls[] = {
SOC_SINGLE("NG Threshold", CS42L73_NGCAB, 2, 7, 0), SOC_SINGLE("NG Threshold", CS42L73_NGCAB, 2, 7, 0),
SOC_ENUM("NG Delay", ng_delay_enum), SOC_ENUM("NG Delay", ng_delay_enum),
SOC_ENUM("Charge Pump Frequency", charge_pump_enum),
SOC_DOUBLE_R_TLV("XSP-IP Volume", SOC_DOUBLE_R_TLV("XSP-IP Volume",
CS42L73_XSPAIPAA, CS42L73_XSPBIPBA, 0, 0x3F, 1, CS42L73_XSPAIPAA, CS42L73_XSPBIPBA, 0, 0x3F, 1,
attn_tlv), attn_tlv),
...@@ -1055,11 +1047,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -1055,11 +1047,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
mmcc |= MS_MASTER; mmcc |= CS42L73_MS_MASTER;
break; break;
case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBS_CFS:
mmcc &= ~MS_MASTER; mmcc &= ~CS42L73_MS_MASTER;
break; break;
default: default:
...@@ -1071,11 +1063,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -1071,11 +1063,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
switch (format) { switch (format) {
case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_I2S:
spc &= ~SPDIF_PCM; spc &= ~CS42L73_SPDIF_PCM;
break; break;
case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_A:
case SND_SOC_DAIFMT_DSP_B: case SND_SOC_DAIFMT_DSP_B:
if (mmcc & MS_MASTER) { if (mmcc & CS42L73_MS_MASTER) {
dev_err(codec->dev, dev_err(codec->dev,
"PCM format in slave mode only\n"); "PCM format in slave mode only\n");
return -EINVAL; return -EINVAL;
...@@ -1085,25 +1077,25 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -1085,25 +1077,25 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
"PCM format is not supported on ASP port\n"); "PCM format is not supported on ASP port\n");
return -EINVAL; return -EINVAL;
} }
spc |= SPDIF_PCM; spc |= CS42L73_SPDIF_PCM;
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
if (spc & SPDIF_PCM) { if (spc & CS42L73_SPDIF_PCM) {
/* Clear PCM mode, clear PCM_BIT_ORDER bit for MSB->LSB */ /* Clear PCM mode, clear PCM_BIT_ORDER bit for MSB->LSB */
spc &= ~(PCM_MODE_MASK | PCM_BIT_ORDER); spc &= ~(CS42L73_PCM_MODE_MASK | CS42L73_PCM_BIT_ORDER);
switch (format) { switch (format) {
case SND_SOC_DAIFMT_DSP_B: case SND_SOC_DAIFMT_DSP_B:
if (inv == SND_SOC_DAIFMT_IB_IF) if (inv == SND_SOC_DAIFMT_IB_IF)
spc |= PCM_MODE0; spc |= CS42L73_PCM_MODE0;
if (inv == SND_SOC_DAIFMT_IB_NF) if (inv == SND_SOC_DAIFMT_IB_NF)
spc |= PCM_MODE1; spc |= CS42L73_PCM_MODE1;
break; break;
case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_A:
if (inv == SND_SOC_DAIFMT_IB_IF) if (inv == SND_SOC_DAIFMT_IB_IF)
spc |= PCM_MODE1; spc |= CS42L73_PCM_MODE1;
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -1163,7 +1155,7 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -1163,7 +1155,7 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream,
int mclk_coeff; int mclk_coeff;
int srate = params_rate(params); int srate = params_rate(params);
if (priv->config[id].mmcc & MS_MASTER) { if (priv->config[id].mmcc & CS42L73_MS_MASTER) {
/* CS42L73 Master */ /* CS42L73 Master */
/* MCLK -> srate */ /* MCLK -> srate */
mclk_coeff = mclk_coeff =
...@@ -1182,13 +1174,13 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -1182,13 +1174,13 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream,
priv->config[id].spc &= 0xFC; priv->config[id].spc &= 0xFC;
/* Use SCLK=64*Fs if internal MCLK >= 6.4MHz */ /* Use SCLK=64*Fs if internal MCLK >= 6.4MHz */
if (priv->mclk >= 6400000) if (priv->mclk >= 6400000)
priv->config[id].spc |= MCK_SCLK_64FS; priv->config[id].spc |= CS42L73_MCK_SCLK_64FS;
else else
priv->config[id].spc |= MCK_SCLK_MCLK; priv->config[id].spc |= CS42L73_MCK_SCLK_MCLK;
} else { } else {
/* CS42L73 Slave */ /* CS42L73 Slave */
priv->config[id].spc &= 0xFC; priv->config[id].spc &= 0xFC;
priv->config[id].spc |= MCK_SCLK_64FS; priv->config[id].spc |= CS42L73_MCK_SCLK_64FS;
} }
/* Update ASRCs */ /* Update ASRCs */
priv->config[id].srate = srate; priv->config[id].srate = srate;
...@@ -1208,8 +1200,8 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, ...@@ -1208,8 +1200,8 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 0); snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 0);
snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 0); snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 0);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
...@@ -1220,11 +1212,11 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, ...@@ -1220,11 +1212,11 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
regcache_cache_only(cs42l73->regmap, false); regcache_cache_only(cs42l73->regmap, false);
regcache_sync(cs42l73->regmap); regcache_sync(cs42l73->regmap);
} }
snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1); snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1); snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1);
if (cs42l73->shutdwn_delay > 0) { if (cs42l73->shutdwn_delay > 0) {
mdelay(cs42l73->shutdwn_delay); mdelay(cs42l73->shutdwn_delay);
cs42l73->shutdwn_delay = 0; cs42l73->shutdwn_delay = 0;
...@@ -1233,7 +1225,7 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, ...@@ -1233,7 +1225,7 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
* down. * down.
*/ */
} }
snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 1); snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 1);
break; break;
} }
codec->dapm.bias_level = level; codec->dapm.bias_level = level;
...@@ -1367,11 +1359,16 @@ static int cs42l73_probe(struct snd_soc_codec *codec) ...@@ -1367,11 +1359,16 @@ static int cs42l73_probe(struct snd_soc_codec *codec)
return ret; return ret;
} }
regcache_cache_only(cs42l73->regmap, true);
cs42l73_set_bias_level(codec, SND_SOC_BIAS_STANDBY); cs42l73_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
cs42l73->mclksel = CS42L73_CLKID_MCLK1; /* MCLK1 as master clk */ /* Set Charge Pump Frequency */
if (cs42l73->pdata.chgfreq)
snd_soc_update_bits(codec, CS42L73_CPFCHC,
CS42L73_CHARGEPUMP_MASK,
cs42l73->pdata.chgfreq << 4);
/* MCLK1 as master clk */
cs42l73->mclksel = CS42L73_CLKID_MCLK1;
cs42l73->mclk = 0; cs42l73->mclk = 0;
return ret; return ret;
...@@ -1415,9 +1412,11 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, ...@@ -1415,9 +1412,11 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct cs42l73_private *cs42l73; struct cs42l73_private *cs42l73;
struct cs42l73_platform_data *pdata = dev_get_platdata(&i2c_client->dev);
int ret; int ret;
unsigned int devid = 0; unsigned int devid = 0;
unsigned int reg; unsigned int reg;
u32 val32;
cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private),
GFP_KERNEL); GFP_KERNEL);
...@@ -1426,14 +1425,49 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, ...@@ -1426,14 +1425,49 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
return -ENOMEM; return -ENOMEM;
} }
i2c_set_clientdata(i2c_client, cs42l73);
cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap); cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap);
if (IS_ERR(cs42l73->regmap)) { if (IS_ERR(cs42l73->regmap)) {
ret = PTR_ERR(cs42l73->regmap); ret = PTR_ERR(cs42l73->regmap);
dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret);
return ret; return ret;
} }
if (pdata) {
cs42l73->pdata = *pdata;
} else {
pdata = devm_kzalloc(&i2c_client->dev,
sizeof(struct cs42l73_platform_data),
GFP_KERNEL);
if (!pdata) {
dev_err(&i2c_client->dev, "could not allocate pdata\n");
return -ENOMEM;
}
if (i2c_client->dev.of_node) {
if (of_property_read_u32(i2c_client->dev.of_node,
"chgfreq", &val32) >= 0)
pdata->chgfreq = val32;
}
pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node,
"reset-gpio", 0);
cs42l73->pdata = *pdata;
}
i2c_set_clientdata(i2c_client, cs42l73);
if (cs42l73->pdata.reset_gpio) {
ret = gpio_request_one(cs42l73->pdata.reset_gpio,
GPIOF_OUT_INIT_HIGH, "CS42L73 /RST");
if (ret < 0) {
dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n",
cs42l73->pdata.reset_gpio, ret);
return ret;
}
gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0);
gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 1);
}
regcache_cache_bypass(cs42l73->regmap, true);
/* initialize codec */ /* initialize codec */
ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, &reg); ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, &reg);
devid = (reg & 0xFF) << 12; devid = (reg & 0xFF) << 12;
...@@ -1444,7 +1478,6 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, ...@@ -1444,7 +1478,6 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, &reg); ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, &reg);
devid |= (reg & 0xF0) >> 4; devid |= (reg & 0xF0) >> 4;
if (devid != CS42L73_DEVID) { if (devid != CS42L73_DEVID) {
ret = -ENODEV; ret = -ENODEV;
dev_err(&i2c_client->dev, dev_err(&i2c_client->dev,
...@@ -1462,7 +1495,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, ...@@ -1462,7 +1495,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
dev_info(&i2c_client->dev, dev_info(&i2c_client->dev,
"Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF); "Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF);
regcache_cache_only(cs42l73->regmap, true); regcache_cache_bypass(cs42l73->regmap, false);
ret = snd_soc_register_codec(&i2c_client->dev, ret = snd_soc_register_codec(&i2c_client->dev,
&soc_codec_dev_cs42l73, cs42l73_dai, &soc_codec_dev_cs42l73, cs42l73_dai,
...@@ -1478,6 +1511,12 @@ static int cs42l73_i2c_remove(struct i2c_client *client) ...@@ -1478,6 +1511,12 @@ static int cs42l73_i2c_remove(struct i2c_client *client)
return 0; return 0;
} }
static const struct of_device_id cs42l73_of_match[] = {
{ .compatible = "cirrus,cs42l73", },
{},
};
MODULE_DEVICE_TABLE(of, cs42l73_of_match);
static const struct i2c_device_id cs42l73_id[] = { static const struct i2c_device_id cs42l73_id[] = {
{"cs42l73", 0}, {"cs42l73", 0},
{} {}
...@@ -1489,6 +1528,7 @@ static struct i2c_driver cs42l73_i2c_driver = { ...@@ -1489,6 +1528,7 @@ static struct i2c_driver cs42l73_i2c_driver = {
.driver = { .driver = {
.name = "cs42l73", .name = "cs42l73",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = cs42l73_of_match,
}, },
.id_table = cs42l73_id, .id_table = cs42l73_id,
.probe = cs42l73_i2c_probe, .probe = cs42l73_i2c_probe,
......
...@@ -128,59 +128,60 @@ ...@@ -128,59 +128,60 @@
/* Bitfield Definitions */ /* Bitfield Definitions */
/* CS42L73_PWRCTL1 */ /* CS42L73_PWRCTL1 */
#define PDN_ADCB (1 << 7) #define CS42L73_PDN_ADCB (1 << 7)
#define PDN_DMICB (1 << 6) #define CS42L73_PDN_DMICB (1 << 6)
#define PDN_ADCA (1 << 5) #define CS42L73_PDN_ADCA (1 << 5)
#define PDN_DMICA (1 << 4) #define CS42L73_PDN_DMICA (1 << 4)
#define PDN_LDO (1 << 2) #define CS42L73_PDN_LDO (1 << 2)
#define DISCHG_FILT (1 << 1) #define CS42L73_DISCHG_FILT (1 << 1)
#define PDN (1 << 0) #define CS42L73_PDN (1 << 0)
/* CS42L73_PWRCTL2 */ /* CS42L73_PWRCTL2 */
#define PDN_MIC2_BIAS (1 << 7) #define CS42L73_PDN_MIC2_BIAS (1 << 7)
#define PDN_MIC1_BIAS (1 << 6) #define CS42L73_PDN_MIC1_BIAS (1 << 6)
#define PDN_VSP (1 << 4) #define CS42L73_PDN_VSP (1 << 4)
#define PDN_ASP_SDOUT (1 << 3) #define CS42L73_PDN_ASP_SDOUT (1 << 3)
#define PDN_ASP_SDIN (1 << 2) #define CS42L73_PDN_ASP_SDIN (1 << 2)
#define PDN_XSP_SDOUT (1 << 1) #define CS42L73_PDN_XSP_SDOUT (1 << 1)
#define PDN_XSP_SDIN (1 << 0) #define CS42L73_PDN_XSP_SDIN (1 << 0)
/* CS42L73_PWRCTL3 */ /* CS42L73_PWRCTL3 */
#define PDN_THMS (1 << 5) #define CS42L73_PDN_THMS (1 << 5)
#define PDN_SPKLO (1 << 4) #define CS42L73_PDN_SPKLO (1 << 4)
#define PDN_EAR (1 << 3) #define CS42L73_PDN_EAR (1 << 3)
#define PDN_SPK (1 << 2) #define CS42L73_PDN_SPK (1 << 2)
#define PDN_LO (1 << 1) #define CS42L73_PDN_LO (1 << 1)
#define PDN_HP (1 << 0) #define CS42L73_PDN_HP (1 << 0)
/* Thermal Overload Detect. Requires interrupt ... */ /* Thermal Overload Detect. Requires interrupt ... */
#define THMOVLD_150C 0 #define CS42L73_THMOVLD_150C 0
#define THMOVLD_132C 1 #define CS42L73_THMOVLD_132C 1
#define THMOVLD_115C 2 #define CS42L73_THMOVLD_115C 2
#define THMOVLD_098C 3 #define CS42L73_THMOVLD_098C 3
#define CS42L73_CHARGEPUMP_MASK (0xF0)
/* CS42L73_ASPC, CS42L73_XSPC, CS42L73_VSPC */ /* CS42L73_ASPC, CS42L73_XSPC, CS42L73_VSPC */
#define SP_3ST (1 << 7) #define CS42L73_SP_3ST (1 << 7)
#define SPDIF_I2S (0 << 6) #define CS42L73_SPDIF_I2S (0 << 6)
#define SPDIF_PCM (1 << 6) #define CS42L73_SPDIF_PCM (1 << 6)
#define PCM_MODE0 (0 << 4) #define CS42L73_PCM_MODE0 (0 << 4)
#define PCM_MODE1 (1 << 4) #define CS42L73_PCM_MODE1 (1 << 4)
#define PCM_MODE2 (2 << 4) #define CS42L73_PCM_MODE2 (2 << 4)
#define PCM_MODE_MASK (3 << 4) #define CS42L73_PCM_MODE_MASK (3 << 4)
#define PCM_BIT_ORDER (1 << 3) #define CS42L73_PCM_BIT_ORDER (1 << 3)
#define MCK_SCLK_64FS (0 << 0) #define CS42L73_MCK_SCLK_64FS (0 << 0)
#define MCK_SCLK_MCLK (2 << 0) #define CS42L73_MCK_SCLK_MCLK (2 << 0)
#define MCK_SCLK_PREMCLK (3 << 0) #define CS42L73_MCK_SCLK_PREMCLK (3 << 0)
/* CS42L73_xSPMMCC */ /* CS42L73_xSPMMCC */
#define MS_MASTER (1 << 7) #define CS42L73_MS_MASTER (1 << 7)
/* CS42L73_DMMCC */ /* CS42L73_DMMCC */
#define MCLKDIS (1 << 0) #define CS42L73_MCLKDIS (1 << 0)
#define MCLKSEL_MCLK2 (1 << 4) #define CS42L73_MCLKSEL_MCLK2 (1 << 4)
#define MCLKSEL_MCLK1 (0 << 4) #define CS42L73_MCLKSEL_MCLK1 (0 << 4)
/* CS42L73 MCLK derived from MCLK1 or MCLK2 */ /* CS42L73 MCLK derived from MCLK1 or MCLK2 */
#define CS42L73_CLKID_MCLK1 0 #define CS42L73_CLKID_MCLK1 0
...@@ -194,28 +195,26 @@ ...@@ -194,28 +195,26 @@
#define CS42L73_VSP 2 #define CS42L73_VSP 2
/* IS1, IM1 */ /* IS1, IM1 */
#define MIC2_SDET (1 << 6) #define CS42L73_MIC2_SDET (1 << 6)
#define THMOVLD (1 << 4) #define CS42L73_THMOVLD (1 << 4)
#define DIGMIXOVFL (1 << 3) #define CS42L73_DIGMIXOVFL (1 << 3)
#define IPBOVFL (1 << 1) #define CS42L73_IPBOVFL (1 << 1)
#define IPAOVFL (1 << 0) #define CS42L73_IPAOVFL (1 << 0)
/* Analog Softramp */ /* Analog Softramp */
#define ANLGOSFT (1 << 0) #define CS42L73_ANLGOSFT (1 << 0)
/* HP A/B Analog Mute */ /* HP A/B Analog Mute */
#define HPA_MUTE (1 << 7) #define CS42L73_HPA_MUTE (1 << 7)
/* LO A/B Analog Mute */ /* LO A/B Analog Mute */
#define LOA_MUTE (1 << 7) #define CS42L73_LOA_MUTE (1 << 7)
/* Digital Mute */ /* Digital Mute */
#define HLAD_MUTE (1 << 0) #define CS42L73_HLAD_MUTE (1 << 0)
#define HLBD_MUTE (1 << 1) #define CS42L73_HLBD_MUTE (1 << 1)
#define SPKD_MUTE (1 << 2) #define CS42L73_SPKD_MUTE (1 << 2)
#define ESLD_MUTE (1 << 3) #define CS42L73_ESLD_MUTE (1 << 3)
/* Misc defines for codec */ /* Misc defines for codec */
#define CS42L73_RESET_GPIO 143
#define CS42L73_DEVID 0x00042A73 #define CS42L73_DEVID 0x00042A73
#define CS42L73_MCLKX_MIN 5644800 #define CS42L73_MCLKX_MIN 5644800
#define CS42L73_MCLKX_MAX 38400000 #define CS42L73_MCLKX_MAX 38400000
......
This diff is collapsed.
This diff is collapsed.
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
...@@ -27,18 +28,26 @@ ...@@ -27,18 +28,26 @@
#include "max9850.h" #include "max9850.h"
struct max9850_priv { struct max9850_priv {
struct regmap *regmap;
unsigned int sysclk; unsigned int sysclk;
}; };
/* max9850 register cache */ /* max9850 register cache */
static const u8 max9850_reg[MAX9850_CACHEREGNUM] = { static const struct reg_default max9850_reg[] = {
0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 { 2, 0x0c },
{ 3, 0x00 },
{ 4, 0x00 },
{ 5, 0x00 },
{ 6, 0x00 },
{ 7, 0x00 },
{ 8, 0x00 },
{ 9, 0x00 },
{ 10, 0x00 },
}; };
/* these registers are not used at the moment but provided for the sake of /* these registers are not used at the moment but provided for the sake of
* completeness */ * completeness */
static int max9850_volatile_register(struct snd_soc_codec *codec, static bool max9850_volatile_register(struct device *dev, unsigned int reg)
unsigned int reg)
{ {
switch (reg) { switch (reg) {
case MAX9850_STATUSA: case MAX9850_STATUSA:
...@@ -49,6 +58,15 @@ static int max9850_volatile_register(struct snd_soc_codec *codec, ...@@ -49,6 +58,15 @@ static int max9850_volatile_register(struct snd_soc_codec *codec,
} }
} }
static const struct regmap_config max9850_regmap = {
.reg_bits = 8,
.val_bits = 8,
.max_register = MAX9850_DIGITAL_AUDIO,
.volatile_reg = max9850_volatile_register,
.cache_type = REGCACHE_RBTREE,
};
static const unsigned int max9850_tlv[] = { static const unsigned int max9850_tlv[] = {
TLV_DB_RANGE_HEAD(4), TLV_DB_RANGE_HEAD(4),
0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0), 0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0),
...@@ -225,6 +243,7 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -225,6 +243,7 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
static int max9850_set_bias_level(struct snd_soc_codec *codec, static int max9850_set_bias_level(struct snd_soc_codec *codec,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec);
int ret; int ret;
switch (level) { switch (level) {
...@@ -234,7 +253,7 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec, ...@@ -234,7 +253,7 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
ret = snd_soc_cache_sync(codec); ret = regcache_sync(max9850->regmap);
if (ret) { if (ret) {
dev_err(codec->dev, dev_err(codec->dev,
"Failed to sync cache: %d\n", ret); "Failed to sync cache: %d\n", ret);
...@@ -295,7 +314,7 @@ static int max9850_probe(struct snd_soc_codec *codec) ...@@ -295,7 +314,7 @@ static int max9850_probe(struct snd_soc_codec *codec)
{ {
int ret; int ret;
ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
return ret; return ret;
...@@ -316,10 +335,6 @@ static struct snd_soc_codec_driver soc_codec_dev_max9850 = { ...@@ -316,10 +335,6 @@ static struct snd_soc_codec_driver soc_codec_dev_max9850 = {
.suspend = max9850_suspend, .suspend = max9850_suspend,
.resume = max9850_resume, .resume = max9850_resume,
.set_bias_level = max9850_set_bias_level, .set_bias_level = max9850_set_bias_level,
.reg_cache_size = ARRAY_SIZE(max9850_reg),
.reg_word_size = sizeof(u8),
.reg_cache_default = max9850_reg,
.volatile_register = max9850_volatile_register,
.controls = max9850_controls, .controls = max9850_controls,
.num_controls = ARRAY_SIZE(max9850_controls), .num_controls = ARRAY_SIZE(max9850_controls),
...@@ -340,6 +355,10 @@ static int max9850_i2c_probe(struct i2c_client *i2c, ...@@ -340,6 +355,10 @@ static int max9850_i2c_probe(struct i2c_client *i2c,
if (max9850 == NULL) if (max9850 == NULL)
return -ENOMEM; return -ENOMEM;
max9850->regmap = devm_regmap_init_i2c(i2c, &max9850_regmap);
if (IS_ERR(max9850->regmap))
return PTR_ERR(max9850->regmap);
i2c_set_clientdata(i2c, max9850); i2c_set_clientdata(i2c, max9850);
ret = snd_soc_register_codec(&i2c->dev, ret = snd_soc_register_codec(&i2c->dev,
......
This diff is collapsed.
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <sound/pcm.h> #include <sound/pcm.h>
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <sound/initval.h> #include <sound/initval.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/tlv.h> #include <sound/tlv.h>
#include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include "pcm1792a.h" #include "pcm1792a.h"
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/acpi.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
...@@ -926,7 +927,7 @@ static int rt5640_set_dmic2_event(struct snd_soc_dapm_widget *w, ...@@ -926,7 +927,7 @@ static int rt5640_set_dmic2_event(struct snd_soc_dapm_widget *w,
return 0; return 0;
} }
void hp_amp_power_on(struct snd_soc_codec *codec) static void hp_amp_power_on(struct snd_soc_codec *codec)
{ {
struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
...@@ -1609,7 +1610,8 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream, ...@@ -1609,7 +1610,8 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream,
rt5640->lrck[dai->id] = params_rate(params); rt5640->lrck[dai->id] = params_rate(params);
pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]);
if (pre_div < 0) { if (pre_div < 0) {
dev_err(codec->dev, "Unsupported clock setting\n"); dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n",
rt5640->lrck[dai->id], dai->id);
return -EINVAL; return -EINVAL;
} }
frame_size = snd_soc_params_to_frame_size(params); frame_size = snd_soc_params_to_frame_size(params);
...@@ -1977,13 +1979,20 @@ static int rt5640_suspend(struct snd_soc_codec *codec) ...@@ -1977,13 +1979,20 @@ static int rt5640_suspend(struct snd_soc_codec *codec)
rt5640_reset(codec); rt5640_reset(codec);
regcache_cache_only(rt5640->regmap, true); regcache_cache_only(rt5640->regmap, true);
regcache_mark_dirty(rt5640->regmap); regcache_mark_dirty(rt5640->regmap);
if (gpio_is_valid(rt5640->pdata.ldo1_en))
gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 0);
return 0; return 0;
} }
static int rt5640_resume(struct snd_soc_codec *codec) static int rt5640_resume(struct snd_soc_codec *codec)
{ {
rt5640_set_bias_level(codec, SND_SOC_BIAS_STANDBY); struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec);
if (gpio_is_valid(rt5640->pdata.ldo1_en)) {
gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 1);
msleep(400);
}
return 0; return 0;
} }
...@@ -2080,6 +2089,14 @@ static const struct i2c_device_id rt5640_i2c_id[] = { ...@@ -2080,6 +2089,14 @@ static const struct i2c_device_id rt5640_i2c_id[] = {
}; };
MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id); MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id);
#ifdef CONFIG_ACPI
static struct acpi_device_id rt5640_acpi_match[] = {
{ "INT33CA", 0 },
{ },
};
MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match);
#endif
static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np) static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np)
{ {
rt5640->pdata.in1_diff = of_property_read_bool(np, rt5640->pdata.in1_diff = of_property_read_bool(np,
...@@ -2199,6 +2216,7 @@ static struct i2c_driver rt5640_i2c_driver = { ...@@ -2199,6 +2216,7 @@ static struct i2c_driver rt5640_i2c_driver = {
.driver = { .driver = {
.name = "rt5640", .name = "rt5640",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.acpi_match_table = ACPI_PTR(rt5640_acpi_match),
}, },
.probe = rt5640_i2c_probe, .probe = rt5640_i2c_probe,
.remove = rt5640_i2c_remove, .remove = rt5640_i2c_remove,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -9,10 +9,7 @@ ...@@ -9,10 +9,7 @@
#define _TLV320AIC16_H_ #define _TLV320AIC16_H_
/* AIC26 Registers */ /* AIC26 Registers */
#define AIC26_READ_COMMAND_WORD(addr) ((1 << 15) | (addr << 5)) #define AIC26_PAGE_ADDR(page, offset) ((page << 11) | offset << 5)
#define AIC26_WRITE_COMMAND_WORD(addr) ((0 << 15) | (addr << 5))
#define AIC26_PAGE_ADDR(page, offset) ((page << 6) | offset)
#define AIC26_NUM_REGS AIC26_PAGE_ADDR(3, 0)
/* Page 0: Auxiliary data registers */ /* Page 0: Auxiliary data registers */
#define AIC26_REG_BAT1 AIC26_PAGE_ADDR(0, 0x05) #define AIC26_REG_BAT1 AIC26_PAGE_ADDR(0, 0x05)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -13,6 +13,7 @@ obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o ...@@ -13,6 +13,7 @@ obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o
snd-soc-evm-objs := davinci-evm.o snd-soc-evm-objs := davinci-evm.o
obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o
obj-$(CONFIG_SND_AM33XX_SOC_EVM) += snd-soc-evm.o
obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o
obj-$(CONFIG_SND_DA830_SOC_EVM) += snd-soc-evm.o obj-$(CONFIG_SND_DA830_SOC_EVM) += snd-soc-evm.o
obj-$(CONFIG_SND_DA850_SOC_EVM) += snd-soc-evm.o obj-$(CONFIG_SND_DA850_SOC_EVM) += snd-soc-evm.o
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment