Commit 9c5ad837 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Lee Jones
Browse files

mfd: arizona: Make legacy gpiolib interface optional



The only machine that still uses the old gpio number based interface
is the wlf_cragg_6410 board file. In order to remove the dependency
on the interfaces, add #ifdef blocks here.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20250808151822.536879-13-arnd@kernel.org


Signed-off-by: default avatarLee Jones <lee@kernel.org>
parent a5b03d81
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ static irqreturn_t arizona_irq_thread(int irq, void *data)
			dev_err(arizona->dev,
				"Failed to read main IRQ status: %d\n", ret);
		}

#ifdef CONFIG_GPIOLIB_LEGACY
		/*
		 * Poll the IRQ pin status to see if we're really done
		 * if the interrupt controller can't do it for us.
@@ -150,6 +150,7 @@ static irqreturn_t arizona_irq_thread(int irq, void *data)
			   !gpio_get_value_cansleep(arizona->pdata.irq_gpio)) {
			poll = true;
		}
#endif
	} while (poll);

	pm_runtime_put_autosuspend(arizona->dev);
@@ -349,6 +350,7 @@ int arizona_irq_init(struct arizona *arizona)
		goto err_map_main_irq;
	}

#ifdef CONFIG_GPIOLIB_LEGACY
	/* Used to emulate edge trigger and to work around broken pinmux */
	if (arizona->pdata.irq_gpio) {
		if (gpio_to_irq(arizona->pdata.irq_gpio) != arizona->irq) {
@@ -368,6 +370,7 @@ int arizona_irq_init(struct arizona *arizona)
			arizona->pdata.irq_gpio = 0;
		}
	}
#endif

	ret = request_threaded_irq(arizona->irq, NULL, arizona_irq_thread,
				   flags, "arizona", arizona);
+6 −0
Original line number Diff line number Diff line
@@ -117,8 +117,10 @@ struct arizona_pdata {
	/** Check for line output with HPDET method */
	bool hpdet_acc_id_line;

#ifdef CONFIG_GPIOLIB_LEGACY
	/** GPIO used for mic isolation with HPDET */
	int hpdet_id_gpio;
#endif

	/** Channel to use for headphone detection */
	unsigned int hpdet_channel;
@@ -129,8 +131,10 @@ struct arizona_pdata {
	/** Extra debounce timeout used during initial mic detection (ms) */
	unsigned int micd_detect_debounce;

#ifdef CONFIG_GPIOLIB_LEGACY
	/** GPIO for mic detection polarity */
	int micd_pol_gpio;
#endif

	/** Mic detect ramp rate */
	unsigned int micd_bias_start_time;
@@ -184,8 +188,10 @@ struct arizona_pdata {
	/** Haptic actuator type */
	unsigned int hap_act;

#ifdef CONFIG_GPIOLIB_LEGACY
	/** GPIO for primary IRQ (used for edge triggered emulation) */
	int irq_gpio;
#endif

	/** General purpose switch control */
	unsigned int gpsw;
+16 −1
Original line number Diff line number Diff line
@@ -461,7 +461,11 @@ static int arizona_hpdet_do_id(struct arizona_priv *info, int *reading,
			       bool *mic)
{
	struct arizona *arizona = info->arizona;
#ifdef CONFIG_GPIOLIB_LEGACY
	int id_gpio = arizona->pdata.hpdet_id_gpio;
#else
	int id_gpio = 0;
#endif

	if (!arizona->pdata.hpdet_acc_id)
		return 0;
@@ -472,6 +476,7 @@ static int arizona_hpdet_do_id(struct arizona_priv *info, int *reading,
	 */
	info->hpdet_res[info->num_hpdet_res++] = *reading;

#ifdef CONFIG_GPIOLIB_LEGACY
	/* Only check the mic directly if we didn't already ID it */
	if (id_gpio && info->num_hpdet_res == 1) {
		dev_dbg(arizona->dev, "Measuring mic\n");
@@ -489,6 +494,7 @@ static int arizona_hpdet_do_id(struct arizona_priv *info, int *reading,
				   ARIZONA_HP_POLL, ARIZONA_HP_POLL);
		return -EAGAIN;
	}
#endif

	/* OK, got both.  Now, compare... */
	dev_dbg(arizona->dev, "HPDET measured %d %d\n",
@@ -529,7 +535,9 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
{
	struct arizona_priv *info = data;
	struct arizona *arizona = info->arizona;
#ifdef CONFIG_GPIOLIB_LEGACY
	int id_gpio = arizona->pdata.hpdet_id_gpio;
#endif
	int ret, reading, state, report;
	bool mic = false;

@@ -585,8 +593,10 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)

	arizona_extcon_hp_clamp(info, false);

#ifdef CONFIG_GPIOLIB_LEGACY
	if (id_gpio)
		gpio_set_value_cansleep(id_gpio, 0);
#endif

	/* If we have a mic then reenable MICDET */
	if (state && (mic || info->mic))
@@ -1317,6 +1327,7 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev)
		regmap_update_bits(arizona->regmap, ARIZONA_GP_SWITCH_1,
				ARIZONA_SW1_MODE_MASK, arizona->pdata.gpsw);

#ifdef CONFIG_GPIOLIB_LEGACY
	if (pdata->micd_pol_gpio > 0) {
		if (info->micd_modes[0].gpio)
			mode = GPIOF_OUT_INIT_HIGH;
@@ -1332,7 +1343,9 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev)
		}

		info->micd_pol_gpio = gpio_to_desc(pdata->micd_pol_gpio);
	} else {
	} else
#endif
	{
		if (info->micd_modes[0].gpio)
			mode = GPIOD_OUT_HIGH;
		else
@@ -1353,6 +1366,7 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev)
		}
	}

#ifdef CONFIG_GPIOLIB_LEGACY
	if (arizona->pdata.hpdet_id_gpio > 0) {
		ret = devm_gpio_request_one(dev, arizona->pdata.hpdet_id_gpio,
					    GPIOF_OUT_INIT_LOW,
@@ -1364,6 +1378,7 @@ int arizona_jack_codec_dev_probe(struct arizona_priv *info, struct device *dev)
			return ret;
		}
	}
#endif

	return 0;
}