<commit_before>/*
 * wm5110.c  --  WM5110 ALSA SoC Audio driver
 *
 * Copyright 2012 Wolfson Microelectronics plc
 *
 * Author: <NAME> <<EMAIL>>
 *
 * 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.
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/jack.h>
#include <sound/initval.h>
#include <sound/tlv.h>

#include <linux/mfd/arizona/core.h>
#include <linux/mfd/arizona/registers.h>

#include "arizona.h"
#include "wm_adsp.h"
#include "wm5110.h"

#define WM5110_NUM_ADSP 4

struct wm5110_priv {
	struct arizona_priv core;
	struct arizona_fll fll[2];
};

static const struct wm_adsp_region wm5110_dsp1_regions[] = {
	{ .type = WMFW_ADSP2_PM, .base = 0x100000 },
	{ .type = WMFW_ADSP2_ZM, .base = 0x180000 },
	{ .type = WMFW_ADSP2_XM, .base = 0x190000 },
	{ .type = WMFW_ADSP2_YM, .base = 0x1a8000 },
};

static const struct wm_adsp_region wm5110_dsp2_regions[] = {
	{ .type = WMFW_ADSP2_PM, .base = 0x200000 },
	{ .type = WMFW_ADSP2_ZM, .base = 0x280000 },
	{ .type = WMFW_ADSP2_XM, .base = 0x290000 },
	{ .type = WMFW_ADSP2_YM, .base = 0x2a8000 },
};

static const struct wm_adsp_region wm5110_dsp3_regions[] = {
	{ .type = WMFW_ADSP2_PM, .base = 0x300000 },
	{ .type = WMFW_ADSP2_ZM, .base = 0x380000 },
	{ .type = WMFW_ADSP2_XM, .base = 0x390000 },
	{ .type = WMFW_ADSP2_YM, .base = 0x3a8000 },
};

static const struct wm_adsp_region wm5110_dsp4_regions[] = {
	{ .type = WMFW_ADSP2_PM, .base = 0x400000 },
	{ .type = WMFW_ADSP2_ZM, .base = 0x480000 },
	{ .type = WMFW_ADSP2_XM, .base = 0x490000 },
	{ .type = WMFW_ADSP2_YM, .base = 0x4a8000 },
};

static const struct wm_adsp_region *wm5110_dsp_regions[] = {
	wm5110_dsp1_regions,
	wm5110_dsp2_regions,
	wm5110_dsp3_regions,
	wm5110_dsp4_regions,
};

static const struct reg_default wm5110_sysclk_revd_patch[] = {
	{ 0x3093, 0x1001 },
	{ 0x30E3, 0x1301 },
	{ 0x3133, 0x1201 },
	{ 0x3183, 0x1501 },
	{ 0x31D3, 0x1401 },
	{ 0x0049, 0x01ea },
	{ 0x004a, 0x01f2 },
	{ 0x0057, 0x01e7 },
	{ 0x0058, 0x01fb },
	{ 0x33ce, 0xc4f5 },
	{ 0x33cf, 0x1361 },
	{ 0x33d0, 0x0402 },
	{ 0x33d1, 0x4700 },
	{ 0x33d2, 0x026d },
	{ 0x33d3, 0xff00 },
	{ 0x33d4, 0x026d },
	{ 0x33d5, 0x0101 },
	{ 0x33d6, 0xc4f5 },
	{ 0x33d7, 0x0361 },
	{ 0x33d8, 0x0402 },
	{ 0x33d9, 0x6701 },
	{ 0x33da, 0xc4f5 },
	{ 0x33db, 0x136f },
	{ 0x33dc, 0xc4f5 },
	{ 0x33dd, 0x134f },
	{ 0x33de, 0xc4f5 },
	{ 0x33df, 0x131f },
	{ 0x33e0, 0x026d },
	{ 0x33e1, 0x4f01 },
	{ 0x33e2, 0x026d },
	{ 0x33e3, 0xf100 },
	{ 0x33e4, 0x026d },
	{ 0x33e5, 0x0001 },
	{ 0x33e6, 0xc4f5 },
	{ 0x33e7, 0x0361 },
	{ 0x33e8, 0x0402 },
	{ 0x33e9, 0x6601 },
	{ 0x33ea, 0xc4f5 },
	{ 0x33eb, 0x136f },
	{ 0x33ec, 0xc4f5 },
	{ 0x33ed, 0x134f },
	{ 0x33ee, 0xc4f5 },
	{ 0x33ef, 0x131f },
	{ 0x33f0, 0x026d },
	{ 0x33f1, 0x4e01 },
	{ 0x33f2, 0x026d },
	{ 0x33f3, 0xf000 },
	{ 0x33f6, 0xc4f5 },
	{ 0x33f7, 0x1361 },
	{ 0x33f8, 0x0402 },
	{ 0x33f9, 0x4600 },
	{ 0x33fa, 0x026d },
	{ 0x33fb, 0xfe00 },
};

static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w,
			    struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_codec *codec = w->codec;
	struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
	struct regmap *regmap = arizona->regmap;
	const struct reg_default *patch = NULL;
	int i, patch_size;

	switch (arizona->rev) {
	case 3:
		patch = wm5110_sysclk_revd_patch;
		patch_size = ARRAY_SIZE(wm5110_sysclk_revd_patch);
		break;
	default:
		return 0;
	}

	switch (event) {
	case SND_SOC_DAPM_POST_PMU:
		if (patch)
			for (i = 0; i < patch_size; i++)
				regmap_write_async(regmap, patch[i].reg,
						   patch[i].def);<commit_msg>ASoC: wm5110: Replace w->codec snd_soc_dapm_to_codec(w->dapm)<commit_after>/*
 * wm5110.c  --  WM5110 ALSA SoC Audio driver
 *
 * Copyright 2012 Wolfson Microelectronics plc
 *
 * Author: <NAME> <<EMAIL>>
 *
 * 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.
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/jack.h>
#include <sound/initval.h>
#include <sound/tlv.h>

#include <linux/mfd/arizona/core.h>
#include <linux/mfd/arizona/registers.h>

#include "arizona.h"
#include "wm_adsp.h"
#include "wm5110.h"

#define WM5110_NUM_ADSP 4

struct wm5110_priv {
	struct arizona_priv core;
	struct arizona_fll fll[2];
};

static const struct wm_adsp_region wm5110_dsp1_regions[] = {
	{ .type = WMFW_ADSP2_PM, .base = 0x100000 },
	{ .type = WMFW_ADSP2_ZM, .base = 0x180000 },
	{ .type = WMFW_ADSP2_XM, .base = 0x190000 },
	{ .type = WMFW_ADSP2_YM, .base = 0x1a8000 },
};

static const struct wm_adsp_region wm5110_dsp2_regions[] = {
	{ .type = WMFW_ADSP2_PM, .base = 0x200000 },
	{ .type = WMFW_ADSP2_ZM, .base = 0x280000 },
	{ .type = WMFW_ADSP2_XM, .base = 0x290000 },
	{ .type = WMFW_ADSP2_YM, .base = 0x2a8000 },
};

static const struct wm_adsp_region wm5110_dsp3_regions[] = {
	{ .type = WMFW_ADSP2_PM, .base = 0x300000 },
	{ .type = WMFW_ADSP2_ZM, .base = 0x380000 },
	{ .type = WMFW_ADSP2_XM, .base = 0x390000 },
	{ .type = WMFW_ADSP2_YM, .base = 0x3a8000 },
};

static const struct wm_adsp_region wm5110_dsp4_regions[] = {
	{ .type = WMFW_ADSP2_PM, .base = 0x400000 },
	{ .type = WMFW_ADSP2_ZM, .base = 0x480000 },
	{ .type = WMFW_ADSP2_XM, .base = 0x490000 },
	{ .type = WMFW_ADSP2_YM, .base = 0x4a8000 },
};

static const struct wm_adsp_region *wm5110_dsp_regions[] = {
	wm5110_dsp1_regions,
	wm5110_dsp2_regions,
	wm5110_dsp3_regions,
	wm5110_dsp4_regions,
};

static const struct reg_default wm5110_sysclk_revd_patch[] = {
	{ 0x3093, 0x1001 },
	{ 0x30E3, 0x1301 },
	{ 0x3133, 0x1201 },
	{ 0x3183, 0x1501 },
	{ 0x31D3, 0x1401 },
	{ 0x0049, 0x01ea },
	{ 0x004a, 0x01f2 },
	{ 0x0057, 0x01e7 },
	{ 0x0058, 0x01fb },
	{ 0x33ce, 0xc4f5 },
	{ 0x33cf, 0x1361 },
	{ 0x33d0, 0x0402 },
	{ 0x33d1, 0x4700 },
	{ 0x33d2, 0x026d },
	{ 0x33d3, 0xff00 },
	{ 0x33d4, 0x026d },
	{ 0x33d5, 0x0101 },
	{ 0x33d6, 0xc4f5 },
	{ 0x33d7, 0x0361 },
	{ 0x33d8, 0x0402 },
	{ 0x33d9, 0x6701 },
	{ 0x33da, 0xc4f5 },
	{ 0x33db, 0x136f },
	{ 0x33dc, 0xc4f5 },
	{ 0x33dd, 0x134f },
	{ 0x33de, 0xc4f5 },
	{ 0x33df, 0x131f },
	{ 0x33e0, 0x026d },
	{ 0x33e1, 0x4f01 },
	{ 0x33e2, 0x026d },
	{ 0x33e3, 0xf100 },
	{ 0x33e4, 0x026d },
	{ 0x33e5, 0x0001 },
	{ 0x33e6, 0xc4f5 },
	{ 0x33e7, 0x0361 },
	{ 0x33e8, 0x0402 },
	{ 0x33e9, 0x6601 },
	{ 0x33ea, 0xc4f5 },
	{ 0x33eb, 0x136f },
	{ 0x33ec, 0xc4f5 },
	{ 0x33ed, 0x134f },
	{ 0x33ee, 0xc4f5 },
	{ 0x33ef, 0x131f },
	{ 0x33f0, 0x026d },
	{ 0x33f1, 0x4e01 },
	{ 0x33f2, 0x026d },
	{ 0x33f3, 0xf000 },
	{ 0x33f6, 0xc4f5 },
	{ 0x33f7, 0x1361 },
	{ 0x33f8, 0x0402 },
	{ 0x33f9, 0x4600 },
	{ 0x33fa, 0x026d },
	{ 0x33fb, 0xfe00 },
};

static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w,
			    struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
	struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
	struct regmap *regmap = arizona->regmap;
	const struct reg_default *patch = NULL;
	int i, patch_size;

	switch (arizona->rev) {
	case 3:
		patch = wm5110_sysclk_revd_patch;
		patch_size = ARRAY_SIZE(wm5110_sysclk_revd_patch);
		break;
	default:
		return 0;
	}

	switch (event) {
	case SND_SOC_DAPM_POST_PMU:
		if (patch)
			for (i = 0; i < patch_size; i++)
				regmap_write_async(regmap, patch[i].reg,
						   patch[i].def);
{'fraction_non_alphanumeric': 0.14944834503510532, 'fraction_numerical': 0.15922768304914744, 'mean_word_length': 3.9577377252952144, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5799607', 'n_tokens_mistral': 4740, 'n_tokens_neox': 3937, 'n_words': 717}