1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * board/renesas/ulcb/ulcb.c
4  *     This file is ULCB board support.
5  *
6  * Copyright (C) 2017 Renesas Electronics Corporation
7  */
8 
9 #include <asm/io.h>
10 #include <asm/arch/rcar-mstp.h>
11 #include <asm/arch/renesas.h>
12 #include <init.h>
13 
14 #define HSUSB_MSTP704		BIT(4)	/* HSUSB */
15 
16 /* HSUSB block registers */
17 #define HSUSB_REG_LPSTS			0xE6590102
18 #define HSUSB_REG_LPSTS_SUSPM_NORMAL	BIT(14)
19 #define HSUSB_REG_UGCTRL2		0xE6590184
20 #define HSUSB_REG_UGCTRL2_USB0SEL	0x30
21 #define HSUSB_REG_UGCTRL2_USB0SEL_EHCI	0x10
22 
board_init(void)23 int board_init(void)
24 {
25 	/* USB1 pull-up */
26 	setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN);
27 
28 	/* Configure the HSUSB block */
29 	mstp_clrbits_le32(SMSTPCR7, SMSTPCR7, HSUSB_MSTP704);
30 	/* Choice USB0SEL */
31 	clrsetbits_le32(HSUSB_REG_UGCTRL2, HSUSB_REG_UGCTRL2_USB0SEL,
32 			HSUSB_REG_UGCTRL2_USB0SEL_EHCI);
33 	/* low power status */
34 	setbits_le16(HSUSB_REG_LPSTS, HSUSB_REG_LPSTS_SUSPM_NORMAL);
35 
36 	return 0;
37 }
38 
39 #ifdef CONFIG_MULTI_DTB_FIT
board_fit_config_name_match(const char * name)40 int board_fit_config_name_match(const char *name)
41 {
42 	/* PRR driver is not available yet */
43 	u32 cpu_type = renesas_get_cpu_type();
44 
45 	if ((cpu_type == RENESAS_CPU_TYPE_R8A7795) &&
46 	    !strcmp(name, "r8a77951-ulcb"))
47 		return 0;
48 
49 	if ((cpu_type == RENESAS_CPU_TYPE_R8A7796) &&
50 	    !strcmp(name, "r8a77960-ulcb"))
51 		return 0;
52 
53 	if ((cpu_type == RENESAS_CPU_TYPE_R8A77965) &&
54 	    !strcmp(name, "r8a77965-ulcb"))
55 		return 0;
56 
57 	return -1;
58 }
59 #endif
60