Lines Matching +full:micd +full:- +full:pol +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0-only
3 * arizona-spi.c -- Arizona SPI bus interface
12 #include <linux/gpio/consumer.h>
13 #include <linux/gpio/machine.h>
21 #include <uapi/linux/input-event-codes.h>
32 { "reset-gpios", &reset_gpios, 1, },
33 { "wlf,ldoena-gpios", &ldoena_gpios, 1 },
38 * The ACPI resources for the device only describe external GPIO-s. They do
39 * not provide mappings for the GPIO-s coming from the Arizona codec itself.
42 { "arizona", 2, "wlf,spkvdd-ena", 0, GPIO_ACTIVE_HIGH },
43 { "arizona", 4, "wlf,micd-pol", 0, GPIO_ACTIVE_LOW },
58 /* Add mappings for the 2 ACPI declared GPIOs used for reset and ldo-ena */ in arizona_spi_acpi_windows_probe()
59 devm_acpi_dev_add_driver_gpios(arizona->dev, arizona_acpi_gpios); in arizona_spi_acpi_windows_probe()
61 /* Add lookups for the SoCs own GPIOs used for micdet-polarity and spkVDD-enable */ in arizona_spi_acpi_windows_probe()
62 lookup = devm_kzalloc(arizona->dev, in arizona_spi_acpi_windows_probe()
66 return -ENOMEM; in arizona_spi_acpi_windows_probe()
68 lookup->dev_id = dev_name(arizona->dev); in arizona_spi_acpi_windows_probe()
69 memcpy(lookup->table, arizona_soc_gpios, sizeof(arizona_soc_gpios)); in arizona_spi_acpi_windows_probe()
72 ret = devm_add_action_or_reset(arizona->dev, arizona_spi_acpi_remove_lookup, lookup); in arizona_spi_acpi_windows_probe()
76 /* Enable 32KHz clock from SoC to codec for jack-detect */ in arizona_spi_acpi_windows_probe()
77 status = acpi_evaluate_object(ACPI_HANDLE(arizona->dev), "CLKE", NULL, NULL); in arizona_spi_acpi_windows_probe()
79 dev_warn(arizona->dev, "Failed to enable 32KHz clk ACPI error %d\n", status); in arizona_spi_acpi_windows_probe()
90 * Get the reset GPIO, treating -ENOENT as -EPROBE_DEFER to wait for in arizona_spi_acpi_android_probe()
91 * the x86-android-tablets module to register the board specific GPIO in arizona_spi_acpi_android_probe()
94 arizona->pdata.reset = devm_gpiod_get(arizona->dev, "reset", GPIOD_OUT_LOW); in arizona_spi_acpi_android_probe()
95 if (IS_ERR(arizona->pdata.reset)) { in arizona_spi_acpi_android_probe()
96 ret = PTR_ERR(arizona->pdata.reset); in arizona_spi_acpi_android_probe()
97 if (ret == -ENOENT) { in arizona_spi_acpi_android_probe()
98 dev_info_once(arizona->dev, in arizona_spi_acpi_android_probe()
99 "Deferring probe till GPIO lookup is registered\n"); in arizona_spi_acpi_android_probe()
100 ret = -EPROBE_DEFER; in arizona_spi_acpi_android_probe()
102 return dev_err_probe(arizona->dev, ret, "getting reset GPIO\n"); in arizona_spi_acpi_android_probe()
118 * value from extcon-arizona.c:arizona_micd_levels halfway 2 button resistances.
129 struct acpi_device *adev = ACPI_COMPANION(arizona->dev); in arizona_spi_acpi_probe()
141 * Some DSDTs wrongly declare the IRQ trigger-type as IRQF_TRIGGER_FALLING in arizona_spi_acpi_probe()
145 * to IRQF_TRIGGER_FALLING. Correct the IRQ trigger-type to fix this. in arizona_spi_acpi_probe()
153 arizona->pdata.irq_flags = IRQF_TRIGGER_LOW; in arizona_spi_acpi_probe()
156 arizona->pdata.micd_detect_debounce = 200; in arizona_spi_acpi_probe()
158 /* Use standard AOSP values for headset-button mappings */ in arizona_spi_acpi_probe()
159 arizona->pdata.micd_ranges = arizona_micd_aosp_ranges; in arizona_spi_acpi_probe()
160 arizona->pdata.num_micd_ranges = ARRAY_SIZE(arizona_micd_aosp_ranges); in arizona_spi_acpi_probe()
162 /* Use left headphone speaker for HP vs line-out detection */ in arizona_spi_acpi_probe()
163 arizona->pdata.hpdet_channel = ARIZONA_ACCDET_MODE_HPL; in arizona_spi_acpi_probe()
187 return -ENODEV; in arizona_spi_acpi_probe()
215 dev_err(&spi->dev, "Unknown device type %ld\n", type); in arizona_spi_probe()
216 return -EINVAL; in arizona_spi_probe()
220 dev_err(&spi->dev, in arizona_spi_probe()
222 return -EINVAL; in arizona_spi_probe()
225 arizona = devm_kzalloc(&spi->dev, sizeof(*arizona), GFP_KERNEL); in arizona_spi_probe()
227 return -ENOMEM; in arizona_spi_probe()
229 arizona->regmap = devm_regmap_init_spi(spi, regmap_config); in arizona_spi_probe()
230 if (IS_ERR(arizona->regmap)) { in arizona_spi_probe()
231 ret = PTR_ERR(arizona->regmap); in arizona_spi_probe()
232 dev_err(&spi->dev, "Failed to allocate register map: %d\n", in arizona_spi_probe()
237 arizona->type = type; in arizona_spi_probe()
238 arizona->dev = &spi->dev; in arizona_spi_probe()
239 arizona->irq = spi->irq; in arizona_spi_probe()
241 if (has_acpi_companion(&spi->dev)) { in arizona_spi_probe()