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

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