diff options
| author | Kelvin Cheung <keguang.zhang@gmail.com> | 2014-10-09 23:40:01 -0400 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2014-11-24 01:45:09 -0500 |
| commit | f29ad10de6c345c8ae4cb33a99ba8ff29bdcd751 (patch) | |
| tree | ac377224cfbe7b116ad9f68deb85fd9dc84f93c4 | |
| parent | 813c14108d0f5bbddc125fb7a6a0819fcdcf61e2 (diff) | |
MIPS: Loongson1B: Some fixes/updates for LS1B
- Fix hanging ethernet issue of LS1B v2.0 by adding pbl field in plat data.
(It seems that the MAC controller of LS1B v2.0 can only accept pbl=1)
- Add GMAC1 support and setup MUX in terms of PHY mode.
- Add CPUFreq support.
- Add MUX Register Definitions.
- Add PWM Register Definitions.
- Update clock register bitfields according to the latest spec.
- Update clock related stuff.
Signed-off-by: Kelvin Cheung <keguang.zhang@gmail.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/8024/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
| -rw-r--r-- | arch/mips/Kconfig | 1 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-loongson1/cpufreq.h | 23 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-loongson1/loongson1.h | 8 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-loongson1/platform.h | 10 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-loongson1/regs-clk.h | 23 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-loongson1/regs-mux.h | 67 | ||||
| -rw-r--r-- | arch/mips/include/asm/mach-loongson1/regs-pwm.h | 29 | ||||
| -rw-r--r-- | arch/mips/loongson1/common/platform.c | 141 | ||||
| -rw-r--r-- | arch/mips/loongson1/ls1b/board.c | 12 |
9 files changed, 283 insertions, 31 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 4a7e0c13c61d..9ea76ed1c2e4 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
| @@ -1573,6 +1573,7 @@ config CPU_LOONGSON1 | |||
| 1573 | select CPU_HAS_PREFETCH | 1573 | select CPU_HAS_PREFETCH |
| 1574 | select CPU_SUPPORTS_32BIT_KERNEL | 1574 | select CPU_SUPPORTS_32BIT_KERNEL |
| 1575 | select CPU_SUPPORTS_HIGHMEM | 1575 | select CPU_SUPPORTS_HIGHMEM |
| 1576 | select CPU_SUPPORTS_CPUFREQ | ||
| 1576 | 1577 | ||
| 1577 | config CPU_BMIPS32_3300 | 1578 | config CPU_BMIPS32_3300 |
| 1578 | select SMP_UP if SMP | 1579 | select SMP_UP if SMP |
diff --git a/arch/mips/include/asm/mach-loongson1/cpufreq.h b/arch/mips/include/asm/mach-loongson1/cpufreq.h new file mode 100644 index 000000000000..e7765ce30bcf --- /dev/null +++ b/arch/mips/include/asm/mach-loongson1/cpufreq.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2014 Zhang, Keguang <keguang.zhang@gmail.com> | ||
| 3 | * | ||
| 4 | * Loongson 1 CPUFreq 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 | |||
| 13 | #ifndef __ASM_MACH_LOONGSON1_CPUFREQ_H | ||
| 14 | #define __ASM_MACH_LOONGSON1_CPUFREQ_H | ||
| 15 | |||
| 16 | struct plat_ls1x_cpufreq { | ||
| 17 | const char *clk_name; /* CPU clk */ | ||
| 18 | const char *osc_clk_name; /* OSC clk */ | ||
| 19 | unsigned int max_freq; /* in kHz */ | ||
| 20 | unsigned int min_freq; /* in kHz */ | ||
| 21 | }; | ||
| 22 | |||
| 23 | #endif /* __ASM_MACH_LOONGSON1_CPUFREQ_H */ | ||
diff --git a/arch/mips/include/asm/mach-loongson1/loongson1.h b/arch/mips/include/asm/mach-loongson1/loongson1.h index 5c437c2ba6b3..20e0c2b155dd 100644 --- a/arch/mips/include/asm/mach-loongson1/loongson1.h +++ b/arch/mips/include/asm/mach-loongson1/loongson1.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #define DEFAULT_MEMSIZE 256 /* If no memsize provided */ | 16 | #define DEFAULT_MEMSIZE 256 /* If no memsize provided */ |
| 17 | 17 | ||
| 18 | /* Loongson 1 Register Bases */ | 18 | /* Loongson 1 Register Bases */ |
| 19 | #define LS1X_MUX_BASE 0x1fd00420 | ||
| 19 | #define LS1X_INTC_BASE 0x1fd01040 | 20 | #define LS1X_INTC_BASE 0x1fd01040 |
| 20 | #define LS1X_EHCI_BASE 0x1fe00000 | 21 | #define LS1X_EHCI_BASE 0x1fe00000 |
| 21 | #define LS1X_OHCI_BASE 0x1fe08000 | 22 | #define LS1X_OHCI_BASE 0x1fe08000 |
| @@ -31,7 +32,10 @@ | |||
| 31 | #define LS1X_I2C0_BASE 0x1fe58000 | 32 | #define LS1X_I2C0_BASE 0x1fe58000 |
| 32 | #define LS1X_I2C1_BASE 0x1fe68000 | 33 | #define LS1X_I2C1_BASE 0x1fe68000 |
| 33 | #define LS1X_I2C2_BASE 0x1fe70000 | 34 | #define LS1X_I2C2_BASE 0x1fe70000 |
| 34 | #define LS1X_PWM_BASE 0x1fe5c000 | 35 | #define LS1X_PWM0_BASE 0x1fe5c000 |
| 36 | #define LS1X_PWM1_BASE 0x1fe5c010 | ||
| 37 | #define LS1X_PWM2_BASE 0x1fe5c020 | ||
| 38 | #define LS1X_PWM3_BASE 0x1fe5c030 | ||
| 35 | #define LS1X_WDT_BASE 0x1fe5c060 | 39 | #define LS1X_WDT_BASE 0x1fe5c060 |
| 36 | #define LS1X_RTC_BASE 0x1fe64000 | 40 | #define LS1X_RTC_BASE 0x1fe64000 |
| 37 | #define LS1X_AC97_BASE 0x1fe74000 | 41 | #define LS1X_AC97_BASE 0x1fe74000 |
| @@ -39,6 +43,8 @@ | |||
| 39 | #define LS1X_CLK_BASE 0x1fe78030 | 43 | #define LS1X_CLK_BASE 0x1fe78030 |
| 40 | 44 | ||
| 41 | #include <regs-clk.h> | 45 | #include <regs-clk.h> |
| 46 | #include <regs-mux.h> | ||
| 47 | #include <regs-pwm.h> | ||
| 42 | #include <regs-wdt.h> | 48 | #include <regs-wdt.h> |
| 43 | 49 | ||
| 44 | #endif /* __ASM_MACH_LOONGSON1_LOONGSON1_H */ | 50 | #endif /* __ASM_MACH_LOONGSON1_LOONGSON1_H */ |
diff --git a/arch/mips/include/asm/mach-loongson1/platform.h b/arch/mips/include/asm/mach-loongson1/platform.h index 30c13e508fff..47de55e0c835 100644 --- a/arch/mips/include/asm/mach-loongson1/platform.h +++ b/arch/mips/include/asm/mach-loongson1/platform.h | |||
| @@ -13,10 +13,12 @@ | |||
| 13 | 13 | ||
| 14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
| 15 | 15 | ||
| 16 | extern struct platform_device ls1x_uart_device; | 16 | extern struct platform_device ls1x_uart_pdev; |
| 17 | extern struct platform_device ls1x_eth0_device; | 17 | extern struct platform_device ls1x_cpufreq_pdev; |
| 18 | extern struct platform_device ls1x_ehci_device; | 18 | extern struct platform_device ls1x_eth0_pdev; |
| 19 | extern struct platform_device ls1x_rtc_device; | 19 | extern struct platform_device ls1x_eth1_pdev; |
| 20 | extern struct platform_device ls1x_ehci_pdev; | ||
| 21 | extern struct platform_device ls1x_rtc_pdev; | ||
| 20 | 22 | ||
| 21 | extern void __init ls1x_clk_init(void); | 23 | extern void __init ls1x_clk_init(void); |
| 22 | extern void __init ls1x_serial_setup(struct platform_device *pdev); | 24 | extern void __init ls1x_serial_setup(struct platform_device *pdev); |
diff --git a/arch/mips/include/asm/mach-loongson1/regs-clk.h b/arch/mips/include/asm/mach-loongson1/regs-clk.h index fb6a3ff9318f..ee2445b10fc3 100644 --- a/arch/mips/include/asm/mach-loongson1/regs-clk.h +++ b/arch/mips/include/asm/mach-loongson1/regs-clk.h | |||
| @@ -20,15 +20,32 @@ | |||
| 20 | 20 | ||
| 21 | /* Clock PLL Divisor Register Bits */ | 21 | /* Clock PLL Divisor Register Bits */ |
| 22 | #define DIV_DC_EN (0x1 << 31) | 22 | #define DIV_DC_EN (0x1 << 31) |
| 23 | #define DIV_DC_RST (0x1 << 30) | ||
| 23 | #define DIV_CPU_EN (0x1 << 25) | 24 | #define DIV_CPU_EN (0x1 << 25) |
| 25 | #define DIV_CPU_RST (0x1 << 24) | ||
| 24 | #define DIV_DDR_EN (0x1 << 19) | 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 | ||
| 25 | 34 | ||
| 26 | #define DIV_DC_SHIFT 26 | 35 | #define DIV_DC_SHIFT 26 |
| 27 | #define DIV_CPU_SHIFT 20 | 36 | #define DIV_CPU_SHIFT 20 |
| 28 | #define DIV_DDR_SHIFT 14 | 37 | #define DIV_DDR_SHIFT 14 |
| 29 | 38 | ||
| 30 | #define DIV_DC_WIDTH 5 | 39 | #define DIV_DC_WIDTH 4 |
| 31 | #define DIV_CPU_WIDTH 5 | 40 | #define DIV_CPU_WIDTH 4 |
| 32 | #define DIV_DDR_WIDTH 5 | 41 | #define DIV_DDR_WIDTH 4 |
| 42 | |||
| 43 | #define BYPASS_DC_SHIFT 12 | ||
| 44 | #define BYPASS_DDR_SHIFT 10 | ||
| 45 | #define BYPASS_CPU_SHIFT 8 | ||
| 46 | |||
| 47 | #define BYPASS_DC_WIDTH 1 | ||
| 48 | #define BYPASS_DDR_WIDTH 1 | ||
| 49 | #define BYPASS_CPU_WIDTH 1 | ||
| 33 | 50 | ||
| 34 | #endif /* __ASM_MACH_LOONGSON1_REGS_CLK_H */ | 51 | #endif /* __ASM_MACH_LOONGSON1_REGS_CLK_H */ |
diff --git a/arch/mips/include/asm/mach-loongson1/regs-mux.h b/arch/mips/include/asm/mach-loongson1/regs-mux.h new file mode 100644 index 000000000000..fb1e36efaa19 --- /dev/null +++ b/arch/mips/include/asm/mach-loongson1/regs-mux.h | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2014 Zhang, Keguang <keguang.zhang@gmail.com> | ||
| 3 | * | ||
| 4 | * Loongson 1 MUX Register Definitions. | ||
| 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_LOONGSON1_REGS_MUX_H | ||
| 13 | #define __ASM_MACH_LOONGSON1_REGS_MUX_H | ||
| 14 | |||
| 15 | #define LS1X_MUX_REG(x) \ | ||
| 16 | ((void __iomem *)KSEG1ADDR(LS1X_MUX_BASE + (x))) | ||
| 17 | |||
| 18 | #define LS1X_MUX_CTRL0 LS1X_MUX_REG(0x0) | ||
| 19 | #define LS1X_MUX_CTRL1 LS1X_MUX_REG(0x4) | ||
| 20 | |||
| 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 | ||
| 50 | |||
| 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 | ||
| 66 | |||
| 67 | #endif /* __ASM_MACH_LOONGSON1_REGS_MUX_H */ | ||
diff --git a/arch/mips/include/asm/mach-loongson1/regs-pwm.h b/arch/mips/include/asm/mach-loongson1/regs-pwm.h new file mode 100644 index 000000000000..99f2bcc586f0 --- /dev/null +++ b/arch/mips/include/asm/mach-loongson1/regs-pwm.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2014 Zhang, Keguang <keguang.zhang@gmail.com> | ||
| 3 | * | ||
| 4 | * Loongson 1 PWM Register Definitions. | ||
| 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_LOONGSON1_REGS_PWM_H | ||
| 13 | #define __ASM_MACH_LOONGSON1_REGS_PWM_H | ||
| 14 | |||
| 15 | /* Loongson 1 PWM Timer Register Definitions */ | ||
| 16 | #define PWM_CNT 0x0 | ||
| 17 | #define PWM_HRC 0x4 | ||
| 18 | #define PWM_LRC 0x8 | ||
| 19 | #define PWM_CTRL 0xc | ||
| 20 | |||
| 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 | ||
| 28 | |||
| 29 | #endif /* __ASM_MACH_LOONGSON1_REGS_PWM_H */ | ||
diff --git a/arch/mips/loongson1/common/platform.c b/arch/mips/loongson1/common/platform.c index fdf8cb5987a4..ddf1d4cbf31e 100644 --- a/arch/mips/loongson1/common/platform.c +++ b/arch/mips/loongson1/common/platform.c | |||
| @@ -16,8 +16,10 @@ | |||
| 16 | #include <linux/usb/ehci_pdriver.h> | 16 | #include <linux/usb/ehci_pdriver.h> |
| 17 | #include <asm-generic/sizes.h> | 17 | #include <asm-generic/sizes.h> |
| 18 | 18 | ||
| 19 | #include <cpufreq.h> | ||
| 19 | #include <loongson1.h> | 20 | #include <loongson1.h> |
| 20 | 21 | ||
| 22 | /* 8250/16550 compatible UART */ | ||
| 21 | #define LS1X_UART(_id) \ | 23 | #define LS1X_UART(_id) \ |
| 22 | { \ | 24 | { \ |
| 23 | .mapbase = LS1X_UART ## _id ## _BASE, \ | 25 | .mapbase = LS1X_UART ## _id ## _BASE, \ |
| @@ -27,7 +29,7 @@ | |||
| 27 | .type = PORT_16550A, \ | 29 | .type = PORT_16550A, \ |
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | static struct plat_serial8250_port ls1x_serial8250_port[] = { | 32 | static struct plat_serial8250_port ls1x_serial8250_pdata[] = { |
| 31 | LS1X_UART(0), | 33 | LS1X_UART(0), |
| 32 | LS1X_UART(1), | 34 | LS1X_UART(1), |
| 33 | LS1X_UART(2), | 35 | LS1X_UART(2), |
| @@ -35,11 +37,11 @@ static struct plat_serial8250_port ls1x_serial8250_port[] = { | |||
| 35 | {}, | 37 | {}, |
| 36 | }; | 38 | }; |
| 37 | 39 | ||
| 38 | struct platform_device ls1x_uart_device = { | 40 | struct platform_device ls1x_uart_pdev = { |
| 39 | .name = "serial8250", | 41 | .name = "serial8250", |
| 40 | .id = PLAT8250_DEV_PLATFORM, | 42 | .id = PLAT8250_DEV_PLATFORM, |
| 41 | .dev = { | 43 | .dev = { |
| 42 | .platform_data = ls1x_serial8250_port, | 44 | .platform_data = ls1x_serial8250_pdata, |
| 43 | }, | 45 | }, |
| 44 | }; | 46 | }; |
| 45 | 47 | ||
| @@ -48,16 +50,97 @@ void __init ls1x_serial_setup(struct platform_device *pdev) | |||
| 48 | struct clk *clk; | 50 | struct clk *clk; |
| 49 | struct plat_serial8250_port *p; | 51 | struct plat_serial8250_port *p; |
| 50 | 52 | ||
| 51 | clk = clk_get(NULL, pdev->name); | 53 | clk = clk_get(&pdev->dev, pdev->name); |
| 52 | if (IS_ERR(clk)) | 54 | if (IS_ERR(clk)) { |
| 53 | panic("unable to get %s clock, err=%ld", | 55 | pr_err("unable to get %s clock, err=%ld", |
| 54 | pdev->name, PTR_ERR(clk)); | 56 | pdev->name, PTR_ERR(clk)); |
| 57 | return; | ||
| 58 | } | ||
| 59 | clk_prepare_enable(clk); | ||
| 55 | 60 | ||
| 56 | for (p = pdev->dev.platform_data; p->flags != 0; ++p) | 61 | for (p = pdev->dev.platform_data; p->flags != 0; ++p) |
| 57 | p->uartclk = clk_get_rate(clk); | 62 | p->uartclk = clk_get_rate(clk); |
| 58 | } | 63 | } |
| 59 | 64 | ||
| 65 | /* CPUFreq */ | ||
| 66 | static struct plat_ls1x_cpufreq ls1x_cpufreq_pdata = { | ||
| 67 | .clk_name = "cpu_clk", | ||
| 68 | .osc_clk_name = "osc_33m_clk", | ||
| 69 | .max_freq = 266 * 1000, | ||
| 70 | .min_freq = 33 * 1000, | ||
| 71 | }; | ||
| 72 | |||
| 73 | struct platform_device ls1x_cpufreq_pdev = { | ||
| 74 | .name = "ls1x-cpufreq", | ||
| 75 | .dev = { | ||
| 76 | .platform_data = &ls1x_cpufreq_pdata, | ||
| 77 | }, | ||
| 78 | }; | ||
| 79 | |||
| 60 | /* Synopsys Ethernet GMAC */ | 80 | /* Synopsys Ethernet GMAC */ |
| 81 | static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = { | ||
| 82 | .phy_mask = 0, | ||
| 83 | }; | ||
| 84 | |||
| 85 | static struct stmmac_dma_cfg ls1x_eth_dma_cfg = { | ||
| 86 | .pbl = 1, | ||
| 87 | }; | ||
| 88 | |||
| 89 | int ls1x_eth_mux_init(struct platform_device *pdev, void *priv) | ||
| 90 | { | ||
| 91 | struct plat_stmmacenet_data *plat_dat = NULL; | ||
| 92 | u32 val; | ||
| 93 | |||
| 94 | val = __raw_readl(LS1X_MUX_CTRL1); | ||
| 95 | |||
| 96 | plat_dat = dev_get_platdata(&pdev->dev); | ||
| 97 | if (plat_dat->bus_id) { | ||
| 98 | __raw_writel(__raw_readl(LS1X_MUX_CTRL0) | GMAC1_USE_UART1 | | ||
| 99 | GMAC1_USE_UART0, LS1X_MUX_CTRL0); | ||
| 100 | switch (plat_dat->interface) { | ||
| 101 | case PHY_INTERFACE_MODE_RGMII: | ||
| 102 | val &= ~(GMAC1_USE_TXCLK | GMAC1_USE_PWM23); | ||
| 103 | break; | ||
| 104 | case PHY_INTERFACE_MODE_MII: | ||
| 105 | val |= (GMAC1_USE_TXCLK | GMAC1_USE_PWM23); | ||
| 106 | break; | ||
| 107 | default: | ||
| 108 | pr_err("unsupported mii mode %d\n", | ||
| 109 | plat_dat->interface); | ||
| 110 | return -ENOTSUPP; | ||
| 111 | } | ||
| 112 | val &= ~GMAC1_SHUT; | ||
| 113 | } else { | ||
| 114 | switch (plat_dat->interface) { | ||
| 115 | case PHY_INTERFACE_MODE_RGMII: | ||
| 116 | val &= ~(GMAC0_USE_TXCLK | GMAC0_USE_PWM01); | ||
| 117 | break; | ||
| 118 | case PHY_INTERFACE_MODE_MII: | ||
| 119 | val |= (GMAC0_USE_TXCLK | GMAC0_USE_PWM01); | ||
| 120 | break; | ||
| 121 | default: | ||
| 122 | pr_err("unsupported mii mode %d\n", | ||
| 123 | plat_dat->interface); | ||
| 124 | return -ENOTSUPP; | ||
| 125 | } | ||
| 126 | val &= ~GMAC0_SHUT; | ||
| 127 | } | ||
| 128 | __raw_writel(val, LS1X_MUX_CTRL1); | ||
| 129 | |||
| 130 | return 0; | ||
| 131 | } | ||
| 132 | |||
| 133 | static struct plat_stmmacenet_data ls1x_eth0_pdata = { | ||
| 134 | .bus_id = 0, | ||
| 135 | .phy_addr = -1, | ||
| 136 | .interface = PHY_INTERFACE_MODE_MII, | ||
| 137 | .mdio_bus_data = &ls1x_mdio_bus_data, | ||
| 138 | .dma_cfg = &ls1x_eth_dma_cfg, | ||
| 139 | .has_gmac = 1, | ||
| 140 | .tx_coe = 1, | ||
| 141 | .init = ls1x_eth_mux_init, | ||
| 142 | }; | ||
| 143 | |||
| 61 | static struct resource ls1x_eth0_resources[] = { | 144 | static struct resource ls1x_eth0_resources[] = { |
| 62 | [0] = { | 145 | [0] = { |
| 63 | .start = LS1X_GMAC0_BASE, | 146 | .start = LS1X_GMAC0_BASE, |
| @@ -71,25 +154,47 @@ static struct resource ls1x_eth0_resources[] = { | |||
| 71 | }, | 154 | }, |
| 72 | }; | 155 | }; |
| 73 | 156 | ||
| 74 | static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = { | 157 | struct platform_device ls1x_eth0_pdev = { |
| 75 | .phy_mask = 0, | 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 | }, | ||
| 76 | }; | 165 | }; |
| 77 | 166 | ||
| 78 | static struct plat_stmmacenet_data ls1x_eth_data = { | 167 | static struct plat_stmmacenet_data ls1x_eth1_pdata = { |
| 79 | .bus_id = 0, | 168 | .bus_id = 1, |
| 80 | .phy_addr = -1, | 169 | .phy_addr = -1, |
| 170 | .interface = PHY_INTERFACE_MODE_MII, | ||
| 81 | .mdio_bus_data = &ls1x_mdio_bus_data, | 171 | .mdio_bus_data = &ls1x_mdio_bus_data, |
| 172 | .dma_cfg = &ls1x_eth_dma_cfg, | ||
| 82 | .has_gmac = 1, | 173 | .has_gmac = 1, |
| 83 | .tx_coe = 1, | 174 | .tx_coe = 1, |
| 175 | .init = ls1x_eth_mux_init, | ||
| 84 | }; | 176 | }; |
| 85 | 177 | ||
| 86 | struct platform_device ls1x_eth0_device = { | 178 | static struct resource ls1x_eth1_resources[] = { |
| 179 | [0] = { | ||
| 180 | .start = LS1X_GMAC1_BASE, | ||
| 181 | .end = LS1X_GMAC1_BASE + SZ_64K - 1, | ||
| 182 | .flags = IORESOURCE_MEM, | ||
| 183 | }, | ||
| 184 | [1] = { | ||
| 185 | .name = "macirq", | ||
| 186 | .start = LS1X_GMAC1_IRQ, | ||
| 187 | .flags = IORESOURCE_IRQ, | ||
| 188 | }, | ||
| 189 | }; | ||
| 190 | |||
| 191 | struct platform_device ls1x_eth1_pdev = { | ||
| 87 | .name = "stmmaceth", | 192 | .name = "stmmaceth", |
| 88 | .id = 0, | 193 | .id = 1, |
| 89 | .num_resources = ARRAY_SIZE(ls1x_eth0_resources), | 194 | .num_resources = ARRAY_SIZE(ls1x_eth1_resources), |
| 90 | .resource = ls1x_eth0_resources, | 195 | .resource = ls1x_eth1_resources, |
| 91 | .dev = { | 196 | .dev = { |
| 92 | .platform_data = &ls1x_eth_data, | 197 | .platform_data = &ls1x_eth1_pdata, |
| 93 | }, | 198 | }, |
| 94 | }; | 199 | }; |
| 95 | 200 | ||
| @@ -111,7 +216,7 @@ static struct resource ls1x_ehci_resources[] = { | |||
| 111 | static struct usb_ehci_pdata ls1x_ehci_pdata = { | 216 | static struct usb_ehci_pdata ls1x_ehci_pdata = { |
| 112 | }; | 217 | }; |
| 113 | 218 | ||
| 114 | struct platform_device ls1x_ehci_device = { | 219 | struct platform_device ls1x_ehci_pdev = { |
| 115 | .name = "ehci-platform", | 220 | .name = "ehci-platform", |
| 116 | .id = -1, | 221 | .id = -1, |
| 117 | .num_resources = ARRAY_SIZE(ls1x_ehci_resources), | 222 | .num_resources = ARRAY_SIZE(ls1x_ehci_resources), |
| @@ -123,7 +228,7 @@ struct platform_device ls1x_ehci_device = { | |||
| 123 | }; | 228 | }; |
| 124 | 229 | ||
| 125 | /* Real Time Clock */ | 230 | /* Real Time Clock */ |
| 126 | struct platform_device ls1x_rtc_device = { | 231 | struct platform_device ls1x_rtc_pdev = { |
| 127 | .name = "ls1x-rtc", | 232 | .name = "ls1x-rtc", |
| 128 | .id = -1, | 233 | .id = -1, |
| 129 | }; | 234 | }; |
diff --git a/arch/mips/loongson1/ls1b/board.c b/arch/mips/loongson1/ls1b/board.c index b26b10dac70a..58daeea25739 100644 --- a/arch/mips/loongson1/ls1b/board.c +++ b/arch/mips/loongson1/ls1b/board.c | |||
| @@ -10,17 +10,19 @@ | |||
| 10 | #include <platform.h> | 10 | #include <platform.h> |
| 11 | 11 | ||
| 12 | static struct platform_device *ls1b_platform_devices[] __initdata = { | 12 | static struct platform_device *ls1b_platform_devices[] __initdata = { |
| 13 | &ls1x_uart_device, | 13 | &ls1x_uart_pdev, |
| 14 | &ls1x_eth0_device, | 14 | &ls1x_cpufreq_pdev, |
| 15 | &ls1x_ehci_device, | 15 | &ls1x_eth0_pdev, |
| 16 | &ls1x_rtc_device, | 16 | &ls1x_eth1_pdev, |
| 17 | &ls1x_ehci_pdev, | ||
| 18 | &ls1x_rtc_pdev, | ||
| 17 | }; | 19 | }; |
| 18 | 20 | ||
| 19 | static int __init ls1b_platform_init(void) | 21 | static int __init ls1b_platform_init(void) |
| 20 | { | 22 | { |
| 21 | int err; | 23 | int err; |
| 22 | 24 | ||
| 23 | ls1x_serial_setup(&ls1x_uart_device); | 25 | ls1x_serial_setup(&ls1x_uart_pdev); |
| 24 | 26 | ||
| 25 | err = platform_add_devices(ls1b_platform_devices, | 27 | err = platform_add_devices(ls1b_platform_devices, |
| 26 | ARRAY_SIZE(ls1b_platform_devices)); | 28 | ARRAY_SIZE(ls1b_platform_devices)); |
