BigW Consortium Gitlab

Commit bae6b7b8 by David Clark

WiFi Serial implementation

parent 2d7b47c0
...@@ -9,6 +9,7 @@ sources: ...@@ -9,6 +9,7 @@ sources:
cflags: cflags:
{ {
// -DDEBUG // -DDEBUG
-I$MANGOH_ROOT/linux_kernel_modules/cp2130 -I$MANGOH_ROOT/linux_kernel_modules/cp2130
-I$MANGOH_ROOT/linux_kernel_modules/mt7697common
} }
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "io.h" #include "io.h"
#include "spi.h" #include "spi.h"
int mt7697_irq_run(struct mt7697q_info *qinfo) static int mt7697q_irq_run(struct mt7697q_info *qinfo)
{ {
int ret; int ret;
u8 ch; u8 ch;
...@@ -80,16 +80,16 @@ cleanup: ...@@ -80,16 +80,16 @@ cleanup:
return ret; return ret;
} }
void mt7697_irq_delayed_work(struct work_struct *irq_delayed_work) void mt7697q_irq_delayed_work(struct work_struct *irq_delayed_work)
{ {
struct mt7697q_info *qinfo = container_of(irq_delayed_work, struct mt7697q_info *qinfo = container_of(irq_delayed_work,
struct mt7697q_info, irq_delayed_work.work); struct mt7697q_info, irq_delayed_work.work);
int ret; int ret;
dev_dbg(qinfo->dev, "%s(): process work\n", __func__); dev_dbg(qinfo->dev, "%s(): process work\n", __func__);
ret = mt7697_irq_run(qinfo); ret = mt7697q_irq_run(qinfo);
if (ret < 0) { if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697_irq_run() failed(%d)\n", dev_err(qinfo->dev, "%s(): mt7697q_irq_run() failed(%d)\n",
__func__, ret); __func__, ret);
goto cleanup; goto cleanup;
} }
...@@ -98,17 +98,17 @@ cleanup: ...@@ -98,17 +98,17 @@ cleanup:
return; return;
} }
void mt7697_irq_work(struct work_struct *irq_work) void mt7697q_irq_work(struct work_struct *irq_work)
{ {
struct mt7697q_info *qinfo = container_of(irq_work, struct mt7697q_info *qinfo = container_of(irq_work,
struct mt7697q_info, irq_work); struct mt7697q_info, irq_work);
int ret; int ret;
dev_dbg(qinfo->dev, "%s(): process work\n", __func__); dev_dbg(qinfo->dev, "%s(): process work\n", __func__);
ret = mt7697_irq_run(qinfo); ret = mt7697q_irq_run(qinfo);
if (ret < 0) { if (ret < 0) {
dev_err(qinfo->dev, dev_err(qinfo->dev,
"%s(): mt7697_irq_run() failed(%d)\n", "%s(): mt7697q_irq_run() failed(%d)\n",
__func__, ret); __func__, ret);
goto cleanup; goto cleanup;
} }
...@@ -117,9 +117,9 @@ cleanup: ...@@ -117,9 +117,9 @@ cleanup:
return; return;
} }
irqreturn_t mt7697_isr(int irq, void *cookie) irqreturn_t mt7697q_isr(int irq, void *arg)
{ {
struct mt7697q_info *qinfo = cookie; struct mt7697q_info *qinfo = (struct mt7697q_info*)arg;
disable_irq_nosync(qinfo->irq); disable_irq_nosync(qinfo->irq);
if (!queue_work(qinfo->irq_workq, &qinfo->irq_work)) { if (!queue_work(qinfo->irq_workq, &qinfo->irq_work)) {
......
...@@ -14,12 +14,13 @@ ...@@ -14,12 +14,13 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#ifndef _MT7697_INTERRUPT_H_ #ifndef _MT7697_SPI_QUEUE_INTERRUPT_H_
#define _MT7697_INTERRUPT_H_ #define _MT7697_SPI_QUEUE_INTERRUPT_H_
#include <linux/interrupt.h> #include <linux/interrupt.h>
irqreturn_t mt7697_isr(int, void*); irqreturn_t mt7697q_isr(int, void*);
void mt7697_irq_work(struct work_struct*); void mt7697q_irq_work(struct work_struct*);
void mt7697q_irq_delayed_work(struct work_struct*);
#endif #endif
...@@ -290,6 +290,40 @@ cleanup: ...@@ -290,6 +290,40 @@ cleanup:
return ret; return ret;
} }
static int mt7697q_wr_unused(struct mt7697q_spec *qsM2S, struct mt7697q_spec *qsS2M)
{
struct mt7697_queue_reset_req req;
int ret;
req.cmd.len = sizeof(struct mt7697_queue_reset_req);
req.cmd.grp = MT7697_CMD_GRP_QUEUE;
req.cmd.type = MT7697_CMD_QUEUE_UNUSED;
req.m2s_ch = qsM2S->ch;
req.s2m_ch = qsS2M->ch;
qsM2S->data.flags &= ~BF_GET(qsM2S->data.flags, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
qsS2M->data.flags &= ~BF_GET(qsS2M->data.flags, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
dev_dbg(qsM2S->qinfo->dev, "%s(): <-- QUEUE UNUSED(%u/%u)\n",
__func__, req.m2s_ch, req.s2m_ch);
ret = mt7697q_write(qsM2S, (const u32*)&req,
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(qsM2S->qinfo->dev,
"%s(): mt7697q_write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
__inline size_t mt7697q_get_free_words(const struct mt7697q_spec *qs) __inline size_t mt7697q_get_free_words(const struct mt7697q_spec *qs)
{ {
return mt7697q_get_capacity(qs) - mt7697q_get_num_words(qs); return mt7697q_get_capacity(qs) - mt7697q_get_num_words(qs);
...@@ -345,8 +379,8 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M) ...@@ -345,8 +379,8 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M)
avail = mt7697q_get_num_words(qsS2M); avail = mt7697q_get_num_words(qsS2M);
req = (qsS2M->qinfo->rsp.cmd.len > 0) ? req = (qsS2M->qinfo->rsp.cmd.len > 0) ?
LEN_TO_WORD(qsS2M->qinfo->rsp.cmd.len - sizeof(struct mt7697q_rsp_hdr)) : LEN_TO_WORD(qsS2M->qinfo->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr)) :
LEN_TO_WORD(sizeof(struct mt7697q_rsp_hdr)); LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr));
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n", dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req); __func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
...@@ -360,8 +394,8 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M) ...@@ -360,8 +394,8 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M)
goto cleanup; goto cleanup;
} }
avail -= LEN_TO_WORD(sizeof(struct mt7697q_rsp_hdr)); avail -= LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr));
req = LEN_TO_WORD(qsS2M->qinfo->rsp.cmd.len - sizeof(struct mt7697q_rsp_hdr)); req = LEN_TO_WORD(qsS2M->qinfo->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr));
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n", dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req); __func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
} }
...@@ -404,7 +438,7 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M) ...@@ -404,7 +438,7 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M)
} }
else { else {
WARN_ON(!qsS2M->rx_fcn); WARN_ON(!qsS2M->rx_fcn);
ret = qsS2M->rx_fcn((const struct mt7697q_rsp_hdr*)&qsS2M->qinfo->rsp, qsS2M->priv); ret = qsS2M->rx_fcn((const struct mt7697_rsp_hdr*)&qsS2M->qinfo->rsp, qsS2M->priv);
if (ret < 0) { if (ret < 0) {
dev_err(qsS2M->qinfo->dev, dev_err(qsS2M->qinfo->dev,
"%s(): rx_fcn() failed(%d)\n", "%s(): rx_fcn() failed(%d)\n",
...@@ -414,7 +448,7 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M) ...@@ -414,7 +448,7 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M)
avail -= req; avail -= req;
qsS2M->qinfo->rsp.cmd.len = 0; qsS2M->qinfo->rsp.cmd.len = 0;
req = LEN_TO_WORD(sizeof(struct mt7697q_rsp_hdr)); req = LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr));
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n", dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req); __func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
...@@ -453,44 +487,6 @@ __inline void mt7697q_unblock_writer(void *hndl) ...@@ -453,44 +487,6 @@ __inline void mt7697q_unblock_writer(void *hndl)
EXPORT_SYMBOL(mt7697q_unblock_writer); EXPORT_SYMBOL(mt7697q_unblock_writer);
int mt7697q_wr_unused(void *tx_hndl, void* rx_hndl)
{
struct mt7697q_spec *qsM2S = (struct mt7697q_spec*)tx_hndl;
struct mt7697q_spec *qsS2M = (struct mt7697q_spec*)rx_hndl;
struct mt7697_queue_reset_req req;
int ret;
req.cmd.len = sizeof(struct mt7697_queue_reset_req);
req.cmd.grp = MT7697_CMD_GRP_QUEUE;
req.cmd.type = MT7697_CMD_QUEUE_UNUSED;
req.m2s_ch = qsM2S->ch;
req.s2m_ch = qsS2M->ch;
qsM2S->data.flags &= ~BF_GET(qsM2S->data.flags, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
qsS2M->data.flags &= ~BF_GET(qsS2M->data.flags, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
dev_dbg(qsM2S->qinfo->dev, "%s(): <-- QUEUE UNUSED(%u/%u)\n",
__func__, req.m2s_ch, req.s2m_ch);
ret = mt7697q_write(qsM2S, (const u32*)&req,
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(qsM2S->qinfo->dev,
"%s(): mt7697q_write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
EXPORT_SYMBOL(mt7697q_wr_unused);
int mt7697q_wr_reset(void *tx_hndl, void* rx_hndl) int mt7697q_wr_reset(void *tx_hndl, void* rx_hndl)
{ {
struct mt7697q_spec *qsM2S = (struct mt7697q_spec*)tx_hndl; struct mt7697q_spec *qsM2S = (struct mt7697q_spec*)tx_hndl;
...@@ -646,6 +642,28 @@ cleanup: ...@@ -646,6 +642,28 @@ cleanup:
EXPORT_SYMBOL(mt7697q_init); EXPORT_SYMBOL(mt7697q_init);
int mt7697q_shutdown(void **tx_hndl, void **rx_hndl)
{
struct mt7697q_spec *qsM2S = *tx_hndl;
struct mt7697q_spec *qsS2M = *rx_hndl;
int ret;
ret = mt7697q_wr_unused(qsM2S, qsS2M);
if (ret < 0) {
dev_err(qsM2S->qinfo->dev, "%s(): mt7697q_wr_unused() failed(%d)\n",
__func__, ret);
goto cleanup;
}
*tx_hndl = NULL;
*rx_hndl = NULL;
cleanup:
return ret;
}
EXPORT_SYMBOL(mt7697q_shutdown);
size_t mt7697q_read(void *hndl, u32 *buf, size_t num) size_t mt7697q_read(void *hndl, u32 *buf, size_t num)
{ {
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl; struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
......
...@@ -54,7 +54,7 @@ struct mt7697q_spec { ...@@ -54,7 +54,7 @@ struct mt7697q_spec {
struct mt7697q_info { struct mt7697q_info {
struct mt7697q_spec queues[MT7697_NUM_QUEUES]; struct mt7697q_spec queues[MT7697_NUM_QUEUES];
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
u8 txBuffer[sizeof(u32)]; u8 txBuffer[sizeof(u32)];
u8 rxBuffer[sizeof(u32)]; u8 rxBuffer[sizeof(u32)];
...@@ -68,14 +68,15 @@ struct mt7697q_info { ...@@ -68,14 +68,15 @@ struct mt7697q_info {
struct work_struct irq_work; struct work_struct irq_work;
struct delayed_work irq_delayed_work; struct delayed_work irq_delayed_work;
atomic_t blocked_writer; atomic_t blocked_writer;
int gpio_pin;
int irq; int irq;
u8 s2m_mbox; u8 s2m_mbox;
bool slave_busy; bool slave_busy;
}; };
void mt7697_irq_delayed_work(struct work_struct*); void mt7697q_irq_delayed_work(struct work_struct*);
void mt7697_irq_work(struct work_struct*); void mt7697q_irq_work(struct work_struct*);
irqreturn_t mt7697_isr(int, void*); irqreturn_t mt7697q_isr(int, void*);
int mt7697q_blocked_writer(const struct mt7697q_spec*); int mt7697q_blocked_writer(const struct mt7697q_spec*);
size_t mt7697q_get_free_words(const struct mt7697q_spec*); size_t mt7697q_get_free_words(const struct mt7697q_spec*);
......
...@@ -17,13 +17,10 @@ ...@@ -17,13 +17,10 @@
#ifndef _MT7697_QUEUE_I_H_ #ifndef _MT7697_QUEUE_I_H_
#define _MT7697_QUEUE_I_H_ #define _MT7697_QUEUE_I_H_
#define LEN32_ALIGNED(x) (((x) / sizeof(u32) + \ #include "mt7697_i.h"
((x) % sizeof(u32) ? 1:0)) * sizeof(u32))
#define LEN_TO_WORD(x) ((x) / sizeof(u32) + \
((x) % sizeof(u32) ? 1:0))
#define mt7697_queue_init_rsp mt7697q_rsp_hdr #define mt7697_queue_init_rsp mt7697_rsp_hdr
#define mt7697_queue_reset_rsp mt7697q_rsp_hdr #define mt7697_queue_reset_rsp mt7697_rsp_hdr
enum mt7697q_dir enum mt7697q_dir
{ {
...@@ -31,12 +28,6 @@ enum mt7697q_dir ...@@ -31,12 +28,6 @@ enum mt7697q_dir
MT7697_QUEUE_DIR_S2M, MT7697_QUEUE_DIR_S2M,
}; };
enum mt7697q_cmd_grp {
MT7697_CMD_GRP_QUEUE = 0,
MT7697_CMD_GRP_80211,
MT7697_CMD_GRP_BT,
};
enum mt7697q_cmd_types { enum mt7697q_cmd_types {
MT7697_CMD_QUEUE_INIT = 0, MT7697_CMD_QUEUE_INIT = 0,
MT7697_CMD_QUEUE_INIT_RSP, MT7697_CMD_QUEUE_INIT_RSP,
...@@ -45,55 +36,33 @@ enum mt7697q_cmd_types { ...@@ -45,55 +36,33 @@ enum mt7697q_cmd_types {
MT7697_CMD_QUEUE_RESET_RSP, MT7697_CMD_QUEUE_RESET_RSP,
}; };
struct mt7697q_cmd_hdr {
__be16 len;
u8 grp;
u8 type;
} __attribute__((__packed__, aligned(4)));
struct mt7697q_rsp_hdr {
struct mt7697q_cmd_hdr cmd;
__be32 result;
} __attribute__((__packed__, aligned(4)));
struct mt7697_queue_init_req { struct mt7697_queue_init_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 m2s_ch; __be32 m2s_ch;
__be32 s2m_ch; __be32 s2m_ch;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_queue_unused_req { struct mt7697_queue_unused_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 m2s_ch; __be32 m2s_ch;
__be32 s2m_ch; __be32 s2m_ch;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_queue_reset_req { struct mt7697_queue_reset_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 m2s_ch; __be32 m2s_ch;
__be32 s2m_ch; __be32 s2m_ch;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
typedef int (*rx_hndlr)(const struct mt7697q_rsp_hdr*, void*);
typedef int (*notify_tx_hndlr)(void*, u32);
struct mt7697q_if_ops {
int (*init)(u8, u8, void*, notify_tx_hndlr, rx_hndlr, void**, void**);
size_t (*read)(void*, u32*, size_t);
size_t (*write)(void*, const u32*, size_t);
void (*reset)(void*);
void (*enable_irq)(void*);
void (*disable_irq)(void*);
};
u32 mt7697q_flags_get_in_use(u32); u32 mt7697q_flags_get_in_use(u32);
u32 mt7697q_flags_get_dir(u32); u32 mt7697q_flags_get_dir(u32);
int mt7697q_init(u8, u8, void*, notify_tx_hndlr, rx_hndlr, void**, void**); int mt7697q_init(u8, u8, void*, notify_tx_hndlr, rx_hndlr, void**, void**);
int mt7697q_wr_reset(void*, void*); int mt7697q_shutdown(void**, void**);
int mt7697q_wr_unused(void*, void*);
size_t mt7697q_read(void*, u32*, size_t); size_t mt7697q_read(void*, u32*, size_t);
void mt7697q_unblock_writer(void*);
size_t mt7697q_write(void*, const u32*, size_t); size_t mt7697q_write(void*, const u32*, size_t);
int mt7697q_wr_reset(void*, void*);
void mt7697q_unblock_writer(void*);
#endif #endif
...@@ -34,9 +34,9 @@ static int mt7697spi_write_then_read(struct spi_device *spi, const void *txbuf, ...@@ -34,9 +34,9 @@ static int mt7697spi_write_then_read(struct spi_device *spi, const void *txbuf,
void *rxbuf, unsigned len) void *rxbuf, unsigned len)
{ {
struct spi_transfer transfer = { struct spi_transfer transfer = {
.tx_buf = txbuf, .tx_buf = txbuf,
.rx_buf = rxbuf, .rx_buf = rxbuf,
.len = len, .len = len,
}; };
return spi_sync_transfer(spi, &transfer, 1); return spi_sync_transfer(spi, &transfer, 1);
...@@ -123,7 +123,7 @@ static int __init mt7697spi_init(void) ...@@ -123,7 +123,7 @@ static int __init mt7697spi_init(void)
goto cleanup; goto cleanup;
} }
dev_info(&master->dev, "%s(): init dev('%s') mode(%d) max speed(%d) " dev_info(&master->dev, "%s(): dev('%s') mode(%d) max speed(%d) "
"CS(%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->bits_per_word); spi->chip_select, spi->bits_per_word);
...@@ -143,8 +143,8 @@ static int __init mt7697spi_init(void) ...@@ -143,8 +143,8 @@ static int __init mt7697spi_init(void)
qinfo->hw_ops = &hw_ops; qinfo->hw_ops = &hw_ops;
mutex_init(&qinfo->mutex); mutex_init(&qinfo->mutex);
INIT_DELAYED_WORK(&qinfo->irq_delayed_work, mt7697_irq_delayed_work); INIT_DELAYED_WORK(&qinfo->irq_delayed_work, mt7697q_irq_delayed_work);
INIT_WORK(&qinfo->irq_work, mt7697_irq_work); INIT_WORK(&qinfo->irq_work, mt7697q_irq_work);
qinfo->irq_workq = alloc_workqueue(DRVNAME"wq", qinfo->irq_workq = alloc_workqueue(DRVNAME"wq",
WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1); WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
...@@ -155,17 +155,25 @@ static int __init mt7697spi_init(void) ...@@ -155,17 +155,25 @@ static int __init mt7697spi_init(void)
goto cleanup; goto cleanup;
} }
ret = gpio_request(MT7697_SPI_INTR_GPIO_PIN, MT7697_GPIO_IRQ_NAME); qinfo->gpio_pin = MT7697_SPI_INTR_GPIO_PIN;
ret = gpio_request(qinfo->gpio_pin, MT7697_SPI_GPIO_IRQ_NAME);
if (ret < 0) { if (ret < 0) {
dev_err(qinfo->dev, "%s(): gpio_request() failed(%d)", if (ret != -EBUSY) {
__func__, ret); dev_err(qinfo->dev, "%s(): gpio_request() failed(%d)",
goto failed_workqueue; __func__, ret);
goto failed_workqueue;
}
qinfo->irq = gpio_to_irq(qinfo->gpio_pin);
qinfo->gpio_pin = MT7697_SPI_INTR_GPIO_PIN_INVALID;
} }
else {
gpio_direction_input(qinfo->gpio_pin);
qinfo->irq = gpio_to_irq(qinfo->gpio_pin);
}
gpio_direction_input(MT7697_SPI_INTR_GPIO_PIN);
qinfo->irq = gpio_to_irq(MT7697_SPI_INTR_GPIO_PIN);
dev_info(qinfo->dev, "%s(): request irq(%d)\n", __func__, qinfo->irq); dev_info(qinfo->dev, "%s(): request irq(%d)\n", __func__, qinfo->irq);
ret = request_irq(qinfo->irq, mt7697_isr, 0, DRVNAME, qinfo); ret = request_irq(qinfo->irq, mt7697q_isr, 0, DRVNAME, qinfo);
if (ret < 0) { if (ret < 0) {
dev_err(qinfo->dev, "%s(): request_irq() failed(%d)", dev_err(qinfo->dev, "%s(): request_irq() failed(%d)",
__func__, ret); __func__, ret);
...@@ -183,7 +191,7 @@ failed_workqueue: ...@@ -183,7 +191,7 @@ failed_workqueue:
destroy_workqueue(qinfo->irq_workq); destroy_workqueue(qinfo->irq_workq);
failed_gpio_req: failed_gpio_req:
gpio_free(MT7697_SPI_INTR_GPIO_PIN); if (qinfo->gpio_pin > 0) gpio_free(qinfo->gpio_pin);
cleanup: cleanup:
if (qinfo) kfree(qinfo); if (qinfo) kfree(qinfo);
...@@ -241,7 +249,7 @@ static void __exit mt7697spi_exit(void) ...@@ -241,7 +249,7 @@ static void __exit mt7697spi_exit(void)
destroy_workqueue(qinfo->irq_workq); destroy_workqueue(qinfo->irq_workq);
free_irq(qinfo->irq, qinfo); free_irq(qinfo->irq, qinfo);
gpio_free(MT7697_SPI_INTR_GPIO_PIN); if (qinfo->gpio_pin > 0) gpio_free(qinfo->gpio_pin);
kfree(qinfo); kfree(qinfo);
cleanup: cleanup:
......
...@@ -24,14 +24,15 @@ ...@@ -24,14 +24,15 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#define DRVNAME "mt7697q" #define DRVNAME "mt7697q"
#define MT7697_GPIO_IRQ_NAME "mt7697q irq" #define MT7697_SPI_GPIO_IRQ_NAME "mt7697q irq"
#define MT7697_SPI_INTR_GPIO_PIN 50 #define MT7697_SPI_INTR_GPIO_PIN 50
#define MT7697_SPI_BUS_NUM 32766 #define MT7697_SPI_INTR_GPIO_PIN_INVALID -1
#define MT7697_SPI_CS 0 #define MT7697_SPI_BUS_NUM 32766
#define MT7697_SPI_CS 0
#define MT7697_SPI_CONFIG "0,2,-1,0,0,1,0,0,0,0,0,mt7697" #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);
......
...@@ -7,6 +7,11 @@ sources: ...@@ -7,6 +7,11 @@ sources:
ioctl.c ioctl.c
} }
params:
{
hw_itf = "spi"
}
cflags: cflags:
{ {
// -DDEBUG // -DDEBUG
...@@ -17,5 +22,7 @@ cflags: ...@@ -17,5 +22,7 @@ cflags:
-DCONFIG_WEXT_PROC -DCONFIG_WEXT_PROC
-DCONFIG_WEXT_SPY -DCONFIG_WEXT_SPY
-DCONFIG_WEXT_PRIV -DCONFIG_WEXT_PRIV
-I$MANGOH_ROOT/linux_kernel_modules/mt7697common
-I$MANGOH_ROOT/linux_kernel_modules/mt7697q -I$MANGOH_ROOT/linux_kernel_modules/mt7697q
-I$MANGOH_ROOT/linux_kernel_modules/mt7697serial
} }
...@@ -1082,12 +1082,25 @@ int mt7697_cfg80211_stop(struct mt7697_vif *vif) ...@@ -1082,12 +1082,25 @@ int mt7697_cfg80211_stop(struct mt7697_vif *vif)
vif->cfg->radio_state = MT7697_RADIO_STATE_OFF; vif->cfg->radio_state = MT7697_RADIO_STATE_OFF;
} }
ret = mt7697q_wr_unused(vif->cfg->txq_hdl, vif->cfg->rxq_hdl); if (vif->cfg->hif_ops->shutdown) {
if (ret < 0) { ret = vif->cfg->hif_ops->shutdown(&vif->cfg->txq_hdl, &vif->cfg->rxq_hdl);
dev_err(vif->cfg->dev, if (ret < 0) {
"%s(): mt7697q_wr_unused() failed(%d)\n", dev_err(vif->cfg->dev,
__func__, ret); "%s(): shutdown() failed(%d)\n",
goto cleanup; __func__, ret);
goto cleanup;
}
}
else {
ret = vif->cfg->hif_ops->close(vif->cfg->txq_hdl);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): shutdown() failed(%d)\n",
__func__, ret);
goto cleanup;
}
vif->cfg->rxq_hdl = NULL;
} }
/* Stop netdev queues, needed during recovery */ /* Stop netdev queues, needed during recovery */
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <net/cfg80211.h> #include <net/cfg80211.h>
#include <net/iw_handler.h> /* New driver API */ #include <net/iw_handler.h> /* New driver API */
#include "mt7697_i.h"
#include "wifi_api.h" #include "wifi_api.h"
#include "wmi.h" #include "wmi.h"
...@@ -90,7 +91,7 @@ struct mt7697_cfg80211_info { ...@@ -90,7 +91,7 @@ struct mt7697_cfg80211_info {
struct semaphore sem; struct semaphore sem;
struct platform_device *hif_priv; struct platform_device *hif_priv;
const struct mt7697q_if_ops *hif_ops; const struct mt7697_if_ops *hif_ops;
void* txq_hdl; void* txq_hdl;
void* rxq_hdl; void* rxq_hdl;
...@@ -219,7 +220,7 @@ int mt7697_notify_tx(void*, u32); ...@@ -219,7 +220,7 @@ int mt7697_notify_tx(void*, u32);
void mt7697_tx_work(struct work_struct *); void mt7697_tx_work(struct work_struct *);
int mt7697_data_tx(struct sk_buff*, struct net_device*); int mt7697_data_tx(struct sk_buff*, struct net_device*);
int mt7697_rx_data(struct mt7697_cfg80211_info*, u32, u32); int mt7697_rx_data(struct mt7697_cfg80211_info*, u32, u32);
int mt7697_proc_80211cmd(const struct mt7697q_rsp_hdr*, void*); int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr*, void*);
void mt7697_disconnect_timer_hndlr(unsigned long); void mt7697_disconnect_timer_hndlr(unsigned long);
int mt7697_disconnect(struct mt7697_vif*); int mt7697_disconnect(struct mt7697_vif*);
......
...@@ -18,17 +18,34 @@ ...@@ -18,17 +18,34 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <net/cfg80211.h> #include <net/cfg80211.h>
#include "mt7697_i.h"
#include "queue_i.h" #include "queue_i.h"
#include "uart_i.h"
#include "common.h" #include "common.h"
#include "ioctl.h" #include "ioctl.h"
#include "core.h" #include "core.h"
#include "cfg80211.h" #include "cfg80211.h"
static int itf_idx_start = 1; static char* hw_itf = "spi";
module_param(hw_itf, charp, S_IRUGO);
MODULE_PARM_DESC(hw_itf, "MT7697 transport interface (SPI/UART");
static int itf_idx_start = 0;
module_param(itf_idx_start, int, S_IRUGO); module_param(itf_idx_start, int, S_IRUGO);
MODULE_PARM_DESC(itf_idx_start, "MT7697 interface start index"); MODULE_PARM_DESC(itf_idx_start, "MT7697 WiFi interface start index");
static struct platform_device *pdev = NULL; static void mt7697_to_lower(char** in)
{
char* ptr = (char*)*in;
while (*ptr != '\0') {
if (((*ptr <= 'Z') && (*ptr >= 'A')) ||
((*ptr <= 'z') && (*ptr >= 'a')))
*ptr = ((*ptr <= 'Z') && (*ptr >= 'A')) ?
*ptr + 'a' - 'A':*ptr;
ptr++;
}
}
static int mt7697_open(struct net_device *ndev) static int mt7697_open(struct net_device *ndev)
{ {
...@@ -127,18 +144,30 @@ static void mt7697_init_hw_start(struct work_struct *work) ...@@ -127,18 +144,30 @@ static void mt7697_init_hw_start(struct work_struct *work)
struct mt7697_cfg80211_info *cfg = container_of(work, struct mt7697_cfg80211_info *cfg = container_of(work,
struct mt7697_cfg80211_info, init_work); struct mt7697_cfg80211_info, init_work);
int err; int err;
if (!strcmp(hw_itf, "spi")) {
dev_dbg(cfg->dev, "%s(): init mt7697 queue(%u/%u)\n",
__func__, MT7697_MAC80211_QUEUE_TX, MT7697_MAC80211_QUEUE_RX);
err = cfg->hif_ops->init(MT7697_MAC80211_QUEUE_TX,
MT7697_MAC80211_QUEUE_RX, cfg,
mt7697_notify_tx,
mt7697_proc_80211cmd,
&cfg->txq_hdl, &cfg->rxq_hdl);
if (err < 0) {
dev_err(cfg->dev, "%s(): queue(%u) init() failed(%d)\n",
__func__, MT7697_MAC80211_QUEUE_TX, err);
goto failed;
}
}
else {
dev_dbg(cfg->dev, "%s(): open mt7697 uart\n", __func__);
cfg->txq_hdl = cfg->hif_ops->open(mt7697_proc_80211cmd, cfg);
if (!cfg->txq_hdl) {
dev_err(cfg->dev, "%s(): open() failed\n", __func__);
goto failed;
}
dev_dbg(cfg->dev, "%s(): init mt7697 queue(%u/%u)\n", cfg->rxq_hdl = cfg->txq_hdl;
__func__, MT7697_MAC80211_QUEUE_TX, MT7697_MAC80211_QUEUE_RX);
err = cfg->hif_ops->init(MT7697_MAC80211_QUEUE_TX,
MT7697_MAC80211_QUEUE_RX, cfg,
mt7697_notify_tx,
mt7697_proc_80211cmd,
&cfg->txq_hdl, &cfg->rxq_hdl);
if (err < 0) {
dev_err(cfg->dev, "%s(): queue(%u) init() failed(%d)\n",
__func__, MT7697_MAC80211_QUEUE_TX, err);
goto failed;
} }
cfg->radio_state = MT7697_RADIO_STATE_OFF; cfg->radio_state = MT7697_RADIO_STATE_OFF;
...@@ -180,11 +209,7 @@ void mt7697_init_netdev(struct net_device *ndev) ...@@ -180,11 +209,7 @@ void mt7697_init_netdev(struct net_device *ndev)
ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM; ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
} }
static const struct mt7697q_if_ops if_ops = { static struct mt7697_if_ops if_ops;
.init = mt7697q_init,
.read = mt7697q_read,
.write = mt7697q_write,
};
static int mt7697_probe(struct platform_device *pdev) static int mt7697_probe(struct platform_device *pdev)
{ {
...@@ -223,6 +248,29 @@ static int mt7697_probe(struct platform_device *pdev) ...@@ -223,6 +248,29 @@ static int mt7697_probe(struct platform_device *pdev)
atomic_set(&cfg->tx_skb_pool_idx, 0); atomic_set(&cfg->tx_skb_pool_idx, 0);
memset(cfg->tx_skb_pool, 0, sizeof(cfg->tx_skb_pool)); memset(cfg->tx_skb_pool, 0, sizeof(cfg->tx_skb_pool));
mt7697_to_lower(&hw_itf);
dev_dbg(&pdev->dev, "%s(): hw_itf('%s')\n", __func__, hw_itf);
if (!strcmp(hw_itf, "spi")) {
if_ops.init = mt7697q_init;
if_ops.shutdown = mt7697q_shutdown;
if_ops.read = mt7697q_read;
if_ops.write = mt7697q_write;
if_ops.unblock_writer = mt7697q_unblock_writer;
}
else if (!strcmp(hw_itf, "uart")) {
if_ops.open = mt7697_uart_open;
if_ops.close = mt7697_uart_close;
if_ops.read = mt7697_uart_read;
if_ops.write = mt7697_uart_write;
}
else {
dev_err(&pdev->dev,
"%s(): invalid hw itf(spi/uart) module paramter('%s')\n",
__func__, hw_itf);
err = -EINVAL;
goto failed;
}
cfg->hif_ops = &if_ops; cfg->hif_ops = &if_ops;
cfg->dev = &pdev->dev; cfg->dev = &pdev->dev;
skb_queue_head_init(&cfg->tx_skb_queue); skb_queue_head_init(&cfg->tx_skb_queue);
...@@ -299,7 +347,7 @@ static int __init mt7697_init(void) ...@@ -299,7 +347,7 @@ static int __init mt7697_init(void)
if (ret) { if (ret) {
pr_err(DRVNAME" %s(): platform_driver_register() failed(%d)\n", pr_err(DRVNAME" %s(): platform_driver_register() failed(%d)\n",
__func__, ret); __func__, ret);
platform_device_del(pdev); platform_device_del(&mt7697_platform_device);
goto cleanup; goto cleanup;
} }
......
...@@ -14,5 +14,5 @@ iface wlan0 inet manual ...@@ -14,5 +14,5 @@ iface wlan0 inet manual
post-down /etc/init.d/tiwifi stop post-down /etc/init.d/tiwifi stop
iface wlan1 inet manual iface wlan1 inet manual
pre-up /etc/init.d/mtwifi start 1 pre-up /etc/init.d/mtwifi start uart 1
post-down /etc/init.d/mtwifi stop 1 post-down /etc/init.d/mtwifi stop 1
...@@ -24,3 +24,4 @@ fi ...@@ -24,3 +24,4 @@ fi
echo "Updating MT7697 WiFi init script..." echo "Updating MT7697 WiFi init script..."
cp /tmp/mtwifi /etc/init.d/mtwifi cp /tmp/mtwifi /etc/init.d/mtwifi
chmod +x /etc/init.d/mtwifi chmod +x /etc/init.d/mtwifi
...@@ -7,29 +7,38 @@ ...@@ -7,29 +7,38 @@
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/flash/wifi #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/flash/wifi
mt_wifi_start() { mt_wifi_start() {
stty -F /dev/ttyHS0 raw || exit 127
stty -F /dev/ttyHS0 921600 || exit 127
stty -F /dev/ttyHS0 crtscts || exit 127
stty -F /dev/ttyHS0 -echo || exit 127
lsmod | grep 2_mt7697wifi_core >/dev/null lsmod | grep 2_mt7697wifi_core >/dev/null
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
insmod /legato/systems/current/modules/2-mt7697wifi_core.ko itf_idx_start=$1 || exit 127 insmod /legato/systems/current/modules/2-mt7697wifi_core.ko hw_itf=$1 itf_idx_start=$2 || exit 127
echo "Initialized MT7697 80211 core"; echo "Initialized MT7697 WiFi core";
sleep 2 sleep 2
fi fi
ifconfig -a | grep wlan$1 >/dev/null ifconfig -a | grep wlan$2 >/dev/null
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "Failed to init MT7697 80211 core"; echo "Failed to init MT7697 WiFi core";
exit 127 exit 127
fi fi
ifconfig wlan$1 up >/dev/null ifconfig wlan$2 up >/dev/null
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "Failed to start MT7697 80211 core"; echo "Failed to start MT7697 WiFi core";
exit 127 exit 127
fi fi
echo "Started MT7697 WiFi $1 core wlan$2";
} }
mt_wifi_stop() { mt_wifi_stop() {
kill -9 $(pidof wpa_supplicant) kill -9 $(pidof wpa_supplicant)
echo "Stop MT7697 WiFi core wlan$1";
ifconfig | grep wlan$1 >/dev/null ifconfig | grep wlan$1 >/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
ifconfig wlan$1 down ifconfig wlan$1 down
...@@ -38,20 +47,20 @@ mt_wifi_stop() { ...@@ -38,20 +47,20 @@ mt_wifi_stop() {
lsmod | grep 2_mt7697wifi_core >/dev/null lsmod | grep 2_mt7697wifi_core >/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rmmod 2_mt7697wifi_core || exit 127 rmmod 2_mt7697wifi_core || exit 127
echo "Removed MT7697 80211 core"; exit 127 echo "Removed MT7697 WiFi core"; exit 127
fi fi
} }
case "$1" in case "$1" in
start) start)
mt_wifi_start $2 mt_wifi_start $2 $3
;; ;;
stop) stop)
mt_wifi_stop $2 mt_wifi_stop $2
;; ;;
restart) restart)
mt_wifi_stop $2 mt_wifi_stop $2
mt_wifi_start $2 mt_wifi_start $2 $3
;; ;;
*) *)
exit 1 exit 1
......
...@@ -28,7 +28,7 @@ int mt7697_notify_tx(void* priv, u32 free) ...@@ -28,7 +28,7 @@ int mt7697_notify_tx(void* priv, u32 free)
struct mt7697_tx_pkt *tx_pkt = list_entry(&cfg->tx_skb_list, struct mt7697_tx_pkt *tx_pkt = list_entry(&cfg->tx_skb_list,
struct mt7697_tx_pkt, next); struct mt7697_tx_pkt, next);
if (tx_pkt->skb->len >= free) { if (tx_pkt->skb->len >= free) {
mt7697q_unblock_writer(cfg->txq_hdl); cfg->hif_ops->unblock_writer(cfg->txq_hdl);
ret = queue_work(cfg->tx_workq, &cfg->tx_work); ret = queue_work(cfg->tx_workq, &cfg->tx_work);
if (ret < 0) { if (ret < 0) {
dev_err(cfg->dev, "%s(): queue_work() failed(%d)\n", dev_err(cfg->dev, "%s(): queue_work() failed(%d)\n",
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "cfg80211.h" #include "cfg80211.h"
#include "wifi_api.h" #include "wifi_api.h"
static int mt7697_proc_mac_addr(const struct mt7697q_rsp_hdr* rsp, static int mt7697_proc_mac_addr(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg) struct mt7697_cfg80211_info *cfg)
{ {
u8 addr[LEN32_ALIGNED(ETH_ALEN)]; u8 addr[LEN32_ALIGNED(ETH_ALEN)];
...@@ -77,18 +77,18 @@ cleanup: ...@@ -77,18 +77,18 @@ cleanup:
return ret; return ret;
} }
static int mt7697_proc_get_wireless_mode(const struct mt7697q_rsp_hdr* rsp, static int mt7697_proc_get_wireless_mode(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg) struct mt7697_cfg80211_info *cfg)
{ {
u32 wireless_mode; u32 wireless_mode;
int ret = 0; int ret = 0;
dev_dbg(cfg->dev, "%s(): --> WIRELESS MODE\n", __func__); dev_dbg(cfg->dev, "%s(): --> WIRELESS MODE\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) != sizeof(u32)) { if (rsp->cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(u32)) {
dev_err(cfg->dev, dev_err(cfg->dev,
"%s(): invalid wireless mode rsp len(%u != %u)\n", "%s(): invalid wireless mode rsp len(%u != %u)\n",
__func__, __func__,
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr), rsp->cmd.len - sizeof(struct mt7697_rsp_hdr),
sizeof(u32)); sizeof(u32));
ret = -EINVAL; ret = -EINVAL;
goto cleanup; goto cleanup;
...@@ -112,7 +112,7 @@ cleanup: ...@@ -112,7 +112,7 @@ cleanup:
return ret; return ret;
} }
static int mt7697_proc_get_cfg(const struct mt7697q_rsp_hdr* rsp, static int mt7697_proc_get_cfg(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg) struct mt7697_cfg80211_info *cfg)
{ {
struct mt7697_wifi_config_t *wifi_cfg; struct mt7697_wifi_config_t *wifi_cfg;
...@@ -120,11 +120,11 @@ static int mt7697_proc_get_cfg(const struct mt7697q_rsp_hdr* rsp, ...@@ -120,11 +120,11 @@ static int mt7697_proc_get_cfg(const struct mt7697q_rsp_hdr* rsp,
int ret = 0; int ret = 0;
dev_dbg(cfg->dev, "%s(): --> CONFIG\n", __func__); dev_dbg(cfg->dev, "%s(): --> CONFIG\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) != if (rsp->cmd.len - sizeof(struct mt7697_rsp_hdr) !=
LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t))) { LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t))) {
dev_err(cfg->dev, "%s(): invalid cfg rsp len(%u != %u)\n", dev_err(cfg->dev, "%s(): invalid cfg rsp len(%u != %u)\n",
__func__, __func__,
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr), rsp->cmd.len - sizeof(struct mt7697_rsp_hdr),
LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t))); LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t)));
ret = -EINVAL; ret = -EINVAL;
goto cleanup; goto cleanup;
...@@ -264,18 +264,18 @@ cleanup: ...@@ -264,18 +264,18 @@ cleanup:
return ret; return ret;
} }
static int mt7697_proc_get_radio_state(const struct mt7697q_rsp_hdr* rsp, static int mt7697_proc_get_radio_state(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg) struct mt7697_cfg80211_info *cfg)
{ {
u32 state; u32 state;
int ret = 0; int ret = 0;
dev_dbg(cfg->dev, "%s(): --> GET RADIO STATE\n", __func__); dev_dbg(cfg->dev, "%s(): --> GET RADIO STATE\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) != sizeof(u32)) { if (rsp->cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(u32)) {
dev_err(cfg->dev, dev_err(cfg->dev,
"%s(): invalid get radio state rsp len(%u != %u)\n", "%s(): invalid get radio state rsp len(%u != %u)\n",
__func__, __func__,
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr), rsp->cmd.len - sizeof(struct mt7697_rsp_hdr),
sizeof(u32)); sizeof(u32));
ret = -EINVAL; ret = -EINVAL;
goto cleanup; goto cleanup;
...@@ -298,18 +298,18 @@ cleanup: ...@@ -298,18 +298,18 @@ cleanup:
return ret; return ret;
} }
static int mt7697_proc_get_listen_interval(const struct mt7697q_rsp_hdr* rsp, static int mt7697_proc_get_listen_interval(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg) struct mt7697_cfg80211_info *cfg)
{ {
u32 interval; u32 interval;
int ret = 0; int ret = 0;
dev_dbg(cfg->dev, "%s(): --> GET LISTEN INTERVAL\n", __func__); dev_dbg(cfg->dev, "%s(): --> GET LISTEN INTERVAL\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) != sizeof(u32)) { if (rsp->cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(u32)) {
dev_err(cfg->dev, dev_err(cfg->dev,
"%s(): invalid get listen interval rsp len(%u != %u)\n", "%s(): invalid get listen interval rsp len(%u != %u)\n",
__func__, __func__,
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr), rsp->cmd.len - sizeof(struct mt7697_rsp_hdr),
sizeof(u32)); sizeof(u32));
ret = -EINVAL; ret = -EINVAL;
goto cleanup; goto cleanup;
...@@ -332,7 +332,7 @@ cleanup: ...@@ -332,7 +332,7 @@ cleanup:
return ret; return ret;
} }
static int mt7697_proc_scan_ind(const struct mt7697q_rsp_hdr* rsp, static int mt7697_proc_scan_ind(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg) struct mt7697_cfg80211_info *cfg)
{ {
struct ieee80211_mgmt *rx_mgmt_frame; struct ieee80211_mgmt *rx_mgmt_frame;
...@@ -471,7 +471,7 @@ cleanup: ...@@ -471,7 +471,7 @@ cleanup:
return ret; return ret;
} }
static int mt7697_proc_scan_rsp(const struct mt7697q_rsp_hdr* rsp, static int mt7697_proc_scan_rsp(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg) struct mt7697_cfg80211_info *cfg)
{ {
struct mt7697_vif *vif; struct mt7697_vif *vif;
...@@ -545,7 +545,7 @@ cleanup: ...@@ -545,7 +545,7 @@ cleanup:
return ret; return ret;
} }
static int mt7697_proc_connect_ind(const struct mt7697q_rsp_hdr* rsp, static int mt7697_proc_connect_ind(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg) struct mt7697_cfg80211_info *cfg)
{ {
u8 bssid[LEN32_ALIGNED(ETH_ALEN)]; u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
...@@ -759,17 +759,17 @@ cleanup: ...@@ -759,17 +759,17 @@ cleanup:
return ret; return ret;
} }
static int mt7697_rx_raw(const struct mt7697q_rsp_hdr* rsp, static int mt7697_rx_raw(const struct mt7697_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg) struct mt7697_cfg80211_info *cfg)
{ {
int ret; int ret;
dev_dbg(cfg->dev, "%s(): --> RX RAW(%u)\n", __func__, rsp->cmd.len); dev_dbg(cfg->dev, "%s(): --> RX RAW(%u)\n", __func__, rsp->cmd.len);
if (rsp->cmd.len <= sizeof(struct mt7697q_rsp_hdr)) { if (rsp->cmd.len <= sizeof(struct mt7697_rsp_hdr)) {
dev_err(cfg->dev, "%s(): invalid rx raw len(%u <= %u)\n", dev_err(cfg->dev, "%s(): invalid rx raw len(%u <= %u)\n",
__func__, rsp->cmd.len, __func__, rsp->cmd.len,
sizeof(struct mt7697q_rsp_hdr)); sizeof(struct mt7697_rsp_hdr));
ret = -EINVAL; ret = -EINVAL;
goto cleanup; goto cleanup;
} }
...@@ -812,7 +812,7 @@ cleanup: ...@@ -812,7 +812,7 @@ cleanup:
return ret; return ret;
} }
int mt7697_proc_80211cmd(const struct mt7697q_rsp_hdr* rsp, void* priv) int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
{ {
struct mt7697_cfg80211_info *cfg = (struct mt7697_cfg80211_info*)priv; struct mt7697_cfg80211_info *cfg = (struct mt7697_cfg80211_info*)priv;
int ret = 0; int ret = 0;
...@@ -1545,7 +1545,7 @@ int mt7697_wr_tx_raw_packet(struct mt7697_cfg80211_info* cfg, ...@@ -1545,7 +1545,7 @@ int mt7697_wr_tx_raw_packet(struct mt7697_cfg80211_info* cfg,
{ {
int ret; int ret;
cfg->tx_req.cmd.len = sizeof(struct mt7697q_cmd_hdr) + sizeof(len) + len; cfg->tx_req.cmd.len = sizeof(struct mt7697_cmd_hdr) + sizeof(len) + len;
cfg->tx_req.len = len; cfg->tx_req.len = len;
WARN_ON(len > sizeof(cfg->tx_req.data)); WARN_ON(len > sizeof(cfg->tx_req.data));
memcpy(cfg->tx_req.data, data, len); memcpy(cfg->tx_req.data, data, len);
......
...@@ -20,34 +20,34 @@ ...@@ -20,34 +20,34 @@
#include <linux/ieee80211.h> #include <linux/ieee80211.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include "queue_i.h" #include "mt7697_i.h"
#include "wifi_api.h" #include "wifi_api.h"
#define MT7697_WOW_MAX_FILTERS_PER_LIST 4 #define MT7697_WOW_MAX_FILTERS_PER_LIST 4
#define MT7697_WOW_PATTERN_SIZE 64 #define MT7697_WOW_PATTERN_SIZE 64
#define MT7697_PASSPHRASE_LEN 64 #define MT7697_PASSPHRASE_LEN 64
#define mt7697_cfg_req mt7697q_cmd_hdr #define mt7697_cfg_req mt7697_cmd_hdr
#define mt7697_get_radio_state_req mt7697q_cmd_hdr #define mt7697_get_radio_state_req mt7697_cmd_hdr
#define mt7697_get_rx_filter_req mt7697q_cmd_hdr #define mt7697_get_rx_filter_req mt7697_cmd_hdr
#define mt7697_get_listen_interval_req mt7697q_cmd_hdr #define mt7697_get_listen_interval_req mt7697_cmd_hdr
#define mt7697_get_smart_conn_filter_req mt7697q_cmd_hdr #define mt7697_get_smart_conn_filter_req mt7697_cmd_hdr
#define mt7697_scan_stop mt7697q_cmd_hdr #define mt7697_scan_stop mt7697_cmd_hdr
#define mt7697_set_wireless_mode_rsp mt7697q_rsp_hdr #define mt7697_set_wireless_mode_rsp mt7697_rsp_hdr
#define mt7697_set_radio_state_rsp mt7697q_rsp_hdr #define mt7697_set_radio_state_rsp mt7697_rsp_hdr
#define mt7697_set_op_mode_rsp mt7697q_rsp_hdr #define mt7697_set_op_mode_rsp mt7697_rsp_hdr
#define mt7697_set_rx_filter_rsp mt7697q_rsp_hdr #define mt7697_set_rx_filter_rsp mt7697_rsp_hdr
#define mt7697_set_smart_conn_filter_rsp mt7697q_rsp_hdr #define mt7697_set_smart_conn_filter_rsp mt7697_rsp_hdr
#define mt7697_set_listen_interval_rsp mt7697q_rsp_hdr #define mt7697_set_listen_interval_rsp mt7697_rsp_hdr
#define mt7697_set_pmk_rsp mt7697q_rsp_hdr #define mt7697_set_pmk_rsp mt7697_rsp_hdr
#define mt7697_set_channel_rsp mt7697q_rsp_hdr #define mt7697_set_channel_rsp mt7697_rsp_hdr
#define mt7697_set_bssid_rsp mt7697q_rsp_hdr #define mt7697_set_bssid_rsp mt7697_rsp_hdr
#define mt7697_set_ssid_rsp mt7697q_rsp_hdr #define mt7697_set_ssid_rsp mt7697_rsp_hdr
#define mt7697_set_security_mode_rsp mt7697q_rsp_hdr #define mt7697_set_security_mode_rsp mt7697_rsp_hdr
#define mt7697_scan_stop_rsp mt7697q_rsp_hdr #define mt7697_scan_stop_rsp mt7697_rsp_hdr
#define mt7697_reload_settings_rsp mt7697q_rsp_hdr #define mt7697_reload_settings_rsp mt7697_rsp_hdr
#define mt7697_disconnect_rsp mt7697q_rsp_hdr #define mt7697_disconnect_rsp mt7697_rsp_hdr
enum mt7697_connect_ctrl_flags_bits { enum mt7697_connect_ctrl_flags_bits {
MT7697_CONNECT_ASSOC_POLICY_USER = 0x0001, MT7697_CONNECT_ASSOC_POLICY_USER = 0x0001,
...@@ -112,68 +112,68 @@ struct mt7697_cfg80211_info; ...@@ -112,68 +112,68 @@ struct mt7697_cfg80211_info;
struct cfg80211_scan_request; struct cfg80211_scan_request;
struct mt7697_mac_addr_req { struct mt7697_mac_addr_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 port; __be32 port;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_mac_addr_rsp { struct mt7697_mac_addr_rsp {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
u8 addr[LEN32_ALIGNED(ETH_ALEN)]; u8 addr[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_get_wireless_mode_req { struct mt7697_get_wireless_mode_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 port; __be32 port;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_get_wireless_mode_rsp { struct mt7697_get_wireless_mode_rsp {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
__be32 mode; __be32 mode;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_set_wireless_mode_req { struct mt7697_set_wireless_mode_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 port; __be32 port;
__be32 mode; __be32 mode;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_cfg_rsp { struct mt7697_cfg_rsp {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
struct mt7697_wifi_config_t cfg; struct mt7697_wifi_config_t cfg;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_set_op_mode_req { struct mt7697_set_op_mode_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 opmode; __be32 opmode;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_get_radio_state_rsp { struct mt7697_get_radio_state_rsp {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
__be32 state; __be32 state;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_set_radio_state_req { struct mt7697_set_radio_state_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 state; __be32 state;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_get_listen_interval_rsp { struct mt7697_get_listen_interval_rsp {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
__be32 interval; __be32 interval;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_set_listen_interval_req { struct mt7697_set_listen_interval_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 interval; __be32 interval;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_reload_settings_req { struct mt7697_reload_settings_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 if_idx; __be32 if_idx;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_scan_req { struct mt7697_scan_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 if_idx; __be32 if_idx;
__be32 mode; __be32 mode;
__be32 option; __be32 option;
...@@ -184,93 +184,93 @@ struct mt7697_scan_req { ...@@ -184,93 +184,93 @@ struct mt7697_scan_req {
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_scan_rsp { struct mt7697_scan_rsp {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
__be32 if_idx; __be32 if_idx;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_scan_ind { struct mt7697_scan_ind {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
__be32 rssi; __be32 rssi;
__be32 channel; __be32 channel;
u8 probe_rsp[]; u8 probe_rsp[];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_scan_complete_ind { struct mt7697_scan_complete_ind {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
__be32 if_idx; __be32 if_idx;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_set_pmk_req { struct mt7697_set_pmk_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 port; __be32 port;
u8 pmk[LEN32_ALIGNED(MT7697_WIFI_LENGTH_PMK)]; u8 pmk[LEN32_ALIGNED(MT7697_WIFI_LENGTH_PMK)];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_set_channel_req { struct mt7697_set_channel_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 port; __be32 port;
__be32 ch; __be32 ch;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_set_bssid_req { struct mt7697_set_bssid_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)]; u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_set_ssid_req { struct mt7697_set_ssid_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 port; __be32 port;
__be32 len; __be32 len;
u8 ssid[LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)]; u8 ssid[LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_set_security_mode_req { struct mt7697_set_security_mode_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 port; __be32 port;
__be32 auth_mode; __be32 auth_mode;
__be32 encrypt_type; __be32 encrypt_type;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_get_security_mode_req { struct mt7697_get_security_mode_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 if_idx; __be32 if_idx;
__be32 port; __be32 port;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_get_security_mode_rsp { struct mt7697_get_security_mode_rsp {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
__be32 if_idx; __be32 if_idx;
__be32 auth_mode; __be32 auth_mode;
__be32 encrypt_type; __be32 encrypt_type;
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_connect_ind { struct mt7697_connect_ind {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
__be32 if_idx; __be32 if_idx;
__be32 channel; __be32 channel;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)]; u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_disconnect_req { struct mt7697_disconnect_req {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 port; __be32 port;
u8 addr[LEN32_ALIGNED(ETH_ALEN)]; u8 addr[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_disconnect_ind { struct mt7697_disconnect_ind {
struct mt7697q_rsp_hdr rsp; struct mt7697_rsp_hdr rsp;
__be32 if_idx; __be32 if_idx;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)]; u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_tx_raw_packet { struct mt7697_tx_raw_packet {
struct mt7697q_cmd_hdr cmd; struct mt7697_cmd_hdr cmd;
__be32 len; __be32 len;
u8 data[LEN32_ALIGNED(IEEE80211_MAX_FRAME_LEN)]; u8 data[LEN32_ALIGNED(IEEE80211_MAX_FRAME_LEN)];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
struct mt7697_rx_raw_packet { struct mt7697_rx_raw_packet {
struct mt7697q_rsp_hdr hdr; struct mt7697_rsp_hdr hdr;
u8 data[]; u8 data[];
} __attribute__((packed, aligned(4))); } __attribute__((packed, aligned(4)));
......
...@@ -66,6 +66,7 @@ kernelModules: ...@@ -66,6 +66,7 @@ kernelModules:
$MANGOH_ROOT/linux_kernel_modules/bmi160/4-bmi160-i2c $MANGOH_ROOT/linux_kernel_modules/bmi160/4-bmi160-i2c
$MANGOH_ROOT/linux_kernel_modules/mt7697q/1-mt7697q $MANGOH_ROOT/linux_kernel_modules/mt7697q/1-mt7697q
$MANGOH_ROOT/linux_kernel_modules/mt7697serial/1-mt7697serial
$MANGOH_ROOT/linux_kernel_modules/mt7697wifi/2-mt7697wifi_core $MANGOH_ROOT/linux_kernel_modules/mt7697wifi/2-mt7697wifi_core
// spisvc creates a spidev device which will appear as /dev/spidev0.0 once the spidev module is // spisvc creates a spidev device which will appear as /dev/spidev0.0 once the spidev module is
......
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