blob: 63550af1f0dd2cd882798520375ba0d8d9d2f959 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Marek Vasutbd390502017-07-21 23:15:21 +02002/*
3 * board/renesas/ulcb/ulcb.c
4 * This file is ULCB board support.
5 *
6 * Copyright (C) 2017 Renesas Electronics Corporation
Marek Vasutbd390502017-07-21 23:15:21 +02007 */
8
9#include <common.h>
10#include <malloc.h>
11#include <netdev.h>
12#include <dm.h>
13#include <dm/platform_data/serial_sh.h>
14#include <asm/processor.h>
15#include <asm/mach-types.h>
16#include <asm/io.h>
17#include <linux/errno.h>
18#include <asm/arch/sys_proto.h>
19#include <asm/gpio.h>
20#include <asm/arch/gpio.h>
21#include <asm/arch/rmobile.h>
22#include <asm/arch/rcar-mstp.h>
23#include <asm/arch/sh_sdhi.h>
24#include <i2c.h>
25#include <mmc.h>
26
27DECLARE_GLOBAL_DATA_PTR;
28
Marek Vasutbd390502017-07-21 23:15:21 +020029void s_init(void)
30{
Marek Vasutbd390502017-07-21 23:15:21 +020031}
32
33#define GSX_MSTP112 BIT(12) /* 3DG */
Marek Vasutbd390502017-07-21 23:15:21 +020034#define SCIF2_MSTP310 BIT(10) /* SCIF2 */
Marek Vasutbd390502017-07-21 23:15:21 +020035#define DVFS_MSTP926 BIT(26)
Marek Vasutef603232017-09-12 19:07:22 +020036#define HSUSB_MSTP704 BIT(4) /* HSUSB */
Marek Vasutbd390502017-07-21 23:15:21 +020037
Marek Vasutbd390502017-07-21 23:15:21 +020038int board_early_init_f(void)
39{
Marek Vasutbd390502017-07-21 23:15:21 +020040#if defined(CONFIG_SYS_I2C) && defined(CONFIG_SYS_I2C_SH)
41 /* DVFS for reset */
Hiroyuki Yokoyamacf97b222018-09-26 16:00:09 +090042 mstp_clrbits_le32(SMSTPCR9, SMSTPCR9, DVFS_MSTP926);
Marek Vasutbd390502017-07-21 23:15:21 +020043#endif
44 return 0;
45}
46
Marek Vasutef603232017-09-12 19:07:22 +020047/* HSUSB block registers */
48#define HSUSB_REG_LPSTS 0xE6590102
49#define HSUSB_REG_LPSTS_SUSPM_NORMAL BIT(14)
50#define HSUSB_REG_UGCTRL2 0xE6590184
51#define HSUSB_REG_UGCTRL2_USB0SEL 0x30
52#define HSUSB_REG_UGCTRL2_USB0SEL_EHCI 0x10
53
Marek Vasutbd390502017-07-21 23:15:21 +020054int board_init(void)
55{
56 /* adress of boot parameters */
57 gd->bd->bi_boot_params = CONFIG_SYS_TEXT_BASE + 0x50000;
58
Marek Vasutbd390502017-07-21 23:15:21 +020059 /* USB1 pull-up */
60 setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN);
61
Marek Vasutef603232017-09-12 19:07:22 +020062 /* Configure the HSUSB block */
Hiroyuki Yokoyamacf97b222018-09-26 16:00:09 +090063 mstp_clrbits_le32(SMSTPCR7, SMSTPCR7, HSUSB_MSTP704);
Marek Vasutef603232017-09-12 19:07:22 +020064 /* Choice USB0SEL */
65 clrsetbits_le32(HSUSB_REG_UGCTRL2, HSUSB_REG_UGCTRL2_USB0SEL,
66 HSUSB_REG_UGCTRL2_USB0SEL_EHCI);
67 /* low power status */
68 setbits_le16(HSUSB_REG_LPSTS, HSUSB_REG_LPSTS_SUSPM_NORMAL);
69
Marek Vasut6f380852017-08-20 17:13:48 +020070 return 0;
Marek Vasutbd390502017-07-21 23:15:21 +020071}
Marek Vasutbd390502017-07-21 23:15:21 +020072
73int dram_init(void)
74{
Siva Durga Prasad Paladugu12308b12018-07-16 15:56:11 +053075 if (fdtdec_setup_mem_size_base() != 0)
Marek Vasutaee24b52017-11-27 05:37:53 +010076 return -EINVAL;
Marek Vasutbd390502017-07-21 23:15:21 +020077
78 return 0;
79}
80
81int dram_init_banksize(void)
82{
Marek Vasutaee24b52017-11-27 05:37:53 +010083 fdtdec_setup_memory_banksize();
84
Marek Vasutbd390502017-07-21 23:15:21 +020085 return 0;
86}