blob: b1147f2e1a7006cfefbd19026b9d6511c5be743b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Patrice Chotard2f329792017-02-21 13:37:12 +01002/*
Patrice Chotard9e216242017-10-23 09:53:57 +02003 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
4 * Author(s): Patrice Chotard, <patrice.chotard@st.com> for STMicroelectronics.
Patrice Chotard2f329792017-02-21 13:37:12 +01005 */
6
7#include <common.h>
Simon Glass1d91ba72019-11-14 12:57:37 -07008#include <cpu_func.h>
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060010#include <asm/cache.h>
Patrice Chotardaecc94c2017-09-05 11:04:27 +020011#include <linux/usb/otg.h>
12#include <dwc3-sti-glue.h>
13#include <dwc3-uboot.h>
14#include <usb.h>
Patrice Chotard2f329792017-02-21 13:37:12 +010015
16DECLARE_GLOBAL_DATA_PTR;
17
18int dram_init(void)
19{
20 gd->ram_size = PHYS_SDRAM_1_SIZE;
21 return 0;
22}
23
Simon Glass2f949c32017-03-31 08:40:32 -060024int dram_init_banksize(void)
Patrice Chotard2f329792017-02-21 13:37:12 +010025{
26 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
27 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
Simon Glass2f949c32017-03-31 08:40:32 -060028
29 return 0;
Patrice Chotard2f329792017-02-21 13:37:12 +010030}
31
Trevor Woerner43ec7e02019-05-03 09:41:00 -040032#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
Patrice Chotard411b3fc2017-03-20 15:21:36 +010033void enable_caches(void)
34{
35 /* Enable D-cache. I-cache is already enabled in start.S */
36 dcache_enable();
37}
38#endif
39
Patrice Chotard2f329792017-02-21 13:37:12 +010040int board_init(void)
41{
42 return 0;
43}
Patrice Chotardaecc94c2017-09-05 11:04:27 +020044
45#ifdef CONFIG_USB_DWC3
46static struct dwc3_device dwc3_device_data = {
47 .maximum_speed = USB_SPEED_HIGH,
48 .dr_mode = USB_DR_MODE_PERIPHERAL,
49 .index = 0,
50};
51
52int usb_gadget_handle_interrupts(int index)
53{
54 dwc3_uboot_handle_interrupt(index);
55 return 0;
56}
57
58int board_usb_init(int index, enum usb_init_type init)
59{
60 int node;
61 const void *blob = gd->fdt_blob;
62
63 /* find the snps,dwc3 node */
64 node = fdt_node_offset_by_compatible(blob, -1, "snps,dwc3");
65
66 dwc3_device_data.base = fdtdec_get_addr(blob, node, "reg");
67
68 return dwc3_uboot_init(&dwc3_device_data);
69}
70
71int board_usb_cleanup(int index, enum usb_init_type init)
72{
73 dwc3_uboot_exit(index);
74 return 0;
75}
76
77int g_dnl_board_usb_cable_connected(void)
78{
79 return 1;
80}
81#endif