blob: e21cbc270e99c298deacd05431a1eb679a4a3509 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Patrice Chotard5cc16d82017-02-21 13:37:12 +01002/*
Patrice Chotardfb48bc42017-10-23 09:53:57 +02003 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
Patrice Chotard0f8106f2020-12-02 18:47:30 +01004 * Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics.
Patrice Chotard5cc16d82017-02-21 13:37:12 +01005 */
6
7#include <common.h>
Simon Glass9edefc22019-11-14 12:57:37 -07008#include <cpu_func.h>
Simon Glass691d7192020-05-10 11:40:02 -06009#include <init.h>
Simon Glass90526e92020-05-10 11:39:56 -060010#include <asm/cache.h>
Simon Glass401d1c42020-10-30 21:38:53 -060011#include <asm/global_data.h>
Patrice Chotard4e6eeea2017-09-05 11:04:27 +020012#include <linux/usb/otg.h>
13#include <dwc3-sti-glue.h>
14#include <dwc3-uboot.h>
15#include <usb.h>
Patrice Chotard5cc16d82017-02-21 13:37:12 +010016
17DECLARE_GLOBAL_DATA_PTR;
18
19int dram_init(void)
20{
21 gd->ram_size = PHYS_SDRAM_1_SIZE;
22 return 0;
23}
24
Simon Glass76b00ac2017-03-31 08:40:32 -060025int dram_init_banksize(void)
Patrice Chotard5cc16d82017-02-21 13:37:12 +010026{
27 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
28 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
Simon Glass76b00ac2017-03-31 08:40:32 -060029
30 return 0;
Patrice Chotard5cc16d82017-02-21 13:37:12 +010031}
32
Trevor Woerner10015022019-05-03 09:41:00 -040033#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
Patrice Chotard4c4da9f2017-03-20 15:21:36 +010034void enable_caches(void)
35{
36 /* Enable D-cache. I-cache is already enabled in start.S */
37 dcache_enable();
38}
39#endif
40
Patrice Chotard5cc16d82017-02-21 13:37:12 +010041int board_init(void)
42{
43 return 0;
44}
Patrice Chotard4e6eeea2017-09-05 11:04:27 +020045
46#ifdef CONFIG_USB_DWC3
47static struct dwc3_device dwc3_device_data = {
48 .maximum_speed = USB_SPEED_HIGH,
49 .dr_mode = USB_DR_MODE_PERIPHERAL,
50 .index = 0,
51};
52
Marek Vasut2caf9742023-09-01 11:50:03 +020053int dm_usb_gadget_handle_interrupts(struct udevice *dev)
Patrice Chotard4e6eeea2017-09-05 11:04:27 +020054{
Marek Vasut2caf9742023-09-01 11:50:03 +020055 dwc3_uboot_handle_interrupt(dev);
Patrice Chotard4e6eeea2017-09-05 11:04:27 +020056 return 0;
57}
58
59int 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
72int board_usb_cleanup(int index, enum usb_init_type init)
73{
74 dwc3_uboot_exit(index);
75 return 0;
76}
77
78int g_dnl_board_usb_cable_connected(void)
79{
80 return 1;
81}
82#endif