Pawel Moll | 3ecbf05 | 2012-09-24 14:55:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify |
| 3 | * it under the terms of the GNU General Public License version 2 as |
| 4 | * published by the Free Software Foundation. |
| 5 | * |
| 6 | * This program is distributed in the hope that it will be useful, |
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 | * GNU General Public License for more details. |
| 10 | * |
| 11 | * Copyright (C) 2012 ARM Limited |
| 12 | */ |
| 13 | |
| 14 | #ifndef _LINUX_VEXPRESS_H |
| 15 | #define _LINUX_VEXPRESS_H |
| 16 | |
| 17 | #include <linux/device.h> |
| 18 | |
| 19 | #define VEXPRESS_SITE_MB 0 |
| 20 | #define VEXPRESS_SITE_DB1 1 |
| 21 | #define VEXPRESS_SITE_DB2 2 |
| 22 | #define VEXPRESS_SITE_MASTER 0xf |
| 23 | |
| 24 | #define VEXPRESS_CONFIG_STATUS_DONE 0 |
| 25 | #define VEXPRESS_CONFIG_STATUS_WAIT 1 |
| 26 | |
Pawel Moll | 88e0abc | 2012-09-18 12:24:57 +0100 | [diff] [blame] | 27 | #define VEXPRESS_GPIO_MMC_CARDIN 0 |
| 28 | #define VEXPRESS_GPIO_MMC_WPROT 1 |
| 29 | #define VEXPRESS_GPIO_FLASH_WPn 2 |
Pawel Moll | 8ea402f | 2013-01-30 10:33:16 +0000 | [diff] [blame] | 30 | #define VEXPRESS_GPIO_LED0 3 |
| 31 | #define VEXPRESS_GPIO_LED1 4 |
| 32 | #define VEXPRESS_GPIO_LED2 5 |
| 33 | #define VEXPRESS_GPIO_LED3 6 |
| 34 | #define VEXPRESS_GPIO_LED4 7 |
| 35 | #define VEXPRESS_GPIO_LED5 8 |
| 36 | #define VEXPRESS_GPIO_LED6 9 |
| 37 | #define VEXPRESS_GPIO_LED7 10 |
Pawel Moll | 88e0abc | 2012-09-18 12:24:57 +0100 | [diff] [blame] | 38 | |
| 39 | #define VEXPRESS_RES_FUNC(_site, _func) \ |
| 40 | { \ |
| 41 | .start = (_site), \ |
| 42 | .end = (_func), \ |
| 43 | .flags = IORESOURCE_BUS, \ |
| 44 | } |
| 45 | |
Pawel Moll | 3ecbf05 | 2012-09-24 14:55:40 +0100 | [diff] [blame] | 46 | /* Config bridge API */ |
| 47 | |
| 48 | /** |
| 49 | * struct vexpress_config_bridge_info - description of the platform |
| 50 | * configuration infrastructure bridge. |
| 51 | * |
| 52 | * @name: Bridge name |
| 53 | * |
| 54 | * @func_get: Obtains pointer to a configuration function for a given |
| 55 | * device or a Device Tree node, to be used with @func_put |
| 56 | * and @func_exec. The node pointer should take precedence |
| 57 | * over device pointer when both are passed. |
| 58 | * |
| 59 | * @func_put: Tells the bridge that the function will not be used any |
| 60 | * more, so all allocated resources can be released. |
| 61 | * |
| 62 | * @func_exec: Executes a configuration function read or write operation. |
| 63 | * The offset selects a 32 bit word of the value accessed. |
| 64 | * Must return VEXPRESS_CONFIG_STATUS_DONE when operation |
| 65 | * is finished immediately, VEXPRESS_CONFIG_STATUS_WAIT when |
| 66 | * will be completed in some time or negative value in case |
| 67 | * of error. |
| 68 | */ |
| 69 | struct vexpress_config_bridge_info { |
| 70 | const char *name; |
Pawel Moll | 854f623 | 2013-06-06 10:59:22 +0100 | [diff] [blame] | 71 | void *(*func_get)(struct device *dev, struct device_node *node, |
| 72 | const char *id); |
Pawel Moll | 3ecbf05 | 2012-09-24 14:55:40 +0100 | [diff] [blame] | 73 | void (*func_put)(void *func); |
| 74 | int (*func_exec)(void *func, int offset, bool write, u32 *data); |
| 75 | }; |
| 76 | |
| 77 | struct vexpress_config_bridge; |
| 78 | |
| 79 | struct vexpress_config_bridge *vexpress_config_bridge_register( |
| 80 | struct device_node *node, |
| 81 | struct vexpress_config_bridge_info *info); |
| 82 | void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge); |
| 83 | |
| 84 | void vexpress_config_complete(struct vexpress_config_bridge *bridge, |
| 85 | int status); |
| 86 | |
| 87 | /* Config function API */ |
| 88 | |
| 89 | struct vexpress_config_func; |
| 90 | |
Pawel Moll | 854f623 | 2013-06-06 10:59:22 +0100 | [diff] [blame] | 91 | struct vexpress_config_func *__vexpress_config_func_get( |
| 92 | struct vexpress_config_bridge *bridge, |
| 93 | struct device *dev, |
| 94 | struct device_node *node, |
| 95 | const char *id); |
| 96 | #define vexpress_config_func_get(bridge, id) \ |
| 97 | __vexpress_config_func_get(bridge, NULL, NULL, id) |
Pawel Moll | 3ecbf05 | 2012-09-24 14:55:40 +0100 | [diff] [blame] | 98 | #define vexpress_config_func_get_by_dev(dev) \ |
Pawel Moll | 854f623 | 2013-06-06 10:59:22 +0100 | [diff] [blame] | 99 | __vexpress_config_func_get(NULL, dev, NULL, NULL) |
Pawel Moll | 3ecbf05 | 2012-09-24 14:55:40 +0100 | [diff] [blame] | 100 | #define vexpress_config_func_get_by_node(node) \ |
Pawel Moll | 854f623 | 2013-06-06 10:59:22 +0100 | [diff] [blame] | 101 | __vexpress_config_func_get(NULL, NULL, node, NULL) |
Pawel Moll | 3ecbf05 | 2012-09-24 14:55:40 +0100 | [diff] [blame] | 102 | void vexpress_config_func_put(struct vexpress_config_func *func); |
| 103 | |
| 104 | /* Both may sleep! */ |
| 105 | int vexpress_config_read(struct vexpress_config_func *func, int offset, |
| 106 | u32 *data); |
| 107 | int vexpress_config_write(struct vexpress_config_func *func, int offset, |
| 108 | u32 data); |
| 109 | |
Pawel Moll | 88e0abc | 2012-09-18 12:24:57 +0100 | [diff] [blame] | 110 | /* Platform control */ |
| 111 | |
| 112 | u32 vexpress_get_procid(int site); |
| 113 | u32 vexpress_get_hbi(int site); |
| 114 | void *vexpress_get_24mhz_clock_base(void); |
| 115 | void vexpress_flags_set(u32 data); |
| 116 | |
| 117 | #define vexpress_get_site_by_node(node) __vexpress_get_site(NULL, node) |
| 118 | #define vexpress_get_site_by_dev(dev) __vexpress_get_site(dev, NULL) |
| 119 | unsigned __vexpress_get_site(struct device *dev, struct device_node *node); |
| 120 | |
| 121 | void vexpress_sysreg_early_init(void __iomem *base); |
| 122 | void vexpress_sysreg_of_early_init(void); |
| 123 | |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 124 | /* Clocks */ |
| 125 | |
| 126 | struct clk *vexpress_osc_setup(struct device *dev); |
| 127 | void vexpress_osc_of_setup(struct device_node *node); |
| 128 | |
Viresh Kumar | 07ae43e | 2012-11-24 00:51:07 +0530 | [diff] [blame] | 129 | struct clk *vexpress_clk_register_spc(const char *name, int cluster_id); |
| 130 | void vexpress_clk_of_register_spc(void); |
| 131 | |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 132 | void vexpress_clk_init(void __iomem *sp810_base); |
| 133 | void vexpress_clk_of_init(void); |
| 134 | |
Lorenzo Pieralisi | af17603 | 2013-06-06 10:59:23 +0100 | [diff] [blame] | 135 | /* SPC */ |
| 136 | |
| 137 | #define VEXPRESS_SPC_WAKE_INTR_IRQ(cluster, cpu) \ |
| 138 | (1 << (4 * (cluster) + (cpu))) |
| 139 | #define VEXPRESS_SPC_WAKE_INTR_FIQ(cluster, cpu) \ |
| 140 | (1 << (7 * (cluster) + (cpu))) |
| 141 | #define VEXPRESS_SPC_WAKE_INTR_SWDOG (1 << 10) |
| 142 | #define VEXPRESS_SPC_WAKE_INTR_GTIMER (1 << 11) |
| 143 | #define VEXPRESS_SPC_WAKE_INTR_MASK 0xFFF |
| 144 | |
| 145 | #ifdef CONFIG_VEXPRESS_SPC |
| 146 | extern bool vexpress_spc_check_loaded(void); |
| 147 | extern void vexpress_spc_set_cpu_wakeup_irq(u32 cpu, u32 cluster, bool set); |
| 148 | extern void vexpress_spc_set_global_wakeup_intr(bool set); |
| 149 | extern int vexpress_spc_get_freq_table(u32 cluster, u32 **fptr); |
| 150 | extern int vexpress_spc_get_performance(u32 cluster, u32 *freq); |
| 151 | extern int vexpress_spc_set_performance(u32 cluster, u32 freq); |
| 152 | extern void vexpress_spc_write_resume_reg(u32 cluster, u32 cpu, u32 addr); |
| 153 | extern int vexpress_spc_get_nb_cpus(u32 cluster); |
| 154 | extern void vexpress_spc_powerdown_enable(u32 cluster, bool enable); |
| 155 | #else |
| 156 | static inline bool vexpress_spc_check_loaded(void) { return false; } |
| 157 | static inline void vexpress_spc_set_cpu_wakeup_irq(u32 cpu, u32 cluster, |
| 158 | bool set) { } |
| 159 | static inline void vexpress_spc_set_global_wakeup_intr(bool set) { } |
| 160 | static inline int vexpress_spc_get_freq_table(u32 cluster, u32 **fptr) |
| 161 | { |
| 162 | return -ENODEV; |
| 163 | } |
| 164 | static inline int vexpress_spc_get_performance(u32 cluster, u32 *freq) |
| 165 | { |
| 166 | return -ENODEV; |
| 167 | } |
| 168 | static inline int vexpress_spc_set_performance(u32 cluster, u32 freq) |
| 169 | { |
| 170 | return -ENODEV; |
| 171 | } |
| 172 | static inline void vexpress_spc_write_resume_reg(u32 cluster, |
| 173 | u32 cpu, u32 addr) { } |
| 174 | static inline int vexpress_spc_get_nb_cpus(u32 cluster) { return -ENODEV; } |
| 175 | static inline void vexpress_spc_powerdown_enable(u32 cluster, bool enable) { } |
| 176 | #endif |
| 177 | |
Pawel Moll | 3ecbf05 | 2012-09-24 14:55:40 +0100 | [diff] [blame] | 178 | #endif |