1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
4 * Dave Gerlach <d-gerlach@ti.com>
11 #include <asm/arch/hardware.h>
14 struct soc_ti_k3_plat {
19 static const char *get_family_string(u32 idreg)
24 soc = (idreg & JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
27 case JTAG_ID_PARTNO_AM65X:
30 case JTAG_ID_PARTNO_J721E:
33 case JTAG_ID_PARTNO_J7200:
36 case JTAG_ID_PARTNO_AM64X:
39 case JTAG_ID_PARTNO_J721S2:
42 case JTAG_ID_PARTNO_AM62X:
45 case JTAG_ID_PARTNO_AM62AX:
49 family = "Unknown Silicon";
55 static char *j721e_rev_string_map[] = {
59 static char *typical_rev_string_map[] = {
63 static const char *get_rev_string(u32 idreg)
68 rev = (idreg & JTAG_ID_VARIANT_MASK) >> JTAG_ID_VARIANT_SHIFT;
69 soc = (idreg & JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT;
72 case JTAG_ID_PARTNO_J721E:
73 if (rev >= ARRAY_SIZE(j721e_rev_string_map))
75 return j721e_rev_string_map[rev];
78 if (rev >= ARRAY_SIZE(typical_rev_string_map))
80 return typical_rev_string_map[rev];
84 return "Unknown Revision";
87 static int soc_ti_k3_get_family(struct udevice *dev, char *buf, int size)
89 struct soc_ti_k3_plat *plat = dev_get_plat(dev);
91 snprintf(buf, size, "%s", plat->family);
96 static int soc_ti_k3_get_revision(struct udevice *dev, char *buf, int size)
98 struct soc_ti_k3_plat *plat = dev_get_plat(dev);
100 snprintf(buf, size, "SR%s", plat->revision);
105 static const struct soc_ops soc_ti_k3_ops = {
106 .get_family = soc_ti_k3_get_family,
107 .get_revision = soc_ti_k3_get_revision,
110 int soc_ti_k3_probe(struct udevice *dev)
112 struct soc_ti_k3_plat *plat = dev_get_plat(dev);
116 idreg_addr = dev_read_addr_ptr(dev);
120 idreg = readl(idreg_addr);
122 plat->family = get_family_string(idreg);
123 plat->revision = get_rev_string(idreg);
128 static const struct udevice_id soc_ti_k3_ids[] = {
129 { .compatible = "ti,am654-chipid" },
133 U_BOOT_DRIVER(soc_ti_k3) = {
136 .ops = &soc_ti_k3_ops,
137 .of_match = soc_ti_k3_ids,
138 .probe = soc_ti_k3_probe,
139 .plat_auto = sizeof(struct soc_ti_k3_plat),