454-board_livebox.patch 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. --- a/arch/mips/bcm63xx/boards/Kconfig
  2. +++ b/arch/mips/bcm63xx/boards/Kconfig
  3. @@ -8,4 +8,10 @@ config BOARD_BCM963XX
  4. select SSB
  5. help
  6. +config BOARD_LIVEBOX
  7. + bool "Inventel Livebox(es) boards"
  8. + select SSB
  9. + help
  10. + Inventel Livebox boards using the RedBoot bootloader.
  11. +
  12. endchoice
  13. --- a/arch/mips/bcm63xx/boards/Makefile
  14. +++ b/arch/mips/bcm63xx/boards/Makefile
  15. @@ -1,3 +1,4 @@
  16. obj-$(CONFIG_BOARD_BCM963XX) += board_bcm963xx.o
  17. +obj-$(CONFIG_BOARD_LIVEBOX) += board_livebox.o
  18. ccflags-y := -Werror
  19. --- /dev/null
  20. +++ b/arch/mips/bcm63xx/boards/board_livebox.c
  21. @@ -0,0 +1,228 @@
  22. +/*
  23. + * This file is subject to the terms and conditions of the GNU General Public
  24. + * License. See the file "COPYING" in the main directory of this archive
  25. + * for more details.
  26. + *
  27. + * Copyright (C) 2008 Florian Fainelli <[email protected]>
  28. + */
  29. +
  30. +#include <linux/init.h>
  31. +#include <linux/kernel.h>
  32. +#include <linux/string.h>
  33. +#include <linux/platform_device.h>
  34. +#include <linux/mtd/mtd.h>
  35. +#include <linux/mtd/partitions.h>
  36. +#include <linux/mtd/physmap.h>
  37. +#include <linux/input.h>
  38. +#include <linux/gpio_buttons.h>
  39. +#include <asm/addrspace.h>
  40. +#include <bcm63xx_board.h>
  41. +#include <bcm63xx_cpu.h>
  42. +#include <bcm63xx_regs.h>
  43. +#include <bcm63xx_io.h>
  44. +#include <bcm63xx_dev_uart.h>
  45. +#include <bcm63xx_dev_pci.h>
  46. +#include <bcm63xx_dev_enet.h>
  47. +#include <bcm63xx_dev_pcmcia.h>
  48. +#include <bcm63xx_dev_usb_ohci.h>
  49. +#include <bcm63xx_dev_usb_ehci.h>
  50. +#include <board_bcm963xx.h>
  51. +
  52. +#define PFX "board_livebox: "
  53. +
  54. +static unsigned int mac_addr_used = 0;
  55. +static struct board_info board;
  56. +
  57. +/*
  58. + * known 6348 boards
  59. + */
  60. +#ifdef CONFIG_BCM63XX_CPU_6348
  61. +static struct board_info __initdata board_livebox = {
  62. + .name = "Livebox",
  63. + .expected_cpu_id = 0x6348,
  64. +
  65. + .has_uart0 = 1,
  66. + .has_enet0 = 1,
  67. + .has_enet1 = 1,
  68. + .has_pci = 1,
  69. +
  70. + .enet0 = {
  71. + .has_phy = 1,
  72. + .use_internal_phy = 1,
  73. + },
  74. +
  75. + .enet1 = {
  76. + .force_speed_100 = 1,
  77. + .force_duplex_full = 1,
  78. + },
  79. +
  80. + .has_ohci0 = 1,
  81. + .has_pccard = 1,
  82. + .has_ehci0 = 1,
  83. +};
  84. +#endif
  85. +
  86. +/*
  87. + * all boards
  88. + */
  89. +static const struct board_info __initdata *bcm963xx_boards[] = {
  90. +#ifdef CONFIG_BCM63XX_CPU_6348
  91. + &board_livebox
  92. +#endif
  93. +};
  94. +
  95. +/*
  96. + * early init callback
  97. + */
  98. +void __init board_prom_init(void)
  99. +{
  100. + u32 val;
  101. +
  102. + /* read base address of boot chip select (0) */
  103. + val = bcm_mpi_readl(MPI_CSBASE_REG(0));
  104. + val &= MPI_CSBASE_BASE_MASK;
  105. +
  106. + /* assume board is a Livebox */
  107. + memcpy(&board, bcm963xx_boards[0], sizeof(board));
  108. +
  109. + /* setup pin multiplexing depending on board enabled device,
  110. + * this has to be done this early since PCI init is done
  111. + * inside arch_initcall */
  112. + val = 0;
  113. +
  114. + if (board.has_pci) {
  115. + bcm63xx_pci_enabled = 1;
  116. + if (BCMCPU_IS_6348())
  117. + val |= GPIO_MODE_6348_G2_PCI;
  118. + }
  119. +
  120. + if (board.has_pccard) {
  121. + if (BCMCPU_IS_6348())
  122. + val |= GPIO_MODE_6348_G1_MII_PCCARD;
  123. + }
  124. +
  125. + if (board.has_enet0 && !board.enet0.use_internal_phy) {
  126. + if (BCMCPU_IS_6348())
  127. + val |= GPIO_MODE_6348_G3_EXT_MII |
  128. + GPIO_MODE_6348_G0_EXT_MII;
  129. + }
  130. +
  131. + if (board.has_enet1 && !board.enet1.use_internal_phy) {
  132. + if (BCMCPU_IS_6348())
  133. + val |= GPIO_MODE_6348_G3_EXT_MII |
  134. + GPIO_MODE_6348_G0_EXT_MII;
  135. + }
  136. +
  137. + bcm_gpio_writel(val, GPIO_MODE_REG);
  138. +}
  139. +
  140. +/*
  141. + * second stage init callback, good time to panic if we couldn't
  142. + * identify on which board we're running since early printk is working
  143. + */
  144. +void __init board_setup(void)
  145. +{
  146. + if (!board.name[0])
  147. + panic("unable to detect bcm963xx board");
  148. + printk(KERN_INFO PFX "board name: %s\n", board.name);
  149. +
  150. + /* make sure we're running on expected cpu */
  151. + if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
  152. + panic("unexpected CPU for bcm963xx board");
  153. +}
  154. +
  155. +/*
  156. + * return board name for /proc/cpuinfo
  157. + */
  158. +const char *board_get_name(void)
  159. +{
  160. + return board.name;
  161. +}
  162. +
  163. +/*
  164. + * register & return a new board mac address
  165. + */
  166. +
  167. +static int board_get_mac_address(u8 *mac)
  168. +{
  169. + u8 default_mac[ETH_ALEN] = {0x00, 0x07, 0x3A, 0x00, 0x00, 0x00};
  170. + u8 *p;
  171. + int count;
  172. +
  173. + memcpy(mac, default_mac, ETH_ALEN);
  174. +
  175. + p = mac + ETH_ALEN - 1;
  176. + count = mac_addr_used;
  177. +
  178. + while (count--) {
  179. + do {
  180. + (*p)++;
  181. + if (*p != 0)
  182. + break;
  183. + p--;
  184. + } while (p != mac);
  185. + }
  186. +
  187. + if (p == mac) {
  188. + printk(KERN_ERR PFX "unable to fetch mac address\n");
  189. + return -ENODEV;
  190. + }
  191. + mac_addr_used++;
  192. +
  193. + return 0;
  194. +}
  195. +
  196. +static struct resource mtd_resources[] = {
  197. + {
  198. + .start = 0, /* filled at runtime */
  199. + .end = 0, /* filled at runtime */
  200. + .flags = IORESOURCE_MEM,
  201. + }
  202. +};
  203. +
  204. +static struct platform_device mtd_dev = {
  205. + .name = "bcm963xx-flash",
  206. + .resource = mtd_resources,
  207. + .num_resources = ARRAY_SIZE(mtd_resources),
  208. +};
  209. +
  210. +
  211. +/*
  212. + * third stage init callback, register all board devices.
  213. + */
  214. +int __init board_register_devices(void)
  215. +{
  216. + u32 val;
  217. +
  218. + if (board.has_uart0)
  219. + bcm63xx_uart_register(0);
  220. +
  221. + if (board.has_pccard)
  222. + bcm63xx_pcmcia_register();
  223. +
  224. + if (board.has_enet0 &&
  225. + !board_get_mac_address(board.enet0.mac_addr))
  226. + bcm63xx_enet_register(0, &board.enet0);
  227. +
  228. + if (board.has_enet1 &&
  229. + !board_get_mac_address(board.enet1.mac_addr))
  230. + bcm63xx_enet_register(1, &board.enet1);
  231. +
  232. + if (board.has_ohci0)
  233. + bcm63xx_ohci_register();
  234. +
  235. + if (board.has_ehci0)
  236. + bcm63xx_ehci_register();
  237. +
  238. +
  239. + /* read base address of boot chip select (0) */
  240. + val = bcm_mpi_readl(MPI_CSBASE_REG(0));
  241. + val &= MPI_CSBASE_BASE_MASK;
  242. + mtd_resources[0].start = val;
  243. + mtd_resources[0].end = 0x1FFFFFFF;
  244. +
  245. + platform_device_register(&mtd_dev);
  246. +
  247. + return 0;
  248. +}
  249. +