diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-01 19:35:31 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-01 19:35:31 -0500 |
| commit | fe53d1443a146326b49d57fe6336b5c2a725223f (patch) | |
| tree | 0bb6de8614bec52f025a0608910e80d6e9315245 /include | |
| parent | adbc128fa8b4e9ecfdd11d5dd0a7d9845c6ea510 (diff) | |
| parent | 796543a64ebffdb638a22f428c4dadd037e34866 (diff) | |
Merge tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM SoC driver updates from Arnd Bergmann:
"A number of new drivers get added this time, along with many
low-priority bugfixes. The most interesting changes by subsystem are:
bus drivers:
- Updates to the Broadcom bus interface driver to support newer SoC
types
- The TI OMAP sysc driver now supports updated DT bindings
memory controllers:
- A new driver for Tegra186 gets added
- A new driver for the ti-emif sram, to allow relocating
suspend/resume handlers there
SoC specific:
- A new driver for Qualcomm QMI, the interface to the modem on MSM
SoCs
- A new driver for power domains on the actions S700 SoC
- A driver for the Xilinx Zynq VCU logicoreIP
reset controllers:
- A new driver for Amlogic Meson-AGX
- various bug fixes
tee subsystem:
- A new user interface got added to enable asynchronous communication
with the TEE supplicant.
- A new method of using user space memory for communication with the
TEE is added"
* tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (84 commits)
of: platform: fix OF node refcount leak
soc: fsl: guts: Add a NULL check for devm_kasprintf()
bus: ti-sysc: Fix smartreflex sysc mask
psci: add CPU_IDLE dependency
soc: xilinx: Fix Kconfig alignment
soc: xilinx: xlnx_vcu: Use bitwise & rather than logical && on clkoutdiv
soc: xilinx: xlnx_vcu: Depends on HAS_IOMEM for xlnx_vcu
soc: bcm: brcmstb: Be multi-platform compatible
soc: brcmstb: biuctrl: exit without warning on non brcmstb platforms
Revert "soc: brcmstb: Only register SoC device on STB platforms"
bus: omap: add MODULE_LICENSE tags
soc: brcmstb: Only register SoC device on STB platforms
tee: shm: Potential NULL dereference calling tee_shm_register()
soc: xilinx: xlnx_vcu: Add Xilinx ZYNQMP VCU logicoreIP init driver
dt-bindings: soc: xilinx: Add DT bindings to xlnx_vcu driver
soc: xilinx: Create folder structure for soc specific drivers
of: platform: populate /firmware/ node from of_platform_default_populate_init()
soc: samsung: Add SPDX license identifiers
soc: qcom: smp2p: Use common error handling code in qcom_smp2p_probe()
tee: shm: don't put_page on null shm->pages
...
Diffstat (limited to 'include')
| -rw-r--r-- | include/dt-bindings/reset/amlogic,meson-axg-reset.h | 124 | ||||
| -rw-r--r-- | include/linux/platform_data/ti-sysc.h | 86 | ||||
| -rw-r--r-- | include/linux/qcom_scm.h | 3 | ||||
| -rw-r--r-- | include/linux/reset.h | 50 | ||||
| -rw-r--r-- | include/linux/soc/brcmstb/brcmstb.h | 6 | ||||
| -rw-r--r-- | include/linux/soc/qcom/qmi.h | 271 | ||||
| -rw-r--r-- | include/linux/tee_drv.h | 196 | ||||
| -rw-r--r-- | include/linux/ti-emif-sram.h | 69 | ||||
| -rw-r--r-- | include/soc/tegra/mc.h | 9 | ||||
| -rw-r--r-- | include/uapi/linux/tee.h | 37 |
10 files changed, 808 insertions, 43 deletions
diff --git a/include/dt-bindings/reset/amlogic,meson-axg-reset.h b/include/dt-bindings/reset/amlogic,meson-axg-reset.h new file mode 100644 index 000000000000..ad6f55dabd6d --- /dev/null +++ b/include/dt-bindings/reset/amlogic,meson-axg-reset.h | |||
| @@ -0,0 +1,124 @@ | |||
| 1 | /* | ||
| 2 | * | ||
| 3 | * Copyright (c) 2016 BayLibre, SAS. | ||
| 4 | * Author: Neil Armstrong <narmstrong@baylibre.com> | ||
| 5 | * | ||
| 6 | * Copyright (c) 2017 Amlogic, inc. | ||
| 7 | * Author: Yixun Lan <yixun.lan@amlogic.com> | ||
| 8 | * | ||
| 9 | * SPDX-License-Identifier: (GPL-2.0+ OR BSD) | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef _DT_BINDINGS_AMLOGIC_MESON_AXG_RESET_H | ||
| 13 | #define _DT_BINDINGS_AMLOGIC_MESON_AXG_RESET_H | ||
| 14 | |||
| 15 | /* RESET0 */ | ||
| 16 | #define RESET_HIU 0 | ||
| 17 | #define RESET_PCIE_A 1 | ||
| 18 | #define RESET_PCIE_B 2 | ||
| 19 | #define RESET_DDR_TOP 3 | ||
| 20 | /* 4 */ | ||
| 21 | #define RESET_VIU 5 | ||
| 22 | #define RESET_PCIE_PHY 6 | ||
| 23 | #define RESET_PCIE_APB 7 | ||
| 24 | /* 8 */ | ||
| 25 | /* 9 */ | ||
| 26 | #define RESET_VENC 10 | ||
| 27 | #define RESET_ASSIST 11 | ||
| 28 | /* 12 */ | ||
| 29 | #define RESET_VCBUS 13 | ||
| 30 | /* 14 */ | ||
| 31 | /* 15 */ | ||
| 32 | #define RESET_GIC 16 | ||
| 33 | #define RESET_CAPB3_DECODE 17 | ||
| 34 | /* 18-21 */ | ||
| 35 | #define RESET_SYS_CPU_CAPB3 22 | ||
| 36 | #define RESET_CBUS_CAPB3 23 | ||
| 37 | #define RESET_AHB_CNTL 24 | ||
| 38 | #define RESET_AHB_DATA 25 | ||
| 39 | #define RESET_VCBUS_CLK81 26 | ||
| 40 | #define RESET_MMC 27 | ||
| 41 | /* 28-31 */ | ||
| 42 | /* RESET1 */ | ||
| 43 | /* 32 */ | ||
| 44 | /* 33 */ | ||
| 45 | #define RESET_USB_OTG 34 | ||
| 46 | #define RESET_DDR 35 | ||
| 47 | #define RESET_AO_RESET 36 | ||
| 48 | /* 37 */ | ||
| 49 | #define RESET_AHB_SRAM 38 | ||
| 50 | /* 39 */ | ||
| 51 | /* 40 */ | ||
| 52 | #define RESET_DMA 41 | ||
| 53 | #define RESET_ISA 42 | ||
| 54 | #define RESET_ETHERNET 43 | ||
| 55 | /* 44 */ | ||
| 56 | #define RESET_SD_EMMC_B 45 | ||
| 57 | #define RESET_SD_EMMC_C 46 | ||
| 58 | #define RESET_ROM_BOOT 47 | ||
| 59 | #define RESET_SYS_CPU_0 48 | ||
| 60 | #define RESET_SYS_CPU_1 49 | ||
| 61 | #define RESET_SYS_CPU_2 50 | ||
| 62 | #define RESET_SYS_CPU_3 51 | ||
| 63 | #define RESET_SYS_CPU_CORE_0 52 | ||
| 64 | #define RESET_SYS_CPU_CORE_1 53 | ||
| 65 | #define RESET_SYS_CPU_CORE_2 54 | ||
| 66 | #define RESET_SYS_CPU_CORE_3 55 | ||
| 67 | #define RESET_SYS_PLL_DIV 56 | ||
| 68 | #define RESET_SYS_CPU_AXI 57 | ||
| 69 | #define RESET_SYS_CPU_L2 58 | ||
| 70 | #define RESET_SYS_CPU_P 59 | ||
| 71 | #define RESET_SYS_CPU_MBIST 60 | ||
| 72 | /* 61-63 */ | ||
| 73 | /* RESET2 */ | ||
| 74 | /* 64 */ | ||
| 75 | /* 65 */ | ||
| 76 | #define RESET_AUDIO 66 | ||
| 77 | /* 67 */ | ||
| 78 | #define RESET_MIPI_HOST 68 | ||
| 79 | #define RESET_AUDIO_LOCKER 69 | ||
| 80 | #define RESET_GE2D 70 | ||
| 81 | /* 71-76 */ | ||
| 82 | #define RESET_AO_CPU_RESET 77 | ||
| 83 | /* 78-95 */ | ||
| 84 | /* RESET3 */ | ||
| 85 | #define RESET_RING_OSCILLATOR 96 | ||
| 86 | /* 97-127 */ | ||
| 87 | /* RESET4 */ | ||
| 88 | /* 128 */ | ||
| 89 | /* 129 */ | ||
| 90 | #define RESET_MIPI_PHY 130 | ||
| 91 | /* 131-140 */ | ||
| 92 | #define RESET_VENCL 141 | ||
| 93 | #define RESET_I2C_MASTER_2 142 | ||
| 94 | #define RESET_I2C_MASTER_1 143 | ||
| 95 | /* 144-159 */ | ||
| 96 | /* RESET5 */ | ||
| 97 | /* 160-191 */ | ||
| 98 | /* RESET6 */ | ||
| 99 | #define RESET_PERIPHS_GENERAL 192 | ||
| 100 | #define RESET_PERIPHS_SPICC 193 | ||
| 101 | /* 194 */ | ||
| 102 | /* 195 */ | ||
| 103 | #define RESET_PERIPHS_I2C_MASTER_0 196 | ||
| 104 | /* 197-200 */ | ||
| 105 | #define RESET_PERIPHS_UART_0 201 | ||
| 106 | #define RESET_PERIPHS_UART_1 202 | ||
| 107 | /* 203-204 */ | ||
| 108 | #define RESET_PERIPHS_SPI_0 205 | ||
| 109 | #define RESET_PERIPHS_I2C_MASTER_3 206 | ||
| 110 | /* 207-223 */ | ||
| 111 | /* RESET7 */ | ||
| 112 | #define RESET_USB_DDR_0 224 | ||
| 113 | #define RESET_USB_DDR_1 225 | ||
| 114 | #define RESET_USB_DDR_2 226 | ||
| 115 | #define RESET_USB_DDR_3 227 | ||
| 116 | /* 228 */ | ||
| 117 | #define RESET_DEVICE_MMC_ARB 229 | ||
| 118 | /* 230 */ | ||
| 119 | #define RESET_VID_LOCK 231 | ||
| 120 | #define RESET_A9_DMC_PIPEL 232 | ||
| 121 | #define RESET_DMC_VPU_PIPEL 233 | ||
| 122 | /* 234-255 */ | ||
| 123 | |||
| 124 | #endif | ||
diff --git a/include/linux/platform_data/ti-sysc.h b/include/linux/platform_data/ti-sysc.h new file mode 100644 index 000000000000..1be356330b96 --- /dev/null +++ b/include/linux/platform_data/ti-sysc.h | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | #ifndef __TI_SYSC_DATA_H__ | ||
| 2 | #define __TI_SYSC_DATA_H__ | ||
| 3 | |||
| 4 | enum ti_sysc_module_type { | ||
| 5 | TI_SYSC_OMAP2, | ||
| 6 | TI_SYSC_OMAP2_TIMER, | ||
| 7 | TI_SYSC_OMAP3_SHAM, | ||
| 8 | TI_SYSC_OMAP3_AES, | ||
| 9 | TI_SYSC_OMAP4, | ||
| 10 | TI_SYSC_OMAP4_TIMER, | ||
| 11 | TI_SYSC_OMAP4_SIMPLE, | ||
| 12 | TI_SYSC_OMAP34XX_SR, | ||
| 13 | TI_SYSC_OMAP36XX_SR, | ||
| 14 | TI_SYSC_OMAP4_SR, | ||
| 15 | TI_SYSC_OMAP4_MCASP, | ||
| 16 | TI_SYSC_OMAP4_USB_HOST_FS, | ||
| 17 | }; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * struct sysc_regbits - TI OCP_SYSCONFIG register field offsets | ||
| 21 | * @midle_shift: Offset of the midle bit | ||
| 22 | * @clkact_shift: Offset of the clockactivity bit | ||
| 23 | * @sidle_shift: Offset of the sidle bit | ||
| 24 | * @enwkup_shift: Offset of the enawakeup bit | ||
| 25 | * @srst_shift: Offset of the softreset bit | ||
| 26 | * @autoidle_shift: Offset of the autoidle bit | ||
| 27 | * @dmadisable_shift: Offset of the dmadisable bit | ||
| 28 | * @emufree_shift; Offset of the emufree bit | ||
| 29 | * | ||
| 30 | * Note that 0 is a valid shift, and for ti-sysc.c -ENODEV can be used if a | ||
| 31 | * feature is not available. | ||
| 32 | */ | ||
| 33 | struct sysc_regbits { | ||
| 34 | s8 midle_shift; | ||
| 35 | s8 clkact_shift; | ||
| 36 | s8 sidle_shift; | ||
| 37 | s8 enwkup_shift; | ||
| 38 | s8 srst_shift; | ||
| 39 | s8 autoidle_shift; | ||
| 40 | s8 dmadisable_shift; | ||
| 41 | s8 emufree_shift; | ||
| 42 | }; | ||
| 43 | |||
| 44 | #define SYSC_QUIRK_RESET_STATUS BIT(7) | ||
| 45 | #define SYSC_QUIRK_NO_IDLE_ON_INIT BIT(6) | ||
| 46 | #define SYSC_QUIRK_NO_RESET_ON_INIT BIT(5) | ||
| 47 | #define SYSC_QUIRK_OPT_CLKS_NEEDED BIT(4) | ||
| 48 | #define SYSC_QUIRK_OPT_CLKS_IN_RESET BIT(3) | ||
| 49 | #define SYSC_QUIRK_16BIT BIT(2) | ||
| 50 | #define SYSC_QUIRK_UNCACHED BIT(1) | ||
| 51 | #define SYSC_QUIRK_USE_CLOCKACT BIT(0) | ||
| 52 | |||
| 53 | #define SYSC_NR_IDLEMODES 4 | ||
| 54 | |||
| 55 | /** | ||
| 56 | * struct sysc_capabilities - capabilities for an interconnect target module | ||
| 57 | * | ||
| 58 | * @sysc_mask: bitmask of supported SYSCONFIG register bits | ||
| 59 | * @regbits: bitmask of SYSCONFIG register bits | ||
| 60 | * @mod_quirks: bitmask of module specific quirks | ||
| 61 | */ | ||
| 62 | struct sysc_capabilities { | ||
| 63 | const enum ti_sysc_module_type type; | ||
| 64 | const u32 sysc_mask; | ||
| 65 | const struct sysc_regbits *regbits; | ||
| 66 | const u32 mod_quirks; | ||
| 67 | }; | ||
| 68 | |||
| 69 | /** | ||
| 70 | * struct sysc_config - configuration for an interconnect target module | ||
| 71 | * @sysc_val: configured value for sysc register | ||
| 72 | * @midlemodes: bitmask of supported master idle modes | ||
| 73 | * @sidlemodes: bitmask of supported master idle modes | ||
| 74 | * @srst_udelay: optional delay needed after OCP soft reset | ||
| 75 | * @quirks: bitmask of enabled quirks | ||
| 76 | */ | ||
| 77 | struct sysc_config { | ||
| 78 | u32 sysc_val; | ||
| 79 | u32 syss_mask; | ||
| 80 | u8 midlemodes; | ||
| 81 | u8 sidlemodes; | ||
| 82 | u8 srst_udelay; | ||
| 83 | u32 quirks; | ||
| 84 | }; | ||
| 85 | |||
| 86 | #endif /* __TI_SYSC_DATA_H__ */ | ||
diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h index 1fd27d68926b..b401b962afff 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h | |||
| @@ -13,6 +13,9 @@ | |||
| 13 | #ifndef __QCOM_SCM_H | 13 | #ifndef __QCOM_SCM_H |
| 14 | #define __QCOM_SCM_H | 14 | #define __QCOM_SCM_H |
| 15 | 15 | ||
| 16 | #include <linux/types.h> | ||
| 17 | #include <linux/cpumask.h> | ||
| 18 | |||
| 16 | #define QCOM_SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF)) | 19 | #define QCOM_SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF)) |
| 17 | #define QCOM_SCM_CPU_PWR_DOWN_L2_ON 0x0 | 20 | #define QCOM_SCM_CPU_PWR_DOWN_L2_ON 0x0 |
| 18 | #define QCOM_SCM_CPU_PWR_DOWN_L2_OFF 0x1 | 21 | #define QCOM_SCM_CPU_PWR_DOWN_L2_OFF 0x1 |
diff --git a/include/linux/reset.h b/include/linux/reset.h index 4c7871ddf3c6..09732c36f351 100644 --- a/include/linux/reset.h +++ b/include/linux/reset.h | |||
| @@ -2,8 +2,10 @@ | |||
| 2 | #ifndef _LINUX_RESET_H_ | 2 | #ifndef _LINUX_RESET_H_ |
| 3 | #define _LINUX_RESET_H_ | 3 | #define _LINUX_RESET_H_ |
| 4 | 4 | ||
| 5 | #include <linux/device.h> | 5 | #include <linux/types.h> |
| 6 | 6 | ||
| 7 | struct device; | ||
| 8 | struct device_node; | ||
| 7 | struct reset_control; | 9 | struct reset_control; |
| 8 | 10 | ||
| 9 | #ifdef CONFIG_RESET_CONTROLLER | 11 | #ifdef CONFIG_RESET_CONTROLLER |
| @@ -20,22 +22,16 @@ struct reset_control *__reset_control_get(struct device *dev, const char *id, | |||
| 20 | int index, bool shared, | 22 | int index, bool shared, |
| 21 | bool optional); | 23 | bool optional); |
| 22 | void reset_control_put(struct reset_control *rstc); | 24 | void reset_control_put(struct reset_control *rstc); |
| 25 | int __device_reset(struct device *dev, bool optional); | ||
| 23 | struct reset_control *__devm_reset_control_get(struct device *dev, | 26 | struct reset_control *__devm_reset_control_get(struct device *dev, |
| 24 | const char *id, int index, bool shared, | 27 | const char *id, int index, bool shared, |
| 25 | bool optional); | 28 | bool optional); |
| 26 | 29 | ||
| 27 | int __must_check device_reset(struct device *dev); | ||
| 28 | |||
| 29 | struct reset_control *devm_reset_control_array_get(struct device *dev, | 30 | struct reset_control *devm_reset_control_array_get(struct device *dev, |
| 30 | bool shared, bool optional); | 31 | bool shared, bool optional); |
| 31 | struct reset_control *of_reset_control_array_get(struct device_node *np, | 32 | struct reset_control *of_reset_control_array_get(struct device_node *np, |
| 32 | bool shared, bool optional); | 33 | bool shared, bool optional); |
| 33 | 34 | ||
| 34 | static inline int device_reset_optional(struct device *dev) | ||
| 35 | { | ||
| 36 | return device_reset(dev); | ||
| 37 | } | ||
| 38 | |||
| 39 | #else | 35 | #else |
| 40 | 36 | ||
| 41 | static inline int reset_control_reset(struct reset_control *rstc) | 37 | static inline int reset_control_reset(struct reset_control *rstc) |
| @@ -62,15 +58,9 @@ static inline void reset_control_put(struct reset_control *rstc) | |||
| 62 | { | 58 | { |
| 63 | } | 59 | } |
| 64 | 60 | ||
| 65 | static inline int __must_check device_reset(struct device *dev) | 61 | static inline int __device_reset(struct device *dev, bool optional) |
| 66 | { | ||
| 67 | WARN_ON(1); | ||
| 68 | return -ENOTSUPP; | ||
| 69 | } | ||
| 70 | |||
| 71 | static inline int device_reset_optional(struct device *dev) | ||
| 72 | { | 62 | { |
| 73 | return -ENOTSUPP; | 63 | return optional ? 0 : -ENOTSUPP; |
| 74 | } | 64 | } |
| 75 | 65 | ||
| 76 | static inline struct reset_control *__of_reset_control_get( | 66 | static inline struct reset_control *__of_reset_control_get( |
| @@ -109,6 +99,16 @@ of_reset_control_array_get(struct device_node *np, bool shared, bool optional) | |||
| 109 | 99 | ||
| 110 | #endif /* CONFIG_RESET_CONTROLLER */ | 100 | #endif /* CONFIG_RESET_CONTROLLER */ |
| 111 | 101 | ||
| 102 | static inline int __must_check device_reset(struct device *dev) | ||
| 103 | { | ||
| 104 | return __device_reset(dev, false); | ||
| 105 | } | ||
| 106 | |||
| 107 | static inline int device_reset_optional(struct device *dev) | ||
| 108 | { | ||
| 109 | return __device_reset(dev, true); | ||
| 110 | } | ||
| 111 | |||
| 112 | /** | 112 | /** |
| 113 | * reset_control_get_exclusive - Lookup and obtain an exclusive reference | 113 | * reset_control_get_exclusive - Lookup and obtain an exclusive reference |
| 114 | * to a reset controller. | 114 | * to a reset controller. |
| @@ -127,9 +127,6 @@ of_reset_control_array_get(struct device_node *np, bool shared, bool optional) | |||
| 127 | static inline struct reset_control * | 127 | static inline struct reset_control * |
| 128 | __must_check reset_control_get_exclusive(struct device *dev, const char *id) | 128 | __must_check reset_control_get_exclusive(struct device *dev, const char *id) |
| 129 | { | 129 | { |
| 130 | #ifndef CONFIG_RESET_CONTROLLER | ||
| 131 | WARN_ON(1); | ||
| 132 | #endif | ||
| 133 | return __reset_control_get(dev, id, 0, false, false); | 130 | return __reset_control_get(dev, id, 0, false, false); |
| 134 | } | 131 | } |
| 135 | 132 | ||
| @@ -275,9 +272,6 @@ static inline struct reset_control * | |||
| 275 | __must_check devm_reset_control_get_exclusive(struct device *dev, | 272 | __must_check devm_reset_control_get_exclusive(struct device *dev, |
| 276 | const char *id) | 273 | const char *id) |
| 277 | { | 274 | { |
| 278 | #ifndef CONFIG_RESET_CONTROLLER | ||
| 279 | WARN_ON(1); | ||
| 280 | #endif | ||
| 281 | return __devm_reset_control_get(dev, id, 0, false, false); | 275 | return __devm_reset_control_get(dev, id, 0, false, false); |
| 282 | } | 276 | } |
| 283 | 277 | ||
| @@ -350,18 +344,6 @@ devm_reset_control_get_shared_by_index(struct device *dev, int index) | |||
| 350 | * These inline function calls will be removed once all consumers | 344 | * These inline function calls will be removed once all consumers |
| 351 | * have been moved over to the new explicit API. | 345 | * have been moved over to the new explicit API. |
| 352 | */ | 346 | */ |
| 353 | static inline struct reset_control *reset_control_get( | ||
| 354 | struct device *dev, const char *id) | ||
| 355 | { | ||
| 356 | return reset_control_get_exclusive(dev, id); | ||
| 357 | } | ||
| 358 | |||
| 359 | static inline struct reset_control *reset_control_get_optional( | ||
| 360 | struct device *dev, const char *id) | ||
| 361 | { | ||
| 362 | return reset_control_get_optional_exclusive(dev, id); | ||
| 363 | } | ||
| 364 | |||
| 365 | static inline struct reset_control *of_reset_control_get( | 347 | static inline struct reset_control *of_reset_control_get( |
| 366 | struct device_node *node, const char *id) | 348 | struct device_node *node, const char *id) |
| 367 | { | 349 | { |
diff --git a/include/linux/soc/brcmstb/brcmstb.h b/include/linux/soc/brcmstb/brcmstb.h index 12e548938bbb..8e884e0dda0a 100644 --- a/include/linux/soc/brcmstb/brcmstb.h +++ b/include/linux/soc/brcmstb/brcmstb.h | |||
| @@ -13,12 +13,6 @@ static inline u32 BRCM_REV(u32 reg) | |||
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | /* | 15 | /* |
| 16 | * Bus Interface Unit control register setup, must happen early during boot, | ||
| 17 | * before SMP is brought up, called by machine entry point. | ||
| 18 | */ | ||
| 19 | void brcmstb_biuctrl_init(void); | ||
| 20 | |||
| 21 | /* | ||
| 22 | * Helper functions for getting family or product id from the | 16 | * Helper functions for getting family or product id from the |
| 23 | * SoC driver. | 17 | * SoC driver. |
| 24 | */ | 18 | */ |
diff --git a/include/linux/soc/qcom/qmi.h b/include/linux/soc/qcom/qmi.h new file mode 100644 index 000000000000..f4de33654a60 --- /dev/null +++ b/include/linux/soc/qcom/qmi.h | |||
| @@ -0,0 +1,271 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* | ||
| 3 | * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. | ||
| 4 | * Copyright (c) 2017, Linaro Ltd. | ||
| 5 | */ | ||
| 6 | #ifndef __QMI_HELPERS_H__ | ||
| 7 | #define __QMI_HELPERS_H__ | ||
| 8 | |||
| 9 | #include <linux/completion.h> | ||
| 10 | #include <linux/idr.h> | ||
| 11 | #include <linux/list.h> | ||
| 12 | #include <linux/qrtr.h> | ||
| 13 | #include <linux/types.h> | ||
| 14 | #include <linux/workqueue.h> | ||
| 15 | |||
| 16 | struct socket; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * qmi_header - wireformat header of QMI messages | ||
| 20 | * @type: type of message | ||
| 21 | * @txn_id: transaction id | ||
| 22 | * @msg_id: message id | ||
| 23 | * @msg_len: length of message payload following header | ||
| 24 | */ | ||
| 25 | struct qmi_header { | ||
| 26 | u8 type; | ||
| 27 | u16 txn_id; | ||
| 28 | u16 msg_id; | ||
| 29 | u16 msg_len; | ||
| 30 | } __packed; | ||
| 31 | |||
| 32 | #define QMI_REQUEST 0 | ||
| 33 | #define QMI_RESPONSE 2 | ||
| 34 | #define QMI_INDICATION 4 | ||
| 35 | |||
| 36 | #define QMI_COMMON_TLV_TYPE 0 | ||
| 37 | |||
| 38 | enum qmi_elem_type { | ||
| 39 | QMI_EOTI, | ||
| 40 | QMI_OPT_FLAG, | ||
| 41 | QMI_DATA_LEN, | ||
| 42 | QMI_UNSIGNED_1_BYTE, | ||
| 43 | QMI_UNSIGNED_2_BYTE, | ||
| 44 | QMI_UNSIGNED_4_BYTE, | ||
| 45 | QMI_UNSIGNED_8_BYTE, | ||
| 46 | QMI_SIGNED_2_BYTE_ENUM, | ||
| 47 | QMI_SIGNED_4_BYTE_ENUM, | ||
| 48 | QMI_STRUCT, | ||
| 49 | QMI_STRING, | ||
| 50 | }; | ||
| 51 | |||
| 52 | enum qmi_array_type { | ||
| 53 | NO_ARRAY, | ||
| 54 | STATIC_ARRAY, | ||
| 55 | VAR_LEN_ARRAY, | ||
| 56 | }; | ||
| 57 | |||
| 58 | /** | ||
| 59 | * struct qmi_elem_info - describes how to encode a single QMI element | ||
| 60 | * @data_type: Data type of this element. | ||
| 61 | * @elem_len: Array length of this element, if an array. | ||
| 62 | * @elem_size: Size of a single instance of this data type. | ||
| 63 | * @array_type: Array type of this element. | ||
| 64 | * @tlv_type: QMI message specific type to identify which element | ||
| 65 | * is present in an incoming message. | ||
| 66 | * @offset: Specifies the offset of the first instance of this | ||
| 67 | * element in the data structure. | ||
| 68 | * @ei_array: Null-terminated array of @qmi_elem_info to describe nested | ||
| 69 | * structures. | ||
| 70 | */ | ||
| 71 | struct qmi_elem_info { | ||
| 72 | enum qmi_elem_type data_type; | ||
| 73 | u32 elem_len; | ||
| 74 | u32 elem_size; | ||
| 75 | enum qmi_array_type array_type; | ||
| 76 | u8 tlv_type; | ||
| 77 | u32 offset; | ||
| 78 | struct qmi_elem_info *ei_array; | ||
| 79 | }; | ||
| 80 | |||
| 81 | #define QMI_RESULT_SUCCESS_V01 0 | ||
| 82 | #define QMI_RESULT_FAILURE_V01 1 | ||
| 83 | |||
| 84 | #define QMI_ERR_NONE_V01 0 | ||
| 85 | #define QMI_ERR_MALFORMED_MSG_V01 1 | ||
| 86 | #define QMI_ERR_NO_MEMORY_V01 2 | ||
| 87 | #define QMI_ERR_INTERNAL_V01 3 | ||
| 88 | #define QMI_ERR_CLIENT_IDS_EXHAUSTED_V01 5 | ||
| 89 | #define QMI_ERR_INVALID_ID_V01 41 | ||
| 90 | #define QMI_ERR_ENCODING_V01 58 | ||
| 91 | #define QMI_ERR_INCOMPATIBLE_STATE_V01 90 | ||
| 92 | #define QMI_ERR_NOT_SUPPORTED_V01 94 | ||
| 93 | |||
| 94 | /** | ||
| 95 | * qmi_response_type_v01 - common response header (decoded) | ||
| 96 | * @result: result of the transaction | ||
| 97 | * @error: error value, when @result is QMI_RESULT_FAILURE_V01 | ||
| 98 | */ | ||
| 99 | struct qmi_response_type_v01 { | ||
| 100 | u16 result; | ||
| 101 | u16 error; | ||
| 102 | }; | ||
| 103 | |||
| 104 | extern struct qmi_elem_info qmi_response_type_v01_ei[]; | ||
| 105 | |||
| 106 | /** | ||
| 107 | * struct qmi_service - context to track lookup-results | ||
| 108 | * @service: service type | ||
| 109 | * @version: version of the @service | ||
| 110 | * @instance: instance id of the @service | ||
| 111 | * @node: node of the service | ||
| 112 | * @port: port of the service | ||
| 113 | * @priv: handle for client's use | ||
| 114 | * @list_node: list_head for house keeping | ||
| 115 | */ | ||
| 116 | struct qmi_service { | ||
| 117 | unsigned int service; | ||
| 118 | unsigned int version; | ||
| 119 | unsigned int instance; | ||
| 120 | |||
| 121 | unsigned int node; | ||
| 122 | unsigned int port; | ||
| 123 | |||
| 124 | void *priv; | ||
| 125 | struct list_head list_node; | ||
| 126 | }; | ||
| 127 | |||
| 128 | struct qmi_handle; | ||
| 129 | |||
| 130 | /** | ||
| 131 | * struct qmi_ops - callbacks for qmi_handle | ||
| 132 | * @new_server: inform client of a new_server lookup-result, returning | ||
| 133 | * successfully from this call causes the library to call | ||
| 134 | * @del_server as the service is removed from the | ||
| 135 | * lookup-result. @priv of the qmi_service can be used by | ||
| 136 | * the client | ||
| 137 | * @del_server: inform client of a del_server lookup-result | ||
| 138 | * @net_reset: inform client that the name service was restarted and | ||
| 139 | * that and any state needs to be released | ||
| 140 | * @msg_handler: invoked for incoming messages, allows a client to | ||
| 141 | * override the usual QMI message handler | ||
| 142 | * @bye: inform a client that all clients from a node are gone | ||
| 143 | * @del_client: inform a client that a particular client is gone | ||
| 144 | */ | ||
| 145 | struct qmi_ops { | ||
| 146 | int (*new_server)(struct qmi_handle *qmi, struct qmi_service *svc); | ||
| 147 | void (*del_server)(struct qmi_handle *qmi, struct qmi_service *svc); | ||
| 148 | void (*net_reset)(struct qmi_handle *qmi); | ||
| 149 | void (*msg_handler)(struct qmi_handle *qmi, struct sockaddr_qrtr *sq, | ||
| 150 | const void *data, size_t count); | ||
| 151 | void (*bye)(struct qmi_handle *qmi, unsigned int node); | ||
| 152 | void (*del_client)(struct qmi_handle *qmi, | ||
| 153 | unsigned int node, unsigned int port); | ||
| 154 | }; | ||
| 155 | |||
| 156 | /** | ||
| 157 | * struct qmi_txn - transaction context | ||
| 158 | * @qmi: QMI handle this transaction is associated with | ||
| 159 | * @id: transaction id | ||
| 160 | * @lock: for synchronization between handler and waiter of messages | ||
| 161 | * @completion: completion object as the transaction receives a response | ||
| 162 | * @result: result code for the completed transaction | ||
| 163 | * @ei: description of the QMI encoded response (optional) | ||
| 164 | * @dest: destination buffer to decode message into (optional) | ||
| 165 | */ | ||
| 166 | struct qmi_txn { | ||
| 167 | struct qmi_handle *qmi; | ||
| 168 | |||
| 169 | int id; | ||
| 170 | |||
| 171 | struct mutex lock; | ||
| 172 | struct completion completion; | ||
| 173 | int result; | ||
| 174 | |||
| 175 | struct qmi_elem_info *ei; | ||
| 176 | void *dest; | ||
| 177 | }; | ||
| 178 | |||
| 179 | /** | ||
| 180 | * struct qmi_msg_handler - description of QMI message handler | ||
| 181 | * @type: type of message | ||
| 182 | * @msg_id: message id | ||
| 183 | * @ei: description of the QMI encoded message | ||
| 184 | * @decoded_size: size of the decoded object | ||
| 185 | * @fn: function to invoke as the message is decoded | ||
| 186 | */ | ||
| 187 | struct qmi_msg_handler { | ||
| 188 | unsigned int type; | ||
| 189 | unsigned int msg_id; | ||
| 190 | |||
| 191 | struct qmi_elem_info *ei; | ||
| 192 | |||
| 193 | size_t decoded_size; | ||
| 194 | void (*fn)(struct qmi_handle *qmi, struct sockaddr_qrtr *sq, | ||
| 195 | struct qmi_txn *txn, const void *decoded); | ||
| 196 | }; | ||
| 197 | |||
| 198 | /** | ||
| 199 | * struct qmi_handle - QMI context | ||
| 200 | * @sock: socket handle | ||
| 201 | * @sock_lock: synchronization of @sock modifications | ||
| 202 | * @sq: sockaddr of @sock | ||
| 203 | * @work: work for handling incoming messages | ||
| 204 | * @wq: workqueue to post @work on | ||
| 205 | * @recv_buf: scratch buffer for handling incoming messages | ||
| 206 | * @recv_buf_size: size of @recv_buf | ||
| 207 | * @lookups: list of registered lookup requests | ||
| 208 | * @lookup_results: list of lookup-results advertised to the client | ||
| 209 | * @services: list of registered services (by this client) | ||
| 210 | * @ops: reference to callbacks | ||
| 211 | * @txns: outstanding transactions | ||
| 212 | * @txn_lock: lock for modifications of @txns | ||
| 213 | * @handlers: list of handlers for incoming messages | ||
| 214 | */ | ||
| 215 | struct qmi_handle { | ||
| 216 | struct socket *sock; | ||
| 217 | struct mutex sock_lock; | ||
| 218 | |||
| 219 | struct sockaddr_qrtr sq; | ||
| 220 | |||
| 221 | struct work_struct work; | ||
| 222 | struct workqueue_struct *wq; | ||
| 223 | |||
| 224 | void *recv_buf; | ||
| 225 | size_t recv_buf_size; | ||
| 226 | |||
| 227 | struct list_head lookups; | ||
| 228 | struct list_head lookup_results; | ||
| 229 | struct list_head services; | ||
| 230 | |||
| 231 | struct qmi_ops ops; | ||
| 232 | |||
| 233 | struct idr txns; | ||
| 234 | struct mutex txn_lock; | ||
| 235 | |||
| 236 | const struct qmi_msg_handler *handlers; | ||
| 237 | }; | ||
| 238 | |||
| 239 | int qmi_add_lookup(struct qmi_handle *qmi, unsigned int service, | ||
| 240 | unsigned int version, unsigned int instance); | ||
| 241 | int qmi_add_server(struct qmi_handle *qmi, unsigned int service, | ||
| 242 | unsigned int version, unsigned int instance); | ||
| 243 | |||
| 244 | int qmi_handle_init(struct qmi_handle *qmi, size_t max_msg_len, | ||
| 245 | const struct qmi_ops *ops, | ||
| 246 | const struct qmi_msg_handler *handlers); | ||
| 247 | void qmi_handle_release(struct qmi_handle *qmi); | ||
| 248 | |||
| 249 | ssize_t qmi_send_request(struct qmi_handle *qmi, struct sockaddr_qrtr *sq, | ||
| 250 | struct qmi_txn *txn, int msg_id, size_t len, | ||
| 251 | struct qmi_elem_info *ei, const void *c_struct); | ||
| 252 | ssize_t qmi_send_response(struct qmi_handle *qmi, struct sockaddr_qrtr *sq, | ||
| 253 | struct qmi_txn *txn, int msg_id, size_t len, | ||
| 254 | struct qmi_elem_info *ei, const void *c_struct); | ||
| 255 | ssize_t qmi_send_indication(struct qmi_handle *qmi, struct sockaddr_qrtr *sq, | ||
| 256 | int msg_id, size_t len, struct qmi_elem_info *ei, | ||
| 257 | const void *c_struct); | ||
| 258 | |||
| 259 | void *qmi_encode_message(int type, unsigned int msg_id, size_t *len, | ||
| 260 | unsigned int txn_id, struct qmi_elem_info *ei, | ||
| 261 | const void *c_struct); | ||
| 262 | |||
| 263 | int qmi_decode_message(const void *buf, size_t len, | ||
| 264 | struct qmi_elem_info *ei, void *c_struct); | ||
| 265 | |||
| 266 | int qmi_txn_init(struct qmi_handle *qmi, struct qmi_txn *txn, | ||
| 267 | struct qmi_elem_info *ei, void *c_struct); | ||
| 268 | int qmi_txn_wait(struct qmi_txn *txn, unsigned long timeout); | ||
| 269 | void qmi_txn_cancel(struct qmi_txn *txn); | ||
| 270 | |||
| 271 | #endif | ||
diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h index cb889afe576b..a2b3dfcee0b5 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 19 | #include <linux/idr.h> | 19 | #include <linux/idr.h> |
| 20 | #include <linux/kref.h> | ||
| 20 | #include <linux/list.h> | 21 | #include <linux/list.h> |
| 21 | #include <linux/tee.h> | 22 | #include <linux/tee.h> |
| 22 | 23 | ||
| @@ -25,8 +26,12 @@ | |||
| 25 | * specific TEE driver. | 26 | * specific TEE driver. |
| 26 | */ | 27 | */ |
| 27 | 28 | ||
| 28 | #define TEE_SHM_MAPPED 0x1 /* Memory mapped by the kernel */ | 29 | #define TEE_SHM_MAPPED BIT(0) /* Memory mapped by the kernel */ |
| 29 | #define TEE_SHM_DMA_BUF 0x2 /* Memory with dma-buf handle */ | 30 | #define TEE_SHM_DMA_BUF BIT(1) /* Memory with dma-buf handle */ |
| 31 | #define TEE_SHM_EXT_DMA_BUF BIT(2) /* Memory with dma-buf handle */ | ||
| 32 | #define TEE_SHM_REGISTER BIT(3) /* Memory registered in secure world */ | ||
| 33 | #define TEE_SHM_USER_MAPPED BIT(4) /* Memory mapped in user space */ | ||
| 34 | #define TEE_SHM_POOL BIT(5) /* Memory allocated from pool */ | ||
| 30 | 35 | ||
| 31 | struct device; | 36 | struct device; |
| 32 | struct tee_device; | 37 | struct tee_device; |
| @@ -38,11 +43,17 @@ struct tee_shm_pool; | |||
| 38 | * @teedev: pointer to this drivers struct tee_device | 43 | * @teedev: pointer to this drivers struct tee_device |
| 39 | * @list_shm: List of shared memory object owned by this context | 44 | * @list_shm: List of shared memory object owned by this context |
| 40 | * @data: driver specific context data, managed by the driver | 45 | * @data: driver specific context data, managed by the driver |
| 46 | * @refcount: reference counter for this structure | ||
| 47 | * @releasing: flag that indicates if context is being released right now. | ||
| 48 | * It is needed to break circular dependency on context during | ||
| 49 | * shared memory release. | ||
| 41 | */ | 50 | */ |
| 42 | struct tee_context { | 51 | struct tee_context { |
| 43 | struct tee_device *teedev; | 52 | struct tee_device *teedev; |
| 44 | struct list_head list_shm; | 53 | struct list_head list_shm; |
| 45 | void *data; | 54 | void *data; |
| 55 | struct kref refcount; | ||
| 56 | bool releasing; | ||
| 46 | }; | 57 | }; |
| 47 | 58 | ||
| 48 | struct tee_param_memref { | 59 | struct tee_param_memref { |
| @@ -76,6 +87,8 @@ struct tee_param { | |||
| 76 | * @cancel_req: request cancel of an ongoing invoke or open | 87 | * @cancel_req: request cancel of an ongoing invoke or open |
| 77 | * @supp_revc: called for supplicant to get a command | 88 | * @supp_revc: called for supplicant to get a command |
| 78 | * @supp_send: called for supplicant to send a response | 89 | * @supp_send: called for supplicant to send a response |
| 90 | * @shm_register: register shared memory buffer in TEE | ||
| 91 | * @shm_unregister: unregister shared memory buffer in TEE | ||
| 79 | */ | 92 | */ |
| 80 | struct tee_driver_ops { | 93 | struct tee_driver_ops { |
| 81 | void (*get_version)(struct tee_device *teedev, | 94 | void (*get_version)(struct tee_device *teedev, |
| @@ -94,6 +107,10 @@ struct tee_driver_ops { | |||
| 94 | struct tee_param *param); | 107 | struct tee_param *param); |
| 95 | int (*supp_send)(struct tee_context *ctx, u32 ret, u32 num_params, | 108 | int (*supp_send)(struct tee_context *ctx, u32 ret, u32 num_params, |
| 96 | struct tee_param *param); | 109 | struct tee_param *param); |
| 110 | int (*shm_register)(struct tee_context *ctx, struct tee_shm *shm, | ||
| 111 | struct page **pages, size_t num_pages, | ||
| 112 | unsigned long start); | ||
| 113 | int (*shm_unregister)(struct tee_context *ctx, struct tee_shm *shm); | ||
| 97 | }; | 114 | }; |
| 98 | 115 | ||
| 99 | /** | 116 | /** |
| @@ -150,6 +167,97 @@ int tee_device_register(struct tee_device *teedev); | |||
| 150 | void tee_device_unregister(struct tee_device *teedev); | 167 | void tee_device_unregister(struct tee_device *teedev); |
| 151 | 168 | ||
| 152 | /** | 169 | /** |
| 170 | * struct tee_shm - shared memory object | ||
| 171 | * @teedev: device used to allocate the object | ||
| 172 | * @ctx: context using the object, if NULL the context is gone | ||
| 173 | * @link link element | ||
| 174 | * @paddr: physical address of the shared memory | ||
| 175 | * @kaddr: virtual address of the shared memory | ||
| 176 | * @size: size of shared memory | ||
| 177 | * @offset: offset of buffer in user space | ||
| 178 | * @pages: locked pages from userspace | ||
| 179 | * @num_pages: number of locked pages | ||
| 180 | * @dmabuf: dmabuf used to for exporting to user space | ||
| 181 | * @flags: defined by TEE_SHM_* in tee_drv.h | ||
| 182 | * @id: unique id of a shared memory object on this device | ||
| 183 | * | ||
| 184 | * This pool is only supposed to be accessed directly from the TEE | ||
| 185 | * subsystem and from drivers that implements their own shm pool manager. | ||
| 186 | */ | ||
| 187 | struct tee_shm { | ||
| 188 | struct tee_device *teedev; | ||
| 189 | struct tee_context *ctx; | ||
| 190 | struct list_head link; | ||
| 191 | phys_addr_t paddr; | ||
| 192 | void *kaddr; | ||
| 193 | size_t size; | ||
| 194 | unsigned int offset; | ||
| 195 | struct page **pages; | ||
| 196 | size_t num_pages; | ||
| 197 | struct dma_buf *dmabuf; | ||
| 198 | u32 flags; | ||
| 199 | int id; | ||
| 200 | }; | ||
| 201 | |||
| 202 | /** | ||
| 203 | * struct tee_shm_pool_mgr - shared memory manager | ||
| 204 | * @ops: operations | ||
| 205 | * @private_data: private data for the shared memory manager | ||
| 206 | */ | ||
| 207 | struct tee_shm_pool_mgr { | ||
| 208 | const struct tee_shm_pool_mgr_ops *ops; | ||
| 209 | void *private_data; | ||
| 210 | }; | ||
| 211 | |||
| 212 | /** | ||
| 213 | * struct tee_shm_pool_mgr_ops - shared memory pool manager operations | ||
| 214 | * @alloc: called when allocating shared memory | ||
| 215 | * @free: called when freeing shared memory | ||
| 216 | * @destroy_poolmgr: called when destroying the pool manager | ||
| 217 | */ | ||
| 218 | struct tee_shm_pool_mgr_ops { | ||
| 219 | int (*alloc)(struct tee_shm_pool_mgr *poolmgr, struct tee_shm *shm, | ||
| 220 | size_t size); | ||
| 221 | void (*free)(struct tee_shm_pool_mgr *poolmgr, struct tee_shm *shm); | ||
| 222 | void (*destroy_poolmgr)(struct tee_shm_pool_mgr *poolmgr); | ||
| 223 | }; | ||
| 224 | |||
| 225 | /** | ||
| 226 | * tee_shm_pool_alloc() - Create a shared memory pool from shm managers | ||
| 227 | * @priv_mgr: manager for driver private shared memory allocations | ||
| 228 | * @dmabuf_mgr: manager for dma-buf shared memory allocations | ||
| 229 | * | ||
| 230 | * Allocation with the flag TEE_SHM_DMA_BUF set will use the range supplied | ||
| 231 | * in @dmabuf, others will use the range provided by @priv. | ||
| 232 | * | ||
| 233 | * @returns pointer to a 'struct tee_shm_pool' or an ERR_PTR on failure. | ||
| 234 | */ | ||
| 235 | struct tee_shm_pool *tee_shm_pool_alloc(struct tee_shm_pool_mgr *priv_mgr, | ||
| 236 | struct tee_shm_pool_mgr *dmabuf_mgr); | ||
| 237 | |||
| 238 | /* | ||
| 239 | * tee_shm_pool_mgr_alloc_res_mem() - Create a shm manager for reserved | ||
| 240 | * memory | ||
| 241 | * @vaddr: Virtual address of start of pool | ||
| 242 | * @paddr: Physical address of start of pool | ||
| 243 | * @size: Size in bytes of the pool | ||
| 244 | * | ||
| 245 | * @returns pointer to a 'struct tee_shm_pool_mgr' or an ERR_PTR on failure. | ||
| 246 | */ | ||
| 247 | struct tee_shm_pool_mgr *tee_shm_pool_mgr_alloc_res_mem(unsigned long vaddr, | ||
| 248 | phys_addr_t paddr, | ||
| 249 | size_t size, | ||
| 250 | int min_alloc_order); | ||
| 251 | |||
| 252 | /** | ||
| 253 | * tee_shm_pool_mgr_destroy() - Free a shared memory manager | ||
| 254 | */ | ||
| 255 | static inline void tee_shm_pool_mgr_destroy(struct tee_shm_pool_mgr *poolm) | ||
| 256 | { | ||
| 257 | poolm->ops->destroy_poolmgr(poolm); | ||
| 258 | } | ||
| 259 | |||
| 260 | /** | ||
| 153 | * struct tee_shm_pool_mem_info - holds information needed to create a shared | 261 | * struct tee_shm_pool_mem_info - holds information needed to create a shared |
| 154 | * memory pool | 262 | * memory pool |
| 155 | * @vaddr: Virtual address of start of pool | 263 | * @vaddr: Virtual address of start of pool |
| @@ -211,6 +319,40 @@ void *tee_get_drvdata(struct tee_device *teedev); | |||
| 211 | struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags); | 319 | struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags); |
| 212 | 320 | ||
| 213 | /** | 321 | /** |
| 322 | * tee_shm_priv_alloc() - Allocate shared memory privately | ||
| 323 | * @dev: Device that allocates the shared memory | ||
| 324 | * @size: Requested size of shared memory | ||
| 325 | * | ||
| 326 | * Allocates shared memory buffer that is not associated with any client | ||
| 327 | * context. Such buffers are owned by TEE driver and used for internal calls. | ||
| 328 | * | ||
| 329 | * @returns a pointer to 'struct tee_shm' | ||
| 330 | */ | ||
| 331 | struct tee_shm *tee_shm_priv_alloc(struct tee_device *teedev, size_t size); | ||
| 332 | |||
| 333 | /** | ||
| 334 | * tee_shm_register() - Register shared memory buffer | ||
| 335 | * @ctx: Context that registers the shared memory | ||
| 336 | * @addr: Address is userspace of the shared buffer | ||
| 337 | * @length: Length of the shared buffer | ||
| 338 | * @flags: Flags setting properties for the requested shared memory. | ||
| 339 | * | ||
| 340 | * @returns a pointer to 'struct tee_shm' | ||
| 341 | */ | ||
| 342 | struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, | ||
| 343 | size_t length, u32 flags); | ||
| 344 | |||
| 345 | /** | ||
| 346 | * tee_shm_is_registered() - Check if shared memory object in registered in TEE | ||
| 347 | * @shm: Shared memory handle | ||
| 348 | * @returns true if object is registered in TEE | ||
| 349 | */ | ||
| 350 | static inline bool tee_shm_is_registered(struct tee_shm *shm) | ||
| 351 | { | ||
| 352 | return shm && (shm->flags & TEE_SHM_REGISTER); | ||
| 353 | } | ||
| 354 | |||
| 355 | /** | ||
| 214 | * tee_shm_free() - Free shared memory | 356 | * tee_shm_free() - Free shared memory |
| 215 | * @shm: Handle to shared memory to free | 357 | * @shm: Handle to shared memory to free |
| 216 | */ | 358 | */ |
| @@ -260,11 +402,47 @@ void *tee_shm_get_va(struct tee_shm *shm, size_t offs); | |||
| 260 | int tee_shm_get_pa(struct tee_shm *shm, size_t offs, phys_addr_t *pa); | 402 | int tee_shm_get_pa(struct tee_shm *shm, size_t offs, phys_addr_t *pa); |
| 261 | 403 | ||
| 262 | /** | 404 | /** |
| 405 | * tee_shm_get_size() - Get size of shared memory buffer | ||
| 406 | * @shm: Shared memory handle | ||
| 407 | * @returns size of shared memory | ||
| 408 | */ | ||
| 409 | static inline size_t tee_shm_get_size(struct tee_shm *shm) | ||
| 410 | { | ||
| 411 | return shm->size; | ||
| 412 | } | ||
| 413 | |||
| 414 | /** | ||
| 415 | * tee_shm_get_pages() - Get list of pages that hold shared buffer | ||
| 416 | * @shm: Shared memory handle | ||
| 417 | * @num_pages: Number of pages will be stored there | ||
| 418 | * @returns pointer to pages array | ||
| 419 | */ | ||
| 420 | static inline struct page **tee_shm_get_pages(struct tee_shm *shm, | ||
| 421 | size_t *num_pages) | ||
| 422 | { | ||
| 423 | *num_pages = shm->num_pages; | ||
| 424 | return shm->pages; | ||
| 425 | } | ||
| 426 | |||
| 427 | /** | ||
| 428 | * tee_shm_get_page_offset() - Get shared buffer offset from page start | ||
| 429 | * @shm: Shared memory handle | ||
| 430 | * @returns page offset of shared buffer | ||
| 431 | */ | ||
| 432 | static inline size_t tee_shm_get_page_offset(struct tee_shm *shm) | ||
| 433 | { | ||
| 434 | return shm->offset; | ||
| 435 | } | ||
| 436 | |||
| 437 | /** | ||
| 263 | * tee_shm_get_id() - Get id of a shared memory object | 438 | * tee_shm_get_id() - Get id of a shared memory object |
| 264 | * @shm: Shared memory handle | 439 | * @shm: Shared memory handle |
| 265 | * @returns id | 440 | * @returns id |
| 266 | */ | 441 | */ |
| 267 | int tee_shm_get_id(struct tee_shm *shm); | 442 | static inline int tee_shm_get_id(struct tee_shm *shm) |
| 443 | { | ||
| 444 | return shm->id; | ||
| 445 | } | ||
| 268 | 446 | ||
| 269 | /** | 447 | /** |
| 270 | * tee_shm_get_from_id() - Find shared memory object and increase reference | 448 | * tee_shm_get_from_id() - Find shared memory object and increase reference |
| @@ -275,4 +453,16 @@ int tee_shm_get_id(struct tee_shm *shm); | |||
| 275 | */ | 453 | */ |
| 276 | struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id); | 454 | struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id); |
| 277 | 455 | ||
| 456 | static inline bool tee_param_is_memref(struct tee_param *param) | ||
| 457 | { | ||
| 458 | switch (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) { | ||
| 459 | case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT: | ||
| 460 | case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT: | ||
| 461 | case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT: | ||
| 462 | return true; | ||
| 463 | default: | ||
| 464 | return false; | ||
| 465 | } | ||
| 466 | } | ||
| 467 | |||
| 278 | #endif /*__TEE_DRV_H*/ | 468 | #endif /*__TEE_DRV_H*/ |
diff --git a/include/linux/ti-emif-sram.h b/include/linux/ti-emif-sram.h new file mode 100644 index 000000000000..45bc6b376492 --- /dev/null +++ b/include/linux/ti-emif-sram.h | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | /* | ||
| 2 | * TI AM33XX EMIF Routines | ||
| 3 | * | ||
| 4 | * Copyright (C) 2016-2017 Texas Instruments Inc. | ||
| 5 | * Dave Gerlach | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU General Public License as | ||
| 9 | * published by the Free Software Foundation version 2. | ||
| 10 | * | ||
| 11 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
| 12 | * kind, whether express or implied; without even the implied warranty | ||
| 13 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | */ | ||
| 16 | #ifndef __LINUX_TI_EMIF_H | ||
| 17 | #define __LINUX_TI_EMIF_H | ||
| 18 | |||
| 19 | #include <linux/kbuild.h> | ||
| 20 | #include <linux/types.h> | ||
| 21 | #ifndef __ASSEMBLY__ | ||
| 22 | |||
| 23 | struct emif_regs_amx3 { | ||
| 24 | u32 emif_sdcfg_val; | ||
| 25 | u32 emif_timing1_val; | ||
| 26 | u32 emif_timing2_val; | ||
| 27 | u32 emif_timing3_val; | ||
| 28 | u32 emif_ref_ctrl_val; | ||
| 29 | u32 emif_zqcfg_val; | ||
| 30 | u32 emif_pmcr_val; | ||
| 31 | u32 emif_pmcr_shdw_val; | ||
| 32 | u32 emif_rd_wr_level_ramp_ctrl; | ||
| 33 | u32 emif_rd_wr_exec_thresh; | ||
| 34 | u32 emif_cos_config; | ||
| 35 | u32 emif_priority_to_cos_mapping; | ||
| 36 | u32 emif_connect_id_serv_1_map; | ||
| 37 | u32 emif_connect_id_serv_2_map; | ||
| 38 | u32 emif_ocp_config_val; | ||
| 39 | u32 emif_lpddr2_nvm_tim; | ||
| 40 | u32 emif_lpddr2_nvm_tim_shdw; | ||
| 41 | u32 emif_dll_calib_ctrl_val; | ||
| 42 | u32 emif_dll_calib_ctrl_val_shdw; | ||
| 43 | u32 emif_ddr_phy_ctlr_1; | ||
| 44 | u32 emif_ext_phy_ctrl_vals[120]; | ||
| 45 | }; | ||
| 46 | |||
| 47 | struct ti_emif_pm_data { | ||
| 48 | void __iomem *ti_emif_base_addr_virt; | ||
| 49 | phys_addr_t ti_emif_base_addr_phys; | ||
| 50 | unsigned long ti_emif_sram_config; | ||
| 51 | struct emif_regs_amx3 *regs_virt; | ||
| 52 | phys_addr_t regs_phys; | ||
| 53 | } __packed __aligned(8); | ||
| 54 | |||
| 55 | struct ti_emif_pm_functions { | ||
| 56 | u32 save_context; | ||
| 57 | u32 restore_context; | ||
| 58 | u32 enter_sr; | ||
| 59 | u32 exit_sr; | ||
| 60 | u32 abort_sr; | ||
| 61 | } __packed __aligned(8); | ||
| 62 | |||
| 63 | struct gen_pool; | ||
| 64 | |||
| 65 | int ti_emif_copy_pm_function_table(struct gen_pool *sram_pool, void *dst); | ||
| 66 | int ti_emif_get_mem_type(void); | ||
| 67 | |||
| 68 | #endif | ||
| 69 | #endif /* __LINUX_TI_EMIF_H */ | ||
diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h index 44202ff897fd..233bae954970 100644 --- a/include/soc/tegra/mc.h +++ b/include/soc/tegra/mc.h | |||
| @@ -51,6 +51,12 @@ struct tegra_smmu_swgroup { | |||
| 51 | unsigned int reg; | 51 | unsigned int reg; |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | struct tegra_smmu_group_soc { | ||
| 55 | const char *name; | ||
| 56 | const unsigned int *swgroups; | ||
| 57 | unsigned int num_swgroups; | ||
| 58 | }; | ||
| 59 | |||
| 54 | struct tegra_smmu_soc { | 60 | struct tegra_smmu_soc { |
| 55 | const struct tegra_mc_client *clients; | 61 | const struct tegra_mc_client *clients; |
| 56 | unsigned int num_clients; | 62 | unsigned int num_clients; |
| @@ -58,6 +64,9 @@ struct tegra_smmu_soc { | |||
| 58 | const struct tegra_smmu_swgroup *swgroups; | 64 | const struct tegra_smmu_swgroup *swgroups; |
| 59 | unsigned int num_swgroups; | 65 | unsigned int num_swgroups; |
| 60 | 66 | ||
| 67 | const struct tegra_smmu_group_soc *groups; | ||
| 68 | unsigned int num_groups; | ||
| 69 | |||
| 61 | bool supports_round_robin_arbitration; | 70 | bool supports_round_robin_arbitration; |
| 62 | bool supports_request_limit; | 71 | bool supports_request_limit; |
| 63 | 72 | ||
diff --git a/include/uapi/linux/tee.h b/include/uapi/linux/tee.h index 688782e90140..4b9eb064d7e7 100644 --- a/include/uapi/linux/tee.h +++ b/include/uapi/linux/tee.h | |||
| @@ -50,6 +50,7 @@ | |||
| 50 | 50 | ||
| 51 | #define TEE_GEN_CAP_GP (1 << 0)/* GlobalPlatform compliant TEE */ | 51 | #define TEE_GEN_CAP_GP (1 << 0)/* GlobalPlatform compliant TEE */ |
| 52 | #define TEE_GEN_CAP_PRIVILEGED (1 << 1)/* Privileged device (for supplicant) */ | 52 | #define TEE_GEN_CAP_PRIVILEGED (1 << 1)/* Privileged device (for supplicant) */ |
| 53 | #define TEE_GEN_CAP_REG_MEM (1 << 2)/* Supports registering shared memory */ | ||
| 53 | 54 | ||
| 54 | /* | 55 | /* |
| 55 | * TEE Implementation ID | 56 | * TEE Implementation ID |
| @@ -154,6 +155,13 @@ struct tee_ioctl_buf_data { | |||
| 154 | */ | 155 | */ |
| 155 | #define TEE_IOCTL_PARAM_ATTR_TYPE_MASK 0xff | 156 | #define TEE_IOCTL_PARAM_ATTR_TYPE_MASK 0xff |
| 156 | 157 | ||
| 158 | /* Meta parameter carrying extra information about the message. */ | ||
| 159 | #define TEE_IOCTL_PARAM_ATTR_META 0x100 | ||
| 160 | |||
| 161 | /* Mask of all known attr bits */ | ||
| 162 | #define TEE_IOCTL_PARAM_ATTR_MASK \ | ||
| 163 | (TEE_IOCTL_PARAM_ATTR_TYPE_MASK | TEE_IOCTL_PARAM_ATTR_META) | ||
| 164 | |||
| 157 | /* | 165 | /* |
| 158 | * Matches TEEC_LOGIN_* in GP TEE Client API | 166 | * Matches TEEC_LOGIN_* in GP TEE Client API |
| 159 | * Are only defined for GP compliant TEEs | 167 | * Are only defined for GP compliant TEEs |
| @@ -332,6 +340,35 @@ struct tee_iocl_supp_send_arg { | |||
| 332 | #define TEE_IOC_SUPPL_SEND _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 7, \ | 340 | #define TEE_IOC_SUPPL_SEND _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 7, \ |
| 333 | struct tee_ioctl_buf_data) | 341 | struct tee_ioctl_buf_data) |
| 334 | 342 | ||
| 343 | /** | ||
| 344 | * struct tee_ioctl_shm_register_data - Shared memory register argument | ||
| 345 | * @addr: [in] Start address of shared memory to register | ||
| 346 | * @length: [in/out] Length of shared memory to register | ||
| 347 | * @flags: [in/out] Flags to/from registration. | ||
| 348 | * @id: [out] Identifier of the shared memory | ||
| 349 | * | ||
| 350 | * The flags field should currently be zero as input. Updated by the call | ||
| 351 | * with actual flags as defined by TEE_IOCTL_SHM_* above. | ||
| 352 | * This structure is used as argument for TEE_IOC_SHM_REGISTER below. | ||
| 353 | */ | ||
| 354 | struct tee_ioctl_shm_register_data { | ||
| 355 | __u64 addr; | ||
| 356 | __u64 length; | ||
| 357 | __u32 flags; | ||
| 358 | __s32 id; | ||
| 359 | }; | ||
| 360 | |||
| 361 | /** | ||
| 362 | * TEE_IOC_SHM_REGISTER - Register shared memory argument | ||
| 363 | * | ||
| 364 | * Registers shared memory between the user space process and secure OS. | ||
| 365 | * | ||
| 366 | * Returns a file descriptor on success or < 0 on failure | ||
| 367 | * | ||
| 368 | * The shared memory is unregisterred when the descriptor is closed. | ||
| 369 | */ | ||
| 370 | #define TEE_IOC_SHM_REGISTER _IOWR(TEE_IOC_MAGIC, TEE_IOC_BASE + 9, \ | ||
| 371 | struct tee_ioctl_shm_register_data) | ||
| 335 | /* | 372 | /* |
| 336 | * Five syscalls are used when communicating with the TEE driver. | 373 | * Five syscalls are used when communicating with the TEE driver. |
| 337 | * open(): opens the device associated with the driver | 374 | * open(): opens the device associated with the driver |
