1 #include <linux/kernel.h>
7 static struct vmmc_sig
*vmmc_module_to_sig(struct vmmc_module
*module
)
9 return container_of(module
, struct vmmc_sig
, module
);
12 static int vmmc_sig_enable(struct vmmc_module
*module
, bool enabled
)
14 struct vmmc_sig
*sig
= vmmc_module_to_sig(module
);
18 sig
->sig_cache
= VMMC_CMD_SIG_SET_ENABLE(sig
->sig_cache
, enabled
);
20 return vmmc_command_write(sig
->vmmc
, VMMC_CMD_SIG(sig
->id
), &sig
->sig_cache
);
23 static int vmmc_sig_sync(struct vmmc_module
*module
)
25 struct vmmc_sig
*sig
= vmmc_module_to_sig(module
);
27 sig
->sig_cache
= VMMC_CMD_SIG_SET_INPUTS(sig
->sig_cache
,
28 module
->pins
[0], module
->pins
[1]);
30 vmmc_command_write(sig
->vmmc
, VMMC_CMD_SIG(sig
->id
),
33 return vmmc_command_write(sig
->vmmc
, VMMC_CMD_DTMFR(sig
->id
),
37 static const struct vmmc_module_ops vmmc_sig_ops
= {
38 .enable
= vmmc_sig_enable
,
39 .sync
= vmmc_sig_sync
,
42 int vmmc_sig_init(struct vmmc_sig
*sig
, struct vmmc
*vmmc
, unsigned int id
)
46 ret
= vmmc_module_init(&sig
->module
, 2, &vmmc_sig_ops
);
51 sig
->module
.id
= id
+ 0x1e;
53 sig
->sig_cache
= VMMC_CMD_SIG_DATA(1, 1, 0, 0, 0, 0, 0);
54 sig
->dtmfr_cache
= VMMC_CMD_DTMFR_DATA(1, 1, id
);
56 vmmc_register_module(vmmc
, &sig
->module
);
58 vmmc_command_write(sig
->vmmc
, VMMC_CMD_SIG(sig
->id
),
60 vmmc_command_write(sig
->vmmc
, VMMC_CMD_DTMFR(sig
->id
),
66 void vmmc_sig_dtmf_event_handler(struct vmmc
*vmmc
, uint32_t id
, uint32_t data
)
68 tapi_report_dtmf_event(&vmmc
->tdev
, &vmmc
->tdev
.ports
[id
], data
& 0xf);