Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2012 Freescale Semiconductor, Inc. |
| 4 | * Author: Fabio Estevam <fabio.estevam@freescale.com> |
| 5 | * |
Matthias Schiffer | b50ae03 | 2021-11-02 11:36:46 +0100 | [diff] [blame] | 6 | * Copyright (C) 2013, 2014 TQ-Systems (ported SabreSD to TQMa6x) |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 7 | * Author: Markus Niebel <markus.niebel@tq-group.com> |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 10 | #include <init.h> |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 11 | #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 Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 16 | #include <env.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 17 | #include <fdt_support.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 18 | #include <asm/global_data.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 19 | #include <linux/errno.h> |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 20 | #include <asm/gpio.h> |
| 21 | #include <asm/io.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 22 | #include <linux/libfdt.h> |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 23 | #include <mmc.h> |
| 24 | #include <power/pfuze100_pmic.h> |
| 25 | #include <power/pmic.h> |
| 26 | |
| 27 | #include "tqma6_bb.h" |
| 28 | |
| 29 | DECLARE_GLOBAL_DATA_PTR; |
| 30 | |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 31 | int dram_init(void) |
| 32 | { |
Markus Niebel | a87a783 | 2014-11-18 13:22:57 +0100 | [diff] [blame] | 33 | gd->ram_size = imx_ddr_size(); |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | static const uint16_t tqma6_emmc_dsr = 0x0100; |
| 39 | |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 40 | |
| 41 | int board_early_init_f(void) |
| 42 | { |
| 43 | return tqma6_bb_board_early_init_f(); |
| 44 | } |
| 45 | |
| 46 | int board_init(void) |
| 47 | { |
| 48 | /* address of boot parameters */ |
| 49 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 50 | |
Michael Krummsdorf | ade873e | 2020-04-09 15:21:41 +0200 | [diff] [blame] | 51 | #ifndef CONFIG_DM_SPI |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 52 | tqma6_iomuxc_spi(); |
Michael Krummsdorf | ade873e | 2020-04-09 15:21:41 +0200 | [diff] [blame] | 53 | #endif |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 54 | tqma6_bb_board_init(); |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | static 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 Estevam | ba1015b | 2024-08-09 14:58:08 -0300 | [diff] [blame] | 81 | #if CONFIG_IS_ENABLED(DM_PMIC) |
Markus Niebel | 00bb187 | 2017-02-03 16:24:58 +0100 | [diff] [blame] | 82 | /* setup board specific PMIC */ |
| 83 | int power_init_board(void) |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 84 | { |
Fabio Estevam | ba1015b | 2024-08-09 14:58:08 -0300 | [diff] [blame] | 85 | struct udevice *dev; |
Markus Niebel | 00bb187 | 2017-02-03 16:24:58 +0100 | [diff] [blame] | 86 | u32 reg, rev; |
Fabio Estevam | ba1015b | 2024-08-09 14:58:08 -0300 | [diff] [blame] | 87 | int ret; |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 88 | |
Fabio Estevam | ba1015b | 2024-08-09 14:58:08 -0300 | [diff] [blame] | 89 | 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 Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 95 | |
Fabio Estevam | ba1015b | 2024-08-09 14:58:08 -0300 | [diff] [blame] | 96 | printf("PMIC: PFUZE100 ID=0x%02x REV=0x%02x\n", reg, rev); |
Markus Niebel | 00bb187 | 2017-02-03 16:24:58 +0100 | [diff] [blame] | 97 | return 0; |
| 98 | } |
Michael Krummsdorf | ade873e | 2020-04-09 15:21:41 +0200 | [diff] [blame] | 99 | #endif |
Markus Niebel | 00bb187 | 2017-02-03 16:24:58 +0100 | [diff] [blame] | 100 | |
| 101 | int board_late_init(void) |
| 102 | { |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 103 | env_set("board_name", tqma6_get_boardname()); |
Markus Niebel | 00bb187 | 2017-02-03 16:24:58 +0100 | [diff] [blame] | 104 | |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 105 | tqma6_bb_board_late_init(); |
| 106 | |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 107 | 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 Niebel | c01ca16 | 2017-02-28 16:37:33 +0100 | [diff] [blame] | 116 | #define MODELSTRLEN 32u |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 117 | int ft_board_setup(void *blob, struct bd_info *bd) |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 118 | { |
Markus Niebel | c01ca16 | 2017-02-28 16:37:33 +0100 | [diff] [blame] | 119 | 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 Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 125 | /* 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 Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 130 | |
| 131 | return 0; |
Markus Niebel | ee2cd2b | 2014-07-18 16:52:44 +0200 | [diff] [blame] | 132 | } |
| 133 | #endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */ |