2 * board/renesas/alt/alt.c
4 * Copyright (C) 2014 Renesas Electronics Corporation
6 * SPDX-License-Identifier: GPL-2.0
11 #include <asm/processor.h>
12 #include <asm/mach-types.h>
14 #include <asm/errno.h>
15 #include <asm/arch/sys_proto.h>
17 #include <asm/arch/rmobile.h>
24 DECLARE_GLOBAL_DATA_PTR;
26 #define CLK2MHZ(clk) (clk / 1000 / 1000)
29 struct rcar_rwdt *rwdt = (struct rcar_rwdt *)RWDT_BASE;
30 struct rcar_swdt *swdt = (struct rcar_swdt *)SWDT_BASE;
33 writel(0xA5A5A500, &rwdt->rwtcsra);
34 writel(0xA5A5A500, &swdt->swtcsra);
40 #define MSTPSR1 0xE6150038
41 #define SMSTPCR1 0xE6150134
42 #define TMU0_MSTP125 (1 << 25)
44 #define MSTPSR7 0xE61501C4
45 #define SMSTPCR7 0xE615014C
46 #define SCIF0_MSTP719 (1 << 19)
48 #define MSTPSR8 0xE61509A0
49 #define SMSTPCR8 0xE6150990
50 #define ETHER_MSTP813 (1 << 13)
52 #define mstp_setbits(type, addr, saddr, set) \
53 out_##type((saddr), in_##type(addr) | (set))
54 #define mstp_clrbits(type, addr, saddr, clear) \
55 out_##type((saddr), in_##type(addr) & ~(clear))
56 #define mstp_setbits_le32(addr, saddr, set) \
57 mstp_setbits(le32, addr, saddr, set)
58 #define mstp_clrbits_le32(addr, saddr, clear) \
59 mstp_clrbits(le32, addr, saddr, clear)
61 int board_early_init_f(void)
64 mstp_clrbits_le32(MSTPSR1, SMSTPCR1, TMU0_MSTP125);
67 mstp_clrbits_le32(MSTPSR7, SMSTPCR7, SCIF0_MSTP719);
70 mstp_clrbits_le32(MSTPSR8, SMSTPCR8, ETHER_MSTP813);
75 void arch_preboot_os(void)
78 mstp_setbits_le32(MSTPSR1, SMSTPCR1, TMU0_MSTP125);
83 /* adress of boot parameters */
84 gd->bd->bi_boot_params = ALT_SDRAM_BASE + 0x100;
86 /* Init PFC controller */
87 r8a7794_pinmux_init();
90 gpio_request(GPIO_FN_ETH_CRS_DV, NULL);
91 gpio_request(GPIO_FN_ETH_RX_ER, NULL);
92 gpio_request(GPIO_FN_ETH_RXD0, NULL);
93 gpio_request(GPIO_FN_ETH_RXD1, NULL);
94 gpio_request(GPIO_FN_ETH_LINK, NULL);
95 gpio_request(GPIO_FN_ETH_REFCLK, NULL);
96 gpio_request(GPIO_FN_ETH_MDIO, NULL);
97 gpio_request(GPIO_FN_ETH_TXD1, NULL);
98 gpio_request(GPIO_FN_ETH_TX_EN, NULL);
99 gpio_request(GPIO_FN_ETH_MAGIC, NULL);
100 gpio_request(GPIO_FN_ETH_TXD0, NULL);
101 gpio_request(GPIO_FN_ETH_MDC, NULL);
102 gpio_request(GPIO_FN_IRQ8, NULL);
105 gpio_request(GPIO_GP_1_24, NULL);
106 gpio_direction_output(GPIO_GP_1_24, 0);
108 gpio_set_value(GPIO_GP_1_24, 1);
114 #define CXR24 0xEE7003C0 /* MAC address high register */
115 #define CXR25 0xEE7003C8 /* MAC address low register */
116 int board_eth_init(bd_t *bis)
118 #ifdef CONFIG_SH_ETHER
121 unsigned char enetaddr[6];
123 ret = sh_eth_initialize(bis);
124 if (!eth_getenv_enetaddr("ethaddr", enetaddr))
127 /* Set Mac address */
128 val = enetaddr[0] << 24 | enetaddr[1] << 16 |
129 enetaddr[2] << 8 | enetaddr[3];
132 val = enetaddr[4] << 8 | enetaddr[5];
143 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
148 const struct rmobile_sysinfo sysinfo = {
149 CONFIG_RMOBILE_BOARD_STRING
152 void dram_init_banksize(void)
154 gd->bd->bi_dram[0].start = ALT_SDRAM_BASE;
155 gd->bd->bi_dram[0].size = ALT_SDRAM_SIZE;
158 int board_late_init(void)
163 void reset_cpu(ulong addr)
167 i2c_set_bus_num(1); /* PowerIC connected to ch3 */
169 i2c_read(CONFIG_SYS_I2C_POWERIC_ADDR, 0x13, 1, &val, 1);
171 i2c_write(CONFIG_SYS_I2C_POWERIC_ADDR, 0x13, 1, &val, 1);