2
0

532-MIPS-BCM63XX-add-inventel-Livebox-support.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. From e796582b499f0ba6acaa1ac3a10c09cceaab7702 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <[email protected]>
  3. Date: Sun, 9 Mar 2014 04:55:52 +0100
  4. Subject: [PATCH] MIPS: BCM63XX: add inventel Livebox support
  5. ---
  6. arch/mips/bcm63xx/boards/Kconfig | 6 +
  7. arch/mips/bcm63xx/boards/Makefile | 1 +
  8. arch/mips/bcm63xx/boards/board_common.c | 2 +-
  9. arch/mips/bcm63xx/boards/board_common.h | 6 +
  10. arch/mips/bcm63xx/boards/board_livebox.c | 215 ++++++++++++++++++++++++++++++
  11. 5 files changed, 229 insertions(+), 1 deletion(-)
  12. create mode 100644 arch/mips/bcm63xx/boards/board_livebox.c
  13. --- a/arch/mips/bcm63xx/boards/Kconfig
  14. +++ b/arch/mips/bcm63xx/boards/Kconfig
  15. @@ -12,4 +12,10 @@ config BOARD_BCM963XX
  16. select BCMA
  17. default y
  18. +config BOARD_LIVEBOX
  19. + bool "Inventel Livebox(es) boards"
  20. + select SSB
  21. + help
  22. + Inventel Livebox boards using the RedBoot bootloader.
  23. +
  24. endmenu
  25. --- a/arch/mips/bcm63xx/boards/Makefile
  26. +++ b/arch/mips/bcm63xx/boards/Makefile
  27. @@ -1,3 +1,4 @@
  28. # SPDX-License-Identifier: GPL-2.0-only
  29. obj-y += board_common.o
  30. obj-$(CONFIG_BOARD_BCM963XX) += board_bcm963xx.o
  31. +obj-$(CONFIG_BOARD_LIVEBOX) += board_livebox.o
  32. --- a/arch/mips/bcm63xx/boards/board_common.c
  33. +++ b/arch/mips/bcm63xx/boards/board_common.c
  34. @@ -54,7 +54,7 @@ void __init board_prom_init(void)
  35. if (fw_arg3 == CFE_EPTSEAL)
  36. board_bcm963xx_init();
  37. else
  38. - panic("unsupported bootloader detected");
  39. + board_livebox_init();
  40. }
  41. static int (*board_get_mac_address)(u8 mac[ETH_ALEN]);
  42. --- a/arch/mips/bcm63xx/boards/board_common.h
  43. +++ b/arch/mips/bcm63xx/boards/board_common.h
  44. @@ -24,4 +24,10 @@ static inline void board_of_device_prese
  45. }
  46. #endif
  47. +#if defined(CONFIG_BOARD_LIVEBOX)
  48. +void board_livebox_init(void);
  49. +#else
  50. +static inline void board_livebox_init(void) { }
  51. +#endif
  52. +
  53. #endif /* __BOARD_COMMON_H */
  54. --- /dev/null
  55. +++ b/arch/mips/bcm63xx/boards/board_livebox.c
  56. @@ -0,0 +1,158 @@
  57. +/*
  58. + * This file is subject to the terms and conditions of the GNU General Public
  59. + * License. See the file "COPYING" in the main directory of this archive
  60. + * for more details.
  61. + *
  62. + * Copyright (C) 2008 Florian Fainelli <[email protected]>
  63. + */
  64. +
  65. +#include <linux/init.h>
  66. +#include <linux/kernel.h>
  67. +#include <linux/string.h>
  68. +#include <linux/input.h>
  69. +#include <asm/addrspace.h>
  70. +#include <bcm63xx_board.h>
  71. +#include <bcm63xx_cpu.h>
  72. +#include <bcm63xx_regs.h>
  73. +#include <bcm63xx_io.h>
  74. +#include <bcm63xx_dev_flash.h>
  75. +#include <board_bcm963xx.h>
  76. +
  77. +#include "board_common.h"
  78. +
  79. +#define PFX "board_livebox: "
  80. +
  81. +static unsigned int mac_addr_used = 0;
  82. +
  83. +/*
  84. + * known 6348 boards
  85. + */
  86. +#ifdef CONFIG_BCM63XX_CPU_6348
  87. +static struct board_info __initdata board_livebox_blue5g = {
  88. + .name = "Livebox-blue-5g",
  89. + .expected_cpu_id = 0x6348,
  90. +
  91. + .has_pccard = 1,
  92. + .has_pci = 1,
  93. + .has_ohci0 = 1,
  94. + .ephy_reset_gpio = 6,
  95. + .ephy_reset_gpio_flags = GPIO_ACTIVE_LOW,
  96. +
  97. + .has_enet0 = 1,
  98. + .enet0 = {
  99. + .has_phy = 1,
  100. + .use_internal_phy = 1,
  101. + },
  102. +
  103. + .has_enet1 = 1,
  104. + .enet1 = {
  105. + .has_phy = 1,
  106. + .phy_id = 31,
  107. + },
  108. +};
  109. +#endif
  110. +
  111. +/*
  112. + * all boards
  113. + */
  114. +static const struct board_info __initdata *bcm963xx_boards[] = {
  115. +#ifdef CONFIG_BCM63XX_CPU_6348
  116. + &board_livebox_blue5g
  117. +#endif /* CONFIG_BCM63XX_CPU_6348 */
  118. +};
  119. +
  120. +static struct of_device_id const livebox_boards_dt[] = {
  121. + { .compatible = "inventel,livebox-1", .data = &board_livebox_blue5g, },
  122. + { }
  123. +};
  124. +
  125. +/*
  126. + * register & return a new board mac address
  127. + */
  128. +static int livebox_get_mac_address(u8 mac[ETH_ALEN])
  129. +{
  130. + u8 *p;
  131. + int count;
  132. + void __iomem *volatile mmio;
  133. +
  134. + mmio = ioremap(0x1ebff377, 0x8);
  135. + if (!mmio)
  136. + return -EIO;
  137. + memcpy_fromio(mac, mmio, ETH_ALEN);
  138. + iounmap(mmio);
  139. +
  140. + p = mac + ETH_ALEN - 1;
  141. + count = mac_addr_used;
  142. +
  143. + while (count--) {
  144. + do {
  145. + (*p)++;
  146. + if (*p != 0)
  147. + break;
  148. + p--;
  149. + } while (p != mac);
  150. + }
  151. +
  152. + if (p == mac) {
  153. + printk(KERN_ERR PFX "unable to fetch mac address\n");
  154. + return -ENODEV;
  155. + }
  156. + mac_addr_used++;
  157. +
  158. + return 0;
  159. +}
  160. +
  161. +/*
  162. + * early init callback
  163. + */
  164. +#define LIVEBOX_GPIO_DETECT_MASK 0x000000ff
  165. +#define LIVEBOX_BOOT_ADDR 0x1e400000
  166. +
  167. +#define LIVEBOX_HW_BLUE5G_9 0x90
  168. +
  169. +void __init board_livebox_init(void)
  170. +{
  171. + u32 val;
  172. + u8 hw_version;
  173. + const struct board_info *board;
  174. + const struct of_device_id *board_match;
  175. +
  176. + /* find board by compat */
  177. + board_match = bcm63xx_match_board(livebox_boards_dt);
  178. + if (board_match) {
  179. + board = board_match->data;
  180. + } else {
  181. + /* Get hardware version */
  182. + val = bcm_gpio_readl(GPIO_CTL_LO_REG);
  183. + val &= ~LIVEBOX_GPIO_DETECT_MASK;
  184. + bcm_gpio_writel(val, GPIO_CTL_LO_REG);
  185. +
  186. + hw_version = bcm_gpio_readl(GPIO_DATA_LO_REG);
  187. + hw_version &= LIVEBOX_GPIO_DETECT_MASK;
  188. +
  189. + switch (hw_version) {
  190. + case LIVEBOX_HW_BLUE5G_9:
  191. + printk(KERN_INFO PFX "Livebox BLUE5G.9\n");
  192. + board = bcm963xx_boards[0];
  193. + break;
  194. + default:
  195. + printk(KERN_INFO PFX "Unknown livebox version: %02x\n",
  196. + hw_version);
  197. + /* use default livebox configuration */
  198. + board = bcm963xx_boards[0];
  199. + break;
  200. + }
  201. + }
  202. +
  203. + /* use default livebox configuration */
  204. + board_early_setup(board, livebox_get_mac_address);
  205. +
  206. + /* read base address of boot chip select (0) */
  207. + val = bcm_mpi_readl(MPI_CSBASE_REG(0));
  208. + val &= MPI_CSBASE_BASE_MASK;
  209. + if (val != LIVEBOX_BOOT_ADDR) {
  210. + printk(KERN_NOTICE PFX "flash address is: 0x%08x, forcing to: 0x%08x\n",
  211. + val, LIVEBOX_BOOT_ADDR);
  212. + bcm63xx_flash_force_phys_base_address(LIVEBOX_BOOT_ADDR, 0x1ebfffff);
  213. + }
  214. +}