|
本帖最后由 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总线,故不能使用。
- /*
- * GL-CONNECT iNet board support
- *
- * Copyright (C) 2011 dongyuqi <729650915@qq.com>
- * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
- * Copyright (C) 2013 alzhao <alzhao@gmail.com>
- * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- */
- #include <linux/gpio.h>
- #include <linux/i2c.h>
- #include <linux/i2c-algo-bit.h>
- #include <linux/i2c-gpio.h>
- #include <linux/platform_data/pca953x.h>
- #include <linux/platform_device.h>
- #include <asm/mach-ath79/ath79.h>
- #include "dev-eth.h"
- #include "dev-gpio-buttons.h"
- #include "dev-leds-gpio.h"
- #include "dev-m25p80.h"
- #include "dev-usb.h"
- #include "dev-wmac.h"
- #include "machtypes.h"
- #define GL_INET_GPIO_LED_WLAN 0
- #define GL_INET_GPIO_LED_LAN 13
- #define GL_INET_GPIO_BTN_RESET 12
- #define GL_INET_KEYS_POLL_INTERVAL 20 /* msecs */
- #define GL_INET_KEYS_DEBOUNCE_INTERVAL (3 * GL_INET_KEYS_POLL_INTERVAL)
- static const char * gl_inet_part_probes[] = {
- "tp-link", /* dont change, this will use tplink parser */
- NULL ,
- };
- static struct i2c_gpio_platform_data sp01_i2c_device_platdata = {
- .sda_pin = 17,
- .scl_pin = 11,
- .udelay = 10,
- .sda_is_open_drain = 0,
- .scl_is_open_drain = 0,
- .scl_is_output_only = 1,
- };
- static struct platform_device sp01_i2c_device = {
- .name = "i2c-gpio",
- .id = 0,
- .dev = {
- .platform_data = &sp01_i2c_device_platdata,
- },
- };
- static struct pca953x_platform_data sp01_pca9554_data = {
- .gpio_base = 32,
- .irq_base = -1,
- };
- static struct i2c_board_info sp01_i2c_devs[] __initdata = {
- {
- I2C_BOARD_INFO("pca9554", 0x38),
- .platform_data = &sp01_pca9554_data,
- },
- };
- static struct flash_platform_data gl_inet_flash_data = {
- .part_probes = gl_inet_part_probes,
- };
- static struct gpio_led gl_inet_leds_gpio[] __initdata = {
- {
- .name = "gl-inet:red:wlan",
- .gpio = GL_INET_GPIO_LED_WLAN,
- .active_low = 0,
- },
- // {
- // .name = "gl-inet:green:lan",
- // .gpio = GL_INET_GPIO_LED_LAN,
- // .active_low = 0,
- // .default_state = 1,
- // },
- };
- static struct gpio_keys_button gl_inet_gpio_keys[] __initdata = {
- {
- .desc = "reset",
- .type = EV_KEY,
- .code = KEY_RESTART,
- .debounce_interval = GL_INET_KEYS_DEBOUNCE_INTERVAL,
- .gpio = GL_INET_GPIO_BTN_RESET,
- .active_low = 0,
- }
- };
- static void __init gl_inet_setup(void)
- {
- /* get the mac address which is stored in the 1st 64k uboot MTD */
- u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
- /* get the art address, which is the last 64K. By using
- 0x1fff1000, it doesn't matter it is 4M, 8M or 16M flash */
- u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
- /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
- ath79_setup_ar933x_phy4_switch(false, false);
- /* register flash. MTD will use tp-link parser to parser MTD */
- ath79_register_m25p80(&gl_inet_flash_data);
- /* register I2C and pca9554 */
- platform_device_register(&sp01_i2c_device);
- i2c_register_board_info(0, sp01_i2c_devs,
- ARRAY_SIZE(sp01_i2c_devs));
-
- /* register gpio LEDs and keys */
- ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_inet_leds_gpio),
- gl_inet_leds_gpio);
- ath79_register_gpio_keys_polled(-1, GL_INET_KEYS_POLL_INTERVAL,
- ARRAY_SIZE(gl_inet_gpio_keys),
- gl_inet_gpio_keys);
-
- /* enable usb */
- ath79_register_usb();
- /* register eth0 as WAN, eth1 as LAN */
- ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
- ath79_register_mdio(0, 0x0);
- ath79_register_eth(0);
- ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
- ath79_register_eth(1);
- /* register wireless mac with cal data */
- ath79_register_wmac(ee, mac);
- }
- MIPS_MACHINE(ATH79_MACH_GL_INET, "GL-INET", "GL-CONNECT INET v1",
- gl_inet_setup);
复制代码
2022/7/12更新:试图将mach-gl-ar750s.c里的spi部分移植进mach-gl-inet.c,编译通过但无法正常启动一直重启。 |
|