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 | 7b19dff | 2020-12-29 13:46:48 +0000 | [diff] [blame] | 12 | #include "G2E/pfc_init_g2e.h" |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame] | 13 | #include "G2H/pfc_init_g2h.h" |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 14 | #include "G2M/pfc_init_g2m.h" |
Lad Prabhakar | b7fc5e2 | 2020-12-29 13:39:31 +0000 | [diff] [blame] | 15 | #include "G2N/pfc_init_g2n.h" |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 16 | #endif /* RCAR_LSI == RCAR_AUTO */ |
Lad Prabhakar | 7b19dff | 2020-12-29 13:46:48 +0000 | [diff] [blame] | 17 | #if (RCAR_LSI == RZ_G2E) |
| 18 | #include "G2E/pfc_init_g2e.h" |
| 19 | #endif /* RCAR_LSI == RZ_G2N */ |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame] | 20 | #if (RCAR_LSI == RZ_G2H) |
| 21 | #include "G2H/pfc_init_g2h.h" |
| 22 | #endif /* RCAR_LSI == RZ_G2H */ |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 23 | #if (RCAR_LSI == RZ_G2M) |
| 24 | #include "G2M/pfc_init_g2m.h" |
| 25 | #endif /* RCAR_LSI == RZ_G2M */ |
Lad Prabhakar | b7fc5e2 | 2020-12-29 13:39:31 +0000 | [diff] [blame] | 26 | #if (RCAR_LSI == RZ_G2N) |
| 27 | #include "G2N/pfc_init_g2n.h" |
| 28 | #endif /* RCAR_LSI == RZ_G2N */ |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 29 | #include "rcar_def.h" |
| 30 | |
| 31 | #define PRR_PRODUCT_ERR(reg) \ |
| 32 | do { \ |
| 33 | ERROR("LSI Product ID(PRR=0x%x) PFC init not supported.\n", \ |
| 34 | reg); \ |
| 35 | panic(); \ |
| 36 | } while (0) |
| 37 | |
| 38 | #define PRR_CUT_ERR(reg) \ |
| 39 | do { \ |
| 40 | ERROR("LSI Cut ID(PRR=0x%x) PFC init not supported.\n", \ |
| 41 | reg); \ |
| 42 | panic();\ |
| 43 | } while (0) |
| 44 | |
| 45 | void rzg_pfc_init(void) |
| 46 | { |
| 47 | uint32_t reg; |
| 48 | |
| 49 | reg = mmio_read_32(RCAR_PRR); |
| 50 | #if RCAR_LSI == RCAR_AUTO |
| 51 | switch (reg & PRR_PRODUCT_MASK) { |
| 52 | case PRR_PRODUCT_M3: |
| 53 | pfc_init_g2m(); |
| 54 | break; |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame] | 55 | case PRR_PRODUCT_H3: |
| 56 | pfc_init_g2h(); |
| 57 | break; |
Lad Prabhakar | b7fc5e2 | 2020-12-29 13:39:31 +0000 | [diff] [blame] | 58 | case PRR_PRODUCT_M3N: |
| 59 | pfc_init_g2n(); |
| 60 | break; |
Lad Prabhakar | 7b19dff | 2020-12-29 13:46:48 +0000 | [diff] [blame] | 61 | case PRR_PRODUCT_E3: |
| 62 | pfc_init_g2e(); |
| 63 | break; |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 64 | default: |
| 65 | PRR_PRODUCT_ERR(reg); |
| 66 | break; |
| 67 | } |
| 68 | |
| 69 | #elif RCAR_LSI_CUT_COMPAT /* RCAR_LSI == RCAR_AUTO */ |
| 70 | switch (reg & PRR_PRODUCT_MASK) { |
| 71 | case PRR_PRODUCT_M3: |
| 72 | #if RCAR_LSI != RZ_G2M |
| 73 | PRR_PRODUCT_ERR(reg); |
| 74 | #else /* RCAR_LSI != RZ_G2M */ |
| 75 | pfc_init_g2m(); |
| 76 | #endif /* RCAR_LSI != RZ_G2M */ |
| 77 | break; |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame] | 78 | case PRR_PRODUCT_H3: |
| 79 | #if (RCAR_LSI != RZ_G2H) |
| 80 | PRR_PRODUCT_ERR(reg); |
| 81 | #else /* RCAR_LSI != RZ_G2H */ |
| 82 | pfc_init_g2h(); |
| 83 | #endif /* RCAR_LSI != RZ_G2H */ |
| 84 | break; |
Lad Prabhakar | b7fc5e2 | 2020-12-29 13:39:31 +0000 | [diff] [blame] | 85 | case PRR_PRODUCT_M3N: |
| 86 | #if RCAR_LSI != RZ_G2N |
| 87 | PRR_PRODUCT_ERR(reg); |
| 88 | #else |
| 89 | pfc_init_g2n(); |
| 90 | #endif /* RCAR_LSI != RZ_G2N */ |
| 91 | break; |
Lad Prabhakar | 7b19dff | 2020-12-29 13:46:48 +0000 | [diff] [blame] | 92 | case PRR_PRODUCT_E3: |
| 93 | #if RCAR_LSI != RZ_G2E |
| 94 | PRR_PRODUCT_ERR(reg); |
| 95 | #else |
| 96 | pfc_init_g2e(); |
| 97 | #endif |
| 98 | break; |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 99 | default: |
| 100 | PRR_PRODUCT_ERR(reg); |
| 101 | break; |
| 102 | } |
| 103 | |
| 104 | #else /* RCAR_LSI == RCAR_AUTO */ |
| 105 | #if (RCAR_LSI == RZ_G2M) |
| 106 | if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3) { |
| 107 | PRR_PRODUCT_ERR(reg); |
| 108 | } |
| 109 | pfc_init_m3(); |
Lad Prabhakar | b3e77d8 | 2021-03-18 13:07:51 +0000 | [diff] [blame] | 110 | #elif (RCAR_LSI == RZ_G2H) |
| 111 | if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_H3) { |
| 112 | PRR_PRODUCT_ERR(reg); |
| 113 | } |
| 114 | pfc_init_g2h(); |
Lad Prabhakar | b7fc5e2 | 2020-12-29 13:39:31 +0000 | [diff] [blame] | 115 | #elif (RCAR_LSI == RZ_G2N) /* G2N */ |
| 116 | if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_M3N) { |
| 117 | PRR_PRODUCT_ERR(reg); |
| 118 | } |
| 119 | pfc_init_g2n(); |
Lad Prabhakar | 7b19dff | 2020-12-29 13:46:48 +0000 | [diff] [blame] | 120 | #elif (RCAR_LSI == RZ_G2E) |
| 121 | if ((reg & PRR_PRODUCT_MASK) != PRR_PRODUCT_E3) { |
| 122 | PRR_PRODUCT_ERR(reg); |
| 123 | } |
| 124 | pfc_init_g2e(); |
Biju Das | bf40dbb | 2020-11-09 09:40:04 +0000 | [diff] [blame] | 125 | #else /* RCAR_LSI == RZ_G2M */ |
| 126 | #error "Don't have PFC initialize routine(unknown)." |
| 127 | #endif /* RCAR_LSI == RZ_G2M */ |
| 128 | #endif /* RCAR_LSI == RCAR_AUTO */ |
| 129 | } |