Attached you find a small patch to support 119 instead of 84 gpios.
Apply only to pxa270.
Bernd
------------------------------------------------------------------------
diff -Nupr haret/src/gpio.cpp haret-new/src/gpio.cpp
--- haret/src/gpio.cpp 2004-01-10 18:37:18.000000000 +0100
+++ haret-new/src/gpio.cpp 2006-01-13 10:43:52.000000000 +0100
@@ -13,17 +13,26 @@
#include "output.h"
// Which GPIO changes to ignore during watch
-uint32 gpioIgnore [3] = { 0, 0, 0 };
+uint32 gpioIgnore [4] = { 0, 0, 0, 0 };
void gpioSetDir (int num, bool out)
{
- if (num > 84)
+ if (num > 118)
return;
uint32 *gpdr = (uint32 *)memPhysMap (GPDR);
- uint32 ofs = num >> 5;
+ uint32 ofs = 0;
uint32 mask = 1 << (num & 31);
+ if(num > 95)
+ {
+ ofs = 64; /* it's always + 0x100 */
+ }
+ else
+ {
+ ofs = num >> 5;
+ }
+
if (out)
gpdr [ofs] |= mask;
else
@@ -32,17 +41,27 @@ void gpioSetDir (int num, bool out)
bool gpioGetDir (int num)
{
- if (num > 84)
+ if (num > 118)
return false;
uint32 *gpdr = (uint32 *)memPhysMap (GPDR);
+ uint32 ofs = 0;
- return (gpdr [num >> 5] & (1 << (num & 31))) != 0;
+ if(num > 95)
+ {
+ ofs = 64; /* it's always + 0x100 */
+ }
+ else
+ {
+ ofs = num >> 5;
+ }
+
+ return (gpdr [ofs] & (1 << (num & 31))) != 0;
}
void gpioSetAlt (int num, int altfn)
{
- if (num > 84)
+ if (num > 118)
return;
uint32 *gafr = (uint32 *)memPhysMap (GAFR);
@@ -54,7 +73,7 @@ void gpioSetAlt (int num, int altfn)
uint32 gpioGetAlt (int num)
{
- if (num > 84)
+ if (num > 118)
return -1;
uint32 *gafr = (uint32 *)memPhysMap (GAFR);
@@ -64,25 +83,47 @@ uint32 gpioGetAlt (int num)
int gpioGetState (int num)
{
- if (num > 84)
+ if (num > 118)
return -1;
+ uint32 ofs = 0;
+
+ if(num > 95)
+ {
+ ofs = 64; /* it's always + 0x100 */
+ }
+ else
+ {
+ ofs = num >> 5;
+ }
+
uint32 *gplr = (uint32 *)memPhysMap (GPLR);
- return (gplr [num >> 5] >> (num & 31)) & 1;
+ return (gplr [ofs] >> (num & 31)) & 1;
}
void gpioSetState (int num, bool state)
{
- if (num > 84)
+ if (num > 118)
return;
+ uint32 ofs = 0;
+
+ if(num > 95)
+ {
+ ofs = 64; /* it's always + 0x100 */
+ }
+ else
+ {
+ ofs = num >> 5;
+ }
+
uint32 *gpscr = (uint32 *)memPhysMap (state ? GPSR : GPCR);
- gpscr [num >> 5] |= 1 << (num & 31);
+ gpscr [ofs] |= 1 << (num & 31);
}
int gpioGetSleepState (int num)
{
- if (num > 84)
+ if (num > 118)
return -1;
uint32 *pgsr = (uint32 *)memPhysMap (PGSR);
@@ -91,7 +132,7 @@ int gpioGetSleepState (int num)
void gpioSetSleepState (int num, bool state)
{
- if (num > 84)
+ if (num > 118)
return;
uint32 *pgsr = (uint32 *)memPhysMap (PGSR);
@@ -117,32 +158,50 @@ void gpioWatch (uint seconds)
int i, j;
uint32 *gplr = (uint32 *)memPhysMap (GPLR);
- uint32 old_gplr [3];
- for (i = 0; i < 3; i++)
- old_gplr [i] = gplr [i];
-
+ uint32 old_gplr [4];
+ for (i = 0; i < 4; i++)
+ {
+ if(i == 3)
+ {
+ old_gplr[i] = gplr[64];
+ }
+ else
+ {
+ old_gplr [i] = gplr [i];
+ }
+ }
+
uint32 *gpdr = (uint32 *)memPhysMap (GPDR);
- uint32 old_gpdr [3];
- for (i = 0; i < 3; i++)
- old_gpdr [i] = gpdr [i];
-
+ uint32 old_gpdr [4];
+ for (i = 0; i < 4; i++)
+ {
+ if(i == 3)
+ {
+ old_gpdr[i] = gpdr[64];
+ }
+ else
+ {
+ old_gpdr [i] = gpdr [i];
+ }
+ }
+
uint32 *gafr = (uint32 *)memPhysMap (GAFR);
- uint32 old_gafr [6];
- for (i = 0; i < 6; i++)
+ uint32 old_gafr [8];
+ for (i = 0; i < 8; i++)
old_gafr [i] = gafr [i];
while (cur_time <= fin_time)
{
gplr = (uint32 *)memPhysMap (GPLR);
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 4; i++)
{
- uint32 val = gplr [i];
+ uint32 val = i == 3 ? gplr[64] : gplr [i];
if (old_gplr [i] != val)
{
uint32 changes = (old_gplr [i] ^ val) & ~gpioIgnore [i];
for (j = 0; j < 32; j++)
if ((changes & (1 << j))
- && ((i * 32 + j) <= 84))
+ && ((i * 32 + j) <= 118))
{
Output (L"GPLR[%d] changed to %d", i * 32 + j, (val >> j) & 1);
Log (L"GPLR[%d] changed to %d", i * 32 + j, (val >> j) & 1);
@@ -152,15 +211,15 @@ void gpioWatch (uint seconds)
}
gpdr = (uint32 *)memPhysMap (GPDR);
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 4; i++)
{
- uint32 val = gpdr [i];
+ uint32 val = i == 3 ? gpdr[64] : gpdr [i];
if (old_gpdr [i] != val)
{
uint32 changes = (old_gpdr [i] ^ val) & ~gpioIgnore [i];
for (j = 0; j < 32; j++)
if ((changes & (1 << j))
- && ((i * 32 + j) <= 84))
+ && ((i * 32 + j) <= 118))
{
Output (L"GPDR[%d] changed to %d", i * 32 + j, (val >> j) & 1);
Log (L"GPDR[%d] changed to %d", i * 32 + j, (val >> j) & 1);
@@ -170,7 +229,7 @@ void gpioWatch (uint seconds)
}
gafr = (uint32 *)memPhysMap (GAFR);
- for (i = 0; i < 6; i++)
+ for (i = 0; i < 8; i++)
{
uint32 val = gafr [i];
if (old_gafr [i] != val)
@@ -178,7 +237,7 @@ void gpioWatch (uint seconds)
uint32 changes = old_gafr [i] ^ val;
for (j = 0; j < 16; j++)
if (changes & (3 << j * 2)
- && ((i * 32 + j) <= 83))
+ && ((i * 32 + j) <= 118))
{
Output (L"GAFR[%d] changed to %d", i * 16 + j, (changes >> j * 2)
& 3);
Log (L"GAFR[%d] changed to %d", i * 16 + j, (changes >> j * 2) &
3);
@@ -193,9 +252,9 @@ void gpioWatch (uint seconds)
uint32 gpioScrGPLR (bool setval, uint32 *args, uint32 val)
{
- if (args [0] > 84)
+ if (args [0] > 118)
{
- Output (L"Valid GPIO indexes are 0..84, not %d", args [0]);
+ Output (L"Valid GPIO indexes are 0..118, not %d", args [0]);
return -1;
}
@@ -210,9 +269,9 @@ uint32 gpioScrGPLR (bool setval, uint32
uint32 gpioScrGPDR (bool setval, uint32 *args, uint32 val)
{
- if (args [0] > 84)
+ if (args [0] > 118)
{
- Output (L"Valid GPIO indexes are 0..84, not %d", args [0]);
+ Output (L"Valid GPIO indexes are 0..118, not %d", args [0]);
return -1;
}
@@ -227,9 +286,9 @@ uint32 gpioScrGPDR (bool setval, uint32
uint32 gpioScrGAFR (bool setval, uint32 *args, uint32 val)
{
- if (args [0] > 84)
+ if (args [0] > 118)
{
- Output (L"Valid GPIO indexes are 0..84, not %d", args [0]);
+ Output (L"Valid GPIO indexes are 0..118, not %d", args [0]);
return -1;
}
@@ -245,7 +304,7 @@ uint32 gpioScrGAFR (bool setval, uint32
bool gpioDump (void (*out) (void *data, const char *, ...),
void *data, uint32 *args)
{
- const uint rows = 84/4;
+ const uint rows = 30;
uint32 *grer = (uint32 *)memPhysMap (GRER);
uint32 *gfer = (uint32 *)memPhysMap (GFER);
@@ -256,8 +315,27 @@ bool gpioDump (void (*out) (void *data,
for (uint j = 0; j < 4; j++)
{
uint gpio = i + j * rows;
- bool re = (grer [gpio >> 5] & (1 << (gpio & 31))) != 0;
- bool fe = (gfer [gpio >> 5] & (1 << (gpio & 31))) != 0;
+ uint32 ofs = 0;
+ bool re = false;
+ bool fe = false;
+
+ if(gpio > 118)
+ {
+ out (data, " %s", j < 3 ? " | " : "\n");
+ continue;
+ }
+
+ if(gpio > 95)
+ {
+ ofs = 64;
+ }
+ else
+ {
+ ofs = gpio >> 5;
+ }
+
+ re = (grer [ofs] & (1 << (gpio & 31))) != 0;
+ fe = (gfer [ofs] & (1 << (gpio & 31))) != 0;
out (data, "%3d %c %d %d %s%s%s", gpio, gpioGetDir (gpio) ? 'O' : 'I',
gpioGetState (gpio), gpioGetAlt (gpio),
@@ -273,19 +351,19 @@ bool gpioDumpState (void (*out) (void *d
{
int i;
out (data, "/* GPIO pin direction setup */\n");
- for (i = 0; i < 81; i++)
+ for (i = 0; i < 118; i++)
out (data, "#define GPIO%02d_Dir\t%d\n",
i, gpioGetDir (i));
out (data, "\n/* GPIO Alternate Function (Select Function 0 ~ 3) */\n");
- for (i = 0; i < 81; i++)
+ for (i = 0; i < 118; i++)
out (data, "#define GPIO%02d_AltFunc\t%d\n",
i, gpioGetAlt (i));
out (data, "\n/* GPIO Pin Init State */\n");
- for (i = 0; i < 81; i++)
+ for (i = 0; i < 118; i++)
out (data, "#define GPIO%02d_Level\t%d\n",
i, gpioGetDir (i) ? gpioGetState (i) : 0);
out (data, "\n/* GPIO Pin Sleep Level */\n");
- for (i = 0; i < 81; i++)
+ for (i = 0; i < 118; i++)
out (data, "#define GPIO%02d_Sleep_Level\t%d\n",
i, gpioGetSleepState (i));
return true;
diff -Nupr haret/src/script.cpp haret-new/src/script.cpp
--- haret/src/script.cpp 2005-04-21 23:06:14.000000000 +0200
+++ haret-new/src/script.cpp 2006-01-13 10:44:16.000000000 +0100
@@ -46,7 +46,7 @@ static varDescriptor ScriptVars [] =
{ "CMDLINE", "Kernel command line",
varString, (uint32 *)&bootCmdline },
{ "IGPIO", "The list of GPIOs to ignore during WGPIO",
- varBitSet, (uint32 *)&gpioIgnore, 84 },
+ varBitSet, (uint32 *)&gpioIgnore, 118 },
{ "BOOTSPD", "Boot animation speed, usec/scanline (0-no delay)",
varInteger, &bootSpeed },
{ "MTYPE", "ARM machine type (see linux/arch/arm/tools/mach-types)",