This patch updates mtd flash layout, adds voip led, adds one gpio
button, enables to read mac address from default uboot environment.

Signed-off-by: Luka Perkov < openwrt ->-to->- lukaperkov.net >
---

Index: target/linux/lantiq/patches-2.6.39/601-mach-gigasx76x.patch
===================================================================
--- target/linux/lantiq/patches-2.6.39/601-mach-gigasx76x.patch (revision 27591)
+++ target/linux/lantiq/patches-2.6.39/601-mach-gigasx76x.patch (working copy)
@@ -1,6 +1,8 @@
---- a/arch/mips/lantiq/xway/Kconfig
-+++ b/arch/mips/lantiq/xway/Kconfig
-@@ -14,6 +14,10 @@
+Index: linux-2.6.39.2/arch/mips/lantiq/xway/Kconfig
+===================================================================
+--- linux-2.6.39.2.orig/arch/mips/lantiq/xway/Kconfig
++++ linux-2.6.39.2/arch/mips/lantiq/xway/Kconfig
+@@ -14,6 +14,10 @@ config LANTIQ_MACH_NETGEAR
        bool "Netgear"
        default y
  
@@ -11,17 +13,21 @@
  endmenu
  
  endif
---- a/arch/mips/lantiq/xway/Makefile
-+++ b/arch/mips/lantiq/xway/Makefile
-@@ -7,4 +7,5 @@
+Index: linux-2.6.39.2/arch/mips/lantiq/xway/Makefile
+===================================================================
+--- linux-2.6.39.2.orig/arch/mips/lantiq/xway/Makefile
++++ linux-2.6.39.2/arch/mips/lantiq/xway/Makefile
+@@ -7,4 +7,5 @@ obj-$(CONFIG_LANTIQ_MACH_EASY50712) += m
  obj-$(CONFIG_LANTIQ_MACH_EASY50601) += mach-easy50601.o
  obj-$(CONFIG_LANTIQ_MACH_ARV45XX) += mach-arv45xx.o
  obj-$(CONFIG_LANTIQ_MACH_NETGEAR) += mach-netgear.o
 +obj-$(CONFIG_LANTIQ_MACH_GIGASX76X) += mach-gigasx76x.o
  obj-y += dev-dwc_otg.o
+Index: linux-2.6.39.2/arch/mips/lantiq/xway/mach-gigasx76x.c
+===================================================================
 --- /dev/null
-+++ b/arch/mips/lantiq/xway/mach-gigasx76x.c
-@@ -0,0 +1,113 @@
++++ linux-2.6.39.2/arch/mips/lantiq/xway/mach-gigasx76x.c
+@@ -0,0 +1,215 @@
 +/*
 + *  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
@@ -32,6 +38,7 @@
 + *
 + */
 +
++#include <linux/kernel.h>
 +#include <linux/init.h>
 +#include <linux/platform_device.h>
 +#include <linux/leds.h>
@@ -44,6 +51,8 @@
 +#include <linux/ath5k_platform.h>
 +#include <linux/pci.h>
 +#include <linux/phy.h>
++#include <linux/io.h>
++#include <linux/string.h>
 +
 +#include <irq.h>
 +
@@ -55,33 +64,45 @@
 +#include "dev-dwc_otg.h"
 +#include "dev-leds-gpio.h"
 +
++/*
++ * TODO: once we have working uboot we should change MTD layout
++ */
++
++#define SECONDARY_ENV_OFFSET  0x00e000
++#define SECONDARY_ENV_SIZE  0x002000
++
 +#ifdef CONFIG_MTD_PARTITIONS
 +static struct mtd_partition gigasx76x_partitions[] =
 +{
 +      {
-+              .name   = "secondary_env",
-+              .offset = 0xe000,
-+              .size   = 0x2000,
++              .name = "primary_bootloader",
++              .offset = 0x000000,
++              .size = 0x00e000,
 +      },
 +      {
++              .name = "secondary_environment",
++              .offset = SECONDARY_ENV_OFFSET,
++              .size = SECONDARY_ENV_SIZE,
++      },
++      {
 +              .name   = "secondary_boot",
-+              .offset = 0x10000,
-+              .size   = 0x10000,
++              .offset = 0x010000,
++              .size = 0x010000,
 +      },
 +      {
-+              .name   = "uboot",
-+              .offset = 0x20000,
-+              .size   = 0x30000,
++              .name = "openwrt_uboot",
++              .offset = 0x020000,
++              .size = 0x030000,
 +      },
 +      {
-+              .name   = "linux",
-+              .offset = 0x50000,
-+              .size   = 0x7a0000,
++              .name = "wireless_data",
++              .offset = 0x050000,
++              .size = 0x001000,
 +      },
 +      {
-+              .name   = "board_config",
-+              .offset = 0x7f0000,
-+              .size   = 0x10000,
++              .name = "linux",
++              .offset = 0x060000,
++              .size = 0x7a0000,
 +      },
 +};
 +#endif
@@ -94,8 +115,13 @@
 +      { .name = "soc:green:phone1", .gpio = 53, },
 +      { .name = "soc:green:line", .gpio = 54, },
 +      { .name = "soc:green:online", .gpio = 55, },
++      { .name = "soc:green:voip", .gpio = 56, },
 +};
 +
++static struct gpio_button 
++      gigasx76x_gpio_buttons[] __initdata = {
++              { .desc = "reset", .type = EV_KEY, .code = BTN_0, .threshold = 
3, .gpio = 14, .active_low = 1, },
++}; 
 +
 +static struct physmap_flash_data gigasx76x_flash_data = {
 +#ifdef CONFIG_MTD_PARTITIONS
@@ -105,39 +131,123 @@
 +};
 +
 +static struct ltq_pci_data ltq_pci_data = {
-+      .clock      = PCI_CLOCK_INT,
-+      .gpio   = PCI_GNT1 | PCI_REQ1,
-+      .irq    = {
-+              [14] = INT_NUM_IM0_IRL0 + 22,
-+      },
++      .clock  = PCI_CLOCK_INT,
++      .gpio   = PCI_GNT1 | PCI_REQ1,
++      .irq    = { [14] = INT_NUM_IM0_IRL0 + 22, },
 +};
 +
 +static struct ltq_eth_data ltq_eth_data = {
-+  .mii_mode = PHY_INTERFACE_MODE_MII,
++  .mii_mode   = PHY_INTERFACE_MODE_MII,
 +};
 +
-+static void __init
-+gigasx76x_init(void)
-+{
++static char __init *get_uboot_env_var(char *haystack, int haystack_len, char 
*needle, int needle_len) {
++      int i;
++      for (i = 0; i <= haystack_len - needle_len; i++) {
++              if (memcmp(haystack + i, needle, needle_len) == 0) {
++                      return haystack + i + needle_len;
++              }
++      }
++      return NULL;
++}
++
++/* 
++ * gigasx76x_parse_hex_* are not uniq. in arm/orion there are also duplicates:
++ * dns323_parse_hex_*
++ * TODO: one day write a patch for this :)
++ */
++static int __init gigasx76x_parse_hex_nibble(char n) {
++      if (n >= '0' && n <= '9')
++              return n - '0';
++
++      if (n >= 'A' && n <= 'F')
++              return n - 'A' + 10;
++
++      if (n >= 'a' && n <= 'f')
++              return n - 'a' + 10;
++
++      return -1;
++}
++
++static int __init gigasx76x_parse_hex_byte(const char *b) {
++      int hi;
++      int lo;
++
++      hi = gigasx76x_parse_hex_nibble(b[0]);
++      lo = gigasx76x_parse_hex_nibble(b[1]);
++
++      if (hi < 0 || lo < 0)
++              return -1;
++
++      return (hi << 4) | lo;
++}
++
++static int __init gigasx76x_register_ethernet(void) {
++      u_int8_t addr[6];
++      int i;
++      char *uboot_env_page;
++      char *mac;
++
++      uboot_env_page = ioremap(LTQ_FLASH_START + SECONDARY_ENV_OFFSET, 
SECONDARY_ENV_SIZE);
++      if (!uboot_env_page)
++              return -ENOMEM;
++
++      mac = get_uboot_env_var(uboot_env_page, SECONDARY_ENV_SIZE, 
"\0ethaddr=", 9);
++
++      if (!mac) {
++      goto error_fail;
++      }
++
++      /* Sanity check the string we're looking at */
++      for (i = 0; i < 5; i++) {
++      if (*(mac + (i * 3) + 2) != ':') {
++              goto error_fail;
++              }
++      }
++
++      for (i = 0; i < 6; i++) {
++              int byte;
++              byte = gigasx76x_parse_hex_byte(mac + (i * 3));
++              if (byte < 0) {
++                      goto error_fail;
++              }
++              addr[i] = byte;
++      }
++
++      iounmap(uboot_env_page);
++      printk("GIGASX76X: Found ethernet MAC address: ");
++      for (i = 0; i < 6; i++)
++              printk("%.2x%s", addr[i], (i < 5) ? ":" : ".\n");
++
++      memcpy(&ltq_eth_data.mac.sa_data, addr, 6);
++      ltq_register_etop(&ltq_eth_data);
++
++      return 0;
++      
++      error_fail:
++              iounmap(uboot_env_page);
++              return -EINVAL;
++}
++
++static void __init gigasx76x_init(void) {
 +#define GIGASX76X_USB                 29
 +
 +      ltq_register_gpio_stp();
 +      ltq_register_nor(&gigasx76x_flash_data);
 +      ltq_register_pci(&ltq_pci_data);
-+      ltq_register_etop(&ltq_eth_data);
++      gigasx76x_register_ethernet();
 +      xway_register_dwc(GIGASX76X_USB);
 +      ltq_register_tapi();
 +      ltq_register_madwifi_eep();
 +      ltq_add_device_leds_gpio(-1, ARRAY_SIZE(gigasx76x_leds_gpio), 
gigasx76x_leds_gpio);
++      ltq_register_gpio_buttons(gigasx76x_gpio_buttons, 
ARRAY_SIZE(gigasx76x_gpio_buttons));
 +}
 +
-+MIPS_MACHINE(LANTIQ_MACH_GIGASX76X,
-+                      "GIGASX76X",
-+                      "GIGASX76X - Gigaset SX761,SX762,SX763",
-+                      gigasx76x_init);
---- a/arch/mips/lantiq/machtypes.h
-+++ b/arch/mips/lantiq/machtypes.h
-@@ -35,6 +35,9 @@
++MIPS_MACHINE(LANTIQ_MACH_GIGASX76X, "GIGASX76X", "GIGASX76X - Gigaset 
SX761,SX762,SX763", gigasx76x_init);
+Index: linux-2.6.39.2/arch/mips/lantiq/machtypes.h
+===================================================================
+--- linux-2.6.39.2.orig/arch/mips/lantiq/machtypes.h
++++ linux-2.6.39.2/arch/mips/lantiq/machtypes.h
+@@ -36,6 +36,9 @@ enum lantiq_mach_type {
  
        /* Netgear */
        LANTIQ_MACH_DGN3500B,           /* Netgear DGN3500 */
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to