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