0
votes

I am trying to do some pin multiplexing on my bare metal AM1808, but I can't seem to write the kick register? Or, more specifically, I seem to be unable to read back the values I tried to write.

Here is my code:

#define SYSCFG_BASE ((void*volatile)0x01C14000)
#define SYSCFG_KICK0R (*((unsigned int*volatile)(SYSCFG_BASE + 0x38)))
#define SYSCFG_KICK1R (*((unsigned int*volatile)(SYSCFG_BASE + 0x3C)))

#define KICK0_UNLOCK  0x83E70B13
#define KICK1_UNLOCK  0x95A4F10
#define KICK0_LOCK    0x0
#define KICK1_LOCK    0x0

static void
gpio_init (int diode)
{
  int status = 0;
  asm volatile (
    "mrs %[ps],cpsr" : [ps]"=&r"(status)
  );
  printf("mode:  0x%x\n", status & 0x1F);

  printf("kick0: 0x%x", SYSCFG_KICK0R);
  SYSCFG_KICK0R = KICK0_UNLOCK;
  printf("   ->  0x%x\n", SYSCFG_KICK0R);

  printf("kick1: 0x%x", SYSCFG_KICK1R);
  SYSCFG_KICK1R = KICK1_UNLOCK;
  printf("   ->  0x%x\n", SYSCFG_KICK1R);

  /* pinmux stuff */

  SYSCFG_KICK0R = KICK0_LOCK;
  SYSCFG_KICK1R = KICK1_LOCK;
}

which outputs:

mode:  0x13
kick0: 0x0   ->  0x0
kick1: 0x0   ->  0x0

Am I generally not able to read the kick registers although I am in supervisor mode? If so, how can I test if I unlocked the syscfg correctly?

UPDATE: As it turns out, the problem I was having was not related to the pin multiplexing, or the kick registers, but instead I had an error in the top level logic that used the correctly multiplexed GPIO pins. Sorry for the confusion.

1
The AM1808 TechRef says this in 10.2.2 Kicker Mecahanism Protection: "The Kick registers are disabled in silicon revision 2 and later. The SYSCFG registers are always unlocked and writes to the Kick registers have no functional effect" Maybe you have a rev 2 device?Michael Burr
@MichaelBurr the REVID register of syscfg contains 0x4E840102 But I could not find anything in the manual if this references revision 2?Andreas Grapentin
I have a AM335x manual at hand and for that KICK registers are write only. Please check if your manual states something similar.auselen
@auselen thanks. my manual states that for the AM1808 the kick registers are both read and writable though.Andreas Grapentin

1 Answers

4
votes

According to the datasheet, your value for KICK1 should be 0x95A4F1E0, your code has 0x95A4F10 which doesn't match. It's visually quite clear in your code that the second value is shorter than the first, which is a warning signal.

It also says, as pointed out in a comment, that Rev 2 of the hardware no longer has the kick registers so check that, too.

Also, make sure calling printf() in that sequence of scary poking is safe.