Commit c2a4d9fb authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Felix Fietkau

mt76x0: inital split between pci and usb

For now pci driver can read ASIC version from the device :-)
Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 1bee323a
...@@ -7,25 +7,35 @@ config MT76_USB ...@@ -7,25 +7,35 @@ config MT76_USB
config MT76x02_LIB config MT76x02_LIB
tristate tristate
depends on MT76_CORE select MT76_CORE
config MT76x0_COMMON
tristate
select MT76x02_LIB
config MT76x2_COMMON config MT76x2_COMMON
tristate tristate
select MT76x02_LIB select MT76x02_LIB
depends on MT76_CORE
config MT76x0U config MT76x0U
tristate "MediaTek MT76x0U (USB) support" tristate "MediaTek MT76x0U (USB) support"
select MT76_CORE select MT76x0_COMMON
select MT76_USB
depends on MAC80211 depends on MAC80211
depends on USB depends on USB
select MT76x02_LIB
help help
This adds support for MT7610U-based wireless USB dongles. This adds support for MT7610U-based wireless USB dongles.
config MT76x0E
tristate "MediaTek MT76x0E (PCIe) support"
select MT76x0_COMMON
depends on MAC80211
depends on PCI
help
This adds support for MT7610/MT7630-based wireless PCIe devices.
config MT76x2E config MT76x2E
tristate "MediaTek MT76x2E (PCIe) support" tristate "MediaTek MT76x2E (PCIe) support"
select MT76_CORE
select MT76x2_COMMON select MT76x2_COMMON
depends on MAC80211 depends on MAC80211
depends on PCI depends on PCI
...@@ -34,9 +44,8 @@ config MT76x2E ...@@ -34,9 +44,8 @@ config MT76x2E
config MT76x2U config MT76x2U
tristate "MediaTek MT76x2U (USB) support" tristate "MediaTek MT76x2U (USB) support"
select MT76_CORE
select MT76_USB
select MT76x2_COMMON select MT76x2_COMMON
select MT76_USB
depends on MAC80211 depends on MAC80211
depends on USB depends on USB
help help
......
obj-$(CONFIG_MT76_CORE) += mt76.o obj-$(CONFIG_MT76_CORE) += mt76.o
obj-$(CONFIG_MT76_USB) += mt76-usb.o obj-$(CONFIG_MT76_USB) += mt76-usb.o
obj-$(CONFIG_MT76x0U) += mt76x0/ obj-$(CONFIG_MT76x0_COMMON) += mt76x0/
obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o
obj-$(CONFIG_MT76x2_COMMON) += mt76x2-common.o obj-$(CONFIG_MT76x2_COMMON) += mt76x2-common.o
obj-$(CONFIG_MT76x2E) += mt76x2e.o obj-$(CONFIG_MT76x2E) += mt76x2e.o
......
obj-$(CONFIG_MT76x0U) += mt76x0.o obj-$(CONFIG_MT76x0U) += mt76x0u.o
obj-$(CONFIG_MT76x0E) += mt76x0e.o
obj-$(CONFIG_MT76x0_COMMON) += mt76x0-common.o
mt76x0-objs = \ mt76x0-common-y := \
usb.o init.o main.o mcu.o trace.o eeprom.o phy.o \ init.o main.o mcu.o trace.o eeprom.o phy.o \
mac.o debugfs.o tx.o mac.o debugfs.o tx.o
mt76x0u-y := usb.o
mt76x0e-y := pci.o
# ccflags-y := -DDEBUG # ccflags-y := -DDEBUG
CFLAGS_trace.o := -I$(src) CFLAGS_trace.o := -I$(src)
...@@ -445,3 +445,5 @@ mt76x0_eeprom_init(struct mt76x0_dev *dev) ...@@ -445,3 +445,5 @@ mt76x0_eeprom_init(struct mt76x0_dev *dev)
kfree(eeprom); kfree(eeprom);
return ret; return ret;
} }
MODULE_LICENSE("Dual BSD/GPL");
...@@ -111,6 +111,7 @@ void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset) ...@@ -111,6 +111,7 @@ void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset)
mutex_unlock(&dev->hw_atomic_mutex); mutex_unlock(&dev->hw_atomic_mutex);
} }
EXPORT_SYMBOL_GPL(mt76x0_chip_onoff);
static void mt76x0_reset_csr_bbp(struct mt76x0_dev *dev) static void mt76x0_reset_csr_bbp(struct mt76x0_dev *dev)
{ {
...@@ -384,6 +385,7 @@ void mt76x0_mac_stop(struct mt76x0_dev *dev) ...@@ -384,6 +385,7 @@ void mt76x0_mac_stop(struct mt76x0_dev *dev)
mt76u_stop_stat_wk(&dev->mt76); mt76u_stop_stat_wk(&dev->mt76);
mt76x0_mac_stop_hw(dev); mt76x0_mac_stop_hw(dev);
} }
EXPORT_SYMBOL_GPL(mt76x0_mac_stop);
int mt76x0_init_hardware(struct mt76x0_dev *dev) int mt76x0_init_hardware(struct mt76x0_dev *dev)
{ {
...@@ -469,6 +471,7 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev) ...@@ -469,6 +471,7 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mt76x0_init_hardware);
void mt76x0_cleanup(struct mt76x0_dev *dev) void mt76x0_cleanup(struct mt76x0_dev *dev)
{ {
...@@ -477,6 +480,7 @@ void mt76x0_cleanup(struct mt76x0_dev *dev) ...@@ -477,6 +480,7 @@ void mt76x0_cleanup(struct mt76x0_dev *dev)
mt76u_queues_deinit(&dev->mt76); mt76u_queues_deinit(&dev->mt76);
mt76u_mcu_deinit(&dev->mt76); mt76u_mcu_deinit(&dev->mt76);
} }
EXPORT_SYMBOL_GPL(mt76x0_cleanup);
struct mt76x0_dev *mt76x0_alloc_device(struct device *pdev) struct mt76x0_dev *mt76x0_alloc_device(struct device *pdev)
{ {
...@@ -505,6 +509,7 @@ struct mt76x0_dev *mt76x0_alloc_device(struct device *pdev) ...@@ -505,6 +509,7 @@ struct mt76x0_dev *mt76x0_alloc_device(struct device *pdev)
return dev; return dev;
} }
EXPORT_SYMBOL_GPL(mt76x0_alloc_device);
int mt76x0_register_device(struct mt76x0_dev *dev) int mt76x0_register_device(struct mt76x0_dev *dev)
{ {
...@@ -569,3 +574,4 @@ int mt76x0_register_device(struct mt76x0_dev *dev) ...@@ -569,3 +574,4 @@ int mt76x0_register_device(struct mt76x0_dev *dev)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mt76x0_register_device);
...@@ -71,6 +71,13 @@ static int mt76x0_config(struct ieee80211_hw *hw, u32 changed) ...@@ -71,6 +71,13 @@ static int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
return ret; return ret;
} }
static void
mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr)
{
mt76_wr(dev, offset, get_unaligned_le32(addr));
mt76_wr(dev, offset + 4, addr[4] | addr[5] << 8);
}
static void static void
mt76x0_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mt76x0_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *info, u32 changed) struct ieee80211_bss_conf *info, u32 changed)
......
...@@ -141,7 +141,6 @@ int mt76x0_read_reg_pairs(struct mt76x0_dev *dev, u32 base, ...@@ -141,7 +141,6 @@ int mt76x0_read_reg_pairs(struct mt76x0_dev *dev, u32 base,
struct mt76_reg_pair *data, int len); struct mt76_reg_pair *data, int len);
int mt76x0_burst_write_regs(struct mt76x0_dev *dev, u32 offset, int mt76x0_burst_write_regs(struct mt76x0_dev *dev, u32 offset,
const u32 *data, int n); const u32 *data, int n);
void mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr);
/* Init */ /* Init */
struct mt76x0_dev *mt76x0_alloc_device(struct device *dev); struct mt76x0_dev *mt76x0_alloc_device(struct device *dev);
......
/*
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include "mt76x0.h"
static int
mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct mt76x0_dev *dev;
int ret = -ENODEV;
ret = pcim_enable_device(pdev);
if (ret)
return ret;
ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
if (ret)
return ret;
pci_set_master(pdev);
ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (ret)
return ret;
dev = mt76x0_alloc_device(&pdev->dev);
if (!dev)
return -ENOMEM;
mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]);
dev->mt76.rev = mt76_rr(dev, MT_ASIC_VERSION);
dev_info(dev->mt76.dev, "ASIC revision: %08x\n", dev->mt76.rev);
/* error: */
ieee80211_free_hw(mt76_hw(dev));
return ret;
}
static void
mt76x0e_remove(struct pci_dev *pdev)
{
struct mt76_dev *mdev = pci_get_drvdata(pdev);
mt76_unregister_device(mdev);
ieee80211_free_hw(mdev->hw);
}
static const struct pci_device_id mt76x0e_device_table[] = {
{ PCI_DEVICE(0x14c3, 0x7630) },
{ },
};
MODULE_DEVICE_TABLE(pci, mt76x0e_device_table);
MODULE_LICENSE("Dual BSD/GPL");
static struct pci_driver mt76x0e_driver = {
.name = KBUILD_MODNAME,
.id_table = mt76x0e_device_table,
.probe = mt76x0e_probe,
.remove = mt76x0e_remove,
};
module_pci_driver(mt76x0e_driver);
...@@ -46,12 +46,6 @@ static struct usb_device_id mt76x0_device_table[] = { ...@@ -46,12 +46,6 @@ static struct usb_device_id mt76x0_device_table[] = {
{ 0, } { 0, }
}; };
void mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr)
{
mt76_wr(dev, offset, get_unaligned_le32(addr));
mt76_wr(dev, offset + 4, addr[4] | addr[5] << 8);
}
static int mt76x0_probe(struct usb_interface *usb_intf, static int mt76x0_probe(struct usb_interface *usb_intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
......
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