From 1c96bc9abc83c9260788631829060fcb1dabc877 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Sun, 3 Jul 2011 15:02:04 +0000 Subject: [PATCH] max80211: rt2x00: load the eeprom data from a file on Ralink SoCs SVN-Revision: 27395 --- package/mac80211/Makefile | 5 +- ...2-rt2x00-introduce-rt2x00_platform_h.patch | 32 ++ .../603-rt2x00-introduce-rt2x00eeprom.patch | 274 ++++++++++++++++++ ...-add-CONFIG_RT2X00_LIB_EEPROM-option.patch | 10 + 4 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 package/mac80211/patches/602-rt2x00-introduce-rt2x00_platform_h.patch create mode 100644 package/mac80211/patches/603-rt2x00-introduce-rt2x00eeprom.patch create mode 100644 package/mac80211/patches/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch diff --git a/package/mac80211/Makefile b/package/mac80211/Makefile index 525cf19293..2fe0b9add6 100644 --- a/package/mac80211/Makefile +++ b/package/mac80211/Makefile @@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mac80211 PKG_VERSION:=2011-06-22 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources PKG_MD5SUM:=3ffdd5cecedcf4236f599bdbc55ba10d @@ -198,6 +198,7 @@ endef NEED_RT2X00_LIB_CRYPTO:=y NEED_RT2X00_LIB_FIRMWARE:=y +NEED_RT2X00_LIB_EEPROM:=y NEED_RT2X00_LIB_HT:=y NEED_RT2X00_LIB_LEDS:=y @@ -1025,6 +1026,7 @@ BUILDFLAGS:= \ $(if $(NEED_RT2X00_LIB_HT),-DCONFIG_RT2X00_LIB_HT) \ $(if $(NEED_RT2X00_LIB_CRYPTO),-DCONFIG_RT2X00_LIB_CRYPTO) \ $(if $(NEED_RT2X00_LIB_FIRMWARE),-DCONFIG_RT2X00_LIB_FIRMWARE) \ + $(if $(NEED_RT2X00_LIB_EEPROM),-DCONFIG_RT2X00_LIB_EEPROM) \ $(if $(NEED_RT2X00_LIB_LEDS),-DCONFIG_RT2X00_LIB_LEDS) \ $(if $(CONFIG_PACKAGE_kmod-rt2x00-pci),-DCONFIG_RT2X00_LIB_PCI) \ $(if $(CONFIG_PACKAGE_kmod-rt2x00-usb),-DCONFIG_RT2X00_LIB_USB) \ @@ -1086,6 +1088,7 @@ MAKE_OPTS:= \ CONFIG_RT2X00_LIB_DEBUGFS=$(CONFIG_PACKAGE_RT2X00_LIB_DEBUGFS) \ CONFIG_RT2X00_LIB_CRYPTO=$(NEED_RT2X00_LIB_CRYPTO) \ CONFIG_RT2X00_LIB_FIRMWARE=$(NEED_RT2X00_LIB_FIRMWARE) \ + CONFIG_RT2X00_LIB_EEPROM=$(NEED_RT2X00_LIB_EEPROM) \ CONFIG_RT2X00_LIB_HT=$(NEED_RT2X00_LIB_HT) \ CONFIG_RT2X00_LIB_LEDS=$(NEED_RT2X00_LIB_LEDS) \ CONFIG_RT2400PCI=$(if $(CONFIG_PACKAGE_kmod-rt2400-pci),m) \ diff --git a/package/mac80211/patches/602-rt2x00-introduce-rt2x00_platform_h.patch b/package/mac80211/patches/602-rt2x00-introduce-rt2x00_platform_h.patch new file mode 100644 index 0000000000..2194cca886 --- /dev/null +++ b/package/mac80211/patches/602-rt2x00-introduce-rt2x00_platform_h.patch @@ -0,0 +1,32 @@ +--- /dev/null ++++ b/include/linux/rt2x00_platform.h +@@ -0,0 +1,19 @@ ++/* ++ * Platform data definition for the rt2x00 driver ++ * ++ * Copyright (C) 2011 Gabor Juhos ++ * ++ * 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. ++ * ++ */ ++ ++#ifndef _RT2X00_PLATFORM_H ++#define _RT2X00_PLATFORM_H ++ ++struct rt2x00_platform_data { ++ char *eeprom_file_name; ++}; ++ ++#endif /* _RT2X00_PLATFORM_H */ +--- a/drivers/net/wireless/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/rt2x00/rt2x00.h +@@ -38,6 +38,7 @@ + #include + #include + #include ++#include + + #include + diff --git a/package/mac80211/patches/603-rt2x00-introduce-rt2x00eeprom.patch b/package/mac80211/patches/603-rt2x00-introduce-rt2x00eeprom.patch new file mode 100644 index 0000000000..fc58744655 --- /dev/null +++ b/package/mac80211/patches/603-rt2x00-introduce-rt2x00eeprom.patch @@ -0,0 +1,274 @@ +--- /dev/null ++++ b/drivers/net/wireless/rt2x00/rt2x00eeprom.c +@@ -0,0 +1,98 @@ ++/* ++ Copyright (C) 2004 - 2009 Ivo van Doorn ++ Copyright (C) 2004 - 2009 Gertjan van Wingerde ++ ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the ++ Free Software Foundation, Inc., ++ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ */ ++ ++/* ++ Module: rt2x00lib ++ Abstract: rt2x00 eeprom file loading routines. ++ */ ++ ++#include ++#include ++ ++#include "rt2x00.h" ++#include "rt2x00lib.h" ++ ++static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++ const struct firmware *ee; ++ char *ee_name; ++ int retval; ++ ++ ee_name = rt2x00dev->ops->lib->get_eeprom_file_name(rt2x00dev); ++ if (!ee_name) { ++ ERROR(rt2x00dev, ++ "Invalid EEPROM filename.\n" ++ "Please file bug report to %s.\n", DRV_PROJECT); ++ return -EINVAL; ++ } ++ ++ INFO(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name); ++ ++ retval = request_firmware(&ee, ee_name, rt2x00dev->dev); ++ if (retval) { ++ ERROR(rt2x00dev, "Failed to request EEPROM.\n"); ++ return retval; ++ } ++ ++ if (!ee || !ee->size || !ee->data) { ++ ERROR(rt2x00dev, "Failed to read EEPROM file.\n"); ++ retval = -ENOENT; ++ goto err_exit; ++ } ++ ++ if (ee->size != rt2x00dev->ops->eeprom_size) { ++ ERROR(rt2x00dev, ++ "EEPROM file size is invalid, it should be %d bytes\n", ++ rt2x00dev->ops->eeprom_size); ++ retval = -EINVAL; ++ goto err_release_ee; ++ } ++ ++ rt2x00dev->eeprom_file = ee; ++ return 0; ++ ++err_release_ee: ++ release_firmware(ee); ++err_exit: ++ return retval; ++} ++ ++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++ int retval; ++ ++ if (!test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags)) ++ return 0; ++ ++ if (!rt2x00dev->eeprom_file) { ++ retval = rt2x00lib_request_eeprom_file(rt2x00dev); ++ if (retval) ++ return retval; ++ } ++ ++ return 0; ++} ++ ++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++ release_firmware(rt2x00dev->eeprom_file); ++ rt2x00dev->eeprom_file = NULL; ++} +--- a/drivers/net/wireless/rt2x00/rt2x00.h ++++ b/drivers/net/wireless/rt2x00/rt2x00.h +@@ -538,6 +538,7 @@ struct rt2x00lib_ops { + const u8 *data, const size_t len); + int (*load_firmware) (struct rt2x00_dev *rt2x00dev, + const u8 *data, const size_t len); ++ char *(*get_eeprom_file_name) (struct rt2x00_dev *rt2x00dev); + + /* + * Device initialization/deinitialization handlers. +@@ -684,6 +685,7 @@ enum rt2x00_capability_flags { + REQUIRE_SW_SEQNO, + REQUIRE_HT_TX_DESC, + REQUIRE_PS_AUTOWAKE, ++ REQUIRE_EEPROM_FILE, + + /* + * Capabilities +@@ -939,6 +941,11 @@ struct rt2x00_dev { + const struct firmware *fw; + + /* ++ * EEPROM image. ++ */ ++ const struct firmware *eeprom_file; ++ ++ /* + * FIFO for storing tx status reports between isr and tasklet. + */ + DECLARE_KFIFO_PTR(txstatus_fifo, u32); +--- a/drivers/net/wireless/rt2x00/rt2x00lib.h ++++ b/drivers/net/wireless/rt2x00/rt2x00lib.h +@@ -309,6 +309,22 @@ static inline void rt2x00lib_free_firmwa + #endif /* CONFIG_RT2X00_LIB_FIRMWARE */ + + /* ++ * EEPROM file handlers. ++ */ ++#ifdef CONFIG_RT2X00_LIB_EEPROM ++int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev); ++void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev); ++#else ++static inline int rt2x00lib_load_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++ return 0; ++} ++static inline void rt2x00lib_free_eeprom_file(struct rt2x00_dev *rt2x00dev) ++{ ++} ++#endif /* CONFIG_RT2X00_LIB_EEPROM_FILE */ ++ ++/* + * Debugfs handlers. + */ + #ifdef CONFIG_RT2X00_LIB_DEBUGFS +--- a/drivers/net/wireless/rt2x00/Kconfig ++++ b/drivers/net/wireless/rt2x00/Kconfig +@@ -60,6 +60,7 @@ config RT2800PCI + select RT2X00_LIB_PCI if PCI + select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X + select RT2X00_LIB_FIRMWARE ++ select RT2X00_LIB_EEPROM + select RT2X00_LIB_CRYPTO + select CRC_CCITT + select EEPROM_93CX6 +@@ -204,6 +205,9 @@ config RT2X00_LIB_FIRMWARE + config RT2X00_LIB_CRYPTO + boolean + ++config RT2X00_LIB_EEPROM ++ boolean ++ + config RT2X00_LIB_LEDS + boolean + default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n) +--- a/drivers/net/wireless/rt2x00/Makefile ++++ b/drivers/net/wireless/rt2x00/Makefile +@@ -7,6 +7,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) + + rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o + rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o + rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o ++rt2x00lib-$(CONFIG_RT2X00_LIB_EEPROM) += rt2x00eeprom.o + + obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o + obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o +--- a/drivers/net/wireless/rt2x00/rt2800pci.c ++++ b/drivers/net/wireless/rt2x00/rt2800pci.c +@@ -84,20 +84,10 @@ static void rt2800pci_mcu_status(struct + rt2x00pci_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0); + } + +-#if defined(CONFIG_RALINK_RT288X) || defined(CONFIG_RALINK_RT305X) + static void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) + { +- void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE); +- +- memcpy_fromio(rt2x00dev->eeprom, base_addr, EEPROM_SIZE); +- +- iounmap(base_addr); ++ memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, EEPROM_SIZE); + } +-#else +-static inline void rt2800pci_read_eeprom_soc(struct rt2x00_dev *rt2x00dev) +-{ +-} +-#endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */ + + #ifdef CONFIG_PCI + static void rt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom) +@@ -315,6 +305,20 @@ static int rt2800pci_write_firmware(stru + } + + /* ++ * EEPROM file functions. ++ */ ++static char *rt2800pci_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev) ++{ ++ struct rt2x00_platform_data *pdata; ++ ++ pdata = rt2x00dev->dev->platform_data; ++ if (pdata) ++ return pdata->eeprom_file_name; ++ ++ return NULL; ++} ++ ++/* + * Initialization functions. + */ + static bool rt2800pci_get_entry_state(struct queue_entry *entry) +@@ -1057,6 +1061,7 @@ static const struct rt2x00lib_ops rt2800 + .get_firmware_name = rt2800pci_get_firmware_name, + .check_firmware = rt2800_check_firmware, + .load_firmware = rt2800_load_firmware, ++ .get_eeprom_file_name = rt2800pci_get_eeprom_file_name, + .initialize = rt2x00pci_initialize, + .uninitialize = rt2x00pci_uninitialize, + .get_entry_state = rt2800pci_get_entry_state, +--- a/drivers/net/wireless/rt2x00/rt2x00dev.c ++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c +@@ -1122,6 +1122,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de + INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); + INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup); + ++ retval = rt2x00lib_load_eeprom_file(rt2x00dev); ++ if (retval) ++ goto exit; ++ + /* + * Let the driver probe the device to detect the capabilities. + */ +@@ -1223,6 +1227,11 @@ void rt2x00lib_remove_dev(struct rt2x00_ + * Free queue structures. + */ + rt2x00queue_free(rt2x00dev); ++ ++ /* ++ * Free EEPROM image. ++ */ ++ rt2x00lib_free_eeprom_file(rt2x00dev); + } + EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev); + +--- a/drivers/net/wireless/rt2x00/rt2x00soc.c ++++ b/drivers/net/wireless/rt2x00/rt2x00soc.c +@@ -94,6 +94,7 @@ int rt2x00soc_probe(struct platform_devi + rt2x00dev->hw = hw; + rt2x00dev->irq = platform_get_irq(pdev, 0); + rt2x00dev->name = pdev->dev.driver->name; ++ set_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags); + + rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC); + diff --git a/package/mac80211/patches/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch b/package/mac80211/patches/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch new file mode 100644 index 0000000000..283a1b3498 --- /dev/null +++ b/package/mac80211/patches/604-rt2x00-add-CONFIG_RT2X00_LIB_EEPROM-option.patch @@ -0,0 +1,10 @@ +--- a/config.mk ++++ b/config.mk +@@ -578,6 +578,7 @@ CONFIG_RT2X00=y + CONFIG_RT2X00_LIB=m + CONFIG_RT2800_LIB=m + CONFIG_RT2X00_LIB_FIRMWARE=y ++CONFIG_RT2X00_LIB_EEPROM=y + CONFIG_RT2X00_LIB_CRYPTO=y + # CONFIG_RT2X00_LIB_SOC=y + ifdef CONFIG_COMPAT_KERNEL_2_6_25 -- 2.25.1