1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152
#include <linux/cleanup.h>
#include <linux/unaligned.h>
#include <linux/firmware.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/regmap.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#include "pcm6240.h"
static const struct i2c_device_id pcmdevice_i2c_id[] = {
{ .name = "adc3120", .driver_data = ADC3120 },
{ .name = "adc5120", .driver_data = ADC5120 },
{ .name = "adc6120", .driver_data = ADC6120 },
{ .name = "dix4192", .driver_data = DIX4192 },
{ .name = "pcm1690", .driver_data = PCM1690 },
{ .name = "pcm3120", .driver_data = PCM3120 },
{ .name = "pcm3140", .driver_data = PCM3140 },
{ .name = "pcm5120", .driver_data = PCM5120 },
{ .name = "pcm5140", .driver_data = PCM5140 },
{ .name = "pcm6120", .driver_data = PCM6120 },
{ .name = "pcm6140", .driver_data = PCM6140 },
{ .name = "pcm6240", .driver_data = PCM6240 },
{ .name = "pcm6260", .driver_data = PCM6260 },
{ .name = "pcm9211", .driver_data = PCM9211 },
{ .name = "pcmd3140", .driver_data = PCMD3140 },
{ .name = "pcmd3180", .driver_data = PCMD3180 },
{ .name = "pcmd512x", .driver_data = PCMD512X },
{ .name = "taa5212", .driver_data = TAA5212 },
{ .name = "taa5412", .driver_data = TAA5412 },
{ .name = "tad5212", .driver_data = TAD5212 },
{ .name = "tad5412", .driver_data = TAD5412 },
{ }
};
MODULE_DEVICE_TABLE(i2c, pcmdevice_i2c_id);
static const char *const pcmdev_ctrl_name[] = {
"%s i2c%d Dev%d Ch%d Ana Volume",
"%s i2c%d Dev%d Ch%d Digi Volume",
"%s i2c%d Dev%d Ch%d Fine Volume",
};
static const struct pcmdevice_mixer_control adc5120_analog_gain_ctl[] = {
{
.shift = 1,
.reg = ADC5120_REG_CH1_ANALOG_GAIN,
.max = 0x54,
.invert = 0,
},
{
.shift = 1,
.reg = ADC5120_REG_CH2_ANALOG_GAIN,
.max = 0x54,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control adc5120_digi_gain_ctl[] = {
{
.shift = 0,
.reg = ADC5120_REG_CH1_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = ADC5120_REG_CH2_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcm1690_digi_gain_ctl[] = {
{
.shift = 0,
.reg = PCM1690_REG_CH1_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM1690_REG_CH2_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM1690_REG_CH3_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM1690_REG_CH4_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM1690_REG_CH5_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM1690_REG_CH6_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM1690_REG_CH7_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM1690_REG_CH8_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcm6240_analog_gain_ctl[] = {
{
.shift = 2,
.reg = PCM6240_REG_CH1_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
},
{
.shift = 2,
.reg = PCM6240_REG_CH2_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
},
{
.shift = 2,
.reg = PCM6240_REG_CH3_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
},
{
.shift = 2,
.reg = PCM6240_REG_CH4_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcm6240_digi_gain_ctl[] = {
{
.shift = 0,
.reg = PCM6240_REG_CH1_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM6240_REG_CH2_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM6240_REG_CH3_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM6240_REG_CH4_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcm6260_analog_gain_ctl[] = {
{
.shift = 2,
.reg = PCM6260_REG_CH1_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
},
{
.shift = 2,
.reg = PCM6260_REG_CH2_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
},
{
.shift = 2,
.reg = PCM6260_REG_CH3_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
},
{
.shift = 2,
.reg = PCM6260_REG_CH4_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
},
{
.shift = 2,
.reg = PCM6260_REG_CH5_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
},
{
.shift = 2,
.reg = PCM6260_REG_CH6_ANALOG_GAIN,
.max = 0x42,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcm6260_digi_gain_ctl[] = {
{
.shift = 0,
.reg = PCM6260_REG_CH1_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM6260_REG_CH2_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM6260_REG_CH3_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM6260_REG_CH4_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM6260_REG_CH5_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM6260_REG_CH6_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcm9211_digi_gain_ctl[] = {
{
.shift = 0,
.reg = PCM9211_REG_CH1_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCM9211_REG_CH2_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcmd3140_digi_gain_ctl[] = {
{
.shift = 0,
.reg = PCMD3140_REG_CH1_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3140_REG_CH2_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3140_REG_CH3_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3140_REG_CH4_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcmd3140_fine_gain_ctl[] = {
{
.shift = 4,
.reg = PCMD3140_REG_CH1_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3140_REG_CH2_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3140_REG_CH3_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3140_REG_CH4_FINE_GAIN,
.max = 0xf,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcmd3180_digi_gain_ctl[] = {
{
.shift = 0,
.reg = PCMD3180_REG_CH1_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3180_REG_CH2_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3180_REG_CH3_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3180_REG_CH4_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3180_REG_CH5_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3180_REG_CH6_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3180_REG_CH7_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = PCMD3180_REG_CH8_DIGITAL_GAIN,
.max = 0xff,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control pcmd3180_fine_gain_ctl[] = {
{
.shift = 4,
.reg = PCMD3180_REG_CH1_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3180_REG_CH2_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3180_REG_CH3_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3180_REG_CH4_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3180_REG_CH5_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3180_REG_CH6_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3180_REG_CH7_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = PCMD3180_REG_CH8_FINE_GAIN,
.max = 0xf,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control taa5412_digi_vol_ctl[] = {
{
.shift = 0,
.reg = TAA5412_REG_CH1_DIGITAL_VOLUME,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = TAA5412_REG_CH2_DIGITAL_VOLUME,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = TAA5412_REG_CH3_DIGITAL_VOLUME,
.max = 0xff,
.invert = 0,
},
{
.shift = 0,
.reg = TAA5412_REG_CH4_DIGITAL_VOLUME,
.max = 0xff,
.invert = 0,
}
};
static const struct pcmdevice_mixer_control taa5412_fine_gain_ctl[] = {
{
.shift = 4,
.reg = TAA5412_REG_CH1_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = TAA5412_REG_CH2_FINE_GAIN,
.max = 0xf,
.invert = 0,
},
{
.shift = 4,
.reg = TAA5412_REG_CH3_FINE_GAIN,
.max = 0xf,
.invert = 4,
},
{
.shift = 0,
.reg = TAA5412_REG_CH4_FINE_GAIN,
.max = 0xf,
.invert = 4,
}
};
static const DECLARE_TLV_DB_MINMAX_MUTE(pcmd3140_dig_gain_tlv,
-10000, 2700);
static const DECLARE_TLV_DB_MINMAX_MUTE(pcm1690_fine_dig_gain_tlv,
-12750, 0);
static const DECLARE_TLV_DB_MINMAX_MUTE(pcm1690_dig_gain_tlv,
-25500, 0);
static const DECLARE_TLV_DB_MINMAX_MUTE(pcm9211_dig_gain_tlv,
-11450, 2000);
static const DECLARE_TLV_DB_MINMAX_MUTE(adc5120_fgain_tlv,
-10050, 2700);
static const DECLARE_TLV_DB_LINEAR(adc5120_chgain_tlv, 0, 4200);
static const DECLARE_TLV_DB_MINMAX_MUTE(pcm6260_fgain_tlv,
-10000, 2700);
static const DECLARE_TLV_DB_LINEAR(pcm6260_chgain_tlv, 0, 4200);
static const DECLARE_TLV_DB_MINMAX_MUTE(taa5412_dig_vol_tlv,
-8050, 4700);
static const DECLARE_TLV_DB_LINEAR(taa5412_fine_gain_tlv,
-80, 70);
static int pcmdev_change_dev(struct pcmdevice_priv *pcm_priv,
unsigned short dev_no)
{
struct i2c_client *client = (struct i2c_client *)pcm_priv->client;
struct regmap *map = pcm_priv->regmap;
int ret;
if (client->addr == pcm_priv->addr[dev_no])
return 0;
client->addr = pcm_priv->addr[dev_no];
ret = regmap_write(map, PCMDEVICE_PAGE_SELECT, 0);
if (ret < 0)
dev_err(pcm_priv->dev, "%s: err = %d\n", __func__, ret);
return ret;
}
static int pcmdev_dev_read(struct pcmdevice_priv *pcm_dev,
unsigned int dev_no, unsigned int reg, unsigned int *val)
{
struct regmap *map = pcm_dev->regmap;
int ret;
if (dev_no >= pcm_dev->ndev) {
dev_err(pcm_dev->dev, "%s: no such channel(%d)\n", __func__,
dev_no);
return -EINVAL;
}
ret = pcmdev_change_dev(pcm_dev, dev_no);
if (ret < 0) {
dev_err(pcm_dev->dev, "%s: chg dev err = %d\n", __func__, ret);
return ret;
}
ret = regmap_read(map, reg, val);
if (ret < 0)
dev_err(pcm_dev->dev, "%s: err = %d\n", __func__, ret);
return ret;
}
static int pcmdev_dev_update_bits(struct pcmdevice_priv *pcm_dev,
unsigned int dev_no, unsigned int reg, unsigned int mask,
unsigned int value)
{
struct regmap *map = pcm_dev->regmap;
int ret;
if (dev_no >= pcm_dev->ndev) {
dev_err(pcm_dev->dev, "%s: no such channel(%d)\n", __func__,
dev_no);
return -EINVAL;
}
ret = pcmdev_change_dev(pcm_dev, dev_no);
if (ret < 0) {
dev_err(pcm_dev->dev, "%s: chg dev err = %d\n", __func__, ret);
return ret;
}
ret = regmap_update_bits(map, reg, mask, value);
if (ret < 0)
dev_err(pcm_dev->dev, "%s: update_bits err=%d\n",
__func__, ret);
return ret;
}
static int pcmdev_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol, int vol_ctrl_type)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct pcmdevice_priv *pcm_dev =
snd_soc_component_get_drvdata(component);
struct pcmdevice_mixer_control *mc =
(struct pcmdevice_mixer_control *)kcontrol->private_value;
int max = mc->max, ret;
unsigned int mask = BIT(fls(max)) - 1;
unsigned int dev_no = mc->dev_no;
unsigned int shift = mc->shift;
unsigned int reg = mc->reg;
unsigned int val;
guard(mutex)(&pcm_dev->codec_lock);
if (pcm_dev->chip_id == PCM1690) {
ret = pcmdev_dev_read(pcm_dev, dev_no, PCM1690_REG_MODE_CTRL,
&val);
if (ret) {
dev_err(pcm_dev->dev, "%s: read mode err=%d\n",
__func__, ret);
return ret;
}
val &= PCM1690_REG_MODE_CTRL_DAMS_MSK;
if (!val && vol_ctrl_type == PCMDEV_PCM1690_VOL_CTRL) {
ucontrol->value.integer.value[0] = -25500;
return 0;
}
if (val && vol_ctrl_type == PCMDEV_PCM1690_FINE_VOL_CTRL) {
ucontrol->value.integer.value[0] = -12750;
return 0;
}
}
ret = pcmdev_dev_read(pcm_dev, dev_no, reg, &val);
if (ret) {
dev_err(pcm_dev->dev, "%s: read err=%d\n",
__func__, ret);
return ret;
}
val = (val >> shift) & mask;
val = (val > max) ? max : val;
val = mc->invert ? max - val : val;
ucontrol->value.integer.value[0] = val;
return 0;
}
static int pcmdevice_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return pcmdev_get_volsw(kcontrol, ucontrol, PCMDEV_GENERIC_VOL_CTRL);
}
static int pcm1690_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return pcmdev_get_volsw(kcontrol, ucontrol, PCMDEV_PCM1690_VOL_CTRL);
}
static int pcm1690_get_finevolsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return pcmdev_get_volsw(kcontrol, ucontrol,
PCMDEV_PCM1690_FINE_VOL_CTRL);
}
static int pcmdev_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol, int vol_ctrl_type)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct pcmdevice_priv *pcm_dev =
snd_soc_component_get_drvdata(component);
struct pcmdevice_mixer_control *mc =
(struct pcmdevice_mixer_control *)kcontrol->private_value;
int max = mc->max, rc;
unsigned int mask = BIT(fls(max)) - 1;
unsigned int dev_no = mc->dev_no;
unsigned int shift = mc->shift;
unsigned int val, val_mask;
unsigned int reg = mc->reg;
guard(mutex)(&pcm_dev->codec_lock);
val = ucontrol->value.integer.value[0] & mask;
val = (val > max) ? max : val;
val = mc->invert ? max - val : val;
val_mask = mask << shift;
val = val << shift;
switch (vol_ctrl_type) {
case PCMDEV_PCM1690_VOL_CTRL:
val_mask |= PCM1690_REG_MODE_CTRL_DAMS_MSK;
val |= PCM1690_REG_MODE_CTRL_DAMS_WIDE_RANGE;
break;
case PCMDEV_PCM1690_FINE_VOL_CTRL:
val_mask |= PCM1690_REG_MODE_CTRL_DAMS_MSK;
val |= PCM1690_REG_MODE_CTRL_DAMS_FINE_STEP;
break;
}
rc = pcmdev_dev_update_bits(pcm_dev, dev_no, reg, val_mask, val);
if (rc < 0)
dev_err(pcm_dev->dev, "%s: update_bits err = %d\n",
__func__, rc);
else
rc = 1;
return rc;
}
static int pcmdevice_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return pcmdev_put_volsw(kcontrol, ucontrol, PCMDEV_GENERIC_VOL_CTRL);
}
static int pcm1690_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return pcmdev_put_volsw(kcontrol, ucontrol, PCMDEV_PCM1690_VOL_CTRL);
}
static int pcm1690_put_finevolsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
return pcmdev_put_volsw(kcontrol, ucontrol,
PCMDEV_PCM1690_FINE_VOL_CTRL);
}
static const struct pcmdev_ctrl_info pcmdev_gain_ctl_info[][2] = {
{
{
.gain = adc5120_chgain_tlv,
.pcmdev_ctrl = adc5120_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = adc5120_fgain_tlv,
.pcmdev_ctrl = adc5120_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = adc5120_chgain_tlv,
.pcmdev_ctrl = adc5120_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = adc5120_fgain_tlv,
.pcmdev_ctrl = adc5120_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = adc5120_chgain_tlv,
.pcmdev_ctrl = adc5120_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = adc5120_fgain_tlv,
.pcmdev_ctrl = adc5120_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.ctrl_array_size = 0,
},
{
.ctrl_array_size = 0,
},
},
{
{
.gain = pcm1690_fine_dig_gain_tlv,
.pcmdev_ctrl = pcm1690_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm1690_digi_gain_ctl),
.get = pcm1690_get_volsw,
.put = pcm1690_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
{
.gain = pcm1690_dig_gain_tlv,
.pcmdev_ctrl = pcm1690_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm1690_digi_gain_ctl),
.get = pcm1690_get_finevolsw,
.put = pcm1690_put_finevolsw,
.pcmdev_ctrl_name_id = 2,
},
},
{
{
.gain = adc5120_chgain_tlv,
.pcmdev_ctrl = adc5120_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = adc5120_fgain_tlv,
.pcmdev_ctrl = adc5120_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = pcm6260_chgain_tlv,
.pcmdev_ctrl = pcm6240_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6240_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = pcm6260_fgain_tlv,
.pcmdev_ctrl = pcm6240_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6240_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = adc5120_chgain_tlv,
.pcmdev_ctrl = adc5120_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = adc5120_fgain_tlv,
.pcmdev_ctrl = adc5120_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = pcm6260_chgain_tlv,
.pcmdev_ctrl = pcm6240_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6240_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = pcm6260_fgain_tlv,
.pcmdev_ctrl = pcm6240_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6240_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = adc5120_chgain_tlv,
.pcmdev_ctrl = adc5120_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = adc5120_fgain_tlv,
.pcmdev_ctrl = adc5120_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(adc5120_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = pcm6260_chgain_tlv,
.pcmdev_ctrl = pcm6240_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6240_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = pcm6260_fgain_tlv,
.pcmdev_ctrl = pcm6240_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6240_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = pcm6260_chgain_tlv,
.pcmdev_ctrl = pcm6240_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6240_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = pcm6260_fgain_tlv,
.pcmdev_ctrl = pcm6240_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6240_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = pcm6260_chgain_tlv,
.pcmdev_ctrl = pcm6260_analog_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6260_analog_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 0,
},
{
.gain = pcm6260_fgain_tlv,
.pcmdev_ctrl = pcm6260_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm6260_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.ctrl_array_size = 0,
},
{
.gain = pcm9211_dig_gain_tlv,
.pcmdev_ctrl = pcm9211_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcm9211_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = taa5412_fine_gain_tlv,
.pcmdev_ctrl = pcmd3140_fine_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcmd3140_fine_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 2,
},
{
.gain = pcmd3140_dig_gain_tlv,
.pcmdev_ctrl = pcmd3140_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcmd3140_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = taa5412_fine_gain_tlv,
.pcmdev_ctrl = pcmd3180_fine_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcmd3180_fine_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 2,
},
{
.gain = pcmd3140_dig_gain_tlv,
.pcmdev_ctrl = pcmd3180_digi_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(pcmd3180_digi_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.ctrl_array_size = 0,
},
{
.ctrl_array_size = 0,
},
},
{
{
.gain = taa5412_fine_gain_tlv,
.pcmdev_ctrl = taa5412_fine_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(taa5412_fine_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 2,
},
{
.gain = taa5412_dig_vol_tlv,
.pcmdev_ctrl = taa5412_digi_vol_ctl,
.ctrl_array_size = ARRAY_SIZE(taa5412_digi_vol_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.gain = taa5412_fine_gain_tlv,
.pcmdev_ctrl = taa5412_fine_gain_ctl,
.ctrl_array_size = ARRAY_SIZE(taa5412_fine_gain_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 2,
},
{
.gain = taa5412_dig_vol_tlv,
.pcmdev_ctrl = taa5412_digi_vol_ctl,
.ctrl_array_size = ARRAY_SIZE(taa5412_digi_vol_ctl),
.get = pcmdevice_get_volsw,
.put = pcmdevice_put_volsw,
.pcmdev_ctrl_name_id = 1,
},
},
{
{
.ctrl_array_size = 0,
},
{
.ctrl_array_size = 0,
},
},
{
{
.ctrl_array_size = 0,
},
{
.ctrl_array_size = 0,
},
},
};
static int pcmdev_dev_bulk_write(struct pcmdevice_priv *pcm_dev,
unsigned int dev_no, unsigned int reg, unsigned char *data,
unsigned int len)
{
struct regmap *map = pcm_dev->regmap;
int ret;
if (dev_no >= pcm_dev->ndev) {
dev_err(pcm_dev->dev, "%s: no such channel(%d)\n", __func__,
dev_no);
return -EINVAL;
}
ret = pcmdev_change_dev(pcm_dev, dev_no);
if (ret < 0) {
dev_err(pcm_dev->dev, "%s: chg dev err = %d\n", __func__, ret);
return ret;
}
ret = regmap_bulk_write(map, reg, data, len);
if (ret < 0)
dev_err(pcm_dev->dev, "%s: bulk_write err = %d\n", __func__,
ret);
return ret;
}
static int pcmdev_dev_write(struct pcmdevice_priv *pcm_dev,
unsigned int dev_no, unsigned int reg, unsigned int value)
{
struct regmap *map = pcm_dev->regmap;
int ret;
if (dev_no >= pcm_dev->ndev) {
dev_err(pcm_dev->dev, "%s: no such channel(%d)\n", __func__,
dev_no);
return -EINVAL;
}
ret = pcmdev_change_dev(pcm_dev, dev_no);
if (ret < 0) {
dev_err(pcm_dev->dev, "%s: chg dev err = %d\n", __func__, ret);
return ret;
}
ret = regmap_write(map, reg, value);
if (ret < 0)
dev_err(pcm_dev->dev, "%s: err = %d\n", __func__, ret);
return ret;
}
static int pcmdevice_info_profile(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol);
struct pcmdevice_priv *pcm_dev =
snd_soc_component_get_drvdata(codec);
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = max(0, pcm_dev->regbin.ncfgs - 1);
return 0;
}
static int pcmdevice_get_profile_id(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol);
struct pcmdevice_priv *pcm_dev =
snd_soc_component_get_drvdata(codec);
ucontrol->value.integer.value[0] = pcm_dev->cur_conf;
return 0;
}
static int pcmdevice_set_profile_id(
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *codec = snd_kcontrol_chip(kcontrol);
struct pcmdevice_priv *pcm_dev =
snd_soc_component_get_drvdata(codec);
int nr_profile = ucontrol->value.integer.value[0];
int max = pcm_dev->regbin.ncfgs - 1;
int ret = 0;
nr_profile = clamp(nr_profile, 0, max);
if (pcm_dev->cur_conf != nr_profile) {
pcm_dev->cur_conf = nr_profile;
ret = 1;
}
return ret;
}
static int pcmdevice_info_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
struct pcmdevice_mixer_control *mc =
(struct pcmdevice_mixer_control *)kcontrol->private_value;
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = mc->max;
return 0;
}
static void pcm9211_sw_rst(struct pcmdevice_priv *pcm_dev)
{
int ret, i;
for (i = 0; i < pcm_dev->ndev; i++) {
ret = pcmdev_dev_update_bits(pcm_dev, i,
PCM9211_REG_SW_CTRL, PCM9211_REG_SW_CTRL_MRST_MSK,
PCM9211_REG_SW_CTRL_MRST);
if (ret < 0)
dev_err(pcm_dev->dev, "%s: dev %d swreset fail %d\n",
__func__, i, ret);
}
}
static void pcmdevice_sw_rst(struct pcmdevice_priv *pcm_dev)
{
int ret, i;
for (i = 0; i < pcm_dev->ndev; i++) {
ret = pcmdev_dev_write(pcm_dev, i, PCMDEVICE_REG_SWRESET,
PCMDEVICE_REG_SWRESET_RESET);
if (ret < 0)
dev_err(pcm_dev->dev, "%s: dev %d swreset fail %d\n",
__func__, i, ret);
}
}
static struct pcmdevice_config_info *pcmdevice_add_config(void *ctxt,
const unsigned char *config_data, unsigned int config_size,
int *status)
{
struct pcmdevice_priv *pcm_dev = (struct pcmdevice_priv *)ctxt;
struct pcmdevice_config_info *cfg_info = NULL;
struct pcmdevice_block_data **bk_da;
char cfg_name[64] = {};
unsigned int config_offset = 0, i;
unsigned int nblocks;
if (pcm_dev->regbin.fw_hdr.binary_version_num >= 0x105) {
if (config_offset + 64 > (int)config_size) {
*status = -EINVAL;
dev_err(pcm_dev->dev,
"%s: cfg_name out of boundary\n", __func__);
goto out;
}
memcpy(cfg_name, &config_data[config_offset], 64);
config_offset += 64;
}
if (config_offset + 4 > config_size) {
*status = -EINVAL;
dev_err(pcm_dev->dev, "%s: nblocks out of boundary\n",
__func__);
goto out;
}
nblocks = get_unaligned_be32(&config_data[config_offset]);
config_offset += 4;
cfg_info = kzalloc_flex(*cfg_info, blk_data, nblocks);
if (!cfg_info) {
*status = -ENOMEM;
goto out;
}
cfg_info->nblocks = nblocks;
memcpy(cfg_info->cfg_name, cfg_name, sizeof(cfg_info->cfg_name));
bk_da = cfg_info->blk_data;
cfg_info->real_nblocks = 0;
for (i = 0; i < cfg_info->nblocks; i++) {
if (config_offset + 12 > config_size) {
*status = -EINVAL;
dev_err(pcm_dev->dev,
"%s: out of boundary i = %d nblocks = %u\n",
__func__, i, cfg_info->nblocks);
break;
}
bk_da[i] = kzalloc_obj(struct pcmdevice_block_data);
if (!bk_da[i]) {
*status = -ENOMEM;
break;
}
bk_da[i]->dev_idx = config_data[config_offset];
config_offset++;
bk_da[i]->block_type = config_data[config_offset];
config_offset++;
if (bk_da[i]->block_type == PCMDEVICE_BIN_BLK_PRE_POWER_UP) {
if (bk_da[i]->dev_idx == 0)
cfg_info->active_dev =
(1 << pcm_dev->ndev) - 1;
else
cfg_info->active_dev =
1 << (bk_da[i]->dev_idx - 1);
}
bk_da[i]->yram_checksum =
get_unaligned_be16(&config_data[config_offset]);
config_offset += 2;
bk_da[i]->block_size =
get_unaligned_be32(&config_data[config_offset]);
config_offset += 4;
bk_da[i]->n_subblks =
get_unaligned_be32(&config_data[config_offset]);
config_offset += 4;
if (config_offset + bk_da[i]->block_size > config_size) {
*status = -EINVAL;
dev_err(pcm_dev->dev,
"%s: out of boundary: i = %d blks = %u\n",
__func__, i, cfg_info->nblocks);
break;
}
bk_da[i]->regdata = kmemdup(&config_data[config_offset],
bk_da[i]->block_size, GFP_KERNEL);
if (!bk_da[i]->regdata) {
*status = -ENOMEM;
goto out;
}
config_offset += bk_da[i]->block_size;
cfg_info->real_nblocks += 1;
}
out:
return cfg_info;
}
static int pcmdev_gain_ctrl_add(struct pcmdevice_priv *pcm_dev,
int dev_no, int ctl_id)
{
struct i2c_adapter *adap = pcm_dev->client->adapter;
struct snd_soc_component *comp = pcm_dev->component;
struct pcmdevice_mixer_control *pcmdev_ctrl;
struct snd_kcontrol_new *pcmdev_controls;
int ret, mix_index = 0, name_id, chn;
unsigned int id = pcm_dev->chip_id;
const int nr_chn =
pcmdev_gain_ctl_info[id][ctl_id].ctrl_array_size;
const char *ctrl_name;
char *name;
if (!nr_chn) {
dev_dbg(pcm_dev->dev, "%s: no gain ctrl for %s\n", __func__,
pcm_dev->dev_name);
return 0;
}
pcmdev_controls = devm_kzalloc_objs(pcm_dev->dev,
struct snd_kcontrol_new, nr_chn);
if (!pcmdev_controls)
return -ENOMEM;
name_id = pcmdev_gain_ctl_info[id][ctl_id].pcmdev_ctrl_name_id;
ctrl_name = pcmdev_ctrl_name[name_id];
for (chn = 1; chn <= nr_chn; chn++) {
name = devm_kzalloc(pcm_dev->dev,
SNDRV_CTL_ELEM_ID_NAME_MAXLEN, GFP_KERNEL);
if (!name) {
ret = -ENOMEM;
goto out;
}
scnprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
ctrl_name, pcm_dev->upper_dev_name, adap->nr,
dev_no, chn);
pcmdev_controls[mix_index].tlv.p =
pcmdev_gain_ctl_info[id][ctl_id].gain;
pcmdev_ctrl = devm_kmemdup(pcm_dev->dev,
&pcmdev_gain_ctl_info[id][ctl_id].pcmdev_ctrl[chn - 1],
sizeof(*pcmdev_ctrl), GFP_KERNEL);
if (!pcmdev_ctrl) {
ret = -ENOMEM;
goto out;
}
pcmdev_ctrl->dev_no = dev_no;
pcmdev_controls[mix_index].private_value =
(unsigned long)pcmdev_ctrl;
pcmdev_controls[mix_index].name = name;
pcmdev_controls[mix_index].access =
SNDRV_CTL_ELEM_ACCESS_TLV_READ |
SNDRV_CTL_ELEM_ACCESS_READWRITE;
pcmdev_controls[mix_index].iface =
SNDRV_CTL_ELEM_IFACE_MIXER;
pcmdev_controls[mix_index].info = pcmdevice_info_volsw;
pcmdev_controls[mix_index].get =
pcmdev_gain_ctl_info[id][ctl_id].get;
pcmdev_controls[mix_index].put =
pcmdev_gain_ctl_info[id][ctl_id].put;
mix_index++;
}
ret = snd_soc_add_component_controls(comp, pcmdev_controls, mix_index);
if (ret)
dev_err(pcm_dev->dev, "%s: add_controls err = %d\n",
__func__, ret);
out:
return ret;
}
static int pcmdev_profile_ctrl_add(struct pcmdevice_priv *pcm_dev)
{
struct snd_soc_component *comp = pcm_dev->component;
struct i2c_adapter *adap = pcm_dev->client->adapter;
struct snd_kcontrol_new *pcmdev_ctrl;
char *name;
int ret;
pcmdev_ctrl = devm_kzalloc_obj(pcm_dev->dev, struct snd_kcontrol_new);
if (!pcmdev_ctrl)
return -ENOMEM;
name = devm_kzalloc(pcm_dev->dev, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
GFP_KERNEL);
if (!name)
return -ENOMEM;
scnprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
"%s i2c%d Profile id", pcm_dev->upper_dev_name, adap->nr);
pcmdev_ctrl->name = name;
pcmdev_ctrl->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
pcmdev_ctrl->info = pcmdevice_info_profile;
pcmdev_ctrl->get = pcmdevice_get_profile_id;
pcmdev_ctrl->put = pcmdevice_set_profile_id;
ret = snd_soc_add_component_controls(comp, pcmdev_ctrl, 1);
if (ret)
dev_err(pcm_dev->dev, "%s: add_controls err = %d\n",
__func__, ret);
return ret;
}
static void pcmdevice_config_info_remove(void *ctxt)
{
struct pcmdevice_priv *pcm_dev = (struct pcmdevice_priv *) ctxt;
struct pcmdevice_regbin *regbin = &(pcm_dev->regbin);
struct pcmdevice_config_info **cfg_info = regbin->cfg_info;
int i, j;
if (!cfg_info)
return;
for (i = 0; i < regbin->ncfgs; i++) {
if (!cfg_info[i])
continue;
for (j = 0; j < (int)cfg_info[i]->real_nblocks; j++) {
if (!cfg_info[i]->blk_data[j])
continue;
kfree(cfg_info[i]->blk_data[j]->regdata);
kfree(cfg_info[i]->blk_data[j]);
}
kfree(cfg_info[i]);
}
kfree(cfg_info);
}
static int pcmdev_regbin_ready(const struct firmware *fmw, void *ctxt)
{
struct pcmdevice_config_info **cfg_info;
struct pcmdevice_priv *pcm_dev = ctxt;
struct pcmdevice_regbin_hdr *fw_hdr;
struct pcmdevice_regbin *regbin;
unsigned int total_config_sz = 0;
int offset = 0, ret = 0, i;
unsigned char *buf;
regbin = &(pcm_dev->regbin);
fw_hdr = &(regbin->fw_hdr);
if (!fmw || !fmw->data) {
dev_err(pcm_dev->dev, "%s: failed to read %s\n",
__func__, pcm_dev->bin_name);
pcm_dev->fw_state = PCMDEVICE_FW_LOAD_FAILED;
ret = -EINVAL;
goto out;
}
buf = (unsigned char *)fmw->data;
fw_hdr->img_sz = get_unaligned_be32(&buf[offset]);
offset += 4;
if (fw_hdr->img_sz != fmw->size) {
dev_err(pcm_dev->dev, "%s: file size(%d) not match %u",
__func__, (int)fmw->size, fw_hdr->img_sz);
pcm_dev->fw_state = PCMDEVICE_FW_LOAD_FAILED;
ret = -EINVAL;
goto out;
}
fw_hdr->checksum = get_unaligned_be32(&buf[offset]);
offset += 4;
fw_hdr->binary_version_num = get_unaligned_be32(&buf[offset]);
if (fw_hdr->binary_version_num < 0x103) {
dev_err(pcm_dev->dev, "%s: bin version 0x%04x is out of date",
__func__, fw_hdr->binary_version_num);
pcm_dev->fw_state = PCMDEVICE_FW_LOAD_FAILED;
ret = -EINVAL;
goto out;
}
offset += 4;
fw_hdr->drv_fw_version = get_unaligned_be32(&buf[offset]);
offset += 8;
fw_hdr->plat_type = buf[offset];
offset += 1;
fw_hdr->dev_family = buf[offset];
offset += 1;
fw_hdr->reserve = buf[offset];
offset += 1;
fw_hdr->ndev = buf[offset];
offset += 1;
if (fw_hdr->ndev != pcm_dev->ndev) {
dev_err(pcm_dev->dev, "%s: invalid ndev(%u)\n", __func__,
fw_hdr->ndev);
pcm_dev->fw_state = PCMDEVICE_FW_LOAD_FAILED;
ret = -EINVAL;
goto out;
}
if (offset + PCMDEVICE_MAX_REGBIN_DEVICES > fw_hdr->img_sz) {
dev_err(pcm_dev->dev, "%s: devs out of boundary!\n", __func__);
pcm_dev->fw_state = PCMDEVICE_FW_LOAD_FAILED;
ret = -EINVAL;
goto out;
}
for (i = 0; i < PCMDEVICE_MAX_REGBIN_DEVICES; i++, offset++)
fw_hdr->devs[i] = buf[offset];
fw_hdr->nconfig = get_unaligned_be32(&buf[offset]);
offset += 4;
for (i = 0; i < PCMDEVICE_CONFIG_SUM; i++) {
fw_hdr->config_size[i] = get_unaligned_be32(&buf[offset]);
offset += 4;
total_config_sz += fw_hdr->config_size[i];
}
if (fw_hdr->img_sz - total_config_sz != (unsigned int)offset) {
dev_err(pcm_dev->dev, "%s: bin file error!\n", __func__);
pcm_dev->fw_state = PCMDEVICE_FW_LOAD_FAILED;
ret = -EINVAL;
goto out;
}
cfg_info = kzalloc_objs(*cfg_info, fw_hdr->nconfig);
if (!cfg_info) {
pcm_dev->fw_state = PCMDEVICE_FW_LOAD_FAILED;
ret = -ENOMEM;
goto out;
}
regbin->cfg_info = cfg_info;
regbin->ncfgs = 0;
for (i = 0; i < (int)fw_hdr->nconfig; i++) {
cfg_info[i] = pcmdevice_add_config(ctxt, &buf[offset],
fw_hdr->config_size[i], &ret);
if (ret) {
if (regbin->ncfgs == 0)
pcm_dev->fw_state = PCMDEVICE_FW_LOAD_FAILED;
break;
}
offset += (int)fw_hdr->config_size[i];
regbin->ncfgs += 1;
}
out:
if (pcm_dev->fw_state == PCMDEVICE_FW_LOAD_FAILED) {
dev_err(pcm_dev->dev,
"%s: remove config due to fw load error!\n", __func__);
pcmdevice_config_info_remove(pcm_dev);
}
return ret;
}
static int pcmdevice_comp_probe(struct snd_soc_component *comp)
{
struct pcmdevice_priv *pcm_dev = snd_soc_component_get_drvdata(comp);
struct i2c_adapter *adap = pcm_dev->client->adapter;
const struct firmware *fw_entry __free(firmware) = NULL;
int ret, i, j;
guard(mutex)(&pcm_dev->codec_lock);
pcm_dev->component = comp;
for (i = 0; i < pcm_dev->ndev; i++) {
for (j = 0; j < 2; j++) {
ret = pcmdev_gain_ctrl_add(pcm_dev, i, j);
if (ret < 0)
return ret;
}
}
if (comp->name_prefix) {
scnprintf(pcm_dev->bin_name, PCMDEVICE_BIN_FILENAME_LEN,
"%s.bin", comp->name_prefix);
} else {
scnprintf(pcm_dev->bin_name, PCMDEVICE_BIN_FILENAME_LEN,
"%s-i2c-%d-%udev.bin", pcm_dev->dev_name, adap->nr,
pcm_dev->ndev);
}
ret = request_firmware(&fw_entry, pcm_dev->bin_name, pcm_dev->dev);
if (ret) {
dev_err(pcm_dev->dev, "%s: request %s err = %d\n", __func__,
pcm_dev->bin_name, ret);
return ret;
}
ret = pcmdev_regbin_ready(fw_entry, pcm_dev);
if (ret) {
dev_err(pcm_dev->dev, "%s: %s parse err = %d\n", __func__,
pcm_dev->bin_name, ret);
return ret;
}
return pcmdev_profile_ctrl_add(pcm_dev);
}
static void pcmdevice_comp_remove(struct snd_soc_component *codec)
{
struct pcmdevice_priv *pcm_dev = snd_soc_component_get_drvdata(codec);
if (!pcm_dev)
return;
guard(mutex)(&pcm_dev->codec_lock);
pcmdevice_config_info_remove(pcm_dev);
}
static const struct snd_soc_dapm_widget pcmdevice_dapm_widgets[] = {
SND_SOC_DAPM_AIF_IN("ASI", "ASI Playback", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_OUT("ASI1 OUT", "ASI1 Capture",
0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_OUTPUT("OUT"),
SND_SOC_DAPM_INPUT("MIC"),
};
static const struct snd_soc_dapm_route pcmdevice_audio_map[] = {
{"OUT", NULL, "ASI"},
{"ASI1 OUT", NULL, "MIC"},
};
static const struct snd_soc_component_driver
soc_codec_driver_pcmdevice = {
.probe = pcmdevice_comp_probe,
.remove = pcmdevice_comp_remove,
.dapm_widgets = pcmdevice_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(pcmdevice_dapm_widgets),
.dapm_routes = pcmdevice_audio_map,
.num_dapm_routes = ARRAY_SIZE(pcmdevice_audio_map),
.suspend_bias_off = 1,
.idle_bias_on = 0,
.use_pmdown_time = 1,
.endianness = 1,
};
static int pcmdev_single_byte_wr(struct pcmdevice_priv *pcm_dev,
unsigned char *data, int devn, int sublocksize)
{
unsigned short len = get_unaligned_be16(&data[2]);
int offset = 2;
int i, ret;
offset += 2;
if (offset + 4 * len > sublocksize) {
dev_err(pcm_dev->dev, "%s: dev-%d byt wr out of boundary\n",
__func__, devn);
return -EINVAL;
}
for (i = 0; i < len; i++) {
ret = pcmdev_dev_write(pcm_dev, devn,
PCMDEVICE_REG(data[offset + 1], data[offset + 2]),
data[offset + 3]);
if (ret < 0)
dev_err(pcm_dev->dev, "%s: dev-%d single write err\n",
__func__, devn);
offset += 4;
}
return offset;
}
static int pcmdev_burst_wr(struct pcmdevice_priv *pcm_dev,
unsigned char *data, int devn, int sublocksize)
{
unsigned short len = get_unaligned_be16(&data[2]);
int offset = 2;
int ret;
offset += 2;
if (offset + 4 + len > sublocksize) {
dev_err(pcm_dev->dev, "%s: dev-%d burst Out of boundary\n",
__func__, devn);
return -EINVAL;
}
if (len % 4) {
dev_err(pcm_dev->dev, "%s: dev-%d bst-len(%u) not div by 4\n",
__func__, devn, len);
return -EINVAL;
}
ret = pcmdev_dev_bulk_write(pcm_dev, devn,
PCMDEVICE_REG(data[offset + 1], data[offset + 2]),
&(data[offset + 4]), len);
if (ret < 0)
dev_err(pcm_dev->dev, "%s: dev-%d bulk_write err = %d\n",
__func__, devn, ret);
offset += (len + 4);
return offset;
}
static int pcmdev_delay(struct pcmdevice_priv *pcm_dev,
unsigned char *data, int devn, int sublocksize)
{
unsigned int delay_time = 0;
int offset = 2;
if (offset + 2 > sublocksize) {
dev_err(pcm_dev->dev, "%s: dev-%d delay out of boundary\n",
__func__, devn);
return -EINVAL;
}
delay_time = get_unaligned_be16(&data[2]) * 1000;
usleep_range(delay_time, delay_time + 50);
offset += 2;
return offset;
}
static int pcmdev_bits_wr(struct pcmdevice_priv *pcm_dev,
unsigned char *data, int devn, int sublocksize)
{
int offset = 2;
int ret;
if (offset + 6 > sublocksize) {
dev_err(pcm_dev->dev, "%s: dev-%d bit write out of memory\n",
__func__, devn);
return -EINVAL;
}
ret = pcmdev_dev_update_bits(pcm_dev, devn,
PCMDEVICE_REG(data[offset + 3], data[offset + 4]),
data[offset + 1], data[offset + 5]);
if (ret < 0)
dev_err(pcm_dev->dev, "%s: dev-%d update_bits err = %d\n",
__func__, devn, ret);
offset += 6;
return offset;
}
static int pcmdevice_process_block(void *ctxt, unsigned char *data,
unsigned char dev_idx, int sublocksize)
{
struct pcmdevice_priv *pcm_dev = (struct pcmdevice_priv *)ctxt;
int devn, dev_end, ret = 0;
unsigned char subblk_typ = data[1];
if (dev_idx) {
devn = dev_idx - 1;
dev_end = dev_idx;
} else {
devn = 0;
dev_end = pcm_dev->ndev;
}
for (; devn < dev_end; devn++) {
switch (subblk_typ) {
case PCMDEVICE_CMD_SING_W:
ret = pcmdev_single_byte_wr(pcm_dev, data, devn, sublocksize);
break;
case PCMDEVICE_CMD_BURST:
ret = pcmdev_burst_wr(pcm_dev, data, devn, sublocksize);
break;
case PCMDEVICE_CMD_DELAY:
ret = pcmdev_delay(pcm_dev, data, devn, sublocksize);
break;
case PCMDEVICE_CMD_FIELD_W:
ret = pcmdev_bits_wr(pcm_dev, data, devn, sublocksize);
break;
default:
break;
}
if (ret < 0)
break;
}
return ret;
}
static void pcmdevice_select_cfg_blk(void *ctxt, int conf_no,
unsigned char block_type)
{
struct pcmdevice_priv *pcm_dev = (struct pcmdevice_priv *)ctxt;
struct pcmdevice_regbin *regbin = &(pcm_dev->regbin);
struct pcmdevice_config_info **cfg_info = regbin->cfg_info;
struct pcmdevice_block_data **blk_data;
int j, k;
if (conf_no >= regbin->ncfgs || conf_no < 0 || NULL == cfg_info) {
dev_err(pcm_dev->dev, "%s: conf_no should be less than %u\n",
__func__, regbin->ncfgs);
goto out;
}
blk_data = cfg_info[conf_no]->blk_data;
for (j = 0; j < (int)cfg_info[conf_no]->real_nblocks; j++) {
unsigned int length = 0, ret;
if (block_type > 5 || block_type < 2) {
dev_err(pcm_dev->dev,
"%s: block_type should be out of range\n",
__func__);
goto out;
}
if (block_type != blk_data[j]->block_type)
continue;
for (k = 0; k < (int)blk_data[j]->n_subblks; k++) {
ret = pcmdevice_process_block(pcm_dev,
blk_data[j]->regdata + length,
blk_data[j]->dev_idx,
blk_data[j]->block_size - length);
length += ret;
if (blk_data[j]->block_size < length) {
dev_err(pcm_dev->dev,
"%s: %u %u out of boundary\n",
__func__, length,
blk_data[j]->block_size);
break;
}
}
if (length != blk_data[j]->block_size)
dev_err(pcm_dev->dev, "%s: %u %u size is not same\n",
__func__, length, blk_data[j]->block_size);
}
out:
return;
}
static int pcmdevice_mute(struct snd_soc_dai *dai, int mute, int stream)
{
struct snd_soc_component *codec = dai->component;
struct pcmdevice_priv *pcm_dev = snd_soc_component_get_drvdata(codec);
unsigned char block_type;
if (pcm_dev->fw_state == PCMDEVICE_FW_LOAD_FAILED) {
dev_err(pcm_dev->dev, "%s: bin file not loaded\n", __func__);
return -EINVAL;
}
if (mute)
block_type = PCMDEVICE_BIN_BLK_PRE_SHUTDOWN;
else
block_type = PCMDEVICE_BIN_BLK_PRE_POWER_UP;
guard(mutex)(&pcm_dev->codec_lock);
pcmdevice_select_cfg_blk(pcm_dev, pcm_dev->cur_conf, block_type);
return 0;
}
static int pcmdevice_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
struct pcmdevice_priv *pcm_dev = snd_soc_dai_get_drvdata(dai);
unsigned int fsrate;
unsigned int slot_width;
int bclk_rate;
int ret = 0;
fsrate = params_rate(params);
switch (fsrate) {
case 48000:
break;
case 44100:
break;
default:
dev_err(pcm_dev->dev, "%s: incorrect sample rate = %u\n",
__func__, fsrate);
ret = -EINVAL;
goto out;
}
slot_width = params_width(params);
switch (slot_width) {
case 16:
break;
case 20:
break;
case 24:
break;
case 32:
break;
default:
dev_err(pcm_dev->dev, "%s: incorrect slot width = %u\n",
__func__, slot_width);
ret = -EINVAL;
goto out;
}
bclk_rate = snd_soc_params_to_bclk(params);
if (bclk_rate < 0) {
dev_err(pcm_dev->dev, "%s: incorrect bclk rate = %d\n",
__func__, bclk_rate);
ret = bclk_rate;
}
out:
return ret;
}
static const struct snd_soc_dai_ops pcmdevice_dai_ops = {
.mute_stream = pcmdevice_mute,
.hw_params = pcmdevice_hw_params,
};
static struct snd_soc_dai_driver pcmdevice_dai_driver[] = {
{
.name = "pcmdevice-codec",
.capture = {
.stream_name = "Capture",
.channels_min = 2,
.channels_max = PCMDEVICE_MAX_CHANNELS,
.rates = PCMDEVICE_RATES,
.formats = PCMDEVICE_FORMATS,
},
.playback = {
.stream_name = "Playback",
.channels_min = 2,
.channels_max = PCMDEVICE_MAX_CHANNELS,
.rates = PCMDEVICE_RATES,
.formats = PCMDEVICE_FORMATS,
},
.ops = &pcmdevice_dai_ops,
.symmetric_rate = 1,
}
};
#ifdef CONFIG_OF
static const struct of_device_id pcmdevice_of_match[] = {
{ .compatible = "ti,adc3120" },
{ .compatible = "ti,adc5120" },
{ .compatible = "ti,adc6120" },
{ .compatible = "ti,dix4192" },
{ .compatible = "ti,pcm1690" },
{ .compatible = "ti,pcm3120" },
{ .compatible = "ti,pcm3140" },
{ .compatible = "ti,pcm5120" },
{ .compatible = "ti,pcm5140" },
{ .compatible = "ti,pcm6120" },
{ .compatible = "ti,pcm6140" },
{ .compatible = "ti,pcm6240" },
{ .compatible = "ti,pcm6260" },
{ .compatible = "ti,pcm9211" },
{ .compatible = "ti,pcmd3140" },
{ .compatible = "ti,pcmd3180" },
{ .compatible = "ti,pcmd512x" },
{ .compatible = "ti,taa5212" },
{ .compatible = "ti,taa5412" },
{ .compatible = "ti,tad5212" },
{ .compatible = "ti,tad5412" },
{},
};
MODULE_DEVICE_TABLE(of, pcmdevice_of_match);
#endif
static const struct regmap_range_cfg pcmdevice_ranges[] = {
{
.range_min = 0,
.range_max = 256 * 128,
.selector_reg = PCMDEVICE_PAGE_SELECT,
.selector_mask = 0xff,
.selector_shift = 0,
.window_start = 0,
.window_len = 128,
},
};
static const struct regmap_config pcmdevice_i2c_regmap = {
.reg_bits = 8,
.val_bits = 8,
.cache_type = REGCACHE_MAPLE,
.ranges = pcmdevice_ranges,
.num_ranges = ARRAY_SIZE(pcmdevice_ranges),
.max_register = 256 * 128,
};
static void pcmdevice_remove(struct pcmdevice_priv *pcm_dev)
{
mutex_destroy(&pcm_dev->codec_lock);
}
static char *str_to_upper(char *str)
{
char *orig = str;
if (!str)
return NULL;
while (*str) {
*str = toupper(*str);
str++;
}
return orig;
}
static int pcmdevice_i2c_probe(struct i2c_client *i2c)
{
struct pcmdevice_priv *pcm_dev;
struct device_node *np;
unsigned int dev_addrs[PCMDEVICE_MAX_I2C_DEVICES];
int ret = 0, i = 0, ndev = 0;
pcm_dev = devm_kzalloc_obj(&i2c->dev, *pcm_dev);
if (!pcm_dev)
return -ENOMEM;
pcm_dev->chip_id = (uintptr_t)i2c_get_match_data(i2c);
pcm_dev->dev = &i2c->dev;
pcm_dev->client = i2c;
if (pcm_dev->chip_id >= MAX_DEVICE)
pcm_dev->chip_id = 0;
strscpy(pcm_dev->dev_name, pcmdevice_i2c_id[pcm_dev->chip_id].name,
sizeof(pcm_dev->dev_name));
strscpy(pcm_dev->upper_dev_name,
pcmdevice_i2c_id[pcm_dev->chip_id].name,
sizeof(pcm_dev->upper_dev_name));
str_to_upper(pcm_dev->upper_dev_name);
pcm_dev->regmap = devm_regmap_init_i2c(i2c, &pcmdevice_i2c_regmap);
if (IS_ERR(pcm_dev->regmap)) {
ret = PTR_ERR(pcm_dev->regmap);
dev_err(&i2c->dev, "%s: failed to allocate register map: %d\n",
__func__, ret);
goto out;
}
i2c_set_clientdata(i2c, pcm_dev);
mutex_init(&pcm_dev->codec_lock);
np = pcm_dev->dev->of_node;
if (IS_ENABLED(CONFIG_OF)) {
u64 addr;
for (i = 0; i < PCMDEVICE_MAX_I2C_DEVICES; i++) {
if (of_property_read_reg(np, i, &addr, NULL))
break;
dev_addrs[ndev++] = addr;
}
} else {
ndev = 1;
dev_addrs[0] = i2c->addr;
}
pcm_dev->irq = of_irq_get(np, 0);
for (i = 0; i < ndev; i++)
pcm_dev->addr[i] = dev_addrs[i];
pcm_dev->ndev = ndev;
pcm_dev->hw_rst = devm_gpiod_get_optional(&i2c->dev,
"reset-gpios", GPIOD_OUT_HIGH);
if (IS_ERR(pcm_dev->hw_rst)) {
if (pcm_dev->chip_id == PCM9211 || pcm_dev->chip_id == PCM1690)
pcm9211_sw_rst(pcm_dev);
else
pcmdevice_sw_rst(pcm_dev);
} else {
gpiod_set_value_cansleep(pcm_dev->hw_rst, 0);
usleep_range(500, 1000);
gpiod_set_value_cansleep(pcm_dev->hw_rst, 1);
}
if (pcm_dev->chip_id == PCM1690)
goto skip_interrupt;
if (pcm_dev->irq) {
dev_dbg(pcm_dev->dev, "irq = %d", pcm_dev->irq);
} else
dev_err(pcm_dev->dev, "No irq provided\n");
skip_interrupt:
ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_driver_pcmdevice, pcmdevice_dai_driver,
ARRAY_SIZE(pcmdevice_dai_driver));
if (ret < 0)
dev_err(&i2c->dev, "probe register comp failed %d\n", ret);
out:
if (ret < 0)
pcmdevice_remove(pcm_dev);
return ret;
}
static void pcmdevice_i2c_remove(struct i2c_client *i2c)
{
struct pcmdevice_priv *pcm_dev = i2c_get_clientdata(i2c);
pcmdevice_remove(pcm_dev);
}
static struct i2c_driver pcmdevice_i2c_driver = {
.driver = {
.name = "pcmdevice-codec",
.of_match_table = of_match_ptr(pcmdevice_of_match),
},
.probe = pcmdevice_i2c_probe,
.remove = pcmdevice_i2c_remove,
.id_table = pcmdevice_i2c_id,
};
module_i2c_driver(pcmdevice_i2c_driver);
MODULE_AUTHOR("Shenghao Ding <shenghao-ding@ti.com>");
MODULE_DESCRIPTION("ASoC PCM6240 Family Audio ADC/DAC Driver");
MODULE_LICENSE("GPL");