Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Komal Seelam | 6ee5590 | 2016-04-11 17:11:07 +0530 | [diff] [blame] | 2 | * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 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 Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 32 | #include "hif.h" |
Govind Singh | 4cc8213 | 2016-05-12 20:02:01 +0530 | [diff] [blame] | 33 | #include "hif_main.h" |
Houston Hoffman | 858f723 | 2016-03-14 21:11:54 -0700 | [diff] [blame] | 34 | |
| 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 Hoffman | bd8c04f | 2016-03-14 21:11:55 -0700 | [diff] [blame] | 39 | #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 Hoffman | 0b48913 | 2016-03-14 21:11:57 -0700 | [diff] [blame] | 44 | /* |
| 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 Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | #ifdef HIF_PCI |
| 82 | #include "hif_io32_pci.h" |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 83 | #endif |
Houston Hoffman | bc69349 | 2016-03-14 21:11:41 -0700 | [diff] [blame] | 84 | #ifdef HIF_SNOC |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 85 | #include "hif_io32_snoc.h" |
| 86 | #endif /* HIF_PCI */ |
Houston Hoffman | 858f723 | 2016-03-14 21:11:54 -0700 | [diff] [blame] | 87 | |
| 88 | #ifdef CONFIG_IO_MEM_ACCESS_DEBUG |
| 89 | uint32_t hif_target_read_checked(struct hif_softc *scn, |
| 90 | uint32_t offset); |
| 91 | void 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 Hoffman | 8f239f6 | 2016-03-14 21:12:05 -0700 | [diff] [blame] | 105 | void hif_irq_enable(struct hif_softc *scn, int irq_id); |
| 106 | void hif_irq_disable(struct hif_softc *scn, int irq_id); |
Venkateswara Swamy Bandaru | 31108f3 | 2016-08-08 18:04:29 +0530 | [diff] [blame] | 107 | void hif_grp_irq_enable(struct hif_softc *scn, uint32_t grp_id); |
| 108 | void hif_grp_irq_disable(struct hif_softc *scn, uint32_t grp_id); |
Houston Hoffman | 858f723 | 2016-03-14 21:11:54 -0700 | [diff] [blame] | 109 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 110 | #endif /* __HIF_IO32_H__ */ |