Konstantin Porotchkin | 01c84d4 | 2018-02-26 16:01:57 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 Marvell International Ltd. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * https://spdx.org/licenses |
| 6 | */ |
| 7 | |
| 8 | /* CP110 Marvell SoC driver */ |
| 9 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 10 | #ifndef CP110_SETUP_H |
| 11 | #define CP110_SETUP_H |
Konstantin Porotchkin | 01c84d4 | 2018-02-26 16:01:57 +0200 | [diff] [blame] | 12 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 13 | #include <lib/mmio.h> |
| 14 | |
Konstantin Porotchkin | 01c84d4 | 2018-02-26 16:01:57 +0200 | [diff] [blame] | 15 | #include <mvebu_def.h> |
| 16 | |
| 17 | #define MVEBU_DEVICE_ID_REG (MVEBU_CP_DFX_OFFSET + 0x40) |
| 18 | #define MVEBU_DEVICE_ID_OFFSET (0) |
| 19 | #define MVEBU_DEVICE_ID_MASK (0xffff << MVEBU_DEVICE_ID_OFFSET) |
| 20 | #define MVEBU_DEVICE_REV_OFFSET (16) |
| 21 | #define MVEBU_DEVICE_REV_MASK (0xf << MVEBU_DEVICE_REV_OFFSET) |
| 22 | #define MVEBU_70X0_DEV_ID (0x7040) |
| 23 | #define MVEBU_70X0_CP115_DEV_ID (0x7045) |
Christine Gharzuzi | 46a4fc6 | 2018-08-02 20:25:11 +0300 | [diff] [blame] | 24 | #define MVEBU_3900_DEV_ID (0x6025) |
Konstantin Porotchkin | 01c84d4 | 2018-02-26 16:01:57 +0200 | [diff] [blame] | 25 | #define MVEBU_80X0_DEV_ID (0x8040) |
| 26 | #define MVEBU_80X0_CP115_DEV_ID (0x8045) |
Ben Peled | 3486136 | 2019-03-27 16:26:02 +0200 | [diff] [blame] | 27 | #define MVEBU_CN9130_DEV_ID (0x7025) |
Konstantin Porotchkin | 01c84d4 | 2018-02-26 16:01:57 +0200 | [diff] [blame] | 28 | #define MVEBU_CP110_SA_DEV_ID (0x110) |
| 29 | #define MVEBU_CP110_REF_ID_A1 1 |
| 30 | #define MVEBU_CP110_REF_ID_A2 2 |
| 31 | #define MAX_STREAM_ID_PER_CP (0x10) |
| 32 | #define STREAM_ID_BASE (0x40) |
| 33 | |
Konstantin Porotchkin | 6262d0b | 2020-01-30 11:19:43 +0200 | [diff] [blame] | 34 | #define MVEBU_SECUREBOOT_CTRL_REG (MVEBU_RFU_BASE + 0x4730) |
| 35 | #define MVEBU_SECUREBOOT_EN_MASK BIT(0) |
| 36 | |
Konstantin Porotchkin | 01c84d4 | 2018-02-26 16:01:57 +0200 | [diff] [blame] | 37 | static inline uint32_t cp110_device_id_get(uintptr_t base) |
| 38 | { |
| 39 | /* Returns: |
| 40 | * - MVEBU_70X0_DEV_ID for A70X0 family |
| 41 | * - MVEBU_80X0_DEV_ID for A80X0 family |
| 42 | * - MVEBU_CP110_SA_DEV_ID for CP that connected stand alone |
| 43 | */ |
| 44 | return (mmio_read_32(base + MVEBU_DEVICE_ID_REG) >> |
| 45 | MVEBU_DEVICE_ID_OFFSET) & |
| 46 | MVEBU_DEVICE_ID_MASK; |
| 47 | } |
| 48 | |
| 49 | static inline uint32_t cp110_rev_id_get(uintptr_t base) |
| 50 | { |
| 51 | return (mmio_read_32(base + MVEBU_DEVICE_ID_REG) & |
| 52 | MVEBU_DEVICE_REV_MASK) >> |
| 53 | MVEBU_DEVICE_REV_OFFSET; |
| 54 | } |
| 55 | |
Konstantin Porotchkin | 6262d0b | 2020-01-30 11:19:43 +0200 | [diff] [blame] | 56 | static inline uint32_t is_secure(void) |
| 57 | { |
| 58 | return !!(mmio_read_32(MVEBU_SECUREBOOT_CTRL_REG) & |
| 59 | MVEBU_SECUREBOOT_EN_MASK); |
| 60 | } |
| 61 | |
Konstantin Porotchkin | 01c84d4 | 2018-02-26 16:01:57 +0200 | [diff] [blame] | 62 | void cp110_init(uintptr_t cp110_base, uint32_t stream_id); |
| 63 | void cp110_ble_init(uintptr_t cp110_base); |
Grzegorz Jaszczyk | 17e43dd | 2017-08-18 16:42:12 +0200 | [diff] [blame] | 64 | void cp110_amb_init(uintptr_t base); |
Konstantin Porotchkin | 01c84d4 | 2018-02-26 16:01:57 +0200 | [diff] [blame] | 65 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 66 | #endif /* CP110_SETUP_H */ |