Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 714fa663 authored by Gertjan van Wingerde's avatar Gertjan van Wingerde Committed by John W. Linville
Browse files

rt2x00: Reorganize RT chipset setting for PCI/SOC devices.



Don't set the RT chipset for a device from within the generic PCI/SOC code,
but rather from the individual drivers, so that individual drivers have
more control over what RT chipset is set.
Preparation for chip handling updates for rt2800 devices.

Signed-off-by: default avatarGertjan van Wingerde <gwingerde@gmail.com>
Acked-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent cea90e55
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -1327,6 +1327,7 @@ static int rt2400pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
{
{
	u32 reg;
	u32 reg;
	u16 chip;
	u16 value;
	u16 value;
	u16 eeprom;
	u16 eeprom;


@@ -1335,13 +1336,17 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
	 */
	 */
	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);


	/*
	 * Identify RT chipset.
	 */
	pci_read_config_word(to_pci_dev(rt2x00dev->dev), PCI_DEVICE_ID, &chip);

	/*
	/*
	 * Identify RF chipset.
	 * Identify RF chipset.
	 */
	 */
	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
	rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
	rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
	rt2x00_set_chip_rf(rt2x00dev, value, reg);
	rt2x00_set_chip(rt2x00dev, chip, value, reg);
	rt2x00_print_chip(rt2x00dev);


	if (!rt2x00_rf(rt2x00dev, RF2420) && !rt2x00_rf(rt2x00dev, RF2421)) {
	if (!rt2x00_rf(rt2x00dev, RF2420) && !rt2x00_rf(rt2x00dev, RF2421)) {
		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
		ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
+7 −2
Original line number Original line Diff line number Diff line
@@ -1490,6 +1490,7 @@ static int rt2500pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
{
{
	u32 reg;
	u32 reg;
	u16 chip;
	u16 value;
	u16 value;
	u16 eeprom;
	u16 eeprom;


@@ -1498,13 +1499,17 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
	 */
	 */
	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
	rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);


	/*
	 * Identify RT chipset.
	 */
	pci_read_config_word(to_pci_dev(rt2x00dev->dev), PCI_DEVICE_ID, &chip);

	/*
	/*
	 * Identify RF chipset.
	 * Identify RF chipset.
	 */
	 */
	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
	rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
	rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
	rt2x00_set_chip_rf(rt2x00dev, value, reg);
	rt2x00_set_chip(rt2x00dev, chip, value, reg);
	rt2x00_print_chip(rt2x00dev);


	if (!rt2x00_rf(rt2x00dev, RF2522) &&
	if (!rt2x00_rf(rt2x00dev, RF2522) &&
	    !rt2x00_rf(rt2x00dev, RF2523) &&
	    !rt2x00_rf(rt2x00dev, RF2523) &&
+0 −1
Original line number Original line Diff line number Diff line
@@ -1408,7 +1408,6 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
	rt2500usb_register_read(rt2x00dev, MAC_CSR0, &reg);
	rt2500usb_register_read(rt2x00dev, MAC_CSR0, &reg);
	rt2x00_set_chip(rt2x00dev, RT2570, value, reg);
	rt2x00_set_chip(rt2x00dev, RT2570, value, reg);
	rt2x00_print_chip(rt2x00dev);


	if (!rt2x00_check_rev(rt2x00dev, 0x000ffff0, 0) ||
	if (!rt2x00_check_rev(rt2x00dev, 0x000ffff0, 0) ||
	    rt2x00_check_rev(rt2x00dev, 0x0000000f, 0)) {
	    rt2x00_check_rev(rt2x00dev, 0x0000000f, 0)) {
+29 −10
Original line number Original line Diff line number Diff line
@@ -40,6 +40,9 @@
#if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE)
#if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE)
#include "rt2x00usb.h"
#include "rt2x00usb.h"
#endif
#endif
#if defined(CONFIG_RT2X00_LIB_PCI) || defined(CONFIG_RT2X00_LIB_PCI_MODULE)
#include "rt2x00pci.h"
#endif
#include "rt2800lib.h"
#include "rt2800lib.h"
#include "rt2800.h"
#include "rt2800.h"
#include "rt2800usb.h"
#include "rt2800usb.h"
@@ -1839,6 +1842,7 @@ EXPORT_SYMBOL_GPL(rt2800_validate_eeprom);
int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
{
{
	u32 reg;
	u32 reg;
	u16 chip;
	u16 value;
	u16 value;
	u16 eeprom;
	u16 eeprom;


@@ -1853,25 +1857,40 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
	value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
	rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);


	rt2x00_set_chip_rf(rt2x00dev, value, reg);
	if (rt2x00_is_pci(rt2x00dev)) {

#if defined(CONFIG_RT2X00_LIB_PCI) || defined(CONFIG_RT2X00_LIB_PCI_MODULE)
	if (rt2x00_is_usb(rt2x00dev)) {
		pci_read_config_word(to_pci_dev(rt2x00dev->dev),
				     PCI_DEVICE_ID,
				     &chip);
#else
		BUG();
#endif
	} else if (rt2x00_is_usb(rt2x00dev)) {
		/*
		/*
		 * The check for rt2860 is not a typo, some rt2870 hardware
		 * The check for rt2860 is not a typo, some rt2870 hardware
		 * identifies itself as rt2860 in the CSR register.
		 * identifies itself as rt2860 in the CSR register.
		 */
		 */
		if (rt2x00_check_rev(rt2x00dev, 0xfff00000, 0x28600000) ||
		if (((reg & 0xfff00000) == 0x28600000) ||
		    rt2x00_check_rev(rt2x00dev, 0xfff00000, 0x28700000) ||
		    ((reg & 0xfff00000) == 0x28700000) ||
		    rt2x00_check_rev(rt2x00dev, 0xfff00000, 0x28800000)) {
		    ((reg & 0xfff00000) == 0x28800000)) {
			rt2x00_set_chip_rt(rt2x00dev, RT2870);
			chip = RT2870;
		} else if (rt2x00_check_rev(rt2x00dev, 0xffff0000, 0x30700000)) {
		} else if ((reg & 0xffff0000) == 0x30700000) {
			rt2x00_set_chip_rt(rt2x00dev, RT3070);
			chip = RT3070;
		} else {
		} else {
			ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
			ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
			return -ENODEV;
			return -ENODEV;
		}
		}
	} else if (rt2x00_is_soc(rt2x00dev)) {
#if defined(CONFIG_RALINK_RT288X)
		chip = RT2880;
#elif defined(CONFIG_RALINK_RT305X)
		chip = RT3052;
#else
		BUG();
#endif
	}
	}
	rt2x00_print_chip(rt2x00dev);

	rt2x00_set_chip(rt2x00dev, chip, value, reg);


	if (!rt2x00_rf(rt2x00dev, RF2820) &&
	if (!rt2x00_rf(rt2x00dev, RF2820) &&
	    !rt2x00_rf(rt2x00dev, RF2850) &&
	    !rt2x00_rf(rt2x00dev, RF2850) &&
+5 −6
Original line number Original line Diff line number Diff line
@@ -1219,11 +1219,10 @@ MODULE_DEVICE_TABLE(pci, rt2800pci_device_table);
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");


#ifdef CONFIG_RT2800PCI_SOC
#ifdef CONFIG_RT2800PCI_SOC
#if defined(CONFIG_RALINK_RT288X)
static int rt2800soc_probe(struct platform_device *pdev)
__rt2x00soc_probe(RT2880, &rt2800pci_ops);
{
#elif defined(CONFIG_RALINK_RT305X)
	return rt2x00soc_probe(pdev, rt2800pci_ops);
__rt2x00soc_probe(RT3052, &rt2800pci_ops);
}
#endif


static struct platform_driver rt2800soc_driver = {
static struct platform_driver rt2800soc_driver = {
	.driver		= {
	.driver		= {
@@ -1231,7 +1230,7 @@ static struct platform_driver rt2800soc_driver = {
		.owner		= THIS_MODULE,
		.owner		= THIS_MODULE,
		.mod_name	= KBUILD_MODNAME,
		.mod_name	= KBUILD_MODNAME,
	},
	},
	.probe		= __rt2x00soc_probe,
	.probe		= rt2800soc_probe,
	.remove		= __devexit_p(rt2x00soc_remove),
	.remove		= __devexit_p(rt2x00soc_remove),
	.suspend	= rt2x00soc_suspend,
	.suspend	= rt2x00soc_suspend,
	.resume		= rt2x00soc_resume,
	.resume		= rt2x00soc_resume,
Loading