Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: loongson32: Switch to generic core

The generic MIPS core is fully compatible with Loongson-1 SoCs,
so migrate Loongson-1 to it.

Main changes are:
- Merge CPU_LOONGSON1B and CPU_LOONGSON1C into a unified CPU_LOONGSON32,
as both are based on the GS232 core.
- Consolidate LOONGSON1_LS1B and LOONGSON1_LS1C Kconfig options into
MACH_LOONGSON32.
- Enable MACH_GENERIC_CORE and remove the legacy custom implementation.
- Remove all Loongson-1 platform devices and associated code,
which are now obsolete due to Device Tree support.
- Misc cleanup.

Partially based on earlier work by Jiaxun Yang.

Link: https://lore.kernel.org/all/20190411121915.8040-4-jiaxun.yang@flygoat.com/
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Keguang Zhang and committed by
Thomas Bogendoerfer
85c43540 ec7c2a10

+33 -1057
-1
MAINTAINERS
··· 17017 17017 S: Maintained 17018 17018 F: Documentation/devicetree/bindings/*/loongson,ls1*.yaml 17019 17019 F: arch/mips/boot/dts/loongson/loongson1* 17020 - F: arch/mips/include/asm/mach-loongson32/ 17021 17020 F: arch/mips/loongson32/ 17022 17021 F: drivers/*/*loongson1* 17023 17022 F: drivers/mtd/nand/raw/loongson1-nand-controller.c
+32 -32
arch/mips/Kconfig
··· 480 480 481 481 config MACH_LOONGSON32 482 482 bool "Loongson 32-bit family of machines" 483 + select MACH_GENERIC_CORE 484 + select USE_OF 485 + select BUILTIN_DTB 486 + select BOOT_ELF32 487 + select CEVT_R4K 488 + select CSRC_R4K 489 + select COMMON_CLK 490 + select DMA_NONCOHERENT 491 + select GENERIC_IRQ_SHOW_LEVEL 492 + select IRQ_MIPS_CPU 493 + select LS1X_IRQ 494 + select SYS_HAS_CPU_LOONGSON32 495 + select SYS_HAS_EARLY_PRINTK 496 + select USE_GENERIC_EARLY_PRINTK_8250 497 + select SYS_SUPPORTS_32BIT_KERNEL 498 + select SYS_SUPPORTS_LITTLE_ENDIAN 499 + select SYS_SUPPORTS_HIGHMEM 483 500 select SYS_SUPPORTS_ZBOOT 484 501 help 485 502 This enables support for the Loongson-1 family of machines. ··· 1403 1386 have a similar programming interface with FPGA northbridge used in 1404 1387 Loongson2E. 1405 1388 1406 - config CPU_LOONGSON1B 1407 - bool "Loongson 1B" 1408 - depends on SYS_HAS_CPU_LOONGSON1B 1409 - select CPU_LOONGSON32 1389 + config CPU_LOONGSON32 1390 + bool "Loongson 32-bit CPU" 1391 + depends on SYS_HAS_CPU_LOONGSON32 1392 + select CPU_MIPS32 1393 + select CPU_MIPSR2 1394 + select CPU_HAS_PREFETCH 1395 + select CPU_HAS_LOAD_STORE_LR 1396 + select CPU_SUPPORTS_32BIT_KERNEL 1397 + select CPU_SUPPORTS_HIGHMEM 1398 + select CPU_SUPPORTS_CPUFREQ 1410 1399 select LEDS_GPIO_REGISTER 1411 1400 help 1412 - The Loongson 1B is a 32-bit SoC, which implements the MIPS32 1413 - Release 1 instruction set and part of the MIPS32 Release 2 1414 - instruction set. 1415 - 1416 - config CPU_LOONGSON1C 1417 - bool "Loongson 1C" 1418 - depends on SYS_HAS_CPU_LOONGSON1C 1419 - select CPU_LOONGSON32 1420 - select LEDS_GPIO_REGISTER 1421 - help 1422 - The Loongson 1C is a 32-bit SoC, which implements the MIPS32 1423 - Release 1 instruction set and part of the MIPS32 Release 2 1424 - instruction set. 1401 + The Loongson GS232 microarchitecture implements the MIPS32 Release 1 1402 + instruction set and part of the MIPS32 Release 2 instruction set. 1425 1403 1426 1404 config CPU_MIPS32_R1 1427 1405 bool "MIPS32 Release 1" ··· 1851 1839 select CPU_SUPPORTS_HUGEPAGES 1852 1840 select RTC_MC146818_LIB 1853 1841 1854 - config CPU_LOONGSON32 1855 - bool 1856 - select CPU_MIPS32 1857 - select CPU_MIPSR2 1858 - select CPU_HAS_PREFETCH 1859 - select CPU_SUPPORTS_32BIT_KERNEL 1860 - select CPU_SUPPORTS_HIGHMEM 1861 - select CPU_SUPPORTS_CPUFREQ 1862 - 1863 1842 config CPU_BMIPS32_3300 1864 1843 select SMP_UP if SMP 1865 1844 bool ··· 1888 1885 select CPU_SUPPORTS_CPUFREQ 1889 1886 select CPU_SUPPORTS_ADDRWINCFG if 64BIT 1890 1887 1891 - config SYS_HAS_CPU_LOONGSON1B 1892 - bool 1893 - 1894 - config SYS_HAS_CPU_LOONGSON1C 1888 + config SYS_HAS_CPU_LOONGSON32 1895 1889 bool 1896 1890 1897 1891 config SYS_HAS_CPU_MIPS32_R1 ··· 2999 2999 prompt "Kernel command line type" 3000 3000 depends on !CMDLINE_OVERRIDE 3001 3001 default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && \ 3002 - !MACH_LOONGSON64 && !MIPS_MALTA && \ 3003 - !CAVIUM_OCTEON_SOC 3002 + !MACH_LOONGSON64 && !MACH_LOONGSON32 && \ 3003 + !MIPS_MALTA && !CAVIUM_OCTEON_SOC 3004 3004 default MIPS_CMDLINE_FROM_BOOTLOADER 3005 3005 3006 3006 config MIPS_CMDLINE_FROM_DTB
+1 -2
arch/mips/include/asm/cpu-type.h
··· 24 24 case CPU_LOONGSON64: 25 25 #endif 26 26 27 - #if defined(CONFIG_SYS_HAS_CPU_LOONGSON1B) || \ 28 - defined(CONFIG_SYS_HAS_CPU_LOONGSON1C) 27 + #ifdef CONFIG_SYS_HAS_CPU_LOONGSON32 29 28 case CPU_LOONGSON32: 30 29 #endif 31 30
-107
arch/mips/include/asm/mach-loongson32/irq.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 4 - * 5 - * IRQ mappings for Loongson 1 6 - */ 7 - 8 - #ifndef __ASM_MACH_LOONGSON32_IRQ_H 9 - #define __ASM_MACH_LOONGSON32_IRQ_H 10 - 11 - /* 12 - * CPU core Interrupt Numbers 13 - */ 14 - #define MIPS_CPU_IRQ_BASE 0 15 - #define MIPS_CPU_IRQ(x) (MIPS_CPU_IRQ_BASE + (x)) 16 - 17 - #define SOFTINT0_IRQ MIPS_CPU_IRQ(0) 18 - #define SOFTINT1_IRQ MIPS_CPU_IRQ(1) 19 - #define INT0_IRQ MIPS_CPU_IRQ(2) 20 - #define INT1_IRQ MIPS_CPU_IRQ(3) 21 - #define INT2_IRQ MIPS_CPU_IRQ(4) 22 - #define INT3_IRQ MIPS_CPU_IRQ(5) 23 - #define INT4_IRQ MIPS_CPU_IRQ(6) 24 - #define TIMER_IRQ MIPS_CPU_IRQ(7) /* cpu timer */ 25 - 26 - #define MIPS_CPU_IRQS (MIPS_CPU_IRQ(7) + 1 - MIPS_CPU_IRQ_BASE) 27 - 28 - /* 29 - * INT0~3 Interrupt Numbers 30 - */ 31 - #define LS1X_IRQ_BASE MIPS_CPU_IRQS 32 - #define LS1X_IRQ(n, x) (LS1X_IRQ_BASE + (n << 5) + (x)) 33 - 34 - #define LS1X_UART0_IRQ LS1X_IRQ(0, 2) 35 - #if defined(CONFIG_LOONGSON1_LS1B) 36 - #define LS1X_UART1_IRQ LS1X_IRQ(0, 3) 37 - #define LS1X_UART2_IRQ LS1X_IRQ(0, 4) 38 - #define LS1X_UART3_IRQ LS1X_IRQ(0, 5) 39 - #elif defined(CONFIG_LOONGSON1_LS1C) 40 - #define LS1X_UART1_IRQ LS1X_IRQ(0, 4) 41 - #define LS1X_UART2_IRQ LS1X_IRQ(0, 5) 42 - #endif 43 - #define LS1X_CAN0_IRQ LS1X_IRQ(0, 6) 44 - #define LS1X_CAN1_IRQ LS1X_IRQ(0, 7) 45 - #define LS1X_SPI0_IRQ LS1X_IRQ(0, 8) 46 - #define LS1X_SPI1_IRQ LS1X_IRQ(0, 9) 47 - #define LS1X_AC97_IRQ LS1X_IRQ(0, 10) 48 - #define LS1X_DMA0_IRQ LS1X_IRQ(0, 13) 49 - #define LS1X_DMA1_IRQ LS1X_IRQ(0, 14) 50 - #define LS1X_DMA2_IRQ LS1X_IRQ(0, 15) 51 - #if defined(CONFIG_LOONGSON1_LS1C) 52 - #define LS1X_NAND_IRQ LS1X_IRQ(0, 16) 53 - #endif 54 - #define LS1X_PWM0_IRQ LS1X_IRQ(0, 17) 55 - #define LS1X_PWM1_IRQ LS1X_IRQ(0, 18) 56 - #define LS1X_PWM2_IRQ LS1X_IRQ(0, 19) 57 - #define LS1X_PWM3_IRQ LS1X_IRQ(0, 20) 58 - #define LS1X_RTC_INT0_IRQ LS1X_IRQ(0, 21) 59 - #define LS1X_RTC_INT1_IRQ LS1X_IRQ(0, 22) 60 - #define LS1X_RTC_INT2_IRQ LS1X_IRQ(0, 23) 61 - #if defined(CONFIG_LOONGSON1_LS1B) 62 - #define LS1X_TOY_INT0_IRQ LS1X_IRQ(0, 24) 63 - #define LS1X_TOY_INT1_IRQ LS1X_IRQ(0, 25) 64 - #define LS1X_TOY_INT2_IRQ LS1X_IRQ(0, 26) 65 - #define LS1X_RTC_TICK_IRQ LS1X_IRQ(0, 27) 66 - #define LS1X_TOY_TICK_IRQ LS1X_IRQ(0, 28) 67 - #define LS1X_UART4_IRQ LS1X_IRQ(0, 29) 68 - #define LS1X_UART5_IRQ LS1X_IRQ(0, 30) 69 - #elif defined(CONFIG_LOONGSON1_LS1C) 70 - #define LS1X_UART3_IRQ LS1X_IRQ(0, 29) 71 - #define LS1X_ADC_IRQ LS1X_IRQ(0, 30) 72 - #define LS1X_SDIO_IRQ LS1X_IRQ(0, 31) 73 - #endif 74 - 75 - #define LS1X_EHCI_IRQ LS1X_IRQ(1, 0) 76 - #define LS1X_OHCI_IRQ LS1X_IRQ(1, 1) 77 - #if defined(CONFIG_LOONGSON1_LS1B) 78 - #define LS1X_GMAC0_IRQ LS1X_IRQ(1, 2) 79 - #define LS1X_GMAC1_IRQ LS1X_IRQ(1, 3) 80 - #elif defined(CONFIG_LOONGSON1_LS1C) 81 - #define LS1X_OTG_IRQ LS1X_IRQ(1, 2) 82 - #define LS1X_GMAC0_IRQ LS1X_IRQ(1, 3) 83 - #define LS1X_CAM_IRQ LS1X_IRQ(1, 4) 84 - #define LS1X_UART4_IRQ LS1X_IRQ(1, 5) 85 - #define LS1X_UART5_IRQ LS1X_IRQ(1, 6) 86 - #define LS1X_UART6_IRQ LS1X_IRQ(1, 7) 87 - #define LS1X_UART7_IRQ LS1X_IRQ(1, 8) 88 - #define LS1X_UART8_IRQ LS1X_IRQ(1, 9) 89 - #define LS1X_UART9_IRQ LS1X_IRQ(1, 13) 90 - #define LS1X_UART10_IRQ LS1X_IRQ(1, 14) 91 - #define LS1X_UART11_IRQ LS1X_IRQ(1, 15) 92 - #define LS1X_I2C0_IRQ LS1X_IRQ(1, 17) 93 - #define LS1X_I2C1_IRQ LS1X_IRQ(1, 18) 94 - #define LS1X_I2C2_IRQ LS1X_IRQ(1, 19) 95 - #endif 96 - 97 - #if defined(CONFIG_LOONGSON1_LS1B) 98 - #define INTN 4 99 - #elif defined(CONFIG_LOONGSON1_LS1C) 100 - #define INTN 5 101 - #endif 102 - 103 - #define LS1X_IRQS (LS1X_IRQ(INTN, 31) + 1 - LS1X_IRQ_BASE) 104 - 105 - #define NR_IRQS (MIPS_CPU_IRQS + LS1X_IRQS) 106 - 107 - #endif /* __ASM_MACH_LOONGSON32_IRQ_H */
-50
arch/mips/include/asm/mach-loongson32/loongson1.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 4 - * 5 - * Register mappings for Loongson 1 6 - */ 7 - 8 - #ifndef __ASM_MACH_LOONGSON32_LOONGSON1_H 9 - #define __ASM_MACH_LOONGSON32_LOONGSON1_H 10 - 11 - #if defined(CONFIG_LOONGSON1_LS1B) 12 - #define DEFAULT_MEMSIZE 64 /* If no memsize provided */ 13 - #elif defined(CONFIG_LOONGSON1_LS1C) 14 - #define DEFAULT_MEMSIZE 32 15 - #endif 16 - 17 - /* Loongson 1 Register Bases */ 18 - #define LS1X_MUX_BASE 0x1fd00420 19 - #define LS1X_INTC_BASE 0x1fd01040 20 - #define LS1X_GPIO0_BASE 0x1fd010c0 21 - #define LS1X_GPIO1_BASE 0x1fd010c4 22 - #define LS1X_DMAC_BASE 0x1fd01160 23 - #define LS1X_CBUS_BASE 0x1fd011c0 24 - #define LS1X_EHCI_BASE 0x1fe00000 25 - #define LS1X_OHCI_BASE 0x1fe08000 26 - #define LS1X_GMAC0_BASE 0x1fe10000 27 - #define LS1X_GMAC1_BASE 0x1fe20000 28 - 29 - #define LS1X_UART0_BASE 0x1fe40000 30 - #define LS1X_UART1_BASE 0x1fe44000 31 - #define LS1X_UART2_BASE 0x1fe48000 32 - #define LS1X_UART3_BASE 0x1fe4c000 33 - #define LS1X_CAN0_BASE 0x1fe50000 34 - #define LS1X_CAN1_BASE 0x1fe54000 35 - #define LS1X_I2C0_BASE 0x1fe58000 36 - #define LS1X_I2C1_BASE 0x1fe68000 37 - #define LS1X_I2C2_BASE 0x1fe70000 38 - #define LS1X_PWM0_BASE 0x1fe5c000 39 - #define LS1X_PWM1_BASE 0x1fe5c010 40 - #define LS1X_PWM2_BASE 0x1fe5c020 41 - #define LS1X_PWM3_BASE 0x1fe5c030 42 - #define LS1X_WDT_BASE 0x1fe5c060 43 - #define LS1X_RTC_BASE 0x1fe64000 44 - #define LS1X_AC97_BASE 0x1fe74000 45 - #define LS1X_NAND_BASE 0x1fe78000 46 - #define LS1X_CLK_BASE 0x1fe78030 47 - 48 - #include <regs-mux.h> 49 - 50 - #endif /* __ASM_MACH_LOONGSON32_LOONGSON1_H */
-23
arch/mips/include/asm/mach-loongson32/platform.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #ifndef __ASM_MACH_LOONGSON32_PLATFORM_H 7 - #define __ASM_MACH_LOONGSON32_PLATFORM_H 8 - 9 - #include <linux/platform_device.h> 10 - 11 - extern struct platform_device ls1x_uart_pdev; 12 - extern struct platform_device ls1x_eth0_pdev; 13 - extern struct platform_device ls1x_eth1_pdev; 14 - extern struct platform_device ls1x_ehci_pdev; 15 - extern struct platform_device ls1x_gpio0_pdev; 16 - extern struct platform_device ls1x_gpio1_pdev; 17 - extern struct platform_device ls1x_rtc_pdev; 18 - extern struct platform_device ls1x_wdt_pdev; 19 - 20 - void __init ls1x_rtc_set_extclk(struct platform_device *pdev); 21 - void __init ls1x_serial_set_uartclk(struct platform_device *pdev); 22 - 23 - #endif /* __ASM_MACH_LOONGSON32_PLATFORM_H */
-124
arch/mips/include/asm/mach-loongson32/regs-mux.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Copyright (c) 2014 Zhang, Keguang <keguang.zhang@gmail.com> 4 - * 5 - * Loongson 1 MUX Register Definitions. 6 - */ 7 - 8 - #ifndef __ASM_MACH_LOONGSON32_REGS_MUX_H 9 - #define __ASM_MACH_LOONGSON32_REGS_MUX_H 10 - 11 - #define LS1X_MUX_REG(x) \ 12 - ((void __iomem *)KSEG1ADDR(LS1X_MUX_BASE + (x))) 13 - 14 - #define LS1X_MUX_CTRL0 LS1X_MUX_REG(0x0) 15 - #define LS1X_MUX_CTRL1 LS1X_MUX_REG(0x4) 16 - 17 - #if defined(CONFIG_LOONGSON1_LS1B) 18 - /* MUX CTRL0 Register Bits */ 19 - #define UART0_USE_PWM23 BIT(28) 20 - #define UART0_USE_PWM01 BIT(27) 21 - #define UART1_USE_LCD0_5_6_11 BIT(26) 22 - #define I2C2_USE_CAN1 BIT(25) 23 - #define I2C1_USE_CAN0 BIT(24) 24 - #define NAND3_USE_UART5 BIT(23) 25 - #define NAND3_USE_UART4 BIT(22) 26 - #define NAND3_USE_UART1_DAT BIT(21) 27 - #define NAND3_USE_UART1_CTS BIT(20) 28 - #define NAND3_USE_PWM23 BIT(19) 29 - #define NAND3_USE_PWM01 BIT(18) 30 - #define NAND2_USE_UART5 BIT(17) 31 - #define NAND2_USE_UART4 BIT(16) 32 - #define NAND2_USE_UART1_DAT BIT(15) 33 - #define NAND2_USE_UART1_CTS BIT(14) 34 - #define NAND2_USE_PWM23 BIT(13) 35 - #define NAND2_USE_PWM01 BIT(12) 36 - #define NAND1_USE_UART5 BIT(11) 37 - #define NAND1_USE_UART4 BIT(10) 38 - #define NAND1_USE_UART1_DAT BIT(9) 39 - #define NAND1_USE_UART1_CTS BIT(8) 40 - #define NAND1_USE_PWM23 BIT(7) 41 - #define NAND1_USE_PWM01 BIT(6) 42 - #define GMAC1_USE_UART1 BIT(4) 43 - #define GMAC1_USE_UART0 BIT(3) 44 - #define LCD_USE_UART0_DAT BIT(2) 45 - #define LCD_USE_UART15 BIT(1) 46 - #define LCD_USE_UART0 BIT(0) 47 - 48 - /* MUX CTRL1 Register Bits */ 49 - #define USB_RESET BIT(31) 50 - #define SPI1_CS_USE_PWM01 BIT(24) 51 - #define SPI1_USE_CAN BIT(23) 52 - #define DISABLE_DDR_CONFSPACE BIT(20) 53 - #define DDR32TO16EN BIT(16) 54 - #define GMAC1_SHUT BIT(13) 55 - #define GMAC0_SHUT BIT(12) 56 - #define USB_SHUT BIT(11) 57 - #define UART1_3_USE_CAN1 BIT(5) 58 - #define UART1_2_USE_CAN0 BIT(4) 59 - #define GMAC1_USE_TXCLK BIT(3) 60 - #define GMAC0_USE_TXCLK BIT(2) 61 - #define GMAC1_USE_PWM23 BIT(1) 62 - #define GMAC0_USE_PWM01 BIT(0) 63 - 64 - #elif defined(CONFIG_LOONGSON1_LS1C) 65 - 66 - /* SHUT_CTRL Register Bits */ 67 - #define UART_SPLIT GENMASK(31, 30) 68 - #define OUTPUT_CLK GENMASK(29, 26) 69 - #define ADC_SHUT BIT(25) 70 - #define SDIO_SHUT BIT(24) 71 - #define DMA2_SHUT BIT(23) 72 - #define DMA1_SHUT BIT(22) 73 - #define DMA0_SHUT BIT(21) 74 - #define SPI1_SHUT BIT(20) 75 - #define SPI0_SHUT BIT(19) 76 - #define I2C2_SHUT BIT(18) 77 - #define I2C1_SHUT BIT(17) 78 - #define I2C0_SHUT BIT(16) 79 - #define AC97_SHUT BIT(15) 80 - #define I2S_SHUT BIT(14) 81 - #define UART3_SHUT BIT(13) 82 - #define UART2_SHUT BIT(12) 83 - #define UART1_SHUT BIT(11) 84 - #define UART0_SHUT BIT(10) 85 - #define CAN1_SHUT BIT(9) 86 - #define CAN0_SHUT BIT(8) 87 - #define ECC_SHUT BIT(7) 88 - #define GMAC_SHUT BIT(6) 89 - #define USBHOST_SHUT BIT(5) 90 - #define USBOTG_SHUT BIT(4) 91 - #define SDRAM_SHUT BIT(3) 92 - #define SRAM_SHUT BIT(2) 93 - #define CAM_SHUT BIT(1) 94 - #define LCD_SHUT BIT(0) 95 - 96 - #define UART_SPLIT_SHIFT 30 97 - #define OUTPUT_CLK_SHIFT 26 98 - 99 - /* MISC_CTRL Register Bits */ 100 - #define USBHOST_RSTN BIT(31) 101 - #define PHY_INTF_SELI GENMASK(30, 28) 102 - #define AC97_EN BIT(25) 103 - #define SDIO_DMA_EN GENMASK(24, 23) 104 - #define ADC_DMA_EN BIT(22) 105 - #define SDIO_USE_SPI1 BIT(17) 106 - #define SDIO_USE_SPI0 BIT(16) 107 - #define SRAM_CTRL GENMASK(15, 0) 108 - 109 - #define PHY_INTF_SELI_SHIFT 28 110 - #define SDIO_DMA_EN_SHIFT 23 111 - #define SRAM_CTRL_SHIFT 0 112 - 113 - #define LS1X_CBUS_REG(n, x) \ 114 - ((void __iomem *)KSEG1ADDR(LS1X_CBUS_BASE + (n * 0x04) + (x))) 115 - 116 - #define LS1X_CBUS_FIRST(n) LS1X_CBUS_REG(n, 0x00) 117 - #define LS1X_CBUS_SECOND(n) LS1X_CBUS_REG(n, 0x10) 118 - #define LS1X_CBUS_THIRD(n) LS1X_CBUS_REG(n, 0x20) 119 - #define LS1X_CBUS_FOURTHT(n) LS1X_CBUS_REG(n, 0x30) 120 - #define LS1X_CBUS_FIFTHT(n) LS1X_CBUS_REG(n, 0x40) 121 - 122 - #endif 123 - 124 - #endif /* __ASM_MACH_LOONGSON32_REGS_MUX_H */
-37
arch/mips/loongson32/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - if MACH_LOONGSON32 3 - 4 - choice 5 - prompt "Machine Type" 6 - 7 - config LOONGSON1_LS1B 8 - bool "Loongson LS1B board" 9 - select CEVT_R4K if !MIPS_EXTERNAL_TIMER 10 - select CSRC_R4K if !MIPS_EXTERNAL_TIMER 11 - select SYS_HAS_CPU_LOONGSON1B 12 - select DMA_NONCOHERENT 13 - select BOOT_ELF32 14 - select IRQ_MIPS_CPU 15 - select SYS_SUPPORTS_32BIT_KERNEL 16 - select SYS_SUPPORTS_LITTLE_ENDIAN 17 - select SYS_SUPPORTS_HIGHMEM 18 - select SYS_HAS_EARLY_PRINTK 19 - select USE_GENERIC_EARLY_PRINTK_8250 20 - select COMMON_CLK 21 - 22 - config LOONGSON1_LS1C 23 - bool "Loongson LS1C board" 24 - select CEVT_R4K if !MIPS_EXTERNAL_TIMER 25 - select CSRC_R4K if !MIPS_EXTERNAL_TIMER 26 - select SYS_HAS_CPU_LOONGSON1C 27 - select DMA_NONCOHERENT 28 - select BOOT_ELF32 29 - select IRQ_MIPS_CPU 30 - select SYS_SUPPORTS_32BIT_KERNEL 31 - select SYS_SUPPORTS_LITTLE_ENDIAN 32 - select SYS_SUPPORTS_HIGHMEM 33 - select SYS_HAS_EARLY_PRINTK 34 - select USE_GENERIC_EARLY_PRINTK_8250 35 - select COMMON_CLK 36 - endchoice 37 - 38 - endif # MACH_LOONGSON32 39 2 40 3 config BUILTIN_DTB_NAME 41 4 string "Source file for built-in DTB"
-17
arch/mips/loongson32/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 - # 3 - # Common code for all Loongson 1 based systems 4 - # 5 - 6 - obj-$(CONFIG_MACH_LOONGSON32) += common/ 7 - 8 - # 9 - # Loongson LS1B board 10 - # 11 - 12 - obj-$(CONFIG_LOONGSON1_LS1B) += ls1b/ 13 - 14 - # 15 - # Loongson LS1C board 16 - # 17 - 18 - obj-$(CONFIG_LOONGSON1_LS1C) += ls1c/
-1
arch/mips/loongson32/Platform
··· 1 1 cflags-$(CONFIG_CPU_LOONGSON32) += -march=mips32r2 -Wa,--trap 2 - cflags-$(CONFIG_MACH_LOONGSON32) += -I$(srctree)/arch/mips/include/asm/mach-loongson32 3 2 load-$(CONFIG_CPU_LOONGSON32) += 0xffffffff80200000
-6
arch/mips/loongson32/common/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0-only 2 - # 3 - # Makefile for common code of loongson1 based machines. 4 - # 5 - 6 - obj-y += time.o irq.o platform.o prom.o setup.o
-191
arch/mips/loongson32/common/irq.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/interrupt.h> 7 - #include <linux/irq.h> 8 - #include <asm/irq_cpu.h> 9 - 10 - #include <loongson1.h> 11 - #include <irq.h> 12 - 13 - #define LS1X_INTC_REG(n, x) \ 14 - ((void __iomem *)KSEG1ADDR(LS1X_INTC_BASE + (n * 0x18) + (x))) 15 - 16 - #define LS1X_INTC_INTISR(n) LS1X_INTC_REG(n, 0x0) 17 - #define LS1X_INTC_INTIEN(n) LS1X_INTC_REG(n, 0x4) 18 - #define LS1X_INTC_INTSET(n) LS1X_INTC_REG(n, 0x8) 19 - #define LS1X_INTC_INTCLR(n) LS1X_INTC_REG(n, 0xc) 20 - #define LS1X_INTC_INTPOL(n) LS1X_INTC_REG(n, 0x10) 21 - #define LS1X_INTC_INTEDGE(n) LS1X_INTC_REG(n, 0x14) 22 - 23 - static void ls1x_irq_ack(struct irq_data *d) 24 - { 25 - unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f; 26 - unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5; 27 - 28 - __raw_writel(__raw_readl(LS1X_INTC_INTCLR(n)) 29 - | (1 << bit), LS1X_INTC_INTCLR(n)); 30 - } 31 - 32 - static void ls1x_irq_mask(struct irq_data *d) 33 - { 34 - unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f; 35 - unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5; 36 - 37 - __raw_writel(__raw_readl(LS1X_INTC_INTIEN(n)) 38 - & ~(1 << bit), LS1X_INTC_INTIEN(n)); 39 - } 40 - 41 - static void ls1x_irq_mask_ack(struct irq_data *d) 42 - { 43 - unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f; 44 - unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5; 45 - 46 - __raw_writel(__raw_readl(LS1X_INTC_INTIEN(n)) 47 - & ~(1 << bit), LS1X_INTC_INTIEN(n)); 48 - __raw_writel(__raw_readl(LS1X_INTC_INTCLR(n)) 49 - | (1 << bit), LS1X_INTC_INTCLR(n)); 50 - } 51 - 52 - static void ls1x_irq_unmask(struct irq_data *d) 53 - { 54 - unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f; 55 - unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5; 56 - 57 - __raw_writel(__raw_readl(LS1X_INTC_INTIEN(n)) 58 - | (1 << bit), LS1X_INTC_INTIEN(n)); 59 - } 60 - 61 - static int ls1x_irq_settype(struct irq_data *d, unsigned int type) 62 - { 63 - unsigned int bit = (d->irq - LS1X_IRQ_BASE) & 0x1f; 64 - unsigned int n = (d->irq - LS1X_IRQ_BASE) >> 5; 65 - 66 - switch (type) { 67 - case IRQ_TYPE_LEVEL_HIGH: 68 - __raw_writel(__raw_readl(LS1X_INTC_INTPOL(n)) 69 - | (1 << bit), LS1X_INTC_INTPOL(n)); 70 - __raw_writel(__raw_readl(LS1X_INTC_INTEDGE(n)) 71 - & ~(1 << bit), LS1X_INTC_INTEDGE(n)); 72 - break; 73 - case IRQ_TYPE_LEVEL_LOW: 74 - __raw_writel(__raw_readl(LS1X_INTC_INTPOL(n)) 75 - & ~(1 << bit), LS1X_INTC_INTPOL(n)); 76 - __raw_writel(__raw_readl(LS1X_INTC_INTEDGE(n)) 77 - & ~(1 << bit), LS1X_INTC_INTEDGE(n)); 78 - break; 79 - case IRQ_TYPE_EDGE_RISING: 80 - __raw_writel(__raw_readl(LS1X_INTC_INTPOL(n)) 81 - | (1 << bit), LS1X_INTC_INTPOL(n)); 82 - __raw_writel(__raw_readl(LS1X_INTC_INTEDGE(n)) 83 - | (1 << bit), LS1X_INTC_INTEDGE(n)); 84 - break; 85 - case IRQ_TYPE_EDGE_FALLING: 86 - __raw_writel(__raw_readl(LS1X_INTC_INTPOL(n)) 87 - & ~(1 << bit), LS1X_INTC_INTPOL(n)); 88 - __raw_writel(__raw_readl(LS1X_INTC_INTEDGE(n)) 89 - | (1 << bit), LS1X_INTC_INTEDGE(n)); 90 - break; 91 - case IRQ_TYPE_EDGE_BOTH: 92 - __raw_writel(__raw_readl(LS1X_INTC_INTPOL(n)) 93 - & ~(1 << bit), LS1X_INTC_INTPOL(n)); 94 - __raw_writel(__raw_readl(LS1X_INTC_INTEDGE(n)) 95 - | (1 << bit), LS1X_INTC_INTEDGE(n)); 96 - break; 97 - case IRQ_TYPE_NONE: 98 - break; 99 - default: 100 - return -EINVAL; 101 - } 102 - 103 - return 0; 104 - } 105 - 106 - static struct irq_chip ls1x_irq_chip = { 107 - .name = "LS1X-INTC", 108 - .irq_ack = ls1x_irq_ack, 109 - .irq_mask = ls1x_irq_mask, 110 - .irq_mask_ack = ls1x_irq_mask_ack, 111 - .irq_unmask = ls1x_irq_unmask, 112 - .irq_set_type = ls1x_irq_settype, 113 - }; 114 - 115 - static void ls1x_irq_dispatch(int n) 116 - { 117 - u32 int_status, irq; 118 - 119 - /* Get pending sources, masked by current enables */ 120 - int_status = __raw_readl(LS1X_INTC_INTISR(n)) & 121 - __raw_readl(LS1X_INTC_INTIEN(n)); 122 - 123 - if (int_status) { 124 - irq = LS1X_IRQ(n, __ffs(int_status)); 125 - do_IRQ(irq); 126 - } 127 - } 128 - 129 - asmlinkage void plat_irq_dispatch(void) 130 - { 131 - unsigned int pending; 132 - 133 - pending = read_c0_cause() & read_c0_status() & ST0_IM; 134 - 135 - if (pending & CAUSEF_IP7) 136 - do_IRQ(TIMER_IRQ); 137 - else if (pending & CAUSEF_IP2) 138 - ls1x_irq_dispatch(0); /* INT0 */ 139 - else if (pending & CAUSEF_IP3) 140 - ls1x_irq_dispatch(1); /* INT1 */ 141 - else if (pending & CAUSEF_IP4) 142 - ls1x_irq_dispatch(2); /* INT2 */ 143 - else if (pending & CAUSEF_IP5) 144 - ls1x_irq_dispatch(3); /* INT3 */ 145 - else if (pending & CAUSEF_IP6) 146 - ls1x_irq_dispatch(4); /* INT4 */ 147 - else 148 - spurious_interrupt(); 149 - 150 - } 151 - 152 - static void __init ls1x_irq_init(int base) 153 - { 154 - int n; 155 - 156 - /* Disable interrupts and clear pending, 157 - * setup all IRQs as high level triggered 158 - */ 159 - for (n = 0; n < INTN; n++) { 160 - __raw_writel(0x0, LS1X_INTC_INTIEN(n)); 161 - __raw_writel(0xffffffff, LS1X_INTC_INTCLR(n)); 162 - __raw_writel(0xffffffff, LS1X_INTC_INTPOL(n)); 163 - /* set DMA0, DMA1 and DMA2 to edge trigger */ 164 - __raw_writel(n ? 0x0 : 0xe000, LS1X_INTC_INTEDGE(n)); 165 - } 166 - 167 - 168 - for (n = base; n < NR_IRQS; n++) { 169 - irq_set_chip_and_handler(n, &ls1x_irq_chip, 170 - handle_level_irq); 171 - } 172 - 173 - if (request_irq(INT0_IRQ, no_action, IRQF_NO_THREAD, "cascade", NULL)) 174 - pr_err("Failed to request irq %d (cascade)\n", INT0_IRQ); 175 - if (request_irq(INT1_IRQ, no_action, IRQF_NO_THREAD, "cascade", NULL)) 176 - pr_err("Failed to request irq %d (cascade)\n", INT1_IRQ); 177 - if (request_irq(INT2_IRQ, no_action, IRQF_NO_THREAD, "cascade", NULL)) 178 - pr_err("Failed to request irq %d (cascade)\n", INT2_IRQ); 179 - if (request_irq(INT3_IRQ, no_action, IRQF_NO_THREAD, "cascade", NULL)) 180 - pr_err("Failed to request irq %d (cascade)\n", INT3_IRQ); 181 - #if defined(CONFIG_LOONGSON1_LS1C) 182 - if (request_irq(INT4_IRQ, no_action, IRQF_NO_THREAD, "cascade", NULL)) 183 - pr_err("Failed to request irq %d (cascade)\n", INT4_IRQ); 184 - #endif 185 - } 186 - 187 - void __init arch_init_irq(void) 188 - { 189 - mips_cpu_irq_init(); 190 - ls1x_irq_init(LS1X_IRQ_BASE); 191 - }
-285
arch/mips/loongson32/common/platform.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2011-2016 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/clk.h> 7 - #include <linux/dma-mapping.h> 8 - #include <linux/err.h> 9 - #include <linux/mtd/partitions.h> 10 - #include <linux/sizes.h> 11 - #include <linux/phy.h> 12 - #include <linux/serial_8250.h> 13 - #include <linux/stmmac.h> 14 - #include <linux/usb/ehci_pdriver.h> 15 - 16 - #include <platform.h> 17 - #include <loongson1.h> 18 - 19 - /* 8250/16550 compatible UART */ 20 - #define LS1X_UART(_id) \ 21 - { \ 22 - .mapbase = LS1X_UART ## _id ## _BASE, \ 23 - .irq = LS1X_UART ## _id ## _IRQ, \ 24 - .iotype = UPIO_MEM, \ 25 - .flags = UPF_IOREMAP | UPF_FIXED_TYPE, \ 26 - .type = PORT_16550A, \ 27 - } 28 - 29 - static struct plat_serial8250_port ls1x_serial8250_pdata[] = { 30 - LS1X_UART(0), 31 - LS1X_UART(1), 32 - LS1X_UART(2), 33 - LS1X_UART(3), 34 - {}, 35 - }; 36 - 37 - struct platform_device ls1x_uart_pdev = { 38 - .name = "serial8250", 39 - .id = PLAT8250_DEV_PLATFORM, 40 - .dev = { 41 - .platform_data = ls1x_serial8250_pdata, 42 - }, 43 - }; 44 - 45 - void __init ls1x_serial_set_uartclk(struct platform_device *pdev) 46 - { 47 - struct clk *clk; 48 - struct plat_serial8250_port *p; 49 - 50 - clk = clk_get(&pdev->dev, pdev->name); 51 - if (IS_ERR(clk)) { 52 - pr_err("unable to get %s clock, err=%ld", 53 - pdev->name, PTR_ERR(clk)); 54 - return; 55 - } 56 - clk_prepare_enable(clk); 57 - 58 - for (p = pdev->dev.platform_data; p->flags != 0; ++p) 59 - p->uartclk = clk_get_rate(clk); 60 - } 61 - 62 - /* Synopsys Ethernet GMAC */ 63 - static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = { 64 - .phy_mask = 0, 65 - }; 66 - 67 - static struct stmmac_dma_cfg ls1x_eth_dma_cfg = { 68 - .pbl = 1, 69 - }; 70 - 71 - int ls1x_eth_mux_init(struct platform_device *pdev, void *priv) 72 - { 73 - struct plat_stmmacenet_data *plat_dat = NULL; 74 - u32 val; 75 - 76 - val = __raw_readl(LS1X_MUX_CTRL1); 77 - 78 - #if defined(CONFIG_LOONGSON1_LS1B) 79 - plat_dat = dev_get_platdata(&pdev->dev); 80 - if (plat_dat->bus_id) { 81 - __raw_writel(__raw_readl(LS1X_MUX_CTRL0) | GMAC1_USE_UART1 | 82 - GMAC1_USE_UART0, LS1X_MUX_CTRL0); 83 - switch (plat_dat->phy_interface) { 84 - case PHY_INTERFACE_MODE_RGMII: 85 - val &= ~(GMAC1_USE_TXCLK | GMAC1_USE_PWM23); 86 - break; 87 - case PHY_INTERFACE_MODE_MII: 88 - val |= (GMAC1_USE_TXCLK | GMAC1_USE_PWM23); 89 - break; 90 - default: 91 - pr_err("unsupported mii mode %d\n", 92 - plat_dat->phy_interface); 93 - return -ENOTSUPP; 94 - } 95 - val &= ~GMAC1_SHUT; 96 - } else { 97 - switch (plat_dat->phy_interface) { 98 - case PHY_INTERFACE_MODE_RGMII: 99 - val &= ~(GMAC0_USE_TXCLK | GMAC0_USE_PWM01); 100 - break; 101 - case PHY_INTERFACE_MODE_MII: 102 - val |= (GMAC0_USE_TXCLK | GMAC0_USE_PWM01); 103 - break; 104 - default: 105 - pr_err("unsupported mii mode %d\n", 106 - plat_dat->phy_interface); 107 - return -ENOTSUPP; 108 - } 109 - val &= ~GMAC0_SHUT; 110 - } 111 - __raw_writel(val, LS1X_MUX_CTRL1); 112 - #elif defined(CONFIG_LOONGSON1_LS1C) 113 - plat_dat = dev_get_platdata(&pdev->dev); 114 - 115 - val &= ~PHY_INTF_SELI; 116 - if (plat_dat->phy_interface == PHY_INTERFACE_MODE_RMII) 117 - val |= 0x4 << PHY_INTF_SELI_SHIFT; 118 - __raw_writel(val, LS1X_MUX_CTRL1); 119 - 120 - val = __raw_readl(LS1X_MUX_CTRL0); 121 - __raw_writel(val & (~GMAC_SHUT), LS1X_MUX_CTRL0); 122 - #endif 123 - 124 - return 0; 125 - } 126 - 127 - static struct plat_stmmacenet_data ls1x_eth0_pdata = { 128 - .bus_id = 0, 129 - .phy_addr = -1, 130 - #if defined(CONFIG_LOONGSON1_LS1B) 131 - .phy_interface = PHY_INTERFACE_MODE_MII, 132 - #elif defined(CONFIG_LOONGSON1_LS1C) 133 - .phy_interface = PHY_INTERFACE_MODE_RMII, 134 - #endif 135 - .mdio_bus_data = &ls1x_mdio_bus_data, 136 - .dma_cfg = &ls1x_eth_dma_cfg, 137 - .has_gmac = 1, 138 - .tx_coe = 1, 139 - .rx_queues_to_use = 1, 140 - .tx_queues_to_use = 1, 141 - .init = ls1x_eth_mux_init, 142 - }; 143 - 144 - static struct resource ls1x_eth0_resources[] = { 145 - [0] = { 146 - .start = LS1X_GMAC0_BASE, 147 - .end = LS1X_GMAC0_BASE + SZ_64K - 1, 148 - .flags = IORESOURCE_MEM, 149 - }, 150 - [1] = { 151 - .name = "macirq", 152 - .start = LS1X_GMAC0_IRQ, 153 - .flags = IORESOURCE_IRQ, 154 - }, 155 - }; 156 - 157 - struct platform_device ls1x_eth0_pdev = { 158 - .name = "stmmaceth", 159 - .id = 0, 160 - .num_resources = ARRAY_SIZE(ls1x_eth0_resources), 161 - .resource = ls1x_eth0_resources, 162 - .dev = { 163 - .platform_data = &ls1x_eth0_pdata, 164 - }, 165 - }; 166 - 167 - #ifdef CONFIG_LOONGSON1_LS1B 168 - static struct plat_stmmacenet_data ls1x_eth1_pdata = { 169 - .bus_id = 1, 170 - .phy_addr = -1, 171 - .phy_interface = PHY_INTERFACE_MODE_MII, 172 - .mdio_bus_data = &ls1x_mdio_bus_data, 173 - .dma_cfg = &ls1x_eth_dma_cfg, 174 - .has_gmac = 1, 175 - .tx_coe = 1, 176 - .rx_queues_to_use = 1, 177 - .tx_queues_to_use = 1, 178 - .init = ls1x_eth_mux_init, 179 - }; 180 - 181 - static struct resource ls1x_eth1_resources[] = { 182 - [0] = { 183 - .start = LS1X_GMAC1_BASE, 184 - .end = LS1X_GMAC1_BASE + SZ_64K - 1, 185 - .flags = IORESOURCE_MEM, 186 - }, 187 - [1] = { 188 - .name = "macirq", 189 - .start = LS1X_GMAC1_IRQ, 190 - .flags = IORESOURCE_IRQ, 191 - }, 192 - }; 193 - 194 - struct platform_device ls1x_eth1_pdev = { 195 - .name = "stmmaceth", 196 - .id = 1, 197 - .num_resources = ARRAY_SIZE(ls1x_eth1_resources), 198 - .resource = ls1x_eth1_resources, 199 - .dev = { 200 - .platform_data = &ls1x_eth1_pdata, 201 - }, 202 - }; 203 - #endif /* CONFIG_LOONGSON1_LS1B */ 204 - 205 - /* GPIO */ 206 - static struct resource ls1x_gpio0_resources[] = { 207 - [0] = { 208 - .start = LS1X_GPIO0_BASE, 209 - .end = LS1X_GPIO0_BASE + SZ_4 - 1, 210 - .flags = IORESOURCE_MEM, 211 - }, 212 - }; 213 - 214 - struct platform_device ls1x_gpio0_pdev = { 215 - .name = "ls1x-gpio", 216 - .id = 0, 217 - .num_resources = ARRAY_SIZE(ls1x_gpio0_resources), 218 - .resource = ls1x_gpio0_resources, 219 - }; 220 - 221 - static struct resource ls1x_gpio1_resources[] = { 222 - [0] = { 223 - .start = LS1X_GPIO1_BASE, 224 - .end = LS1X_GPIO1_BASE + SZ_4 - 1, 225 - .flags = IORESOURCE_MEM, 226 - }, 227 - }; 228 - 229 - struct platform_device ls1x_gpio1_pdev = { 230 - .name = "ls1x-gpio", 231 - .id = 1, 232 - .num_resources = ARRAY_SIZE(ls1x_gpio1_resources), 233 - .resource = ls1x_gpio1_resources, 234 - }; 235 - 236 - /* USB EHCI */ 237 - static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32); 238 - 239 - static struct resource ls1x_ehci_resources[] = { 240 - [0] = { 241 - .start = LS1X_EHCI_BASE, 242 - .end = LS1X_EHCI_BASE + SZ_32K - 1, 243 - .flags = IORESOURCE_MEM, 244 - }, 245 - [1] = { 246 - .start = LS1X_EHCI_IRQ, 247 - .flags = IORESOURCE_IRQ, 248 - }, 249 - }; 250 - 251 - static struct usb_ehci_pdata ls1x_ehci_pdata = { 252 - }; 253 - 254 - struct platform_device ls1x_ehci_pdev = { 255 - .name = "ehci-platform", 256 - .id = -1, 257 - .num_resources = ARRAY_SIZE(ls1x_ehci_resources), 258 - .resource = ls1x_ehci_resources, 259 - .dev = { 260 - .dma_mask = &ls1x_ehci_dmamask, 261 - .platform_data = &ls1x_ehci_pdata, 262 - }, 263 - }; 264 - 265 - /* Real Time Clock */ 266 - struct platform_device ls1x_rtc_pdev = { 267 - .name = "ls1x-rtc", 268 - .id = -1, 269 - }; 270 - 271 - /* Watchdog */ 272 - static struct resource ls1x_wdt_resources[] = { 273 - { 274 - .start = LS1X_WDT_BASE, 275 - .end = LS1X_WDT_BASE + SZ_16 - 1, 276 - .flags = IORESOURCE_MEM, 277 - }, 278 - }; 279 - 280 - struct platform_device ls1x_wdt_pdev = { 281 - .name = "ls1x-wdt", 282 - .id = -1, 283 - .num_resources = ARRAY_SIZE(ls1x_wdt_resources), 284 - .resource = ls1x_wdt_resources, 285 - };
-42
arch/mips/loongson32/common/prom.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 4 - * 5 - * Modified from arch/mips/pnx833x/common/prom.c. 6 - */ 7 - 8 - #include <linux/io.h> 9 - #include <linux/init.h> 10 - #include <linux/memblock.h> 11 - #include <linux/serial_reg.h> 12 - #include <asm/fw/fw.h> 13 - 14 - #include <loongson1.h> 15 - 16 - unsigned long memsize; 17 - 18 - void __init prom_init(void) 19 - { 20 - void __iomem *uart_base; 21 - 22 - fw_init_cmdline(); 23 - 24 - memsize = fw_getenvl("memsize"); 25 - if(!memsize) 26 - memsize = DEFAULT_MEMSIZE; 27 - 28 - if (strstr(arcs_cmdline, "console=ttyS3")) 29 - uart_base = ioremap(LS1X_UART3_BASE, 0x0f); 30 - else if (strstr(arcs_cmdline, "console=ttyS2")) 31 - uart_base = ioremap(LS1X_UART2_BASE, 0x0f); 32 - else if (strstr(arcs_cmdline, "console=ttyS1")) 33 - uart_base = ioremap(LS1X_UART1_BASE, 0x0f); 34 - else 35 - uart_base = ioremap(LS1X_UART0_BASE, 0x0f); 36 - setup_8250_early_printk_port((unsigned long)uart_base, 0, 0); 37 - } 38 - 39 - void __init plat_mem_setup(void) 40 - { 41 - memblock_add(0x0, (memsize << 20)); 42 - }
-26
arch/mips/loongson32/common/setup.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/io.h> 7 - #include <linux/init.h> 8 - #include <linux/smp.h> 9 - #include <asm/cpu-info.h> 10 - #include <asm/bootinfo.h> 11 - 12 - const char *get_system_type(void) 13 - { 14 - unsigned int processor_id = (&current_cpu_data)->processor_id; 15 - 16 - switch (processor_id & PRID_REV_MASK) { 17 - case PRID_REV_LOONGSON1B: 18 - #if defined(CONFIG_LOONGSON1_LS1B) 19 - return "LOONGSON LS1B"; 20 - #elif defined(CONFIG_LOONGSON1_LS1C) 21 - return "LOONGSON LS1C"; 22 - #endif 23 - default: 24 - return "LOONGSON (unknown)"; 25 - } 26 - }
-23
arch/mips/loongson32/common/time.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2014 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/clk.h> 7 - #include <linux/of_clk.h> 8 - #include <asm/time.h> 9 - 10 - void __init plat_time_init(void) 11 - { 12 - struct clk *clk = NULL; 13 - 14 - /* initialize LS1X clocks */ 15 - of_clk_init(NULL); 16 - 17 - /* setup mips r4k timer */ 18 - clk = clk_get(NULL, "cpu_clk"); 19 - if (IS_ERR(clk)) 20 - panic("unable to get cpu clock, err=%ld", PTR_ERR(clk)); 21 - 22 - mips_hpt_frequency = clk_get_rate(clk) / 2; 23 - }
-6
arch/mips/loongson32/ls1b/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0-only 2 - # 3 - # Makefile for loongson1B based machines. 4 - # 5 - 6 - obj-y += board.o
-55
arch/mips/loongson32/ls1b/board.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2011-2016 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/leds.h> 7 - #include <linux/mtd/partitions.h> 8 - #include <linux/sizes.h> 9 - 10 - #include <loongson1.h> 11 - #include <platform.h> 12 - 13 - static const struct gpio_led ls1x_gpio_leds[] __initconst = { 14 - { 15 - .name = "LED9", 16 - .default_trigger = "heartbeat", 17 - .gpio = 38, 18 - .active_low = 1, 19 - .default_state = LEDS_GPIO_DEFSTATE_OFF, 20 - }, { 21 - .name = "LED6", 22 - .default_trigger = "nand-disk", 23 - .gpio = 39, 24 - .active_low = 1, 25 - .default_state = LEDS_GPIO_DEFSTATE_OFF, 26 - }, 27 - }; 28 - 29 - static const struct gpio_led_platform_data ls1x_led_pdata __initconst = { 30 - .num_leds = ARRAY_SIZE(ls1x_gpio_leds), 31 - .leds = ls1x_gpio_leds, 32 - }; 33 - 34 - static struct platform_device *ls1b_platform_devices[] __initdata = { 35 - &ls1x_uart_pdev, 36 - &ls1x_eth0_pdev, 37 - &ls1x_eth1_pdev, 38 - &ls1x_ehci_pdev, 39 - &ls1x_gpio0_pdev, 40 - &ls1x_gpio1_pdev, 41 - &ls1x_rtc_pdev, 42 - &ls1x_wdt_pdev, 43 - }; 44 - 45 - static int __init ls1b_platform_init(void) 46 - { 47 - ls1x_serial_set_uartclk(&ls1x_uart_pdev); 48 - 49 - gpio_led_register_device(-1, &ls1x_led_pdata); 50 - 51 - return platform_add_devices(ls1b_platform_devices, 52 - ARRAY_SIZE(ls1b_platform_devices)); 53 - } 54 - 55 - arch_initcall(ls1b_platform_init);
-6
arch/mips/loongson32/ls1c/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0-only 2 - # 3 - # Makefile for loongson1C based machines. 4 - # 5 - 6 - obj-y += board.o
-23
arch/mips/loongson32/ls1c/board.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2016 Yang Ling <gnaygnil@gmail.com> 4 - */ 5 - 6 - #include <platform.h> 7 - 8 - static struct platform_device *ls1c_platform_devices[] __initdata = { 9 - &ls1x_uart_pdev, 10 - &ls1x_eth0_pdev, 11 - &ls1x_rtc_pdev, 12 - &ls1x_wdt_pdev, 13 - }; 14 - 15 - static int __init ls1c_platform_init(void) 16 - { 17 - ls1x_serial_set_uartclk(&ls1x_uart_pdev); 18 - 19 - return platform_add_devices(ls1c_platform_devices, 20 - ARRAY_SIZE(ls1c_platform_devices)); 21 - } 22 - 23 - arch_initcall(ls1c_platform_init);