notro / fbtft

Linux Framebuffer drivers for small TFT LCD display modules. Development has moved to https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/fbtft?h=staging-testing
1.86k stars 494 forks source link

ILI9341 with 16bit Interface #118

Closed faultylee closed 10 years ago

faultylee commented 10 years ago

Hi, I've recently bought a 2.8" Alientek TFTLCD from Shanghai without much documentation. I've managed to figure out from trial and error that it's running on ILI9341 based on the ID of the device. I've since been able to draw something onto the LCD using python. I then went ahead to do sudo modprobe fbtft_device custom name=fb_ili9341 debug=0 width=240 height=320 rotate=270 bgr=0 buswidth=8 gpios=... and it works but everything is in red. Only later I realized that I can't change the interface bit size from 16bit to 8bit. The jumper on the LCD is not doing anything. So decided to wire up the 16bit interface and change to buswidth=16. I then get the error below. I think the key here is no default functions for regwidth=8 and buswidth=16. I wonder if changing fb_ili9341.c line:156 from .regwidth = 8, to .regwidth = 16, would do the trick?

dmesg:

[  130.007958] fbtft_device:  SPI devices registered:
[  130.007988] fbtft_device:  'fb' Platform devices registered:
[  130.008011] fbtft_device:      bcm2708_fb id=-1 pdata? no
[  130.008202] fbtft_device:  GPIOS used by 'fb_ili9341':
[  130.008220] fbtft_device:    'reset' = GPIO17
[  130.008231] fbtft_device:    'dc' = GPIO3
[  130.008240] fbtft_device:    'wr' = GPIO2
[  130.008249] fbtft_device:    'cs' = GPIO27
[  130.008258] fbtft_device:    'led' = GPIO0
[  130.008267] fbtft_device:    'db00' = GPIO22
[  130.008277] fbtft_device:    'db01' = GPIO11
[  130.008288] fbtft_device:    'db02' = GPIO18
[  130.008298] fbtft_device:    'db03' = GPIO23
[  130.008307] fbtft_device:    'db04' = GPIO24
[  130.008316] fbtft_device:    'db05' = GPIO25
[  130.008325] fbtft_device:    'db06' = GPIO8
[  130.008334] fbtft_device:    'db07' = GPIO7
[  130.008343] fbtft_device:    'db08' = GPIO4
[  130.008352] fbtft_device:    'db09' = GPIO9
[  130.008361] fbtft_device:    'db10' = GPIO10
[  130.008371] fbtft_device:    'db11' = GPIO15
[  130.008380] fbtft_device:    'db12' = GPIO28
[  130.008389] fbtft_device:    'db13' = GPIO29
[  130.008398] fbtft_device:    'db14' = GPIO30
[  130.008408] fbtft_device:    'db15' = GPIO31
[  130.008416] fbtft_device:  'fb' Platform devices registered:
[  130.008433] fbtft_device:      bcm2708_fb id=-1 pdata? no
[  130.008465] fbtft_device:      fb_ili9341 id=0 pdata? yes
[  130.046845] fb_ili9341 fb_ili9341.0: no default functions for regwidth=8 and buswidth=16
[  141.852098] Unable to handle kernel paging request at virtual address dc000000
[  141.852184] pgd = dabd0000
[  141.852209] [dc000000] *pgd=00000000
[  141.852248] Internal error: Oops: 5 [#1] PREEMPT ARM
[  141.852281] Modules linked in: fb_ili9341(+) fbtft_device fbtft syscopyarea sysfillrect sysimgblt fb_sys_fops snd_bcm2835 snd_soc_bcm2708_i2s regmap_mmio snd_soc_core snd_compress regmap_i2c regmap_spi evdev snd_pcm snd_page_alloc snd_seq r8712u(C) snd_seq_device snd_timer leds_gpio led_class snd
[  141.852495] CPU: 0 PID: 2217 Comm: modprobe Tainted: G         C   3.10.34+ #1
[  141.852543] task: d982d6a0 ti: d99ae000 task.ti: d99ae000
[  141.852633] PC is at fbtft_write_gpio16_wr+0x40/0x1bc [fbtft]
[  141.852693] LR is at __gpio_set_value+0x70/0xac
[  141.852729] pc : [<bf10b7a4>]    lr : [<c0242ccc>]    psr: a0000013
[  141.852729] sp : d99afa00  ip : 00000001  fp : 0000004c
[  141.852787] r10: 00000000  r9 : f2200000  r8 : dc000002
[  141.852818] r7 : fd842701  r6 : 00000001  r5 : 00000000  r4 : daabc334
[  141.852853] r3 : f220001c  r2 : f2200000  r1 : 00000000  r0 : 00000002
[  141.852891] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  141.852930] Control: 00c5387d  Table: 1abd0008  DAC: 00000015
[  141.852964] Process modprobe (pid: 2217, stack limit = 0xd99ae1b0)
[  141.852999] Stack: (0xd99afa00 to 0xd99b0000)
[  141.853040] fa00: 00000001 00000010 00000002 ffffffff d9842700 daabc334 d99afa60 00000001
[  141.853094] fa20: d99afa64 60000013 d99afa60 bf10b2fc daabc334 c05da058 c05ba008 d99afa64
[  141.853146] fa40: 00000005 daabc334 c05da058 c05ba008 000001ff 00000005 bf1086e4 00000004
[  141.853196] fa60: 000000cf 00000000 00000083 00000030 c0236694 00000001 0000000a 00000006
[  141.853248] fa80: ffffffff ffffffff ffffffff c05eda9c 3fa12563 6c0a0100 ffff0006 ff0a0200
[  141.853301] faa0: c05f2458 c05eda9c 00000000 c05eda9c 00000001 0000004c c05f2458 c05f2468
[  141.853353] fac0: c0236c1c 00000008 d99afbd8 0000000f 0000004c c05eda9c 00000001 0000004c
[  141.853405] fae0: c05edaab 00000000 c001fad4 00000000 00000001 c05ee2c8 000000ec 00000000
[  141.853456] fb00: 00000086 c05edea4 c05f2458 00000000 000000ec 00000000 c0020658 00000400
[  141.853506] fb20: 00000040 000000eb 00000000 00000001 00000000 00000000 d99ae000 20000093
[  141.853559] fb40: 00000001 60000013 0000004c 60000013 00000006 d99ae000 60000013 00000006
[  141.853609] fb60: 00000005 000000cf 00000000 00000083 00000030 c0236694 00000001 0000000a
[  141.853662] fb80: 00000006 ffffffff ffffffff ffffffff c05eda9c 3fa12563 6c0a0100 ffff0006
[  141.853714] fba0: ff0a0200 c05f2458 c05eda9c 00000000 c05eda9c 00000001 0000004c c05f2458
[  141.853767] fbc0: c05f2468 c0236c1c 00000008 d99afbd8 0000000f 0000004c c05eda9c 00000001
[  141.853818] fbe0: 0000004c c05edaab 00000000 c001fad4 00000000 00000001 c05ee2c8 000000ec
[  141.853868] fc00: 00000000 00000086 c05edea4 c05f2458 00000000 000000ec 00000000 c0020658
[  141.853920] fc20: 00000400 00000040 000000eb 00000000 00000001 00000000 00000000 d99ae000
[  141.853973] fc40: 20000093 00000001 60000013 0000004c 60000013 00000006 d99ae000 60000013
[  141.854025] fc60: 00000006 30337830 00000020 bf11a3f8 00000000 30307830 38783020 78302033
[  141.854077] fc80: 00203033 d99afcc0 00000000 c05ba008 bf1179e0 daabc000 c005ff3c c023c0bc
[  141.854128] fca0: d99afccc 0000001f 00000000 0000001f da8cda8c c001bd40 c001bd28 0000001f
[  141.854181] fcc0: c066e634 da8cda8c 40000013 c02436d0 bf1228a4 00000000 00000000 00000000
[  141.854233] fce0: c066e634 00000000 c05ba008 c0244738 daabc334 ecd025fe 0000ffff daabc334
[  141.854286] fd00: 00000000 daabc000 00000000 c05ba008 bf1179e0 daabc000 c005ff3c bf108968
[  141.854337] fd20: da988f80 daabc000 bf1227c0 c00174c8 00000247 00000000 00000000 00000000
[  141.854386] fd40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  141.854437] fd60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  141.854488] fd80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ecd025fe
[  141.854541] fda0: bf1227c0 daabc334 bf118d20 daabc39c bf1179f0 bf10a3c0 c067450c bf1179f0
[  141.854594] fdc0: bf117a24 bf1228a4 d99ae000 bf124000 c05ecda0 c0284328 c0284310 c028309c
[  141.854647] fde0: 00000000 bf1179f0 bf1228a4 bf117a24 00000000 c02832b4 00000000 bf1228a4
[  141.854700] fe00: c0283228 c0281828 da820e8c dab0b450 bf1228a4 dab0b2a0 c05de4a8 c0282870
[  141.854751] fe20: bf122734 bf1228a4 bf1228a4 bf1228f0 bf1228e4 00000001 d99ae000 c02837a0
[  141.854804] fe40: 00000000 d99aff58 bf1228f0 bf1228e4 00000001 d99ae000 c05ecda0 c0008574
[  141.854856] fe60: c05c53e8 ffffffff 00000000 00000000 00000000 c00420a0 00000000 00000001
[  141.854908] fe80: d9834ac0 d99aff58 bf1228f0 bf1228e4 00000001 d9834ac0 d99ae000 00000001
[  141.854961] fea0: c005ff3c c0062670 bf1228f0 00007fff c005f5a4 dc964000 c005ffec dc961000
[  141.855013] fec0: d99ae000 bf12292c d99ae000 d99ae000 c022a8a8 c054b9c4 00000000 00000000
[  141.855064] fee0: 00000000 00000000 00000000 00000000 6e72656b 00006c65 00000000 00000000
[  141.855114] ff00: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  141.855166] ff20: 00000000 00000000 00000000 ecd025fe 000000d2 00002020 b6f6a000 b6f57948
[  141.855217] ff40: 00000080 c000dd68 d99ae000 00000000 00000000 c0062e04 dc961000 00002020
[  141.855269] ff60: dc962084 dc961f35 dc962cfc 00000a34 00000cc4 00000000 00000000 00000000
[  141.855320] ff80: 0000001e 0000001f 00000016 00000013 00000011 00000000 00000000 00060000
[  141.855372] ffa0: b80ca380 c000dbc0 00000000 00060000 b6f6a000 00002020 b6f57948 b6f6a000
[  141.855424] ffc0: 00000000 00060000 b80ca380 00000080 b80ccd98 00002020 b6f57948 00000000
[  141.855476] ffe0: 00000000 beb279bc b6f4efb4 b6eb9fd4 60000010 b6f6a000 1aff6821 1aff6c21
[  141.855608] [<bf10b7a4>] (fbtft_write_gpio16_wr+0x40/0x1bc [fbtft]) from [<bf10b2fc>] (fbtft_write_reg8_bus8+0x84/0x1a4 [fbtft])
[  141.855724] [<bf10b2fc>] (fbtft_write_reg8_bus8+0x84/0x1a4 [fbtft]) from [<bf1086e4>] (fbtft_init_display+0x3d4/0x504 [fbtft])
[  141.855832] [<bf1086e4>] (fbtft_init_display+0x3d4/0x504 [fbtft]) from [<bf108968>] (fbtft_register_framebuffer+0xe8/0x30c [fbtft])
[  141.855938] [<bf108968>] (fbtft_register_framebuffer+0xe8/0x30c [fbtft]) from [<bf10a3c0>] (fbtft_probe_common+0x144/0x2dc [fbtft])
[  141.856041] [<bf10a3c0>] (fbtft_probe_common+0x144/0x2dc [fbtft]) from [<c0284328>] (platform_drv_probe+0x18/0x1c)
[  141.856115] [<c0284328>] (platform_drv_probe+0x18/0x1c) from [<c028309c>] (driver_probe_device+0x6c/0x1f8)
[  141.856184] [<c028309c>] (driver_probe_device+0x6c/0x1f8) from [<c02832b4>] (__driver_attach+0x8c/0x90)
[  141.856247] [<c02832b4>] (__driver_attach+0x8c/0x90) from [<c0281828>] (bus_for_each_dev+0x54/0x88)
[  141.856310] [<c0281828>] (bus_for_each_dev+0x54/0x88) from [<c0282870>] (bus_add_driver+0xd4/0x230)
[  141.856372] [<c0282870>] (bus_add_driver+0xd4/0x230) from [<c02837a0>] (driver_register+0x78/0x14c)
[  141.856438] [<c02837a0>] (driver_register+0x78/0x14c) from [<c0008574>] (do_one_initcall+0xec/0x150)
[  141.856517] [<c0008574>] (do_one_initcall+0xec/0x150) from [<c0062670>] (load_module+0x1720/0x1ddc)
[  141.856586] [<c0062670>] (load_module+0x1720/0x1ddc) from [<c0062e04>] (SyS_init_module+0xd8/0xec)
[  141.856659] [<c0062e04>] (SyS_init_module+0xd8/0xec) from [<c000dbc0>] (ret_fast_syscall+0x0/0x30)
[  141.856717] Code: e3a0a000 e3a06001 e59400c4 e3a01000 (e15850b2)
[  141.856758] ---[ end trace 9cc09dd09a534adb ]---
faultylee commented 10 years ago

I've managed to use only 8bit interface by setting RCM[1:0] = "10" for 6bit interface mode, and RGB is sent via 3 individual bytes. Though I'm not sure how to modify the code to send RGB in 3 separate bytes instead of 2 when buswidth=8. Would this approach be harder then making buswidth=16 works?

faultylee commented 10 years ago

I've found a jumper on the flex cable from the panel to the PCB, R2 and R3. Shifting the 0ohm resistor from R2 to R3 turn it into 8bit interface.