]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
e525d34b NI |
2 | /* |
3 | * board/renesas/salvator-x/salvator-x.c | |
adf3057f | 4 | * This file is Salvator-X/Salvator-XS board support. |
e525d34b | 5 | * |
50fb0c45 | 6 | * Copyright (C) 2015-2017 Renesas Electronics Corporation |
e525d34b | 7 | * Copyright (C) 2015 Nobuhiro Iwamatsu <iwamatsu@nigauri.org> |
e525d34b NI |
8 | */ |
9 | ||
9a3b4ceb | 10 | #include <cpu_func.h> |
4d72caa5 | 11 | #include <image.h> |
691d719d | 12 | #include <init.h> |
e525d34b NI |
13 | #include <malloc.h> |
14 | #include <netdev.h> | |
15 | #include <dm.h> | |
401d1c4f | 16 | #include <asm/global_data.h> |
e525d34b NI |
17 | #include <dm/platform_data/serial_sh.h> |
18 | #include <asm/processor.h> | |
19 | #include <asm/mach-types.h> | |
20 | #include <asm/io.h> | |
cd93d625 | 21 | #include <linux/bitops.h> |
1221ce45 | 22 | #include <linux/errno.h> |
e525d34b NI |
23 | #include <asm/arch/sys_proto.h> |
24 | #include <asm/gpio.h> | |
25 | #include <asm/arch/gpio.h> | |
26 | #include <asm/arch/rmobile.h> | |
27 | #include <asm/arch/rcar-mstp.h> | |
28 | #include <i2c.h> | |
29 | #include <mmc.h> | |
30 | ||
31 | DECLARE_GLOBAL_DATA_PTR; | |
32 | ||
fe2e8ff9 | 33 | #define DVFS_MSTP926 BIT(26) |
afb19d65 | 34 | #define HSUSB_MSTP704 BIT(4) /* HSUSB */ |
50fb0c45 | 35 | |
e525d34b NI |
36 | int board_early_init_f(void) |
37 | { | |
55dabcc8 | 38 | #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY) && defined(CONFIG_SYS_I2C_SH) |
fe2e8ff9 | 39 | /* DVFS for reset */ |
cf97b221 | 40 | mstp_clrbits_le32(SMSTPCR9, SMSTPCR9, DVFS_MSTP926); |
fe2e8ff9 | 41 | #endif |
e525d34b NI |
42 | return 0; |
43 | } | |
44 | ||
afb19d65 MV |
45 | /* HSUSB block registers */ |
46 | #define HSUSB_REG_LPSTS 0xE6590102 | |
47 | #define HSUSB_REG_LPSTS_SUSPM_NORMAL BIT(14) | |
48 | #define HSUSB_REG_UGCTRL2 0xE6590184 | |
49 | #define HSUSB_REG_UGCTRL2_USB0SEL 0x30 | |
50 | #define HSUSB_REG_UGCTRL2_USB0SEL_EHCI 0x10 | |
51 | ||
e525d34b NI |
52 | int board_init(void) |
53 | { | |
d1018f5f MV |
54 | /* USB1 pull-up */ |
55 | setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN); | |
56 | ||
afb19d65 | 57 | /* Configure the HSUSB block */ |
cf97b221 | 58 | mstp_clrbits_le32(SMSTPCR7, SMSTPCR7, HSUSB_MSTP704); |
afb19d65 MV |
59 | /* Choice USB0SEL */ |
60 | clrsetbits_le32(HSUSB_REG_UGCTRL2, HSUSB_REG_UGCTRL2_USB0SEL, | |
61 | HSUSB_REG_UGCTRL2_USB0SEL_EHCI); | |
62 | /* low power status */ | |
63 | setbits_le16(HSUSB_REG_LPSTS, HSUSB_REG_LPSTS_SUSPM_NORMAL); | |
64 | ||
ddb39a07 | 65 | return 0; |
50fb0c45 | 66 | } |
50fb0c45 | 67 | |
a4fc6ee9 | 68 | #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY) && defined(CONFIG_SYS_I2C_SH) |
35b65dd8 | 69 | void reset_cpu(void) |
e525d34b | 70 | { |
fe2e8ff9 | 71 | i2c_reg_write(CONFIG_SYS_I2C_POWERIC_ADDR, 0x20, 0x80); |
e525d34b | 72 | } |
a4fc6ee9 | 73 | #endif |
14ebe87b MV |
74 | |
75 | #ifdef CONFIG_MULTI_DTB_FIT | |
76 | int board_fit_config_name_match(const char *name) | |
77 | { | |
78 | /* PRR driver is not available yet */ | |
6bd3a95b | 79 | u32 cpu_type = renesas_get_cpu_type(); |
14ebe87b MV |
80 | |
81 | if ((cpu_type == RMOBILE_CPU_TYPE_R8A7795) && | |
c7d68120 | 82 | !strcmp(name, "r8a77950-salvator-x-u-boot")) |
14ebe87b MV |
83 | return 0; |
84 | ||
85 | if ((cpu_type == RMOBILE_CPU_TYPE_R8A7796) && | |
c7d68120 | 86 | !strcmp(name, "r8a77960-salvator-x-u-boot")) |
14ebe87b MV |
87 | return 0; |
88 | ||
89 | if ((cpu_type == RMOBILE_CPU_TYPE_R8A77965) && | |
90 | !strcmp(name, "r8a77965-salvator-x-u-boot")) | |
91 | return 0; | |
92 | ||
93 | return -1; | |
94 | } | |
95 | #endif |