2 * Copyright (c) 2016 Landon Fuller <landonf@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification.
11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 * redistribution must be conditioned upon including a substantially
14 * similar Disclaimer requirement for further binary redistribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
32 #ifndef _MIPS_BROADCOM_BCM_MACHDEP_H_
33 #define _MIPS_BROADCOM_BCM_MACHDEP_H_
35 #include <machine/cpufunc.h>
36 #include <machine/cpuregs.h>
38 #include <dev/bhnd/bhnd.h>
39 #include <dev/bhnd/bhnd_erom.h>
41 #include <dev/bhnd/cores/pmu/bhnd_pmuvar.h>
43 extern const struct bhnd_pmu_io bcm_pmu_soc_io;
46 struct bhnd_chipid cid; /**< chip id */
47 struct bhnd_core_info cc_id; /**< chipc core info */
48 uintptr_t cc_addr; /**< chipc core phys address */
49 uint32_t cc_caps; /**< chipc capabilities */
50 uint32_t cc_caps_ext; /**< chipc extended capabilies */
52 /* On non-AOB devices, the PMU register block is mapped to chipc;
53 * the pmu_id and pmu_addr values will be copied from cc_id
55 struct bhnd_core_info pmu_id; /**< PMU core info */
56 uintptr_t pmu_addr; /**< PMU core phys address, or
59 struct bhnd_pmu_query pmu; /**< PMU query instance */
61 bhnd_erom_class_t *erom_impl; /**< erom parser class */
62 struct kobj_ops erom_ops; /**< compiled kobj opcache */
64 bhnd_erom_static_t data;
69 int cfe_console; /**< Console handle, or -1 */
73 struct bcm_platform *bcm_get_platform(void);
75 uint64_t bcm_get_cpufreq(struct bcm_platform *bp);
76 uint64_t bcm_get_sifreq(struct bcm_platform *bp);
77 uint64_t bcm_get_alpfreq(struct bcm_platform *bp);
78 uint64_t bcm_get_ilpfreq(struct bcm_platform *bp);
80 u_int bcm_get_uart_rclk(struct bcm_platform *bp);
82 #define BCM_ERR(fmt, ...) \
83 printf("%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
85 #define BCM_SOC_BSH(_addr, _offset) \
86 ((bus_space_handle_t)BCM_SOC_ADDR((_addr), (_offset)))
88 #define BCM_SOC_ADDR(_addr, _offset) \
89 MIPS_PHYS_TO_KSEG1((_addr) + (_offset))
91 #define BCM_SOC_READ_4(_addr, _offset) \
92 readl(BCM_SOC_ADDR((_addr), (_offset)))
93 #define BCM_SOC_WRITE_4(_addr, _reg, _val) \
94 writel(BCM_SOC_ADDR((_addr), (_offset)), (_val))
96 #define BCM_CORE_ADDR(_bp, _name, _reg) \
97 BCM_SOC_ADDR(_bp->_name, (_reg))
99 #define BCM_CORE_READ_4(_bp, _name, _reg) \
100 readl(BCM_CORE_ADDR(_bp, _name, (_reg)))
101 #define BCM_CORE_WRITE_4(_bp, _name, _reg, _val) \
102 writel(BCM_CORE_ADDR(_bp, _name, (_reg)), (_val))
104 #define BCM_CHIPC_READ_4(_bp, _reg) \
105 BCM_CORE_READ_4(_bp, cc_addr, (_reg))
106 #define BCM_CHIPC_WRITE_4(_bp, _reg, _val) \
107 BCM_CORE_WRITE_4(_bp, cc_addr, (_reg), (_val))
109 #define BCM_PMU_READ_4(_bp, _reg) \
110 BCM_CORE_READ_4(_bp, pmu_addr, (_reg))
111 #define BCM_PMU_WRITE_4(_bp, _reg, _val) \
112 BCM_CORE_WRITE_4(_bp, pmu_addr, (_reg), (_val))
114 #endif /* _MIPS_BROADCOM_BCM_MACHDEP_H_ */