kernel: bump 5.15 to 5.15.118
[openwrt/openwrt.git] / target / linux / bcm63xx / patches-5.15 / 532-MIPS-BCM63XX-add-inventel-Livebox-support.patch
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 ---
7 arch/mips/bcm63xx/boards/Kconfig | 6 +
8 arch/mips/bcm63xx/boards/Makefile | 1 +
9 arch/mips/bcm63xx/boards/board_common.c | 2 +-
10 arch/mips/bcm63xx/boards/board_common.h | 6 +
11 arch/mips/bcm63xx/boards/board_livebox.c | 215 ++++++++++++++++++++++++++++++
12 5 files changed, 229 insertions(+), 1 deletion(-)
13 create mode 100644 arch/mips/bcm63xx/boards/board_livebox.c
14
15 --- a/arch/mips/bcm63xx/boards/Kconfig
16 +++ b/arch/mips/bcm63xx/boards/Kconfig
17 @@ -12,4 +12,10 @@ config BOARD_BCM963XX
18 select BCMA
19 default y
20
21 +config BOARD_LIVEBOX
22 + bool "Inventel Livebox(es) boards"
23 + select SSB
24 + help
25 + Inventel Livebox boards using the RedBoot bootloader.
26 +
27 endmenu
28 --- a/arch/mips/bcm63xx/boards/Makefile
29 +++ b/arch/mips/bcm63xx/boards/Makefile
30 @@ -1,3 +1,4 @@
31 # SPDX-License-Identifier: GPL-2.0-only
32 obj-y += board_common.o
33 obj-$(CONFIG_BOARD_BCM963XX) += board_bcm963xx.o
34 +obj-$(CONFIG_BOARD_LIVEBOX) += board_livebox.o
35 --- a/arch/mips/bcm63xx/boards/board_common.c
36 +++ b/arch/mips/bcm63xx/boards/board_common.c
37 @@ -54,7 +54,7 @@ void __init board_prom_init(void)
38 if (fw_arg3 == CFE_EPTSEAL)
39 board_bcm963xx_init();
40 else
41 - panic("unsupported bootloader detected");
42 + board_livebox_init();
43 }
44
45 static int (*board_get_mac_address)(u8 mac[ETH_ALEN]);
46 --- a/arch/mips/bcm63xx/boards/board_common.h
47 +++ b/arch/mips/bcm63xx/boards/board_common.h
48 @@ -24,4 +24,10 @@ static inline void board_of_device_prese
49 }
50 #endif
51
52 +#if defined(CONFIG_BOARD_LIVEBOX)
53 +void board_livebox_init(void);
54 +#else
55 +static inline void board_livebox_init(void) { }
56 +#endif
57 +
58 #endif /* __BOARD_COMMON_H */
59 --- /dev/null
60 +++ b/arch/mips/bcm63xx/boards/board_livebox.c
61 @@ -0,0 +1,158 @@
62 +/*
63 + * This file is subject to the terms and conditions of the GNU General Public
64 + * License. See the file "COPYING" in the main directory of this archive
65 + * for more details.
66 + *
67 + * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
68 + */
69 +
70 +#include <linux/init.h>
71 +#include <linux/kernel.h>
72 +#include <linux/string.h>
73 +#include <linux/input.h>
74 +#include <asm/addrspace.h>
75 +#include <bcm63xx_board.h>
76 +#include <bcm63xx_cpu.h>
77 +#include <bcm63xx_regs.h>
78 +#include <bcm63xx_io.h>
79 +#include <bcm63xx_dev_flash.h>
80 +#include <board_bcm963xx.h>
81 +
82 +#include "board_common.h"
83 +
84 +#define PFX "board_livebox: "
85 +
86 +static unsigned int mac_addr_used = 0;
87 +
88 +/*
89 + * known 6348 boards
90 + */
91 +#ifdef CONFIG_BCM63XX_CPU_6348
92 +static struct board_info __initdata board_livebox_blue5g = {
93 + .name = "Livebox-blue-5g",
94 + .expected_cpu_id = 0x6348,
95 +
96 + .has_pccard = 1,
97 + .has_pci = 1,
98 + .has_ohci0 = 1,
99 + .ephy_reset_gpio = 6,
100 + .ephy_reset_gpio_flags = GPIO_ACTIVE_LOW,
101 +
102 + .has_enet0 = 1,
103 + .enet0 = {
104 + .has_phy = 1,
105 + .use_internal_phy = 1,
106 + },
107 +
108 + .has_enet1 = 1,
109 + .enet1 = {
110 + .has_phy = 1,
111 + .phy_id = 31,
112 + },
113 +};
114 +#endif
115 +
116 +/*
117 + * all boards
118 + */
119 +static const struct board_info __initdata *bcm963xx_boards[] = {
120 +#ifdef CONFIG_BCM63XX_CPU_6348
121 + &board_livebox_blue5g
122 +#endif /* CONFIG_BCM63XX_CPU_6348 */
123 +};
124 +
125 +static struct of_device_id const livebox_boards_dt[] = {
126 + { .compatible = "inventel,livebox-1", .data = &board_livebox_blue5g, },
127 + { }
128 +};
129 +
130 +/*
131 + * register & return a new board mac address
132 + */
133 +static int livebox_get_mac_address(u8 mac[ETH_ALEN])
134 +{
135 + u8 *p;
136 + int count;
137 + void __iomem *volatile mmio;
138 +
139 + mmio = ioremap(0x1ebff377, 0x8);
140 + if (!mmio)
141 + return -EIO;
142 + memcpy_fromio(mac, mmio, ETH_ALEN);
143 + iounmap(mmio);
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 +}