xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/dispatcher/multibus_pci.c (revision 4865edfd190c086bbe2c69aae12a8226f877b91e)
1 /*
2  * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #include "hif.h"
20 #include "hif_main.h"
21 #include "multibus.h"
22 #include "pci_api.h"
23 #include "hif_io32.h"
24 #include "dummy.h"
25 #include "ce_api.h"
26 
27 /**
28  * hif_initialize_pci_ops() - initialize the pci ops
29  * @bus_ops: hif_bus_ops table pointer to initialize
30  *
31  * Return: QDF_STATUS_SUCCESS
32  */
33 QDF_STATUS hif_initialize_pci_ops(struct hif_softc *hif_sc)
34 {
35 	struct hif_bus_ops *bus_ops = &hif_sc->bus_ops;
36 
37 	bus_ops->hif_bus_open = &hif_pci_open;
38 	bus_ops->hif_bus_close = &hif_pci_close;
39 	bus_ops->hif_bus_prevent_linkdown = &hif_pci_prevent_linkdown;
40 	bus_ops->hif_reset_soc = &hif_pci_reset_soc;
41 	bus_ops->hif_bus_suspend = &hif_pci_bus_suspend;
42 	bus_ops->hif_bus_resume = &hif_pci_bus_resume;
43 	bus_ops->hif_bus_suspend_noirq = &hif_pci_bus_suspend_noirq;
44 	bus_ops->hif_bus_resume_noirq = &hif_pci_bus_resume_noirq;
45 
46 	/* do not put the target to sleep for epping or maxperf mode */
47 	if (CONFIG_ATH_PCIE_MAX_PERF == 0 &&
48 	    !QDF_IS_EPPING_ENABLED(hif_get_conparam(hif_sc)))
49 		bus_ops->hif_target_sleep_state_adjust =
50 			&hif_pci_target_sleep_state_adjust;
51 	else
52 		bus_ops->hif_target_sleep_state_adjust =
53 			&hif_dummy_target_sleep_state_adjust;
54 
55 	bus_ops->hif_disable_isr = &hif_pci_disable_isr;
56 	bus_ops->hif_nointrs = &hif_pci_nointrs;
57 	bus_ops->hif_enable_bus = &hif_pci_enable_bus;
58 	bus_ops->hif_disable_bus = &hif_pci_disable_bus;
59 	bus_ops->hif_bus_configure = &hif_pci_bus_configure;
60 	bus_ops->hif_get_config_item = &hif_dummy_get_config_item;
61 	bus_ops->hif_set_mailbox_swap = &hif_dummy_set_mailbox_swap;
62 	bus_ops->hif_claim_device = &hif_dummy_claim_device;
63 	bus_ops->hif_shutdown_device = &hif_ce_stop;
64 	bus_ops->hif_stop = &hif_ce_stop;
65 	bus_ops->hif_cancel_deferred_target_sleep =
66 					&hif_pci_cancel_deferred_target_sleep;
67 	bus_ops->hif_irq_disable = &hif_pci_irq_disable;
68 	bus_ops->hif_irq_enable = &hif_pci_irq_enable;
69 	bus_ops->hif_dump_registers = &hif_pci_dump_registers;
70 	bus_ops->hif_dump_target_memory = &hif_ce_dump_target_memory;
71 	bus_ops->hif_ipa_get_ce_resource = &hif_ce_ipa_get_ce_resource;
72 	bus_ops->hif_mask_interrupt_call = &hif_dummy_mask_interrupt_call;
73 	bus_ops->hif_enable_power_management =
74 		&hif_pci_enable_power_management;
75 	bus_ops->hif_disable_power_management =
76 		&hif_pci_disable_power_management;
77 	bus_ops->hif_grp_irq_configure = &hif_pci_configure_grp_irq;
78 	bus_ops->hif_display_stats =
79 		&hif_pci_display_stats;
80 	bus_ops->hif_clear_stats =
81 		&hif_pci_clear_stats;
82 	bus_ops->hif_addr_in_boundary = &hif_pci_addr_in_boundary;
83 
84 	/* default to legacy mapping handler; override as needed */
85 	bus_ops->hif_map_ce_to_irq = &hif_pci_legacy_map_ce_to_irq;
86 	bus_ops->hif_needs_bmi = &hif_pci_needs_bmi;
87 
88 	return QDF_STATUS_SUCCESS;
89 }
90 
91 /**
92  * hif_pci_get_context_size() - return the size of the pci context
93  *
94  * Return the size of the context.  (0 for invalid bus)
95  */
96 int hif_pci_get_context_size(void)
97 {
98 	return sizeof(struct hif_pci_softc);
99 }
100