移植16550 UART驱动

发布于 2022-09-22 14:45:11 字数 8419 浏览 13 评论 0

求教:公司自己做的板子,处理器MPC5200,扩展16550 UART(不做console),Kernel 2.6.16,之前未加载该驱动时启动正常,加载后在"Freeing unused kernel memory: 100k"挂住了。因板子与Freescale公司的lite5200b基本类似,我在arch/ppc/platform/lite5200b.c定义了以下结构(感觉在哪定义都行):

  1. static struct plat_serial8250_port serial8250_ports[] = {
  2. [0] = {
  3. .uartclk = 9600*16,
  4. .iotype = UPIO_MEM,
  5. .mapbase = 0xfc000000,
  6. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ,
  7. .irq = MPC52xx_IRQ1,
  8. },
  9. [1] = {
  10. .uartclk = 9600*16,,
  11. .iotype = UPIO_MEM,
  12. .mapbase = 0xfc000008,
  13. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ,
  14. .irq = MPC52xx_IRQ1,
  15. },
  16. [2] = {
  17. .uartclk =  9600*16,,
  18. .iotype = UPIO_MEM,
  19. .mapbase = 0xfc000010,
  20. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ,
  21. .irq = MPC52xx_IRQ2,
  22. },
  23. [3] = {
  24. .uartclk =  9600*16,,
  25. .iotype = UPIO_MEM,
  26. .mapbase = 0xfc000018,
  27. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ,
  28. .irq = MPC52xx_IRQ2,
  29. },
  30. [4] = {
  31. .uartclk =  9600*16,,
  32. .iotype = UPIO_MEM,
  33. .mapbase = 0xfc000020,
  34. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ,
  35. .irq = MPC52xx_IRQ3,
  36. },
  37. [5] = {
  38. .uartclk =  9600*16,,
  39. .iotype = UPIO_MEM,
  40. .mapbase = 0xfc000028,
  41. .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ,
  42. .irq = MPC52xx_IRQ3,
  43. },
  44. {},
  45. };
  46. static struct platform_device serial8250_device = {
  47. .name = "serial8250",
  48. .id = 0,
  49. .dev.platform_data = serial8250_ports,
  50. };
  51. static int __init
  52. add_serial8250_devices(void)
  53. {
  54. return platform_device_register(&serial8250_device);
  55. }
  56. arch_initcall(add_serial8250_devices);

复制代码

启动信息如下
The boot message is :
FT-Boot 1.2.0 (Sep 17 2008 - 09:16:55)

CPU:   MPC5200 v2.2, Core v1.4 at 462 MHz
       Bus 132 MHz, IPB 132 MHz, PCI 33 MHz
Board: FXALM(mpc52xx)
I2C:   85 kHz, ready
DRAM:  256 MB
FLASH: (Bank#1 - 512 kB, Bank#2 - 16 MB) 16.5 MB
In:    serial
Out:   serial
Err:   serial
Net:   FEC ETHERNET
IDE:   Bus 0: OK
  Device 0: Model: 128MB  ATA Flash Disk Firm: ADAA408J Ser#: A161112339F000831558
            Type: Hard Disk
            Capacity: 122.1 MB = 0.1 GB (250112 x 512)
Hit any key to stop autoboot:  0
Using FEC ETHERNET device
TFTP from server 192.168.1.40; our IP address is 192.168.1.50
Filename '/tftpboot/uImage'.
Load address: 0x200000
Loading: #################################################################
         #################################################################
         #################################################################
         ########################################################
done
Bytes transferred = 1281939 (138f93 hex)
## Booting image at 00200000 ...
   Image Name:   Linux-2.6.16
   Created:      2008-11-19  19:22:59 UTC
   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
   Data Size:    1281875 Bytes =  1.2 MB
   Load Address: 00000000
   Entry Point:  00000000
   Uncompressing Kernel Image ... OK
id mach(): done
MMU:enter
MMU:hw init
MMU:mapin
MMU:setio
MMU:exit
setup_arch: enter
setup_arch: bootmem
arch: exit
bootinfo is find_bootinfo()<5>Linux version 2.6.16 (root@...) (gcc version 3.4.3) #50 Thu No8
Built 1 zonelists
Kernel command line: console=ttyPSC0,9600 root=/dev/nfs rw nfsroot=192.168.1.40:/home/hyz/ltib-mpc5200-20070201
PID hash table entries: 2048 (order: 11, 32768 bytes)
Console: colour dummy device 80x25
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 256896k available (1968k kernel code, 664k data, 100k init, 0k highmem)
Mount-cache hash table entries: 512
NET: Registered protocol family 16
            
DMA: MPC52xx BestComm driver
MPC52xx BestComm inited
SCSI subsystem initialized
Installing knfsd (copyright (C) 1996 okir@...).
JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Serial: 8250/16550 driver $Revision: 1.90 $ 6 ports, IRQ sharing enabled
serial8250.0: ttyS0 at MMIO 0xfc000000 (irq = 6) is a 16550A
serial8250.0: ttyS1 at MMIO 0xfc000008 (irq = 6) is a 16550A
serial8250.0: ttyS2 at MMIO 0xfc000010 (irq = 7) is a 16550A
serial8250.0: ttyS3 at MMIO 0xfc000018 (irq = 7) is a 16550A
serial8250.0: ttyS4 at MMIO 0xfc000020 (irq = 8)is a 16550A
serial8250.0: ttyS5 at MMIO 0xfc000028 (irq = 8)is a 16550A
Serial: MPC52xx PSC driver
ttyPSC0 at MMIO 0xf0002000 (irq = 40) is a MPC52xx PSC
ttyPSC1 at MMIO 0xf0002200 (irq = 41) is a MPC52xx PSC
ttyPSC2 at MMIO 0xf0002400 (irq = 42) is a MPC52xx PSC
ttyPSC3 at MMIO 0xf0002600 (irq = 50) is a MPC52xx PSC
ttyPSC4 at MMIO 0xf0002800 (irq = 51) is a MPC52xx PSC
ttyPSC5 at MMIO 0xf0002c00 (irq = 43) is a MPC52xx PSC
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
ide: MPC52xx IDE/ATA driver
eth0: Phy @ 0x0, type LXT971 (0x001378e2)
hda: 128MB ATA Flash Disk, ATA DISK drive
ide0 at 0xf0003a60-0xf0003a67,0xf0003a5c on irq 46
mpc52xx-ide: Setup successful for ide0 (mem=f0003a00-f0003aff irq=46)
hda: max request size: 128KiB
hda: 250112 sectors (128 MB) w/1KiB Cache, CHS=977/8/32
hda: cache flushes not supported
hda: hda1
flash chip on the Lite5200/Lite5200B: Found 1 x16 devices at 0x0 in 8-bit bank
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
cfi_cmdset_0001: Erase suspend on write enabled
Creating 1 MTD partitions on "flash chip on the Lite5200/Lite5200B":
0x00000000-0x01000000 : "Filesystem"
mice: PS/2 mouse device common for all mice
NET: Registered protocol family 2
IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
TCP established hash table entries: 16384 (order: 4, 65536 bytes)
TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 16384 bind 16384)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
eth0: config: auto-negotiation on, 100HDX, 10HDX.
IP-Config: Complete:
      device=eth0, addr=192.168.1.50, mask=255.255.255.0, gw=192.168.1.1,
     host=192.168.1.50, domain=, nis-domain=(none),
     bootserver=192.168.1.40, rootserver=192.168.1.40, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.40
Looking up port of RPC 100005/1 on 192.168.1.40
VFS: Mounted root (nfs filesystem).
Freeing unused kernel memory: 100k init

就停在这里了,我什么地方做错了?驱动8250.c文件有要修改的地方吗?

[ 本帖最后由 dreamice 于 2008-11-28 15:02 编辑 ]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

琴流音 2022-09-29 14:45:11

static struct plat_serial8250_port serial8250_ports[] 你这个结构的初始化真是很奇怪哦。
另外,platform_device_register也不知道是怎么实现的

狼亦尘 2022-09-29 14:45:11

哪里奇怪啊?
arch_initcall(add_serial8250_devices)不是执行了吗

凌乱心跳 2022-09-29 14:45:11

停在这个地方,感觉和串口驱动没有什么直接的关系啊

﹏半生如梦愿梦如真 2022-09-29 14:45:11

那还会有哪些原因呢?没有他的话,boot是一点问题都没有的,对了还有一点,模块方式加载的话,
insmod 8250.ko也不会死,设备文件可操作,但收发都不通,囧,还是驱动的问题吧,是不是我那些结构体里漏了或错了?

人心善变 2022-09-29 14:45:11

1:结构体里可能有错
2:8250.ko模块中程序虽语法正确,但逻辑可能有问题

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文