brcm63xx: probe gpio controllers through DT
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-3.14 / 513-MIPS-BCM63XX-add-inventel-Livebox-support.patch
index e1629a30c2a82b0d3ff1f5027c392ca256ae46e7..9775970105a1d7634c46c32eb7fd8a6d2c36a741 100644 (file)
@@ -1,20 +1,20 @@
-From 7e6b22225e16fbb22dbf7f2113d8c6d65333818c Mon Sep 17 00:00:00 2001
+From e796582b499f0ba6acaa1ac3a10c09cceaab7702 Mon Sep 17 00:00:00 2001
 From: Jonas Gorski <jogo@openwrt.org>
 Date: Sun, 9 Mar 2014 04:55:52 +0100
-Subject: [PATCH 44/44] MIPS: BCM63XX: add inventel Livebox support
+Subject: [PATCH] MIPS: BCM63XX: add inventel Livebox support
 
 ---
- arch/mips/bcm63xx/boards/Kconfig         |   6 +
- arch/mips/bcm63xx/boards/Makefile        |   1 +
- arch/mips/bcm63xx/boards/board_common.c  |   2 +-
- arch/mips/bcm63xx/boards/board_common.h  |   6 +
- arch/mips/bcm63xx/boards/board_livebox.c | 193 +++++++++++++++++++++++++++++++
- 5 files changed, 207 insertions(+), 1 deletion(-)
+ arch/mips/bcm63xx/boards/Kconfig         |    6 +
+ arch/mips/bcm63xx/boards/Makefile        |    1 +
+ arch/mips/bcm63xx/boards/board_common.c  |    2 +-
+ arch/mips/bcm63xx/boards/board_common.h  |    6 +
+ arch/mips/bcm63xx/boards/board_livebox.c |  215 ++++++++++++++++++++++++++++++
+ 5 files changed, 229 insertions(+), 1 deletion(-)
  create mode 100644 arch/mips/bcm63xx/boards/board_livebox.c
 
 --- a/arch/mips/bcm63xx/boards/Kconfig
 +++ b/arch/mips/bcm63xx/boards/Kconfig
-@@ -8,4 +8,10 @@ config BOARD_BCM963XX
+@@ -12,4 +12,10 @@ config BOARD_BCM963XX
        default y
         help
  
@@ -33,7 +33,7 @@ Subject: [PATCH 44/44] MIPS: BCM63XX: add inventel Livebox support
 +obj-$(CONFIG_BOARD_LIVEBOX)           += board_livebox.o
 --- a/arch/mips/bcm63xx/boards/board_common.c
 +++ b/arch/mips/bcm63xx/boards/board_common.c
-@@ -58,7 +58,7 @@ void __init board_prom_init(void)
+@@ -61,7 +61,7 @@ void __init board_prom_init(void)
        if (fw_arg3 == CFE_EPTSEAL)
                board_bcm963xx_init();
        else
@@ -44,8 +44,8 @@ Subject: [PATCH 44/44] MIPS: BCM63XX: add inventel Livebox support
  static int (*board_get_mac_address)(u8 mac[ETH_ALEN]);
 --- a/arch/mips/bcm63xx/boards/board_common.h
 +++ b/arch/mips/bcm63xx/boards/board_common.h
-@@ -12,4 +12,10 @@ void board_bcm963xx_init(void);
static inline void board_bcm963xx_init(void) { }
+@@ -24,4 +24,10 @@ static inline void board_of_device_prese
+ }
  #endif
  
 +#if defined(CONFIG_BOARD_LIVEBOX)
@@ -57,7 +57,7 @@ Subject: [PATCH 44/44] MIPS: BCM63XX: add inventel Livebox support
  #endif /* __BOARD_COMMON_H */
 --- /dev/null
 +++ b/arch/mips/bcm63xx/boards/board_livebox.c
-@@ -0,0 +1,200 @@
+@@ -0,0 +1,212 @@
 +/*
 + * This file is subject to the terms and conditions of the GNU General Public
 + * License.  See the file "COPYING" in the main directory of this archive
@@ -111,7 +111,7 @@ Subject: [PATCH 44/44] MIPS: BCM63XX: add inventel Livebox support
 +      },
 +
 +      .ephy_reset_gpio                = 6,
-+      .ephy_reset_gpio_flags          = GPIOF_INIT_HIGH,
++      .ephy_reset_gpio_flags          = GPIO_ACTIVE_LOW,
 +
 +      .has_ohci0                      = 1,
 +      .has_pccard                     = 1,
@@ -168,9 +168,6 @@ Subject: [PATCH 44/44] MIPS: BCM63XX: add inventel Livebox support
 +              },
 +
 +      },
-+
-+      .ephy_reset_gpio                = 6,
-+      .ephy_reset_gpio_flags          = GPIOF_INIT_HIGH,
 +};
 +#endif
 +
@@ -183,6 +180,11 @@ Subject: [PATCH 44/44] MIPS: BCM63XX: add inventel Livebox support
 +#endif
 +};
 +
++static struct of_device_id const livebox_boards_dt[] = {
++      { .compatible = "inventel,livebox-blue-5g", .data = &board_livebox_blue5g, },
++      { }
++};
++
 +/*
 + * register & return a new board mac address
 + */
@@ -227,23 +229,33 @@ Subject: [PATCH 44/44] MIPS: BCM63XX: add inventel Livebox support
 +      u32 val;
 +      u8 hw_version;
 +      const struct board_info *board;
-+
-+      /* Get hardware version */
-+      val = bcm_gpio_readl(GPIO_CTL_LO_REG);
-+      val &= ~LIVEBOX_GPIO_DETECT_MASK;
-+      bcm_gpio_writel(val, GPIO_CTL_LO_REG);
-+
-+      hw_version = bcm_gpio_readl(GPIO_DATA_LO_REG) & LIVEBOX_GPIO_DETECT_MASK;
-+      switch (hw_version) {
-+      case LIVEBOX_HW_BLUE5G_9:
-+              printk(KERN_INFO PFX "Livebox BLUE5G.9\n");
-+              board = bcm963xx_boards[0];
-+              break;
-+      default:
-+              printk(KERN_INFO PFX "Unknown livebox version: %02x\n", hw_version);
-+              /* use default livebox configuration */
-+              board = bcm963xx_boards[0];
-+              break;
++      const struct of_device_id *board_match;
++
++      /* find board by compat */
++      board_match = bcm63xx_match_board(livebox_boards_dt);
++      if (board_match) {
++              board = board_match->data;
++      } else {
++              /* Get hardware version */
++              val = bcm_gpio_readl(GPIO_CTL_LO_REG);
++              val &= ~LIVEBOX_GPIO_DETECT_MASK;
++              bcm_gpio_writel(val, GPIO_CTL_LO_REG);
++
++              hw_version = bcm_gpio_readl(GPIO_DATA_LO_REG);
++              hw_version &= LIVEBOX_GPIO_DETECT_MASK;
++
++              switch (hw_version) {
++              case LIVEBOX_HW_BLUE5G_9:
++                      printk(KERN_INFO PFX "Livebox BLUE5G.9\n");
++                      board = bcm963xx_boards[0];
++                      break;
++              default:
++                      printk(KERN_INFO PFX "Unknown livebox version: %02x\n",
++                             hw_version);
++                      /* use default livebox configuration */
++                      board = bcm963xx_boards[0];
++                      break;
++              }
 +      }
 +
 +      /* use default livebox configuration */