Skip to contentSkip to conversation

MIPS: Loongson 1C: Add board support

PATCH In review Yang Ling 1 participant 1 message May 12, 2016

Subsystems (2)
lore
Share & tools
lore

Yang Ling

author
#0 lore raw

PATCH 3/4 MIPS: Loongson 1C: Add board support

Adds basic platform devices for Loongson 1C, including serial port, and ethernet.

---
 arch/mips/Kconfig                                 | 11 ++++
 arch/mips/include/asm/mach-loongson32/irq.h       | 43 ++++++++++++++-
 arch/mips/include/asm/mach-loongson32/loongson1.h | 22 ++++++++
 arch/mips/include/asm/mach-loongson32/regs-gpio.h | 26 +++++++++
 arch/mips/include/asm/mach-loongson32/regs-mux.h  | 65 +++++++++++++++++++++++
 arch/mips/loongson32/Kconfig                      | 15 ++++++
 arch/mips/loongson32/Makefile                     |  6 +++
 arch/mips/loongson32/Platform                     |  1 +
 arch/mips/loongson32/common/irq.c                 | 57 ++++++++++++++++++--
 arch/mips/loongson32/common/platform.c            | 24 ++++++++-
 arch/mips/loongson32/common/setup.c               |  6 +++
 arch/mips/loongson32/ls1c/Makefile                |  5 ++
 arch/mips/loongson32/ls1c/board.c                 | 30 +++++++++++
 13 files changed, 306 insertions(+), 5 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-loongson32/regs-gpio.h
 create mode 100644 arch/mips/loongson32/ls1c/Makefile
 create mode 100644 arch/mips/loongson32/ls1c/board.c
arch/mips/Kconfig +11 -0
index 51a03c3..443c826 100644
@@ -1382,6 +1382,14 @@ config CPU_LOONGSON1B
 	  The Loongson 1B is a 32-bit SoC, which implements the MIPS32
 	  release 2 instruction set.
 
+config CPU_LOONGSON1C
+	bool "Loongson 1C"
+	depends on SYS_HAS_CPU_LOONGSON1C
+	select CPU_LOONGSON1
+	help
+	  The Loongson 1C is a 32-bit SoC, which implements the MIPS32
+	  release 2 instruction set.
+
 config CPU_MIPS32_R1
 	bool "MIPS32 Release 1"
 	depends on SYS_HAS_CPU_MIPS32_R1
@@ -1825,6 +1833,9 @@ config SYS_HAS_CPU_LOONGSON2F
 config SYS_HAS_CPU_LOONGSON1B
 	bool
 
+config SYS_HAS_CPU_LOONGSON1C
+	bool
+
 config SYS_HAS_CPU_MIPS32_R1
 	bool
 
arch/mips/include/asm/mach-loongson32/irq.h +42 -1

80 lines not on this page · raw message

arch/mips/include/asm/mach-loongson32/loongson1.h +22 -0
index 12aa129..4a2f4cd 100644
@@ -1,5 +1,7 @@
 /*
  * Copyright (c) 2011 Zhang, Keguang <[email protected]>
+ * Copyright (c) 2015 Tang Haifeng <[email protected]>
+ * Copyright (c) 2016 Ling Yang <[email protected]>
  *
  * Register mappings for Loongson 1
  *
@@ -13,15 +15,29 @@
 #ifndef __ASM_MACH_LOONGSON32_LOONGSON1_H
 #define __ASM_MACH_LOONGSON32_LOONGSON1_H
 
+#if defined(CONFIG_LOONGSON1_LS1B)
 #define DEFAULT_MEMSIZE			256	/* If no memsize provided */
+#elif defined(CONFIG_LOONGSON1_LS1C)
+#define DEFAULT_MEMSIZE			32	/* If no memsize provided */
+#endif
 
 /* Loongson 1 Register Bases */
 #define LS1X_MUX_BASE			0x1fd00420
 #define LS1X_INTC_BASE			0x1fd01040
+#define LS1X_GPIO_BASE			0x1fd010c0
+#define LS1X_CBUS_BASE			0x1fd011c0
+#if defined(CONFIG_LOONGSON1_LS1B)
 #define LS1X_EHCI_BASE			0x1fe00000
 #define LS1X_OHCI_BASE			0x1fe08000
+#elif defined(CONFIG_LOONGSON1_LS1C)
+#define LS1X_OTG_BASE			0x1fe00000
+#define LS1X_EHCI_BASE			0x1fe20000
+#define LS1X_OHCI_BASE			0x1fe28000
+#endif
 #define LS1X_GMAC0_BASE			0x1fe10000
+#if defined(CONFIG_LOONGSON1_LS1B)
 #define LS1X_GMAC1_BASE			0x1fe20000
+#endif
 
 #define LS1X_UART0_BASE			0x1fe40000
 #define LS1X_UART1_BASE			0x1fe44000
@@ -38,7 +54,12 @@
 #define LS1X_PWM3_BASE			0x1fe5c030
 #define LS1X_WDT_BASE			0x1fe5c060
 #define LS1X_RTC_BASE			0x1fe64000
+#if defined(CONFIG_LOONGSON1_LS1B)
 #define LS1X_AC97_BASE			0x1fe74000
+#elif defined(CONFIG_LOONGSON1_LS1C)
+#define LS1X_AC97_BASE			0x1fe60000
+#define LS1X_I2S_BASE			0x1fe60000
+#endif
 #define LS1X_NAND_BASE			0x1fe78000
 #define LS1X_CLK_BASE			0x1fe78030
 
@@ -46,5 +67,6 @@
 #include <regs-mux.h>
 #include <regs-pwm.h>
 #include <regs-wdt.h>
+#include <regs-gpio.h>
 
 #endif /* __ASM_MACH_LOONGSON32_LOONGSON1_H */
arch/mips/include/asm/mach-loongson32/regs-gpio.h new file +26 -0
new file mode 100644
index 0000000..87b66bb
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2015 Tang Haifeng <[email protected]>
+ * Copyright (c) 2016 Ling Yang <[email protected]>
+ *
+ * Loongson 1 GPIO Register Definitions.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#ifndef __ASM_MACH_LOONGSON32_REGS_GPIO_H
+#define __ASM_MACH_LOONGSON32_REGS_GPIO_H
+
+#include <loongson1.h>
+
+#define LS1X_GPIO_REG(n, x) \
+		((void __iomem *)KSEG1ADDR(LS1X_GPIO_BASE + (n * 0x04) + (x)))
+
+#define LS1X_GPIO_CFG(n)	LS1X_GPIO_REG(n, 0x00)
+#define LS1X_GPIO_OE(n)		LS1X_GPIO_REG(n, 0x10)
+#define LS1X_GPIO_IN(n)		LS1X_GPIO_REG(n, 0x20)
+#define LS1X_GPIO_OUT(n)	LS1X_GPIO_REG(n, 0x30)
+
+#endif /* __ASM_MACH_LOONGSON32_REGS_GPIO_H */
arch/mips/include/asm/mach-loongson32/regs-mux.h +65 -0

86 lines not on this page · raw message

arch/mips/loongson32/Kconfig +15 -0
index 7704f20..3c0c2f2 100644
@@ -19,6 +19,21 @@ config LOONGSON1_LS1B
 	select USE_GENERIC_EARLY_PRINTK_8250
 	select COMMON_CLK
 
+config LOONGSON1_LS1C
+	bool "Loongson LS1C board"
+	select CEVT_R4K if !MIPS_EXTERNAL_TIMER
+	select CSRC_R4K if !MIPS_EXTERNAL_TIMER
+	select SYS_HAS_CPU_LOONGSON1C
+	select DMA_NONCOHERENT
+	select BOOT_ELF32
+	select IRQ_MIPS_CPU
+	select SYS_SUPPORTS_32BIT_KERNEL
+	select SYS_SUPPORTS_LITTLE_ENDIAN
+	select SYS_SUPPORTS_HIGHMEM
+	select SYS_SUPPORTS_MIPS16
+	select SYS_HAS_EARLY_PRINTK
+	select USE_GENERIC_EARLY_PRINTK_8250
+	select COMMON_CLK
 endchoice
 
 menuconfig CEVT_CSRC_LS1X
arch/mips/loongson32/Makefile +6 -0
index 5f4bd6e..1ab2c5b 100644
@@ -9,3 +9,9 @@ obj-$(CONFIG_MACH_LOONGSON32) += common/
 #
 
 obj-$(CONFIG_LOONGSON1_LS1B)  += ls1b/
+
+#
+# Loongson LS1C board
+#
+
+obj-$(CONFIG_LOONGSON1_LS1C)  += ls1c/
arch/mips/loongson32/Platform +1 -0
index ebb6dc2..ffe01c6 100644
@@ -5,3 +5,4 @@ cflags-$(CONFIG_CPU_LOONGSON1)	+= \
 platform-$(CONFIG_MACH_LOONGSON32)	+= loongson32/
 cflags-$(CONFIG_MACH_LOONGSON32)	+= -I$(srctree)/arch/mips/include/asm/mach-loongson32
 load-$(CONFIG_LOONGSON1_LS1B)		+= 0xffffffff80100000
+load-$(CONFIG_LOONGSON1_LS1C)		+= 0xffffffff80100000
arch/mips/loongson32/common/irq.c +54 -3

98 lines not on this page · raw message

arch/mips/loongson32/common/platform.c +23 -1
index ddf1d4c..f3a6881 100644
@@ -1,5 +1,7 @@
 /*
  * Copyright (c) 2011 Zhang, Keguang <[email protected]>
+ * Copyright (c) 2015 Tang Haifeng <[email protected]>
+ * Copyright (c) 2016 Ling Yang <[email protected]>
  *
  * This program is free software; you can redistribute	it and/or modify it
  * under  the terms of	the GNU General	 Public License as published by the
@@ -18,6 +20,7 @@
 
 #include <cpufreq.h>
 #include <loongson1.h>
+#include <platform.h>
 
 /* 8250/16550 compatible UART */
 #define LS1X_UART(_id)						\
@@ -86,13 +89,14 @@ static struct stmmac_dma_cfg ls1x_eth_dma_cfg = {
 	.pbl		= 1,
 };
 
-int ls1x_eth_mux_init(struct platform_device *pdev, void *priv)
+static int ls1x_eth_mux_init(struct platform_device *pdev, void *priv)
 {
 	struct plat_stmmacenet_data *plat_dat = NULL;
 	u32 val;
 
 	val = __raw_readl(LS1X_MUX_CTRL1);
 
+#if defined(CONFIG_LOONGSON1_LS1B)
 	plat_dat = dev_get_platdata(&pdev->dev);
 	if (plat_dat->bus_id) {
 		__raw_writel(__raw_readl(LS1X_MUX_CTRL0) | GMAC1_USE_UART1 |
@@ -127,13 +131,29 @@ int ls1x_eth_mux_init(struct platform_device *pdev, void *priv)
 	}
 	__raw_writel(val, LS1X_MUX_CTRL1);
 
+#elif defined(CONFIG_LOONGSON1_LS1C)
+	plat_dat = dev_get_platdata(&pdev->dev);
+
+	val &= ~PHY_INTF_SELI;
+	if (plat_dat->interface == PHY_INTERFACE_MODE_RMII)
+		val |= 0x4 << PHY_INTF_SELI_SHIFT;
+	__raw_writel(val, LS1X_MUX_CTRL1);
+
+	val = __raw_readl(LS1X_MUX_CTRL0);
+	__raw_writel(val & (~GMAC_SHUT), LS1X_MUX_CTRL0);
+#endif
+
 	return 0;
 }
 
 static struct plat_stmmacenet_data ls1x_eth0_pdata = {
 	.bus_id		= 0,
 	.phy_addr	= -1,
+#if defined(CONFIG_LOONGSON1_LS1B)
 	.interface	= PHY_INTERFACE_MODE_MII,
+#elif defined(CONFIG_LOONGSON1_LS1C)
+	.interface	= PHY_INTERFACE_MODE_RMII,
+#endif
 	.mdio_bus_data	= &ls1x_mdio_bus_data,
 	.dma_cfg	= &ls1x_eth_dma_cfg,
 	.has_gmac	= 1,
@@ -164,6 +184,7 @@ struct platform_device ls1x_eth0_pdev = {
 	},
 };
 
+#if defined(CONFIG_LOONGSON1_LS1B)
 static struct plat_stmmacenet_data ls1x_eth1_pdata = {
 	.bus_id		= 1,
 	.phy_addr	= -1,
@@ -197,6 +218,7 @@ struct platform_device ls1x_eth1_pdev = {
 		.platform_data = &ls1x_eth1_pdata,
 	},
 };
+#endif
 
 /* USB EHCI */
 static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32);
arch/mips/loongson32/common/setup.c +6 -0
index 62f41af..65634d0 100644
@@ -1,5 +1,7 @@
 /*
  * Copyright (c) 2011 Zhang, Keguang <[email protected]>
+ * Copyright (c) 2015 Tang Haifeng <[email protected]>
+ * Copyright (c) 2016 Ling Yang <[email protected]>
  *
  * This program is free software; you can redistribute	it and/or modify it
  * under  the terms of	the GNU General	 Public License as published by the
@@ -22,7 +24,11 @@ const char *get_system_type(void)
 
 	switch (processor_id & PRID_REV_MASK) {
 	case PRID_REV_LOONGSON1B:
+#if defined(CONFIG_LOONGSON1_LS1B)
 		return "LOONGSON LS1B";
+#elif defined(CONFIG_LOONGSON1_LS1C)
+		return "LOONGSON LS1C";
+#endif
 	default:
 		return "LOONGSON (unknown)";
 	}
arch/mips/loongson32/ls1c/Makefile new file +5 -0
new file mode 100644
index 0000000..891eac4
@@ -0,0 +1,5 @@
+#
+# Makefile for loongson1B based machines.
+#
+
+obj-y += board.o
arch/mips/loongson32/ls1c/board.c new file +30 -0
new file mode 100644
index 0000000..998f607
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2011 Zhang, Keguang <[email protected]>
+ * Copyright (c) 2015 Tang Haifeng <[email protected]>
+ * Copyright (c) 2016 Ling Yang <[email protected]>
+ *
+ * This program is free software; you can redistribute	it and/or modify it
+ * under  the terms of	the GNU General	 Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <platform.h>
+
+static struct platform_device *ls1c_platform_devices[] __initdata = {
+	&ls1x_uart_pdev,
+	&ls1x_eth0_pdev,
+};
+
+static int __init ls1c_platform_init(void)
+{
+	int err;
+
+	ls1x_serial_setup(&ls1x_uart_pdev);
+
+	err = platform_add_devices(ls1c_platform_devices,
+				   ARRAY_SIZE(ls1c_platform_devices));
+	return err;
+}
+
+arch_initcall(ls1c_platform_init);
Signature · 1 line
1.9.1