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