xref: /kernel/linux/linux-6.6/include/sound/wm8904.h (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Platform data for WM8904
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright 2009 Wolfson Microelectronics PLC.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef __MFD_WM8994_PDATA_H__
1162306a36Sopenharmony_ci#define __MFD_WM8994_PDATA_H__
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* Used to enable configuration of a GPIO to all zeros */
1462306a36Sopenharmony_ci#define WM8904_GPIO_NO_CONFIG 0x8000
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/*
1762306a36Sopenharmony_ci * R6 (0x06) - Mic Bias Control 0
1862306a36Sopenharmony_ci */
1962306a36Sopenharmony_ci#define WM8904_MICDET_THR_MASK                  0x0070  /* MICDET_THR - [6:4] */
2062306a36Sopenharmony_ci#define WM8904_MICDET_THR_SHIFT                      4  /* MICDET_THR - [6:4] */
2162306a36Sopenharmony_ci#define WM8904_MICDET_THR_WIDTH                      3  /* MICDET_THR - [6:4] */
2262306a36Sopenharmony_ci#define WM8904_MICSHORT_THR_MASK                0x000C  /* MICSHORT_THR - [3:2] */
2362306a36Sopenharmony_ci#define WM8904_MICSHORT_THR_SHIFT                    2  /* MICSHORT_THR - [3:2] */
2462306a36Sopenharmony_ci#define WM8904_MICSHORT_THR_WIDTH                    2  /* MICSHORT_THR - [3:2] */
2562306a36Sopenharmony_ci#define WM8904_MICDET_ENA                       0x0002  /* MICDET_ENA */
2662306a36Sopenharmony_ci#define WM8904_MICDET_ENA_MASK                  0x0002  /* MICDET_ENA */
2762306a36Sopenharmony_ci#define WM8904_MICDET_ENA_SHIFT                      1  /* MICDET_ENA */
2862306a36Sopenharmony_ci#define WM8904_MICDET_ENA_WIDTH                      1  /* MICDET_ENA */
2962306a36Sopenharmony_ci#define WM8904_MICBIAS_ENA                      0x0001  /* MICBIAS_ENA */
3062306a36Sopenharmony_ci#define WM8904_MICBIAS_ENA_MASK                 0x0001  /* MICBIAS_ENA */
3162306a36Sopenharmony_ci#define WM8904_MICBIAS_ENA_SHIFT                     0  /* MICBIAS_ENA */
3262306a36Sopenharmony_ci#define WM8904_MICBIAS_ENA_WIDTH                     1  /* MICBIAS_ENA */
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/*
3562306a36Sopenharmony_ci * R7 (0x07) - Mic Bias Control 1
3662306a36Sopenharmony_ci */
3762306a36Sopenharmony_ci#define WM8904_MIC_DET_FILTER_ENA               0x8000  /* MIC_DET_FILTER_ENA */
3862306a36Sopenharmony_ci#define WM8904_MIC_DET_FILTER_ENA_MASK          0x8000  /* MIC_DET_FILTER_ENA */
3962306a36Sopenharmony_ci#define WM8904_MIC_DET_FILTER_ENA_SHIFT             15  /* MIC_DET_FILTER_ENA */
4062306a36Sopenharmony_ci#define WM8904_MIC_DET_FILTER_ENA_WIDTH              1  /* MIC_DET_FILTER_ENA */
4162306a36Sopenharmony_ci#define WM8904_MIC_SHORT_FILTER_ENA             0x4000  /* MIC_SHORT_FILTER_ENA */
4262306a36Sopenharmony_ci#define WM8904_MIC_SHORT_FILTER_ENA_MASK        0x4000  /* MIC_SHORT_FILTER_ENA */
4362306a36Sopenharmony_ci#define WM8904_MIC_SHORT_FILTER_ENA_SHIFT           14  /* MIC_SHORT_FILTER_ENA */
4462306a36Sopenharmony_ci#define WM8904_MIC_SHORT_FILTER_ENA_WIDTH            1  /* MIC_SHORT_FILTER_ENA */
4562306a36Sopenharmony_ci#define WM8904_MICBIAS_SEL_MASK                 0x0007  /* MICBIAS_SEL - [2:0] */
4662306a36Sopenharmony_ci#define WM8904_MICBIAS_SEL_SHIFT                     0  /* MICBIAS_SEL - [2:0] */
4762306a36Sopenharmony_ci#define WM8904_MICBIAS_SEL_WIDTH                     3  /* MICBIAS_SEL - [2:0] */
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci/*
5162306a36Sopenharmony_ci * R121 (0x79) - GPIO Control 1
5262306a36Sopenharmony_ci */
5362306a36Sopenharmony_ci#define WM8904_GPIO1_PU                         0x0020  /* GPIO1_PU */
5462306a36Sopenharmony_ci#define WM8904_GPIO1_PU_MASK                    0x0020  /* GPIO1_PU */
5562306a36Sopenharmony_ci#define WM8904_GPIO1_PU_SHIFT                        5  /* GPIO1_PU */
5662306a36Sopenharmony_ci#define WM8904_GPIO1_PU_WIDTH                        1  /* GPIO1_PU */
5762306a36Sopenharmony_ci#define WM8904_GPIO1_PD                         0x0010  /* GPIO1_PD */
5862306a36Sopenharmony_ci#define WM8904_GPIO1_PD_MASK                    0x0010  /* GPIO1_PD */
5962306a36Sopenharmony_ci#define WM8904_GPIO1_PD_SHIFT                        4  /* GPIO1_PD */
6062306a36Sopenharmony_ci#define WM8904_GPIO1_PD_WIDTH                        1  /* GPIO1_PD */
6162306a36Sopenharmony_ci#define WM8904_GPIO1_SEL_MASK                   0x000F  /* GPIO1_SEL - [3:0] */
6262306a36Sopenharmony_ci#define WM8904_GPIO1_SEL_SHIFT                       0  /* GPIO1_SEL - [3:0] */
6362306a36Sopenharmony_ci#define WM8904_GPIO1_SEL_WIDTH                       4  /* GPIO1_SEL - [3:0] */
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci/*
6662306a36Sopenharmony_ci * R122 (0x7A) - GPIO Control 2
6762306a36Sopenharmony_ci */
6862306a36Sopenharmony_ci#define WM8904_GPIO2_PU                         0x0020  /* GPIO2_PU */
6962306a36Sopenharmony_ci#define WM8904_GPIO2_PU_MASK                    0x0020  /* GPIO2_PU */
7062306a36Sopenharmony_ci#define WM8904_GPIO2_PU_SHIFT                        5  /* GPIO2_PU */
7162306a36Sopenharmony_ci#define WM8904_GPIO2_PU_WIDTH                        1  /* GPIO2_PU */
7262306a36Sopenharmony_ci#define WM8904_GPIO2_PD                         0x0010  /* GPIO2_PD */
7362306a36Sopenharmony_ci#define WM8904_GPIO2_PD_MASK                    0x0010  /* GPIO2_PD */
7462306a36Sopenharmony_ci#define WM8904_GPIO2_PD_SHIFT                        4  /* GPIO2_PD */
7562306a36Sopenharmony_ci#define WM8904_GPIO2_PD_WIDTH                        1  /* GPIO2_PD */
7662306a36Sopenharmony_ci#define WM8904_GPIO2_SEL_MASK                   0x000F  /* GPIO2_SEL - [3:0] */
7762306a36Sopenharmony_ci#define WM8904_GPIO2_SEL_SHIFT                       0  /* GPIO2_SEL - [3:0] */
7862306a36Sopenharmony_ci#define WM8904_GPIO2_SEL_WIDTH                       4  /* GPIO2_SEL - [3:0] */
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/*
8162306a36Sopenharmony_ci * R123 (0x7B) - GPIO Control 3
8262306a36Sopenharmony_ci */
8362306a36Sopenharmony_ci#define WM8904_GPIO3_PU                         0x0020  /* GPIO3_PU */
8462306a36Sopenharmony_ci#define WM8904_GPIO3_PU_MASK                    0x0020  /* GPIO3_PU */
8562306a36Sopenharmony_ci#define WM8904_GPIO3_PU_SHIFT                        5  /* GPIO3_PU */
8662306a36Sopenharmony_ci#define WM8904_GPIO3_PU_WIDTH                        1  /* GPIO3_PU */
8762306a36Sopenharmony_ci#define WM8904_GPIO3_PD                         0x0010  /* GPIO3_PD */
8862306a36Sopenharmony_ci#define WM8904_GPIO3_PD_MASK                    0x0010  /* GPIO3_PD */
8962306a36Sopenharmony_ci#define WM8904_GPIO3_PD_SHIFT                        4  /* GPIO3_PD */
9062306a36Sopenharmony_ci#define WM8904_GPIO3_PD_WIDTH                        1  /* GPIO3_PD */
9162306a36Sopenharmony_ci#define WM8904_GPIO3_SEL_MASK                   0x000F  /* GPIO3_SEL - [3:0] */
9262306a36Sopenharmony_ci#define WM8904_GPIO3_SEL_SHIFT                       0  /* GPIO3_SEL - [3:0] */
9362306a36Sopenharmony_ci#define WM8904_GPIO3_SEL_WIDTH                       4  /* GPIO3_SEL - [3:0] */
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci/*
9662306a36Sopenharmony_ci * R124 (0x7C) - GPIO Control 4
9762306a36Sopenharmony_ci */
9862306a36Sopenharmony_ci#define WM8904_GPI7_ENA                         0x0200  /* GPI7_ENA */
9962306a36Sopenharmony_ci#define WM8904_GPI7_ENA_MASK                    0x0200  /* GPI7_ENA */
10062306a36Sopenharmony_ci#define WM8904_GPI7_ENA_SHIFT                        9  /* GPI7_ENA */
10162306a36Sopenharmony_ci#define WM8904_GPI7_ENA_WIDTH                        1  /* GPI7_ENA */
10262306a36Sopenharmony_ci#define WM8904_GPI8_ENA                         0x0100  /* GPI8_ENA */
10362306a36Sopenharmony_ci#define WM8904_GPI8_ENA_MASK                    0x0100  /* GPI8_ENA */
10462306a36Sopenharmony_ci#define WM8904_GPI8_ENA_SHIFT                        8  /* GPI8_ENA */
10562306a36Sopenharmony_ci#define WM8904_GPI8_ENA_WIDTH                        1  /* GPI8_ENA */
10662306a36Sopenharmony_ci#define WM8904_GPIO_BCLK_MODE_ENA               0x0080  /* GPIO_BCLK_MODE_ENA */
10762306a36Sopenharmony_ci#define WM8904_GPIO_BCLK_MODE_ENA_MASK          0x0080  /* GPIO_BCLK_MODE_ENA */
10862306a36Sopenharmony_ci#define WM8904_GPIO_BCLK_MODE_ENA_SHIFT              7  /* GPIO_BCLK_MODE_ENA */
10962306a36Sopenharmony_ci#define WM8904_GPIO_BCLK_MODE_ENA_WIDTH              1  /* GPIO_BCLK_MODE_ENA */
11062306a36Sopenharmony_ci#define WM8904_GPIO_BCLK_SEL_MASK               0x000F  /* GPIO_BCLK_SEL - [3:0] */
11162306a36Sopenharmony_ci#define WM8904_GPIO_BCLK_SEL_SHIFT                   0  /* GPIO_BCLK_SEL - [3:0] */
11262306a36Sopenharmony_ci#define WM8904_GPIO_BCLK_SEL_WIDTH                   4  /* GPIO_BCLK_SEL - [3:0] */
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#define WM8904_MIC_REGS  2
11562306a36Sopenharmony_ci#define WM8904_GPIO_REGS 4
11662306a36Sopenharmony_ci#define WM8904_DRC_REGS  4
11762306a36Sopenharmony_ci#define WM8904_EQ_REGS   24
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci/**
12062306a36Sopenharmony_ci * DRC configurations are specified with a label and a set of register
12162306a36Sopenharmony_ci * values to write (the enable bits will be ignored).  At runtime an
12262306a36Sopenharmony_ci * enumerated control will be presented for each DRC block allowing
12362306a36Sopenharmony_ci * the user to choose the configuration to use.
12462306a36Sopenharmony_ci *
12562306a36Sopenharmony_ci * Configurations may be generated by hand or by using the DRC control
12662306a36Sopenharmony_ci * panel provided by the WISCE - see  http://www.wolfsonmicro.com/wisce/
12762306a36Sopenharmony_ci * for details.
12862306a36Sopenharmony_ci */
12962306a36Sopenharmony_cistruct wm8904_drc_cfg {
13062306a36Sopenharmony_ci	const char *name;
13162306a36Sopenharmony_ci	u16 regs[WM8904_DRC_REGS];
13262306a36Sopenharmony_ci};
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci/**
13562306a36Sopenharmony_ci * ReTune Mobile configurations are specified with a label, sample
13662306a36Sopenharmony_ci * rate and set of values to write (the enable bits will be ignored).
13762306a36Sopenharmony_ci *
13862306a36Sopenharmony_ci * Configurations are expected to be generated using the ReTune Mobile
13962306a36Sopenharmony_ci * control panel in WISCE - see http://www.wolfsonmicro.com/wisce/
14062306a36Sopenharmony_ci */
14162306a36Sopenharmony_cistruct wm8904_retune_mobile_cfg {
14262306a36Sopenharmony_ci	const char *name;
14362306a36Sopenharmony_ci	unsigned int rate;
14462306a36Sopenharmony_ci	u16 regs[WM8904_EQ_REGS];
14562306a36Sopenharmony_ci};
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_cistruct wm8904_pdata {
14862306a36Sopenharmony_ci	int num_drc_cfgs;
14962306a36Sopenharmony_ci	struct wm8904_drc_cfg *drc_cfgs;
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci	int num_retune_mobile_cfgs;
15262306a36Sopenharmony_ci	struct wm8904_retune_mobile_cfg *retune_mobile_cfgs;
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci	u32 gpio_cfg[WM8904_GPIO_REGS];
15562306a36Sopenharmony_ci	u32 mic_cfg[WM8904_MIC_REGS];
15662306a36Sopenharmony_ci};
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#endif
159