Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 2 | /* |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 3 | * Copyright 2017-2018 NXP |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <i2c.h> |
| 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/clock.h> |
| 10 | #include <asm/arch/fsl_serdes.h> |
Prabhakar Kushwaha | 74d129b | 2017-01-30 17:05:35 +0530 | [diff] [blame] | 11 | #ifdef CONFIG_FSL_LS_PPA |
| 12 | #include <asm/arch/ppa.h> |
| 13 | #endif |
York Sun | 729f2d1 | 2017-03-06 09:02:34 -0800 | [diff] [blame] | 14 | #include <asm/arch/mmu.h> |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 15 | #include <asm/arch/soc.h> |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 16 | #include <fsl_esdhc.h> |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 17 | #include <hwconfig.h> |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 18 | #include <environment.h> |
| 19 | #include <fsl_mmdc.h> |
| 20 | #include <netdev.h> |
| 21 | |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 24 | static inline int get_board_version(void) |
| 25 | { |
| 26 | struct ccsr_gpio *pgpio = (void *)(GPIO1_BASE_ADDR); |
| 27 | int val; |
| 28 | |
| 29 | val = in_be32(&pgpio->gpdat); |
| 30 | |
| 31 | return val; |
| 32 | } |
| 33 | |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 34 | int checkboard(void) |
| 35 | { |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 36 | #ifdef CONFIG_TARGET_LS1012AFRDM |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 37 | puts("Board: LS1012AFRDM "); |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 38 | #else |
| 39 | int rev; |
| 40 | |
| 41 | rev = get_board_version(); |
| 42 | |
| 43 | puts("Board: FRWY-LS1012A "); |
| 44 | |
| 45 | puts("Version"); |
| 46 | |
| 47 | switch (rev) { |
| 48 | case BOARD_REV_A: |
| 49 | puts(": RevA "); |
| 50 | break; |
| 51 | case BOARD_REV_B: |
| 52 | puts(": RevB "); |
| 53 | break; |
| 54 | default: |
| 55 | puts(": unknown"); |
| 56 | break; |
| 57 | } |
| 58 | #endif |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | #ifdef CONFIG_TARGET_LS1012AFRWY |
| 64 | int esdhc_status_fixup(void *blob, const char *compat) |
| 65 | { |
| 66 | char esdhc0_path[] = "/soc/esdhc@1560000"; |
| 67 | char esdhc1_path[] = "/soc/esdhc@1580000"; |
| 68 | |
| 69 | do_fixup_by_path(blob, esdhc0_path, "status", "okay", |
| 70 | sizeof("okay"), 1); |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 71 | |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 72 | do_fixup_by_path(blob, esdhc1_path, "status", "disabled", |
| 73 | sizeof("disabled"), 1); |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 74 | return 0; |
| 75 | } |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 76 | #endif |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 77 | |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 78 | int dram_init(void) |
| 79 | { |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 80 | #ifdef CONFIG_TARGET_LS1012AFRWY |
| 81 | int board_rev; |
| 82 | #endif |
| 83 | struct fsl_mmdc_info mparam = { |
York Sun | c1e979b | 2016-09-26 08:09:25 -0700 | [diff] [blame] | 84 | 0x04180000, /* mdctl */ |
| 85 | 0x00030035, /* mdpdc */ |
| 86 | 0x12554000, /* mdotc */ |
| 87 | 0xbabf7954, /* mdcfg0 */ |
| 88 | 0xdb328f64, /* mdcfg1 */ |
| 89 | 0x01ff00db, /* mdcfg2 */ |
| 90 | 0x00001680, /* mdmisc */ |
| 91 | 0x0f3c8000, /* mdref */ |
| 92 | 0x00002000, /* mdrwd */ |
| 93 | 0x00bf1023, /* mdor */ |
| 94 | 0x0000003f, /* mdasp */ |
| 95 | 0x0000022a, /* mpodtctrl */ |
| 96 | 0xa1390003, /* mpzqhwctrl */ |
| 97 | }; |
| 98 | |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 99 | #ifdef CONFIG_TARGET_LS1012AFRWY |
| 100 | board_rev = get_board_version(); |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 101 | |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 102 | if (board_rev & BOARD_REV_B) { |
| 103 | mparam.mdctl = 0x05180000; |
| 104 | gd->ram_size = SYS_SDRAM_SIZE_1024; |
| 105 | } else { |
| 106 | gd->ram_size = SYS_SDRAM_SIZE_512; |
| 107 | } |
| 108 | #else |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 109 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
Bhaskar Upadhaya | 5e6f598 | 2018-05-23 11:03:30 +0530 | [diff] [blame^] | 110 | #endif |
| 111 | mmdc_init(&mparam); |
| 112 | |
York Sun | 729f2d1 | 2017-03-06 09:02:34 -0800 | [diff] [blame] | 113 | #if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD) |
| 114 | /* This will break-before-make MMU for DDR */ |
| 115 | update_early_mmu_table(); |
| 116 | #endif |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 117 | |
| 118 | return 0; |
| 119 | } |
| 120 | |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 121 | int board_early_init_f(void) |
| 122 | { |
| 123 | fsl_lsch2_early_init_f(); |
| 124 | |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | int board_init(void) |
| 129 | { |
Ashish Kumar | 1123406 | 2017-08-11 11:09:14 +0530 | [diff] [blame] | 130 | struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR + |
| 131 | CONFIG_SYS_CCI400_OFFSET); |
| 132 | |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 133 | /* |
| 134 | * Set CCI-400 control override register to enable barrier |
| 135 | * transaction |
| 136 | */ |
| 137 | out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER); |
| 138 | |
| 139 | #ifdef CONFIG_ENV_IS_NOWHERE |
| 140 | gd->env_addr = (ulong)&default_environment[0]; |
| 141 | #endif |
| 142 | |
Prabhakar Kushwaha | 74d129b | 2017-01-30 17:05:35 +0530 | [diff] [blame] | 143 | #ifdef CONFIG_FSL_LS_PPA |
| 144 | ppa_init(); |
| 145 | #endif |
Prabhakar Kushwaha | 9e7ee7b | 2016-06-03 18:41:36 +0530 | [diff] [blame] | 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | int ft_board_setup(void *blob, bd_t *bd) |
| 150 | { |
| 151 | arch_fixup_fdt(blob); |
| 152 | |
| 153 | ft_cpu_setup(blob, bd); |
| 154 | |
| 155 | return 0; |
| 156 | } |