Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
bac4d82
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
io_uring
ipc
kernel
lib
mm
net
rust
samples
scripts
security
sound
ac97
aoa
arm
atmel
core
drivers
firewire
hda
i2c
isa
mips
oss
parisc
pci
pcmcia
ppc
sh
soc
adi
amd
apple
atmel
au1x
bcm
cirrus
codecs
aw88395
88pm860x-codec.c
88pm860x-codec.h
Kconfig
Makefile
ab8500-codec.c
ab8500-codec.h
ac97.c
ad1836.c
ad1836.h
ad193x-i2c.c
ad193x-spi.c
ad193x.c
ad193x.h
ad1980.c
ad73311.c
ad73311.h
adau-utils.c
adau-utils.h
adau1372-i2c.c
adau1372-spi.c
adau1372.c
adau1372.h
adau1373.c
adau1373.h
adau1701.c
adau1701.h
adau1761-i2c.c
adau1761-spi.c
adau1761.c
adau1761.h
adau1781-i2c.c
adau1781-spi.c
adau1781.c
adau1781.h
adau17x1.c
adau17x1.h
adau1977-i2c.c
adau1977-spi.c
adau1977.c
adau1977.h
adau7002.c
adau7118-hw.c
adau7118-i2c.c
adau7118.c
adau7118.h
adav801.c
adav803.c
adav80x.c
adav80x.h
ads117x.c
ak4104.c
ak4118.c
ak4375.c
ak4458.c
ak4458.h
ak4535.c
ak4535.h
ak4554.c
ak4613.c
ak4641.c
ak4642.c
ak4671.c
ak4671.h
ak5386.c
ak5558.c
ak5558.h
alc5623.c
alc5623.h
alc5632.c
alc5632.h
arizona-jack.c
arizona.c
arizona.h
aw8738.c
bd28623.c
bt-sco.c
cirrus_legacy.h
cpcap.c
cq93vc.c
cros_ec_codec.c
cs35l32.c
cs35l32.h
cs35l33.c
cs35l33.h
cs35l34.c
cs35l34.h
cs35l35.c
cs35l35.h
cs35l36.c
cs35l36.h
cs35l41-i2c.c
cs35l41-lib.c
cs35l41-spi.c
cs35l41.c
cs35l41.h
cs35l45-i2c.c
cs35l45-spi.c
cs35l45-tables.c
cs35l45.c
cs35l45.h
cs35l56-i2c.c
cs35l56-sdw.c
cs35l56-shared.c
cs35l56-spi.c
cs35l56.c
cs35l56.h
cs4234.c
cs4234.h
cs4265.c
cs4265.h
cs4270.c
cs4271-i2c.c
cs4271-spi.c
cs4271.c
cs4271.h
cs42l42-i2c.c
cs42l42-sdw.c
cs42l42.c
cs42l42.h
cs42l51-i2c.c
cs42l51.c
cs42l51.h
cs42l52.c
cs42l52.h
cs42l56.c
cs42l56.h
cs42l73.c
cs42l73.h
cs42l83-i2c.c
cs42xx8-i2c.c
cs42xx8.c
cs42xx8.h
cs43130.c
cs43130.h
cs4341.c
cs4349.c
cs4349.h
cs47l15.c
cs47l24.c
cs47l24.h
cs47l35.c
cs47l85.c
cs47l90.c
cs47l92.c
cs53l30.c
cs53l30.h
cx20442.c
cx20442.h
cx2072x.c
cx2072x.h
da7210.c
da7213.c
da7213.h
da7218.c
da7218.h
da7219-aad.c
da7219-aad.h
da7219.c
da7219.h
da732x.c
da732x.h
da732x_reg.h
da9055.c
dmic.c
es7134.c
es7241.c
es8316.c
es8316.h
es8326.c
es8326.h
es8328-i2c.c
es8328-spi.c
es8328.c
es8328.h
gtm601.c
hda-dai.c
hda.c
hda.h
hdac_hda.c
hdac_hda.h
hdac_hdmi.c
hdac_hdmi.h
hdmi-codec.c
ics43432.c
idt821034.c
inno_rk3036.c
inno_rk3036.h
isabelle.c
isabelle.h
jz4725b.c
jz4740.c
jz4760.c
jz4770.c
l3.c
lm4857.c
lm49453.c
lm49453.h
lochnagar-sc.c
lpass-macro-common.c
lpass-macro-common.h
lpass-rx-macro.c
lpass-tx-macro.c
lpass-va-macro.c
lpass-wsa-macro.c
lpass-wsa-macro.h
madera.c
madera.h
max9759.c
max9768.c
max98088.c
max98088.h
max98090.c
max98090.h
max98095.c
max98095.h
max98357a.c
max98363.c
max98363.h
max98371.c
max98371.h
max98373-i2c.c
max98373-sdw.c
max98373-sdw.h
max98373.c
max98373.h
max98390.c
max98390.h
max98396.c
max98396.h
max9850.c
max9850.h
max98504.c
max98504.h
max98520.c
max98520.h
max9860.c
max9860.h
max9867.c
max9867.h
max9877.c
max9877.h
max98925.c
max98925.h
max98926.c
max98926.h
max98927.c
max98927.h
mc13783.c
mc13783.h
ml26124.c
ml26124.h
msm8916-wcd-analog.c
msm8916-wcd-digital.c
mt6351.c
mt6351.h
mt6358.c
mt6358.h
mt6359-accdet.c
mt6359-accdet.h
mt6359.c
mt6359.h
mt6660.c
mt6660.h
nau8315.c
nau8540.c
nau8540.h
nau8810.c
nau8810.h
nau8821.c
nau8821.h
nau8822.c
nau8822.h
nau8824.c
nau8824.h
nau8825.c
nau8825.h
pcm1681.c
pcm1789-i2c.c
pcm1789.c
pcm1789.h
pcm179x-i2c.c
pcm179x-spi.c
pcm179x.c
pcm179x.h
pcm186x-i2c.c
pcm186x-spi.c
pcm186x.c
pcm186x.h
pcm3008.c
pcm3008.h
pcm3060-i2c.c
pcm3060-spi.c
pcm3060.c
pcm3060.h
pcm3168a-i2c.c
pcm3168a-spi.c
pcm3168a.c
pcm3168a.h
pcm5102a.c
pcm512x-i2c.c
pcm512x-spi.c
pcm512x.c
pcm512x.h
peb2466.c
rk3328_codec.c
rk3328_codec.h
rk817_codec.c
rl6231.c
rl6231.h
rl6347a.c
rl6347a.h
rt1011.c
rt1011.h
rt1015.c
rt1015.h
rt1015p.c
rt1016.c
rt1016.h
rt1019.c
rt1019.h
rt1305.c
rt1305.h
rt1308-sdw.c
rt1308-sdw.h
rt1308.c
rt1308.h
rt1316-sdw.c
rt1316-sdw.h
rt1318-sdw.c
rt1318-sdw.h
rt274.c
rt274.h
rt286.c
rt286.h
rt298.c
rt298.h
rt5514-spi.c
rt5514-spi.h
rt5514.c
rt5514.h
rt5616.c
rt5616.h
rt5631.c
rt5631.h
rt5640.c
rt5640.h
rt5645.c
rt5645.h
rt5651.c
rt5651.h
rt5659.c
rt5659.h
rt5660.c
rt5660.h
rt5663.c
rt5663.h
rt5665.c
rt5665.h
rt5668.c
rt5668.h
rt5670-dsp.h
rt5670.c
rt5670.h
rt5677-spi.c
rt5677-spi.h
rt5677.c
rt5677.h
rt5682-i2c.c
rt5682-sdw.c
rt5682.c
rt5682.h
rt5682s.c
rt5682s.h
rt700-sdw.c
rt700-sdw.h
rt700.c
rt700.h
rt711-sdca-sdw.c
rt711-sdca-sdw.h
rt711-sdca.c
rt711-sdca.h
rt711-sdw.c
rt711-sdw.h
rt711.c
rt711.h
rt712-sdca-dmic.c
rt712-sdca-dmic.h
rt712-sdca-sdw.c
rt712-sdca-sdw.h
rt712-sdca.c
rt712-sdca.h
rt715-sdca-sdw.c
rt715-sdca-sdw.h
rt715-sdca.c
rt715-sdca.h
rt715-sdw.c
rt715-sdw.h
rt715.c
rt715.h
rt9120.c
sdw-mockup.c
sgtl5000.c
sgtl5000.h
si476x.c
sigmadsp-i2c.c
sigmadsp-regmap.c
sigmadsp.c
sigmadsp.h
simple-amplifier.c
simple-mux.c
sma1303.c
sma1303.h
spdif_receiver.c
spdif_transmitter.c
src4xxx-i2c.c
src4xxx.c
src4xxx.h
ssm2305.c
ssm2518.c
ssm2518.h
ssm2602-i2c.c
ssm2602-spi.c
ssm2602.c
ssm2602.h
ssm4567.c
sta32x.c
sta32x.h
sta350.c
sta350.h
sta529.c
stac9766.c
sti-sas.c
tas2552.c
tas2552.h
tas2562.c
tas2562.h
tas2764.c
tas2764.h
tas2770.c
tas2770.h
tas2780.c
tas2780.h
tas5086.c
tas571x.c
tas571x.h
tas5720.c
tas5720.h
tas5805m.c
tas6424.c
tas6424.h
tda7419.c
tfa9879.c
tfa9879.h
tfa989x.c
tlv320adc3xxx.c
tlv320adcx140.c
tlv320adcx140.h
tlv320aic23-i2c.c
tlv320aic23-spi.c
tlv320aic23.c
tlv320aic23.h
tlv320aic26.c
tlv320aic26.h
tlv320aic31xx.c
tlv320aic31xx.h
tlv320aic32x4-clk.c
tlv320aic32x4-i2c.c
tlv320aic32x4-spi.c
tlv320aic32x4.c
tlv320aic32x4.h
tlv320aic3x-i2c.c
tlv320aic3x-spi.c
tlv320aic3x.c
tlv320aic3x.h
tlv320dac33.c
tlv320dac33.h
tpa6130a2.c
tpa6130a2.h
ts3a227e.c
ts3a227e.h
tscs42xx.c
tscs42xx.h
tscs454.c
tscs454.h
twl4030.c
twl6040.c
twl6040.h
uda1334.c
uda134x.c
uda134x.h
uda1380.c
uda1380.h
wcd-clsh-v2.c
wcd-clsh-v2.h
wcd-mbhc-v2.c
wcd-mbhc-v2.h
wcd9335.c
wcd9335.h
wcd934x.c
wcd938x-sdw.c
wcd938x.c
wcd938x.h
wl1273.c
wl1273.h
wm0010.c
wm1250-ev1.c
wm2000.c
wm2000.h
wm2200.c
wm2200.h
wm5100-tables.c
wm5100.c
wm5100.h
wm5102.c
wm5102.h
wm5110.c
wm5110.h
wm8350.c
wm8350.h
wm8400.c
wm8400.h
wm8510.c
wm8510.h
wm8523.c
wm8523.h
wm8524.c
wm8580.c
wm8580.h
wm8711.c
wm8711.h
wm8727.c
wm8728.c
wm8728.h
wm8731-i2c.c
wm8731-spi.c
wm8731.c
wm8731.h
wm8737.c
wm8737.h
wm8741.c
wm8741.h
wm8750.c
wm8750.h
wm8753.c
wm8753.h
wm8770.c
wm8770.h
wm8776.c
wm8776.h
wm8782.c
wm8804-i2c.c
wm8804-spi.c
wm8804.c
wm8804.h
wm8900.c
wm8900.h
wm8903.c
wm8903.h
wm8904.c
wm8904.h
wm8940.c
wm8940.h
wm8955.c
wm8955.h
wm8958-dsp2.c
wm8960.c
wm8960.h
wm8961.c
wm8961.h
wm8962.c
wm8962.h
wm8971.c
wm8971.h
wm8974.c
wm8974.h
wm8978.c
wm8978.h
wm8983.c
wm8983.h
wm8985.c
wm8985.h
wm8988.c
wm8988.h
wm8990.c
wm8990.h
wm8991.c
wm8991.h
wm8993.c
wm8993.h
wm8994.c
wm8994.h
wm8995.c
wm8995.h
wm8996.c
wm8996.h
wm8997.c
wm8997.h
wm8998.c
wm8998.h
wm9081.c
wm9081.h
wm9090.c
wm9090.h
wm9705.c
wm9712.c
wm9713.c
wm9713.h
wm_adsp.c
wm_adsp.h
wm_hubs.c
wm_hubs.h
wsa881x.c
wsa883x.c
zl38060.c
dwc
fsl
generic
hisilicon
img
intel
jz4740
kirkwood
mediatek
meson
mxs
pxa
qcom
rockchip
samsung
sh
sof
spear
sprd
sti
stm
sunxi
tegra
ti
uniphier
ux500
xilinx
xtensa
Kconfig
Makefile
soc-ac97.c
soc-acpi.c
soc-card.c
soc-component.c
soc-compress.c
soc-core.c
soc-dai.c
soc-dapm.c
soc-devres.c
soc-generic-dmaengine-pcm.c
soc-jack.c
soc-link.c
soc-ops.c
soc-pcm.c
soc-topology-test.c
soc-topology.c
soc-utils-test.c
soc-utils.c
sparc
spi
synth
usb
virtio
x86
xen
Kconfig
Makefile
ac97_bus.c
last.c
sound_core.c
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
sound
/
soc
/
codecs
/
rt5682-i2c.c
Copy path
Blame
Blame
Latest commit
Matthias Kaehlcke
and
Mark Brown
ASoC: rt5682: Disable jack detection interrupt during suspend
May 17, 2023
8b27137
·
May 17, 2023
History
History
346 lines (294 loc) · 9.23 KB
Breadcrumbs
linux
/
sound
/
soc
/
codecs
/
rt5682-i2c.c
Top
File metadata and controls
Code
Blame
346 lines (294 loc) · 9.23 KB
Raw
// SPDX-License-Identifier: GPL-2.0-only // // rt5682.c -- RT5682 ALSA SoC audio component driver // // Copyright 2018 Realtek Semiconductor Corp. // Author: Bard Liao <bardliao@realtek.com> // #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/i2c.h> #include <linux/platform_device.h> #include <linux/spi/spi.h> #include <linux/acpi.h> #include <linux/gpio.h> #include <linux/of_gpio.h> #include <linux/mutex.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/jack.h> #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/initval.h> #include <sound/tlv.h> #include <sound/rt5682.h> #include "rl6231.h" #include "rt5682.h" static const struct rt5682_platform_data i2s_default_platform_data = { .dmic1_data_pin = RT5682_DMIC1_DATA_GPIO2, .dmic1_clk_pin = RT5682_DMIC1_CLK_GPIO3, .jd_src = RT5682_JD1, .btndet_delay = 16, .dai_clk_names[RT5682_DAI_WCLK_IDX] = "rt5682-dai-wclk", .dai_clk_names[RT5682_DAI_BCLK_IDX] = "rt5682-dai-bclk", }; static const struct regmap_config rt5682_regmap = { .reg_bits = 16, .val_bits = 16, .max_register = RT5682_I2C_MODE, .volatile_reg = rt5682_volatile_register, .readable_reg = rt5682_readable_register, .cache_type = REGCACHE_RBTREE, .reg_defaults = rt5682_reg, .num_reg_defaults = RT5682_REG_NUM, .use_single_read = true, .use_single_write = true, }; static void rt5682_jd_check_handler(struct work_struct *work) { struct rt5682_priv *rt5682 = container_of(work, struct rt5682_priv, jd_check_work.work); if (snd_soc_component_read(rt5682->component, RT5682_AJD1_CTRL) & RT5682_JDH_RS_MASK) /* jack out */ mod_delayed_work(system_power_efficient_wq, &rt5682->jack_detect_work, 0); else schedule_delayed_work(&rt5682->jd_check_work, 500); } static irqreturn_t rt5682_irq(int irq, void *data) { struct rt5682_priv *rt5682 = data; mod_delayed_work(system_power_efficient_wq, &rt5682->jack_detect_work, msecs_to_jiffies(rt5682->irq_work_delay_time)); return IRQ_HANDLED; } static struct snd_soc_dai_driver rt5682_dai[] = { { .name = "rt5682-aif1", .id = RT5682_AIF1, .playback = { .stream_name = "AIF1 Playback", .channels_min = 1, .channels_max = 2, .rates = RT5682_STEREO_RATES, .formats = RT5682_FORMATS, }, .capture = { .stream_name = "AIF1 Capture", .channels_min = 1, .channels_max = 2, .rates = RT5682_STEREO_RATES, .formats = RT5682_FORMATS, }, .ops = &rt5682_aif1_dai_ops, }, { .name = "rt5682-aif2", .id = RT5682_AIF2, .capture = { .stream_name = "AIF2 Capture", .channels_min = 1, .channels_max = 2, .rates = RT5682_STEREO_RATES, .formats = RT5682_FORMATS, }, .ops = &rt5682_aif2_dai_ops, }, }; static void rt5682_i2c_disable_regulators(void *data) { struct rt5682_priv *rt5682 = data; regulator_bulk_disable(ARRAY_SIZE(rt5682->supplies), rt5682->supplies); } static int rt5682_i2c_probe(struct i2c_client *i2c) { struct rt5682_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rt5682_priv *rt5682; int i, ret; unsigned int val; rt5682 = devm_kzalloc(&i2c->dev, sizeof(struct rt5682_priv), GFP_KERNEL); if (!rt5682) return -ENOMEM; i2c_set_clientdata(i2c, rt5682); rt5682->i2c_dev = &i2c->dev; rt5682->pdata = i2s_default_platform_data; if (pdata) rt5682->pdata = *pdata; else rt5682_parse_dt(rt5682, &i2c->dev); rt5682->regmap = devm_regmap_init_i2c(i2c, &rt5682_regmap); if (IS_ERR(rt5682->regmap)) { ret = PTR_ERR(rt5682->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); return ret; } for (i = 0; i < ARRAY_SIZE(rt5682->supplies); i++) rt5682->supplies[i].supply = rt5682_supply_names[i]; ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(rt5682->supplies), rt5682->supplies); if (ret) { dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); return ret; } ret = devm_add_action_or_reset(&i2c->dev, rt5682_i2c_disable_regulators, rt5682); if (ret) return ret; ret = regulator_bulk_enable(ARRAY_SIZE(rt5682->supplies), rt5682->supplies); if (ret) { dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); return ret; } if (gpio_is_valid(rt5682->pdata.ldo1_en)) { if (devm_gpio_request_one(&i2c->dev, rt5682->pdata.ldo1_en, GPIOF_OUT_INIT_HIGH, "rt5682")) dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); } /* Sleep for 300 ms miniumum */ usleep_range(300000, 350000); regmap_write(rt5682->regmap, RT5682_I2C_MODE, 0x1); usleep_range(10000, 15000); regmap_read(rt5682->regmap, RT5682_DEVICE_ID, &val); if (val != DEVICE_ID) { dev_err(&i2c->dev, "Device with ID register %x is not rt5682\n", val); return -ENODEV; } mutex_init(&rt5682->calibrate_mutex); rt5682_calibrate(rt5682); rt5682_apply_patch_list(rt5682, &i2c->dev); regmap_write(rt5682->regmap, RT5682_DEPOP_1, 0x0000); /* DMIC pin*/ if (rt5682->pdata.dmic1_data_pin != RT5682_DMIC1_NULL) { switch (rt5682->pdata.dmic1_data_pin) { case RT5682_DMIC1_DATA_GPIO2: /* share with LRCK2 */ regmap_update_bits(rt5682->regmap, RT5682_DMIC_CTRL_1, RT5682_DMIC_1_DP_MASK, RT5682_DMIC_1_DP_GPIO2); regmap_update_bits(rt5682->regmap, RT5682_GPIO_CTRL_1, RT5682_GP2_PIN_MASK, RT5682_GP2_PIN_DMIC_SDA); break; case RT5682_DMIC1_DATA_GPIO5: /* share with DACDAT1 */ regmap_update_bits(rt5682->regmap, RT5682_DMIC_CTRL_1, RT5682_DMIC_1_DP_MASK, RT5682_DMIC_1_DP_GPIO5); regmap_update_bits(rt5682->regmap, RT5682_GPIO_CTRL_1, RT5682_GP5_PIN_MASK, RT5682_GP5_PIN_DMIC_SDA); break; default: dev_warn(&i2c->dev, "invalid DMIC_DAT pin\n"); break; } switch (rt5682->pdata.dmic1_clk_pin) { case RT5682_DMIC1_CLK_GPIO1: /* share with IRQ */ regmap_update_bits(rt5682->regmap, RT5682_GPIO_CTRL_1, RT5682_GP1_PIN_MASK, RT5682_GP1_PIN_DMIC_CLK); break; case RT5682_DMIC1_CLK_GPIO3: /* share with BCLK2 */ regmap_update_bits(rt5682->regmap, RT5682_GPIO_CTRL_1, RT5682_GP3_PIN_MASK, RT5682_GP3_PIN_DMIC_CLK); if (rt5682->pdata.dmic_clk_driving_high) regmap_update_bits(rt5682->regmap, RT5682_PAD_DRIVING_CTRL, RT5682_PAD_DRV_GP3_MASK, 2 << RT5682_PAD_DRV_GP3_SFT); break; default: dev_warn(&i2c->dev, "invalid DMIC_CLK pin\n"); break; } } regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1, RT5682_LDO1_DVO_MASK | RT5682_HP_DRIVER_MASK, RT5682_LDO1_DVO_12 | RT5682_HP_DRIVER_5X); regmap_write(rt5682->regmap, RT5682_MICBIAS_2, 0x0080); regmap_update_bits(rt5682->regmap, RT5682_GPIO_CTRL_1, RT5682_GP4_PIN_MASK | RT5682_GP5_PIN_MASK, RT5682_GP4_PIN_ADCDAT1 | RT5682_GP5_PIN_DACDAT1); regmap_write(rt5682->regmap, RT5682_TEST_MODE_CTRL_1, 0x0000); regmap_update_bits(rt5682->regmap, RT5682_BIAS_CUR_CTRL_8, RT5682_HPA_CP_BIAS_CTRL_MASK, RT5682_HPA_CP_BIAS_3UA); regmap_update_bits(rt5682->regmap, RT5682_CHARGE_PUMP_1, RT5682_CP_CLK_HP_MASK, RT5682_CP_CLK_HP_300KHZ); regmap_update_bits(rt5682->regmap, RT5682_HP_CHARGE_PUMP_1, RT5682_PM_HP_MASK, RT5682_PM_HP_HV); regmap_update_bits(rt5682->regmap, RT5682_DMIC_CTRL_1, RT5682_FIFO_CLK_DIV_MASK, RT5682_FIFO_CLK_DIV_2); INIT_DELAYED_WORK(&rt5682->jack_detect_work, rt5682_jack_detect_handler); INIT_DELAYED_WORK(&rt5682->jd_check_work, rt5682_jd_check_handler); if (i2c->irq) { ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, rt5682_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "rt5682", rt5682); if (!ret) rt5682->irq = i2c->irq; else dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); } #ifdef CONFIG_COMMON_CLK /* Check if MCLK provided */ rt5682->mclk = devm_clk_get_optional(&i2c->dev, "mclk"); if (IS_ERR(rt5682->mclk)) return PTR_ERR(rt5682->mclk); /* Register CCF DAI clock control */ ret = rt5682_register_dai_clks(rt5682); if (ret) return ret; /* Initial setup for CCF */ rt5682->lrck[RT5682_AIF1] = 48000; #endif return devm_snd_soc_register_component(&i2c->dev, &rt5682_soc_component_dev, rt5682_dai, ARRAY_SIZE(rt5682_dai)); } static void rt5682_i2c_shutdown(struct i2c_client *client) { struct rt5682_priv *rt5682 = i2c_get_clientdata(client); disable_irq(client->irq); cancel_delayed_work_sync(&rt5682->jack_detect_work); cancel_delayed_work_sync(&rt5682->jd_check_work); rt5682_reset(rt5682); } static void rt5682_i2c_remove(struct i2c_client *client) { rt5682_i2c_shutdown(client); } static const struct of_device_id rt5682_of_match[] = { {.compatible = "realtek,rt5682i"}, {}, }; MODULE_DEVICE_TABLE(of, rt5682_of_match); static const struct acpi_device_id rt5682_acpi_match[] = { {"10EC5682", 0,}, {}, }; MODULE_DEVICE_TABLE(acpi, rt5682_acpi_match); static const struct i2c_device_id rt5682_i2c_id[] = { {"rt5682", 0}, {} }; MODULE_DEVICE_TABLE(i2c, rt5682_i2c_id); static struct i2c_driver rt5682_i2c_driver = { .driver = { .name = "rt5682", .of_match_table = rt5682_of_match, .acpi_match_table = rt5682_acpi_match, .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, .probe_new = rt5682_i2c_probe, .remove = rt5682_i2c_remove, .shutdown = rt5682_i2c_shutdown, .id_table = rt5682_i2c_id, }; module_i2c_driver(rt5682_i2c_driver); MODULE_DESCRIPTION("ASoC RT5682 driver"); MODULE_AUTHOR("Bard Liao <bardliao@realtek.com>"); MODULE_LICENSE("GPL v2");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
You can’t perform that action at this time.