[PATCH 1/9] pxa2x0_clock.c: Make clock frequency part of pxaost_softc

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/9] pxa2x0_clock.c: Make clock frequency part of pxaost_softc

Marek Vasut
---
 sys/arch/arm/xscale/pxa2x0_clock.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/sys/arch/arm/xscale/pxa2x0_clock.c b/sys/arch/arm/xscale/pxa2x0_clock.c
index 89b9c44..7644c0c 100644
--- a/sys/arch/arm/xscale/pxa2x0_clock.c
+++ b/sys/arch/arm/xscale/pxa2x0_clock.c
@@ -45,6 +45,7 @@ struct pxaost_softc {
  bus_space_tag_t sc_iot;
  bus_space_handle_t sc_ioh;
 
+ u_int32_t sc_clock_hz;
  u_int32_t sc_clock_count;
  u_int32_t sc_statclock_count;
  u_int32_t sc_statclock_step;
@@ -55,10 +56,6 @@ struct pxaost_softc {
 
 static struct pxaost_softc *pxaost_sc = NULL;
 
-#define CLK4_TIMER_FREQUENCY 32768 /* 32.768KHz */
-
-#define CLK0_TIMER_FREQUENCY 3250000 /* 3.2500MHz */
-
 #ifndef STATHZ
 #define STATHZ 64
 #endif
@@ -74,7 +71,7 @@ struct cfdriver pxaost_cd = {
 u_int pxaost_get_timecount(struct timecounter *tc);
 
 static struct timecounter pxaost_timecounter = {
- pxaost_get_timecount, NULL, 0xffffffff, CLK4_TIMER_FREQUENCY,
+ pxaost_get_timecount, NULL, 0xffffffff, 0,
  "pxaost", 0, NULL
 };
 
@@ -98,6 +95,8 @@ pxaost_attach(parent, self, aux)
 
  printf("\n");
 
+ sc->sc_clock_hz = 32768; /* OS Timer 4-11 uses 32768Hz clock */
+
  sc->sc_iot = sa->sa_iot;
 
  pxaost_sc = sc;
@@ -203,7 +202,7 @@ void
 setstatclockrate(int newstathz)
 {
  u_int32_t count;
- pxaost_sc->sc_statclock_step = CLK4_TIMER_FREQUENCY / newstathz;
+ pxaost_sc->sc_statclock_step = pxaost_sc->sc_clock_hz / newstathz;
  count = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR4);
  count += pxaost_sc->sc_statclock_step;
  pxaost_sc->sc_statclock_count = count;
@@ -233,14 +232,14 @@ cpu_initclocks()
 
  stathz = STATHZ;
  profhz = stathz;
- pxaost_sc->sc_statclock_step = CLK4_TIMER_FREQUENCY / stathz;
- pxaost_sc->sc_clock_step = CLK4_TIMER_FREQUENCY / hz;
- pxaost_sc->sc_clock_step_err_cnt = CLK4_TIMER_FREQUENCY % hz;
+ pxaost_sc->sc_statclock_step = pxaost_sc->sc_clock_hz / stathz;
+ pxaost_sc->sc_clock_step = pxaost_sc->sc_clock_hz / hz;
+ pxaost_sc->sc_clock_step_err_cnt = pxaost_sc->sc_clock_hz % hz;
  pxaost_sc->sc_clock_step_error = 0;
 
  /* Use the channels 0 and 1 for hardclock and statclock, respectively */
  pxaost_sc->sc_clock_count = pxaost_sc->sc_clock_step;
- pxaost_sc->sc_statclock_count = CLK4_TIMER_FREQUENCY / stathz;
+ pxaost_sc->sc_statclock_count = pxaost_sc->sc_clock_hz / stathz;
 
  pxa2x0_intr_establish(PXA2X0_INT_OST, IPL_CLOCK, doclockintr, 0, "clock");
 
@@ -253,6 +252,7 @@ cpu_initclocks()
  bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR5,
     clk + pxaost_sc->sc_statclock_count);
 
+ pxaost_timecounter.tc_frequency = pxaost_sc->sc_clock_hz;
  tc_init(&pxaost_timecounter);
 }
 
@@ -264,14 +264,14 @@ delay(usecs)
  volatile int j;
  int csec, usec;
 
- if (usecs > (0x80000000 / (CLK4_TIMER_FREQUENCY))) {
+ if (usecs > (0x80000000 / (pxaost_sc->sc_clock_hz))) {
  csec = usecs / 10000;
  usec = usecs % 10000;
 
- delaycnt = (CLK4_TIMER_FREQUENCY / 100) * csec +
-    (CLK4_TIMER_FREQUENCY / 100) * usec / 10000;
+ delaycnt = (pxaost_sc->sc_clock_hz / 100) * csec +
+    (pxaost_sc->sc_clock_hz / 100) * usec / 10000;
  } else {
- delaycnt = CLK4_TIMER_FREQUENCY * usecs / 1000000;
+ delaycnt = pxaost_sc->sc_clock_hz * usecs / 1000000;
  }
 
  if (delaycnt <= 1)
--
1.7.0.5

Reply | Threaded
Open this post in threaded view
|

[PATCH 2/9] pxa2x0_clock.c: Switch to OS Timer 0

Marek Vasut
---
 sys/arch/arm/xscale/pxa2x0_clock.c |   72 ++++++++++++++----------------------
 1 files changed, 28 insertions(+), 44 deletions(-)

diff --git a/sys/arch/arm/xscale/pxa2x0_clock.c b/sys/arch/arm/xscale/pxa2x0_clock.c
index 7644c0c..b781edf 100644
--- a/sys/arch/arm/xscale/pxa2x0_clock.c
+++ b/sys/arch/arm/xscale/pxa2x0_clock.c
@@ -95,7 +95,7 @@ pxaost_attach(parent, self, aux)
 
  printf("\n");
 
- sc->sc_clock_hz = 32768; /* OS Timer 4-11 uses 32768Hz clock */
+ sc->sc_clock_hz = 3250000; /* OS Timer 0 uses 3.25MHz clock */
 
  sc->sc_iot = sa->sa_iot;
 
@@ -109,16 +109,13 @@ pxaost_attach(parent, self, aux)
  bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_IR, 0);
  bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x3f);
 
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OMCR4, 0xc1);
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OMCR5, 0x41);
-
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR4,
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR0,
     pxaost_sc->sc_clock_count);
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR5,
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR1,
     pxaost_sc->sc_statclock_count);
 
  /* Zero the counter value */
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR4, 0);
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR0, 0);
 
 }
 
@@ -126,7 +123,7 @@ u_int
 pxaost_get_timecount(struct timecounter *tc)
 {
  return bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
-    OST_OSCR4);
+    OST_OSCR0);
 }
 
 int
@@ -137,7 +134,7 @@ clockintr(arg)
  u_int32_t oscr, match;
  u_int32_t match_error;
 
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x10);
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x01);
 
  match = pxaost_sc->sc_clock_count;
 
@@ -154,15 +151,15 @@ clockintr(arg)
  hardclock(frame);
 
  oscr = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
-    OST_OSCR4);
+    OST_OSCR0);
 
  } while ((signed)(oscr - match) > 0);
 
  /* prevent missed interrupts */
- if (oscr - match < 5)
- match += 5;
+ if (oscr - match < 50)
+ match += 50;
 
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR4,
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR0,
     match);
 
  return(1);
@@ -173,9 +170,9 @@ statintr(arg)
  void *arg;
 {
  struct clockframe *frame = arg;
- u_int32_t oscr, match;
+ u_int32_t oscr, match = 0;
 
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x20);
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x02);
 
  /* schedule next clock intr */
  match = pxaost_sc->sc_statclock_count;
@@ -185,14 +182,15 @@ statintr(arg)
  statclock(frame);
 
  oscr = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
-    OST_OSCR4);
+    OST_OSCR0);
 
  } while ((signed)(oscr - match) > 0);
 
  /* prevent missed interrupts */
- if (oscr - match < 5)
- match += 5;
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR5,
+ if (oscr - match < 50)
+ match += 50;
+
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR1,
     match);
 
  return(1);
@@ -203,26 +201,11 @@ setstatclockrate(int newstathz)
 {
  u_int32_t count;
  pxaost_sc->sc_statclock_step = pxaost_sc->sc_clock_hz / newstathz;
- count = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR4);
- count += pxaost_sc->sc_statclock_step;
+ count = pxaost_sc->sc_statclock_step;
+ count += bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR0);
  pxaost_sc->sc_statclock_count = count;
  bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
-    OST_OSMR5, count);
-}
-
-int
-doclockintr(void *arg)
-{
- u_int32_t status;
- int result = 0;
-
- status = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR);
- if (status & 0x10)
- result |= clockintr(arg);
- if (status & 0x20)
- result |= statintr(arg);
-
- return (result);
+    OST_OSMR1, count);
 }
 
 void
@@ -241,15 +224,16 @@ cpu_initclocks()
  pxaost_sc->sc_clock_count = pxaost_sc->sc_clock_step;
  pxaost_sc->sc_statclock_count = pxaost_sc->sc_clock_hz / stathz;
 
- pxa2x0_intr_establish(PXA2X0_INT_OST, IPL_CLOCK, doclockintr, 0, "clock");
+ pxa2x0_intr_establish(PXA2X0_INT_OST0, IPL_CLOCK, clockintr, 0, "clock");
+ pxa2x0_intr_establish(PXA2X0_INT_OST1, IPL_CLOCK, statintr, 0, "statclock");
 
- clk = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR4);
+ clk = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSCR0);
 
  bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_SR, 0x3f);
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_IR, 0x30);
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR4,
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, SAOST_IR, 0x03);
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR0,
     clk + pxaost_sc->sc_clock_count);
- bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR5,
+ bus_space_write_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh, OST_OSMR1,
     clk + pxaost_sc->sc_statclock_count);
 
  pxaost_timecounter.tc_frequency = pxaost_sc->sc_clock_hz;
@@ -287,13 +271,13 @@ delay(usecs)
  }
 
  oclock = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
-    OST_OSCR4);
+    OST_OSCR0);
 
  while (1) {
  for (j = 100; j > 0; j--)
  ;
  clock = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
-    OST_OSCR4);
+    OST_OSCR0);
  delta = clock - oclock;
  if (delta > delaycnt)
  break;
--
1.7.0.5

Reply | Threaded
Open this post in threaded view
|

[PATCH 3/9] pxa2x0_clock.c: Rework the delay() function

Marek Vasut
In reply to this post by Marek Vasut
---
 sys/arch/arm/xscale/pxa2x0_clock.c |   44 +++++++++++++----------------------
 1 files changed, 16 insertions(+), 28 deletions(-)

diff --git a/sys/arch/arm/xscale/pxa2x0_clock.c b/sys/arch/arm/xscale/pxa2x0_clock.c
index b781edf..8ea5072 100644
--- a/sys/arch/arm/xscale/pxa2x0_clock.c
+++ b/sys/arch/arm/xscale/pxa2x0_clock.c
@@ -241,26 +241,10 @@ cpu_initclocks()
 }
 
 void
-delay(usecs)
- u_int usecs;
+delay(u_int usecs)
 {
- u_int32_t clock, oclock, delta, delaycnt;
+ u_int32_t ost, i;
  volatile int j;
- int csec, usec;
-
- if (usecs > (0x80000000 / (pxaost_sc->sc_clock_hz))) {
- csec = usecs / 10000;
- usec = usecs % 10000;
-
- delaycnt = (pxaost_sc->sc_clock_hz / 100) * csec +
-    (pxaost_sc->sc_clock_hz / 100) * usec / 10000;
- } else {
- delaycnt = pxaost_sc->sc_clock_hz * usecs / 1000000;
- }
-
- if (delaycnt <= 1)
- for (j = 100; j > 0; j--)
- ;
 
  if (!pxaost_sc) {
  /* clock isn't initialized yet */
@@ -270,16 +254,20 @@ delay(usecs)
  return;
  }
 
- oclock = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
-    OST_OSCR0);
+ /* 1us == 3.25 ticks on pxa27x */
+ /* 1us == 3.6864 ticks on pxa25x and 26x */
+ i = usecs / 1000000;
+ usecs %= 1000000;
 
- while (1) {
- for (j = 100; j > 0; j--)
- ;
- clock = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
-    OST_OSCR0);
- delta = clock - oclock;
- if (delta > delaycnt)
- break;
+ while (i--) {
+ ost = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
+    OST_OSCR0) + pxaost_sc->sc_clock_hz; /* 1s ahead */
+ while((signed)(ost - bus_space_read_4(pxaost_sc->sc_iot,
+ pxaost_sc->sc_ioh, OST_OSCR0)) > 0);
  }
+
+ ost = bus_space_read_4(pxaost_sc->sc_iot, pxaost_sc->sc_ioh,
+    OST_OSCR0) + ((pxaost_sc->sc_clock_hz * usecs) / 1000000);
+ while((signed)(ost - bus_space_read_4(pxaost_sc->sc_iot,
+ pxaost_sc->sc_ioh, OST_OSCR0)) > 0);
 }
--
1.7.0.5

Reply | Threaded
Open this post in threaded view
|

[PATCH 4/9] pxa2x0_clock.c: Setup clock correctly on pxa25x and pxa26x

Marek Vasut
In reply to this post by Marek Vasut
---
 sys/arch/arm/xscale/pxa2x0_clock.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/sys/arch/arm/xscale/pxa2x0_clock.c b/sys/arch/arm/xscale/pxa2x0_clock.c
index 8ea5072..0da4b22 100644
--- a/sys/arch/arm/xscale/pxa2x0_clock.c
+++ b/sys/arch/arm/xscale/pxa2x0_clock.c
@@ -95,7 +95,10 @@ pxaost_attach(parent, self, aux)
 
  printf("\n");
 
- sc->sc_clock_hz = 3250000; /* OS Timer 0 uses 3.25MHz clock */
+ if ((cputype & ~CPU_ID_XSCALE_COREREV_MASK) == CPU_ID_PXA27X)
+ sc->sc_clock_hz = 3250000; /* OS Timer 0 uses 3.25MHz clock */
+ else
+ sc->sc_clock_hz = 3686400; /* OS Timer 0 uses 3.6864MHz clock */
 
  sc->sc_iot = sa->sa_iot;
 
--
1.7.0.5

Reply | Threaded
Open this post in threaded view
|

[PATCH 5/9] pxa2x0_mmc.c: Make available for pxa25x and pxa26x

Marek Vasut
In reply to this post by Marek Vasut
---
 sys/arch/arm/xscale/pxa2x0_mmc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sys/arch/arm/xscale/pxa2x0_mmc.c b/sys/arch/arm/xscale/pxa2x0_mmc.c
index b8be421..27b90a0 100644
--- a/sys/arch/arm/xscale/pxa2x0_mmc.c
+++ b/sys/arch/arm/xscale/pxa2x0_mmc.c
@@ -108,7 +108,7 @@ int sdhcdebug = 0; /* XXX must be named sdhcdebug for sdmmc.c */
 int
 pxammc_match(void)
 {
- return (cputype & ~CPU_ID_XSCALE_COREREV_MASK) == CPU_ID_PXA27X;
+ return 1;
 }
 
 void
--
1.7.0.5

Reply | Threaded
Open this post in threaded view
|

[PATCH 6/9] pxa2x0_mmc.c: Move GPIO configuration to platform specific files

Marek Vasut
In reply to this post by Marek Vasut
---
 sys/arch/arm/xscale/pxa2x0_mmc.c |   20 --------------------
 sys/arch/zaurus/dev/scoop_mmc.c  |    6 ++++++
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/sys/arch/arm/xscale/pxa2x0_mmc.c b/sys/arch/arm/xscale/pxa2x0_mmc.c
index 27b90a0..82eca88 100644
--- a/sys/arch/arm/xscale/pxa2x0_mmc.c
+++ b/sys/arch/arm/xscale/pxa2x0_mmc.c
@@ -43,14 +43,6 @@
 #include <dev/sdmmc/sdmmcreg.h>
 #include <dev/sdmmc/sdmmcvar.h>
 
-/* GPIO pins */
-#define PXAMMC_MMCLK 32
-#define PXAMMC_MMCMD 112
-#define PXAMMC_MMDAT0 92
-#define PXAMMC_MMDAT1 109
-#define PXAMMC_MMDAT2 110
-#define PXAMMC_MMDAT3 111
-
 int pxammc_host_reset(sdmmc_chipset_handle_t);
 u_int32_t pxammc_host_ocr(sdmmc_chipset_handle_t);
 int pxammc_host_maxblklen(sdmmc_chipset_handle_t);
@@ -158,18 +150,6 @@ pxammc_attach(struct pxammc_softc *sc, void *aux)
  printf(": MMC/SD/SDIO controller\n");
 
  /*
- * Configure the GPIO pins.  In SD/MMC mode, all pins except
- * MMCLK are bidirectional and the direction is controlled in
- * hardware without our assistence.
- */
- pxa2x0_gpio_set_function(PXAMMC_MMCLK, GPIO_ALT_FN_2_OUT);
- pxa2x0_gpio_set_function(PXAMMC_MMCMD, GPIO_ALT_FN_1_IN);
- pxa2x0_gpio_set_function(PXAMMC_MMDAT0, GPIO_ALT_FN_1_IN);
- pxa2x0_gpio_set_function(PXAMMC_MMDAT1, GPIO_ALT_FN_1_IN);
- pxa2x0_gpio_set_function(PXAMMC_MMDAT2, GPIO_ALT_FN_1_IN);
- pxa2x0_gpio_set_function(PXAMMC_MMDAT3, GPIO_ALT_FN_1_IN);
-
- /*
  * Reset the host controller and unmask normal interrupts.
  */
  (void)pxammc_host_reset(sc);
diff --git a/sys/arch/zaurus/dev/scoop_mmc.c b/sys/arch/zaurus/dev/scoop_mmc.c
index 3af95d7..cfae822 100644
--- a/sys/arch/zaurus/dev/scoop_mmc.c
+++ b/sys/arch/zaurus/dev/scoop_mmc.c
@@ -56,6 +56,12 @@ scoop_mmc_attach(struct device *parent, struct device *self, void *aux)
  sc->tag.set_power = scoop_mmc_set_power;
 
  sc->sc_gpio_detect = GPIO_MMC_DETECT;
+ pxa2x0_gpio_set_function(32, GPIO_ALT_FN_2_OUT);
+ pxa2x0_gpio_set_function(112, GPIO_ALT_FN_1_IN);
+ pxa2x0_gpio_set_function(92, GPIO_ALT_FN_1_IN);
+ pxa2x0_gpio_set_function(109, GPIO_ALT_FN_1_IN);
+ pxa2x0_gpio_set_function(110, GPIO_ALT_FN_1_IN);
+ pxa2x0_gpio_set_function(111, GPIO_ALT_FN_1_IN);
 
  pxammc_attach(sc, aux);
 }
--
1.7.0.5

Reply | Threaded
Open this post in threaded view
|

[PATCH 7/9] Palm: copy-patch dumb APM implementation, allows CPU scaling

Marek Vasut
In reply to this post by Marek Vasut
---
 sys/arch/palm/conf/GENERIC    |    3 +
 sys/arch/palm/conf/RAMDISK    |    3 +
 sys/arch/palm/conf/files.palm |    3 +
 sys/arch/palm/dev/palm_apm.c  |  195 +++++++++++++++++++++++++++++++++++++++++
 sys/arch/palm/dev/palm_apm.h  |   20 ++++
 5 files changed, 224 insertions(+), 0 deletions(-)
 create mode 100644 sys/arch/palm/dev/palm_apm.c
 create mode 100644 sys/arch/palm/dev/palm_apm.h

diff --git a/sys/arch/palm/conf/GENERIC b/sys/arch/palm/conf/GENERIC
index 419b611..feff44d 100644
--- a/sys/arch/palm/conf/GENERIC
+++ b/sys/arch/palm/conf/GENERIC
@@ -217,6 +217,9 @@ owid* at onewire? # ID
 owsbm* at onewire? # Smart Battery Monitor
 owtemp* at onewire? # Temperature
 
+# APM emulation
+apm0 at pxaip?
+
 # Pseudo-Devices
 pseudo-device wsmux 2 # mouse & keyboard multiplexor
 pseudo-device hotplug 1 # devices hot plugging
diff --git a/sys/arch/palm/conf/RAMDISK b/sys/arch/palm/conf/RAMDISK
index 9c3cfd7..c8c40c9 100644
--- a/sys/arch/palm/conf/RAMDISK
+++ b/sys/arch/palm/conf/RAMDISK
@@ -152,6 +152,9 @@ wskbd0 at pxa27x_kpc0 mux 1
 lcd0 at pxaip? addr 0x44000000
 wsdisplay* at lcd? console ?
 
+# APM emulation
+apm0 at pxaip?
+
 # Pseudo-Devices
 pseudo-device wsmux 2 # mouse & keyboard multiplexor
 #pseudo-device crypto 1
diff --git a/sys/arch/palm/conf/files.palm b/sys/arch/palm/conf/files.palm
index bb756a8..6f960ca 100644
--- a/sys/arch/palm/conf/files.palm
+++ b/sys/arch/palm/conf/files.palm
@@ -32,6 +32,9 @@ file arch/palm/palm/palm_lcd.c lcd_pxaip
 attach pxammc at pxaip with pxammc_palm
 file arch/palm/dev/palm_mmc.c pxammc_palm
 
+# Power manager and APM emulation
+attach apm at pxaip with pxaapm_palm
+file arch/palm/dev/palm_apm.c pxaapm_palm
 #
 # Machine-independent ATA drivers
 #
diff --git a/sys/arch/palm/dev/palm_apm.c b/sys/arch/palm/dev/palm_apm.c
new file mode 100644
index 0000000..fa527d2
--- /dev/null
+++ b/sys/arch/palm/dev/palm_apm.c
@@ -0,0 +1,195 @@
+/* $OpenBSD: src/sys/arch/zaurus/dev/zaurus_apm.c,v 1.13 2006/12/12 23:14:28 dim Exp $ */
+
+/*
+ * Copyright (c) 2005 Uwe Stuehler <[hidden email]>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/timeout.h>
+#include <sys/conf.h>
+#include <sys/sysctl.h>
+
+#include <arm/xscale/pxa2x0reg.h>
+#include <arm/xscale/pxa2x0var.h>
+#include <arm/xscale/pxa2x0_apm.h>
+#include <arm/xscale/pxa2x0_gpio.h>
+
+#include <palm/dev/palm_apm.h>
+
+#if defined(APMDEBUG)
+#define DPRINTF(x) printf x
+#else
+#define DPRINTF(x) /**/
+#endif
+
+struct papm_softc {
+ struct pxa2x0_apm_softc sc;
+ struct timeout sc_poll;
+ struct timeval sc_lastbattchk;
+ int sc_suspended;
+ u_int sc_event;
+};
+
+int apm_match(struct device *, void *, void *);
+void apm_attach(struct device *, struct device *, void *);
+
+struct cfattach pxaapm_palm_ca = {
+        sizeof (struct papm_softc), apm_match, apm_attach
+};
+extern struct cfdriver apm_cd;
+
+/* Prototypes */
+
+int papm_get_event(struct pxa2x0_apm_softc *, u_int *);
+void papm_suspend(struct pxa2x0_apm_softc *);
+int papm_resume(struct pxa2x0_apm_softc *);
+void pxa2x0_setperf(int);
+int pxa2x0_cpuspeed(int *);
+
+
+int
+apm_match(struct device *parent, void *match, void *aux)
+{
+ return (1);
+}
+
+void
+apm_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct papm_softc *sc = (struct papm_softc *)self;
+
+ sc->sc_event = APM_NOEVENT;
+ sc->sc.sc_get_event = papm_get_event;
+ sc->sc.sc_suspend = papm_suspend;
+ sc->sc.sc_resume = papm_resume;
+
+ pxa2x0_apm_attach_sub(&sc->sc);
+
+ cpu_setperf = pxa2x0_setperf;
+ cpu_cpuspeed = pxa2x0_cpuspeed;
+}
+
+/*
+ * apm_thread() calls this routine approximately once per second.
+ */
+int
+papm_get_event(struct pxa2x0_apm_softc *pxa_sc, u_int *typep)
+{
+ struct papm_softc *sc = (struct papm_softc *)pxa_sc;
+ int s;
+
+ s = splsoftclock();
+
+ *typep = sc->sc_event;
+ sc->sc_event = APM_NOEVENT;
+
+ splx(s);
+ return 1;
+}
+
+/*
+ * Called before suspending when all powerhooks are done.
+ */
+void
+papm_suspend(struct pxa2x0_apm_softc *pxa_sc)
+{
+ struct papm_softc *sc = (struct papm_softc *)pxa_sc;
+
+ /* Poll in suspended mode and forget the discharge timeout. */
+ sc->sc_suspended = 1;
+ timeout_del(&sc->sc_poll);
+
+ /* Make sure charging is enabled and RTC alarm is set. */
+ timerclear(&sc->sc_lastbattchk);
+
+ pxa2x0_wakeup_config(PXA2X0_WAKEUP_ALL, 1);
+}
+
+/*
+ * Called after wake-up from suspend with interrupts still disabled,
+ * before any powerhooks are done.
+ */
+int
+papm_resume(struct pxa2x0_apm_softc *pxa_sc)
+{
+ struct papm_softc *sc = (struct papm_softc *)pxa_sc;
+ int wakeup = 0;
+
+ sc->sc_suspended = 0;
+ pxa2x0_rtc_setalarm(0);
+
+ return (wakeup);
+}
+
+void
+papm_poweroff(void)
+{
+ struct pxa2x0_apm_softc *sc;
+
+ KASSERT(apm_cd.cd_ndevs > 0 && apm_cd.cd_devs[0] != NULL);
+ sc = apm_cd.cd_devs[0];
+
+ dopowerhooks(PWR_SUSPEND);
+
+ /* XXX enable charging during suspend */
+
+ /* XXX keep power LED state during suspend */
+
+ /* XXX do the same thing for GPIO 43 (BTTXD) */
+
+ /* XXX scoop power down */
+
+ /* XXX set PGSRn and GPDRn */
+
+ pxa2x0_wakeup_config(PXA2X0_WAKEUP_ALL, 1);
+
+ do {
+ pxa2x0_apm_sleep(sc);
+ }
+ while (!papm_resume(sc));
+
+ papm_restart();
+
+ /* NOTREACHED */
+ dopowerhooks(PWR_RESUME);
+}
+
+/*
+ * Do a GPIO reset, immediately causing the processor to begin the normal
+ * boot sequence.  See 2.7 Reset in the PXA27x Developer's Manual for the
+ * summary of effects of this kind of reset.
+ */
+void
+papm_restart(void)
+{
+ if (apm_cd.cd_ndevs > 0 && apm_cd.cd_devs[0] != NULL) {
+ struct pxa2x0_apm_softc *sc = apm_cd.cd_devs[0];
+ int rv;
+
+ /*
+ * Reduce the ROM Delay Next Access and ROM Delay First
+ * Access times for synchronous flash connected to nCS1.
+ */
+ rv = bus_space_read_4(sc->sc_iot, sc->sc_memctl_ioh,
+    MEMCTL_MSC0);
+ if ((rv & 0xffff0000) == 0x7ff00000)
+ bus_space_write_4(sc->sc_iot, sc->sc_memctl_ioh,
+    MEMCTL_MSC0, (rv & 0xffff) | 0x7ee00000);
+ }
+
+ delay(1000000);
+}
diff --git a/sys/arch/palm/dev/palm_apm.h b/sys/arch/palm/dev/palm_apm.h
new file mode 100644
index 0000000..cda1482
--- /dev/null
+++ b/sys/arch/palm/dev/palm_apm.h
@@ -0,0 +1,20 @@
+/* $OpenBSD: src/sys/arch/zaurus/dev/zaurus_apm.h,v 1.1 2005/04/11 03:21:03 uwe Exp $ */
+
+/*
+ * Copyright (c) 2005 Uwe Stuehler <[hidden email]>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+void papm_poweroff(void);
+void papm_restart(void);
--
1.7.0.5

Reply | Threaded
Open this post in threaded view
|

[PATCH 9/9] WM1613 touchscreen driver

Marek Vasut
In reply to this post by Marek Vasut
---
 sys/arch/palm/conf/GENERIC    |    5 +
 sys/arch/palm/conf/RAMDISK    |    6 +
 sys/arch/palm/conf/files.palm |    4 +
 sys/arch/palm/dev/palm_tsc.c  |  361 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 376 insertions(+), 0 deletions(-)
 create mode 100644 sys/arch/palm/dev/palm_tsc.c

diff --git a/sys/arch/palm/conf/GENERIC b/sys/arch/palm/conf/GENERIC
index feff44d..c12bf82 100644
--- a/sys/arch/palm/conf/GENERIC
+++ b/sys/arch/palm/conf/GENERIC
@@ -33,6 +33,7 @@ option WSDISPLAY_DEFAULTSCREENS=2 # initial number of text consoles
 option WSDISPLAY_COMPAT_PCVT # emulate some ioctls; needed for X11
 
 option USBVERBOSE
+option APERTURE
 
 config bsd root on sd1a swap on sd1b
 
@@ -220,6 +221,10 @@ owtemp* at onewire? # Temperature
 # APM emulation
 apm0 at pxaip?
 
+# Touchscreen
+palm_tsc0 at pxaip? addr 0x40500000 size 0x10000
+wsmouse* at palm_tsc? mux 0
+
 # Pseudo-Devices
 pseudo-device wsmux 2 # mouse & keyboard multiplexor
 pseudo-device hotplug 1 # devices hot plugging
diff --git a/sys/arch/palm/conf/RAMDISK b/sys/arch/palm/conf/RAMDISK
index c8c40c9..b22e09f 100644
--- a/sys/arch/palm/conf/RAMDISK
+++ b/sys/arch/palm/conf/RAMDISK
@@ -36,6 +36,8 @@ option WSDISPLAY_COMPAT_RAWKBD # provide raw scancodes; needed for X11
 option WSDISPLAY_DEFAULTSCREENS=2 # initial number of text consoles
 option WSDISPLAY_COMPAT_PCVT # emulate some ioctls; needed for X11
 
+option APERTURE
+
 config bsd root on rd0a swap on rd0b
 
 # The main bus device
@@ -155,6 +157,10 @@ wsdisplay* at lcd? console ?
 # APM emulation
 apm0 at pxaip?
 
+# Touchscreen
+palm_tsc0 at pxaip? addr 0x40500000 size 0x10000
+wsmouse* at palm_tsc? mux 0
+
 # Pseudo-Devices
 pseudo-device wsmux 2 # mouse & keyboard multiplexor
 #pseudo-device crypto 1
diff --git a/sys/arch/palm/conf/files.palm b/sys/arch/palm/conf/files.palm
index 6f960ca..94d8351 100644
--- a/sys/arch/palm/conf/files.palm
+++ b/sys/arch/palm/conf/files.palm
@@ -72,6 +72,10 @@ file arch/palm/dev/palm_udc.c pxaudc_palm
 attach pxa27x_kpc at pxaip with pxakpc_palm
 file arch/palm/dev/palm_kpc.c pxakpc_palm
 
+device palm_tsc: wsmousedev
+attach palm_tsc at pxaip
+file arch/palm/dev/palm_tsc.c palm_tsc needs-flag
+
 # Bluetooth
 include "dev/bluetooth/files.bluetooth"
 
diff --git a/sys/arch/palm/dev/palm_tsc.c b/sys/arch/palm/dev/palm_tsc.c
new file mode 100644
index 0000000..0a2ec04
--- /dev/null
+++ b/sys/arch/palm/dev/palm_tsc.c
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2009 Marek Vasut <[hidden email]>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/timeout.h>
+#include <sys/kernel.h>
+
+#include <arm/xscale/pxa2x0reg.h>
+#include <arm/xscale/pxa2x0_gpio.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <arm/xscale/pxa2x0var.h>
+#include <arm/xscale/pxa2x0_lcd.h>
+
+struct tsscale {
+ int minx, maxx;
+ int miny, maxy;
+ int swapxy;
+ int resx, resy;
+} palm_tsc_scale = {
+ 0x128, 0xe8f, 0xa0, 0xf40, 0, 324, 484
+};
+
+struct palm_tsc_softc {
+ struct device sc_dev;
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+
+
+ struct timeout sc_ts_poll;
+ void *sc_touch_ih;
+ struct device *sc_wsmousedev;
+ int sc_oldx;
+ int sc_oldy;
+ int sc_rawmode;
+
+ struct tsscale sc_tsscale;
+};
+
+int palm_tsc_gsrw(struct palm_tsc_softc *, int);
+int palm_tsc_read_4(struct palm_tsc_softc *, int);
+void palm_tsc_write_4(struct palm_tsc_softc *, int, int);
+
+int palm_tsc_match(struct device *, void *, void *);
+void palm_tsc_attach(struct device *, struct device *, void *);
+
+int palm_tsc_enable(void *);
+void palm_tsc_disable(void *);
+int palm_tsc_ioctl(void *, u_long, caddr_t, int, struct proc *);
+
+void palm_tsc_power(int, void *);
+void palm_tsc_poll(void *);
+int palm_tsc_irq(void *);
+
+
+struct cfattach palm_tsc_ca = {
+ sizeof(struct palm_tsc_softc), palm_tsc_match, palm_tsc_attach
+};
+
+struct cfdriver palm_tsc_cd = {
+ NULL, "palm_tsc", DV_DULL
+};
+
+const struct wsmouse_accessops palm_tsc_accessops = {
+        palm_tsc_enable,
+ palm_tsc_ioctl,
+ palm_tsc_disable
+};
+
+int
+palm_tsc_gsrw(struct palm_tsc_softc *sc, int mask)
+{
+ int timeout, val;
+ for (timeout = 5000; timeout > 0; timeout--) {
+ val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, AC97_GSR);
+ if ((val & mask) == mask)
+ return 0;
+ }
+ return 1;
+}
+int
+palm_tsc_read_4(struct palm_tsc_softc *sc, int reg)
+{
+ int ret;
+ bus_space_read_4(sc->sc_iot, sc->sc_ioh, reg);
+ if (!palm_tsc_gsrw(sc, GSR_SDONE))
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, AC97_GSR, GSR_SDONE | GSR_CDONE);
+
+ ret = bus_space_read_4(sc->sc_iot, sc->sc_ioh, reg);
+ if (!palm_tsc_gsrw(sc, GSR_SDONE))
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, AC97_GSR, GSR_SDONE | GSR_CDONE);
+
+ return ret;
+}
+
+void
+palm_tsc_write_4(struct palm_tsc_softc *sc, int reg, int val)
+{
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, reg, val);
+ if (!palm_tsc_gsrw(sc, GSR_CDONE))
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, AC97_GSR, GSR_SDONE | GSR_CDONE);
+}
+
+int
+palm_tsc_match(struct device *parent, void *cf, void *aux)
+{
+ struct pxaip_attach_args *pxa = aux;
+ return (pxa->pxa_addr == 0x40500000);
+}
+
+void
+palm_tsc_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct pxaip_attach_args *pxa = aux;
+ struct wsmousedev_attach_args a;  
+ struct palm_tsc_softc *sc = (struct palm_tsc_softc *)self;
+ int s;
+
+ s = spltty();
+ timeout_set(&sc->sc_ts_poll, palm_tsc_poll, sc);
+
+ /* Map registers */
+ sc->sc_iot = pxa->pxa_sa.sa_iot;
+ if (bus_space_map(sc->sc_iot, pxa->pxa_addr, pxa->pxa_size, 0,
+    &sc->sc_ioh) != 0) {
+     splx(s);
+ printf(": can't map regs\n");
+ return;
+ }
+
+ pxa2x0_gpio_set_function(27, GPIO_IN);
+ sc->sc_touch_ih = pxa2x0_gpio_intr_establish(27,
+ IST_EDGE_BOTH, IPL_TTY, palm_tsc_irq, sc, "palm_tscd");
+ if (sc->sc_touch_ih == NULL) {
+ splx(s);
+ printf(": can't establish touchscreen interrupt\n");
+ return;
+ }
+ pxa2x0_gpio_intr_mask(sc->sc_touch_ih);
+
+ /* Configure GPIOs */
+ pxa2x0_gpio_set_function(28, GPIO_ALT_FN_1_IN); // BITCLK
+ pxa2x0_gpio_set_function(29, GPIO_ALT_FN_1_IN); // SDATA_IN_0
+ pxa2x0_gpio_set_function(30, GPIO_ALT_FN_2_OUT); // SDATA_OUT
+ pxa2x0_gpio_set_function(31, GPIO_ALT_FN_2_OUT); // SYNC
+ pxa2x0_gpio_set_function(89, GPIO_ALT_FN_1_OUT); // SYSCLK
+ pxa2x0_gpio_set_function(95, GPIO_ALT_FN_1_OUT); // nRESET
+
+ /* Enable clock */
+ pxa2x0_clkman_config(CKEN_AC97, 1);
+ delay(100);
+
+ /* Cold reset the codec */
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, AC97_GCR, 0);
+ delay(100);
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, AC97_GCR, GCR_nCRST);
+ delay(100);
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, AC97_CAR, 0);
+
+ /* Wait for codec ready */
+ if (palm_tsc_gsrw(sc, GSR_PCRDY))
+ return;
+
+ /* init phy */
+ palm_tsc_write_4(sc, (0x200 + (0x76<<1)), 0x0030);
+ palm_tsc_write_4(sc, (0x200 + (0x78<<1)), 0x2008);
+
+ /* start TS */
+ palm_tsc_write_4(sc, (0x200 + (0x78<<1)), 0xe008);
+ palm_tsc_read_4(sc, (0x200 + (0x7a<<1)));
+
+ a.accessops = &palm_tsc_accessops;
+ a.accesscookie = sc;
+
+ /* Copy the default scale values to each softc */
+ bcopy(&palm_tsc_scale, &sc->sc_tsscale, sizeof(sc->sc_tsscale));
+
+ sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
+
+ pxa2x0_gpio_intr_unmask(sc->sc_touch_ih);
+ splx(s);
+}
+
+int
+palm_tsc_enable(void *v)
+{
+ struct palm_tsc_softc *sc = v;
+ timeout_del(&sc->sc_ts_poll);
+ return 0;
+}
+
+void
+palm_tsc_disable(void *v)
+{
+ struct palm_tsc_softc *sc = v;
+ timeout_del(&sc->sc_ts_poll);
+}
+
+void
+palm_tsc_power(int why, void *v)
+{
+ struct palm_tsc_softc *sc = v;
+ switch (why) {
+ case PWR_STANDBY:
+ case PWR_SUSPEND:
+ timeout_del(&sc->sc_ts_poll);
+ break;
+ case PWR_RESUME:
+ break;
+ }
+}
+
+void
+palm_tsc_poll(void *v)
+{
+ int s;
+ struct palm_tsc_softc *sc = v;
+ s = spltty();
+ pxa2x0_gpio_intr_unmask(sc->sc_touch_ih);
+ splx(s);
+ palm_tsc_irq(v);
+}
+
+#define TS_STABLE 8
+int
+palm_tsc_irq(void *v)
+{
+ int s;
+ int x = 0, y = 0, t;
+ int i, timeout;
+ struct palm_tsc_softc *sc = v;
+
+ s = spltty();
+
+ if (pxa2x0_gpio_get_bit(27)) {
+ timeout_add(&sc->sc_ts_poll, hz/20);
+ pxa2x0_gpio_intr_mask(sc->sc_touch_ih);
+
+ palm_tsc_write_4(sc, (0x200 + (0x54<<1)), 0xdfff);
+
+ i = 0;
+ timeout = 10;
+ while(--timeout && i < 3) {
+ palm_tsc_write_4(sc, (0x200 + (0x76<<1)), 0x9030);
+ while(palm_tsc_read_4(sc, (0x200 + (0x76<<1))) & 0x8000);
+ t = palm_tsc_read_4(sc, (0x200 + (0x7a<<1)));
+ if ((t & 0x9000) == 0x9000) {
+ x += t & 0xfff;
+ i++;
+ }
+ }
+ if (!timeout)
+ goto penrel;
+ x /= i;
+
+ i = 0;
+ timeout = 10;
+ while(--timeout && i < 3) {
+ palm_tsc_write_4(sc, (0x200 + (0x76<<1)), 0xa030);
+ while(palm_tsc_read_4(sc, (0x200 + (0x76<<1))) & 0x8000);
+ t = palm_tsc_read_4(sc, (0x200 + (0x7a<<1)));
+ if ((t & 0xa000) == 0xa000) {
+ y += t & 0xfff;
+ i++;
+ }
+ }
+ if (!timeout)
+ goto penrel;
+ y /= i;
+
+ splx(s);
+ if (!sc->sc_rawmode) {
+ x = ((x - sc->sc_tsscale.minx) * (sc->sc_tsscale.resx)) / (sc->sc_tsscale.maxx - sc->sc_tsscale.minx);
+ y = ((y - sc->sc_tsscale.miny) * (sc->sc_tsscale.resy)) / (sc->sc_tsscale.maxy - sc->sc_tsscale.miny);
+ }
+ x = sc->sc_tsscale.maxx - x;
+ y = sc->sc_tsscale.maxy - y;
+
+ sc->sc_oldx = x;
+ sc->sc_oldy = y;
+ wsmouse_input(sc->sc_wsmousedev, 1, x, y, 0 /* z */, 0 /* w */,
+ WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
+ WSMOUSE_INPUT_ABSOLUTE_Z);
+ return 1;
+ }
+penrel:
+ splx(s);
+ wsmouse_input(sc->sc_wsmousedev, 0, sc->sc_oldx, sc->sc_oldy,
+ 0 /* z */, 0 /* w */,
+ WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
+ WSMOUSE_INPUT_ABSOLUTE_Z);
+
+ return 1;
+}
+
+int
+palm_tsc_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
+{
+ int error = 0;
+ struct palm_tsc_softc *sc = v;
+ struct wsmouse_calibcoords *wsmc = (struct wsmouse_calibcoords *)data;
+ switch (cmd) {
+ case WSMOUSEIO_SCALIBCOORDS:
+ if (!(wsmc->minx >= 0 && wsmc->maxx >= 0 &&
+    wsmc->miny >= 0 && wsmc->maxy >= 0 &&
+    wsmc->resx >= 0 && wsmc->resy >= 0 &&
+    wsmc->minx < 32768 && wsmc->maxx < 32768 &&
+    wsmc->miny < 32768 && wsmc->maxy < 32768 &&
+    wsmc->resx < 32768 && wsmc->resy < 32768 &&
+    wsmc->swapxy >= 0 && wsmc->swapxy <= 1 &&
+    wsmc->samplelen >= 0 && wsmc->samplelen <= 1))
+ return (EINVAL);
+
+ sc->sc_tsscale.minx = wsmc->minx;
+ sc->sc_tsscale.maxx = wsmc->maxx;
+ sc->sc_tsscale.miny = wsmc->miny;
+ sc->sc_tsscale.maxy = wsmc->maxy;
+ sc->sc_tsscale.swapxy = wsmc->swapxy;
+ sc->sc_tsscale.resx = wsmc->resx;
+ sc->sc_tsscale.resy = wsmc->resy;
+ sc->sc_rawmode = wsmc->samplelen;
+ break;
+ case WSMOUSEIO_GCALIBCOORDS:
+ wsmc->minx = sc->sc_tsscale.minx;
+ wsmc->maxx = sc->sc_tsscale.maxx;
+ wsmc->miny = sc->sc_tsscale.miny;
+ wsmc->maxy = sc->sc_tsscale.maxy;
+ wsmc->swapxy = sc->sc_tsscale.swapxy;
+ wsmc->resx = sc->sc_tsscale.resx;
+ wsmc->resy = sc->sc_tsscale.resy;
+ wsmc->samplelen = sc->sc_rawmode;
+ break;
+ case WSMOUSEIO_GTYPE:
+ *(u_int *)data = WSMOUSE_TYPE_TPANEL;
+ break;
+ default:
+ error = ENOTTY;
+ break;
+ }
+ return (error);
+}
--
1.7.0.5

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 9/9] WM1613 touchscreen driver

Rob Sciuk
On Sat, 17 Jul 2010, Marek Vasut wrote:

> Date: Sat, 17 Jul 2010 01:24:53 +0200
> From: Marek Vasut <[hidden email]>
> To: [hidden email]
> Cc: [hidden email], [hidden email], [hidden email],
>     Marek Vasut <[hidden email]>
> Subject: [PATCH 9/9] WM1613 touchscreen driver
>

Marek,

Thanks for the patches, much appreciated.  Two things, however:

  1.) There was no number 8 in the patch set.  Is there one?

  2.) They don't apply cleanly to the source in /usr/src ...
  you have an "a/src" and "b/src" appended to the file paths.
  how do I apply the patches cleanly??

Cheers,
Rob.

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
Robert S. Sciuk http://www.controlq.com                259 Simcoe St. S.
Control-Q Research tel: 905.576.8028 Oshawa, Ont.
[hidden email] fax: 905.576.8386   Canada, L1H 4H3

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 9/9] WM1613 touchscreen driver

Marek Vasut
Dne St 21. D
ervence 2010 18:21:03 Rob Sciuk napsal(a):

> On Sat, 17 Jul 2010, Marek Vasut wrote:
> > Date: Sat, 17 Jul 2010 01:24:53 +0200
> > From: Marek Vasut <[hidden email]>
> > To: [hidden email]
> > Cc: [hidden email], [hidden email], [hidden email],
> >
> >     Marek Vasut <[hidden email]>
> >
> > Subject: [PATCH 9/9] WM1613 touchscreen driver
>
> Marek,
>
> Thanks for the patches, much appreciated.  Two things, however:
>
>   1.) There was no number 8 in the patch set.  Is there one?

That one isn't there, it was some experimental crap.
>
>   2.) They don't apply cleanly to the source in /usr/src ...
>   you have an "a/src" and "b/src" appended to the file paths.
>   how do I apply the patches cleanly??

I used git ... git am <patch> ... or patch -Np1 -i <patch>
>
> Cheers,
> Rob.

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 9/9] WM1613 touchscreen driver

Rob Sciuk
On Thu, 22 Jul 2010, Marek Vasut wrote:

> Date: Thu, 22 Jul 2010 00:59:55 +0200
> From: Marek Vasut <[hidden email]>
> To: [hidden email]
> Cc: [hidden email]
> Subject: Re: [PATCH 9/9] WM1613 touchscreen driver
>
> Dne St 21. Dervence 2010 18:21:03 Rob Sciuk napsal(a):
>> On Sat, 17 Jul 2010, Marek Vasut wrote:
>>> Date: Sat, 17 Jul 2010 01:24:53 +0200
>>> From: Marek Vasut <[hidden email]>
>>> To: [hidden email]
>>> Cc: [hidden email], [hidden email], [hidden email],
>>>
>>>     Marek Vasut <[hidden email]>
>>>
>>> Subject: [PATCH 9/9] WM1613 touchscreen driver
>>
>> Marek,
>>
>> Thanks for the patches, much appreciated.  Two things, however:
>>
>>   1.) There was no number 8 in the patch set.  Is there one?
>
> That one isn't there, it was some experimental crap.
>>
>>   2.) They don't apply cleanly to the source in /usr/src ...
>>   you have an "a/src" and "b/src" appended to the file paths.
>>   how do I apply the patches cleanly??
>
> I used git ... git am <patch> ... or patch -Np1 -i <patch>
>>
>> Cheers,
>> Rob.

Thanks, Marek.  Building now.

Cheers,
Rob.


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
Robert S. Sciuk http://www.controlq.com                259 Simcoe St. S.
Control-Q Research tel: 905.576.8028 Oshawa, Ont.
[hidden email] fax: 905.576.8386   Canada, L1H 4H3