blob: 40369f03e72a6070bc40ae62374cdd267771b142 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Markus Niebelee2cd2b2014-07-18 16:52:44 +02002/*
3 * Copyright (C) 2012 Freescale Semiconductor, Inc.
4 * Author: Fabio Estevam <fabio.estevam@freescale.com>
5 *
Matthias Schifferb50ae032021-11-02 11:36:46 +01006 * Copyright (C) 2013, 2014 TQ-Systems (ported SabreSD to TQMa6x)
Markus Niebelee2cd2b2014-07-18 16:52:44 +02007 * Author: Markus Niebel <markus.niebel@tq-group.com>
Markus Niebelee2cd2b2014-07-18 16:52:44 +02008 */
9
Simon Glassa7b51302019-11-14 12:57:46 -070010#include <init.h>
Markus Niebelee2cd2b2014-07-18 16:52:44 +020011#include <asm/arch/clock.h>
12#include <asm/arch/mx6-pins.h>
13#include <asm/arch/imx-regs.h>
14#include <asm/arch/iomux.h>
15#include <asm/arch/sys_proto.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060016#include <env.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060017#include <fdt_support.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060018#include <asm/global_data.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090019#include <linux/errno.h>
Markus Niebelee2cd2b2014-07-18 16:52:44 +020020#include <asm/gpio.h>
21#include <asm/io.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090022#include <linux/libfdt.h>
Markus Niebelee2cd2b2014-07-18 16:52:44 +020023#include <mmc.h>
24#include <power/pfuze100_pmic.h>
25#include <power/pmic.h>
26
27#include "tqma6_bb.h"
28
29DECLARE_GLOBAL_DATA_PTR;
30
Markus Niebelee2cd2b2014-07-18 16:52:44 +020031int dram_init(void)
32{
Markus Niebela87a7832014-11-18 13:22:57 +010033 gd->ram_size = imx_ddr_size();
Markus Niebelee2cd2b2014-07-18 16:52:44 +020034
35 return 0;
36}
37
38static const uint16_t tqma6_emmc_dsr = 0x0100;
39
Markus Niebelee2cd2b2014-07-18 16:52:44 +020040
41int board_early_init_f(void)
42{
43 return tqma6_bb_board_early_init_f();
44}
45
46int board_init(void)
47{
48 /* address of boot parameters */
49 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
50
Michael Krummsdorfade873e2020-04-09 15:21:41 +020051#ifndef CONFIG_DM_SPI
Markus Niebelee2cd2b2014-07-18 16:52:44 +020052 tqma6_iomuxc_spi();
Michael Krummsdorfade873e2020-04-09 15:21:41 +020053#endif
Markus Niebelee2cd2b2014-07-18 16:52:44 +020054 tqma6_bb_board_init();
55
56 return 0;
57}
58
59static const char *tqma6_get_boardname(void)
60{
61 u32 cpurev = get_cpu_rev();
62
63 switch ((cpurev & 0xFF000) >> 12) {
64 case MXC_CPU_MX6SOLO:
65 return "TQMa6S";
66 break;
67 case MXC_CPU_MX6DL:
68 return "TQMa6DL";
69 break;
70 case MXC_CPU_MX6D:
71 return "TQMa6D";
72 break;
73 case MXC_CPU_MX6Q:
74 return "TQMa6Q";
75 break;
76 default:
77 return "??";
78 };
79}
80
Fabio Estevamba1015b2024-08-09 14:58:08 -030081#if CONFIG_IS_ENABLED(DM_PMIC)
Markus Niebel00bb1872017-02-03 16:24:58 +010082/* setup board specific PMIC */
83int power_init_board(void)
Markus Niebelee2cd2b2014-07-18 16:52:44 +020084{
Fabio Estevamba1015b2024-08-09 14:58:08 -030085 struct udevice *dev;
Markus Niebel00bb1872017-02-03 16:24:58 +010086 u32 reg, rev;
Fabio Estevamba1015b2024-08-09 14:58:08 -030087 int ret;
Markus Niebelee2cd2b2014-07-18 16:52:44 +020088
Fabio Estevamba1015b2024-08-09 14:58:08 -030089 ret = pmic_get("pmic@8", &dev);
90 if (ret < 0)
91 return 0;
92
93 reg = pmic_reg_read(dev, PFUZE100_DEVICEID);
94 rev = pmic_reg_read(dev, PFUZE100_REVID);
Markus Niebelee2cd2b2014-07-18 16:52:44 +020095
Fabio Estevamba1015b2024-08-09 14:58:08 -030096 printf("PMIC: PFUZE100 ID=0x%02x REV=0x%02x\n", reg, rev);
Markus Niebel00bb1872017-02-03 16:24:58 +010097 return 0;
98}
Michael Krummsdorfade873e2020-04-09 15:21:41 +020099#endif
Markus Niebel00bb1872017-02-03 16:24:58 +0100100
101int board_late_init(void)
102{
Simon Glass6a38e412017-08-03 12:22:09 -0600103 env_set("board_name", tqma6_get_boardname());
Markus Niebel00bb1872017-02-03 16:24:58 +0100104
Markus Niebelee2cd2b2014-07-18 16:52:44 +0200105 tqma6_bb_board_late_init();
106
Markus Niebelee2cd2b2014-07-18 16:52:44 +0200107 printf("Board: %s on a %s\n", tqma6_get_boardname(),
108 tqma6_bb_get_boardname());
109 return 0;
110}
111
112/*
113 * Device Tree Support
114 */
115#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
Markus Niebelc01ca162017-02-28 16:37:33 +0100116#define MODELSTRLEN 32u
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900117int ft_board_setup(void *blob, struct bd_info *bd)
Markus Niebelee2cd2b2014-07-18 16:52:44 +0200118{
Markus Niebelc01ca162017-02-28 16:37:33 +0100119 char modelstr[MODELSTRLEN];
120
121 snprintf(modelstr, MODELSTRLEN, "TQ %s on %s", tqma6_get_boardname(),
122 tqma6_bb_get_boardname());
123 do_fixup_by_path_string(blob, "/", "model", modelstr);
124 fdt_fixup_memory(blob, (u64)PHYS_SDRAM, (u64)gd->ram_size);
Markus Niebelee2cd2b2014-07-18 16:52:44 +0200125 /* bring in eMMC dsr settings */
126 do_fixup_by_path_u32(blob,
127 "/soc/aips-bus@02100000/usdhc@02198000",
128 "dsr", tqma6_emmc_dsr, 2);
129 tqma6_bb_ft_board_setup(blob, bd);
Simon Glass2aec3cc2014-10-23 18:58:47 -0600130
131 return 0;
Markus Niebelee2cd2b2014-07-18 16:52:44 +0200132}
133#endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */