WK2124 驱动移植

    //  1.  更名为 wk2124A.h  wk2124A.c
    //  2. 在 Kconfig 加入如下配置:
    429 config SPI_WK2124A
    430     tristate "WK2124A spi to 4 uart drvier"
    431     depends on SPI
    432     help
    433       SPI driver for  wk2124  cs1  spi to 4 wire uart IC driver.

    // 3 . 在 Makefile 里面加入:
    61 obj-$(CONFIG_SPI_WK2124A)       += wk2124A.o

     //  4. 修改驱动源码
    //  5. 在 头文件中修改:
    //  修改主次设备号
    144 #define     SERIAL_WK2124A_MAJOR        190
    145 #define     CALLOUT_WK2124A_MAJOR       191

    148 /* am33xx irq   */
    149 #define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
    150 #define IH2_BASE        32
    151 #define OMAP_MAX_GPIO_LINES 192
    152 #define IH_GPIO_BASE        (128 + IH2_BASE)
    153 #define IH_MPUIO_BASE       (OMAP_MAX_GPIO_LINES + IH_GPIO_BASE)
    154 #define OMAP_IRQ_END        (IH_MPUIO_BASE + 16)
    155 #define OMAP_GPIO_IS_MPUIO(nr)  ((nr) >= OMAP_MAX_GPIO_LINES)
    156 #define OMAP_GPIO_IRQ(nr)   (OMAP_GPIO_IS_MPUIO(nr) ? \
    157                  IH_MPUIO_BASE + ((nr) & 0x0f) : \
    158                  IH_GPIO_BASE + (nr))
    159 
    160 //wk2xxx hardware configuration
    161 #define     IRQ_WK2124A             OMAP_GPIO_IRQ(GPIO_TO_PIN(0, 23)) 
     //  这段代码是加入 AM335X 中断的选择

    //  在 wk2124A.c 里面修改
    29 #include "wk2124A.h"
    1476 static struct uart_driver wk2124_uart_driver = {
    1477     owner:          THIS_MODULE,
    1478     major:          SERIAL_WK2124A_MAJOR,
    1479 #ifdef CONFIG_DEVFS_FS
    1480     driver_name:    "ttySWZA",
    1481     dev_name:       "ttysWZA",
    1482 #else
    1483     driver_name:    "ttySWZA",
    1484     dev_name:       "ttysWZA",
    1485 #endif
    1486     minor:          MINOR_START,
    1487     nr:             NR_PORTS,
    1488     cons:           NULL//WK2Xxx_CONSOLE,
    1489 };

    1595 static struct spi_driver wk2124A_driver = {
    1596     .driver = {
    1597         .name  = "wk2124A",
    1598         .bus   = &spi_bus_type,
    1599         .owner = THIS_MODULE,
    1600     },
    1601 
    1602     .probe  = wk2124A_probe,     // 相应的, probe 的名字也要修改
    1603     .remove = __devexit_p(wk2124_remove),
    1604     .resume = wk2124_resume,
    1605 };
    1607 static int __init wk2124A_init(void)
    1608 {
    1609     int retval;
    1610 
    1611     retval = spi_register_driver(&wk2124A_driver);
    1612     printk(KERN_ALERT "rgister spi return v = :%d\n", retval);
    1613 
    1614     return retval;
    1615 }
    1616 
    1617 static void __exit wk2124A_exit(void)
    1618 {
    1619     spi_unregister_driver(&wk2124A_driver);
    1620     printk("TEST_REG:quit ");
    1621 }
    1622 
    1623 module_init(wk2124A_init);
    1624 module_exit(wk2124A_exit);
    1625 
    1626 MODULE_AUTHOR("WKIC Ltd");
    1627 MODULE_DESCRIPTION("wk2xxx generic serial port driver");
    1628 MODULE_LICENSE("GPL");
    // 修改 init 函数名字以及 驱动名字
  • 在板级文件的 spi_slave 里面加入:

     841 static struct spi_board_info am335x_spi0_slave_info[] = {
     842 #if 0
     843     {
     844         .modalias      = "spidev",
     845         .max_speed_hz  = 10000000,//48Mbps
     846         .bus_num       = 1,
     847         .chip_select   = 0,
     848         .mode = SPI_MODE_0,
     849     },
     850 #endif
     851 #if 1
     852     {
     853         .modalias = "wk2124A",    // compiler
     854         .mode = SPI_MODE_0,
     855         .max_speed_hz = 10000000,   // speed 10Mbps
     856         .bus_num = 1,               //  spi0 bus
     857         .chip_select = 0,           //  spi_cs0
     858     },
     859 #endif
     860 };
posted @ 2017-12-21 16:56  陈富林  阅读(2683)  评论(0编辑  收藏  举报