blob: b4fddafe64029eed14c0733048712fc0690f6d3c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Peng Fan186585c2016-12-11 19:24:37 +08002/*
3 * Copyright (C) 2016 Freescale Semiconductor, Inc.
Peng Fan186585c2016-12-11 19:24:37 +08004 */
5
Simon Glassa7b51302019-11-14 12:57:46 -07006#include <init.h>
Peng Fan186585c2016-12-11 19:24:37 +08007#include <asm/arch/clock.h>
8#include <asm/arch/crm_regs.h>
9#include <asm/arch/iomux.h>
10#include <asm/arch/imx-regs.h>
11#include <asm/arch/mx6-pins.h>
12#include <asm/arch/sys_proto.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060013#include <asm/global_data.h>
Peng Fan186585c2016-12-11 19:24:37 +080014#include <asm/gpio.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020015#include <asm/mach-imx/iomux-v3.h>
16#include <asm/mach-imx/boot_mode.h>
Peng Fan186585c2016-12-11 19:24:37 +080017#include <asm/io.h>
18#include <common.h>
19#include <linux/sizes.h>
20#include <mmc.h>
21#include <power/pmic.h>
22#include <power/pfuze100_pmic.h>
23#include "../common/pfuze.h"
24
25DECLARE_GLOBAL_DATA_PTR;
26
27#define UART_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
28 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
29 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
30
31int dram_init(void)
32{
33 gd->ram_size = imx_ddr_size();
34
35 return 0;
36}
37
38static iomux_v3_cfg_t const uart1_pads[] = {
39 MX6_PAD_UART1_TXD__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
40 MX6_PAD_UART1_RXD__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
41};
42
43static iomux_v3_cfg_t const wdog_pads[] = {
44 MX6_PAD_WDOG_B__WDOG1_B | MUX_PAD_CTRL(NO_PAD_CTRL),
45};
46
47static void setup_iomux_uart(void)
48{
49 imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
50}
51
52#ifdef CONFIG_DM_PMIC_PFUZE100
53int power_init_board(void)
54{
55 struct udevice *dev;
56 int ret;
57 u32 dev_id, rev_id, i;
58 u32 switch_num = 6;
59 u32 offset = PFUZE100_SW1CMODE;
60
Fabio Estevamcf7a8202019-12-20 14:59:27 -030061 ret = pmic_get("pfuze100@08", &dev);
Peng Fan186585c2016-12-11 19:24:37 +080062 if (ret == -ENODEV)
63 return 0;
64
65 if (ret != 0)
66 return ret;
67
68 dev_id = pmic_reg_read(dev, PFUZE100_DEVICEID);
69 rev_id = pmic_reg_read(dev, PFUZE100_REVID);
70 printf("PMIC: PFUZE100! DEV_ID=0x%x REV_ID=0x%x\n", dev_id, rev_id);
71
72
73 /* Init mode to APS_PFM */
74 pmic_reg_write(dev, PFUZE100_SW1ABMODE, APS_PFM);
75
76 for (i = 0; i < switch_num - 1; i++)
77 pmic_reg_write(dev, offset + i * SWITCH_SIZE, APS_PFM);
78
79 /* set SW1AB staby volatage 0.975V */
80 pmic_clrsetbits(dev, PFUZE100_SW1ABSTBY, 0x3f, 0x1b);
81
82 /* set SW1AB/VDDARM step ramp up time from 16us to 4us/25mV */
83 pmic_clrsetbits(dev, PFUZE100_SW1ABCONF, 0xc0, 0x40);
84
85 /* set SW1C staby volatage 0.975V */
86 pmic_clrsetbits(dev, PFUZE100_SW1CSTBY, 0x3f, 0x1b);
87
88 /* set SW1C/VDDSOC step ramp up time to from 16us to 4us/25mV */
89 pmic_clrsetbits(dev, PFUZE100_SW1CCONF, 0xc0, 0x40);
90
91 return 0;
92}
93#endif
94
95int board_early_init_f(void)
96{
97 setup_iomux_uart();
98
99 return 0;
100}
101
102int board_init(void)
103{
104 /* Address of boot parameters */
105 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
106
107 return 0;
108}
109
110int board_late_init(void)
111{
112 imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
113
114 return 0;
115}
116
117int checkboard(void)
118{
119 puts("Board: MX6SLL EVK\n");
120
121 return 0;
122}
123
124int board_mmc_get_env_dev(int devno)
125{
126 return devno;
127}
128
129int mmc_map_to_kernel_blk(int devno)
130{
131 return devno;
132}