/*
* wm8985.c -- WM8985 ALSA SoC Audio driver
*
* Copyright 2010 Wolfson Microelectronics plc
*
* Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
*
* 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.
*
* TODO:
* o Add OUT3/OUT4 mixer controls.
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include "wm8985.h"
#define WM8985_NUM_SUPPLIES 4
static const char *wm8985_supply_names[WM8985_NUM_SUPPLIES] = {
"DCVDD",
"DBVDD",
"AVDD1",
"AVDD2"
};
static const u16 wm8985_reg_defs[] = {
0x0000, /* R0 - Software Reset */
0x0000, /* R1 - Power management 1 */
0x0000, /* R2 - Power management 2 */
0x0000, /* R3 - Power management 3 */
0x0050, /* R4 - Audio Interface */
0x0000, /* R5 - Companding control */
0x0140, /* R6 - Clock Gen control */
0x0000, /* R7 - Additional control */
0x0000, /* R8 - GPIO Control */
0x0000, /* R9 - Jack Detect Control 1 */
0x0000, /* R10 - DAC Control */
0x00FF, /* R11 - Left DAC digital Vol */
0x00FF, /* R12 - Right DAC digital vol */
0x0000, /* R13 - Jack Detect Control 2 */
0x0100, /* R14 - ADC Control */
0x00FF, /* R15 - Left ADC Digital Vol */
0x00FF, /* R16 - Right ADC Digital Vol */
0x0000, /* R17 */
0x012C, /* R18 - EQ1 - low shelf */
0x002C, /* R19 - EQ2 - peak 1 */
0x002C, /* R20 - EQ3 - peak 2 */
0x002C, /* R21 - EQ4 - peak 3 */
0x002C, /* R22 - EQ5 - high shelf */
0x0000, /* R23 */
0x0032, /* R24 - DAC Limiter 1 */
0x0000, /* R25 - DAC Limiter 2 */
0x0000, /* R26 */
0x0000, /* R27 - Notch Filter 1 */
0x0000, /* R28 - Notch Filter 2 */
0x0000, /* R29 - Notch Filter 3 */
0x0000, /* R30 - Notch Filter 4 */
0x0000, /* R31 */
0x0038, /* R32 - ALC control 1 */
0x000B, /* R33 - ALC control 2 */
0x0032, /* R34 - ALC control 3 */
0x0000, /* R35 - Noise Gate */
0x0008, /* R36 - PLL N */
0x000C, /* R37 - PLL K 1 */
0x0093, /* R38 - PLL K 2 */
0x00E9, /* R39 - PLL K 3 */
0x0000, /* R40 */
0x0000, /* R41 - 3D control */
0x0000, /* R42 - OUT4 to ADC */
0x0000, /* R43 - Beep control */
0x0033, /* R44 - Input ctrl */
0x0010, /* R45 - Left INP PGA gain ctrl */
0x0010, /* R46 - Right INP PGA gain ctrl */
0x0100, /* R47 - Left ADC BOOST ctrl */
0x0100, /* R48 - Right ADC BOOST ctrl */
0x0002, /* R49 - Output ctrl */
0x0001, /* R50 - Left mixer ctrl */
0x0001, /* R51 - Right mixer ctrl */
0x0039, /* R52 - LOUT1 (HP) volume ctrl */
0x0039, /* R53 - ROUT1 (HP) volume ctrl */
0x0039, /* R54 - LOUT2 (SPK) volume ctrl */
0x0039, /* R55 - ROUT2 (SPK) volume ctrl */
0x0001, /* R56 - OUT3 mixer ctrl */
0x0001, /* R57 - OUT4 (MONO) mix ctrl */
0x0001, /* R58 */
0x0000, /* R59 */
0x0004, /* R60 - OUTPUT ctrl */
0x0000, /* R61 - BIAS CTRL */
0x0180, /* R62 */
0x0000 /* R63 */
};
/*
* latch bit 8 of these registers to ensure instant
* volume updates
*/
static const int volume_update_regs[] = {
WM8985_LEFT_DAC_DIGITAL_VOL,
WM8985_RIGHT_DAC_DIGITAL_VOL,
WM8985_LEFT_ADC_DIGITAL_VOL,
WM8985_RIGHT_ADC_DIGITAL_VOL,
WM8985_LOUT2_SPK_VOLUME_CTRL,
WM8985_ROUT2_SPK_VOLUME_CTRL,
WM8985_LOUT1_HP_VOLUME_CTRL,
WM8985_ROUT1_HP_VOLUME_CTRL,
WM8985_LEFT_INP_PGA_GAIN_CTRL,
WM8985_RIGHT_INP_PGA_GAIN_CTRL
};
struct wm8985_priv {
enum snd_soc_control_type control_type;
struct regulator_bulk_data supplies[WM8985_NUM_SUPPLIES];
unsigned int sysclk;
unsigned int bclk;
};
static const struct {
int div;
int ratio;
} fs_ratios[] = {
{