How to access h/w address in embedded linux on colibri T30

Hi,
How do we access h/w address in colibri T30 in a program , i have installed embd linux on my T30 and i want access h/w address like we can in windows @ Register Access

Please advice.

Thanks.
Pankaj

As you do not reveal what exactly you would need that HW access for it’s kind of difficult to suggest the best way to go about it. However for debugging purpose you may find devmem2 helpful.

Thanks Marcel for reply as always .
i am trying to replicate the below functions from windows environment to embed linux env , we have a simple consol application in windows CE , which i am kind of trying to port on linux now.

EDIT:
Also how do i enable GMI clock ?
Win-ce uses map.lib functions to map the registers , how do i achieve it in linux ?

MY FUNCTIONS ARE:

void InitAddresses()
{
pDataAddress = (PUSHORT)MapRegister(0x48000000);
//pDataAddress = (PUSHORT)MapRegister(0xD0000000);
pRegNoAddress = pDataAddress + (1 << 7);
}

void InitGMIClk()
{
volatile DWORD pClk;
/// clock enable
/// NOR0 clock source register address - 0x6000_61D0;
pClk = (DWORD
)MapRegister(0x60006000);
volatile DWORD* pReg = pClk;

    pReg += (0x1D0 >> 2);

    ULONG dt = *pReg;
    *pReg = ((1 << 30) | 0x06); // Src = PLLC_Out0, div by 6 + 1

                                                            // Clk En
    pReg = pClk;
    // CLK_RST_CONTROLLER_CLK_OUT_ENB_H_0
    pReg += (0x14 >> 2);

    dt = *pReg;

    //  Enable clock to NOR Flash Controller.
    dt |= (1 << 10);
    *pReg = dt;

    UnMapRegister((LPVOID)(pClk));

}

void InitGMI()
{
volatile DWORD* pReg;
ULONG dt;

    //  GMI 
    volatile DWORD* pGMI = (DWORD*)MapRegister(0x70009000); // S-NOR Controller
    pReg = pGMI;

    pReg += (0x14 >> 2); // SNOR_TIMING1_0
    //*pReg = 0x010103;
    *pReg = 0x010101;
    dt = *pReg;

    pReg = pGMI;
    pReg += (0x10 >> 2); // SNOR_TIMING0_0
    *pReg = 0x04;

    dt = *pReg;

    //SNOR_CONFIG_0
    *pGMI = (3 << 4); // CS3
    *pGMI |= (1 << 31); // enable GMI

    dt = *pGMI; // just to check    
    UnMapRegister((void*)pGMI);

}

ULONG ReadFromDevice(UCHAR regNo, PUSHORT pData, ULONG bytesCnt)
{

    // номер рега
    *pRegNoAddress = (regNo & 0x1F);

    /*
    for (ULONG i = 0; i < (bytesCnt >> 1); i++)
    {
    pData[i] = *pDataAddress;
    }*/
    ULONG toCopy = bytesCnt >> 1;
    ULONG copied = 0;
    while (toCopy)
    {
            ULONG copyLen = toCopy;
            if (copyLen > 256)
            {
                    copyLen = 256;
            }

            memcpy(&pData[copied], pDataAddress, copyLen << 1);
            copied += copyLen;
            toCopy -= copyLen;
    }
    return 0;

}

int main(int argc, wchar_t *argv)
{
int iTest;

    // init connection
    InitPins();
    InitGMIClk();
    InitGMI();
    InitAddresses();

}

Above is Snippet of my consol app in windows.

please share if you have example available.

Thanks.
Pankaj

There are several ways to access HW on Linux the easiest (but really limited) is trough the userspace, maybe you want to check the memtools utility or the cpufrequtils. The real HW control is managed by the kernel, see if a kernel loadable module fits your needs.

Thanks kahjiit,
My requirement are simple and i would prefer to do it in user space,

In the function below, ( works in windows-ce)

We have remap.lib available with APis MapRegister(addr); to map the address as i am doing below. i am trying to achieve the same in linux now?

Do you know a good approach to achieve this ?

void InitGMIClk()
{

volatile DWORD pClk; /// clock enable
pClk = (DWORD)MapRegister(0x60006000); volatile DWORD* pReg = pClk;

 pReg += (0x1D0 >> 2);

 ULONG dt = *pReg;
 *pReg = ((1 << 30) | 0x06); // Src = PLLC_Out0, div by 6 + 1

                                                         // Clk En
 pReg = pClk;
 // CLK_RST_CONTROLLER_CLK_OUT_ENB_H_0
 pReg += (0x14 >> 2);

 dt = *pReg;

 //  Enable clock to NOR Flash Controller.
 dt |= (1 << 10);
 *pReg = dt;

 UnMapRegister((LPVOID)(pClk));

}