Commit a18d5151 authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branch 'asoc/topic/arizona' into asoc-next

parents 0680fa6c b6ed61cf
Loading
Loading
Loading
Loading
+52 −55
Original line number Diff line number Diff line
@@ -100,6 +100,55 @@ static const char *arizona_cable[] = {
	NULL,
};

static void arizona_extcon_do_magic(struct arizona_extcon_info *info,
				    unsigned int magic)
{
	struct arizona *arizona = info->arizona;
	int ret;

	mutex_lock(&arizona->dapm->card->dapm_mutex);

	arizona->hpdet_magic = magic;

	/* Keep the HP output stages disabled while doing the magic */
	if (magic) {
		ret = regmap_update_bits(arizona->regmap,
					 ARIZONA_OUTPUT_ENABLES_1,
					 ARIZONA_OUT1L_ENA |
					 ARIZONA_OUT1R_ENA, 0);
		if (ret != 0)
			dev_warn(arizona->dev,
				"Failed to disable headphone outputs: %d\n",
				 ret);
	}

	ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000,
				 magic);
	if (ret != 0)
		dev_warn(arizona->dev, "Failed to do magic: %d\n",
				 ret);

	ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000,
				 magic);
	if (ret != 0)
		dev_warn(arizona->dev, "Failed to do magic: %d\n",
			 ret);

	/* Restore the desired state while not doing the magic */
	if (!magic) {
		ret = regmap_update_bits(arizona->regmap,
					 ARIZONA_OUTPUT_ENABLES_1,
					 ARIZONA_OUT1L_ENA |
					 ARIZONA_OUT1R_ENA, arizona->hp_ena);
		if (ret != 0)
			dev_warn(arizona->dev,
				 "Failed to restore headphone outputs: %d\n",
				 ret);
	}

	mutex_unlock(&arizona->dapm->card->dapm_mutex);
}

static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
{
	struct arizona *arizona = info->arizona;
@@ -484,7 +533,6 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
	struct arizona *arizona = info->arizona;
	int id_gpio = arizona->pdata.hpdet_id_gpio;
	int report = ARIZONA_CABLE_HEADPHONE;
	unsigned int val;
	int ret, reading;

	mutex_lock(&info->lock);
@@ -539,28 +587,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
		dev_err(arizona->dev, "Failed to report HP/line: %d\n",
			ret);

	mutex_lock(&arizona->dapm->card->dapm_mutex);

	ret = regmap_read(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, &val);
	if (ret != 0) {
		dev_err(arizona->dev, "Failed to read output enables: %d\n",
			ret);
		val = 0;
	}

	if (!(val & (ARIZONA_OUT1L_ENA | ARIZONA_OUT1R_ENA))) {
		ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0);
		if (ret != 0)
			dev_warn(arizona->dev, "Failed to undo magic: %d\n",
				 ret);

		ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0);
		if (ret != 0)
			dev_warn(arizona->dev, "Failed to undo magic: %d\n",
				 ret);
	}

	mutex_unlock(&arizona->dapm->card->dapm_mutex);
	arizona_extcon_do_magic(info, 0);

done:
	if (id_gpio)
@@ -606,13 +633,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
	if (info->mic)
		arizona_stop_mic(info);

	ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0x4000);
	if (ret != 0)
		dev_warn(arizona->dev, "Failed to do magic: %d\n", ret);

	ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0x4000);
	if (ret != 0)
		dev_warn(arizona->dev, "Failed to do magic: %d\n", ret);
	arizona_extcon_do_magic(info, 0x4000);

	ret = regmap_update_bits(arizona->regmap,
				 ARIZONA_ACCESSORY_DETECT_MODE_1,
@@ -653,7 +674,6 @@ err:
static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
{
	struct arizona *arizona = info->arizona;
	unsigned int val;
	int ret;

	dev_dbg(arizona->dev, "Starting identification via HPDET\n");
@@ -665,30 +685,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)

	arizona_extcon_pulse_micbias(info);

	mutex_lock(&arizona->dapm->card->dapm_mutex);

	ret = regmap_read(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, &val);
	if (ret != 0) {
		dev_err(arizona->dev, "Failed to read output enables: %d\n",
			ret);
		val = 0;
	}

	if (!(val & (ARIZONA_OUT1L_ENA | ARIZONA_OUT1R_ENA))) {
		ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000,
					 0x4000);
		if (ret != 0)
			dev_warn(arizona->dev, "Failed to do magic: %d\n",
				 ret);

		ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000,
					 0x4000);
		if (ret != 0)
			dev_warn(arizona->dev, "Failed to do magic: %d\n",
				 ret);
	}

	mutex_unlock(&arizona->dapm->card->dapm_mutex);
	arizona_extcon_do_magic(info, 0x4000);

	ret = regmap_update_bits(arizona->regmap,
				 ARIZONA_ACCESSORY_DETECT_MODE_1,
+10 −0
Original line number Diff line number Diff line
@@ -290,12 +290,14 @@ static const struct reg_default wm5102_reg_default[] = {
	{ 0x00000176, 0x0000 },   /* R374   - FLL1 Control 6 */ 
	{ 0x00000177, 0x0181 },   /* R375   - FLL1 Loop Filter Test 1 */ 
	{ 0x00000178, 0x0000 },   /* R376   - FLL1 NCO Test 0 */
	{ 0x00000179, 0x0000 },   /* R377   - FLL1 Control 7 */
	{ 0x00000181, 0x0000 },   /* R385   - FLL1 Synchroniser 1 */ 
	{ 0x00000182, 0x0000 },   /* R386   - FLL1 Synchroniser 2 */ 
	{ 0x00000183, 0x0000 },   /* R387   - FLL1 Synchroniser 3 */ 
	{ 0x00000184, 0x0000 },   /* R388   - FLL1 Synchroniser 4 */ 
	{ 0x00000185, 0x0000 },   /* R389   - FLL1 Synchroniser 5 */ 
	{ 0x00000186, 0x0000 },   /* R390   - FLL1 Synchroniser 6 */ 
	{ 0x00000187, 0x0001 },   /* R391   - FLL1 Synchroniser 7 */
	{ 0x00000189, 0x0000 },   /* R393   - FLL1 Spread Spectrum */ 
	{ 0x0000018A, 0x0004 },   /* R394   - FLL1 GPIO Clock */ 
	{ 0x00000191, 0x0000 },   /* R401   - FLL2 Control 1 */ 
@@ -306,12 +308,14 @@ static const struct reg_default wm5102_reg_default[] = {
	{ 0x00000196, 0x0000 },   /* R406   - FLL2 Control 6 */ 
	{ 0x00000197, 0x0000 },   /* R407   - FLL2 Loop Filter Test 1 */ 
	{ 0x00000198, 0x0000 },   /* R408   - FLL2 NCO Test 0 */
	{ 0x00000199, 0x0000 },   /* R409   - FLL2 Control 7 */
	{ 0x000001A1, 0x0000 },   /* R417   - FLL2 Synchroniser 1 */ 
	{ 0x000001A2, 0x0000 },   /* R418   - FLL2 Synchroniser 2 */ 
	{ 0x000001A3, 0x0000 },   /* R419   - FLL2 Synchroniser 3 */ 
	{ 0x000001A4, 0x0000 },   /* R420   - FLL2 Synchroniser 4 */ 
	{ 0x000001A5, 0x0000 },   /* R421   - FLL2 Synchroniser 5 */ 
	{ 0x000001A6, 0x0000 },   /* R422   - FLL2 Synchroniser 6 */ 
	{ 0x000001A7, 0x0001 },   /* R423   - FLL2 Synchroniser 7 */
	{ 0x000001A9, 0x0000 },   /* R425   - FLL2 Spread Spectrum */ 
	{ 0x000001AA, 0x0004 },   /* R426   - FLL2 GPIO Clock */ 
	{ 0x00000200, 0x0006 },   /* R512   - Mic Charge Pump 1 */ 
@@ -1051,12 +1055,14 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg)
	case ARIZONA_FLL1_CONTROL_6:
	case ARIZONA_FLL1_LOOP_FILTER_TEST_1:
	case ARIZONA_FLL1_NCO_TEST_0:
	case ARIZONA_FLL1_CONTROL_7:
	case ARIZONA_FLL1_SYNCHRONISER_1:
	case ARIZONA_FLL1_SYNCHRONISER_2:
	case ARIZONA_FLL1_SYNCHRONISER_3:
	case ARIZONA_FLL1_SYNCHRONISER_4:
	case ARIZONA_FLL1_SYNCHRONISER_5:
	case ARIZONA_FLL1_SYNCHRONISER_6:
	case ARIZONA_FLL1_SYNCHRONISER_7:
	case ARIZONA_FLL1_SPREAD_SPECTRUM:
	case ARIZONA_FLL1_GPIO_CLOCK:
	case ARIZONA_FLL2_CONTROL_1:
@@ -1067,12 +1073,14 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg)
	case ARIZONA_FLL2_CONTROL_6:
	case ARIZONA_FLL2_LOOP_FILTER_TEST_1:
	case ARIZONA_FLL2_NCO_TEST_0:
	case ARIZONA_FLL2_CONTROL_7:
	case ARIZONA_FLL2_SYNCHRONISER_1:
	case ARIZONA_FLL2_SYNCHRONISER_2:
	case ARIZONA_FLL2_SYNCHRONISER_3:
	case ARIZONA_FLL2_SYNCHRONISER_4:
	case ARIZONA_FLL2_SYNCHRONISER_5:
	case ARIZONA_FLL2_SYNCHRONISER_6:
	case ARIZONA_FLL2_SYNCHRONISER_7:
	case ARIZONA_FLL2_SPREAD_SPECTRUM:
	case ARIZONA_FLL2_GPIO_CLOCK:
	case ARIZONA_MIC_CHARGE_PUMP_1:
@@ -1161,6 +1169,8 @@ static bool wm5102_readable_register(struct device *dev, unsigned int reg)
	case ARIZONA_NOISE_GATE_CONTROL:
	case ARIZONA_PDM_SPK1_CTRL_1:
	case ARIZONA_PDM_SPK1_CTRL_2:
	case ARIZONA_SPK_CTRL_2:
	case ARIZONA_SPK_CTRL_3:
	case ARIZONA_DAC_COMP_1:
	case ARIZONA_DAC_COMP_2:
	case ARIZONA_DAC_COMP_3:
+3 −0
Original line number Diff line number Diff line
@@ -100,6 +100,9 @@ struct arizona {
	struct regmap_irq_chip_data *aod_irq_chip;
	struct regmap_irq_chip_data *irq_chip;

	bool hpdet_magic;
	unsigned int hp_ena;

	struct mutex clk_lock;
	int clk32k_ref;

+42 −0
Original line number Diff line number Diff line
@@ -85,12 +85,14 @@
#define ARIZONA_FLL1_CONTROL_6                   0x176
#define ARIZONA_FLL1_LOOP_FILTER_TEST_1          0x177
#define ARIZONA_FLL1_NCO_TEST_0                  0x178
#define ARIZONA_FLL1_CONTROL_7                   0x179
#define ARIZONA_FLL1_SYNCHRONISER_1              0x181
#define ARIZONA_FLL1_SYNCHRONISER_2              0x182
#define ARIZONA_FLL1_SYNCHRONISER_3              0x183
#define ARIZONA_FLL1_SYNCHRONISER_4              0x184
#define ARIZONA_FLL1_SYNCHRONISER_5              0x185
#define ARIZONA_FLL1_SYNCHRONISER_6              0x186
#define ARIZONA_FLL1_SYNCHRONISER_7              0x187
#define ARIZONA_FLL1_SPREAD_SPECTRUM             0x189
#define ARIZONA_FLL1_GPIO_CLOCK                  0x18A
#define ARIZONA_FLL2_CONTROL_1                   0x191
@@ -101,12 +103,14 @@
#define ARIZONA_FLL2_CONTROL_6                   0x196
#define ARIZONA_FLL2_LOOP_FILTER_TEST_1          0x197
#define ARIZONA_FLL2_NCO_TEST_0                  0x198
#define ARIZONA_FLL2_CONTROL_7                   0x199
#define ARIZONA_FLL2_SYNCHRONISER_1              0x1A1
#define ARIZONA_FLL2_SYNCHRONISER_2              0x1A2
#define ARIZONA_FLL2_SYNCHRONISER_3              0x1A3
#define ARIZONA_FLL2_SYNCHRONISER_4              0x1A4
#define ARIZONA_FLL2_SYNCHRONISER_5              0x1A5
#define ARIZONA_FLL2_SYNCHRONISER_6              0x1A6
#define ARIZONA_FLL2_SYNCHRONISER_7              0x1A7
#define ARIZONA_FLL2_SPREAD_SPECTRUM             0x1A9
#define ARIZONA_FLL2_GPIO_CLOCK                  0x1AA
#define ARIZONA_MIC_CHARGE_PUMP_1                0x200
@@ -213,6 +217,8 @@
#define ARIZONA_PDM_SPK1_CTRL_2                  0x491
#define ARIZONA_PDM_SPK2_CTRL_1                  0x492
#define ARIZONA_PDM_SPK2_CTRL_2                  0x493
#define ARIZONA_SPK_CTRL_2                       0x4B5
#define ARIZONA_SPK_CTRL_3                       0x4B6
#define ARIZONA_DAC_COMP_1                       0x4DC
#define ARIZONA_DAC_COMP_2                       0x4DD
#define ARIZONA_DAC_COMP_3                       0x4DE
@@ -1677,6 +1683,13 @@
#define ARIZONA_FLL1_FRC_INTEG_VAL_SHIFT              0  /* FLL1_FRC_INTEG_VAL - [11:0] */
#define ARIZONA_FLL1_FRC_INTEG_VAL_WIDTH             12  /* FLL1_FRC_INTEG_VAL - [11:0] */

/*
 * R377 (0x179) - FLL1 Control 7
 */
#define ARIZONA_FLL1_GAIN_MASK                   0x003c  /* FLL1_GAIN */
#define ARIZONA_FLL1_GAIN_SHIFT                       2  /* FLL1_GAIN */
#define ARIZONA_FLL1_GAIN_WIDTH                       4  /* FLL1_GAIN */

/*
 * R385 (0x181) - FLL1 Synchroniser 1
 */
@@ -1723,6 +1736,17 @@
#define ARIZONA_FLL1_CLK_SYNC_SRC_SHIFT               0  /* FLL1_CLK_SYNC_SRC - [3:0] */
#define ARIZONA_FLL1_CLK_SYNC_SRC_WIDTH               4  /* FLL1_CLK_SYNC_SRC - [3:0] */

/*
 * R391 (0x187) - FLL1 Synchroniser 7
 */
#define ARIZONA_FLL1_SYNC_GAIN_MASK              0x003c  /* FLL1_SYNC_GAIN */
#define ARIZONA_FLL1_SYNC_GAIN_SHIFT                  2  /* FLL1_SYNC_GAIN */
#define ARIZONA_FLL1_SYNC_GAIN_WIDTH                  4  /* FLL1_SYNC_GAIN */
#define ARIZONA_FLL1_SYNC_BW                     0x0001  /* FLL1_SYNC_BW */
#define ARIZONA_FLL1_SYNC_BW_MASK                0x0001  /* FLL1_SYNC_BW */
#define ARIZONA_FLL1_SYNC_BW_SHIFT                    0  /* FLL1_SYNC_BW */
#define ARIZONA_FLL1_SYNC_BW_WIDTH                    1  /* FLL1_SYNC_BW */

/*
 * R393 (0x189) - FLL1 Spread Spectrum
 */
@@ -1815,6 +1839,13 @@
#define ARIZONA_FLL2_FRC_INTEG_VAL_SHIFT              0  /* FLL2_FRC_INTEG_VAL - [11:0] */
#define ARIZONA_FLL2_FRC_INTEG_VAL_WIDTH             12  /* FLL2_FRC_INTEG_VAL - [11:0] */

/*
 * R409 (0x199) - FLL2 Control 7
 */
#define ARIZONA_FLL2_GAIN_MASK                   0x003c  /* FLL2_GAIN */
#define ARIZONA_FLL2_GAIN_SHIFT                       2  /* FLL2_GAIN */
#define ARIZONA_FLL2_GAIN_WIDTH                       4  /* FLL2_GAIN */

/*
 * R417 (0x1A1) - FLL2 Synchroniser 1
 */
@@ -1861,6 +1892,17 @@
#define ARIZONA_FLL2_CLK_SYNC_SRC_SHIFT               0  /* FLL2_CLK_SYNC_SRC - [3:0] */
#define ARIZONA_FLL2_CLK_SYNC_SRC_WIDTH               4  /* FLL2_CLK_SYNC_SRC - [3:0] */

/*
 * R423 (0x1A7) - FLL2 Synchroniser 7
 */
#define ARIZONA_FLL2_SYNC_GAIN_MASK              0x003c  /* FLL2_SYNC_GAIN */
#define ARIZONA_FLL2_SYNC_GAIN_SHIFT                  2  /* FLL2_SYNC_GAIN */
#define ARIZONA_FLL2_SYNC_GAIN_WIDTH                  4  /* FLL2_SYNC_GAIN */
#define ARIZONA_FLL2_SYNC_BW_MASK                0x0001  /* FLL2_SYNC_BW */
#define ARIZONA_FLL2_SYNC_BW_MASK                0x0001  /* FLL2_SYNC_BW */
#define ARIZONA_FLL2_SYNC_BW_SHIFT                    0  /* FLL2_SYNC_BW */
#define ARIZONA_FLL2_SYNC_BW_WIDTH                    1  /* FLL2_SYNC_BW */

/*
 * R425 (0x1A9) - FLL2 Spread Spectrum
 */
+461 −69

File changed.

Preview size limit exceeded, changes collapsed.

Loading