Skip to content

Commit 6086f34

Browse files
committed
Merge tag 'mips_7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
Pull MIPS updates from Thomas Bogendoerfer: "Cleanups and fixes" * tag 'mips_7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: (28 commits) Revert "clk: microchip: core: allow driver to be compiled with COMPILE_TEST" Revert "clk: microchip: fix typo in reference to a config option" MIPS: Implement ARCH_HAS_CC_CAN_LINK MIPS: rb532: Fix MMIO UART resource registration MIPS: Work around LLVM bug when gp is used as global register variable MIPS: Loongson64: env: Fixup serial clock-frequency when using LEFI MIPS: Loongson2ef: Use pcibios_align_resource() to block io range MIPS: Loongson2ef: Register PCI controller in early stage clk: microchip: fix typo in reference to a config option MIPS: Loongson64: dts: fix phy-related definition of LS7A GMAC clk: microchip: core: allow driver to be compiled with COMPILE_TEST MIPS: drop unused pic32.h header watchdog: pic32-wdt: update include to use pic32.h from platform_data watchdog: pic32-dmt: update include to use pic32.h from platform_data serial: pic32_uart: update include to use pic32.h from platform_data rtc: pic32: update include to use pic32.h from platform_data pinctrl: pic32: update include to use pic32.h from platform_data mmc: sdhci-pic32: update include to use pic32.h from platform_data irqchip/irq-pic32-evic: update include to use pic32.h from platform_data clk: microchip: core: update include to use pic32.h from platform_data ...
2 parents 2d10a48 + 720452a commit 6086f34

23 files changed

Lines changed: 191 additions & 38 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17611,6 +17611,7 @@ F: Documentation/arch/mips/
1761117611
F: arch/mips/
1761217612
F: drivers/platform/mips/
1761317613
F: include/dt-bindings/mips/
17614+
F: include/linux/platform_data/pic32.h
1761417615

1761517616
MIPS BOSTON DEVELOPMENT BOARD
1761617617
M: Paul Burton <paulburton@kernel.org>

arch/mips/Kconfig

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ config MIPS
44
default y
55
select ARCH_32BIT_OFF_T if !64BIT
66
select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT
7+
select ARCH_HAS_CC_CAN_LINK
78
select ARCH_HAS_CPU_CACHE_ALIASING
89
select ARCH_HAS_CPU_FINALIZE_INIT
910
select ARCH_HAS_CURRENT_STACK_POINTER
@@ -1409,7 +1410,6 @@ config CPU_LOONGSON32
14091410
select CPU_MIPS32
14101411
select CPU_MIPSR2
14111412
select CPU_HAS_PREFETCH
1412-
select CPU_HAS_LOAD_STORE_LR
14131413
select CPU_SUPPORTS_32BIT_KERNEL
14141414
select CPU_SUPPORTS_HIGHMEM
14151415
select CPU_SUPPORTS_CPUFREQ
@@ -3127,6 +3127,33 @@ config CC_HAS_MNO_BRANCH_LIKELY
31273127
config CC_HAS_BROKEN_INLINE_COMPAT_BRANCH
31283128
def_bool y if CC_IS_CLANG
31293129

3130+
config ARCH_CC_CAN_LINK_N32
3131+
bool
3132+
default $(cc_can_link_user,-mabi=n32 -EL) if MIPS32_N32 && CPU_LITTLE_ENDIAN
3133+
default $(cc_can_link_user,-mabi=n32 -EB) if MIPS32_N32 && CPU_BIG_ENDIAN
3134+
3135+
config ARCH_CC_CAN_LINK_N64
3136+
bool
3137+
default $(cc_can_link_user,-mabi=64 -EL) if 64BIT && CPU_LITTLE_ENDIAN
3138+
default $(cc_can_link_user,-mabi=64 -EB) if 64BIT && CPU_BIG_ENDIAN
3139+
3140+
config ARCH_CC_CAN_LINK_O32
3141+
bool
3142+
default $(cc_can_link_user,-mabi=32 -EL) if (32BIT || MIPS32_O32) && CPU_LITTLE_ENDIAN
3143+
default $(cc_can_link_user,-mabi=32 -EB) if (32BIT || MIPS32_O32) && CPU_BIG_ENDIAN
3144+
3145+
config ARCH_CC_CAN_LINK
3146+
def_bool ARCH_CC_CAN_LINK_N32 || ARCH_CC_CAN_LINK_N64 || ARCH_CC_CAN_LINK_O32
3147+
3148+
config ARCH_USERFLAGS
3149+
string
3150+
default "-mabi=n32 -EL" if ARCH_CC_CAN_LINK_N32 && CPU_LITTLE_ENDIAN
3151+
default "-mabi=n32 -EB" if ARCH_CC_CAN_LINK_N32 && CPU_BIG_ENDIAN
3152+
default "-mabi=64 -EL" if ARCH_CC_CAN_LINK_N64 && CPU_LITTLE_ENDIAN
3153+
default "-mabi=64 -EB" if ARCH_CC_CAN_LINK_N64 && CPU_BIG_ENDIAN
3154+
default "-mabi=32 -EL" if ARCH_CC_CAN_LINK_O32 && CPU_LITTLE_ENDIAN
3155+
default "-mabi=32 -EB" if ARCH_CC_CAN_LINK_O32 && CPU_BIG_ENDIAN
3156+
31303157
menu "Power management options"
31313158

31323159
config ARCH_HIBERNATION_POSSIBLE

arch/mips/boot/dts/loongson/ls7a-pch.dtsi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@
199199
<13 IRQ_TYPE_LEVEL_HIGH>;
200200
interrupt-names = "macirq", "eth_lpi";
201201
interrupt-parent = <&pic>;
202-
phy-mode = "rgmii";
202+
phy-mode = "rgmii-id";
203+
phy-handle = <&phy0>;
203204
mdio {
204205
#address-cells = <1>;
205206
#size-cells = <0>;
@@ -222,7 +223,8 @@
222223
<15 IRQ_TYPE_LEVEL_HIGH>;
223224
interrupt-names = "macirq", "eth_lpi";
224225
interrupt-parent = <&pic>;
225-
phy-mode = "rgmii";
226+
phy-mode = "rgmii-id";
227+
phy-handle = <&phy1>;
226228
mdio {
227229
#address-cells = <1>;
228230
#size-cells = <0>;

arch/mips/include/asm/mach-loongson2ef/loongson.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,10 @@ extern unsigned long _loongson_addrwincfg_base;
324324

325325
#endif /* ! CONFIG_CPU_SUPPORTS_ADDRWINCFG */
326326

327+
#ifdef CONFIG_PCI
328+
void loongson2ef_pcibios_init(void);
329+
#else
330+
static inline void loongson2ef_pcibios_init(void) { }
331+
#endif
332+
327333
#endif /* __ASM_MACH_LOONGSON2EF_LOONGSON_H */

arch/mips/include/asm/mach-loongson64/topology.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define cpu_to_node(cpu) (cpu_logical_map(cpu) >> 2)
88

99
extern cpumask_t __node_cpumask[];
10-
#define cpumask_of_node(node) (&__node_cpumask[node])
10+
#define cpumask_of_node(node) ((node) == NUMA_NO_NODE ? cpu_all_mask : &__node_cpumask[node])
1111

1212
struct pci_bus;
1313
extern int pcibus_to_node(struct pci_bus *);

arch/mips/kernel/relocate.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,20 @@ void *__init relocate_kernel(void)
420420
goto out;
421421

422422
/* The current thread is now within the relocated image */
423+
#ifndef CONFIG_CC_IS_CLANG
423424
__current_thread_info = RELOCATED(&init_thread_union);
425+
#else
426+
/*
427+
* LLVM may wrongly restore $gp ($28) in epilog even if it's
428+
* intentionally modified. Work around this by using inline
429+
* assembly to assign $gp. $gp couldn't be listed as output or
430+
* clobber, or LLVM will still restore its original value.
431+
* See also LLVM upstream issue
432+
* https://github.com/llvm/llvm-project/issues/176546
433+
*/
434+
asm volatile("move $28, %0" : :
435+
"r" (RELOCATED(&init_thread_union)));
436+
#endif
424437

425438
/* Return the new kernel's entry point */
426439
kernel_entry = RELOCATED(start_kernel);

arch/mips/loongson2ef/common/pci.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static struct resource loongson_pci_mem_resource = {
1717

1818
static struct resource loongson_pci_io_resource = {
1919
.name = "pci io space",
20-
.start = LOONGSON_PCI_IO_START,
20+
.start = 0x00000000UL, /* See loongson2ef_pcibios_init(). */
2121
.end = IO_SPACE_LIMIT,
2222
.flags = IORESOURCE_IO,
2323
};
@@ -73,15 +73,19 @@ static void __init setup_pcimap(void)
7373
#endif
7474
}
7575

76-
static int __init pcibios_init(void)
76+
void __init loongson2ef_pcibios_init(void)
7777
{
7878
setup_pcimap();
7979

80+
/*
81+
* ISA-mode only IDE controllers have a hard dependency on ISA IO ports.
82+
*
83+
* Claim them by setting PCI IO space to start at 0x00000000, and set
84+
* PCIBIOS_MIN_IO to prevent non-legacy PCI devices from touching
85+
* reserved regions.
86+
*/
87+
PCIBIOS_MIN_IO = LOONGSON_PCI_IO_START;
88+
8089
loongson_pci_controller.io_map_base = mips_io_port_base;
8190
register_pci_controller(&loongson_pci_controller);
82-
83-
84-
return 0;
8591
}
86-
87-
arch_initcall(pcibios_init);

arch/mips/loongson2ef/common/setup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ EXPORT_SYMBOL(__wbflush);
2727

2828
void __init plat_mem_setup(void)
2929
{
30+
loongson2ef_pcibios_init();
3031
}

arch/mips/loongson64/env.c

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <linux/dma-map-ops.h>
1818
#include <linux/export.h>
19+
#include <linux/libfdt.h>
1920
#include <linux/pci_ids.h>
2021
#include <linux/string_choices.h>
2122
#include <asm/bootinfo.h>
@@ -57,6 +58,101 @@ void __init prom_dtb_init_env(void)
5758
loongson_fdt_blob = (void *)fw_arg2;
5859
}
5960

61+
static int __init lefi_fixup_fdt_serial(void *fdt, u64 uart_addr, u32 uart_clk)
62+
{
63+
int node, len, depth = -1;
64+
const fdt64_t *reg;
65+
fdt32_t *clk;
66+
67+
for (node = fdt_next_node(fdt, -1, &depth);
68+
node >= 0 && depth >= 0;
69+
node = fdt_next_node(fdt, node, &depth)) {
70+
reg = fdt_getprop(fdt, node, "reg", &len);
71+
if (!reg || len <= 8 || fdt64_ld(reg) != uart_addr)
72+
continue;
73+
74+
clk = fdt_getprop_w(fdt, node, "clock-frequency", &len);
75+
if (!clk) {
76+
pr_warn("UART 0x%llx misses clock-frequency property\n",
77+
uart_addr);
78+
return -ENOENT;
79+
} else if (len != 4) {
80+
pr_warn("UART 0x%llx has invalid clock-frequency property\n",
81+
uart_addr);
82+
return -EINVAL;
83+
}
84+
85+
fdt32_st(clk, uart_clk);
86+
87+
return 0;
88+
}
89+
90+
return -ENODEV;
91+
}
92+
93+
static void __init lefi_fixup_fdt(struct system_loongson *system)
94+
{
95+
static unsigned char fdt_buf[16 << 10] __initdata;
96+
struct uart_device *uartdev;
97+
bool is_loongson64g;
98+
u64 uart_base;
99+
int ret, i;
100+
101+
ret = fdt_open_into(loongson_fdt_blob, fdt_buf, sizeof(fdt_buf));
102+
if (ret) {
103+
pr_err("Failed to open FDT to fix up\n");
104+
return;
105+
}
106+
107+
is_loongson64g = (read_c0_prid() & PRID_IMP_MASK) == PRID_IMP_LOONGSON_64G;
108+
109+
for (i = 0; i < system->nr_uarts; i++) {
110+
uartdev = &system->uarts[i];
111+
112+
ret = lefi_fixup_fdt_serial(fdt_buf, uartdev->uart_base,
113+
uartdev->uartclk);
114+
/*
115+
* LOONGSON64G's CPU serials are mapped to two different
116+
* addresses, one full-featured but differs from
117+
* previous generations, one fully compatible with them.
118+
*
119+
* It's unspecified that which mapping should uart_base refer
120+
* to, thus we should try fixing up with both.
121+
*/
122+
if (ret == -ENODEV && is_loongson64g) {
123+
switch (uartdev->uart_base) {
124+
case 0x1fe00100:
125+
uart_base = 0x1fe001e0;
126+
break;
127+
case 0x1fe00110:
128+
uart_base = 0x1fe001e8;
129+
break;
130+
case 0x1fe001e0:
131+
uart_base = 0x1fe00100;
132+
break;
133+
case 0x1fe001e8:
134+
uart_base = 0x1fe00110;
135+
break;
136+
default:
137+
pr_err("Unexpected UART address 0x%llx passed by firmware\n",
138+
uartdev->uart_base);
139+
ret = -EINVAL;
140+
goto err_fixup;
141+
}
142+
143+
ret = lefi_fixup_fdt_serial(fdt_buf, uart_base,
144+
uartdev->uartclk);
145+
}
146+
147+
err_fixup:
148+
if (ret)
149+
pr_err("Couldn't fix up FDT node for UART 0x%llx\n",
150+
uartdev->uart_base);
151+
}
152+
153+
loongson_fdt_blob = fdt_buf;
154+
}
155+
60156
void __init prom_lefi_init_env(void)
61157
{
62158
struct boot_params *boot_p;
@@ -237,4 +333,6 @@ void __init prom_lefi_init_env(void)
237333

238334
if (!loongson_fdt_blob)
239335
pr_err("Failed to determine built-in Loongson64 dtb\n");
336+
else
337+
lefi_fixup_fdt(esys);
240338
}

arch/mips/pic32/common/reset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
* Copyright (C) 2015 Microchip Technology Inc. All rights reserved.
55
*/
66
#include <linux/init.h>
7+
#include <linux/io.h>
8+
#include <linux/platform_data/pic32.h>
79
#include <linux/pm.h>
810
#include <asm/reboot.h>
9-
#include <asm/mach-pic32/pic32.h>
1011

1112
#define PIC32_RSWRST 0x10
1213

0 commit comments

Comments
 (0)