blob: a1f3f3cd7972d6b9c1a0607a862058c5a1bbcb13 [file] [log] [blame]
Ilko Ilieve2480f12021-04-16 15:48:13 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2021 Ronetix GmbH
4 */
5
6#include <init.h>
7#include <net.h>
8#include <asm/arch/clock.h>
9#include <asm/arch/crm_regs.h>
10#include <asm/arch/imx-regs.h>
11#include <asm/arch/mx7-pins.h>
12#include <asm/arch/sys_proto.h>
13#include <asm/global_data.h>
14#include <asm/gpio.h>
15#include <asm/mach-imx/iomux-v3.h>
16#include <asm/mach-imx/mxc_i2c.h>
17#include <asm/io.h>
Ilko Ilieve2480f12021-04-16 15:48:13 +020018#include <i2c.h>
19#include <miiphy.h>
20#include <power/pmic.h>
21#include <power/pfuze3000_pmic.h>
22
23DECLARE_GLOBAL_DATA_PTR;
24
25int dram_init(void)
26{
27 gd->ram_size = imx_ddr_size();
28 return 0;
29}
30
31int power_init_board(void)
32{
33 struct udevice *dev;
34 int ret;
35 unsigned int reg, rev;
36
37 ret = pmic_get("pmic@8", &dev);
38 if (ret == -ENODEV) {
39 puts("No pmic\n");
40 return 0;
41 }
42 if (ret != 0)
43 return ret;
44
45 reg = pmic_reg_read(dev, PFUZE3000_DEVICEID);
46 rev = pmic_reg_read(dev, PFUZE3000_REVID);
47 printf("PMIC: PFUZE3000 DEV_ID=0x%x REV_ID=0x%x\n", reg, rev);
48
49 /* disable Low Power Mode during standby mode */
50 reg = pmic_reg_read(dev, PFUZE3000_LDOGCTL);
51 reg |= 0x1;
52 pmic_reg_write(dev, PFUZE3000_LDOGCTL, reg);
53
54 /* SW1A/1B mode set to APS/APS */
55 reg = 0x8;
56 pmic_reg_write(dev, PFUZE3000_SW1AMODE, reg);
57 pmic_reg_write(dev, PFUZE3000_SW1BMODE, reg);
58
59 /* SW1A/1B standby voltage set to 1.025V */
60 reg = 0xd;
61 pmic_reg_write(dev, PFUZE3000_SW1ASTBY, reg);
62 pmic_reg_write(dev, PFUZE3000_SW1BSTBY, reg);
63
64 /* decrease SW1B normal voltage to 0.975V */
65 reg = pmic_reg_read(dev, PFUZE3000_SW1BVOLT);
66 reg &= ~0x1f;
67 reg |= PFUZE3000_SW1AB_SETP(975);
68 pmic_reg_write(dev, PFUZE3000_SW1BVOLT, reg);
69
70 return 0;
71}
72
73static int setup_fec(void)
74{
75 return set_clk_enet(ENET_125MHZ);
76}
77
78int board_init(void)
79{
80 /* address of boot parameters */
81 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
82
83 setup_fec();
84
85 return 0;
86}
87
88int board_late_init(void)
89{
90 return 0;
91}
92
93int checkboard(void)
94{
95 puts("Board: iMX7-CM\n");
96 return 0;
97}