找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 273|回复: 0

[求助帖]Openwrt ar9331 spi自定义cs引脚配置问题

[复制链接]
本帖最后由 Blue_Beaker 于 2022-7-12 20:57 编辑

我尝试在邦讯玩儿插排(虽然是插排,但基于ar9331,可以跑openwrt)上移植openwrt替换原厂固件再自己写程序以实现本地控制功能,现在openwrt能运行,无线有线均正常,经过调试后I2C的pca9554及其所接三个按钮都能正常工作
这个插排还有三个走spi的pl7223,继电器和功率计量都在那个ic上,和spi flash共用一条spi总线,但板子上这几个ic的cs引脚触发方式比较特殊:
我在这三个芯片的cs引脚上焊了led,测得三个cs分别是gpio1,gpio26,gpio33(通过pca9554转接得到),但是选了之后并不能立即生效,还要上拉再下拉一下gpio14才能生效。
我写了个程序在切换cs后马上拉一下gpio14可以正常驱动三个cs,但是spiflash的cs引脚gpio2通过gpioctl或我自己写的程序拉低后马上又拉高回去了,一直被spiflash占用着没法正常访问那几个spi设备,故必须修改固件
请问怎么修改编译配置才能正常访问那几个spi设备?我用的是19.07.10,这个版本的ar71xx没有dts那种配置文件,也找不到自定义spi cs pin的地方,编译配置是修改自target/linux/ar71xx/files/arch/mips/ath79/gl-inet.c,贴在这里了。
我想应该可以通过另外的程序在每次切换cs时拉一下gpio14,这方面应该不成问题。

之前也试过21.02,自定义的i2c引脚是开漏模式,没法驱动这个插座主板上没有上拉的i2c总线,故不能使用。
  1. /*
  2. *  GL-CONNECT iNet board support
  3. *
  4. *  Copyright (C) 2011 dongyuqi <729650915@qq.com>
  5. *  Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  6. *  Copyright (C) 2013 alzhao <alzhao@gmail.com>
  7. *  Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
  8. *
  9. *  This program is free software; you can redistribute it and/or modify it
  10. *  under the terms of the GNU General Public License version 2 as published
  11. *  by the Free Software Foundation.
  12. */

  13. #include <linux/gpio.h>
  14. #include <linux/i2c.h>
  15. #include <linux/i2c-algo-bit.h>
  16. #include <linux/i2c-gpio.h>
  17. #include <linux/platform_data/pca953x.h>
  18. #include <linux/platform_device.h>

  19. #include <asm/mach-ath79/ath79.h>

  20. #include "dev-eth.h"
  21. #include "dev-gpio-buttons.h"
  22. #include "dev-leds-gpio.h"
  23. #include "dev-m25p80.h"
  24. #include "dev-usb.h"
  25. #include "dev-wmac.h"
  26. #include "machtypes.h"

  27. #define GL_INET_GPIO_LED_WLAN                0
  28. #define GL_INET_GPIO_LED_LAN                13
  29. #define GL_INET_GPIO_BTN_RESET                12

  30. #define GL_INET_KEYS_POLL_INTERVAL        20        /* msecs */
  31. #define GL_INET_KEYS_DEBOUNCE_INTERVAL        (3 * GL_INET_KEYS_POLL_INTERVAL)

  32. static const char * gl_inet_part_probes[] = {
  33.         "tp-link", /* dont change, this will use tplink parser */
  34.         NULL ,
  35. };

  36. static struct i2c_gpio_platform_data sp01_i2c_device_platdata = {
  37.         .sda_pin                = 17,
  38.         .scl_pin                = 11,
  39.         .udelay                        = 10,
  40.         .sda_is_open_drain        = 0,
  41.         .scl_is_open_drain        = 0,
  42.     .scl_is_output_only = 1,
  43. };

  44. static struct platform_device sp01_i2c_device = {
  45.         .name                = "i2c-gpio",
  46.         .id                = 0,
  47.         .dev                = {
  48.                 .platform_data        = &sp01_i2c_device_platdata,
  49.         },
  50. };

  51. static struct pca953x_platform_data sp01_pca9554_data = {
  52.         .gpio_base        = 32,
  53.         .irq_base        = -1,
  54. };

  55. static struct i2c_board_info sp01_i2c_devs[] __initdata = {
  56.         {
  57.                 I2C_BOARD_INFO("pca9554", 0x38),
  58.                 .platform_data = &sp01_pca9554_data,
  59.         },
  60. };

  61. static struct flash_platform_data gl_inet_flash_data = {
  62.         .part_probes = gl_inet_part_probes,
  63. };

  64. static struct gpio_led gl_inet_leds_gpio[] __initdata = {
  65.         {
  66.                 .name = "gl-inet:red:wlan",
  67.                 .gpio = GL_INET_GPIO_LED_WLAN,
  68.                 .active_low = 0,
  69.         },
  70. //        {
  71. //                .name = "gl-inet:green:lan",
  72. //                .gpio = GL_INET_GPIO_LED_LAN,
  73. //                .active_low = 0,
  74. //                .default_state = 1,
  75. //        },
  76. };

  77. static struct gpio_keys_button gl_inet_gpio_keys[] __initdata = {
  78.         {
  79.                 .desc = "reset",
  80.                 .type = EV_KEY,
  81.                 .code = KEY_RESTART,
  82.                 .debounce_interval = GL_INET_KEYS_DEBOUNCE_INTERVAL,
  83.                 .gpio = GL_INET_GPIO_BTN_RESET,
  84.                 .active_low = 0,
  85.         }
  86. };

  87. static void __init gl_inet_setup(void)
  88. {
  89.         /* get the mac address which is stored in the 1st 64k uboot MTD */
  90.         u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);

  91.         /* get the art address, which is the last 64K. By using
  92.            0x1fff1000, it doesn't matter it is 4M, 8M or 16M flash */
  93.         u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);

  94.         /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  95.         ath79_setup_ar933x_phy4_switch(false, false);

  96.         /* register flash. MTD will use tp-link parser to parser MTD */
  97.         ath79_register_m25p80(&gl_inet_flash_data);

  98.     /* register I2C and pca9554 */
  99.         platform_device_register(&sp01_i2c_device);
  100.         i2c_register_board_info(0, sp01_i2c_devs,
  101.                                 ARRAY_SIZE(sp01_i2c_devs));
  102.    
  103.         /* register gpio LEDs and keys */
  104.         ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_inet_leds_gpio),
  105.                                  gl_inet_leds_gpio);
  106.         ath79_register_gpio_keys_polled(-1, GL_INET_KEYS_POLL_INTERVAL,
  107.                                         ARRAY_SIZE(gl_inet_gpio_keys),
  108.                                         gl_inet_gpio_keys);
  109.    
  110.         /* enable usb */
  111.         ath79_register_usb();

  112.         /* register eth0 as WAN, eth1 as LAN */
  113.         ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  114.         ath79_register_mdio(0, 0x0);
  115.         ath79_register_eth(0);
  116.         ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  117.         ath79_register_eth(1);

  118.         /* register wireless mac with cal data */
  119.         ath79_register_wmac(ee, mac);
  120. }

  121. MIPS_MACHINE(ATH79_MACH_GL_INET, "GL-INET", "GL-CONNECT INET v1",
  122.              gl_inet_setup);
复制代码



2022/7/12更新:试图将mach-gl-ar750s.c里的spi部分移植进mach-gl-inet.c,编译通过但无法正常启动一直重启。
我的恩山、我的无线 The best wifi forum is right here.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-28 03:31

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表