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