Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bob Ham
uboot-imx
Commits
4e55d89c
Commit
4e55d89c
authored
Oct 17, 2018
by
Angus Ainslie (Purism)
Browse files
board/emcraft : mve the board_usb_init to the SPL for SDP
parent
18a4f806
Changes
3
Hide whitespace changes
Inline
Side-by-side
board/emcraft/imx8m_som/imx8m_som.c
View file @
4e55d89c
...
...
@@ -145,12 +145,143 @@ int board_phy_config(struct phy_device *phydev)
#endif
#ifdef CONFIG_USB_DWC3
#if 0
#define USB_PHY_CTRL0 0xF0040
#define USB_PHY_CTRL0_REF_SSP_EN BIT(2)
#define USB_PHY_CTRL1 0xF0044
#define USB_PHY_CTRL1_RESET BIT(0)
#define USB_PHY_CTRL1_COMMONONN BIT(1)
#define USB_PHY_CTRL1_ATERESET BIT(3)
#define USB_PHY_CTRL1_VDATSRCENB0 BIT(19)
#define USB_PHY_CTRL1_VDATDETENB0 BIT(20)
#define USB_PHY_CTRL2 0xF0048
#define USB_PHY_CTRL2_TXENABLEN0 BIT(8)
static struct dwc3_device dwc3_device_data = {
.maximum_speed = USB_SPEED_SUPER,
.base = USB1_BASE_ADDR,
.dr_mode = USB_DR_MODE_PERIPHERAL,
.index = 0,
.power_down_scale = 2,
};
static void dwc3_nxp_usb_phy_init(struct dwc3_device *dwc3)
{
u32 RegData;
RegData = readl(dwc3->base + USB_PHY_CTRL1);
RegData &= ~(USB_PHY_CTRL1_VDATSRCENB0 | USB_PHY_CTRL1_VDATDETENB0 |
USB_PHY_CTRL1_COMMONONN);
RegData |= USB_PHY_CTRL1_RESET | USB_PHY_CTRL1_ATERESET;
writel(RegData, dwc3->base + USB_PHY_CTRL1);
RegData = readl(dwc3->base + USB_PHY_CTRL0);
RegData |= USB_PHY_CTRL0_REF_SSP_EN;
writel(RegData, dwc3->base + USB_PHY_CTRL0);
RegData = readl(dwc3->base + USB_PHY_CTRL2);
RegData |= USB_PHY_CTRL2_TXENABLEN0;
writel(RegData, dwc3->base + USB_PHY_CTRL2);
RegData = readl(dwc3->base + USB_PHY_CTRL1);
RegData &= ~(USB_PHY_CTRL1_RESET | USB_PHY_CTRL1_ATERESET);
writel(RegData, dwc3->base + USB_PHY_CTRL1);
}
#endif
#endif
int
usb_gadget_handle_interrupts
(
void
)
{
dwc3_uboot_handle_interrupt
(
0
);
return
0
;
}
#if 0
#ifdef CONFIG_USB_TCPC
struct tcpc_port port;
struct tcpc_port_config port_config = {
.i2c_bus = 0,
.addr = 0x50,
.port_type = TYPEC_PORT_UFP,
.max_snk_mv = 20000,
.max_snk_ma = 3000,
.max_snk_mw = 15000,
.op_snk_mv = 9000,
};
#define USB_TYPEC_SEL IMX_GPIO_NR(3, 15)
static iomux_v3_cfg_t ss_mux_gpio[] = {
IMX8MQ_PAD_NAND_RE_B__GPIO3_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL),
};
void ss_mux_select(enum typec_cc_polarity pol)
{
if (pol == TYPEC_POLARITY_CC1)
gpio_direction_output(USB_TYPEC_SEL, 1);
else
gpio_direction_output(USB_TYPEC_SEL, 0);
}
static int setup_typec(void)
{
int ret;
imx_iomux_v3_setup_multiple_pads(ss_mux_gpio, ARRAY_SIZE(ss_mux_gpio));
gpio_request(USB_TYPEC_SEL, "typec_sel");
ret = tcpc_init(&port, port_config, &ss_mux_select);
if (ret) {
printf("%s: tcpc init failed, err=%d\n",
__func__, ret);
}
return ret;
}
#endif
#if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_IMX8M)
int board_usb_init(int index, enum usb_init_type init)
{
int ret = 0;
imx8m_usb_power(index, true);
if (index == 0 && init == USB_INIT_DEVICE) {
#ifdef CONFIG_USB_TCPC
ret = tcpc_setup_ufp_mode(&port);
#endif
dwc3_nxp_usb_phy_init(&dwc3_device_data);
return dwc3_uboot_init(&dwc3_device_data);
} else if (index == 0 && init == USB_INIT_HOST) {
#ifdef CONFIG_USB_TCPC
ret = tcpc_setup_dfp_mode(&port);
#endif
return ret;
}
return 0;
}
int board_usb_cleanup(int index, enum usb_init_type init)
{
int ret = 0;
if (index == 0 && init == USB_INIT_DEVICE) {
dwc3_uboot_exit(index);
} else if (index == 0 && init == USB_INIT_HOST) {
#ifdef CONFIG_USB_TCPC
ret = tcpc_disable_src_vbus(&port);
#endif
}
imx8m_usb_power(index, false);
return ret;
}
#endif
#endif
int
board_init
(
void
)
{
...
...
@@ -160,6 +291,10 @@ int board_init(void)
setup_fec
();
#endif
#ifdef CONFIG_USB_TCPC
setup_typec
();
#endif
return
0
;
return
0
;
}
...
...
board/emcraft/imx8m_som/spl.c
View file @
4e55d89c
...
...
@@ -312,8 +312,50 @@ int board_fit_config_name_match(const char *name)
}
#endif
#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
#ifdef CONFIG_USB_TCPC
struct
tcpc_port
port
;
struct
tcpc_port_config
port_config
=
{
.
i2c_bus
=
0
,
.
addr
=
0x50
,
.
port_type
=
TYPEC_PORT_UFP
,
.
max_snk_mv
=
20000
,
.
max_snk_ma
=
3000
,
.
max_snk_mw
=
15000
,
.
op_snk_mv
=
9000
,
};
#define USB_TYPEC_SEL IMX_GPIO_NR(3, 15)
static
iomux_v3_cfg_t
ss_mux_gpio
[]
=
{
IMX8MQ_PAD_NAND_RE_B__GPIO3_IO15
|
MUX_PAD_CTRL
(
NO_PAD_CTRL
),
};
void
ss_mux_select
(
enum
typec_cc_polarity
pol
)
{
if
(
pol
==
TYPEC_POLARITY_CC1
)
gpio_direction_output
(
USB_TYPEC_SEL
,
1
);
else
gpio_direction_output
(
USB_TYPEC_SEL
,
0
);
}
static
int
setup_typec
(
void
)
{
int
ret
;
imx_iomux_v3_setup_multiple_pads
(
ss_mux_gpio
,
ARRAY_SIZE
(
ss_mux_gpio
));
gpio_request
(
USB_TYPEC_SEL
,
"typec_sel"
);
ret
=
tcpc_init
(
&
port
,
port_config
,
&
ss_mux_select
);
if
(
ret
)
{
printf
(
"%s: tcpc init failed, err=%d
\n
"
,
__func__
,
ret
);
}
return
ret
;
}
#endif
#ifdef CONFIG_SPL_USB_GADGET_SUPPORT
static
struct
dwc3_device
dwc3_device_data
=
{
.
maximum_speed
=
USB_SPEED_SUPER
,
.
base
=
USB1_BASE_ADDR
,
...
...
@@ -335,11 +377,6 @@ static struct dwc3_device dwc3_device_data = {
#define USB_PHY_CTRL2 0xF0048
#define USB_PHY_CTRL2_TXENABLEN0 BIT(8)
int
board_usb_cleanup
(
int
index
,
enum
usb_init_type
init
)
{
dwc3_uboot_exit
(
index
);
return
0
;
}
#if 0
int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
{
...
...
@@ -348,6 +385,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
return 0;
}
#endif
static
void
dwc3_nxp_usb_phy_init
(
struct
dwc3_device
*
dwc3
)
{
u32
RegData
;
...
...
@@ -371,11 +409,45 @@ static void dwc3_nxp_usb_phy_init(struct dwc3_device *dwc3)
writel
(
RegData
,
dwc3
->
base
+
USB_PHY_CTRL1
);
}
#if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_IMX8M)
int
board_usb_init
(
int
index
,
enum
usb_init_type
init
)
{
dwc3_nxp_usb_phy_init
(
&
dwc3_device_data
);
return
dwc3_uboot_init
(
&
dwc3_device_data
);
int
ret
=
0
;
imx8m_usb_power
(
index
,
true
);
if
(
index
==
0
&&
init
==
USB_INIT_DEVICE
)
{
#ifdef CONFIG_USB_TCPC
ret
=
tcpc_setup_ufp_mode
(
&
port
);
#endif
dwc3_nxp_usb_phy_init
(
&
dwc3_device_data
);
return
dwc3_uboot_init
(
&
dwc3_device_data
);
}
else
if
(
index
==
0
&&
init
==
USB_INIT_HOST
)
{
#ifdef CONFIG_USB_TCPC
ret
=
tcpc_setup_dfp_mode
(
&
port
);
#endif
return
ret
;
}
return
0
;
}
int
board_usb_cleanup
(
int
index
,
enum
usb_init_type
init
)
{
int
ret
=
0
;
if
(
index
==
0
&&
init
==
USB_INIT_DEVICE
)
{
dwc3_uboot_exit
(
index
);
}
else
if
(
index
==
0
&&
init
==
USB_INIT_HOST
)
{
#ifdef CONFIG_USB_TCPC
ret
=
tcpc_disable_src_vbus
(
&
port
);
#endif
}
imx8m_usb_power
(
index
,
false
);
return
ret
;
}
#endif
#endif
void
board_init_f
(
ulong
dummy
)
...
...
@@ -404,6 +476,8 @@ void board_init_f(ulong dummy)
enable_tzc380
();
printf
(
"Initializing Charger
\n
"
);
/* Adjust pmic voltage VDD_DRAM to 1.0V for DRAM RUN >= 2400MHZ */
setup_i2c
(
0
,
CONFIG_SYS_I2C_SPEED
,
0x7f
,
&
i2c_pad_info1
);
...
...
@@ -411,9 +485,29 @@ void board_init_f(ulong dummy)
power_init_board
();
printf
(
"Initializing DDR
\n
"
);
/* DDR initialization */
spl_dram_init
();
#ifdef CONFIG_SYS_SPL_MALLOC_START
printf
(
"Initializing malloc region
\n
"
);
mem_malloc_init
(
CONFIG_SYS_SPL_MALLOC_START
,
CONFIG_SYS_SPL_MALLOC_SIZE
);
gd
->
flags
|=
GD_FLG_FULL_MALLOC_INIT
;
#endif
printf
(
"Initializing USB
\n
"
);
/* malloc region must be initialized before this */
if
(
board_usb_init
(
0
,
USB_INIT_DEVICE
))
printf
(
"board_usb_init - failed
\n
"
);
else
printf
(
"board_usb_init - passed
\n
"
);
printf
(
"Board init
\n
"
);
board_init_r
(
NULL
,
0
);
}
common/spl/spl.c
View file @
4e55d89c
...
...
@@ -287,7 +287,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
debug
(
">>spl:board_init_r()
\n
"
);
#if defined(CONFIG_SYS_SPL_MALLOC_START)
#if defined(CONFIG_SYS_SPL_MALLOC_START) && !defined(CONFIG_SPL_USB_SDP_SUPPORT)
/* for SDP in the SPL malloc need to be initialized before this */
mem_malloc_init
(
CONFIG_SYS_SPL_MALLOC_START
,
CONFIG_SYS_SPL_MALLOC_SIZE
);
gd
->
flags
|=
GD_FLG_FULL_MALLOC_INIT
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment