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

MIPS: Loongson1B: Some updates/fixes for LS1B

- Add DMA device
- Add NAND device
- Add GPIO device
- Add LED device
- Update the defconfig and rename it to loongson1b_defconfig
- Fix ioremap size
- Other minor fixes

Signed-off-by: Kelvin Cheung <keguang.zhang@gmail.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: linux-clk@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: dmaengine@vger.kernel.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-mtd@lists.infradead.org
Patchwork: https://patchwork.linux-mips.org/patch/13033/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Kelvin Cheung and committed by
Ralf Baechle
9ec88b60 0d61ed17

+340 -104
+2
arch/mips/Kconfig
··· 1387 1387 bool "Loongson 1B" 1388 1388 depends on SYS_HAS_CPU_LOONGSON1B 1389 1389 select CPU_LOONGSON1 1390 + select ARCH_WANT_OPTIONAL_GPIOLIB 1391 + select LEDS_GPIO_REGISTER 1390 1392 help 1391 1393 The Loongson 1B is a 32-bit SoC, which implements the MIPS32 1392 1394 release 2 instruction set.
+25 -10
arch/mips/configs/ls1b_defconfig arch/mips/configs/loongson1b_defconfig
··· 1 1 CONFIG_MACH_LOONGSON32=y 2 2 CONFIG_PREEMPT=y 3 3 # CONFIG_SECCOMP is not set 4 - CONFIG_EXPERIMENTAL=y 5 4 # CONFIG_LOCALVERSION_AUTO is not set 5 + CONFIG_KERNEL_XZ=y 6 6 CONFIG_SYSVIPC=y 7 + CONFIG_HIGH_RES_TIMERS=y 7 8 CONFIG_BSD_PROCESS_ACCT=y 8 9 CONFIG_BSD_PROCESS_ACCT_V3=y 9 - CONFIG_HIGH_RES_TIMERS=y 10 10 CONFIG_IKCONFIG=y 11 11 CONFIG_IKCONFIG_PROC=y 12 12 CONFIG_LOG_BUF_SHIFT=16 13 13 CONFIG_NAMESPACES=y 14 - CONFIG_BLK_DEV_INITRD=y 15 - CONFIG_RD_BZIP2=y 16 - CONFIG_RD_LZMA=y 14 + CONFIG_CC_OPTIMIZE_FOR_SIZE=y 17 15 CONFIG_EXPERT=y 18 16 CONFIG_PERF_EVENTS=y 19 17 # CONFIG_COMPAT_BRK is not set ··· 39 41 CONFIG_DEVTMPFS=y 40 42 CONFIG_DEVTMPFS_MOUNT=y 41 43 # CONFIG_STANDALONE is not set 44 + CONFIG_MTD=y 45 + CONFIG_MTD_CMDLINE_PARTS=y 46 + CONFIG_MTD_BLOCK=y 47 + CONFIG_MTD_NAND=y 48 + CONFIG_MTD_NAND_LOONGSON1=y 49 + CONFIG_MTD_UBI=y 42 50 CONFIG_BLK_DEV_LOOP=y 43 51 CONFIG_SCSI=m 44 52 # CONFIG_SCSI_PROC_FS is not set ··· 52 48 # CONFIG_SCSI_LOWLEVEL is not set 53 49 CONFIG_NETDEVICES=y 54 50 # CONFIG_NET_VENDOR_BROADCOM is not set 55 - # CONFIG_NET_VENDOR_CHELSIO is not set 56 51 # CONFIG_NET_VENDOR_INTEL is not set 57 52 # CONFIG_NET_VENDOR_MARVELL is not set 58 53 # CONFIG_NET_VENDOR_MICREL is not set ··· 59 56 # CONFIG_NET_VENDOR_SEEQ is not set 60 57 # CONFIG_NET_VENDOR_SMSC is not set 61 58 CONFIG_STMMAC_ETH=y 62 - CONFIG_STMMAC_DA=y 63 59 # CONFIG_NET_VENDOR_WIZNET is not set 64 60 # CONFIG_WLAN is not set 65 61 CONFIG_INPUT_EVDEV=y ··· 71 69 CONFIG_SERIAL_8250=y 72 70 CONFIG_SERIAL_8250_CONSOLE=y 73 71 # CONFIG_HW_RANDOM is not set 72 + CONFIG_GPIOLIB=y 73 + CONFIG_GPIO_LOONGSON1=y 74 74 # CONFIG_HWMON is not set 75 75 # CONFIG_VGA_CONSOLE is not set 76 - CONFIG_USB_HID=m 77 76 CONFIG_HID_GENERIC=m 77 + CONFIG_USB_HID=m 78 78 CONFIG_USB=y 79 79 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y 80 80 CONFIG_USB_EHCI_HCD=y 81 - CONFIG_USB_EHCI_HCD_PLATFORM=y 82 81 # CONFIG_USB_EHCI_TT_NEWSCHED is not set 82 + CONFIG_USB_EHCI_HCD_PLATFORM=y 83 83 CONFIG_USB_STORAGE=m 84 84 CONFIG_USB_SERIAL=m 85 85 CONFIG_USB_SERIAL_PL2303=m 86 + CONFIG_NEW_LEDS=y 87 + CONFIG_LEDS_CLASS=y 88 + CONFIG_LEDS_GPIO=y 89 + CONFIG_LEDS_TRIGGERS=y 90 + CONFIG_LEDS_TRIGGER_HEARTBEAT=y 86 91 CONFIG_RTC_CLASS=y 87 92 CONFIG_RTC_DRV_LOONGSON1=y 88 93 # CONFIG_IOMMU_SUPPORT is not set ··· 105 96 CONFIG_PROC_KCORE=y 106 97 CONFIG_TMPFS=y 107 98 CONFIG_TMPFS_POSIX_ACL=y 108 - # CONFIG_MISC_FILESYSTEMS is not set 99 + CONFIG_UBIFS_FS=y 100 + CONFIG_UBIFS_FS_ADVANCED_COMPR=y 101 + CONFIG_UBIFS_ATIME_SUPPORT=y 109 102 CONFIG_NFS_FS=y 110 103 CONFIG_ROOT_NFS=y 111 104 CONFIG_NLS_CODEPAGE_437=m 112 105 CONFIG_NLS_ISO8859_1=m 106 + CONFIG_DYNAMIC_DEBUG=y 113 107 # CONFIG_ENABLE_WARN_DEPRECATED is not set 114 108 # CONFIG_ENABLE_MUST_CHECK is not set 109 + CONFIG_DEBUG_FS=y 115 110 CONFIG_MAGIC_SYSRQ=y 116 111 # CONFIG_SCHED_DEBUG is not set 117 112 # CONFIG_DEBUG_PREEMPT is not set 118 113 # CONFIG_FTRACE is not set 119 114 # CONFIG_EARLY_PRINTK is not set 115 + # CONFIG_CRYPTO_ECHAINIV is not set 116 + # CONFIG_CRYPTO_HW is not set
-1
arch/mips/include/asm/mach-loongson32/cpufreq.h
··· 9 9 * option) any later version. 10 10 */ 11 11 12 - 13 12 #ifndef __ASM_MACH_LOONGSON32_CPUFREQ_H 14 13 #define __ASM_MACH_LOONGSON32_CPUFREQ_H 15 14
+25
arch/mips/include/asm/mach-loongson32/dma.h
··· 1 + /* 2 + * Copyright (c) 2015 Zhang, Keguang <keguang.zhang@gmail.com> 3 + * 4 + * Loongson 1 NAND platform support. 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License as published by the 8 + * Free Software Foundation; either version 2 of the License, or (at your 9 + * option) any later version. 10 + */ 11 + 12 + #ifndef __ASM_MACH_LOONGSON32_DMA_H 13 + #define __ASM_MACH_LOONGSON32_DMA_H 14 + 15 + #define LS1X_DMA_CHANNEL0 0 16 + #define LS1X_DMA_CHANNEL1 1 17 + #define LS1X_DMA_CHANNEL2 2 18 + 19 + struct plat_ls1x_dma { 20 + int nr_channels; 21 + }; 22 + 23 + extern struct plat_ls1x_dma ls1b_dma_pdata; 24 + 25 + #endif /* __ASM_MACH_LOONGSON32_DMA_H */
-1
arch/mips/include/asm/mach-loongson32/irq.h
··· 9 9 * option) any later version. 10 10 */ 11 11 12 - 13 12 #ifndef __ASM_MACH_LOONGSON32_IRQ_H 14 13 #define __ASM_MACH_LOONGSON32_IRQ_H 15 14
+3 -1
arch/mips/include/asm/mach-loongson32/loongson1.h
··· 9 9 * option) any later version. 10 10 */ 11 11 12 - 13 12 #ifndef __ASM_MACH_LOONGSON32_LOONGSON1_H 14 13 #define __ASM_MACH_LOONGSON32_LOONGSON1_H 15 14 ··· 17 18 /* Loongson 1 Register Bases */ 18 19 #define LS1X_MUX_BASE 0x1fd00420 19 20 #define LS1X_INTC_BASE 0x1fd01040 21 + #define LS1X_GPIO0_BASE 0x1fd010c0 22 + #define LS1X_GPIO1_BASE 0x1fd010c4 23 + #define LS1X_DMAC_BASE 0x1fd01160 20 24 #define LS1X_EHCI_BASE 0x1fe00000 21 25 #define LS1X_OHCI_BASE 0x1fe08000 22 26 #define LS1X_GMAC0_BASE 0x1fe10000
+30
arch/mips/include/asm/mach-loongson32/nand.h
··· 1 + /* 2 + * Copyright (c) 2015 Zhang, Keguang <keguang.zhang@gmail.com> 3 + * 4 + * Loongson 1 NAND platform support. 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License as published by the 8 + * Free Software Foundation; either version 2 of the License, or (at your 9 + * option) any later version. 10 + */ 11 + 12 + #ifndef __ASM_MACH_LOONGSON32_NAND_H 13 + #define __ASM_MACH_LOONGSON32_NAND_H 14 + 15 + #include <linux/dmaengine.h> 16 + #include <linux/mtd/partitions.h> 17 + 18 + struct plat_ls1x_nand { 19 + struct mtd_partition *parts; 20 + unsigned int nr_parts; 21 + 22 + int hold_cycle; 23 + int wait_cycle; 24 + }; 25 + 26 + extern struct plat_ls1x_nand ls1b_nand_pdata; 27 + 28 + bool ls1x_dma_filter_fn(struct dma_chan *chan, void *param); 29 + 30 + #endif /* __ASM_MACH_LOONGSON32_NAND_H */
+11 -3
arch/mips/include/asm/mach-loongson32/platform.h
··· 7 7 * option) any later version. 8 8 */ 9 9 10 - 11 10 #ifndef __ASM_MACH_LOONGSON32_PLATFORM_H 12 11 #define __ASM_MACH_LOONGSON32_PLATFORM_H 13 12 14 13 #include <linux/platform_device.h> 15 14 15 + #include <dma.h> 16 + #include <nand.h> 17 + 16 18 extern struct platform_device ls1x_uart_pdev; 17 19 extern struct platform_device ls1x_cpufreq_pdev; 20 + extern struct platform_device ls1x_dma_pdev; 18 21 extern struct platform_device ls1x_eth0_pdev; 19 22 extern struct platform_device ls1x_eth1_pdev; 20 23 extern struct platform_device ls1x_ehci_pdev; 24 + extern struct platform_device ls1x_gpio0_pdev; 25 + extern struct platform_device ls1x_gpio1_pdev; 26 + extern struct platform_device ls1x_nand_pdev; 21 27 extern struct platform_device ls1x_rtc_pdev; 22 28 23 - extern void __init ls1x_clk_init(void); 24 - extern void __init ls1x_serial_setup(struct platform_device *pdev); 29 + void __init ls1x_clk_init(void); 30 + void __init ls1x_dma_set_platdata(struct plat_ls1x_dma *pdata); 31 + void __init ls1x_nand_set_platdata(struct plat_ls1x_nand *pdata); 32 + void __init ls1x_serial_set_uartclk(struct platform_device *pdev); 25 33 26 34 #endif /* __ASM_MACH_LOONGSON32_PLATFORM_H */
+12 -12
arch/mips/include/asm/mach-loongson32/regs-clk.h
··· 19 19 #define LS1X_CLK_PLL_DIV LS1X_CLK_REG(0x4) 20 20 21 21 /* Clock PLL Divisor Register Bits */ 22 - #define DIV_DC_EN (0x1 << 31) 23 - #define DIV_DC_RST (0x1 << 30) 24 - #define DIV_CPU_EN (0x1 << 25) 25 - #define DIV_CPU_RST (0x1 << 24) 26 - #define DIV_DDR_EN (0x1 << 19) 27 - #define DIV_DDR_RST (0x1 << 18) 28 - #define RST_DC_EN (0x1 << 5) 29 - #define RST_DC (0x1 << 4) 30 - #define RST_DDR_EN (0x1 << 3) 31 - #define RST_DDR (0x1 << 2) 32 - #define RST_CPU_EN (0x1 << 1) 33 - #define RST_CPU 0x1 22 + #define DIV_DC_EN BIT(31) 23 + #define DIV_DC_RST BIT(30) 24 + #define DIV_CPU_EN BIT(25) 25 + #define DIV_CPU_RST BIT(24) 26 + #define DIV_DDR_EN BIT(19) 27 + #define DIV_DDR_RST BIT(18) 28 + #define RST_DC_EN BIT(5) 29 + #define RST_DC BIT(4) 30 + #define RST_DDR_EN BIT(3) 31 + #define RST_DDR BIT(2) 32 + #define RST_CPU_EN BIT(1) 33 + #define RST_CPU BIT(0) 34 34 35 35 #define DIV_DC_SHIFT 26 36 36 #define DIV_CPU_SHIFT 20
+42 -42
arch/mips/include/asm/mach-loongson32/regs-mux.h
··· 19 19 #define LS1X_MUX_CTRL1 LS1X_MUX_REG(0x4) 20 20 21 21 /* MUX CTRL0 Register Bits */ 22 - #define UART0_USE_PWM23 (0x1 << 28) 23 - #define UART0_USE_PWM01 (0x1 << 27) 24 - #define UART1_USE_LCD0_5_6_11 (0x1 << 26) 25 - #define I2C2_USE_CAN1 (0x1 << 25) 26 - #define I2C1_USE_CAN0 (0x1 << 24) 27 - #define NAND3_USE_UART5 (0x1 << 23) 28 - #define NAND3_USE_UART4 (0x1 << 22) 29 - #define NAND3_USE_UART1_DAT (0x1 << 21) 30 - #define NAND3_USE_UART1_CTS (0x1 << 20) 31 - #define NAND3_USE_PWM23 (0x1 << 19) 32 - #define NAND3_USE_PWM01 (0x1 << 18) 33 - #define NAND2_USE_UART5 (0x1 << 17) 34 - #define NAND2_USE_UART4 (0x1 << 16) 35 - #define NAND2_USE_UART1_DAT (0x1 << 15) 36 - #define NAND2_USE_UART1_CTS (0x1 << 14) 37 - #define NAND2_USE_PWM23 (0x1 << 13) 38 - #define NAND2_USE_PWM01 (0x1 << 12) 39 - #define NAND1_USE_UART5 (0x1 << 11) 40 - #define NAND1_USE_UART4 (0x1 << 10) 41 - #define NAND1_USE_UART1_DAT (0x1 << 9) 42 - #define NAND1_USE_UART1_CTS (0x1 << 8) 43 - #define NAND1_USE_PWM23 (0x1 << 7) 44 - #define NAND1_USE_PWM01 (0x1 << 6) 45 - #define GMAC1_USE_UART1 (0x1 << 4) 46 - #define GMAC1_USE_UART0 (0x1 << 3) 47 - #define LCD_USE_UART0_DAT (0x1 << 2) 48 - #define LCD_USE_UART15 (0x1 << 1) 49 - #define LCD_USE_UART0 0x1 22 + #define UART0_USE_PWM23 BIT(28) 23 + #define UART0_USE_PWM01 BIT(27) 24 + #define UART1_USE_LCD0_5_6_11 BIT(26) 25 + #define I2C2_USE_CAN1 BIT(25) 26 + #define I2C1_USE_CAN0 BIT(24) 27 + #define NAND3_USE_UART5 BIT(23) 28 + #define NAND3_USE_UART4 BIT(22) 29 + #define NAND3_USE_UART1_DAT BIT(21) 30 + #define NAND3_USE_UART1_CTS BIT(20) 31 + #define NAND3_USE_PWM23 BIT(19) 32 + #define NAND3_USE_PWM01 BIT(18) 33 + #define NAND2_USE_UART5 BIT(17) 34 + #define NAND2_USE_UART4 BIT(16) 35 + #define NAND2_USE_UART1_DAT BIT(15) 36 + #define NAND2_USE_UART1_CTS BIT(14) 37 + #define NAND2_USE_PWM23 BIT(13) 38 + #define NAND2_USE_PWM01 BIT(12) 39 + #define NAND1_USE_UART5 BIT(11) 40 + #define NAND1_USE_UART4 BIT(10) 41 + #define NAND1_USE_UART1_DAT BIT(9) 42 + #define NAND1_USE_UART1_CTS BIT(8) 43 + #define NAND1_USE_PWM23 BIT(7) 44 + #define NAND1_USE_PWM01 BIT(6) 45 + #define GMAC1_USE_UART1 BIT(4) 46 + #define GMAC1_USE_UART0 BIT(3) 47 + #define LCD_USE_UART0_DAT BIT(2) 48 + #define LCD_USE_UART15 BIT(1) 49 + #define LCD_USE_UART0 BIT(0) 50 50 51 51 /* MUX CTRL1 Register Bits */ 52 - #define USB_RESET (0x1 << 31) 53 - #define SPI1_CS_USE_PWM01 (0x1 << 24) 54 - #define SPI1_USE_CAN (0x1 << 23) 55 - #define DISABLE_DDR_CONFSPACE (0x1 << 20) 56 - #define DDR32TO16EN (0x1 << 16) 57 - #define GMAC1_SHUT (0x1 << 13) 58 - #define GMAC0_SHUT (0x1 << 12) 59 - #define USB_SHUT (0x1 << 11) 60 - #define UART1_3_USE_CAN1 (0x1 << 5) 61 - #define UART1_2_USE_CAN0 (0x1 << 4) 62 - #define GMAC1_USE_TXCLK (0x1 << 3) 63 - #define GMAC0_USE_TXCLK (0x1 << 2) 64 - #define GMAC1_USE_PWM23 (0x1 << 1) 65 - #define GMAC0_USE_PWM01 0x1 52 + #define USB_RESET BIT(31) 53 + #define SPI1_CS_USE_PWM01 BIT(24) 54 + #define SPI1_USE_CAN BIT(23) 55 + #define DISABLE_DDR_CONFSPACE BIT(20) 56 + #define DDR32TO16EN BIT(16) 57 + #define GMAC1_SHUT BIT(13) 58 + #define GMAC0_SHUT BIT(12) 59 + #define USB_SHUT BIT(11) 60 + #define UART1_3_USE_CAN1 BIT(5) 61 + #define UART1_2_USE_CAN0 BIT(4) 62 + #define GMAC1_USE_TXCLK BIT(3) 63 + #define GMAC0_USE_TXCLK BIT(2) 64 + #define GMAC1_USE_PWM23 BIT(1) 65 + #define GMAC0_USE_PWM01 BIT(0) 66 66 67 67 #endif /* __ASM_MACH_LOONGSON32_REGS_MUX_H */
+6 -6
arch/mips/include/asm/mach-loongson32/regs-pwm.h
··· 19 19 #define PWM_CTRL 0xc 20 20 21 21 /* PWM Control Register Bits */ 22 - #define CNT_RST (0x1 << 7) 23 - #define INT_SR (0x1 << 6) 24 - #define INT_EN (0x1 << 5) 25 - #define PWM_SINGLE (0x1 << 4) 26 - #define PWM_OE (0x1 << 3) 27 - #define CNT_EN 0x1 22 + #define CNT_RST BIT(7) 23 + #define INT_SR BIT(6) 24 + #define INT_EN BIT(5) 25 + #define PWM_SINGLE BIT(4) 26 + #define PWM_OE BIT(3) 27 + #define CNT_EN BIT(0) 28 28 29 29 #endif /* __ASM_MACH_LOONGSON32_REGS_PWM_H */
+101 -4
arch/mips/loongson32/common/platform.c
··· 1 1 /* 2 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 2 + * Copyright (c) 2011-2016 Zhang, Keguang <keguang.zhang@gmail.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it 5 5 * under the terms of the GNU General Public License as published by the ··· 10 10 #include <linux/clk.h> 11 11 #include <linux/dma-mapping.h> 12 12 #include <linux/err.h> 13 + #include <linux/mtd/partitions.h> 14 + #include <linux/sizes.h> 13 15 #include <linux/phy.h> 14 16 #include <linux/serial_8250.h> 15 17 #include <linux/stmmac.h> 16 18 #include <linux/usb/ehci_pdriver.h> 17 - #include <asm-generic/sizes.h> 18 19 19 - #include <cpufreq.h> 20 20 #include <loongson1.h> 21 + #include <cpufreq.h> 22 + #include <dma.h> 23 + #include <nand.h> 21 24 22 25 /* 8250/16550 compatible UART */ 23 26 #define LS1X_UART(_id) \ ··· 48 45 }, 49 46 }; 50 47 51 - void __init ls1x_serial_setup(struct platform_device *pdev) 48 + void __init ls1x_serial_set_uartclk(struct platform_device *pdev) 52 49 { 53 50 struct clk *clk; 54 51 struct plat_serial8250_port *p; ··· 79 76 .platform_data = &ls1x_cpufreq_pdata, 80 77 }, 81 78 }; 79 + 80 + /* DMA */ 81 + static struct resource ls1x_dma_resources[] = { 82 + [0] = { 83 + .start = LS1X_DMAC_BASE, 84 + .end = LS1X_DMAC_BASE + SZ_4 - 1, 85 + .flags = IORESOURCE_MEM, 86 + }, 87 + [1] = { 88 + .start = LS1X_DMA0_IRQ, 89 + .end = LS1X_DMA0_IRQ, 90 + .flags = IORESOURCE_IRQ, 91 + }, 92 + [2] = { 93 + .start = LS1X_DMA1_IRQ, 94 + .end = LS1X_DMA1_IRQ, 95 + .flags = IORESOURCE_IRQ, 96 + }, 97 + [3] = { 98 + .start = LS1X_DMA2_IRQ, 99 + .end = LS1X_DMA2_IRQ, 100 + .flags = IORESOURCE_IRQ, 101 + }, 102 + }; 103 + 104 + struct platform_device ls1x_dma_pdev = { 105 + .name = "ls1x-dma", 106 + .id = -1, 107 + .num_resources = ARRAY_SIZE(ls1x_dma_resources), 108 + .resource = ls1x_dma_resources, 109 + }; 110 + 111 + void __init ls1x_dma_set_platdata(struct plat_ls1x_dma *pdata) 112 + { 113 + ls1x_dma_pdev.dev.platform_data = pdata; 114 + } 82 115 83 116 /* Synopsys Ethernet GMAC */ 84 117 static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = { ··· 236 197 .platform_data = &ls1x_eth1_pdata, 237 198 }, 238 199 }; 200 + 201 + /* GPIO */ 202 + static struct resource ls1x_gpio0_resources[] = { 203 + [0] = { 204 + .start = LS1X_GPIO0_BASE, 205 + .end = LS1X_GPIO0_BASE + SZ_4 - 1, 206 + .flags = IORESOURCE_MEM, 207 + }, 208 + }; 209 + 210 + struct platform_device ls1x_gpio0_pdev = { 211 + .name = "ls1x-gpio", 212 + .id = 0, 213 + .num_resources = ARRAY_SIZE(ls1x_gpio0_resources), 214 + .resource = ls1x_gpio0_resources, 215 + }; 216 + 217 + static struct resource ls1x_gpio1_resources[] = { 218 + [0] = { 219 + .start = LS1X_GPIO1_BASE, 220 + .end = LS1X_GPIO1_BASE + SZ_4 - 1, 221 + .flags = IORESOURCE_MEM, 222 + }, 223 + }; 224 + 225 + struct platform_device ls1x_gpio1_pdev = { 226 + .name = "ls1x-gpio", 227 + .id = 1, 228 + .num_resources = ARRAY_SIZE(ls1x_gpio1_resources), 229 + .resource = ls1x_gpio1_resources, 230 + }; 231 + 232 + /* NAND Flash */ 233 + static struct resource ls1x_nand_resources[] = { 234 + [0] = { 235 + .start = LS1X_NAND_BASE, 236 + .end = LS1X_NAND_BASE + SZ_32 - 1, 237 + .flags = IORESOURCE_MEM, 238 + }, 239 + [1] = { 240 + /* DMA channel 0 is dedicated to NAND */ 241 + .start = LS1X_DMA_CHANNEL0, 242 + .end = LS1X_DMA_CHANNEL0, 243 + .flags = IORESOURCE_DMA, 244 + }, 245 + }; 246 + 247 + struct platform_device ls1x_nand_pdev = { 248 + .name = "ls1x-nand", 249 + .id = -1, 250 + .num_resources = ARRAY_SIZE(ls1x_nand_resources), 251 + .resource = ls1x_nand_resources, 252 + }; 253 + 254 + void __init ls1x_nand_set_platdata(struct plat_ls1x_nand *pdata) 255 + { 256 + ls1x_nand_pdev.dev.platform_data = pdata; 257 + } 239 258 240 259 /* USB EHCI */ 241 260 static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32);
+7 -6
arch/mips/loongson32/common/reset.c
··· 9 9 10 10 #include <linux/io.h> 11 11 #include <linux/pm.h> 12 + #include <linux/sizes.h> 12 13 #include <asm/idle.h> 13 14 #include <asm/reboot.h> 14 15 15 16 #include <loongson1.h> 16 17 17 - static void __iomem *wdt_base; 18 + static void __iomem *wdt_reg_base; 18 19 19 20 static void ls1x_halt(void) 20 21 { ··· 27 26 28 27 static void ls1x_restart(char *command) 29 28 { 30 - __raw_writel(0x1, wdt_base + WDT_EN); 31 - __raw_writel(0x1, wdt_base + WDT_TIMER); 32 - __raw_writel(0x1, wdt_base + WDT_SET); 29 + __raw_writel(0x1, wdt_reg_base + WDT_EN); 30 + __raw_writel(0x1, wdt_reg_base + WDT_TIMER); 31 + __raw_writel(0x1, wdt_reg_base + WDT_SET); 33 32 34 33 ls1x_halt(); 35 34 } ··· 41 40 42 41 static int __init ls1x_reboot_setup(void) 43 42 { 44 - wdt_base = ioremap_nocache(LS1X_WDT_BASE, 0x0f); 45 - if (!wdt_base) 43 + wdt_reg_base = ioremap_nocache(LS1X_WDT_BASE, (SZ_4 + SZ_8)); 44 + if (!wdt_reg_base) 46 45 panic("Failed to remap watchdog registers"); 47 46 48 47 _machine_restart = ls1x_restart;
+14 -13
arch/mips/loongson32/common/time.c
··· 9 9 10 10 #include <linux/clk.h> 11 11 #include <linux/interrupt.h> 12 + #include <linux/sizes.h> 12 13 #include <asm/time.h> 13 14 14 15 #include <loongson1.h> ··· 36 35 37 36 DEFINE_RAW_SPINLOCK(ls1x_timer_lock); 38 37 39 - static void __iomem *timer_base; 38 + static void __iomem *timer_reg_base; 40 39 static uint32_t ls1x_jiffies_per_tick; 41 40 42 41 static inline void ls1x_pwmtimer_set_period(uint32_t period) 43 42 { 44 - __raw_writel(period, timer_base + PWM_HRC); 45 - __raw_writel(period, timer_base + PWM_LRC); 43 + __raw_writel(period, timer_reg_base + PWM_HRC); 44 + __raw_writel(period, timer_reg_base + PWM_LRC); 46 45 } 47 46 48 47 static inline void ls1x_pwmtimer_restart(void) 49 48 { 50 - __raw_writel(0x0, timer_base + PWM_CNT); 51 - __raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL); 49 + __raw_writel(0x0, timer_reg_base + PWM_CNT); 50 + __raw_writel(INT_EN | CNT_EN, timer_reg_base + PWM_CTRL); 52 51 } 53 52 54 53 void __init ls1x_pwmtimer_init(void) 55 54 { 56 - timer_base = ioremap(LS1X_TIMER_BASE, 0xf); 57 - if (!timer_base) 55 + timer_reg_base = ioremap_nocache(LS1X_TIMER_BASE, SZ_16); 56 + if (!timer_reg_base) 58 57 panic("Failed to remap timer registers"); 59 58 60 59 ls1x_jiffies_per_tick = DIV_ROUND_CLOSEST(mips_hpt_frequency, HZ); ··· 87 86 */ 88 87 jifs = jiffies; 89 88 /* read the count */ 90 - count = __raw_readl(timer_base + PWM_CNT); 89 + count = __raw_readl(timer_reg_base + PWM_CNT); 91 90 92 91 /* 93 92 * It's possible for count to appear to go the wrong way for this ··· 132 131 raw_spin_lock(&ls1x_timer_lock); 133 132 ls1x_pwmtimer_set_period(ls1x_jiffies_per_tick); 134 133 ls1x_pwmtimer_restart(); 135 - __raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL); 134 + __raw_writel(INT_EN | CNT_EN, timer_reg_base + PWM_CTRL); 136 135 raw_spin_unlock(&ls1x_timer_lock); 137 136 138 137 return 0; ··· 141 140 static int ls1x_clockevent_tick_resume(struct clock_event_device *cd) 142 141 { 143 142 raw_spin_lock(&ls1x_timer_lock); 144 - __raw_writel(INT_EN | CNT_EN, timer_base + PWM_CTRL); 143 + __raw_writel(INT_EN | CNT_EN, timer_reg_base + PWM_CTRL); 145 144 raw_spin_unlock(&ls1x_timer_lock); 146 145 147 146 return 0; ··· 150 149 static int ls1x_clockevent_set_state_shutdown(struct clock_event_device *cd) 151 150 { 152 151 raw_spin_lock(&ls1x_timer_lock); 153 - __raw_writel(__raw_readl(timer_base + PWM_CTRL) & ~CNT_EN, 154 - timer_base + PWM_CTRL); 152 + __raw_writel(__raw_readl(timer_reg_base + PWM_CTRL) & ~CNT_EN, 153 + timer_reg_base + PWM_CTRL); 155 154 raw_spin_unlock(&ls1x_timer_lock); 156 155 157 156 return 0; ··· 221 220 222 221 #ifdef CONFIG_CEVT_CSRC_LS1X 223 222 /* setup LS1X PWM timer */ 224 - clk = clk_get(NULL, "ls1x_pwmtimer"); 223 + clk = clk_get(NULL, "ls1x-pwmtimer"); 225 224 if (IS_ERR(clk)) 226 225 panic("unable to get timer clock, err=%ld", PTR_ERR(clk)); 227 226
+62 -5
arch/mips/loongson32/ls1b/board.c
··· 1 1 /* 2 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 2 + * Copyright (c) 2011-2016 Zhang, Keguang <keguang.zhang@gmail.com> 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify it 5 5 * under the terms of the GNU General Public License as published by the ··· 7 7 * option) any later version. 8 8 */ 9 9 10 + #include <linux/leds.h> 11 + #include <linux/mtd/partitions.h> 12 + #include <linux/sizes.h> 13 + 14 + #include <loongson1.h> 15 + #include <dma.h> 16 + #include <nand.h> 10 17 #include <platform.h> 18 + 19 + struct plat_ls1x_dma ls1x_dma_pdata = { 20 + .nr_channels = 3, 21 + }; 22 + 23 + static struct mtd_partition ls1x_nand_parts[] = { 24 + { 25 + .name = "kernel", 26 + .offset = 0, 27 + .size = SZ_16M, 28 + }, 29 + { 30 + .name = "rootfs", 31 + .offset = MTDPART_OFS_APPEND, 32 + .size = MTDPART_SIZ_FULL, 33 + }, 34 + }; 35 + 36 + struct plat_ls1x_nand ls1x_nand_pdata = { 37 + .parts = ls1x_nand_parts, 38 + .nr_parts = ARRAY_SIZE(ls1x_nand_parts), 39 + .hold_cycle = 0x2, 40 + .wait_cycle = 0xc, 41 + }; 42 + 43 + static const struct gpio_led ls1x_gpio_leds[] __initconst = { 44 + { 45 + .name = "LED9", 46 + .default_trigger = "heartbeat", 47 + .gpio = 38, 48 + .active_low = 1, 49 + .default_state = LEDS_GPIO_DEFSTATE_OFF, 50 + }, { 51 + .name = "LED6", 52 + .default_trigger = "nand-disk", 53 + .gpio = 39, 54 + .active_low = 1, 55 + .default_state = LEDS_GPIO_DEFSTATE_OFF, 56 + }, 57 + }; 58 + 59 + static const struct gpio_led_platform_data ls1x_led_pdata __initconst = { 60 + .num_leds = ARRAY_SIZE(ls1x_gpio_leds), 61 + .leds = ls1x_gpio_leds, 62 + }; 11 63 12 64 static struct platform_device *ls1b_platform_devices[] __initdata = { 13 65 &ls1x_uart_pdev, 14 66 &ls1x_cpufreq_pdev, 67 + &ls1x_dma_pdev, 15 68 &ls1x_eth0_pdev, 16 69 &ls1x_eth1_pdev, 17 70 &ls1x_ehci_pdev, 71 + &ls1x_gpio0_pdev, 72 + &ls1x_gpio1_pdev, 73 + &ls1x_nand_pdev, 18 74 &ls1x_rtc_pdev, 19 75 }; 20 76 21 77 static int __init ls1b_platform_init(void) 22 78 { 23 - int err; 79 + ls1x_serial_set_uartclk(&ls1x_uart_pdev); 80 + ls1x_dma_set_platdata(&ls1x_dma_pdata); 81 + ls1x_nand_set_platdata(&ls1x_nand_pdata); 24 82 25 - ls1x_serial_setup(&ls1x_uart_pdev); 83 + gpio_led_register_device(-1, &ls1x_led_pdata); 26 84 27 - err = platform_add_devices(ls1b_platform_devices, 85 + return platform_add_devices(ls1b_platform_devices, 28 86 ARRAY_SIZE(ls1b_platform_devices)); 29 - return err; 30 87 } 31 88 32 89 arch_initcall(ls1b_platform_init);