123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw_type.h>
#include <linux/workqueue.h>
#include <sound/pcm.h>
#include <sound/sdca.h>
#include <sound/sdca_class.h>
#include <sound/sdca_function.h>
#include <sound/soc.h>
#include <sound/soc-dai.h>
#include "wcd9378-sdca.h"
struct wcd9378_priv {
struct sdca_class_drv class;
};
static struct sdca_entity wcd9378_sdca_entities[];
#define QSJ_IT41 0
#define QSJ_CS41 1
#define QSJ_MFPU21 2
#define QSJ_XU42 3
#define QSJ_SU43 4
#define QSJ_SU45 5
#define QSJ_PDE47 6
#define QSJ_OT43 7
#define QSJ_OT45 8
#define QSJ_GE35 9
#define QSJ_IT131 10
#define QSJ_CS131 11
#define QSJ_IT33 12
#define QSJ_PDE34 13
#define QSJ_FU33 14
#define QSJ_SU35 15
#define QSJ_XU36 16
#define QSJ_CS36 17
#define QSJ_OT36 18
#define QSJ_MFPU236 19
#define QSJ_CS236 20
#define QSJ_OT236 21
#define QSJ_FU6 22
static u32 range_it41_usage_data[] = {
0x2, 0x2d0, 0xbb80, 0x10, 0x0, 0x0, 0x0,
};
static u32 range_it41_cluster_data[] = { 0x1, 0x1 };
static u32 range_it41_dp_data[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
static u32 range_cs41_sr_data[] = { 0x1, 0xbb80 };
static u32 range_su_sel_data[] = { 0x0, 0x1 };
static u32 range_pde_req_ps_data[] = { 0x0, 0x3 };
static u32 range_ge35_mode_data[] = {
0x0, 0x6c0,
0x1, 0x6c0,
0x3, 0x6d0,
0x4, 0x6c0,
};
static u32 range_it131_usage_data[] = {
0x3, 0x334, 0x2ee00, 0x8, 0x0, 0x0, 0x0,
};
static u32 range_it131_cluster_data[] = { 0x1, 0x3 };
static u32 range_it131_dp_data[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
static u32 range_cs131_sr_data[] = { 0x1, 0x2ee00 };
static u32 range_it33_micbias_data[] = { 0x5 };
static u32 range_it33_usage_data[] = {
0x1, 0x2c6, 0x0, 0x0, 0x0, 0x0, 0x0,
};
static u32 range_it33_cluster_data[] = { 0x1, 0x2 };
static u32 range_cs36_sr_data[] = { 0x1, 0xbb80 };
static u32 range_ot36_usage_data[] = {
0x1, 0x2c6, 0xbb80, 0x10, 0x0, 0x0, 0x0,
};
static u32 range_ot36_dp_data[] = {
0xff, 0xff, 0x2, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
static u32 range_cs236_sr_data[] = { 0x1, 0xbb80 };
static u32 range_ot236_usage_data[] = {
0x1, 0x334, 0x2ee00, 0x8, 0x0, 0x0, 0x0,
};
static u32 range_ot236_dp_data[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0x5, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
static int ctrl_fun_sdca_ver_vals[] = { 0x11 };
static int ctrl_fun_type_vals[] = { 0x08 };
static int ctrl_fun_man_id_vals[] = { 0x0217 };
static int ctrl_fun_id_vals[] = { 0x3 };
static int ctrl_fun_ver_vals[] = { 0x0 };
static int ctrl_dev_sdca_ver_vals[] = { 0x11 };
static int ctrl_it41_latency_vals[] = { 0x0 };
static int ctrl_it41_cluster_vals[] = { 0x1 };
static int ctrl_it41_dp_vals[] = { 0x6 };
static int ctrl_cs41_sr_vals[] = { 0x1 };
static int ctrl_mfpu21_bypass_vals[] = { 0x1 };
static int ctrl_xu42_id_vals[] = { 0x2131 };
static int ctrl_xu42_ver_vals[] = { 0x1 };
static int ctrl_it131_latency_vals[] = { 0x0 };
static int ctrl_it131_cluster_vals[] = { 0x1 };
static int ctrl_it131_dp_vals[] = { 0x7 };
static int ctrl_cs131_sr_vals[] = { 0x1 };
static int ctrl_it33_micbias_vals[] = { 0x5 };
static int ctrl_it33_latency_vals[] = { 0x0 };
static int ctrl_it33_cluster_vals[] = { 0x1 };
static int ctrl_xu36_bypass_vals[] = { 0x1 };
static int ctrl_xu36_id_vals[] = { 0x2131 };
static int ctrl_xu36_ver_vals[] = { 0x1 };
static int ctrl_cs36_sr_vals[] = { 0x1 };
static int ctrl_ot36_latency_vals[] = { 0x0 };
static int ctrl_ot36_dp_vals[] = { 0x2 };
static int ctrl_mfpu236_bypass_vals[] = { 0x1 };
static int ctrl_cs236_sr_vals[] = { 0x1 };
static int ctrl_ot236_latency_vals[] = { 0x0 };
static int ctrl_ot236_dp_vals[] = { 0x5 };
static struct sdca_control entity0_controls[] = {
{ .sel = 0x1, .mode = SDCA_ACCESS_MODE_RW, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_COMMIT_GROUP_MASK_NAME },
{ .sel = 0x4, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_fun_sdca_ver_vals, .has_fixed = true,
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_FUNCTION_SDCA_VERSION_NAME },
{ .sel = 0x5, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_fun_type_vals, .has_fixed = true,
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_FUNCTION_TYPE_NAME },
{ .sel = 0x6, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_fun_man_id_vals, .has_fixed = true,
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_FUNCTION_MANUFACTURER_ID_NAME },
{ .sel = 0x7, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_fun_id_vals, .has_fixed = true,
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_FUNCTION_ID_NAME },
{ .sel = 0x8, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_fun_ver_vals, .has_fixed = true,
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_FUNCTION_VERSION_NAME },
{ .sel = 0x9, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.is_volatile = true, .label = SDCA_CTL_FUNCTION_EXTENSION_ID_NAME },
{ .sel = 0xa, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.is_volatile = true, .label = SDCA_CTL_FUNCTION_EXTENSION_VERSION_NAME },
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_RW1C, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.is_volatile = true, .label = SDCA_CTL_FUNCTION_STATUS_NAME },
{ .sel = 0x11, .mode = SDCA_ACCESS_MODE_RW1S, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.is_volatile = true, .label = SDCA_CTL_FUNCTION_ACTION_NAME },
{ .sel = 0x2c, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.is_volatile = true, .label = SDCA_CTL_DEVICE_MANUFACTURER_ID_NAME },
{ .sel = 0x2d, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.is_volatile = true, .label = SDCA_CTL_DEVICE_PART_ID_NAME },
{ .sel = 0x2e, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.is_volatile = true, .label = SDCA_CTL_DEVICE_VERSION_NAME },
{ .sel = 0x2f, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_dev_sdca_ver_vals, .has_fixed = true,
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_DEVICE_SDCA_VERSION_NAME },
};
static struct sdca_control entity_it41_controls[] = {
{ .sel = 0x4, .mode = SDCA_ACCESS_MODE_RW, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.range = { .cols = 0x7, .rows = 0x1, .data = range_it41_usage_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_USAGE_NAME },
{ .sel = 0x8, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.values = ctrl_it41_latency_vals, .has_fixed = true, .label = SDCA_CTL_LATENCY_NAME },
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_it41_cluster_vals, .has_fixed = true,
.range = { .cols = 0x2, .rows = 0x1, .data = range_it41_cluster_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_CLUSTERINDEX_NAME },
{ .sel = 0x11, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_it41_dp_vals, .has_fixed = true,
.range = { .cols = 0x10, .rows = 0x4, .data = range_it41_dp_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_DATAPORT_SELECTOR_NAME },
};
static struct sdca_control entity_cs41_controls[] = {
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_cs41_sr_vals, .has_fixed = true,
.range = { .cols = 0x2, .rows = 0x1, .data = range_cs41_sr_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_SAMPLERATEINDEX_NAME },
};
static struct sdca_entity *entity_mfpu21_sources[] = {
&wcd9378_sdca_entities[QSJ_IT41],
&wcd9378_sdca_entities[QSJ_IT131],
};
static struct sdca_control entity_mfpu21_controls[] = {
{ .sel = SDCA_CTL_MFPU_BYPASS, .mode = SDCA_ACCESS_MODE_DC,
.layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.has_reset = true, .reset = 1,
.values = ctrl_mfpu21_bypass_vals, .has_fixed = true, .label = SDCA_CTL_BYPASS_NAME },
};
static struct sdca_entity *entity_xu42_sources[] = { &wcd9378_sdca_entities[QSJ_MFPU21] };
static struct sdca_control entity_xu42_controls[] = {
{ .sel = SDCA_CTL_XU_BYPASS, .mode = SDCA_ACCESS_MODE_RW,
.layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.has_reset = true, .reset = 1,
.label = SDCA_CTL_BYPASS_NAME },
{ .sel = 0x7, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.values = ctrl_xu42_id_vals, .has_fixed = true, .label = SDCA_CTL_XU_ID_NAME },
{ .sel = 0x8, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.values = ctrl_xu42_ver_vals, .has_fixed = true, .label = SDCA_CTL_XU_VERSION_NAME },
};
static struct sdca_entity *entity_su43_sources[] = { &wcd9378_sdca_entities[QSJ_XU42] };
static struct sdca_control entity_su43_controls[] = {
{ .sel = 0x1, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_DEVICE,
.cn_list = 0x1,
.range = { .cols = 0x1, .rows = 0x2, .data = range_su_sel_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_SELECTOR_NAME },
};
static struct sdca_entity *entity_su45_sources[] = { &wcd9378_sdca_entities[QSJ_XU42] };
static struct sdca_control entity_su45_controls[] = {
{ .sel = 0x1, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_DEVICE,
.cn_list = 0x1,
.range = { .cols = 0x1, .rows = 0x2, .data = range_su_sel_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_SELECTOR_NAME },
};
static struct sdca_entity *entity_pde47_managed[] = {
&wcd9378_sdca_entities[QSJ_FU6],
&wcd9378_sdca_entities[QSJ_OT43],
&wcd9378_sdca_entities[QSJ_OT45],
};
static struct sdca_pde_delay pde47_delays[] = {
{ .from_ps = 3, .to_ps = 0, .us = 30000 },
{ .from_ps = 0, .to_ps = 3, .us = 30000 },
};
static struct sdca_control entity_pde47_controls[] = {
{ .sel = SDCA_CTL_PDE_REQUESTED_PS, .mode = SDCA_ACCESS_MODE_RW,
.layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.range = { .cols = 0x1, .rows = 0x2, .data = range_pde_req_ps_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.has_reset = true, .reset = 3,
.label = SDCA_CTL_REQUESTED_PS_NAME },
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.is_volatile = true, .label = SDCA_CTL_ACTUAL_PS_NAME },
};
static struct sdca_entity *entity_ot43_sources[] = { &wcd9378_sdca_entities[QSJ_IT41] };
static struct sdca_entity *entity_ot45_sources[] = { &wcd9378_sdca_entities[QSJ_IT41] };
static struct sdca_ge_control ge35_mode0_controls[] = {
{ .id = 0x8, .sel = 0x1, .cn = 0x0, .val = 0x1 },
};
static struct sdca_ge_control ge35_mode1_controls[] = {
{ .id = 0x8, .sel = 0x1, .cn = 0x0, .val = 0x1 },
};
static struct sdca_ge_control ge35_mode3_controls[] = {
{ .id = 0x7, .sel = 0x1, .cn = 0x0, .val = 0x1 },
};
static struct sdca_ge_control ge35_mode4_controls[] = {
{ .id = 0x8, .sel = 0x1, .cn = 0x0, .val = 0x1 },
};
static struct sdca_ge_mode ge35_modes[] = {
{ .val = 0x0, .num_controls = ARRAY_SIZE(ge35_mode0_controls), .controls = ge35_mode0_controls },
{ .val = 0x1, .num_controls = ARRAY_SIZE(ge35_mode1_controls), .controls = ge35_mode1_controls },
{ .val = 0x3, .num_controls = ARRAY_SIZE(ge35_mode3_controls), .controls = ge35_mode3_controls },
{ .val = 0x4, .num_controls = ARRAY_SIZE(ge35_mode4_controls), .controls = ge35_mode4_controls },
};
static struct sdca_control entity_ge35_controls[] = {
{ .sel = SDCA_CTL_GE_SELECTED_MODE, .mode = SDCA_ACCESS_MODE_RW,
.layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.range = { .cols = 0x2, .rows = 0x4, .data = range_ge35_mode_data },
.has_reset = true, .reset = 0,
.label = SDCA_CTL_SELECTED_MODE_NAME },
{ .sel = 0x2, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = 4,
.is_volatile = true, .label = SDCA_CTL_DETECTED_MODE_NAME },
};
static struct sdca_control entity_it131_controls[] = {
{ .sel = 0x4, .mode = SDCA_ACCESS_MODE_RW, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.range = { .cols = 0x7, .rows = 0x1, .data = range_it131_usage_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_USAGE_NAME },
{ .sel = 0x8, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.values = ctrl_it131_latency_vals, .has_fixed = true, .label = SDCA_CTL_LATENCY_NAME },
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_it131_cluster_vals, .has_fixed = true,
.range = { .cols = 0x2, .rows = 0x1, .data = range_it131_cluster_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_CLUSTERINDEX_NAME },
{ .sel = 0x11, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_it131_dp_vals, .has_fixed = true,
.range = { .cols = 0x10, .rows = 0x4, .data = range_it131_dp_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_DATAPORT_SELECTOR_NAME },
};
static struct sdca_control entity_cs131_controls[] = {
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_cs131_sr_vals, .has_fixed = true,
.range = { .cols = 0x2, .rows = 0x1, .data = range_cs131_sr_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_SAMPLERATEINDEX_NAME },
};
static struct sdca_control entity_it33_controls[] = {
{ .sel = 0x3, .mode = SDCA_ACCESS_MODE_RW, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_it33_micbias_vals, .has_default = true,
.range = { .cols = 0x1, .rows = 0x1, .data = range_it33_micbias_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_MIC_BIAS_NAME },
{ .sel = 0x4, .mode = SDCA_ACCESS_MODE_RW, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.range = { .cols = 0x7, .rows = 0x1, .data = range_it33_usage_data },
.has_reset = true,
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_USAGE_NAME },
{ .sel = 0x8, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.values = ctrl_it33_latency_vals, .has_fixed = true, .label = SDCA_CTL_LATENCY_NAME },
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_it33_cluster_vals, .has_fixed = true,
.range = { .cols = 0x2, .rows = 0x1, .data = range_it33_cluster_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_CLUSTERINDEX_NAME },
};
static struct sdca_entity *entity_pde34_managed[] = { &wcd9378_sdca_entities[QSJ_IT33] };
static struct sdca_pde_delay pde34_delays[] = {
{ .from_ps = 3, .to_ps = 0, .us = 30000 },
{ .from_ps = 0, .to_ps = 3, .us = 30000 },
};
static struct sdca_control entity_pde34_controls[] = {
{ .sel = SDCA_CTL_PDE_REQUESTED_PS, .mode = SDCA_ACCESS_MODE_RW,
.layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.range = { .cols = 0x1, .rows = 0x2, .data = range_pde_req_ps_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.has_reset = true, .reset = 3,
.label = SDCA_CTL_REQUESTED_PS_NAME },
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_RO, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.is_volatile = true, .label = SDCA_CTL_ACTUAL_PS_NAME },
};
static u32 range_fu6_vol_data[] = {
0x00008000, 0x00007fff, 0x00000001,
};
static struct sdca_control entity_fu6_controls[] = {
{ .sel = SDCA_CTL_FU_MUTE, .mode = SDCA_ACCESS_MODE_DUAL,
.layers = SDCA_ACCESS_LAYER_USER, .cn_list = 0x6, .nbits = 1,
.type = SDCA_CTL_DATATYPE_ONEBIT,
.interrupt_position = SDCA_NO_INTERRUPT,
.has_reset = true, .reset = 1,
.label = SDCA_CTL_MUTE_NAME },
{ .sel = SDCA_CTL_FU_CHANNEL_VOLUME, .mode = SDCA_ACCESS_MODE_DUAL,
.layers = SDCA_ACCESS_LAYER_USER, .cn_list = 0x6, .nbits = 16,
.type = SDCA_CTL_DATATYPE_Q7P8DB,
.range = { .cols = SDCA_VOLUME_LINEAR_NCOLS, .rows = 1,
.data = range_fu6_vol_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_CHANNEL_VOLUME_NAME },
};
static struct sdca_entity *entity_fu33_sources[] = { &wcd9378_sdca_entities[QSJ_IT33] };
static struct sdca_entity *entity_su35_sources[] = { &wcd9378_sdca_entities[QSJ_FU33] };
static struct sdca_control entity_su35_controls[] = {
{ .sel = 0x1, .mode = SDCA_ACCESS_MODE_RW, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.range = { .cols = 0x1, .rows = 0x2, .data = range_su_sel_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_SELECTOR_NAME },
};
static struct sdca_entity *entity_xu36_sources[] = { &wcd9378_sdca_entities[QSJ_SU35] };
static struct sdca_control entity_xu36_controls[] = {
{ .sel = SDCA_CTL_XU_BYPASS, .mode = SDCA_ACCESS_MODE_RW,
.layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.has_reset = true, .reset = 1,
.values = ctrl_xu36_bypass_vals, .has_default = true, .label = SDCA_CTL_BYPASS_NAME },
{ .sel = 0x7, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.values = ctrl_xu36_id_vals, .has_fixed = true, .label = SDCA_CTL_XU_ID_NAME },
{ .sel = 0x8, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.values = ctrl_xu36_ver_vals, .has_fixed = true, .label = SDCA_CTL_XU_VERSION_NAME },
};
static struct sdca_control entity_cs36_controls[] = {
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_cs36_sr_vals, .has_fixed = true,
.range = { .cols = 0x2, .rows = 0x1, .data = range_cs36_sr_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_SAMPLERATEINDEX_NAME },
};
static struct sdca_entity *entity_ot36_sources[] = { &wcd9378_sdca_entities[QSJ_XU36] };
static struct sdca_control entity_ot36_controls[] = {
{ .sel = 0x4, .mode = SDCA_ACCESS_MODE_RW, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.range = { .cols = 0x7, .rows = 0x1, .data = range_ot36_usage_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_USAGE_NAME },
{ .sel = 0x8, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.values = ctrl_ot36_latency_vals, .has_fixed = true, .label = SDCA_CTL_LATENCY_NAME },
{ .sel = 0x11, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_ot36_dp_vals, .has_fixed = true,
.range = { .cols = 0x10, .rows = 0x4, .data = range_ot36_dp_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_DATAPORT_SELECTOR_NAME },
};
static struct sdca_control entity_mfpu236_controls[] = {
{ .sel = SDCA_CTL_MFPU_BYPASS, .mode = SDCA_ACCESS_MODE_DC,
.layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.has_reset = true, .reset = 1,
.values = ctrl_mfpu236_bypass_vals, .has_fixed = true, .label = SDCA_CTL_BYPASS_NAME },
};
static struct sdca_control entity_cs236_controls[] = {
{ .sel = 0x10, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_cs236_sr_vals, .has_fixed = true,
.range = { .cols = 0x2, .rows = 0x1, .data = range_cs236_sr_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_SAMPLERATEINDEX_NAME },
};
static struct sdca_entity *entity_ot236_sources[] = { &wcd9378_sdca_entities[QSJ_IT33] };
static struct sdca_control entity_ot236_controls[] = {
{ .sel = 0x4, .mode = SDCA_ACCESS_MODE_RW, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.range = { .cols = 0x7, .rows = 0x1, .data = range_ot236_usage_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_USAGE_NAME },
{ .sel = 0x8, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.interrupt_position = SDCA_NO_INTERRUPT,
.values = ctrl_ot236_latency_vals, .has_fixed = true, .label = SDCA_CTL_LATENCY_NAME },
{ .sel = 0x11, .mode = SDCA_ACCESS_MODE_DC, .layers = SDCA_ACCESS_LAYER_CLASS, .cn_list = 0x1,
.values = ctrl_ot236_dp_vals, .has_fixed = true,
.range = { .cols = 0x10, .rows = 0x4, .data = range_ot236_dp_data },
.interrupt_position = SDCA_NO_INTERRUPT,
.label = SDCA_CTL_DATAPORT_SELECTOR_NAME },
};
static struct sdca_entity wcd9378_sdca_entities[] = {
{ .id = 0x1, .label = "IT 41", .type = SDCA_ENTITY_TYPE_IT,
.iot = { .type = 0x0191, .is_dataport = true, .clock = &wcd9378_sdca_entities[QSJ_CS41] },
.num_controls = ARRAY_SIZE(entity_it41_controls), .controls = entity_it41_controls },
{ .id = 0x2, .label = "CS 41", .type = SDCA_ENTITY_TYPE_CS,
.cs = { .type = 0x0 },
.num_controls = ARRAY_SIZE(entity_cs41_controls), .controls = entity_cs41_controls },
{ .id = 0x3, .label = "MFPU 21", .type = SDCA_ENTITY_TYPE_MFPU,
.num_controls = ARRAY_SIZE(entity_mfpu21_controls), .controls = entity_mfpu21_controls,
.num_sources = ARRAY_SIZE(entity_mfpu21_sources), .sources = entity_mfpu21_sources },
{ .id = 0x4, .label = "XU 42", .type = SDCA_ENTITY_TYPE_XU,
.num_controls = ARRAY_SIZE(entity_xu42_controls), .controls = entity_xu42_controls,
.num_sources = ARRAY_SIZE(entity_xu42_sources), .sources = entity_xu42_sources },
{ .id = 0x7, .label = "SU 43", .type = SDCA_ENTITY_TYPE_SU,
.group = &wcd9378_sdca_entities[QSJ_GE35],
.num_controls = ARRAY_SIZE(entity_su43_controls), .controls = entity_su43_controls,
.num_sources = ARRAY_SIZE(entity_su43_sources), .sources = entity_su43_sources },
{ .id = 0x8, .label = "SU 45", .type = SDCA_ENTITY_TYPE_SU,
.group = &wcd9378_sdca_entities[QSJ_GE35],
.num_controls = ARRAY_SIZE(entity_su45_controls), .controls = entity_su45_controls,
.num_sources = ARRAY_SIZE(entity_su45_sources), .sources = entity_su45_sources },
{ .id = 0x9, .label = "PDE 47", .type = SDCA_ENTITY_TYPE_PDE,
.pde = { .num_managed = ARRAY_SIZE(entity_pde47_managed), .managed = entity_pde47_managed,
.num_max_delay = ARRAY_SIZE(pde47_delays), .max_delay = pde47_delays },
.num_controls = ARRAY_SIZE(entity_pde47_controls), .controls = entity_pde47_controls },
{ .id = 0xa, .label = "OT 43", .type = SDCA_ENTITY_TYPE_OT,
.iot = { .type = 0x06c0 },
.num_sources = ARRAY_SIZE(entity_ot43_sources), .sources = entity_ot43_sources },
{ .id = 0xb, .label = "OT 45", .type = SDCA_ENTITY_TYPE_OT,
.iot = { .type = 0x06d0 },
.num_sources = ARRAY_SIZE(entity_ot45_sources), .sources = entity_ot45_sources },
{ .id = 0xc, .label = "GE 35", .type = SDCA_ENTITY_TYPE_GE,
.ge = { .num_modes = ARRAY_SIZE(ge35_modes), .modes = ge35_modes },
.num_controls = ARRAY_SIZE(entity_ge35_controls), .controls = entity_ge35_controls },
{ .id = 0xd, .label = "IT 131", .type = SDCA_ENTITY_TYPE_IT,
.iot = { .type = 0x0190, .is_dataport = true, .clock = &wcd9378_sdca_entities[QSJ_CS131] },
.num_controls = ARRAY_SIZE(entity_it131_controls), .controls = entity_it131_controls },
{ .id = 0xe, .label = "CS 131", .type = SDCA_ENTITY_TYPE_CS,
.cs = { .type = 0x0 },
.num_controls = ARRAY_SIZE(entity_cs131_controls), .controls = entity_cs131_controls },
{ .id = 0xf, .label = "IT 33", .type = SDCA_ENTITY_TYPE_IT,
.iot = { .type = 0x06d0 },
.num_controls = ARRAY_SIZE(entity_it33_controls), .controls = entity_it33_controls },
{ .id = 0x10, .label = "PDE 34", .type = SDCA_ENTITY_TYPE_PDE,
.pde = { .num_managed = ARRAY_SIZE(entity_pde34_managed), .managed = entity_pde34_managed,
.num_max_delay = ARRAY_SIZE(pde34_delays), .max_delay = pde34_delays },
.num_controls = ARRAY_SIZE(entity_pde34_controls), .controls = entity_pde34_controls },
{ .id = 0x11, .label = "FU 33", .type = SDCA_ENTITY_TYPE_FU,
.num_sources = ARRAY_SIZE(entity_fu33_sources), .sources = entity_fu33_sources },
{ .id = 0x12, .label = "SU 35", .type = SDCA_ENTITY_TYPE_SU,
.num_controls = ARRAY_SIZE(entity_su35_controls), .controls = entity_su35_controls,
.num_sources = ARRAY_SIZE(entity_su35_sources), .sources = entity_su35_sources },
{ .id = 0x13, .label = "XU 36", .type = SDCA_ENTITY_TYPE_XU,
.num_controls = ARRAY_SIZE(entity_xu36_controls), .controls = entity_xu36_controls,
.num_sources = ARRAY_SIZE(entity_xu36_sources), .sources = entity_xu36_sources },
{ .id = 0x15, .label = "CS 36", .type = SDCA_ENTITY_TYPE_CS,
.cs = { .type = 0x0 },
.num_controls = ARRAY_SIZE(entity_cs36_controls), .controls = entity_cs36_controls },
{ .id = 0x16, .label = "OT 36", .type = SDCA_ENTITY_TYPE_OT,
.iot = { .type = 0x0191, .is_dataport = true, .clock = &wcd9378_sdca_entities[QSJ_CS36] },
.num_controls = ARRAY_SIZE(entity_ot36_controls), .controls = entity_ot36_controls,
.num_sources = ARRAY_SIZE(entity_ot36_sources), .sources = entity_ot36_sources },
{ .id = 0x17, .label = "MFPU 236", .type = SDCA_ENTITY_TYPE_MFPU,
.num_controls = ARRAY_SIZE(entity_mfpu236_controls), .controls = entity_mfpu236_controls },
{ .id = 0x18, .label = "CS 236", .type = SDCA_ENTITY_TYPE_CS,
.cs = { .type = 0x0 },
.num_controls = ARRAY_SIZE(entity_cs236_controls), .controls = entity_cs236_controls },
{ .id = 0x19, .label = "OT 236", .type = SDCA_ENTITY_TYPE_OT,
.iot = { .type = 0x0190, .is_dataport = true, .clock = &wcd9378_sdca_entities[QSJ_CS131] },
.num_controls = ARRAY_SIZE(entity_ot236_controls), .controls = entity_ot236_controls,
.num_sources = ARRAY_SIZE(entity_ot236_sources), .sources = entity_ot236_sources },
{ .id = 0x6, .label = "FU 6", .type = SDCA_ENTITY_TYPE_FU,
.num_controls = ARRAY_SIZE(entity_fu6_controls), .controls = entity_fu6_controls },
{ .id = 0x0, .label = "entity0",
.num_controls = ARRAY_SIZE(entity0_controls), .controls = entity0_controls },
};
static struct sdca_channel cl1_channels[] = {
{ .id = 0x1, .purpose = 0x1, .relationship = 0x2 },
{ .id = 0x2, .purpose = 0x1, .relationship = 0x3 },
};
static struct sdca_channel cl2_channels[] = {
{ .id = 0xff, .purpose = 0x1, .relationship = 0x1 },
};
static struct sdca_channel cl3_channels[] = {
{ .id = 0xff, .purpose = 0x1, .relationship = 0x1 },
{ .id = 0x1, .purpose = 0x1, .relationship = 0x2 },
{ .id = 0x2, .purpose = 0x1, .relationship = 0x3 },
};
static struct sdca_channel cl5_channels[] = {
{ .id = 0xff, .purpose = 0x1, .relationship = 0x1 },
};
static struct sdca_cluster wcd9378_sdca_clusters[] = {
{ .id = 0x1, .num_channels = ARRAY_SIZE(cl1_channels), .channels = cl1_channels },
{ .id = 0x2, .num_channels = ARRAY_SIZE(cl2_channels), .channels = cl2_channels },
{ .id = 0x3, .num_channels = ARRAY_SIZE(cl3_channels), .channels = cl3_channels },
{ .id = 0x5, .num_channels = ARRAY_SIZE(cl5_channels), .channels = cl5_channels },
};
static struct sdca_init_write wcd9378_sdca_init_table[] = {
{ .addr = 0x401804f0, .val = 0x00 },
{ .addr = 0x4018046e, .val = 0x10 },
{ .addr = 0x0000004d, .val = 0x01 },
{ .addr = 0x00000062, .val = 0x02 },
{ .addr = 0x4018016a, .val = 0x80 },
{ .addr = 0x40180165, .val = 0x6b },
{ .addr = 0x40180103, .val = 0x1e },
{ .addr = 0x40180103, .val = 0x9e },
{ .addr = 0x40180103, .val = 0xde },
{ .addr = 0x40180029, .val = 0xb5 },
{ .addr = 0x40180001, .val = 0x80 },
{ .addr = 0x40180001, .val = 0xc0 },
{ .addr = 0x40180001, .val = 0x80 },
{ .addr = 0x4018007b, .val = 0xa2 },
{ .addr = 0x40180465, .val = 0x17 },
{ .addr = 0x40180466, .val = 0x17 },
{ .addr = 0x4018006c, .val = 0x01 },
{ .addr = 0x40180072, .val = 0x81 },
{ .addr = 0x401800ce, .val = 0x38 },
{ .addr = 0x401800ce, .val = 0x3a },
{ .addr = 0x401800d4, .val = 0xe1 },
{ .addr = 0x401800d7, .val = 0xe1 },
{ .addr = 0x4018044e, .val = 0x04 },
{ .addr = 0x4018044e, .val = 0x0c },
{ .addr = 0x4018000f, .val = 0x0c },
{ .addr = 0x40180133, .val = 0x84 },
{ .addr = 0x40180136, .val = 0x84 },
{ .addr = 0x401800d9, .val = 0x19 },
{ .addr = 0x40180132, .val = 0x50 },
{ .addr = 0x40180510, .val = 0x05 },
{ .addr = 0x40180519, .val = 0x05 },
{ .addr = 0x4018051b, .val = 0x06 },
{ .addr = 0x40180414, .val = 0x02 },
{ .addr = 0x40180414, .val = 0x03 },
{ .addr = 0x401804f2, .val = 0x80 },
{ .addr = 0x401804f2, .val = 0x00 },
{ .addr = 0x40180501, .val = 0x01 },
{ .addr = 0x40180601, .val = 0x01 },
{ .addr = 0x40180414, .val = 0x00 },
{ .addr = 0x401804f2, .val = 0x88 },
{ .addr = 0x40180517, .val = 0x07 },
{ .addr = 0x4018051c, .val = 0x07 },
{ .addr = 0x401800ce, .val = 0x28 },
{ .addr = 0x401800d4, .val = 0xe0 },
{ .addr = 0x401800d7, .val = 0xe0 },
{ .addr = 0x40180510, .val = 0x07 },
{ .addr = 0x40c80008, .val = 0x01 },
{ .addr = 0x40c00008, .val = 0x02 },
{ .addr = 0x40c80000, .val = 0xff },
{ .addr = 0x00000000, .val = 0x08 },
{ .addr = 0x00000041, .val = 0x08 },
{ .addr = 0x0000005c, .val = 0x10 },
{ .addr = 0x4018016a, .val = 0x00 },
{ .addr = 0x40180165, .val = 0x6b },
};
static struct sdca_function_desc wcd9378_sdca_desc = {
.adr = 0x3,
.type = SDCA_FUNCTION_TYPE_SIMPLE_JACK,
.name = SDCA_FUNCTION_TYPE_SIMPLE_NAME,
};
static struct sdca_function_data wcd9378_sdca_data = {
.desc = &wcd9378_sdca_desc,
.num_entities = ARRAY_SIZE(wcd9378_sdca_entities),
.entities = wcd9378_sdca_entities,
.num_clusters = ARRAY_SIZE(wcd9378_sdca_clusters),
.clusters = wcd9378_sdca_clusters,
.num_init_table = ARRAY_SIZE(wcd9378_sdca_init_table),
.init_table = wcd9378_sdca_init_table,
.reset_max_delay = 25000,
};
#define WCD9378_SCP_HOST_CLK_DIV2_CTL_B1 0xf0
#define WCD9378_SDCA_MAX_PORTS 8
static const char * const wcd9378_sdca_supplies[] = {
"vdd-buck", "vdd-rxtx", "vdd-io", "vdd-mic-bias",
};
int wcd9378_sdca_read_prop(struct sdw_slave *slave)
{
struct sdw_slave_prop *prop = &slave->prop;
struct device *dev = &slave->dev;
struct sdw_dpn_prop *sink, *src;
int ret;
prop->use_domain_irq = true;
prop->scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY |
SDW_SCP_INT1_IMPL_DEF;
prop->simple_clk_stop_capable = true;
prop->paging_support = true;
prop->clock_reg_supported = true;
prop->lane_control_support = true;
prop->source_ports = BIT(2) | BIT(5);
prop->sink_ports = BIT(6) | BIT(7) | BIT(8);
src = devm_kzalloc_objs(dev, *src, 2);
if (!src)
return -ENOMEM;
src[0].num = 2;
src[0].type = SDW_DPN_SIMPLE;
src[0].simple_ch_prep_sm = true;
src[0].ch_prep_timeout = 10;
src[0].max_ch = 1;
src[0].min_ch = 1;
src[1].num = 5;
src[1].type = SDW_DPN_SIMPLE;
src[1].simple_ch_prep_sm = true;
src[1].ch_prep_timeout = 10;
src[1].max_ch = 1;
src[1].min_ch = 1;
prop->src_dpn_prop = src;
sink = devm_kzalloc_objs(dev, *sink, 3);
if (!sink)
return -ENOMEM;
sink[0].num = 6;
sink[0].type = SDW_DPN_SIMPLE;
sink[0].simple_ch_prep_sm = true;
sink[0].ch_prep_timeout = 10;
sink[0].max_ch = 2;
sink[0].min_ch = 1;
sink[1].num = 7;
sink[1].type = SDW_DPN_FULL;
sink[1].simple_ch_prep_sm = true;
sink[1].ch_prep_timeout = 10;
sink[1].max_ch = 1;
sink[1].min_ch = 1;
sink[2].num = 8;
sink[2].type = SDW_DPN_REDUCED;
sink[2].simple_ch_prep_sm = true;
sink[2].ch_prep_timeout = 10;
sink[2].max_ch = 2;
sink[2].min_ch = 1;
prop->sink_dpn_prop = sink;
ret = device_property_read_u32_array(dev, "qcom,port-mapping",
&slave->m_port_map[1],
WCD9378_SDCA_MAX_PORTS);
if (ret)
return dev_err_probe(dev, ret, "qcom,port-mapping missing\n");
return 0;
}
static int wcd9378_sdca_populate_function(struct device *dev,
struct sdca_function_data *function)
{
if (function->desc->type != wcd9378_sdca_desc.type)
return -EINVAL;
function->num_entities = wcd9378_sdca_data.num_entities;
function->entities = wcd9378_sdca_data.entities;
function->num_clusters = wcd9378_sdca_data.num_clusters;
function->clusters = wcd9378_sdca_data.clusters;
function->num_init_table = wcd9378_sdca_data.num_init_table;
function->init_table = wcd9378_sdca_data.init_table;
function->reset_max_delay = wcd9378_sdca_data.reset_max_delay;
return 0;
}
static const struct sdca_class_ops wcd9378_sdca_class_ops = {
.populate_function = wcd9378_sdca_populate_function,
};
int wcd9378_sdca_probe(struct sdw_slave *slave,
const struct sdw_device_id *id)
{
struct device *dev = &slave->dev;
struct sdca_device_data *data = &slave->sdca_data;
struct wcd9378_priv *priv;
struct gpio_desc *reset;
int ret;
if (!device_property_read_bool(dev, "qcom,sdca-compliant"))
return -ENODEV;
priv = devm_kzalloc_obj(dev, *priv);
if (!priv)
return -ENOMEM;
dev_set_drvdata(dev, priv);
ret = devm_regulator_bulk_get_enable(dev,
ARRAY_SIZE(wcd9378_sdca_supplies),
wcd9378_sdca_supplies);
if (ret)
return dev_err_probe(dev, ret, "failed to enable supplies\n");
reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(reset))
return dev_err_probe(dev, PTR_ERR(reset),
"failed to get reset GPIO\n");
if (reset) {
gpiod_set_value(reset, 1);
usleep_range(20, 30);
gpiod_set_value(reset, 0);
usleep_range(20, 30);
}
ret = sdw_slave_wait_for_init(slave, 5000);
if (ret)
return dev_err_probe(dev, ret,
"slave attach timeout: %d\n", ret);
ret = sdw_write_no_pm(slave, WCD9378_SCP_HOST_CLK_DIV2_CTL_B1, 0x01);
if (ret)
return dev_err_probe(dev, ret,
"HOST_CLK_DIV2_CTL_B1: %d\n", ret);
ret = sdw_write_no_pm(slave, SDW_SCP_COMMIT, 0x02);
if (ret)
return dev_err_probe(dev, ret, "SCP_COMMIT: %d\n", ret);
if (!data->num_functions) {
data->function[0].type = wcd9378_sdca_desc.type;
data->function[0].adr = wcd9378_sdca_desc.adr;
data->function[0].name = wcd9378_sdca_desc.name;
data->num_functions = 1;
}
return sdca_class_probe(slave, &priv->class, &wcd9378_sdca_class_ops);
}
void wcd9378_sdca_remove(struct sdw_slave *slave)
{
struct wcd9378_priv *priv = dev_get_drvdata(&slave->dev);
sdca_class_remove(&priv->class);
}
int wcd9378_sdca_runtime_suspend(struct device *dev)
{
struct wcd9378_priv *priv = dev_get_drvdata(dev);
return sdca_class_runtime_suspend(&priv->class);
}
int wcd9378_sdca_runtime_resume(struct device *dev)
{
struct wcd9378_priv *priv = dev_get_drvdata(dev);
return sdca_class_runtime_resume(&priv->class);
}
int wcd9378_sdca_system_suspend(struct device *dev)
{
struct wcd9378_priv *priv = dev_get_drvdata(dev);
return sdca_class_system_suspend(&priv->class);
}
int wcd9378_sdca_system_resume(struct device *dev)
{
struct wcd9378_priv *priv = dev_get_drvdata(dev);
return sdca_class_system_resume(&priv->class);
}