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