Dne Ne 29. listopadu 2009 06:10:57 David Brownell napsal(a): > On Saturday 28 November 2009, Marek Vasut wrote: > > > > +static int xscale_version = XSCALE_IXP4XX_PXA2XX; > > > > > > Please put this in the instance-specific struct ... this approach > > > obviously breaks on a board with both a PXA2xx and a PXA3xx. > > > > Have you ever seen such a mutant ? Come on ... > > Bad design is bad design. This is trivial to fix, and preventing > such bugs from appearing in the first place is better than trying > to troubleshoot them in the field later on. > > > btw. where should I look for that instance-specific struct ? > > Did you look at "xscale.h"? That's where I'd start. There > turns out to be a "struct xscale_common", go figure. ;) > Ok, here's an updated patch
From 2a2b0143bf8b359f6acabac633bc2607e9bd9de0 Mon Sep 17 00:00:00 2001 From: Marek Vasut <marek.va...@gmail.com> Date: Sun, 29 Nov 2009 12:53:06 +0100 Subject: [PATCH 1/3] Add initial PXA3xx support
--- src/target/xscale.c | 37 +++++++++++++++++++++++++++---------- src/target/xscale.h | 7 +++++++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/target/xscale.c b/src/target/xscale.c index 49653a9..fdc269a 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -191,7 +191,8 @@ static int xscale_read_dcsr(struct target *target) uint8_t field2_check_mask = 0x1; jtag_set_end_state(TAP_DRPAUSE); - xscale_jtag_set_instr(target->tap, XSCALE_SELDCSR); + xscale_jtag_set_instr(target->tap, + XSCALE_SELDCSR << xscale->xscale_variant); buf_set_u32(&field0, 1, 1, xscale->hold_rst); buf_set_u32(&field0, 2, 1, xscale->external_debug_break); @@ -256,6 +257,7 @@ static int xscale_receive(struct target *target, uint32_t *buffer, int num_words if (num_words == 0) return ERROR_INVALID_ARGUMENTS; + struct xscale_common *xscale = target_to_xscale(target); int retval = ERROR_OK; tap_state_t path[3]; struct scan_field fields[3]; @@ -289,7 +291,8 @@ static int xscale_receive(struct target *target, uint32_t *buffer, int num_words fields[2].check_mask = &field2_check_mask; jtag_set_end_state(TAP_IDLE); - xscale_jtag_set_instr(target->tap, XSCALE_DBGTX); + xscale_jtag_set_instr(target->tap, + XSCALE_DBGTX << xscale->xscale_variant); jtag_add_runtest(1, jtag_get_end_state()); /* ensures that we're in the TAP_IDLE state as the above could be a no-op */ /* repeat until all words have been collected */ @@ -371,7 +374,8 @@ static int xscale_read_tx(struct target *target, int consume) jtag_set_end_state(TAP_IDLE); - xscale_jtag_set_instr(target->tap, XSCALE_DBGTX); + xscale_jtag_set_instr(target->tap, + XSCALE_DBGTX << xscale->xscale_variant); path[0] = TAP_DRSELECT; path[1] = TAP_DRCAPTURE; @@ -469,7 +473,8 @@ static int xscale_write_rx(struct target *target) jtag_set_end_state(TAP_IDLE); - xscale_jtag_set_instr(target->tap, XSCALE_DBGRX); + xscale_jtag_set_instr(target->tap, + XSCALE_DBGRX << xscale->xscale_variant); memset(&fields, 0, sizeof fields); @@ -541,6 +546,7 @@ static int xscale_write_rx(struct target *target) /* send count elements of size byte to the debug handler */ static int xscale_send(struct target *target, uint8_t *buffer, int count, int size) { + struct xscale_common *xscale = target_to_xscale(target); uint32_t t[3]; int bits[3]; int retval; @@ -548,7 +554,8 @@ static int xscale_send(struct target *target, uint8_t *buffer, int count, int si jtag_set_end_state(TAP_IDLE); - xscale_jtag_set_instr(target->tap, XSCALE_DBGRX); + xscale_jtag_set_instr(target->tap, + XSCALE_DBGRX << xscale->xscale_variant); bits[0]=3; t[0]=0; @@ -629,7 +636,8 @@ static int xscale_write_dcsr(struct target *target, int hold_rst, int ext_dbg_br xscale->external_debug_break = ext_dbg_brk; jtag_set_end_state(TAP_IDLE); - xscale_jtag_set_instr(target->tap, XSCALE_SELDCSR); + xscale_jtag_set_instr(target->tap, + XSCALE_SELDCSR << xscale->xscale_variant); buf_set_u32(&field0, 1, 1, xscale->hold_rst); buf_set_u32(&field0, 2, 1, xscale->external_debug_break); @@ -683,6 +691,7 @@ static unsigned int parity (unsigned int v) static int xscale_load_ic(struct target *target, uint32_t va, uint32_t buffer[8]) { + struct xscale_common *xscale = target_to_xscale(target); uint8_t packet[4]; uint8_t cmd; int word; @@ -692,7 +701,8 @@ static int xscale_load_ic(struct target *target, uint32_t va, uint32_t buffer[8] /* LDIC into IR */ jtag_set_end_state(TAP_IDLE); - xscale_jtag_set_instr(target->tap, XSCALE_LDIC); + xscale_jtag_set_instr(target->tap, + XSCALE_LDIC << xscale->xscale_variant); /* CMD is b011 to load a cacheline into the Mini ICache. * Loading into the main ICache is deprecated, and unused. @@ -738,12 +748,14 @@ static int xscale_load_ic(struct target *target, uint32_t va, uint32_t buffer[8] static int xscale_invalidate_ic_line(struct target *target, uint32_t va) { + struct xscale_common *xscale = target_to_xscale(target); uint8_t packet[4]; uint8_t cmd; struct scan_field fields[2]; jtag_set_end_state(TAP_IDLE); - xscale_jtag_set_instr(target->tap, XSCALE_LDIC); + xscale_jtag_set_instr(target->tap, + XSCALE_LDIC << xscale->xscale_variant); /* CMD for invalidate IC line b000, bits [6:4] b000 */ buf_set_u32(&cmd, 0, 6, 0x0); @@ -1479,7 +1491,8 @@ static int xscale_assert_reset(struct target *target) * end up in T-L-R, which would reset JTAG */ jtag_set_end_state(TAP_IDLE); - xscale_jtag_set_instr(target->tap, XSCALE_SELDCSR); + xscale_jtag_set_instr(target->tap, + XSCALE_SELDCSR << xscale->xscale_variant); /* set Hold reset, Halt mode and Trap Reset */ buf_set_u32(xscale->reg_cache->reg_list[XSCALE_DCSR].value, 30, 1, 0x1); @@ -2882,6 +2895,7 @@ static int xscale_init_arch_info(struct target *target, /* we don't really *need* variant info ... */ if (variant) { int ir_length = 0; + xscale->xscale_variant = XSCALE_IXP4XX_PXA2XX; /* PXA2xx and IXP4xx */ if (strcmp(variant, "pxa250") == 0 || strcmp(variant, "pxa255") == 0 @@ -2892,7 +2906,10 @@ static int xscale_init_arch_info(struct target *target, || strcmp(variant, "ixp45x") == 0 || strcmp(variant, "ixp46x") == 0) ir_length = 7; - else + else if (strcmp(variant, "pxa3xx") == 0) { + ir_length = 11; + xscale->xscale_variant = XSCALE_PXA3XX; /* PXA3xx */ + } else LOG_WARNING("%s: unrecognized variant %s", tap->dotted_name, variant); diff --git a/src/target/xscale.h b/src/target/xscale.h index 4f1b54d..0a70ecb 100644 --- a/src/target/xscale.h +++ b/src/target/xscale.h @@ -37,6 +37,10 @@ #define XSCALE_LDIC 0x07 #define XSCALE_SELDCSR 0x09 +/* Possible CPU types */ +#define XSCALE_IXP4XX_PXA2XX 0x0 +#define XSCALE_PXA3XX 0x4 + enum xscale_debug_reason { XSCALE_DBG_REASON_GENERIC, @@ -129,6 +133,9 @@ struct xscale_common uint32_t cp15_control_reg; int fast_memory_access; + + /* CPU variant */ + int xscale_variant; }; static inline struct xscale_common * -- 1.6.5
_______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development