| 
									
										
										
										
											2013-10-22 15:16:06 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * LED, Switch and Debug control registers for ARM Integrator Boards | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This is currently a stub for this functionality but at least | 
					
						
							|  |  |  |  * ensures something other than unassigned_mem_read() handles access | 
					
						
							|  |  |  |  * to this area. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The real h/w is described at: | 
					
						
							| 
									
										
										
										
											2021-02-05 17:14:56 +00:00
										 |  |  |  *  https://developer.arm.com/documentation/dui0159/b/peripherals-and-interfaces/debug-leds-and-dip-switch-interface
 | 
					
						
							| 
									
										
										
										
											2013-10-22 15:16:06 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2013 Alex Bennée <alex@bennee.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This work is licensed under the terms of the GNU GPL, version 2 or later. | 
					
						
							|  |  |  |  * See the COPYING file in the top-level directory. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-26 18:17:17 +00:00
										 |  |  | #include "qemu/osdep.h"
 | 
					
						
							| 
									
										
										
										
											2013-10-22 15:16:06 +01:00
										 |  |  | #include "hw/sysbus.h"
 | 
					
						
							|  |  |  | #include "hw/misc/arm_integrator_debug.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-15 13:16:16 +01:00
										 |  |  | #include "qemu/log.h"
 | 
					
						
							| 
									
										
										
										
											2019-05-23 16:35:07 +02:00
										 |  |  | #include "qemu/module.h"
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | #include "qom/object.h"
 | 
					
						
							| 
									
										
										
										
											2013-10-22 15:16:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-16 14:25:19 -04:00
										 |  |  | OBJECT_DECLARE_SIMPLE_TYPE(IntegratorDebugState, INTEGRATOR_DEBUG) | 
					
						
							| 
									
										
										
										
											2013-10-22 15:16:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | struct IntegratorDebugState { | 
					
						
							| 
									
										
										
										
											2013-10-22 15:16:06 +01:00
										 |  |  |     SysBusDevice parent_obj; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MemoryRegion iomem; | 
					
						
							| 
									
										
										
										
											2020-09-03 16:43:22 -04:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-10-22 15:16:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | static uint64_t intdbg_control_read(void *opaque, hwaddr offset, | 
					
						
							|  |  |  |                                     unsigned size) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     switch (offset >> 2) { | 
					
						
							|  |  |  |     case 0: /* ALPHA */ | 
					
						
							|  |  |  |     case 1: /* LEDS */ | 
					
						
							|  |  |  |     case 2: /* SWITCHES */ | 
					
						
							|  |  |  |         qemu_log_mask(LOG_UNIMP, | 
					
						
							|  |  |  |                       "%s: returning zero from %" HWADDR_PRIx ":%u\n", | 
					
						
							|  |  |  |                       __func__, offset, size); | 
					
						
							|  |  |  |         return 0; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         qemu_log_mask(LOG_GUEST_ERROR, | 
					
						
							|  |  |  |                       "%s: Bad offset %" HWADDR_PRIx, | 
					
						
							|  |  |  |                       __func__, offset); | 
					
						
							|  |  |  |         return 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void intdbg_control_write(void *opaque, hwaddr offset, | 
					
						
							|  |  |  |                                  uint64_t value, unsigned size) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     switch (offset >> 2) { | 
					
						
							|  |  |  |     case 1: /* ALPHA */ | 
					
						
							|  |  |  |     case 2: /* LEDS */ | 
					
						
							|  |  |  |     case 3: /* SWITCHES */ | 
					
						
							|  |  |  |         /* Nothing interesting implemented yet.  */ | 
					
						
							|  |  |  |         qemu_log_mask(LOG_UNIMP, | 
					
						
							|  |  |  |                       "%s: ignoring write of %" PRIu64 | 
					
						
							|  |  |  |                       " to %" HWADDR_PRIx ":%u\n", | 
					
						
							|  |  |  |                       __func__, value, offset, size); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         qemu_log_mask(LOG_GUEST_ERROR, | 
					
						
							|  |  |  |                       "%s: write of %" PRIu64 | 
					
						
							|  |  |  |                       " to bad offset %" HWADDR_PRIx "\n", | 
					
						
							|  |  |  |                       __func__, value, offset); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const MemoryRegionOps intdbg_control_ops = { | 
					
						
							|  |  |  |     .read = intdbg_control_read, | 
					
						
							|  |  |  |     .write = intdbg_control_write, | 
					
						
							|  |  |  |     .endianness = DEVICE_NATIVE_ENDIAN, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void intdbg_control_init(Object *obj) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SysBusDevice *sd = SYS_BUS_DEVICE(obj); | 
					
						
							|  |  |  |     IntegratorDebugState *s = INTEGRATOR_DEBUG(obj); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-01 10:59:51 +02:00
										 |  |  |     memory_region_init_io(&s->iomem, obj, &intdbg_control_ops, | 
					
						
							| 
									
										
										
										
											2013-10-22 15:16:06 +01:00
										 |  |  |                           NULL, "dbg-leds", 0x1000000); | 
					
						
							|  |  |  |     sysbus_init_mmio(sd, &s->iomem); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const TypeInfo intdbg_info = { | 
					
						
							|  |  |  |     .name          = TYPE_INTEGRATOR_DEBUG, | 
					
						
							|  |  |  |     .parent        = TYPE_SYS_BUS_DEVICE, | 
					
						
							|  |  |  |     .instance_size = sizeof(IntegratorDebugState), | 
					
						
							|  |  |  |     .instance_init = intdbg_control_init, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void intdbg_register_types(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     type_register_static(&intdbg_info); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type_init(intdbg_register_types) |