.. | .. |
---|
42 | 42 | #define AFE_PARAM_ID_I2S_CONFIG 0x0001020D |
---|
43 | 43 | #define AFE_PARAM_ID_TDM_CONFIG 0x0001029D |
---|
44 | 44 | #define AFE_PARAM_ID_PORT_SLOT_MAPPING_CONFIG 0x00010297 |
---|
| 45 | +#define AFE_PARAM_ID_CODEC_DMA_CONFIG 0x000102B8 |
---|
| 46 | +#define AFE_CMD_REMOTE_LPASS_CORE_HW_VOTE_REQUEST 0x000100f4 |
---|
| 47 | +#define AFE_CMD_RSP_REMOTE_LPASS_CORE_HW_VOTE_REQUEST 0x000100f5 |
---|
| 48 | +#define AFE_CMD_REMOTE_LPASS_CORE_HW_DEVOTE_REQUEST 0x000100f6 |
---|
45 | 49 | |
---|
46 | 50 | /* I2S config specific */ |
---|
47 | 51 | #define AFE_API_VERSION_I2S_CONFIG 0x1 |
---|
.. | .. |
---|
71 | 75 | /* Port IDs */ |
---|
72 | 76 | #define AFE_API_VERSION_HDMI_CONFIG 0x1 |
---|
73 | 77 | #define AFE_PORT_ID_MULTICHAN_HDMI_RX 0x100E |
---|
| 78 | +#define AFE_PORT_ID_HDMI_OVER_DP_RX 0x6020 |
---|
74 | 79 | |
---|
75 | 80 | #define AFE_API_VERSION_SLIMBUS_CONFIG 0x1 |
---|
76 | 81 | /* Clock set API version */ |
---|
.. | .. |
---|
298 | 303 | #define AFE_PORT_ID_QUINARY_TDM_TX_7 \ |
---|
299 | 304 | (AFE_PORT_ID_QUINARY_TDM_TX + 0x0E) |
---|
300 | 305 | |
---|
| 306 | +/* AFE WSA Codec DMA Rx port 0 */ |
---|
| 307 | +#define AFE_PORT_ID_WSA_CODEC_DMA_RX_0 0xB000 |
---|
| 308 | +/* AFE WSA Codec DMA Tx port 0 */ |
---|
| 309 | +#define AFE_PORT_ID_WSA_CODEC_DMA_TX_0 0xB001 |
---|
| 310 | +/* AFE WSA Codec DMA Rx port 1 */ |
---|
| 311 | +#define AFE_PORT_ID_WSA_CODEC_DMA_RX_1 0xB002 |
---|
| 312 | +/* AFE WSA Codec DMA Tx port 1 */ |
---|
| 313 | +#define AFE_PORT_ID_WSA_CODEC_DMA_TX_1 0xB003 |
---|
| 314 | +/* AFE WSA Codec DMA Tx port 2 */ |
---|
| 315 | +#define AFE_PORT_ID_WSA_CODEC_DMA_TX_2 0xB005 |
---|
| 316 | +/* AFE VA Codec DMA Tx port 0 */ |
---|
| 317 | +#define AFE_PORT_ID_VA_CODEC_DMA_TX_0 0xB021 |
---|
| 318 | +/* AFE VA Codec DMA Tx port 1 */ |
---|
| 319 | +#define AFE_PORT_ID_VA_CODEC_DMA_TX_1 0xB023 |
---|
| 320 | +/* AFE VA Codec DMA Tx port 2 */ |
---|
| 321 | +#define AFE_PORT_ID_VA_CODEC_DMA_TX_2 0xB025 |
---|
| 322 | +/* AFE Rx Codec DMA Rx port 0 */ |
---|
| 323 | +#define AFE_PORT_ID_RX_CODEC_DMA_RX_0 0xB030 |
---|
| 324 | +/* AFE Tx Codec DMA Tx port 0 */ |
---|
| 325 | +#define AFE_PORT_ID_TX_CODEC_DMA_TX_0 0xB031 |
---|
| 326 | +/* AFE Rx Codec DMA Rx port 1 */ |
---|
| 327 | +#define AFE_PORT_ID_RX_CODEC_DMA_RX_1 0xB032 |
---|
| 328 | +/* AFE Tx Codec DMA Tx port 1 */ |
---|
| 329 | +#define AFE_PORT_ID_TX_CODEC_DMA_TX_1 0xB033 |
---|
| 330 | +/* AFE Rx Codec DMA Rx port 2 */ |
---|
| 331 | +#define AFE_PORT_ID_RX_CODEC_DMA_RX_2 0xB034 |
---|
| 332 | +/* AFE Tx Codec DMA Tx port 2 */ |
---|
| 333 | +#define AFE_PORT_ID_TX_CODEC_DMA_TX_2 0xB035 |
---|
| 334 | +/* AFE Rx Codec DMA Rx port 3 */ |
---|
| 335 | +#define AFE_PORT_ID_RX_CODEC_DMA_RX_3 0xB036 |
---|
| 336 | +/* AFE Tx Codec DMA Tx port 3 */ |
---|
| 337 | +#define AFE_PORT_ID_TX_CODEC_DMA_TX_3 0xB037 |
---|
| 338 | +/* AFE Rx Codec DMA Rx port 4 */ |
---|
| 339 | +#define AFE_PORT_ID_RX_CODEC_DMA_RX_4 0xB038 |
---|
| 340 | +/* AFE Tx Codec DMA Tx port 4 */ |
---|
| 341 | +#define AFE_PORT_ID_TX_CODEC_DMA_TX_4 0xB039 |
---|
| 342 | +/* AFE Rx Codec DMA Rx port 5 */ |
---|
| 343 | +#define AFE_PORT_ID_RX_CODEC_DMA_RX_5 0xB03A |
---|
| 344 | +/* AFE Tx Codec DMA Tx port 5 */ |
---|
| 345 | +#define AFE_PORT_ID_TX_CODEC_DMA_TX_5 0xB03B |
---|
| 346 | +/* AFE Rx Codec DMA Rx port 6 */ |
---|
| 347 | +#define AFE_PORT_ID_RX_CODEC_DMA_RX_6 0xB03C |
---|
| 348 | +/* AFE Rx Codec DMA Rx port 7 */ |
---|
| 349 | +#define AFE_PORT_ID_RX_CODEC_DMA_RX_7 0xB03E |
---|
| 350 | + |
---|
301 | 351 | #define Q6AFE_LPASS_MODE_CLK1_VALID 1 |
---|
302 | 352 | #define Q6AFE_LPASS_MODE_CLK2_VALID 2 |
---|
303 | 353 | #define Q6AFE_LPASS_CLK_SRC_INTERNAL 1 |
---|
304 | 354 | #define Q6AFE_LPASS_CLK_ROOT_DEFAULT 0 |
---|
305 | 355 | #define AFE_API_VERSION_TDM_CONFIG 1 |
---|
306 | 356 | #define AFE_API_VERSION_SLOT_MAPPING_CONFIG 1 |
---|
| 357 | +#define AFE_API_VERSION_CODEC_DMA_CONFIG 1 |
---|
307 | 358 | |
---|
308 | 359 | #define TIMEOUT_MS 1000 |
---|
309 | 360 | #define AFE_CMD_RESP_AVAIL 0 |
---|
310 | 361 | #define AFE_CMD_RESP_NONE 1 |
---|
| 362 | +#define AFE_CLK_TOKEN 1024 |
---|
311 | 363 | |
---|
312 | 364 | struct q6afe { |
---|
313 | 365 | struct apr_device *apr; |
---|
314 | 366 | struct device *dev; |
---|
315 | 367 | struct q6core_svc_api_info ainfo; |
---|
316 | 368 | struct mutex lock; |
---|
| 369 | + struct aprv2_ibasic_rsp_result_t result; |
---|
| 370 | + wait_queue_head_t wait; |
---|
317 | 371 | struct list_head port_list; |
---|
318 | 372 | spinlock_t port_list_lock; |
---|
319 | 373 | }; |
---|
.. | .. |
---|
447 | 501 | u32 slot_mask; |
---|
448 | 502 | } __packed; |
---|
449 | 503 | |
---|
| 504 | +struct afe_param_id_cdc_dma_cfg { |
---|
| 505 | + u32 cdc_dma_cfg_minor_version; |
---|
| 506 | + u32 sample_rate; |
---|
| 507 | + u16 bit_width; |
---|
| 508 | + u16 data_format; |
---|
| 509 | + u16 num_channels; |
---|
| 510 | + u16 active_channels_mask; |
---|
| 511 | +} __packed; |
---|
| 512 | + |
---|
450 | 513 | union afe_port_config { |
---|
451 | 514 | struct afe_param_id_hdmi_multi_chan_audio_cfg hdmi_multi_ch; |
---|
452 | 515 | struct afe_param_id_slimbus_cfg slim_cfg; |
---|
453 | 516 | struct afe_param_id_i2s_cfg i2s_cfg; |
---|
454 | 517 | struct afe_param_id_tdm_cfg tdm_cfg; |
---|
| 518 | + struct afe_param_id_cdc_dma_cfg dma_cfg; |
---|
455 | 519 | } __packed; |
---|
456 | 520 | |
---|
457 | 521 | |
---|
.. | .. |
---|
484 | 548 | struct kref refcount; |
---|
485 | 549 | struct list_head node; |
---|
486 | 550 | }; |
---|
| 551 | + |
---|
| 552 | +struct afe_cmd_remote_lpass_core_hw_vote_request { |
---|
| 553 | + uint32_t hw_block_id; |
---|
| 554 | + char client_name[8]; |
---|
| 555 | +} __packed; |
---|
| 556 | + |
---|
| 557 | +struct afe_cmd_remote_lpass_core_hw_devote_request { |
---|
| 558 | + uint32_t hw_block_id; |
---|
| 559 | + uint32_t client_handle; |
---|
| 560 | +} __packed; |
---|
| 561 | + |
---|
| 562 | + |
---|
487 | 563 | |
---|
488 | 564 | struct afe_port_map { |
---|
489 | 565 | int port_id; |
---|
.. | .. |
---|
704 | 780 | QUINARY_TDM_RX_7, 1, 1}, |
---|
705 | 781 | [QUINARY_TDM_TX_7] = { AFE_PORT_ID_QUINARY_TDM_TX_7, |
---|
706 | 782 | QUINARY_TDM_TX_7, 0, 1}, |
---|
| 783 | + [DISPLAY_PORT_RX] = { AFE_PORT_ID_HDMI_OVER_DP_RX, |
---|
| 784 | + DISPLAY_PORT_RX, 1, 1}, |
---|
| 785 | + [WSA_CODEC_DMA_RX_0] = { AFE_PORT_ID_WSA_CODEC_DMA_RX_0, |
---|
| 786 | + WSA_CODEC_DMA_RX_0, 1, 1}, |
---|
| 787 | + [WSA_CODEC_DMA_TX_0] = { AFE_PORT_ID_WSA_CODEC_DMA_TX_0, |
---|
| 788 | + WSA_CODEC_DMA_TX_0, 0, 1}, |
---|
| 789 | + [WSA_CODEC_DMA_RX_1] = { AFE_PORT_ID_WSA_CODEC_DMA_RX_1, |
---|
| 790 | + WSA_CODEC_DMA_RX_1, 1, 1}, |
---|
| 791 | + [WSA_CODEC_DMA_TX_1] = { AFE_PORT_ID_WSA_CODEC_DMA_TX_1, |
---|
| 792 | + WSA_CODEC_DMA_TX_1, 0, 1}, |
---|
| 793 | + [WSA_CODEC_DMA_TX_2] = { AFE_PORT_ID_WSA_CODEC_DMA_TX_2, |
---|
| 794 | + WSA_CODEC_DMA_TX_2, 0, 1}, |
---|
| 795 | + [VA_CODEC_DMA_TX_0] = { AFE_PORT_ID_VA_CODEC_DMA_TX_0, |
---|
| 796 | + VA_CODEC_DMA_TX_0, 0, 1}, |
---|
| 797 | + [VA_CODEC_DMA_TX_1] = { AFE_PORT_ID_VA_CODEC_DMA_TX_1, |
---|
| 798 | + VA_CODEC_DMA_TX_1, 0, 1}, |
---|
| 799 | + [VA_CODEC_DMA_TX_2] = { AFE_PORT_ID_VA_CODEC_DMA_TX_2, |
---|
| 800 | + VA_CODEC_DMA_TX_2, 0, 1}, |
---|
| 801 | + [RX_CODEC_DMA_RX_0] = { AFE_PORT_ID_RX_CODEC_DMA_RX_0, |
---|
| 802 | + RX_CODEC_DMA_RX_0, 1, 1}, |
---|
| 803 | + [TX_CODEC_DMA_TX_0] = { AFE_PORT_ID_TX_CODEC_DMA_TX_0, |
---|
| 804 | + TX_CODEC_DMA_TX_0, 0, 1}, |
---|
| 805 | + [RX_CODEC_DMA_RX_1] = { AFE_PORT_ID_RX_CODEC_DMA_RX_1, |
---|
| 806 | + RX_CODEC_DMA_RX_1, 1, 1}, |
---|
| 807 | + [TX_CODEC_DMA_TX_1] = { AFE_PORT_ID_TX_CODEC_DMA_TX_1, |
---|
| 808 | + TX_CODEC_DMA_TX_1, 0, 1}, |
---|
| 809 | + [RX_CODEC_DMA_RX_2] = { AFE_PORT_ID_RX_CODEC_DMA_RX_2, |
---|
| 810 | + RX_CODEC_DMA_RX_2, 1, 1}, |
---|
| 811 | + [TX_CODEC_DMA_TX_2] = { AFE_PORT_ID_TX_CODEC_DMA_TX_2, |
---|
| 812 | + TX_CODEC_DMA_TX_2, 0, 1}, |
---|
| 813 | + [RX_CODEC_DMA_RX_3] = { AFE_PORT_ID_RX_CODEC_DMA_RX_3, |
---|
| 814 | + RX_CODEC_DMA_RX_3, 1, 1}, |
---|
| 815 | + [TX_CODEC_DMA_TX_3] = { AFE_PORT_ID_TX_CODEC_DMA_TX_3, |
---|
| 816 | + TX_CODEC_DMA_TX_3, 0, 1}, |
---|
| 817 | + [RX_CODEC_DMA_RX_4] = { AFE_PORT_ID_RX_CODEC_DMA_RX_4, |
---|
| 818 | + RX_CODEC_DMA_RX_4, 1, 1}, |
---|
| 819 | + [TX_CODEC_DMA_TX_4] = { AFE_PORT_ID_TX_CODEC_DMA_TX_4, |
---|
| 820 | + TX_CODEC_DMA_TX_4, 0, 1}, |
---|
| 821 | + [RX_CODEC_DMA_RX_5] = { AFE_PORT_ID_RX_CODEC_DMA_RX_5, |
---|
| 822 | + RX_CODEC_DMA_RX_5, 1, 1}, |
---|
| 823 | + [TX_CODEC_DMA_TX_5] = { AFE_PORT_ID_TX_CODEC_DMA_TX_5, |
---|
| 824 | + TX_CODEC_DMA_TX_5, 0, 1}, |
---|
| 825 | + [RX_CODEC_DMA_RX_6] = { AFE_PORT_ID_RX_CODEC_DMA_RX_6, |
---|
| 826 | + RX_CODEC_DMA_RX_6, 1, 1}, |
---|
| 827 | + [RX_CODEC_DMA_RX_7] = { AFE_PORT_ID_RX_CODEC_DMA_RX_7, |
---|
| 828 | + RX_CODEC_DMA_RX_7, 1, 1}, |
---|
707 | 829 | }; |
---|
708 | 830 | |
---|
709 | 831 | static void q6afe_port_free(struct kref *ref) |
---|
.. | .. |
---|
766 | 888 | port->result = *res; |
---|
767 | 889 | wake_up(&port->wait); |
---|
768 | 890 | kref_put(&port->refcount, q6afe_port_free); |
---|
| 891 | + } else if (hdr->token == AFE_CLK_TOKEN) { |
---|
| 892 | + afe->result = *res; |
---|
| 893 | + wake_up(&afe->wait); |
---|
769 | 894 | } |
---|
770 | 895 | break; |
---|
771 | 896 | default: |
---|
.. | .. |
---|
773 | 898 | break; |
---|
774 | 899 | } |
---|
775 | 900 | } |
---|
| 901 | + break; |
---|
| 902 | + case AFE_CMD_RSP_REMOTE_LPASS_CORE_HW_VOTE_REQUEST: |
---|
| 903 | + afe->result.opcode = hdr->opcode; |
---|
| 904 | + afe->result.status = res->status; |
---|
| 905 | + wake_up(&afe->wait); |
---|
776 | 906 | break; |
---|
777 | 907 | default: |
---|
778 | 908 | break; |
---|
.. | .. |
---|
798 | 928 | EXPORT_SYMBOL_GPL(q6afe_get_port_id); |
---|
799 | 929 | |
---|
800 | 930 | static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt, |
---|
801 | | - struct q6afe_port *port) |
---|
| 931 | + struct q6afe_port *port, uint32_t rsp_opcode) |
---|
802 | 932 | { |
---|
803 | 933 | wait_queue_head_t *wait = &port->wait; |
---|
804 | | - struct apr_hdr *hdr = &pkt->hdr; |
---|
| 934 | + struct aprv2_ibasic_rsp_result_t *result; |
---|
805 | 935 | int ret; |
---|
806 | 936 | |
---|
807 | 937 | mutex_lock(&afe->lock); |
---|
808 | | - port->result.opcode = 0; |
---|
809 | | - port->result.status = 0; |
---|
| 938 | + if (port) { |
---|
| 939 | + wait = &port->wait; |
---|
| 940 | + result = &port->result; |
---|
| 941 | + } else { |
---|
| 942 | + result = &afe->result; |
---|
| 943 | + wait = &afe->wait; |
---|
| 944 | + } |
---|
| 945 | + |
---|
| 946 | + result->opcode = 0; |
---|
| 947 | + result->status = 0; |
---|
810 | 948 | |
---|
811 | 949 | ret = apr_send_pkt(afe->apr, pkt); |
---|
812 | 950 | if (ret < 0) { |
---|
.. | .. |
---|
815 | 953 | goto err; |
---|
816 | 954 | } |
---|
817 | 955 | |
---|
818 | | - ret = wait_event_timeout(*wait, (port->result.opcode == hdr->opcode), |
---|
| 956 | + ret = wait_event_timeout(*wait, (result->opcode == rsp_opcode), |
---|
819 | 957 | msecs_to_jiffies(TIMEOUT_MS)); |
---|
820 | 958 | if (!ret) { |
---|
821 | 959 | ret = -ETIMEDOUT; |
---|
822 | | - } else if (port->result.status > 0) { |
---|
| 960 | + } else if (result->status > 0) { |
---|
823 | 961 | dev_err(afe->dev, "DSP returned error[%x]\n", |
---|
824 | | - port->result.status); |
---|
| 962 | + result->status); |
---|
825 | 963 | ret = -EINVAL; |
---|
826 | 964 | } else { |
---|
827 | 965 | ret = 0; |
---|
.. | .. |
---|
833 | 971 | return ret; |
---|
834 | 972 | } |
---|
835 | 973 | |
---|
836 | | -static int q6afe_port_set_param(struct q6afe_port *port, void *data, |
---|
837 | | - int param_id, int module_id, int psize) |
---|
| 974 | +static int q6afe_set_param(struct q6afe *afe, struct q6afe_port *port, |
---|
| 975 | + void *data, int param_id, int module_id, int psize, |
---|
| 976 | + int token) |
---|
838 | 977 | { |
---|
839 | 978 | struct afe_svc_cmd_set_param *param; |
---|
840 | 979 | struct afe_port_param_data_v2 *pdata; |
---|
841 | | - struct q6afe *afe = port->afe; |
---|
842 | 980 | struct apr_pkt *pkt; |
---|
843 | | - u16 port_id = port->id; |
---|
844 | 981 | int ret, pkt_size; |
---|
845 | 982 | void *p, *pl; |
---|
846 | 983 | |
---|
.. | .. |
---|
861 | 998 | pkt->hdr.pkt_size = pkt_size; |
---|
862 | 999 | pkt->hdr.src_port = 0; |
---|
863 | 1000 | pkt->hdr.dest_port = 0; |
---|
864 | | - pkt->hdr.token = port->token; |
---|
| 1001 | + pkt->hdr.token = token; |
---|
865 | 1002 | pkt->hdr.opcode = AFE_SVC_CMD_SET_PARAM; |
---|
866 | 1003 | |
---|
867 | 1004 | param->payload_size = sizeof(*pdata) + psize; |
---|
.. | .. |
---|
872 | 1009 | pdata->param_id = param_id; |
---|
873 | 1010 | pdata->param_size = psize; |
---|
874 | 1011 | |
---|
875 | | - ret = afe_apr_send_pkt(afe, pkt, port); |
---|
| 1012 | + ret = afe_apr_send_pkt(afe, pkt, port, AFE_SVC_CMD_SET_PARAM); |
---|
876 | 1013 | if (ret) |
---|
877 | | - dev_err(afe->dev, "AFE enable for port 0x%x failed %d\n", |
---|
878 | | - port_id, ret); |
---|
| 1014 | + dev_err(afe->dev, "AFE set params failed %d\n", ret); |
---|
879 | 1015 | |
---|
880 | 1016 | kfree(pkt); |
---|
881 | 1017 | return ret; |
---|
| 1018 | +} |
---|
| 1019 | + |
---|
| 1020 | +static int q6afe_port_set_param(struct q6afe_port *port, void *data, |
---|
| 1021 | + int param_id, int module_id, int psize) |
---|
| 1022 | +{ |
---|
| 1023 | + return q6afe_set_param(port->afe, port, data, param_id, module_id, |
---|
| 1024 | + psize, port->token); |
---|
882 | 1025 | } |
---|
883 | 1026 | |
---|
884 | 1027 | static int q6afe_port_set_param_v2(struct q6afe_port *port, void *data, |
---|
.. | .. |
---|
921 | 1064 | pdata->param_id = param_id; |
---|
922 | 1065 | pdata->param_size = psize; |
---|
923 | 1066 | |
---|
924 | | - ret = afe_apr_send_pkt(afe, pkt, port); |
---|
| 1067 | + ret = afe_apr_send_pkt(afe, pkt, port, AFE_PORT_CMD_SET_PARAM_V2); |
---|
925 | 1068 | if (ret) |
---|
926 | 1069 | dev_err(afe->dev, "AFE enable for port 0x%x failed %d\n", |
---|
927 | 1070 | port_id, ret); |
---|
.. | .. |
---|
930 | 1073 | return ret; |
---|
931 | 1074 | } |
---|
932 | 1075 | |
---|
933 | | -static int q6afe_set_lpass_clock(struct q6afe_port *port, |
---|
| 1076 | +static int q6afe_port_set_lpass_clock(struct q6afe_port *port, |
---|
934 | 1077 | struct afe_clk_cfg *cfg) |
---|
935 | 1078 | { |
---|
936 | 1079 | return q6afe_port_set_param_v2(port, cfg, |
---|
.. | .. |
---|
955 | 1098 | sizeof(*cfg)); |
---|
956 | 1099 | } |
---|
957 | 1100 | |
---|
| 1101 | +int q6afe_set_lpass_clock(struct device *dev, int clk_id, int attri, |
---|
| 1102 | + int clk_root, unsigned int freq) |
---|
| 1103 | +{ |
---|
| 1104 | + struct q6afe *afe = dev_get_drvdata(dev->parent); |
---|
| 1105 | + struct afe_clk_set cset = {0,}; |
---|
| 1106 | + |
---|
| 1107 | + cset.clk_set_minor_version = AFE_API_VERSION_CLOCK_SET; |
---|
| 1108 | + cset.clk_id = clk_id; |
---|
| 1109 | + cset.clk_freq_in_hz = freq; |
---|
| 1110 | + cset.clk_attri = attri; |
---|
| 1111 | + cset.clk_root = clk_root; |
---|
| 1112 | + cset.enable = !!freq; |
---|
| 1113 | + |
---|
| 1114 | + return q6afe_set_param(afe, NULL, &cset, AFE_PARAM_ID_CLOCK_SET, |
---|
| 1115 | + AFE_MODULE_CLOCK_SET, sizeof(cset), |
---|
| 1116 | + AFE_CLK_TOKEN); |
---|
| 1117 | +} |
---|
| 1118 | +EXPORT_SYMBOL_GPL(q6afe_set_lpass_clock); |
---|
| 1119 | + |
---|
958 | 1120 | int q6afe_port_set_sysclk(struct q6afe_port *port, int clk_id, |
---|
959 | 1121 | int clk_src, int clk_root, |
---|
960 | 1122 | unsigned int freq, int dir) |
---|
.. | .. |
---|
977 | 1139 | ccfg.clk_src = clk_src; |
---|
978 | 1140 | ccfg.clk_root = clk_root; |
---|
979 | 1141 | ccfg.clk_set_mode = Q6AFE_LPASS_MODE_CLK1_VALID; |
---|
980 | | - ret = q6afe_set_lpass_clock(port, &ccfg); |
---|
| 1142 | + ret = q6afe_port_set_lpass_clock(port, &ccfg); |
---|
981 | 1143 | break; |
---|
982 | 1144 | |
---|
983 | 1145 | case LPAIF_OSR_CLK: |
---|
.. | .. |
---|
986 | 1148 | ccfg.clk_src = clk_src; |
---|
987 | 1149 | ccfg.clk_root = clk_root; |
---|
988 | 1150 | ccfg.clk_set_mode = Q6AFE_LPASS_MODE_CLK2_VALID; |
---|
989 | | - ret = q6afe_set_lpass_clock(port, &ccfg); |
---|
| 1151 | + ret = q6afe_port_set_lpass_clock(port, &ccfg); |
---|
990 | 1152 | break; |
---|
991 | 1153 | case Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT ... Q6AFE_LPASS_CLK_ID_QUI_MI2S_OSR: |
---|
992 | 1154 | case Q6AFE_LPASS_CLK_ID_MCLK_1 ... Q6AFE_LPASS_CLK_ID_INT_MCLK_1: |
---|
993 | 1155 | case Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT ... Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT: |
---|
| 1156 | + case Q6AFE_LPASS_CLK_ID_WSA_CORE_MCLK ... Q6AFE_LPASS_CLK_ID_VA_CORE_2X_MCLK: |
---|
994 | 1157 | cset.clk_set_minor_version = AFE_API_VERSION_CLOCK_SET; |
---|
995 | 1158 | cset.clk_id = clk_id; |
---|
996 | 1159 | cset.clk_freq_in_hz = freq; |
---|
.. | .. |
---|
1051 | 1214 | stop->port_id = port_id; |
---|
1052 | 1215 | stop->reserved = 0; |
---|
1053 | 1216 | |
---|
1054 | | - ret = afe_apr_send_pkt(afe, pkt, port); |
---|
| 1217 | + ret = afe_apr_send_pkt(afe, pkt, port, AFE_PORT_CMD_DEVICE_STOP); |
---|
1055 | 1218 | if (ret) |
---|
1056 | 1219 | dev_err(afe->dev, "AFE close failed %d\n", ret); |
---|
1057 | 1220 | |
---|
.. | .. |
---|
1286 | 1449 | EXPORT_SYMBOL_GPL(q6afe_i2s_port_prepare); |
---|
1287 | 1450 | |
---|
1288 | 1451 | /** |
---|
| 1452 | + * q6afe_dam_port_prepare() - Prepare dma afe port. |
---|
| 1453 | + * |
---|
| 1454 | + * @port: Instance of afe port |
---|
| 1455 | + * @cfg: DMA configuration for the afe port |
---|
| 1456 | + * |
---|
| 1457 | + */ |
---|
| 1458 | +void q6afe_cdc_dma_port_prepare(struct q6afe_port *port, |
---|
| 1459 | + struct q6afe_cdc_dma_cfg *cfg) |
---|
| 1460 | +{ |
---|
| 1461 | + union afe_port_config *pcfg = &port->port_cfg; |
---|
| 1462 | + struct afe_param_id_cdc_dma_cfg *dma_cfg = &pcfg->dma_cfg; |
---|
| 1463 | + |
---|
| 1464 | + dma_cfg->cdc_dma_cfg_minor_version = AFE_API_VERSION_CODEC_DMA_CONFIG; |
---|
| 1465 | + dma_cfg->sample_rate = cfg->sample_rate; |
---|
| 1466 | + dma_cfg->bit_width = cfg->bit_width; |
---|
| 1467 | + dma_cfg->data_format = cfg->data_format; |
---|
| 1468 | + dma_cfg->num_channels = cfg->num_channels; |
---|
| 1469 | + if (!cfg->active_channels_mask) |
---|
| 1470 | + dma_cfg->active_channels_mask = (1 << cfg->num_channels) - 1; |
---|
| 1471 | +} |
---|
| 1472 | +EXPORT_SYMBOL_GPL(q6afe_cdc_dma_port_prepare); |
---|
| 1473 | +/** |
---|
1289 | 1474 | * q6afe_port_start() - Start a afe port |
---|
1290 | 1475 | * |
---|
1291 | 1476 | * @port: Instance of port to start |
---|
.. | .. |
---|
1341 | 1526 | |
---|
1342 | 1527 | start->port_id = port_id; |
---|
1343 | 1528 | |
---|
1344 | | - ret = afe_apr_send_pkt(afe, pkt, port); |
---|
| 1529 | + ret = afe_apr_send_pkt(afe, pkt, port, AFE_PORT_CMD_DEVICE_START); |
---|
1345 | 1530 | if (ret) |
---|
1346 | 1531 | dev_err(afe->dev, "AFE enable for port 0x%x failed %d\n", |
---|
1347 | 1532 | port_id, ret); |
---|
.. | .. |
---|
1384 | 1569 | |
---|
1385 | 1570 | switch (port_id) { |
---|
1386 | 1571 | case AFE_PORT_ID_MULTICHAN_HDMI_RX: |
---|
| 1572 | + case AFE_PORT_ID_HDMI_OVER_DP_RX: |
---|
1387 | 1573 | cfg_type = AFE_PARAM_ID_HDMI_CONFIG; |
---|
1388 | 1574 | break; |
---|
1389 | 1575 | case AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_TX: |
---|
.. | .. |
---|
1416 | 1602 | case AFE_PORT_ID_PRIMARY_TDM_RX ... AFE_PORT_ID_QUINARY_TDM_TX_7: |
---|
1417 | 1603 | cfg_type = AFE_PARAM_ID_TDM_CONFIG; |
---|
1418 | 1604 | break; |
---|
1419 | | - |
---|
| 1605 | + case AFE_PORT_ID_WSA_CODEC_DMA_RX_0 ... AFE_PORT_ID_RX_CODEC_DMA_RX_7: |
---|
| 1606 | + cfg_type = AFE_PARAM_ID_CODEC_DMA_CONFIG; |
---|
| 1607 | + break; |
---|
1420 | 1608 | default: |
---|
1421 | 1609 | dev_err(dev, "Invalid port id 0x%x\n", port_id); |
---|
1422 | 1610 | return ERR_PTR(-EINVAL); |
---|
.. | .. |
---|
1454 | 1642 | } |
---|
1455 | 1643 | EXPORT_SYMBOL_GPL(q6afe_port_put); |
---|
1456 | 1644 | |
---|
| 1645 | +int q6afe_unvote_lpass_core_hw(struct device *dev, uint32_t hw_block_id, |
---|
| 1646 | + uint32_t client_handle) |
---|
| 1647 | +{ |
---|
| 1648 | + struct q6afe *afe = dev_get_drvdata(dev->parent); |
---|
| 1649 | + struct afe_cmd_remote_lpass_core_hw_devote_request *vote_cfg; |
---|
| 1650 | + struct apr_pkt *pkt; |
---|
| 1651 | + int ret = 0; |
---|
| 1652 | + int pkt_size; |
---|
| 1653 | + void *p; |
---|
| 1654 | + |
---|
| 1655 | + pkt_size = APR_HDR_SIZE + sizeof(*vote_cfg); |
---|
| 1656 | + p = kzalloc(pkt_size, GFP_KERNEL); |
---|
| 1657 | + if (!p) |
---|
| 1658 | + return -ENOMEM; |
---|
| 1659 | + |
---|
| 1660 | + pkt = p; |
---|
| 1661 | + vote_cfg = p + APR_HDR_SIZE; |
---|
| 1662 | + |
---|
| 1663 | + pkt->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, |
---|
| 1664 | + APR_HDR_LEN(APR_HDR_SIZE), |
---|
| 1665 | + APR_PKT_VER); |
---|
| 1666 | + pkt->hdr.pkt_size = pkt_size; |
---|
| 1667 | + pkt->hdr.src_port = 0; |
---|
| 1668 | + pkt->hdr.dest_port = 0; |
---|
| 1669 | + pkt->hdr.token = hw_block_id; |
---|
| 1670 | + pkt->hdr.opcode = AFE_CMD_REMOTE_LPASS_CORE_HW_DEVOTE_REQUEST; |
---|
| 1671 | + vote_cfg->hw_block_id = hw_block_id; |
---|
| 1672 | + vote_cfg->client_handle = client_handle; |
---|
| 1673 | + |
---|
| 1674 | + ret = apr_send_pkt(afe->apr, pkt); |
---|
| 1675 | + if (ret < 0) |
---|
| 1676 | + dev_err(afe->dev, "AFE failed to unvote (%d)\n", hw_block_id); |
---|
| 1677 | + |
---|
| 1678 | + kfree(pkt); |
---|
| 1679 | + return ret; |
---|
| 1680 | +} |
---|
| 1681 | +EXPORT_SYMBOL(q6afe_unvote_lpass_core_hw); |
---|
| 1682 | + |
---|
| 1683 | +int q6afe_vote_lpass_core_hw(struct device *dev, uint32_t hw_block_id, |
---|
| 1684 | + char *client_name, uint32_t *client_handle) |
---|
| 1685 | +{ |
---|
| 1686 | + struct q6afe *afe = dev_get_drvdata(dev->parent); |
---|
| 1687 | + struct afe_cmd_remote_lpass_core_hw_vote_request *vote_cfg; |
---|
| 1688 | + struct apr_pkt *pkt; |
---|
| 1689 | + int ret = 0; |
---|
| 1690 | + int pkt_size; |
---|
| 1691 | + void *p; |
---|
| 1692 | + |
---|
| 1693 | + pkt_size = APR_HDR_SIZE + sizeof(*vote_cfg); |
---|
| 1694 | + p = kzalloc(pkt_size, GFP_KERNEL); |
---|
| 1695 | + if (!p) |
---|
| 1696 | + return -ENOMEM; |
---|
| 1697 | + |
---|
| 1698 | + pkt = p; |
---|
| 1699 | + vote_cfg = p + APR_HDR_SIZE; |
---|
| 1700 | + |
---|
| 1701 | + pkt->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, |
---|
| 1702 | + APR_HDR_LEN(APR_HDR_SIZE), |
---|
| 1703 | + APR_PKT_VER); |
---|
| 1704 | + pkt->hdr.pkt_size = pkt_size; |
---|
| 1705 | + pkt->hdr.src_port = 0; |
---|
| 1706 | + pkt->hdr.dest_port = 0; |
---|
| 1707 | + pkt->hdr.token = hw_block_id; |
---|
| 1708 | + pkt->hdr.opcode = AFE_CMD_REMOTE_LPASS_CORE_HW_VOTE_REQUEST; |
---|
| 1709 | + vote_cfg->hw_block_id = hw_block_id; |
---|
| 1710 | + strlcpy(vote_cfg->client_name, client_name, |
---|
| 1711 | + sizeof(vote_cfg->client_name)); |
---|
| 1712 | + |
---|
| 1713 | + ret = afe_apr_send_pkt(afe, pkt, NULL, |
---|
| 1714 | + AFE_CMD_RSP_REMOTE_LPASS_CORE_HW_VOTE_REQUEST); |
---|
| 1715 | + if (ret) |
---|
| 1716 | + dev_err(afe->dev, "AFE failed to vote (%d)\n", hw_block_id); |
---|
| 1717 | + |
---|
| 1718 | + |
---|
| 1719 | + kfree(pkt); |
---|
| 1720 | + return ret; |
---|
| 1721 | +} |
---|
| 1722 | +EXPORT_SYMBOL(q6afe_vote_lpass_core_hw); |
---|
| 1723 | + |
---|
1457 | 1724 | static int q6afe_probe(struct apr_device *adev) |
---|
1458 | 1725 | { |
---|
1459 | 1726 | struct q6afe *afe; |
---|
.. | .. |
---|
1466 | 1733 | q6core_get_svc_api_info(adev->svc_id, &afe->ainfo); |
---|
1467 | 1734 | afe->apr = adev; |
---|
1468 | 1735 | mutex_init(&afe->lock); |
---|
| 1736 | + init_waitqueue_head(&afe->wait); |
---|
1469 | 1737 | afe->dev = dev; |
---|
1470 | 1738 | INIT_LIST_HEAD(&afe->port_list); |
---|
1471 | 1739 | spin_lock_init(&afe->port_list_lock); |
---|
.. | .. |
---|
1482 | 1750 | return 0; |
---|
1483 | 1751 | } |
---|
1484 | 1752 | |
---|
| 1753 | +#ifdef CONFIG_OF |
---|
1485 | 1754 | static const struct of_device_id q6afe_device_id[] = { |
---|
1486 | 1755 | { .compatible = "qcom,q6afe" }, |
---|
1487 | 1756 | {}, |
---|
1488 | 1757 | }; |
---|
1489 | 1758 | MODULE_DEVICE_TABLE(of, q6afe_device_id); |
---|
| 1759 | +#endif |
---|
1490 | 1760 | |
---|
1491 | 1761 | static struct apr_driver qcom_q6afe_driver = { |
---|
1492 | 1762 | .probe = q6afe_probe, |
---|