Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2007-2008 |
Stelian Pop | 5ee0c7f | 2011-11-01 00:00:39 +0100 | [diff] [blame] | 4 | * Stelian Pop <stelian@popies.net> |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 5 | * Lead Tech Design <www.leadtechdesign.com> |
| 6 | * Copyright (C) 2008 Ronetix Ilko Iliev (www.ronetix.at) |
| 7 | * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 10 | #include <config.h> |
Simon Glass | 8e16b1e | 2019-12-28 10:45:05 -0700 | [diff] [blame] | 11 | #include <init.h> |
Simon Glass | c3b8e3a | 2024-08-21 10:18:59 -0600 | [diff] [blame] | 12 | #include <video.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Alexey Brodkin | 267d8e2 | 2014-02-26 17:47:58 +0400 | [diff] [blame] | 14 | #include <linux/sizes.h> |
Asen Dimov | e1002e2 | 2011-06-08 22:01:16 +0000 | [diff] [blame] | 15 | #include <asm/io.h> |
Andreas Bießmann | a4c24d3 | 2013-11-29 12:13:45 +0100 | [diff] [blame] | 16 | #include <asm/gpio.h> |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 17 | #include <asm/arch/at91sam9_smc.h> |
| 18 | #include <asm/arch/at91_common.h> |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 19 | #include <asm/arch/at91_rstc.h> |
Asen Dimov | e7480ad | 2010-04-19 14:18:43 +0300 | [diff] [blame] | 20 | #include <asm/arch/at91_matrix.h> |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 21 | #include <asm/arch/clk.h> |
Asen Dimov | e1002e2 | 2011-06-08 22:01:16 +0000 | [diff] [blame] | 22 | #include <asm/arch/gpio.h> |
Simon Glass | 0ffb9d6 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 23 | #include <asm/mach-types.h> |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 24 | |
| 25 | DECLARE_GLOBAL_DATA_PTR; |
| 26 | |
| 27 | /* ------------------------------------------------------------------------- */ |
| 28 | /* |
Ilko Iliev | a0fe318 | 2021-04-23 15:41:34 +0200 | [diff] [blame] | 29 | * Miscellaneous platform dependent initializations |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 30 | */ |
| 31 | |
| 32 | #ifdef CONFIG_CMD_NAND |
| 33 | static void pm9263_nand_hw_init(void) |
| 34 | { |
| 35 | unsigned long csa; |
Asen Dimov | e1002e2 | 2011-06-08 22:01:16 +0000 | [diff] [blame] | 36 | struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC0; |
| 37 | struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX; |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 38 | |
| 39 | /* Enable CS3 */ |
Asen Dimov | e7480ad | 2010-04-19 14:18:43 +0300 | [diff] [blame] | 40 | csa = readl(&matrix->csa[0]) | AT91_MATRIX_CSA_EBI_CS3A; |
| 41 | writel(csa, &matrix->csa[0]); |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 42 | |
| 43 | /* Configure SMC CS3 for NAND/SmartMedia */ |
Asen Dimov | e7480ad | 2010-04-19 14:18:43 +0300 | [diff] [blame] | 44 | writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(1) | |
| 45 | AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(1), |
| 46 | &smc->cs[3].setup); |
| 47 | |
| 48 | writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) | |
| 49 | AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3), |
| 50 | &smc->cs[3].pulse); |
| 51 | |
| 52 | writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5), |
| 53 | &smc->cs[3].cycle); |
| 54 | |
| 55 | writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE | |
| 56 | AT91_SMC_MODE_EXNW_DISABLE | |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 57 | #ifdef CONFIG_SYS_NAND_DBW_16 |
Asen Dimov | e7480ad | 2010-04-19 14:18:43 +0300 | [diff] [blame] | 58 | AT91_SMC_MODE_DBW_16 | |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 59 | #else /* CONFIG_SYS_NAND_DBW_8 */ |
Asen Dimov | e7480ad | 2010-04-19 14:18:43 +0300 | [diff] [blame] | 60 | AT91_SMC_MODE_DBW_8 | |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 61 | #endif |
Asen Dimov | e7480ad | 2010-04-19 14:18:43 +0300 | [diff] [blame] | 62 | AT91_SMC_MODE_TDF_CYCLE(2), |
| 63 | &smc->cs[3].mode); |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 64 | |
| 65 | /* Configure RDY/BSY */ |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 66 | gpio_direction_input(CFG_SYS_NAND_READY_PIN); |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 67 | |
| 68 | /* Enable NandFlash */ |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 69 | gpio_direction_output(CFG_SYS_NAND_ENABLE_PIN, 1); |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 70 | } |
| 71 | #endif |
| 72 | |
Asen Dimov | bd0f023 | 2011-12-09 10:56:55 +0000 | [diff] [blame] | 73 | int board_early_init_f(void) |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 74 | { |
Asen Dimov | bd0f023 | 2011-12-09 10:56:55 +0000 | [diff] [blame] | 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | int board_init(void) |
| 79 | { |
Ilko Iliev | a0fe318 | 2021-04-23 15:41:34 +0200 | [diff] [blame] | 80 | /* arch number of PM9263 Board */ |
Asen Dimov | bd0f023 | 2011-12-09 10:56:55 +0000 | [diff] [blame] | 81 | gd->bd->bi_arch_number = MACH_TYPE_PM9263; |
| 82 | |
Ilko Iliev | a0fe318 | 2021-04-23 15:41:34 +0200 | [diff] [blame] | 83 | /* address of boot parameters */ |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 84 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 85 | |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 86 | #ifdef CONFIG_CMD_NAND |
| 87 | pm9263_nand_hw_init(); |
| 88 | #endif |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 89 | #ifdef CONFIG_USB_OHCI_NEW |
| 90 | at91_uhp_hw_init(); |
| 91 | #endif |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | int dram_init(void) |
| 96 | { |
Ilko Iliev | a0fe318 | 2021-04-23 15:41:34 +0200 | [diff] [blame] | 97 | /* dram_init must store complete RAM size in gd->ram_size */ |
Albert ARIBAUD | a960673 | 2011-07-03 05:55:33 +0000 | [diff] [blame] | 98 | gd->ram_size = get_ram_size((void *)PHYS_SDRAM, |
Asen Dimov | 84ea97c | 2010-12-12 12:41:59 +0200 | [diff] [blame] | 99 | PHYS_SDRAM_SIZE); |
| 100 | return 0; |
| 101 | } |
| 102 | |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 103 | int dram_init_banksize(void) |
Asen Dimov | 84ea97c | 2010-12-12 12:41:59 +0200 | [diff] [blame] | 104 | { |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 105 | gd->bd->bi_dram[0].start = PHYS_SDRAM; |
| 106 | gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE; |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 107 | |
| 108 | return 0; |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 109 | } |
| 110 | |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 111 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 112 | int checkboard (void) |
| 113 | { |
Simon Glass | c3b8e3a | 2024-08-21 10:18:59 -0600 | [diff] [blame] | 114 | ulong fb_base = video_get_fb(); |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 115 | char *ss; |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 116 | |
| 117 | printf ("Board : Ronetix PM9263\n"); |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 118 | |
Simon Glass | c3b8e3a | 2024-08-21 10:18:59 -0600 | [diff] [blame] | 119 | switch (fb_base) { |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 120 | case PHYS_PSRAM: |
| 121 | ss = "(PSRAM)"; |
| 122 | break; |
| 123 | |
Asen Dimov | e1002e2 | 2011-06-08 22:01:16 +0000 | [diff] [blame] | 124 | case ATMEL_BASE_SRAM0: |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 125 | ss = "(Internal SRAM)"; |
| 126 | break; |
| 127 | |
| 128 | default: |
| 129 | ss = ""; |
| 130 | break; |
| 131 | } |
Simon Glass | c3b8e3a | 2024-08-21 10:18:59 -0600 | [diff] [blame] | 132 | printf("Video memory : 0x%08lX %s\n", fb_base, ss); |
Ilko Iliev | 8b954a9 | 2009-04-16 21:30:48 +0200 | [diff] [blame] | 133 | |
| 134 | printf ("\n"); |
| 135 | return 0; |
| 136 | } |
| 137 | #endif |