Welcome, Guest

Author Topic: Hardware register printouts  (Read 2826 times)

marcolazzaroni

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
Hardware register printouts
« on: October 02, 2012, 07:52:28 PM »
Is it possible to print in some way the content of the Imx233 registers?
They're defined in bootlets at mach-mx23/includes/registers/regsssp.h
I think that I need to access them in a way similar to that they do here:
http://lxr.free-electrons.com/source/drivers/mmc/host/mxs-mmc.c

For example I could need to create a small executable that detects sd card presence by accessing physical registers:

http://lxr.free-electrons.com/source/drivers/mmc/host/mxs-mmc.c#L186
186 static int mxs_mmc_get_cd(struct mmc_host *mmc)
187 {
188         struct mxs_mmc_host *host = mmc_priv(mmc);
189
190         return !(readl(host->base + HW_SSP_STATUS(host)) &
191                  BM_SSP_STATUS_CARD_DETECT);
192 }

What is the simplest way to compile such little executable? I need to install some headers/sources on the target machine?
Cheers
  Marco

dpwhittaker

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: Hardware register printouts
« Reply #1 on: October 03, 2012, 05:53:19 AM »
The easiest way to do this is with memory mapping.  I've got a simple C header file for GPIO mmap that can show you the basic idea.

https://www.dropbox.com/sh/fbmucmbmh01zzyg/jxUuXOoiV5

Take a look at that one.  You could just change GPIO_BASE to the MMC base address, then call gpio_map() and  use gpio_rd(offset) with whatever HW_SSP_STATUS(host) works out to be.  You'll probably want to delete what you're not using, and change all the gpio's to mmc's, but beyond that, gpio-mmap.h serves as a good example of how to read any register from user space.

marcolazzaroni

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
Re: Hardware register printouts
« Reply #2 on: October 03, 2012, 09:05:36 AM »
Thank you dpwhittaker!
I'll give a look at it today!
Cheers
  Marco