Hardware register printouts

Started by marcolazzaroni, October 02, 2012, 07:52:28 PM

Previous topic - Next topic

marcolazzaroni

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

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

Thank you dpwhittaker!
I'll give a look at it today!
Cheers
  Marco