blob: 8c1453f49ff39e42647fd45135954f1fba22f958 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Komal Seelam6ee55902016-04-11 17:11:07 +05302 * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#ifndef __HIF_IO32_H__
29#define __HIF_IO32_H__
30
31#include <linux/io.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080032#include "hif.h"
Govind Singh4cc82132016-05-12 20:02:01 +053033#include "hif_main.h"
Houston Hoffman858f7232016-03-14 21:11:54 -070034
35#define hif_read32_mb(addr) ioread32((void __iomem *)addr)
36#define hif_write32_mb(addr, value) \
37 iowrite32((u32)(value), (void __iomem *)(addr))
38
Houston Hoffmanbd8c04f2016-03-14 21:11:55 -070039#define Q_TARGET_ACCESS_BEGIN(scn) \
40 hif_target_sleep_state_adjust(scn, false, true)
41#define Q_TARGET_ACCESS_END(scn) \
42 hif_target_sleep_state_adjust(scn, true, false)
43
Houston Hoffman0b489132016-03-14 21:11:57 -070044/*
45 * A_TARGET_ACCESS_LIKELY will not wait for the target to wake up before
46 * continuing execution. Because A_TARGET_ACCESS_LIKELY does not guarantee
47 * that the target is awake before continuing, Q_TARGET_ACCESS macros must
48 * protect the actual target access. Since Q_TARGET_ACCESS protect the actual
49 * target access, A_TARGET_ACCESS_LIKELY hints are optional.
50 *
51 * To ignore "LIKELY" hints, set CONFIG_TARGET_ACCESS_LIKELY to 0
52 * (slightly worse performance, less power)
53 *
54 * To use "LIKELY" hints, set CONFIG_TARGET_ACCESS_LIKELY to 1
55 * (slightly better performance, more power)
56 *
57 * note: if a bus doesn't use hif_target_sleep_state_adjust, this will have
58 * no impact.
59 */
60#define CONFIG_TARGET_ACCESS_LIKELY 0
61#if CONFIG_TARGET_ACCESS_LIKELY
62#define A_TARGET_ACCESS_LIKELY(scn) \
63 hif_target_sleep_state_adjust(scn, false, false)
64#define A_TARGET_ACCESS_UNLIKELY(scn) \
65 hif_target_sleep_state_adjust(scn, true, false)
66#else /* CONFIG_ATH_PCIE_ACCESS_LIKELY */
67#define A_TARGET_ACCESS_LIKELY(scn) \
68 do { \
69 unsigned long unused = (unsigned long)(scn); \
70 unused = unused; \
71 } while (0)
72
73#define A_TARGET_ACCESS_UNLIKELY(scn) \
74 do { \
75 unsigned long unused = (unsigned long)(scn); \
76 unused = unused; \
77 } while (0)
78#endif /* CONFIG_ATH_PCIE_ACCESS_LIKELY */
79
80
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081#ifdef HIF_PCI
82#include "hif_io32_pci.h"
Houston Hoffmanbc693492016-03-14 21:11:41 -070083#endif
Houston Hoffmanbc693492016-03-14 21:11:41 -070084#ifdef HIF_SNOC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085#include "hif_io32_snoc.h"
86#endif /* HIF_PCI */
Houston Hoffman858f7232016-03-14 21:11:54 -070087
88#ifdef CONFIG_IO_MEM_ACCESS_DEBUG
89uint32_t hif_target_read_checked(struct hif_softc *scn,
90 uint32_t offset);
91void hif_target_write_checked(struct hif_softc *scn, uint32_t offset,
92 uint32_t value);
93
94#define A_TARGET_READ(scn, offset) \
95 hif_target_read_checked(scn, (offset))
96#define A_TARGET_WRITE(scn, offset, value) \
97 hif_target_write_checked(scn, (offset), (value))
98#else /* CONFIG_ATH_PCIE_ACCESS_DEBUG */
99#define A_TARGET_READ(scn, offset) \
100 hif_read32_mb(scn->mem + (offset))
101#define A_TARGET_WRITE(scn, offset, value) \
102 hif_write32_mb((scn->mem) + (offset), value)
103#endif
104
Houston Hoffman8f239f62016-03-14 21:12:05 -0700105void hif_irq_enable(struct hif_softc *scn, int irq_id);
106void hif_irq_disable(struct hif_softc *scn, int irq_id);
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530107void hif_grp_irq_enable(struct hif_softc *scn, uint32_t grp_id);
108void hif_grp_irq_disable(struct hif_softc *scn, uint32_t grp_id);
Houston Hoffman858f7232016-03-14 21:11:54 -0700109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110#endif /* __HIF_IO32_H__ */