Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Patrice Chotard | 5cc16d8 | 2017-02-21 13:37:12 +0100 | [diff] [blame] | 2 | /* |
Patrice Chotard | fb48bc4 | 2017-10-23 09:53:57 +0200 | [diff] [blame] | 3 | * Copyright (C) 2017, STMicroelectronics - All Rights Reserved |
Patrice Chotard | 0f8106f | 2020-12-02 18:47:30 +0100 | [diff] [blame] | 4 | * Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics. |
Patrice Chotard | 5cc16d8 | 2017-02-21 13:37:12 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Simon Glass | 9edefc2 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 7 | #include <cpu_func.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 9 | #include <asm/cache.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Patrice Chotard | 4e6eeea | 2017-09-05 11:04:27 +0200 | [diff] [blame] | 11 | #include <linux/usb/otg.h> |
| 12 | #include <dwc3-sti-glue.h> |
| 13 | #include <dwc3-uboot.h> |
| 14 | #include <usb.h> |
Patrice Chotard | 5cc16d8 | 2017-02-21 13:37:12 +0100 | [diff] [blame] | 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
| 18 | int dram_init(void) |
| 19 | { |
| 20 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
| 21 | return 0; |
| 22 | } |
| 23 | |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 24 | int dram_init_banksize(void) |
Patrice Chotard | 5cc16d8 | 2017-02-21 13:37:12 +0100 | [diff] [blame] | 25 | { |
| 26 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 27 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 28 | |
| 29 | return 0; |
Patrice Chotard | 5cc16d8 | 2017-02-21 13:37:12 +0100 | [diff] [blame] | 30 | } |
| 31 | |
Trevor Woerner | 1001502 | 2019-05-03 09:41:00 -0400 | [diff] [blame] | 32 | #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) |
Patrice Chotard | 4c4da9f | 2017-03-20 15:21:36 +0100 | [diff] [blame] | 33 | void enable_caches(void) |
| 34 | { |
| 35 | /* Enable D-cache. I-cache is already enabled in start.S */ |
| 36 | dcache_enable(); |
| 37 | } |
| 38 | #endif |
| 39 | |
Patrice Chotard | 5cc16d8 | 2017-02-21 13:37:12 +0100 | [diff] [blame] | 40 | int board_init(void) |
| 41 | { |
| 42 | return 0; |
| 43 | } |
Patrice Chotard | 4e6eeea | 2017-09-05 11:04:27 +0200 | [diff] [blame] | 44 | |
| 45 | #ifdef CONFIG_USB_DWC3 |
| 46 | static struct dwc3_device dwc3_device_data = { |
| 47 | .maximum_speed = USB_SPEED_HIGH, |
| 48 | .dr_mode = USB_DR_MODE_PERIPHERAL, |
| 49 | .index = 0, |
| 50 | }; |
| 51 | |
Patrice Chotard | 4e6eeea | 2017-09-05 11:04:27 +0200 | [diff] [blame] | 52 | int board_usb_init(int index, enum usb_init_type init) |
| 53 | { |
| 54 | int node; |
| 55 | const void *blob = gd->fdt_blob; |
| 56 | |
| 57 | /* find the snps,dwc3 node */ |
| 58 | node = fdt_node_offset_by_compatible(blob, -1, "snps,dwc3"); |
| 59 | |
| 60 | dwc3_device_data.base = fdtdec_get_addr(blob, node, "reg"); |
| 61 | |
| 62 | return dwc3_uboot_init(&dwc3_device_data); |
| 63 | } |
| 64 | |
| 65 | int board_usb_cleanup(int index, enum usb_init_type init) |
| 66 | { |
| 67 | dwc3_uboot_exit(index); |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | int g_dnl_board_usb_cable_connected(void) |
| 72 | { |
| 73 | return 1; |
| 74 | } |
| 75 | #endif |