Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 1 | /* |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame^] | 2 | * Copyright (c) 2020-2021, Renesas Electronics Corporation. All rights reserved. |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | #include <stdint.h> |
| 7 | |
| 8 | #include <common/debug.h> |
| 9 | #include <lib/mmio.h> |
| 10 | |
| 11 | #if RCAR_LSI == RCAR_AUTO |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame^] | 12 | #include "G2H/pfc_init_g2h.h" |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 13 | #include "G2M/pfc_init_g2m.h" |
| 14 | #endif /* RCAR_LSI == RCAR_AUTO */ |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame^] | 15 | #if (RCAR_LSI == RZ_G2H) |
| 16 | #include "G2H/pfc_init_g2h.h" |
| 17 | #endif /* RCAR_LSI == RZ_G2H */ |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 18 | #if (RCAR_LSI == RZ_G2M) |
| 19 | #include "G2M/pfc_init_g2m.h" |
| 20 | #endif /* RCAR_LSI == RZ_G2M */ |
| 21 | #include "rcar_def.h" |
| 22 | |
| 23 | #define PRR_PRODUCT_ERR(reg) \ |
| 24 | do { \ |
| 25 | ERROR("LSI Product ID(PRR=0x%x) PFC init not supported.\n", \ |
| 26 | reg); \ |
| 27 | panic(); \ |
| 28 | } while (0) |
| 29 | |
| 30 | #define PRR_CUT_ERR(reg) \ |
| 31 | do { \ |
| 32 | ERROR("LSI Cut ID(PRR=0x%x) PFC init not supported.\n", \ |
| 33 | reg); \ |
| 34 | panic();\ |
| 35 | } while (0) |
| 36 | |
| 37 | void rzg_pfc_init(void) |
| 38 | { |
| 39 | uint32_t reg; |
| 40 | |
| 41 | reg = mmio_read_32(RCAR_PRR); |
| 42 | #if RCAR_LSI == RCAR_AUTO |
| 43 | switch (reg & PRR_PRODUCT_MASK) { |
| 44 | case PRR_PRODUCT_M3: |
| 45 | pfc_init_g2m(); |
| 46 | break; |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame^] | 47 | case PRR_PRODUCT_H3: |
| 48 | pfc_init_g2h(); |
| 49 | break; |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 50 | default: |
| 51 | PRR_PRODUCT_ERR(reg); |
| 52 | break; |
| 53 | } |
| 54 | |
| 55 | #elif RCAR_LSI_CUT_COMPAT /* RCAR_LSI == RCAR_AUTO */ |
| 56 | switch (reg & PRR_PRODUCT_MASK) { |
| 57 | case PRR_PRODUCT_M3: |
| 58 | #if RCAR_LSI != RZ_G2M |
| 59 | PRR_PRODUCT_ERR(reg); |
| 60 | #else /* RCAR_LSI != RZ_G2M */ |
| 61 | pfc_init_g2m(); |
| 62 | #endif /* RCAR_LSI != RZ_G2M */ |
| 63 | break; |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame^] | 64 | case PRR_PRODUCT_H3: |
| 65 | #if (RCAR_LSI != RZ_G2H) |
| 66 | PRR_PRODUCT_ERR(reg); |
| 67 | #else /* RCAR_LSI != RZ_G2H */ |
| 68 | pfc_init_g2h(); |
| 69 | #endif /* RCAR_LSI != RZ_G2H */ |
| 70 | break; |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 71 | default: |
| 72 | PRR_PRODUCT_ERR(reg); |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | #else /* RCAR_LSI == RCAR_AUTO */ |
| 77 | #if (RCAR_LSI == RZ_G2M) |
| 78 | if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3) { |
| 79 | PRR_PRODUCT_ERR(reg); |
| 80 | } |
| 81 | pfc_init_m3(); |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame^] | 82 | #elif (RCAR_LSI == RZ_G2H) |
| 83 | if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_H3) { |
| 84 | PRR_PRODUCT_ERR(reg); |
| 85 | } |
| 86 | pfc_init_g2h(); |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 87 | #else /* RCAR_LSI == RZ_G2M */ |
| 88 | #error "Don't have PFC initialize routine(unknown)." |
| 89 | #endif /* RCAR_LSI == RZ_G2M */ |
| 90 | #endif /* RCAR_LSI == RCAR_AUTO */ |
| 91 | } |