blob: b1a8fa8f0b2f234b7fe572f8776d861f4756c3a2 [file] [log] [blame]
Daniel Hellstromfeb0c262008-03-26 23:00:38 +01001/*
2 * (C) Copyright 2007
3 * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Daniel Hellstromfeb0c262008-03-26 23:00:38 +01006 */
7
8/*
9 * AMBA Plug&Play information list command
10 *
11 */
12#include <common.h>
13#include <command.h>
14#include <ambapp.h>
15
16DECLARE_GLOBAL_DATA_PTR;
17
Daniel Hellstromfeb0c262008-03-26 23:00:38 +010018typedef struct {
19 int device_id;
20 char *name;
Daniel Hellstrom02e2a842010-01-25 09:54:51 +010021 char *desc;
Daniel Hellstromfeb0c262008-03-26 23:00:38 +010022} ambapp_device_name;
23
Daniel Hellstrom02e2a842010-01-25 09:54:51 +010024typedef struct {
25 unsigned int vendor_id;
26 char *name;
27 char *desc;
28 ambapp_device_name *devices;
29} ambapp_vendor_devnames;
30
31/** Vendor GAISLER devices */
32static ambapp_device_name GAISLER_devices[] = {
33 {GAISLER_LEON2DSU, "LEON2DSU", "Leon2 Debug Support Unit"},
34 {GAISLER_LEON3, "LEON3", "Leon3 SPARC V8 Processor"},
35 {GAISLER_LEON3DSU, "LEON3DSU", "Leon3 Debug Support Unit"},
36 {GAISLER_ETHAHB, "ETHAHB", "OC ethernet AHB interface"},
37 {GAISLER_APBMST, "APBMST", "AHB/APB Bridge"},
38 {GAISLER_AHBUART, "AHBUART", "AHB Debug UART"},
39 {GAISLER_SRCTRL, "SRCTRL", "Simple SRAM Controller"},
40 {GAISLER_SDCTRL, "SDCTRL", "PC133 SDRAM Controller"},
41 {GAISLER_SSRCTRL, "SSRCTRL", "Synchronous SRAM Controller"},
42 {GAISLER_APBUART, "APBUART", "Generic UART"},
43 {GAISLER_IRQMP, "IRQMP", "Multi-processor Interrupt Ctrl."},
44 {GAISLER_AHBRAM, "AHBRAM", "Single-port AHB SRAM module"},
45 {GAISLER_AHBDPRAM, "AHBDPRAM", "Dual-port AHB SRAM module"},
46 {GAISLER_GPTIMER, "GPTIMER", "Modular Timer Unit"},
47 {GAISLER_PCITRG, "PCITRG", "Simple 32-bit PCI Target"},
48 {GAISLER_PCISBRG, "PCISBRG", "Simple 32-bit PCI Bridge"},
49 {GAISLER_PCIFBRG, "PCIFBRG", "Fast 32-bit PCI Bridge"},
50 {GAISLER_PCITRACE, "PCITRACE", "32-bit PCI Trace Buffer"},
51 {GAISLER_DMACTRL, "DMACTRL", "AMBA DMA controller"},
52 {GAISLER_AHBTRACE, "AHBTRACE", "AMBA Trace Buffer"},
53 {GAISLER_DSUCTRL, "DSUCTRL", "DSU/ETH controller"},
54 {GAISLER_CANAHB, "CANAHB", "OC CAN AHB interface"},
55 {GAISLER_GPIO, "GPIO", "General Purpose I/O port"},
56 {GAISLER_AHBROM, "AHBROM", "Generic AHB ROM"},
57 {GAISLER_AHBJTAG, "AHBJTAG", "JTAG Debug Link"},
58 {GAISLER_ETHMAC, "ETHMAC", "GR Ethernet MAC"},
59 {GAISLER_SWNODE, "SWNODE", "SpaceWire Node Interface"},
60 {GAISLER_SPW, "SPW", "SpaceWire Serial Link"},
61 {GAISLER_AHB2AHB, "AHB2AHB", "AHB-to-AHB Bridge"},
62 {GAISLER_USBDC, "USBDC", "GR USB 2.0 Device Controller"},
63 {GAISLER_USB_DCL, "USB_DCL", "USB Debug Communication Link"},
64 {GAISLER_DDRMP, "DDRMP", "Multi-port DDR controller"},
65 {GAISLER_ATACTRL, "ATACTRL", "ATA controller"},
66 {GAISLER_DDRSP, "DDRSP", "Single-port DDR266 controller"},
67 {GAISLER_EHCI, "EHCI", "USB Enhanced Host Controller"},
68 {GAISLER_UHCI, "UHCI", "USB Universal Host Controller"},
69 {GAISLER_I2CMST, "I2CMST", "AMBA Wrapper for OC I2C-master"},
70 {GAISLER_SPW2, "SPW2", "GRSPW2 SpaceWire Serial Link"},
71 {GAISLER_AHBDMA, "AHBDMA", ""},
72 {GAISLER_NUHOSP3, "NUHOSP3", "Nuhorizons Spartan3 IO I/F"},
73 {GAISLER_CLKGATE, "CLKGATE", "Clock gating unit"},
74 {GAISLER_SPICTRL, "SPICTRL", "SPI Controller"},
75 {GAISLER_DDR2SP, "DDR2SP", "Single-port DDR2 controller"},
76 {GAISLER_SLINK, "SLINK", "SLINK Master"},
77 {GAISLER_GRTM, "GRTM", "CCSDS Telemetry Encoder"},
78 {GAISLER_GRTC, "GRTC", "CCSDS Telecommand Decoder"},
79 {GAISLER_GRPW, "GRPW", "PacketWire to AMBA AHB I/F"},
80 {GAISLER_GRCTM, "GRCTM", "CCSDS Time Manager"},
81 {GAISLER_GRHCAN, "GRHCAN", "ESA HurriCANe CAN with DMA"},
82 {GAISLER_GRFIFO, "GRFIFO", "FIFO Controller"},
83 {GAISLER_GRADCDAC, "GRADCDAC", "ADC / DAC Interface"},
84 {GAISLER_GRPULSE, "GRPULSE", "General Purpose I/O with Pulses"},
85 {GAISLER_GRTIMER, "GRTIMER", "Timer Unit with Latches"},
86 {GAISLER_AHB2PP, "AHB2PP", "AMBA AHB to Packet Parallel I/F"},
87 {GAISLER_GRVERSION, "GRVERSION", "Version and Revision Register"},
88 {GAISLER_APB2PW, "APB2PW", "PacketWire Transmit Interface"},
89 {GAISLER_PW2APB, "PW2APB", "PacketWire Receive Interface"},
90 {GAISLER_GRCAN, "GRCAN", "CAN Controller with DMA"},
91 {GAISLER_I2CSLV, "I2CSLV", "I2C Slave"},
92 {GAISLER_U16550, "U16550", "Simple 16550 UART"},
93 {GAISLER_AHBMST_EM, "AHBMST_EM", "AMBA Master Emulator"},
94 {GAISLER_AHBSLV_EM, "AHBSLV_EM", "AMBA Slave Emulator"},
95 {GAISLER_GRTESTMOD, "GRTESTMOD", "Test report module"},
96 {GAISLER_ASCS, "ASCS", "ASCS Master"},
97 {GAISLER_IPMVBCTRL, "IPMVBCTRL", "IPM-bus/MVBC memory controller"},
98 {GAISLER_SPIMCTRL, "SPIMCTRL", "SPI Memory Controller"},
99 {GAISLER_LEON4, "LEON4", "Leon4 SPARC V8 Processor"},
100 {GAISLER_LEON4DSU, "LEON4DSU", "Leon4 Debug Support Unit"},
101 {GAISLER_PWM, "PWM", "PWM generator"},
102 {GAISLER_L2CACHE, "L2CACHE", "L2-Cache Controller"},
103 {GAISLER_SDCTRL64, "SDCTRL64", ""},
104 {GAISLER_FTAHBRAM, "FTAHBRAM", "Generic FT AHB SRAM module"},
105 {GAISLER_FTSRCTRL, "FTSRCTRL", "Simple FT SRAM Controller"},
106 {GAISLER_AHBSTAT, "AHBSTAT", "AHB Status Register"},
107 {GAISLER_LEON3FT, "LEON3FT", "Leon3-FT SPARC V8 Processor"},
108 {GAISLER_FTMCTRL, "FTMCTRL", "Memory controller with EDAC"},
109 {GAISLER_FTSDCTRL, "FTSDCTRL", "FT PC133 SDRAM Controller"},
110 {GAISLER_FTSRCTRL8, "FTSRCTRL8", "FT 8-bit SRAM/16-bit IO Ctrl"},
111 {GAISLER_APBPS2, "APBPS2", "PS2 interface"},
112 {GAISLER_VGACTRL, "VGACTRL", "VGA controller"},
113 {GAISLER_LOGAN, "LOGAN", "On chip Logic Analyzer"},
114 {GAISLER_SVGACTRL, "SVGACTRL", "SVGA frame buffer"},
115 {GAISLER_T1AHB, "T1AHB", "Niagara T1 PCX/AHB bridge"},
116 {GAISLER_MP7WRAP, "MP7WRAP", "CoreMP7 wrapper"},
117 {GAISLER_GRSYSMON, "GRSYSMON", "AMBA wrapper for System Monitor"},
118 {GAISLER_GRACECTRL, "GRACECTRL", "System ACE I/F Controller"},
119 {GAISLER_ATAHBSLV, "ATAHBSLV", "AMBA Test Framework AHB Slave"},
120 {GAISLER_ATAHBMST, "ATAHBMST", "AMBA Test Framework AHB Master"},
121 {GAISLER_ATAPBSLV, "ATAPBSLV", "AMBA Test Framework APB Slave"},
122 {GAISLER_B1553BC, "B1553BC", "AMBA Wrapper for Core1553BBC"},
123 {GAISLER_B1553RT, "B1553RT", "AMBA Wrapper for Core1553BRT"},
124 {GAISLER_B1553BRM, "B1553BRM", "AMBA Wrapper for Core1553BRM"},
125 {GAISLER_AES, "AES", "Advanced Encryption Standard"},
126 {GAISLER_ECC, "ECC", "Elliptic Curve Cryptography"},
127 {GAISLER_PCIF, "PCIF", "AMBA Wrapper for CorePCIF"},
128 {GAISLER_CLKMOD, "CLKMOD", "CPU Clock Switching Ctrl module"},
129 {GAISLER_HAPSTRAK, "HAPSTRAK", "HAPS HapsTrak I/O Port"},
130 {GAISLER_TEST_1X2, "TEST_1X2", "HAPS TEST_1x2 interface"},
131 {GAISLER_WILD2AHB, "WILD2AHB", "WildCard CardBus interface"},
132 {GAISLER_BIO1, "BIO1", "Basic I/O board BIO1"},
133 {GAISLER_SATCAN, "SATCAN", "SatCAN controller"},
134 {GAISLER_CANMUX, "CANMUX", "CAN Bus multiplexer"},
135 {GAISLER_GRTMRX, "GRTMRX", "CCSDS Telemetry Receiver"},
136 {GAISLER_GRTCTX, "GRTCTX", "CCSDS Telecommand Transmitter"},
137 {GAISLER_GRTMDESC, "GRTMDESC", "CCSDS Telemetry Descriptor"},
138 {GAISLER_GRTMVC, "GRTMVC", "CCSDS Telemetry VC Generator"},
139 {GAISLER_GEFFE, "GEFFE", "Geffe Generator"},
140 {GAISLER_GPREG, "GPREG", ""},
141 {GAISLER_GRTMPAHB, "GRTMPAHB", "CCSDS Telemetry VC AHB Input"},
142 {0, NULL, NULL}
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100143};
144
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100145
146/** Vendor PENDER devices */
147static ambapp_device_name PENDER_devices[] = {
148 {0, NULL, NULL}
149};
150
151
152/** Vendor ESA devices */
153static ambapp_device_name ESA_devices[] = {
154 {ESA_LEON2, "LEON2", "Leon2 SPARC V8 Processor"},
155 {ESA_LEON2APB, "LEON2APB", "Leon2 Peripheral Bus"},
156 {ESA_IRQ, "IRQ", "Leon2 Interrupt Controller"},
157 {ESA_TIMER, "TIMER", "Leon2 Timer"},
158 {ESA_UART, "UART", "Leon2 UART"},
159 {ESA_CFG, "CFG", "Leon2 Configuration Register"},
160 {ESA_IO, "IO", "Leon2 Input/Output"},
161 {ESA_MCTRL, "MCTRL", "Leon2 Memory Controller"},
162 {ESA_PCIARB, "PCIARB", "PCI Arbiter"},
163 {ESA_HURRICANE, "HURRICANE", "HurriCANe/HurryAMBA CAN Ctrl"},
164 {ESA_SPW_RMAP, "SPW_RMAP", "UoD/Saab SpaceWire/RMAP link"},
165 {ESA_AHBUART, "AHBUART", "Leon2 AHB Debug UART"},
166 {ESA_SPWA, "SPWA", "ESA/ASTRIUM SpaceWire link"},
167 {ESA_BOSCHCAN, "BOSCHCAN", "SSC/BOSCH CAN Ctrl"},
168 {ESA_IRQ2, "IRQ2", "Leon2 Secondary Irq Controller"},
169 {ESA_AHBSTAT, "AHBSTAT", "Leon2 AHB Status Register"},
170 {ESA_WPROT, "WPROT", "Leon2 Write Protection"},
171 {ESA_WPROT2, "WPROT2", "Leon2 Extended Write Protection"},
172 {ESA_PDEC3AMBA, "PDEC3AMBA", "ESA CCSDS PDEC3AMBA TC Decoder"},
173 {ESA_PTME3AMBA, "PTME3AMBA", "ESA CCSDS PTME3AMBA TM Encoder"},
174 {0, NULL, NULL}
175};
176
177
178/** Vendor ASTRIUM devices */
179static ambapp_device_name ASTRIUM_devices[] = {
180 {0, NULL, NULL}
181};
182
183
184/** Vendor OPENCHIP devices */
185static ambapp_device_name OPENCHIP_devices[] = {
186 {OPENCHIP_APBGPIO, "APBGPIO", "APB General Purpose IO"},
187 {OPENCHIP_APBI2C, "APBI2C", "APB I2C Interface"},
188 {OPENCHIP_APBSPI, "APBSPI", "APB SPI Interface"},
189 {OPENCHIP_APBCHARLCD, "APBCHARLCD", "APB Character LCD"},
190 {OPENCHIP_APBPWM, "APBPWM", "APB PWM"},
191 {OPENCHIP_APBPS2, "APBPS2", "APB PS/2 Interface"},
192 {OPENCHIP_APBMMCSD, "APBMMCSD", "APB MMC/SD Card Interface"},
193 {OPENCHIP_APBNAND, "APBNAND", "APB NAND(SmartMedia) Interface"},
194 {OPENCHIP_APBLPC, "APBLPC", "APB LPC Interface"},
195 {OPENCHIP_APBCF, "APBCF", "APB CompactFlash (IDE)"},
196 {OPENCHIP_APBSYSACE, "APBSYSACE", "APB SystemACE Interface"},
197 {OPENCHIP_APB1WIRE, "APB1WIRE", "APB 1-Wire Interface"},
198 {OPENCHIP_APBJTAG, "APBJTAG", "APB JTAG TAP Master"},
199 {OPENCHIP_APBSUI, "APBSUI", "APB Simple User Interface"},
200 {0, NULL, NULL}
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100201};
202
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100203
204/** Vendor OPENCORES devices */
205static ambapp_device_name OPENCORES_devices[] = {
206 {OPENCORES_PCIBR, "PCIBR", "PCI Bridge"},
207 {OPENCORES_ETHMAC, "ETHMAC", "Ethernet MAC"},
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100208 {0, NULL}
209};
210
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100211
212/** Vendor CONTRIB devices */
213static ambapp_device_name CONTRIB_devices[] = {
214 {CONTRIB_CORE1, "CORE1", "Contributed core 1"},
215 {CONTRIB_CORE2, "CORE2", "Contributed core 2"},
216 {0, NULL, NULL}
217};
218
219
220/** Vendor EONIC devices */
221static ambapp_device_name EONIC_devices[] = {
222 {0, NULL, NULL}
223};
224
225
226/** Vendor RADIONOR devices */
227static ambapp_device_name RADIONOR_devices[] = {
228 {0, NULL, NULL}
229};
230
231
232/** Vendor GLEICHMANN devices */
233static ambapp_device_name GLEICHMANN_devices[] = {
234 {GLEICHMANN_CUSTOM, "CUSTOM", "Custom device"},
235 {GLEICHMANN_GEOLCD01, "GEOLCD01", "GEOLCD01 graphics system"},
236 {GLEICHMANN_DAC, "DAC", "Sigma delta DAC"},
237 {GLEICHMANN_HPI, "HPI", "AHB-to-HPI bridge"},
238 {GLEICHMANN_SPI, "SPI", "SPI master"},
239 {GLEICHMANN_HIFC, "HIFC", "Human interface controller"},
240 {GLEICHMANN_ADCDAC, "ADCDAC", "Sigma delta ADC/DAC"},
241 {GLEICHMANN_SPIOC, "SPIOC", ""},
242 {GLEICHMANN_AC97, "AC97", ""},
243 {0, NULL, NULL}
244};
245
246
247/** Vendor MENTA devices */
248static ambapp_device_name MENTA_devices[] = {
249 {0, NULL, NULL}
250};
251
252
253/** Vendor SUN devices */
254static ambapp_device_name SUN_devices[] = {
255 {SUN_T1, "T1", "Niagara T1 SPARC V9 Processor"},
256 {SUN_S1, "S1", "Niagara S1 SPARC V9 Processor"},
257 {0, NULL, NULL}
258};
259
260
261/** Vendor MOVIDIA devices */
262static ambapp_device_name MOVIDIA_devices[] = {
263 {0, NULL, NULL}
264};
265
266
267/** Vendor ORBITA devices */
268static ambapp_device_name ORBITA_devices[] = {
269 {ORBITA_1553B, "1553B", "MIL-STD-1553B Controller"},
270 {ORBITA_429, "429", "429 Interface"},
271 {ORBITA_SPI, "SPI", "SPI Interface"},
272 {ORBITA_I2C, "I2C", "I2C Interface"},
273 {ORBITA_SMARTCARD, "SMARTCARD", "Smart Card Reader"},
274 {ORBITA_SDCARD, "SDCARD", "SD Card Reader"},
275 {ORBITA_UART16550, "UART16550", "16550 UART"},
276 {ORBITA_CRYPTO, "CRYPTO", "Crypto Engine"},
277 {ORBITA_SYSIF, "SYSIF", "System Interface"},
278 {ORBITA_PIO, "PIO", "Programmable IO module"},
279 {ORBITA_RTC, "RTC", "Real-Time Clock"},
280 {ORBITA_COLORLCD, "COLORLCD", "Color LCD Controller"},
281 {ORBITA_PCI, "PCI", "PCI Module"},
282 {ORBITA_DSP, "DSP", "DPS Co-Processor"},
283 {ORBITA_USBHOST, "USBHOST", "USB Host"},
284 {ORBITA_USBDEV, "USBDEV", "USB Device"},
285 {0, NULL, NULL}
286};
287
288
289/** Vendor SYNOPSYS devices */
290static ambapp_device_name SYNOPSYS_devices[] = {
291 {0, NULL, NULL}
292};
293
294
295/** Vendor NASA devices */
296static ambapp_device_name NASA_devices[] = {
297 {NASA_EP32, "EP32", "EP32 Forth processor"},
298 {0, NULL, NULL}
299};
300
301
302/** Vendor CAL devices */
303static ambapp_device_name CAL_devices[] = {
304 {CAL_DDRCTRL, "DDRCTRL", ""},
305 {0, NULL, NULL}
306};
307
308
309/** Vendor EMBEDDIT devices */
310static ambapp_device_name EMBEDDIT_devices[] = {
311 {0, NULL, NULL}
312};
313
314
315/** Vendor CETON devices */
316static ambapp_device_name CETON_devices[] = {
317 {0, NULL, NULL}
318};
319
320
321/** Vendor ACTEL devices */
322static ambapp_device_name ACTEL_devices[] = {
323 {ACTEL_COREMP7, "COREMP7", "CoreMP7 Processor"},
324 {0, NULL, NULL}
325};
326
327
328/** Vendor APPLECORE devices */
329static ambapp_device_name APPLECORE_devices[] = {
330 {APPLECORE_UTLEON3, "UTLEON3", "AppleCore uT-LEON3 Processor"},
331 {APPLECORE_UTLEON3DSU, "UTLEON3DSU", "AppleCore uT-LEON3 DSU"},
332 {0, NULL, NULL}
333};
334
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100335
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100336/** Vendors and their devices */
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100337static ambapp_vendor_devnames vendors[] = {
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100338 {VENDOR_GAISLER, "GAISLER", "Gaisler Research", GAISLER_devices},
339 {VENDOR_PENDER, "PENDER", "", PENDER_devices},
340 {VENDOR_ESA, "ESA", "European Space Agency", ESA_devices},
341 {VENDOR_ASTRIUM, "ASTRIUM", "", ASTRIUM_devices},
342 {VENDOR_OPENCHIP, "OPENCHIP", "OpenChip", OPENCHIP_devices},
343 {VENDOR_OPENCORES, "OPENCORES", "OpenCores", OPENCORES_devices},
344 {VENDOR_CONTRIB, "CONTRIB", "Various contributions", CONTRIB_devices},
345 {VENDOR_EONIC, "EONIC", "Eonic BV", EONIC_devices},
346 {VENDOR_RADIONOR, "RADIONOR", "Radionor Communications", RADIONOR_devices},
347 {VENDOR_GLEICHMANN, "GLEICHMANN", "Gleichmann Electronics", GLEICHMANN_devices},
348 {VENDOR_MENTA, "MENTA", "Menta", MENTA_devices},
349 {VENDOR_SUN, "SUN", "Sun Microsystems", SUN_devices},
350 {VENDOR_MOVIDIA, "MOVIDIA", "", MOVIDIA_devices},
351 {VENDOR_ORBITA, "ORBITA", "Orbita", ORBITA_devices},
352 {VENDOR_SYNOPSYS, "SYNOPSYS", "Synopsys Inc.", SYNOPSYS_devices},
353 {VENDOR_NASA, "NASA", "NASA", NASA_devices},
354 {VENDOR_CAL, "CAL", "", CAL_devices},
355 {VENDOR_EMBEDDIT, "EMBEDDIT", "Embedd.it", EMBEDDIT_devices},
356 {VENDOR_CETON, "CETON", "Ceton Corporation", CETON_devices},
357 {VENDOR_ACTEL, "ACTEL", "Actel Corporation", ACTEL_devices},
358 {VENDOR_APPLECORE, "APPLECORE", "AppleCore", APPLECORE_devices},
359 {0, NULL, NULL, NULL}
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100360};
361
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100362static ambapp_device_name *ambapp_get_dev(ambapp_device_name *devs, int id)
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100363{
364 if (!devs)
365 return NULL;
366
367 while (devs->device_id > 0) {
368 if (devs->device_id == id)
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100369 return devs;
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100370 devs++;
371 }
372 return NULL;
373}
374
375char *ambapp_device_id2str(int vendor, int id)
376{
377 ambapp_vendor_devnames *ven = &vendors[0];
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100378 ambapp_device_name *dev;
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100379
380 while (ven->vendor_id > 0) {
381 if (ven->vendor_id == vendor) {
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100382 dev = ambapp_get_dev(ven->devices, id);
383 if (!dev)
384 return NULL;
385 return dev->name;
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100386 }
387 ven++;
388 }
389 return NULL;
390}
391
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100392char *ambapp_device_id2desc(int vendor, int id)
393{
394 ambapp_vendor_devnames *ven = &vendors[0];
395 ambapp_device_name *dev;
396
397 while (ven->vendor_id > 0) {
398 if (ven->vendor_id == vendor) {
399 dev = ambapp_get_dev(ven->devices, id);
400 if (!dev)
401 return NULL;
402 return dev->desc;
403 }
404 ven++;
405 }
406 return NULL;
407}
408
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100409char *ambapp_vendor_id2str(int vendor)
410{
411 ambapp_vendor_devnames *ven = &vendors[0];
412
413 while (ven->vendor_id > 0) {
414 if (ven->vendor_id == vendor) {
415 return ven->name;
416 }
417 ven++;
418 }
419 return NULL;
420}
421
422static char *unknown = "unknown";
423
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100424char *ambapp_type_names[4] = {
425 /* 0 */ "UNUSED",
426 /* 1 */ "apb",
427 /* 2 */ "ahbmem",
428 /* 3 */ "ahbio"
429};
430
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100431/* Print one APB device */
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100432void ambapp_print_apb(ambapp_apbdev *dev, int index)
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100433{
434 char *dev_str, *ven_str;
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100435 unsigned int freq;
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100436
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100437 ven_str = ambapp_vendor_id2str(dev->vendor);
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100438 if (!ven_str) {
439 ven_str = unknown;
440 dev_str = unknown;
441 } else {
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100442 dev_str = ambapp_device_id2str(dev->vendor, dev->device);
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100443 if (!dev_str)
444 dev_str = unknown;
445 }
446
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100447 /* Get Frequency of Core */
448 freq = ambapp_bus_freq(&ambapp_plb, dev->ahb_bus_index);
449
450 printf("0x%02x:0x%02x:0x%02x: %s %s (%dkHz)\n"
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100451 " apb: 0x%08x - 0x%08x\n"
452 " irq: %-2d (ver: %-2d)\n",
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100453 index, dev->vendor, dev->device, ven_str, dev_str, freq / 1000,
454 dev->address, dev->address + (dev->mask-1),
455 dev->irq, dev->ver);
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100456}
457
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100458void ambapp_print_ahb(ambapp_ahbdev *dev, int index)
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100459{
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100460 char *dev_str, *ven_str, *type_str;
461 int i;
462 unsigned int freq;
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100463
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100464 ven_str = ambapp_vendor_id2str(dev->vendor);
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100465 if (!ven_str) {
466 ven_str = unknown;
467 dev_str = unknown;
468 } else {
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100469 dev_str = ambapp_device_id2str(dev->vendor, dev->device);
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100470 if (!dev_str)
471 dev_str = unknown;
472 }
473
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100474 /* Get Frequency of Core */
475 freq = ambapp_bus_freq(&ambapp_plb, dev->ahb_bus_index);
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100476
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100477 printf("0x%02x:0x%02x:0x%02x: %s %s (%dkHz)\n",
478 index, dev->vendor, dev->device, ven_str, dev_str, freq / 1000);
479
480 for (i = 0; i < 4; i++) {
481 if (dev->type[i] == 0)
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100482 continue;
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100483 type_str = ambapp_type_names[dev->type[i]];
484 printf(" %-7s: 0x%08x - 0x%08x\n", type_str, dev->address[i],
485 dev->address[i] + (dev->mask[i]-1));
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100486 }
487
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100488 printf(" irq: %-2d (ver: %d)\n", dev->irq, dev->ver);
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100489}
490
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200491int do_ambapp_print(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100492{
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100493 int index;
494 ambapp_apbdev apbdev;
495 ambapp_ahbdev ahbdev;
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100496
497 /* Print AHB Masters */
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100498 puts("\n--------- AHB Masters ---------\n");
499 index = 0;
500 while (ambapp_ahbmst_find(&ambapp_plb, 0, 0, index, &ahbdev) == 1) {
501 /* Found a AHB Master Device */
502 ambapp_print_ahb(&ahbdev, index);
503 index++;
504 }
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100505
506 /* Print AHB Slaves */
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100507 puts("\n--------- AHB Slaves ---------\n");
508 index = 0;
509 while (ambapp_ahbslv_find(&ambapp_plb, 0, 0, index, &ahbdev) == 1) {
510 /* Found a AHB Slave Device */
511 ambapp_print_ahb(&ahbdev, index);
512 index++;
513 }
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100514
515 /* Print APB Slaves */
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100516 puts("\n--------- APB Slaves ---------\n");
517 index = 0;
518 while (ambapp_apb_find(&ambapp_plb, 0, 0, index, &apbdev) == 1) {
519 /* Found a APB Slave Device */
520 ambapp_print_apb(&apbdev, index);
521 index++;
522 }
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100523
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100524 puts("\n");
525 return 0;
526}
527
528int ambapp_init_reloc(void)
529{
530 ambapp_vendor_devnames *vend = vendors;
531 ambapp_device_name *dev;
532
533 while (vend->vendor_id && vend->name) {
534 vend->name = (char *)((unsigned int)vend->name + gd->reloc_off);
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100535 vend->desc = (char *)((unsigned int)vend->desc + gd->reloc_off);
536 vend->devices = (ambapp_device_name *)
537 ((unsigned int)vend->devices + gd->reloc_off);
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100538 dev = vend->devices;
539 vend++;
540 if (!dev)
541 continue;
542 while (dev->device_id && dev->name) {
543 dev->name =
Daniel Hellstrom02e2a842010-01-25 09:54:51 +0100544 (char *)((unsigned int)dev->name + gd->reloc_off);
545 dev->desc =
546 (char *)((unsigned int)dev->desc + gd->reloc_off);
Daniel Hellstromfeb0c262008-03-26 23:00:38 +0100547 dev++;
548 }
549 }
550 return 0;
551}
552
Frans Meulenbroeks7675a092010-07-31 15:01:53 +0200553U_BOOT_CMD(
554 ambapp, 1, 1, do_ambapp_print,
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200555 "list AMBA Plug&Play information",
556 "ambapp\n"
557 " - lists AMBA (AHB & APB) Plug&Play devices present on the system"
558);