2009-01-12 14:20:37     BF537 TSC2046 touch screen controler

Document created by Aaronwu Employee on Aug 14, 2013
Version 1Show Document
  • View in full screen mode

2009-01-12 14:20:37     BF537 TSC2046 touch screen controler

damien OLLIVE (UNITED STATES)

Message: 67821   

 

hy,

 

I search to add a touchscreen to the BF537 stamp board.

 

I use a TSC2046 Touchscreen controler which can be work with the ads7846 driver.

 

But i have some problem :

 

The busy pin is not use by this driver?

 

the Penirq is not use too? if yes i have tried to put the PF14 pin like that in stamp.c

 

 

 

#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)

static struct bfin5xx_spi_chip spi_ads7846_chip_info = {

    .enable_dma = 0,

    .bits_per_word = 16,

};

static struct ads7846_platform_data bfin_ads7846_ts_info = {

    .model        = 7846,

    .x_max        = 0x0fff,

    .y_max        = 0x0fff,

    .x_plate_ohms    = 180,

    .pressure_max    = 255,

    .debounce_max    = 10,

    .debounce_tol    = 3,

};

#endif

 

#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)

    {

        .modalias        = "ads7846",

        .platform_data        = &bfin_ads7846_ts_info,

        .irq            = IRQ_PF14,

        .max_speed_hz    = 2500000,     /* max spi clock (SCK) speed in HZ */

        .bus_num    = 0,

        .chip_select  = 1,

        .controller_data = &spi_ads7846_chip_info,

    },

#endif

 

 

 

When i boot the kernel I have this error

 

 

 

SMSC LAN83C185: Registered new driver

bfin_mac_mdio: probed

bfin_mac: attached PHY driver [SMSC LAN83C185] (mii_bus:phy_addr=0:01, irq=-1, mdc_clk=2500000Hz(mdc_div=19)@sclk=100MHz)

bfin_mac: Version 1.1, Blackfin BF53[67] BF527 on-chip Ethernet MAC driver

bfin-spi bfin-spi.0: Blackfin BF5xx on-chip SPI Contoller Driver, Version 1.0, regs_base@ffc00500, dma channel@7

ads7846: probe of spi0.1 failed with error -22

rtc-bfin rtc-bfin: rtc core: registered rtc-bfin as rtc0

i2c-bfin-twi i2c-bfin-twi.0: Blackfin BF5xx on-chip I2C TWI Contoller Driver, Version 1.8, regs_base@ffc01400

TCP cubic registered

NET: Registered protocol family 1

NET: Registered protocol family 17

rtc-bfin rtc-bfin: setting the system clock to 1970-01-01 01:06:50 (4010)

Freeing unused kernel memory: 6280k freed

 

 

I don't know how debug it, what is an error 22 by a driver

 

could you help me please

 

damien

QuoteReplyEditDelete

 

 

2009-01-12 14:38:05     Re: BF537 TSC2046 touch screen controler

Mike Frysinger (UNITED STATES)

Message: 67822   

 

all errors in the kernel are standard errno values.  look in the errno headers to figure out what exactly a specific number is for.

 

grep 22 include/*/*errno* arch/blackfin/include/asm/*errno*

QuoteReplyEditDelete

 

 

2009-01-12 15:52:28     Re: BF537 TSC2046 touch screen controler

damien OLLIVE (UNITED STATES)

Message: 67824   

 

Thanks

 

the error 22 is an Invalid argument... The problem is to found it.

 

I have tried to boot the kernel with the driver of the AD7877 to know if the error come from the driver or from the spi and i haven't the error 22 and just

 

spi0.1: Failed to probe AD7877 Touchscreen that's looks normal because i have a tsc 2046.

 

that should mean that the error come from the configuration of my driver. I have try to configure it in stamp.c with the help of ad7877 configuration and the boardnokia770.c which use the same controler.

 

 

 

 

 

#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)

static struct bfin5xx_spi_chip spi_ads7846_chip_info = {

    .enable_dma = 0,

    .bits_per_word = 16,

};

static struct ads7846_platform_data bfin_ads7846_ts_info = {

    .model        = 7846,

    .x_max        = 0x0fff,

    .y_max        = 0x0fff,

    .x_plate_ohms    = 180,

    .pressure_max    = 255,

    .debounce_max    = 10,

    .debounce_tol    = 3,

};

#endif

 

 

 

#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)

    {

        .modalias        = "ads7846",

        .platform_data        = &bfin_ads7846_ts_info,

        .irq            = IRQ_PF10,

        .max_speed_hz    = 2500000,     /* max spi clock (SCK) speed in HZ */

        .bus_num    = 0,

        .chip_select  = 1,

        .controller_data = &spi_ads7846_chip_info,

    },

#endif

 

I have to do something else?

 

Do you read an error in this file?

 

I hope there isn't an error in the driver, i haven't modify it.

 

 

QuoteReplyEditDelete

 

 

2009-01-12 16:05:00     Re: BF537 TSC2046 touch screen controler

Mike Frysinger (UNITED STATES)

Message: 67825   

 

so enabling debugging in the ads7846 driver by putting '#define DEBUG' at the top of it.  most likely your speed is wrong (too fast).

QuoteReplyEditDelete

 

 

2009-01-12 18:42:06     Re: BF537 TSC2046 touch screen controler

damien OLLIVE (UNITED STATES)

Message: 67828   

 

Ok the problem was the get_pendown_state function

 

     if (pdata->get_pendown_state == NULL) {

         dev_dbg(&spi->dev, "no get_pendown_state function?\n");

         return -EINVAL;

     }

 

the kernel panic without this function.

 

1/ I haven't found this function get_pendown_state, could you show me where can i find it?

 

I Have written one in stamp.c which return the states of the pin, but nothing hapen after the call of this function.

 

static int ads7846_pendown_state(void)

{

int valeur;

 

    valeur = gpio_get_value(GPIO_PF7);

    printk("stqtesgpio %d\n",valeur);

     return valeur;

}

 

 

static struct ads7846_platform_data bfin_ads7846_ts_info = {

    .model        = 7846,

    .x_max        = 0x0fff,

    .y_max        = 0x0fff,

    .x_plate_ohms    = 180,

    .pressure_max    = 255,

    .debounce_max    = 10,

    .debounce_tol    = 3,

    .get_pendown_state = ads7846_pendown_state,

};

#endif

 

 

 

2/ What the function get_pendown_state have to do?

 

I am not sure that the driver working,

 

 

 

The boot running well, create the event0 file and fs0, i can test the irq, when i touch the screen the function ads7846_pendown_state is launching, but i have nothing after : no X and Y and nothing in the SPI (no CLK, no data)

 

3/ this driver have been testing? Do you have an idea of the problem?

 

 

 

bfin-spi bfin-spi.0: Blackfin BF5xx on-chip SPI Contoller Driver, Version 1.0, regs_base@ffc00500, dma channel@7

ads7846 spi0.1: touchscreen, irq 57

input: ADS784x Touchscreen as /class/input/input0

 

 

 

root:/> cd dev/input/

root:/dev/input> ls

event0  ts0

root:/dev/input>

 

root:/dev/input> event_test event0

Input driver version is 1.0.0

Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0

Input device name: "ADS784x Touchscreen"

Supported events:

  Event type 0 (Reset)

    Event code 0 (Reset)

    Event code 1 (Key)

    Event code 3 (Absolute)

  Event type 1 (Key)

    Event code 330 (Touch)

  Event type 3 (Absolute)

    Event code 0 (X)

      Value      0

      Min        0

      Max     4095

    Event code 1 (Y)

      Value      0

      Min        0

      Max     4095

    Event code 24 (Pressure)

      Value      0

      Min        0

      Max      255

Testing ... (interrupt to exit)

QuoteReplyEditDelete

 

 

2009-01-13 17:23:46     Re: BF537 TSC2046 touch screen controler

damien OLLIVE (UNITED STATES)

Message: 67896   

 

Hy,

 

I have spend my day to work on the driver but I don't understand it yet.

 

the initialization of the driver looks to work well during the boot :

 

bfin_mac: Version 1.1, Blackfin BF53[67] BF527 on-chip Ethernet MAC driver

bfin-spi bfin-spi.0: Blackfin BF5xx on-chip SPI Contoller Driver, Version 1.0, regs_base@ffc00500, dma channel@7

ads7846 spi0.1: assuming 2.5V internal vREF

ads7846 spi0.1: touchscreen, irq 57

input: ADS784x Touchscreen as /class/input/input0

evbug.c: Connected device: "ADS784x Touchscreen", spi0.1/input0

 

But after when i try to use the touch screen the interrupt is detected and the function irqreturn and get_pendown_state are launched but nothing happen with the SPI.

 

I receive the interruption in event0 but thats all

 

 

 

 

If you can help me to start to understand this driver

 

There isn't any information about the Busy signal in this driver, could you confirm that it's not use (that possible, it's just an image of the CS)

 

What the driver should do when he receive the interrupt? (nothing happen, no timer and no communication Start).

 

I will try to read an simple SPI driver that will maibe help to understand this one, but if you could help that will be great

QuoteReplyEditDelete

 

 

2009-01-13 21:26:12     Re: BF537 TSC2046 touch screen controler

Mike Frysinger (UNITED STATES)

Message: 67900   

 

as i said, we've never tested this hardware let alone the driver as we've never had any boards.  i cant tell you how the driver works because we dont know.

 

there are boards in the tree that apparently use it.  grep the arch/ subdirectory for "ads7846".

QuoteReplyEditDelete

 

 

2009-01-19 16:31:15     Re: BF537 TSC2046 touch screen controler

damien OLLIVE (UNITED STATES)

Message: 68128   

 

I have a problem in my attempt to modify this driver.

 

the ADS7846 is the base which Michael Hennerich have changed to writting the AD7877 driver there are close.

 

My problem is that the Mosi signal of the SPI is high during the time that i don't use it (always high exept when i writting the control bytes) and so the controller understand that i want to give him the control data. I don't understand when i can change it, could you help me please?

QuoteReplyEditDelete

 

 

2009-01-20 11:38:39     Re: BF537 TSC2046 touch screen controler

damien OLLIVE (UNITED STATES)

Message: 68156   

 

I have the same problem with spidev driver when i want to read the mosi of the blackfin is high.

 

Is it possible to have a low MOSI when i read by SPI?

QuoteReplyEditDelete

 

 

2009-01-20 12:45:20     Re: BF537 TSC2046 touch screen controler

damien OLLIVE (UNITED STATES)

Message: 68160   

 

I think that i was wrong in the last post, the problem in this driver isn't that the Mosi is high but more than the Cheap Select do high betweem the config write and the read of the answer of the Toush Screen controler.

 

I try to keep the CS low during all the exange if somebody have an idea about it

QuoteReplyEditDelete

 

 

2009-01-20 14:50:52     Re: BF537 TSC2046 touch screen controler

Michael Hennerich (GERMANY)

Message: 68161   

 

 

If you want to have the SPI SSEL asserted the entire transfer, you need to use SPI_MODE3 (CPOL | CPHA) rather than SPI_MODE0.

In most cases MODE 0 and 3 can be used alternatively.

 

If the devices depends on MODE0 - on kernel trunk there is now the option to use GPIO controlled SPI SSEL.

 

Take a look at the enc28j60 platform board example.

 

-Michael

QuoteReplyEditDelete

 

 

2009-01-26 10:21:17     Re: BF537 TSC2046 touch screen controler

damien OLLIVE (UNITED STATES)

Message: 68348   

 

Thanks michael,

 

I have try the mode 3 that assert the SSEL during the transfer (i haven't understood why but that done)

 

But the problem with this mode is that my device don't take the first edge down and miss one at the end.

 

So i am return to the mode 0 and i have created a SSEL by an GPIO : PF4. (I haven't understood the enc28j60, it's not really easy to use a code writting by other about something that i don't understand well yet)

 

So my driver is working exept an filter problem : i have more value that i want for an event and just the first is good, i have to try to filter it.

 

 

 

But my big problem is that when i want to use my SPI touchscreen controler driver(base on ads7846) with my TFTLCD driver (base on lq035 driver) they don't work together.

 

I use tmr0, tmr1 and tmr5 but not the TMR2 in my lcd driver and i use the PF7 pin to the irq of the TScreen.

 

I use PF3 to creat the SSEL for the SPI ToushScreen (and i don't use the tmr 6 and the uart1)

 

 

 

There is something in the lq035 driver which can affect the SPI?

 

If you have an idea

QuoteReplyEditDelete

 

 

2009-01-26 10:44:48     Re: BF537 TSC2046 touch screen controler

Michael Hennerich (GERMANY)

Message: 68349   

 

 

Check  docs.blackfin.uclinux.org/doku.php?id=spi

again – today I added some notes about the Slave Select Line behavior based on different SPI_MODEs.

 

I didn’t say that you should look at the enc28j60 driver source – I only wanted to give you the hint on using GPIO controlled SPI selects.

(bfin5xx_spi_chip.cs_gpio = GPIO_PXxx and spi_board_info[].chip_select = 0)

 

If you would use an AD7879 or AD7877 touch screen digitizer all the filtering would be done inside the touch screen controller.

Typically there is no relation between Display Driver and Touch Screen.

 

Do you get resource conflict error messages during kernel startup or module loading?

What kernel version are you using?

 

-Michael

QuoteReplyEditDelete

 

 

2009-01-26 17:08:17     Re: BF537 TSC2046 touch screen controler

damien OLLIVE (UNITED STATES)

Message: 68361   

 

hy,

 

 

Thanks for the information about the SPI, my kernel is Linux-2.6.22.19-ADI-2008R1.5-svn and i have spend a lot of time to have a driver for the toush screen and for the LCD and i haven't time to do it again with the next revision of the kernel, i will try it after that working.

 

my toush screen driver working alone with an event test

 

root:/> event_test dev/input/event0

Input driver version is 1.0.0

Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0

Input device name: "ADS784x Touchscreen"

Supported events:

  Event type 0 (Reset)

    Event code 0 (Reset)

    Event code 1 (Key)

    Event code 3 (Absolute)

  Event type 1 (Key)

    Event code 330 (Touch)

  Event type 3 (Absolute)

    Event code 0 (X)

      Value   2695

      Min      150

      Max     4095

    Event code 1 (Y)

      Value   3207

      Min      190

      Max     4095

    Event code 24 (Pressure)

      Value    231

      Min        0

      Max      255

Testing ... (interrupt to exit)

Event: time 5212.499099, type 3 (Absolute), code 0 (X), value 2439

Event: time 5212.499177, type 3 (Absolute), code 1 (Y), value 2567

Event: time 5212.499220, type 3 (Absolute), code 24 (Pressure), value 164

Event: time 5212.499262, type 0 (Reset), code 0 (Reset), value 0

Event: time 5212.499097, type 3 (Absolute), code 0 (X), value 2439

Event: time 5212.499176, type 3 (Absolute), code 1 (Y), value 2567

Event: time 5212.499219, type 3 (Absolute), code 24 (Pressure), value 164

Event: time 5212.499261, type 0 (Reset), code 0 (Reset), value 0

Event: time 5213.875095, type 3 (Absolute), code 0 (X), value 3591

Event: time 5213.875172, type 3 (Absolute), code 1 (Y), value 2695

Event: time 5213.875215, type 3 (Absolute), code 24 (Pressure), value 181

Event: time 5213.875256, type 0 (Reset), code 0 (Reset), value 0

Event: time 5213.875097, type 3 (Absolute), code 0 (X), value 3591

Event: time 5213.875173, type 3 (Absolute), code 1 (Y), value 2695

Event: time 5213.875215, type 3 (Absolute), code 24 (Pressure), value 181

 

 

But when i want to calibrate it with an ts_calibrate nothing hapend I have put an event test with & to test if the event are present and yes there is some event

 

root:/> event_test dev/input/event0 &

121

root:/> Input driver version is 1.0.0

Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0

Input device name: "ADS784x Touchscreen"

Supported events:

  Event type 0 (Reset)

    Event code 0 (Reset)

    Event code 1 (Key)

    Event code 3 (Absolute)

  Event type 1 (Key)

    Event code 330 (Touch)

  Event type 3 (Absolute)

    Event code 0 (X)

      Value      0

      Min      150

      Max     4095

    Event code 1 (Y)

      Value      0

      Min      190

      Max     4095

    Event code 24 (Pressure)

      Value      0

      Min        0

      Max      255

Testing ... (interrupt to exit)

 

root:/> export TSLIB_FBDEVICE=/dev/fb0

root:/> export TSLIB_CONSOLEDEVICE=none

root:/> export TSLIB_CONFFILE=/etc/ts.conf

root:/> export TSLIB_CALIBFILE=/etc/pointercl

root:/> export TSLIB_TSDEVICE=/dev/input/event0

root:/>

root:/> ts_calibrate

openfb

config

writePPI

finfctopenfb

xres = 480, yres = 272

 

 

Event: time 5291.327339, type 3 (Absolute), code 0 (X), value 2823

Event: time 5291.327464, type 3 (Absolute), code 1 (Y), value 3335

Event: time 5291.327525, type 3 (Absolute), code 24 (Pressure), value 200

Event: time 5291.327583, type 0 (Reset), code 0 (Reset), value 0

Event: time 5297.103325, type 3 (Absolute), code 0 (X), value 2567

Event: time 5297.103438, type 3 (Absolute), code 1 (Y), value 2695

Event: time 5297.103499, type 3 (Absolute), code 24 (Pressure), value 184

Event: time 5297.103556, type 0 (Reset), code 0 (Reset), value 0

Event: time 5297.111470, type 3 (Absolute), code 1 (Y), value 2567

Event: time 5297.111593, type 0 (Reset), code 0 (Reset), value 0

Event: time 5297.119418, type 3 (Absolute), code 1 (Y), value 2695

Event: time 5297.119541, type 0 (Reset), code 0 (Reset), value 0

 

signal 2 caught

 

But the ts calibrate haven't see anything, maibe my problem is juste with the tslib : the event of my driver aren't good for the TSlib??

QuoteReplyEditDelete

 

 

2009-01-27 03:43:41     Re: BF537 TSC2046 touch screen controler

Michael Hennerich (GERMANY)

Message: 68376   

 

I would look at the ts_calibrate utility to see what is going wrong.

 

1) Do you have CONFIG_VT and the framebuffer console enabled? I would try doing so.

docs.blackfin.uclinux.org/doku.php?id=the_framebuffer_console

 

Honestly I never tried tslib without.

 

2) ts_calibrate doesn't like your framebuffer device.

 

Put some extra debug info into fbutils.c and ts_calibrate.c (uclinux-dist-trunk/lib/tslib-1.0/tests)

 

-Michael

QuoteReplyEditDelete

 

 

2009-04-01 19:00:26     Re: BF537 TSC2046 touch screen controler

Alexander Buryak (UKRAINE)

Message: 71982   

 

Try to check with virtual framebuffer.On my board the same situation.

 

First you need to modify vfb.c:

 

static int vfb_mmap(struct fb_info *info,

      struct vm_area_struct *vma)

{

unsigned long start = vma->vm_start;

unsigned long size = vma->vm_end - vma->vm_start;

unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;

unsigned long page, pos;

 

if (offset + size > info->fix.smem_len) {

  return -EINVAL;

}

 

pos = (unsigned long)info->fix.smem_start + offset;

 

vma->vm_start = (unsigned long)info->fix.smem_start;

vma->vm_end = vma->vm_start+inc-�>fix.smem_len;

vma->vm_flags |= VM_MAYSHARE;

 

 

vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */

return 0;

 

}

 

load module:

modprobe vfb vfb_enable=1

 

On my board   ts_calibration works with vfb.With LCD  not works.Also I can  test events with event_test /dev/input/event0.

Attachments

    Outcomes