Re: [OpenWrt-Devel] [PATCH 1/3] ar71xx: in-flash macs and eeprom for mach-eap7660d

2010-07-15 Thread Gabor Juhos
2010.07.14. 0:38 keltezéssel, daniel.go...@gmail.com írta:
 I now renamed everything to ath5k_platform and also included all other 
 previously suggested fixes.
 Cheers!
 
 
 This adds in-flash mac-addresses and callibration data for the Senao EAP7660D 
 board.
 
 Signed-off-by: Daniel Golle daniel.go...@gmail.com

Applied: https://dev.openwrt.org/changeset/22187

Thanks,
Gabor
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/3] ar71xx: in-flash macs and eeprom for mach-eap7660d

2010-07-13 Thread daniel . golle
This patch adds support for reading MAC addresses as well as wireless interface 
callibration-data from the board flash of the EAP7660D.

Signed-off-by: Daniel Golle daniel.go...@gmail.com

Index: target/linux/ar71xx/files/include/linux/ath_platform.h
===
--- target/linux/ar71xx/files/include/linux/ath_platform.h  (revision 0)
+++ target/linux/ar71xx/files/include/linux/ath_platform.h  (revision 0)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2008 Atheros Communications Inc.
+ * Copyright (c) 2009 Gabor Juhos juh...@openwrt.org
+ * Copyright (c) 2009 Imre Kaloz ka...@openwrt.org
+ * Copyright (c) 2010 Daniel Golle daniel.go...@gmail.com
+ *
+ * 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.
+ */
+
+#ifndef _LINUX_ATH_PLATFORM_H
+#define _LINUX_ATH_PLATFORM_H
+
+#define ATH_PLAT_EEP_MAX_WORDS 2048
+
+struct ath_platform_data {
+   u16 *eeprom_data;
+   u8 *macaddr;
+};
+
+#endif /* _LINUX_ATH_PLATFORM_H */
Index: target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig
===
--- target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig  (revision 22105)
+++ target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig  (working copy)
@@ -226,7 +226,6 @@
 config AR71XX_MACH_EAP7660D
bool Senao EAP7660D support
select AR71XX_DEV_M25P80
-   select AR71XX_DEV_PB42_PCI if PCI
select AR71XX_DEV_GPIO_BUTTONS
select AR71XX_DEV_LEDS_GPIO
default n
Index: target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c
===
--- target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c  (revision 22105)
+++ target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c  (working copy)
@@ -10,13 +10,16 @@
  *  by the Free Software Foundation.
  */
 
+#include linux/pci.h
+#include linux/ath_platform.h
+#include linux/delay.h
 #include asm/mach-ar71xx/ar71xx.h
+#include asm/mach-ar71xx/pci.h
 
 #include machtype.h
 #include devices.h
 #include dev-gpio-buttons.h
 #include dev-leds-gpio.h
-#include dev-pb42-pci.h
 #include dev-m25p80.h
 
 #define EAP7660D_BUTTONS_POLL_INTERVAL 20
@@ -27,7 +30,77 @@
 #define EAP7660D_GPIO_SW1  3
 #define EAP7660D_GPIO_SW3  8
 #define EAP7660D_PHYMASK   BIT(20)
+#define EAP7660D_BOARDCONFIG   0x1F7F
+#define EAP7660D_GBIC_MAC_OFFSET   0x1000
+#define EAP7660D_WMAC0_MAC_OFFSET  0x1010
+#define EAP7660D_WMAC1_MAC_OFFSET  0x1016
+#define EAP7660D_WMAC0_CALDATA_OFFSET  0x2000
+#define EAP7660D_WMAC1_CALDATA_OFFSET  0x3000
 
+static struct ath_platform_data eap7660d_wmac0_data;
+static struct ath_platform_data eap7660d_wmac1_data;
+static char eap7660d_wmac0_mac[6];
+static char eap7660d_wmac1_mac[6];
+static __u16 eap7660d_wmac0_eeprom[ATH_PLAT_EEP_MAX_WORDS];
+static __u16 eap7660d_wmac1_eeprom[ATH_PLAT_EEP_MAX_WORDS];
+static int ap94_pci_fixup_enabled;
+
+static struct ar71xx_pci_irq eap7660d_pci_irqs[] __initdata = {
+{
+.slot   = 0,
+.pin= 1,
+.irq= AR71XX_PCI_IRQ_DEV0,
+}, {
+.slot   = 1,
+.pin= 1,
+.irq= AR71XX_PCI_IRQ_DEV1,
+}
+};
+
+static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
+{
+   switch(PCI_SLOT(dev-devfn)) {
+   case 17:
+   dev-dev.platform_data = eap7660d_wmac0_data;
+   break;
+
+   case 18:
+   dev-dev.platform_data = eap7660d_wmac1_data;
+   break;
+   }
+
+   return 0;
+}
+
+void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
+ u8 *cal_data1, u8 *mac_addr1)
+{
+   if (cal_data0  *cal_data0 == 0xa55a) {
+   memcpy(eap7660d_wmac0_eeprom, cal_data0,
+   ATH_PLAT_EEP_MAX_WORDS);
+   eap7660d_wmac0_data.eeprom_data = eap7660d_wmac0_eeprom;
+   }
+
+   if (cal_data1  *cal_data1 == 0xa55a) {
+   memcpy(eap7660d_wmac1_eeprom, cal_data1,
+   ATH_PLAT_EEP_MAX_WORDS);
+   eap7660d_wmac1_data.eeprom_data = eap7660d_wmac1_eeprom;
+   }
+
+   if (mac_addr0) {
+   

Re: [OpenWrt-Devel] [PATCH 1/3] ar71xx: in-flash macs and eeprom for mach-eap7660d

2010-07-13 Thread Gabor Juhos
2010.07.13. 19:22 keltezéssel, daniel.go...@gmail.com írta:
 This patch adds support for reading MAC addresses as well as wireless 
 interface callibration-data from the board flash of the EAP7660D.
 
 Signed-off-by: Daniel Golle daniel.go...@gmail.com
 
 Index: target/linux/ar71xx/files/include/linux/ath_platform.h
 ===
 --- target/linux/ar71xx/files/include/linux/ath_platform.h(revision 0)
 +++ target/linux/ar71xx/files/include/linux/ath_platform.h(revision 0)
 @@ -0,0 +1,30 @@
 +/*
 + * Copyright (c) 2008 Atheros Communications Inc.
 + * Copyright (c) 2009 Gabor Juhos juh...@openwrt.org
 + * Copyright (c) 2009 Imre Kaloz ka...@openwrt.org
 + * Copyright (c) 2010 Daniel Golle daniel.go...@gmail.com
 + *
 + * 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.
 + */
 +
 +#ifndef _LINUX_ATH_PLATFORM_H
 +#define _LINUX_ATH_PLATFORM_H
 +
 +#define ATH_PLAT_EEP_MAX_WORDS   2048
 +
 +struct ath_platform_data {
 + u16 *eeprom_data;
 + u8 *macaddr;
 +};
 +
 +#endif /* _LINUX_ATH_PLATFORM_H */

Now that this will be used for ath5k devices only, it would be better to rename
it to ath5k_platform.h, and change the ath prefixes to ath5k as well.

 Index: target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig
 ===
 --- target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig(revision 22105)
 +++ target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig(working copy)
 @@ -226,7 +226,6 @@
  config AR71XX_MACH_EAP7660D
   bool Senao EAP7660D support
   select AR71XX_DEV_M25P80
 - select AR71XX_DEV_PB42_PCI if PCI
   select AR71XX_DEV_GPIO_BUTTONS
   select AR71XX_DEV_LEDS_GPIO
   default n
 Index: target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c
 ===
 --- target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c
 (revision 22105)
 +++ target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c
 (working copy)
 @@ -10,13 +10,16 @@
   *  by the Free Software Foundation.
   */
  
 +#include linux/pci.h
 +#include linux/ath_platform.h
 +#include linux/delay.h
  #include asm/mach-ar71xx/ar71xx.h
 +#include asm/mach-ar71xx/pci.h
  
  #include machtype.h
  #include devices.h
  #include dev-gpio-buttons.h
  #include dev-leds-gpio.h
 -#include dev-pb42-pci.h
  #include dev-m25p80.h
  
  #define EAP7660D_BUTTONS_POLL_INTERVAL   20
 @@ -27,7 +30,77 @@
  #define EAP7660D_GPIO_SW13
  #define EAP7660D_GPIO_SW38
  #define EAP7660D_PHYMASK BIT(20)
 +#define EAP7660D_BOARDCONFIG 0x1F7F
 +#define EAP7660D_GBIC_MAC_OFFSET 0x1000
 +#define EAP7660D_WMAC0_MAC_OFFSET0x1010
 +#define EAP7660D_WMAC1_MAC_OFFSET0x1016
 +#define EAP7660D_WMAC0_CALDATA_OFFSET0x2000
 +#define EAP7660D_WMAC1_CALDATA_OFFSET0x3000
  
 +static struct ath_platform_data eap7660d_wmac0_data;
 +static struct ath_platform_data eap7660d_wmac1_data;
 +static char eap7660d_wmac0_mac[6];
 +static char eap7660d_wmac1_mac[6];
 +static __u16 eap7660d_wmac0_eeprom[ATH_PLAT_EEP_MAX_WORDS];
 +static __u16 eap7660d_wmac1_eeprom[ATH_PLAT_EEP_MAX_WORDS];

The __xx types are used in the header files which are exported to used-space.
You should use 'u16' here.

 +static int ap94_pci_fixup_enabled;

This variable is not needed.

 +
 +static struct ar71xx_pci_irq eap7660d_pci_irqs[] __initdata = {
 +{
 +.slot   = 0,
 +.pin= 1,
 +.irq= AR71XX_PCI_IRQ_DEV0,
 +}, {
 +.slot   = 1,
 +.pin= 1,
 +.irq= AR71XX_PCI_IRQ_DEV1,
 +}
 +};
 +
 +static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
 +{
 + switch(PCI_SLOT(dev-devfn)) {
 + case 17:
 + dev-dev.platform_data = eap7660d_wmac0_data;
 + break;
 +
 + case 18:
 + dev-dev.platform_data = eap7660d_wmac1_data;
 + break;
 + }
 +
 + return 0;
 +}
 +
 +void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
 +   u8 *cal_data1, u8 *mac_addr1)
 +{
 + if (cal_data0  *cal_data0 == 0xa55a) {
 + 

Re: [OpenWrt-Devel] [PATCH 1/3] ar71xx: in-flash macs and eeprom for mach-eap7660d

2010-07-13 Thread daniel . golle
I now renamed everything to ath5k_platform and also included all other 
previously suggested fixes.
Cheers!


This adds in-flash mac-addresses and callibration data for the Senao EAP7660D 
board.

Signed-off-by: Daniel Golle daniel.go...@gmail.com

Index: target/linux/ar71xx/files/include/linux/ath5k_platform.h
===
--- target/linux/ar71xx/files/include/linux/ath5k_platform.h(revision 0)
+++ target/linux/ar71xx/files/include/linux/ath5k_platform.h(revision 0)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2008 Atheros Communications Inc.
+ * Copyright (c) 2009 Gabor Juhos juh...@openwrt.org
+ * Copyright (c) 2009 Imre Kaloz ka...@openwrt.org
+ * Copyright (c) 2010 Daniel Golle daniel.go...@gmail.com
+ *
+ * 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.
+ */
+
+#ifndef _LINUX_ATH5K_PLATFORM_H
+#define _LINUX_ATH5K_PLATFORM_H
+
+#define ATH5K_PLAT_EEP_MAX_WORDS   2048
+
+struct ath5k_platform_data {
+   u16 *eeprom_data;
+   u8 *macaddr;
+};
+
+#endif /* _LINUX_ATH5K_PLATFORM_H */
Index: target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig
===
--- target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig  (revision 22105)
+++ target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig  (working copy)
@@ -226,7 +226,6 @@
 config AR71XX_MACH_EAP7660D
bool Senao EAP7660D support
select AR71XX_DEV_M25P80
-   select AR71XX_DEV_PB42_PCI if PCI
select AR71XX_DEV_GPIO_BUTTONS
select AR71XX_DEV_LEDS_GPIO
default n
Index: target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c
===
--- target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c  (revision 22105)
+++ target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c  (working copy)
@@ -10,13 +10,16 @@
  *  by the Free Software Foundation.
  */
 
+#include linux/pci.h
+#include linux/ath5k_platform.h
+#include linux/delay.h
 #include asm/mach-ar71xx/ar71xx.h
+#include asm/mach-ar71xx/pci.h
 
 #include machtype.h
 #include devices.h
 #include dev-gpio-buttons.h
 #include dev-leds-gpio.h
-#include dev-pb42-pci.h
 #include dev-m25p80.h
 
 #define EAP7660D_BUTTONS_POLL_INTERVAL 20
@@ -27,7 +30,76 @@
 #define EAP7660D_GPIO_SW1  3
 #define EAP7660D_GPIO_SW3  8
 #define EAP7660D_PHYMASK   BIT(20)
+#define EAP7660D_BOARDCONFIG   0x1F7F
+#define EAP7660D_GBIC_MAC_OFFSET   0x1000
+#define EAP7660D_WMAC0_MAC_OFFSET  0x1010
+#define EAP7660D_WMAC1_MAC_OFFSET  0x1016
+#define EAP7660D_WMAC0_CALDATA_OFFSET  0x2000
+#define EAP7660D_WMAC1_CALDATA_OFFSET  0x3000
 
+static struct ath5k_platform_data eap7660d_wmac0_data;
+static struct ath5k_platform_data eap7660d_wmac1_data;
+static char eap7660d_wmac0_mac[6];
+static char eap7660d_wmac1_mac[6];
+static u16 eap7660d_wmac0_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
+static u16 eap7660d_wmac1_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
+
+static struct ar71xx_pci_irq eap7660d_pci_irqs[] __initdata = {
+{
+.slot   = 0,
+.pin= 1,
+.irq= AR71XX_PCI_IRQ_DEV0,
+}, {
+.slot   = 1,
+.pin= 1,
+.irq= AR71XX_PCI_IRQ_DEV1,
+}
+};
+
+static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
+{
+   switch(PCI_SLOT(dev-devfn)) {
+   case 17:
+   dev-dev.platform_data = eap7660d_wmac0_data;
+   break;
+
+   case 18:
+   dev-dev.platform_data = eap7660d_wmac1_data;
+   break;
+   }
+
+   return 0;
+}
+
+void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
+ u8 *cal_data1, u8 *mac_addr1)
+{
+   if (cal_data0  *cal_data0 == 0xa55a) {
+   memcpy(eap7660d_wmac0_eeprom, cal_data0,
+   ATH5K_PLAT_EEP_MAX_WORDS);
+   eap7660d_wmac0_data.eeprom_data = eap7660d_wmac0_eeprom;
+   }
+
+   if (cal_data1  *cal_data1 == 0xa55a) {
+   memcpy(eap7660d_wmac1_eeprom, cal_data1,
+   ATH5K_PLAT_EEP_MAX_WORDS);
+   eap7660d_wmac1_data.eeprom_data = eap7660d_wmac1_eeprom;
+   }
+
+   if