diff options
author | Manuel Lauss <manuel.lauss@googlemail.com> | 2011-05-08 04:42:17 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-05-19 04:55:45 -0400 |
commit | 80130204b43ce9c3b50924e4c2d44e9f2881f8c3 (patch) | |
tree | b136768ee20f226dbe0c55e1957f19e882784a5b /arch/mips/include | |
parent | adcb86279f1e4d7a1a9f267b49441aecf4a5110a (diff) |
MIPS: Alchemy: Rewrite UART setup and constants.
Detect CPU type at runtime and setup uarts accordingly; also clean up the
uart base address mess in the process as far as possible.
Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
To: Linux-MIPS <linux-mips@linux-mips.org>
Cc: Florian Fainelli <florian@openwrt.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Patchwork: https://patchwork.linux-mips.org/patch/2352/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org
Diffstat (limited to 'arch/mips/include')
-rw-r--r-- | arch/mips/include/asm/mach-au1x00/au1000.h | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h index eb8f1034e1ef..c4ffb209edf2 100644 --- a/arch/mips/include/asm/mach-au1x00/au1000.h +++ b/arch/mips/include/asm/mach-au1x00/au1000.h | |||
@@ -161,6 +161,45 @@ static inline int alchemy_get_cputype(void) | |||
161 | return ALCHEMY_CPU_UNKNOWN; | 161 | return ALCHEMY_CPU_UNKNOWN; |
162 | } | 162 | } |
163 | 163 | ||
164 | /* return number of uarts on a given cputype */ | ||
165 | static inline int alchemy_get_uarts(int type) | ||
166 | { | ||
167 | switch (type) { | ||
168 | case ALCHEMY_CPU_AU1000: | ||
169 | return 4; | ||
170 | case ALCHEMY_CPU_AU1500: | ||
171 | case ALCHEMY_CPU_AU1200: | ||
172 | return 2; | ||
173 | case ALCHEMY_CPU_AU1100: | ||
174 | case ALCHEMY_CPU_AU1550: | ||
175 | return 3; | ||
176 | } | ||
177 | return 0; | ||
178 | } | ||
179 | |||
180 | /* enable an UART block if it isn't already */ | ||
181 | static inline void alchemy_uart_enable(u32 uart_phys) | ||
182 | { | ||
183 | void __iomem *addr = (void __iomem *)KSEG1ADDR(uart_phys); | ||
184 | |||
185 | /* reset, enable clock, deassert reset */ | ||
186 | if ((__raw_readl(addr + 0x100) & 3) != 3) { | ||
187 | __raw_writel(0, addr + 0x100); | ||
188 | wmb(); | ||
189 | __raw_writel(1, addr + 0x100); | ||
190 | wmb(); | ||
191 | } | ||
192 | __raw_writel(3, addr + 0x100); | ||
193 | wmb(); | ||
194 | } | ||
195 | |||
196 | static inline void alchemy_uart_disable(u32 uart_phys) | ||
197 | { | ||
198 | void __iomem *addr = (void __iomem *)KSEG1ADDR(uart_phys); | ||
199 | __raw_writel(0, addr + 0x100); /* UART_MOD_CNTRL */ | ||
200 | wmb(); | ||
201 | } | ||
202 | |||
164 | static inline void alchemy_uart_putchar(u32 uart_phys, u8 c) | 203 | static inline void alchemy_uart_putchar(u32 uart_phys, u8 c) |
165 | { | 204 | { |
166 | void __iomem *base = (void __iomem *)KSEG1ADDR(uart_phys); | 205 | void __iomem *base = (void __iomem *)KSEG1ADDR(uart_phys); |
@@ -634,6 +673,10 @@ enum soc_au1200_ints { | |||
634 | */ | 673 | */ |
635 | 674 | ||
636 | #define AU1000_IC0_PHYS_ADDR 0x10400000 /* 01234 */ | 675 | #define AU1000_IC0_PHYS_ADDR 0x10400000 /* 01234 */ |
676 | #define AU1000_UART0_PHYS_ADDR 0x11100000 /* 01234 */ | ||
677 | #define AU1000_UART1_PHYS_ADDR 0x11200000 /* 0234 */ | ||
678 | #define AU1000_UART2_PHYS_ADDR 0x11300000 /* 0 */ | ||
679 | #define AU1000_UART3_PHYS_ADDR 0x11400000 /* 0123 */ | ||
637 | #define AU1000_IC1_PHYS_ADDR 0x11800000 /* 01234 */ | 680 | #define AU1000_IC1_PHYS_ADDR 0x11800000 /* 01234 */ |
638 | #define AU1550_DBDMA_PHYS_ADDR 0x14002000 /* 34 */ | 681 | #define AU1550_DBDMA_PHYS_ADDR 0x14002000 /* 34 */ |
639 | #define AU1550_DBDMA_CONF_PHYS_ADDR 0x14003000 /* 34 */ | 682 | #define AU1550_DBDMA_CONF_PHYS_ADDR 0x14003000 /* 34 */ |
@@ -660,10 +703,6 @@ enum soc_au1200_ints { | |||
660 | #define MACDMA0_PHYS_ADDR 0x14004000 | 703 | #define MACDMA0_PHYS_ADDR 0x14004000 |
661 | #define MACDMA1_PHYS_ADDR 0x14004200 | 704 | #define MACDMA1_PHYS_ADDR 0x14004200 |
662 | #define I2S_PHYS_ADDR 0x11000000 | 705 | #define I2S_PHYS_ADDR 0x11000000 |
663 | #define UART0_PHYS_ADDR 0x11100000 | ||
664 | #define UART1_PHYS_ADDR 0x11200000 | ||
665 | #define UART2_PHYS_ADDR 0x11300000 | ||
666 | #define UART3_PHYS_ADDR 0x11400000 | ||
667 | #define SSI0_PHYS_ADDR 0x11600000 | 706 | #define SSI0_PHYS_ADDR 0x11600000 |
668 | #define SSI1_PHYS_ADDR 0x11680000 | 707 | #define SSI1_PHYS_ADDR 0x11680000 |
669 | #define SYS_PHYS_ADDR 0x11900000 | 708 | #define SYS_PHYS_ADDR 0x11900000 |
@@ -695,8 +734,6 @@ enum soc_au1200_ints { | |||
695 | #define MACDMA0_PHYS_ADDR 0x14004000 | 734 | #define MACDMA0_PHYS_ADDR 0x14004000 |
696 | #define MACDMA1_PHYS_ADDR 0x14004200 | 735 | #define MACDMA1_PHYS_ADDR 0x14004200 |
697 | #define I2S_PHYS_ADDR 0x11000000 | 736 | #define I2S_PHYS_ADDR 0x11000000 |
698 | #define UART0_PHYS_ADDR 0x11100000 | ||
699 | #define UART3_PHYS_ADDR 0x11400000 | ||
700 | #define GPIO2_PHYS_ADDR 0x11700000 | 737 | #define GPIO2_PHYS_ADDR 0x11700000 |
701 | #define SYS_PHYS_ADDR 0x11900000 | 738 | #define SYS_PHYS_ADDR 0x11900000 |
702 | #define PCI_MEM_PHYS_ADDR 0x400000000ULL | 739 | #define PCI_MEM_PHYS_ADDR 0x400000000ULL |
@@ -732,9 +769,6 @@ enum soc_au1200_ints { | |||
732 | #define MACDMA0_PHYS_ADDR 0x14004000 | 769 | #define MACDMA0_PHYS_ADDR 0x14004000 |
733 | #define MACDMA1_PHYS_ADDR 0x14004200 | 770 | #define MACDMA1_PHYS_ADDR 0x14004200 |
734 | #define I2S_PHYS_ADDR 0x11000000 | 771 | #define I2S_PHYS_ADDR 0x11000000 |
735 | #define UART0_PHYS_ADDR 0x11100000 | ||
736 | #define UART1_PHYS_ADDR 0x11200000 | ||
737 | #define UART3_PHYS_ADDR 0x11400000 | ||
738 | #define SSI0_PHYS_ADDR 0x11600000 | 772 | #define SSI0_PHYS_ADDR 0x11600000 |
739 | #define SSI1_PHYS_ADDR 0x11680000 | 773 | #define SSI1_PHYS_ADDR 0x11680000 |
740 | #define GPIO2_PHYS_ADDR 0x11700000 | 774 | #define GPIO2_PHYS_ADDR 0x11700000 |
@@ -758,9 +792,6 @@ enum soc_au1200_ints { | |||
758 | #define MACEN_PHYS_ADDR 0x10520000 | 792 | #define MACEN_PHYS_ADDR 0x10520000 |
759 | #define MACDMA0_PHYS_ADDR 0x14004000 | 793 | #define MACDMA0_PHYS_ADDR 0x14004000 |
760 | #define MACDMA1_PHYS_ADDR 0x14004200 | 794 | #define MACDMA1_PHYS_ADDR 0x14004200 |
761 | #define UART0_PHYS_ADDR 0x11100000 | ||
762 | #define UART1_PHYS_ADDR 0x11200000 | ||
763 | #define UART3_PHYS_ADDR 0x11400000 | ||
764 | #define GPIO2_PHYS_ADDR 0x11700000 | 795 | #define GPIO2_PHYS_ADDR 0x11700000 |
765 | #define SYS_PHYS_ADDR 0x11900000 | 796 | #define SYS_PHYS_ADDR 0x11900000 |
766 | #define PE_PHYS_ADDR 0x14008000 | 797 | #define PE_PHYS_ADDR 0x14008000 |
@@ -786,8 +817,6 @@ enum soc_au1200_ints { | |||
786 | #define CIM_PHYS_ADDR 0x14004000 | 817 | #define CIM_PHYS_ADDR 0x14004000 |
787 | #define USBM_PHYS_ADDR 0x14020000 | 818 | #define USBM_PHYS_ADDR 0x14020000 |
788 | #define USBH_PHYS_ADDR 0x14020100 | 819 | #define USBH_PHYS_ADDR 0x14020100 |
789 | #define UART0_PHYS_ADDR 0x11100000 | ||
790 | #define UART1_PHYS_ADDR 0x11200000 | ||
791 | #define GPIO2_PHYS_ADDR 0x11700000 | 820 | #define GPIO2_PHYS_ADDR 0x11700000 |
792 | #define SYS_PHYS_ADDR 0x11900000 | 821 | #define SYS_PHYS_ADDR 0x11900000 |
793 | #define PSC0_PHYS_ADDR 0x11A00000 | 822 | #define PSC0_PHYS_ADDR 0x11A00000 |