BigW Consortium Gitlab

Commit e61c2559 by David Clark

Updates after instlegato is working

parent befd3ef7
sources:
{
io.c
interrupt.c
queue.c
spi.c
}
cflags:
{
// -DDEBUG
}
...@@ -515,22 +515,28 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, rx_hndlr rx_fcn, ...@@ -515,22 +515,28 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, rx_hndlr rx_fcn,
void** tx_hndl, void** rx_hndl) void** tx_hndl, void** rx_hndl)
{ {
char str[32]; char str[32];
struct spi_master *master; struct spi_master *master = NULL;
struct device *dev; struct device *dev;
struct spi_device *spi; struct spi_device *spi;
struct mt7697q_info *qinfo; struct mt7697q_info *qinfo;
struct mt7697q_spec *qsTx, *qsRx; struct mt7697q_spec *qsTx, *qsRx;
int bus_num = MT7697_SPI_BUS_NUM;
int ret; int ret;
pr_info(DRVNAME" %s(): initialize queue(%u/%u)\n", pr_info(DRVNAME" %s(): initialize queue(%u/%u)\n",
__func__, tx_ch, rx_ch); __func__, tx_ch, rx_ch);
pr_info(DRVNAME" %s(): get SPI master bus(%u)\n", while (!master && (bus_num >= 0)) {
__func__, MT7697_SPI_BUS_NUM); pr_info(DRVNAME" %s(): get SPI master bus(%u)\n",
master = spi_busnum_to_master(MT7697_SPI_BUS_NUM); __func__, bus_num);
master = spi_busnum_to_master(bus_num);
if (!master)
bus_num--;
}
if (!master) { if (!master) {
pr_err(DRVNAME" %s(): spi_busnum_to_master(%d) failed\n", pr_err(DRVNAME" %s(): spi_busnum_to_master() failed\n",
__func__, MT7697_SPI_BUS_NUM); __func__);
ret = -EINVAL; ret = -EINVAL;
goto cleanup; goto cleanup;
} }
...@@ -594,6 +600,7 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, rx_hndlr rx_fcn, ...@@ -594,6 +600,7 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, rx_hndlr rx_fcn,
goto cleanup; goto cleanup;
} }
ret = mt7697q_read_state(rx_ch, qsRx); ret = mt7697q_read_state(rx_ch, qsRx);
if (ret < 0) { if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697q_read_state() failed(%d)\n", dev_err(qinfo->dev, "%s(): mt7697q_read_state() failed(%d)\n",
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include "spi-cp2130.h"
#include "interrupt.h" #include "interrupt.h"
#include "queue.h" #include "queue.h"
#include "spi.h" #include "spi.h"
...@@ -61,20 +62,34 @@ static const struct mt7697spi_hw_ops hw_ops = ...@@ -61,20 +62,34 @@ static const struct mt7697spi_hw_ops hw_ops =
static int __init mt7697spi_init(void) static int __init mt7697spi_init(void)
{ {
char str[32]; char str[32];
struct spi_master *master; struct spi_master *master = NULL;
struct device *dev; struct device *dev;
struct spi_device *spi; struct spi_device *spi;
struct mt7697q_info *qinfo; struct mt7697q_info *qinfo = NULL;
int bus_num = MT7697_SPI_BUS_NUM;
int ret = 0; int ret = 0;
pr_info(DRVNAME" %s(): '%s' initialize\n", __func__, DRVNAME); pr_info(DRVNAME" %s(): '%s' initialize\n", __func__, DRVNAME);
pr_info(DRVNAME" %s(): get SPI master bus(%u)\n", while (!master && (bus_num >= 0)) {
__func__, MT7697_SPI_BUS_NUM); pr_info(DRVNAME" %s(): get SPI master bus(%u)\n",
master = spi_busnum_to_master(MT7697_SPI_BUS_NUM); __func__, bus_num);
master = spi_busnum_to_master(bus_num);
if (!master)
bus_num--;
}
if (!master) { if (!master) {
pr_err(DRVNAME" spi_busnum_to_master(%d) failed\n", pr_err(DRVNAME" spi_busnum_to_master() failed\n");
MT7697_SPI_BUS_NUM); ret = -EINVAL;
goto cleanup;
}
ret = cp2130_update_ch_config(master, MT7697_SPI_CONFIG);
if (ret < 0) {
dev_err(&master->dev,
"%s(): cp2130_update_ch_config() failed(%d)\n",
__func__, ret);
goto cleanup; goto cleanup;
} }
...@@ -83,8 +98,10 @@ static int __init mt7697spi_init(void) ...@@ -83,8 +98,10 @@ static int __init mt7697spi_init(void)
dev = bus_find_device_by_name(&spi_bus_type, NULL, str); dev = bus_find_device_by_name(&spi_bus_type, NULL, str);
if (!dev) { if (!dev) {
dev_err(&master->dev, dev_err(&master->dev,
"%s(): '%s' bus_find_device_by_name() failed\n", "%s(): bus_find_device_by_name('%s') failed\n",
__func__, str); __func__, str);
ret = -EINVAL;
goto cleanup; goto cleanup;
} }
...@@ -92,13 +109,14 @@ static int __init mt7697spi_init(void) ...@@ -92,13 +109,14 @@ static int __init mt7697spi_init(void)
if (!spi) { if (!spi) {
dev_err(&master->dev, "%s(): get SPI device failed\n", dev_err(&master->dev, "%s(): get SPI device failed\n",
__func__); __func__);
ret = -EINVAL;
goto cleanup; goto cleanup;
} }
dev_info(&master->dev, "%s(): init dev('%s') mode(%d) max speed(%d) " dev_info(&master->dev, "%s(): init dev('%s') mode(%d) max speed(%d) "
"CS(%d) GPIO(%d) bits/word(%d)\n", "CS(%d) bits/word(%d)\n",
__func__, spi->modalias, spi->mode, spi->max_speed_hz, __func__, spi->modalias, spi->mode, spi->max_speed_hz,
spi->chip_select, spi->cs_gpio, spi->bits_per_word); spi->chip_select, spi->bits_per_word);
qinfo = kzalloc(sizeof(struct mt7697q_info), GFP_KERNEL); qinfo = kzalloc(sizeof(struct mt7697q_info), GFP_KERNEL);
if (!qinfo) { if (!qinfo) {
...@@ -157,24 +175,29 @@ failed_gpio_req: ...@@ -157,24 +175,29 @@ failed_gpio_req:
gpio_free(MT7697_SPI_INTR_GPIO_PIN); gpio_free(MT7697_SPI_INTR_GPIO_PIN);
cleanup: cleanup:
kfree(qinfo); if (qinfo) kfree(qinfo);
return ret; return ret;
} }
static void __exit mt7697spi_exit(void) static void __exit mt7697spi_exit(void)
{ {
char str[32]; char str[32];
struct spi_master *master; struct spi_master *master = NULL;
struct device *dev; struct device *dev;
struct spi_device *spi; struct spi_device *spi;
struct mt7697q_info *qinfo; struct mt7697q_info *qinfo;
int bus_num = MT7697_SPI_BUS_NUM;
while (!master && (bus_num >= 0)) {
pr_info(DRVNAME" %s(): get SPI master bus(%u)\n",
__func__, bus_num);
master = spi_busnum_to_master(bus_num);
if (!master)
bus_num--;
}
pr_info(DRVNAME" %s(): get SPI master bus(%u)\n",
__func__, MT7697_SPI_BUS_NUM);
master = spi_busnum_to_master(MT7697_SPI_BUS_NUM);
if (!master) { if (!master) {
pr_err(DRVNAME" %s(): spi_busnum_to_master(%d) failed\n", pr_err(DRVNAME" spi_busnum_to_master() failed\n");
__func__, MT7697_SPI_BUS_NUM);
goto cleanup; goto cleanup;
} }
......
...@@ -27,10 +27,12 @@ ...@@ -27,10 +27,12 @@
#define DRVNAME "mt7697q" #define DRVNAME "mt7697q"
#define MT7697_GPIO_IRQ_NAME "mt7697q irq" #define MT7697_GPIO_IRQ_NAME "mt7697q irq"
#define MT7697_SPI_INTR_GPIO_PIN 50//21 #define MT7697_SPI_INTR_GPIO_PIN 50
#define MT7697_SPI_BUS_NUM 32766 #define MT7697_SPI_BUS_NUM 32766
#define MT7697_SPI_CS 0 #define MT7697_SPI_CS 0
#define MT7697_SPI_CONFIG "0,2,-1,0,0,1,0,0,0,0,0,mt7697"
struct mt7697spi_hw_ops { struct mt7697spi_hw_ops {
int (*write)(struct spi_device*, const void*, size_t); int (*write)(struct spi_device*, const void*, size_t);
int (*read)(struct spi_device*, void*, size_t); int (*read)(struct spi_device*, void*, size_t);
......
sources:
{
wmi.c
cfg80211.c
main.c
txrx.c
ioctl.c
}
cflags:
{
// -DDEBUG
-DCONFIG_CFG80211_WEXT
-DCONFIG_WIRELESS
-DCONFIG_WIRELESS_EXT
// -DCONFIG_WEXT_CORE
// -DCONFIG_WEXT_PROC
// -DCONFIG_WEXT_SPY
// -DCONFIG_WEXT_PRIV
-I$MANGOH_ROOT/linux_kernel_modules/mt7697q
}
...@@ -245,27 +245,6 @@ cleanup: ...@@ -245,27 +245,6 @@ cleanup:
return ret; return ret;
} }
static bool mt7697_is_valid_iftype(const struct mt7697_cfg80211_info *cfg,
enum nl80211_iftype type, u8 *if_idx)
{
int i;
if (cfg->ibss_if_active ||
((type == NL80211_IFTYPE_ADHOC) && cfg->num_vif))
return false;
if (type == NL80211_IFTYPE_STATION || type == NL80211_IFTYPE_AP) {
for (i = cfg->vif_start; i < cfg->vif_max; i++) {
if ((cfg->avail_idx_map) & BIT(i)) {
*if_idx = i;
return true;
}
}
}
return false;
}
static struct cfg80211_bss* mt7697_add_bss_if_needed(struct mt7697_vif *vif, static struct cfg80211_bss* mt7697_add_bss_if_needed(struct mt7697_vif *vif,
const u8* bssid, const u8* bssid,
u32 freq) u32 freq)
...@@ -344,31 +323,35 @@ static struct wireless_dev* mt7697_cfg80211_add_iface(struct wiphy *wiphy, ...@@ -344,31 +323,35 @@ static struct wireless_dev* mt7697_cfg80211_add_iface(struct wiphy *wiphy,
struct vif_params *params) struct vif_params *params)
{ {
struct mt7697_cfg80211_info *cfg = wiphy_priv(wiphy); struct mt7697_cfg80211_info *cfg = wiphy_priv(wiphy);
struct mt7697_vif *vif;
struct wireless_dev *wdev = NULL; struct wireless_dev *wdev = NULL;
u8 if_idx; u8 if_idx;
dev_dbg(cfg->dev, "%s(): iface('%s') type(%u)\n", dev_dbg(cfg->dev, "%s(): iface('%s') type(%u)\n",
__func__, name, type); __func__, name, type);
if (cfg->num_vif == cfg->vif_max) {
dev_err(cfg->dev, "max # supported vif(%u)\n", cfg->num_vif); spin_lock_bh(&cfg->vif_list_lock);
goto cleanup; if (!list_empty(&cfg->vif_list)) {
} list_for_each_entry(vif, &cfg->vif_list, next) {
wdev = &vif->wdev;
if (!mt7697_is_valid_iftype(cfg, type, &if_idx)) { break;
dev_err(cfg->dev, "%s(): unsupported interface(%d)\n", }
__func__, type);
goto cleanup; spin_unlock_bh(&cfg->vif_list_lock);
dev_dbg(cfg->dev, "%s(): iface('%s') exists\n",
__func__, name);
} }
else {
wdev = mt7697_interface_add(cfg, name, type, if_idx);
if (!wdev) {
dev_err(cfg->dev, "%s(): mt7697_interface_add() failed\n",
__func__);
goto cleanup;
}
wdev = mt7697_interface_add(cfg, name, type, if_idx); cfg->num_vif++;
if (!wdev) {
dev_err(cfg->dev, "%s(): mt7697_interface_add() failed\n",
__func__);
goto cleanup;
} }
cfg->num_vif++;
cleanup: cleanup:
return wdev; return wdev;
} }
......
...@@ -170,7 +170,7 @@ static void mt7697_cookie_cleanup(struct mt7697_cfg80211_info *cfg) ...@@ -170,7 +170,7 @@ static void mt7697_cookie_cleanup(struct mt7697_cfg80211_info *cfg)
cfg->cookie_count = 0; cfg->cookie_count = 0;
} }
static int __init mt7697_probe(struct platform_device *pdev) static int mt7697_probe(struct platform_device *pdev)
{ {
struct wiphy *wiphy; struct wiphy *wiphy;
struct mt7697_cfg80211_info *cfg; struct mt7697_cfg80211_info *cfg;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment