Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Maintainer : |
| 4 | * Tapani Utriainen <linuxfae@technexion.com> |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 5 | */ |
| 6 | #include <common.h> |
Simon Glass | 52f2423 | 2020-05-10 11:40:00 -0600 | [diff] [blame] | 7 | #include <bootstage.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Simon Glass | 336d461 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 9 | #include <malloc.h> |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 10 | #include <netdev.h> |
| 11 | #include <twl4030.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 12 | #include <asm/global_data.h> |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 13 | #include <asm/io.h> |
| 14 | #include <asm/arch/mmc_host_def.h> |
| 15 | #include <asm/arch/mem.h> |
| 16 | #include <asm/arch/mux.h> |
| 17 | #include <asm/arch/sys_proto.h> |
| 18 | #include <asm/arch/gpio.h> |
| 19 | #include <asm/gpio.h> |
| 20 | #include <asm/mach-types.h> |
| 21 | |
| 22 | #include <usb.h> |
| 23 | #include <asm/ehci-omap.h> |
| 24 | |
| 25 | #include "tao3530.h" |
| 26 | |
| 27 | DECLARE_GLOBAL_DATA_PTR; |
| 28 | |
| 29 | int tao3530_revision(void) |
| 30 | { |
| 31 | int ret = 0; |
| 32 | |
| 33 | /* char *label argument is unused in gpio_request() */ |
| 34 | ret = gpio_request(65, ""); |
| 35 | if (ret) { |
| 36 | puts("Error: GPIO 65 not available\n"); |
| 37 | goto out; |
| 38 | } |
| 39 | MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M4)); |
| 40 | |
| 41 | ret = gpio_request(1, ""); |
| 42 | if (ret) { |
| 43 | puts("Error: GPIO 1 not available\n"); |
| 44 | goto out2; |
| 45 | } |
| 46 | MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M4)); |
| 47 | |
| 48 | ret = gpio_direction_input(65); |
| 49 | if (ret) { |
| 50 | puts("Error: GPIO 65 not available for input\n"); |
| 51 | goto out3; |
| 52 | } |
| 53 | |
| 54 | ret = gpio_direction_input(1); |
| 55 | if (ret) { |
| 56 | puts("Error: GPIO 1 not available for input\n"); |
| 57 | goto out3; |
| 58 | } |
| 59 | |
| 60 | ret = gpio_get_value(65) << 1 | gpio_get_value(1); |
| 61 | |
| 62 | out3: |
| 63 | MUX_VAL(CP(SYS_CLKREQ), (IEN | PTU | EN | M0)); |
| 64 | gpio_free(1); |
| 65 | out2: |
| 66 | MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M0)); |
| 67 | gpio_free(65); |
| 68 | out: |
| 69 | |
| 70 | return ret; |
| 71 | } |
| 72 | |
Stefan Roese | a9f5249 | 2013-12-04 09:27:34 +0100 | [diff] [blame] | 73 | #ifdef CONFIG_SPL_BUILD |
| 74 | /* |
| 75 | * Routine: get_board_mem_timings |
| 76 | * Description: If we use SPL then there is no x-loader nor config header |
| 77 | * so we have to setup the DDR timings ourself on both banks. |
| 78 | */ |
| 79 | void get_board_mem_timings(struct board_sdrc_timings *timings) |
| 80 | { |
Stefan Roese | 8f0cbd6 | 2013-12-04 09:27:37 +0100 | [diff] [blame] | 81 | #if defined(CONFIG_SYS_BOARD_OMAP3_HA) |
| 82 | /* |
| 83 | * Switch baseboard LED to red upon power-on |
| 84 | */ |
| 85 | MUX_OMAP3_HA(); |
| 86 | |
| 87 | /* Request a gpio before using it */ |
| 88 | gpio_request(111, ""); |
| 89 | /* Sets the gpio as output and its value to 1, switch LED to red */ |
| 90 | gpio_direction_output(111, 1); |
| 91 | #endif |
| 92 | |
Stefan Roese | a9f5249 | 2013-12-04 09:27:34 +0100 | [diff] [blame] | 93 | if (tao3530_revision() < 3) { |
| 94 | /* 256MB / Bank */ |
| 95 | timings->mcfg = MCFG(256 << 20, 14); /* RAS-width 14 */ |
| 96 | timings->ctrla = HYNIX_V_ACTIMA_165; |
| 97 | timings->ctrlb = HYNIX_V_ACTIMB_165; |
| 98 | } else { |
| 99 | /* 128MB / Bank */ |
| 100 | timings->mcfg = MCFG(128 << 20, 13); /* RAS-width 13 */ |
| 101 | timings->ctrla = MICRON_V_ACTIMA_165; |
| 102 | timings->ctrlb = MICRON_V_ACTIMB_165; |
| 103 | } |
| 104 | |
| 105 | timings->mr = MICRON_V_MR_165; |
| 106 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
| 107 | } |
| 108 | #endif |
| 109 | |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 110 | /* |
| 111 | * Routine: board_init |
| 112 | * Description: Early hardware init. |
| 113 | */ |
| 114 | int board_init(void) |
| 115 | { |
| 116 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 117 | /* board id for Linux */ |
| 118 | gd->bd->bi_arch_number = MACH_TYPE_OMAP3_TAO3530; |
| 119 | /* boot param addr */ |
| 120 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 121 | |
| 122 | return 0; |
| 123 | } |
| 124 | |
| 125 | /* |
| 126 | * Routine: misc_init_r |
| 127 | * Description: Configure board specific parts |
| 128 | */ |
| 129 | int misc_init_r(void) |
| 130 | { |
| 131 | struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; |
| 132 | struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; |
| 133 | |
| 134 | twl4030_power_init(); |
| 135 | twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); |
| 136 | |
| 137 | /* Configure GPIOs to output */ |
| 138 | /* GPIO23 */ |
| 139 | writel(~(GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe); |
| 140 | writel(~(GPIO31 | GPIO30 | GPIO22 | GPIO21 | |
| 141 | GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe); |
| 142 | |
| 143 | /* Set GPIOs */ |
| 144 | writel(GPIO10 | GPIO8 | GPIO2 | GPIO1, |
| 145 | &gpio6_base->setdataout); |
| 146 | writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | |
| 147 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); |
| 148 | |
Stefan Roese | fcd9adc | 2013-12-04 09:27:36 +0100 | [diff] [blame] | 149 | switch (tao3530_revision()) { |
| 150 | case 0: |
| 151 | puts("TAO-3530 REV Reserve 1\n"); |
| 152 | break; |
| 153 | case 1: |
| 154 | puts("TAO-3530 REV Reserve 2\n"); |
| 155 | break; |
| 156 | case 2: |
| 157 | puts("TAO-3530 REV Cx\n"); |
| 158 | break; |
| 159 | case 3: |
| 160 | puts("TAO-3530 REV Ax/Bx\n"); |
| 161 | break; |
| 162 | default: |
| 163 | puts("Unknown board revision\n"); |
| 164 | } |
| 165 | |
Paul Kocialkowski | 679f82c | 2015-08-27 19:37:13 +0200 | [diff] [blame] | 166 | omap_die_id_display(); |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 167 | |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | /* |
| 172 | * Routine: set_muxconf_regs |
| 173 | * Description: Setting up the configuration Mux registers specific to the |
| 174 | * hardware. Many pins need to be moved from protect to primary |
| 175 | * mode. |
| 176 | */ |
| 177 | void set_muxconf_regs(void) |
| 178 | { |
| 179 | MUX_TAO3530(); |
Stefan Roese | 8f0cbd6 | 2013-12-04 09:27:37 +0100 | [diff] [blame] | 180 | #if defined(CONFIG_SYS_BOARD_OMAP3_HA) |
| 181 | MUX_OMAP3_HA(); |
| 182 | #endif |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 183 | } |
| 184 | |
Masahiro Yamada | 4aa2ba3 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 185 | #if defined(CONFIG_MMC) |
Masahiro Yamada | b75d8dc | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 186 | int board_mmc_init(struct bd_info *bis) |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 187 | { |
| 188 | omap_mmc_init(0, 0, 0, -1, -1); |
| 189 | |
| 190 | return 0; |
| 191 | } |
| 192 | #endif |
| 193 | |
Masahiro Yamada | 4aa2ba3 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 194 | #if defined(CONFIG_MMC) |
Paul Kocialkowski | aac5450 | 2014-11-08 20:55:47 +0100 | [diff] [blame] | 195 | void board_mmc_power_init(void) |
| 196 | { |
| 197 | twl4030_power_mmc_init(0); |
| 198 | } |
| 199 | #endif |
| 200 | |
Tom Rini | 8850c5d | 2017-05-12 22:33:27 -0400 | [diff] [blame] | 201 | #if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD) |
Tapani Utriainen | 550e375 | 2013-12-04 09:27:33 +0100 | [diff] [blame] | 202 | /* Call usb_stop() before starting the kernel */ |
| 203 | void show_boot_progress(int val) |
| 204 | { |
| 205 | if (val == BOOTSTAGE_ID_RUN_OS) |
| 206 | usb_stop(); |
| 207 | } |
| 208 | |
| 209 | static struct omap_usbhs_board_data usbhs_bdata = { |
| 210 | .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED, |
| 211 | .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, |
| 212 | .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED |
| 213 | }; |
| 214 | |
| 215 | int ehci_hcd_init(int index, enum usb_init_type init, |
| 216 | struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
| 217 | { |
| 218 | return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor); |
| 219 | } |
| 220 | |
| 221 | int ehci_hcd_stop(int index) |
| 222 | { |
| 223 | return omap_ehci_hcd_stop(); |
| 224 | } |
Tom Rini | 8850c5d | 2017-05-12 22:33:27 -0400 | [diff] [blame] | 225 | #endif /* CONFIG_USB_EHCI_HCD */ |