blob: c23097f04769ffb00721218dd9d6543725911144 [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>
18#include <common.h>
19#include <i2c.h>
20#include <miiphy.h>
21#include <power/pmic.h>
22#include <power/pfuze3000_pmic.h>
23
24DECLARE_GLOBAL_DATA_PTR;
25
26int dram_init(void)
27{
28 gd->ram_size = imx_ddr_size();
29 return 0;
30}
31
32int power_init_board(void)
33{
34 struct udevice *dev;
35 int ret;
36 unsigned int reg, rev;
37
38 ret = pmic_get("pmic@8", &dev);
39 if (ret == -ENODEV) {
40 puts("No pmic\n");
41 return 0;
42 }
43 if (ret != 0)
44 return ret;
45
46 reg = pmic_reg_read(dev, PFUZE3000_DEVICEID);
47 rev = pmic_reg_read(dev, PFUZE3000_REVID);
48 printf("PMIC: PFUZE3000 DEV_ID=0x%x REV_ID=0x%x\n", reg, rev);
49
50 /* disable Low Power Mode during standby mode */
51 reg = pmic_reg_read(dev, PFUZE3000_LDOGCTL);
52 reg |= 0x1;
53 pmic_reg_write(dev, PFUZE3000_LDOGCTL, reg);
54
55 /* SW1A/1B mode set to APS/APS */
56 reg = 0x8;
57 pmic_reg_write(dev, PFUZE3000_SW1AMODE, reg);
58 pmic_reg_write(dev, PFUZE3000_SW1BMODE, reg);
59
60 /* SW1A/1B standby voltage set to 1.025V */
61 reg = 0xd;
62 pmic_reg_write(dev, PFUZE3000_SW1ASTBY, reg);
63 pmic_reg_write(dev, PFUZE3000_SW1BSTBY, reg);
64
65 /* decrease SW1B normal voltage to 0.975V */
66 reg = pmic_reg_read(dev, PFUZE3000_SW1BVOLT);
67 reg &= ~0x1f;
68 reg |= PFUZE3000_SW1AB_SETP(975);
69 pmic_reg_write(dev, PFUZE3000_SW1BVOLT, reg);
70
71 return 0;
72}
73
74static int setup_fec(void)
75{
76 return set_clk_enet(ENET_125MHZ);
77}
78
79int board_init(void)
80{
81 /* address of boot parameters */
82 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
83
84 setup_fec();
85
86 return 0;
87}
88
89int board_late_init(void)
90{
91 return 0;
92}
93
94int checkboard(void)
95{
96 puts("Board: iMX7-CM\n");
97 return 0;
98}