Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame^] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/548x/config.c |
| 5 | * |
| 6 | * Copyright (C) 2010, Philippe De Muyter <phdm@macqel.be> |
| 7 | */ |
| 8 | |
| 9 | /***************************************************************************/ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/param.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/io.h> |
| 16 | #include <asm/machdep.h> |
| 17 | #include <asm/coldfire.h> |
| 18 | #include <asm/m548xsim.h> |
| 19 | #include <asm/mcfuart.h> |
| 20 | #include <asm/m548xgpt.h> |
| 21 | |
| 22 | /***************************************************************************/ |
| 23 | |
| 24 | static struct mcf_platform_uart m548x_uart_platform[] = { |
| 25 | { |
| 26 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 27 | .irq = 64 + 35, |
| 28 | }, |
| 29 | { |
| 30 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 31 | .irq = 64 + 34, |
| 32 | }, |
| 33 | { |
| 34 | .mapbase = MCF_MBAR + MCFUART_BASE3, |
| 35 | .irq = 64 + 33, |
| 36 | }, |
| 37 | { |
| 38 | .mapbase = MCF_MBAR + MCFUART_BASE4, |
| 39 | .irq = 64 + 32, |
| 40 | }, |
| 41 | }; |
| 42 | |
| 43 | static struct platform_device m548x_uart = { |
| 44 | .name = "mcfuart", |
| 45 | .id = 0, |
| 46 | .dev.platform_data = m548x_uart_platform, |
| 47 | }; |
| 48 | |
| 49 | static struct platform_device *m548x_devices[] __initdata = { |
| 50 | &m548x_uart, |
| 51 | }; |
| 52 | |
| 53 | |
| 54 | /***************************************************************************/ |
| 55 | |
| 56 | static void __init m548x_uart_init_line(int line, int irq) |
| 57 | { |
| 58 | int rts_cts; |
| 59 | |
| 60 | /* enable io pins */ |
| 61 | switch (line) { |
| 62 | case 0: |
| 63 | rts_cts = 0; break; |
| 64 | case 1: |
| 65 | rts_cts = MCF_PAR_PSC_RTS_RTS; break; |
| 66 | case 2: |
| 67 | rts_cts = MCF_PAR_PSC_RTS_RTS | MCF_PAR_PSC_CTS_CTS; break; |
| 68 | case 3: |
| 69 | rts_cts = 0; break; |
| 70 | } |
| 71 | __raw_writeb(MCF_PAR_PSC_TXD | rts_cts | MCF_PAR_PSC_RXD, |
| 72 | MCF_MBAR + MCF_PAR_PSC(line)); |
| 73 | } |
| 74 | |
| 75 | static void __init m548x_uarts_init(void) |
| 76 | { |
| 77 | const int nrlines = ARRAY_SIZE(m548x_uart_platform); |
| 78 | int line; |
| 79 | |
| 80 | for (line = 0; (line < nrlines); line++) |
| 81 | m548x_uart_init_line(line, m548x_uart_platform[line].irq); |
| 82 | } |
| 83 | |
| 84 | /***************************************************************************/ |
| 85 | |
| 86 | static void mcf548x_reset(void) |
| 87 | { |
| 88 | /* disable interrupts and enable the watchdog */ |
| 89 | asm("movew #0x2700, %sr\n"); |
| 90 | __raw_writel(0, MCF_MBAR + MCF_GPT_GMS0); |
| 91 | __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_MBAR + MCF_GPT_GCIR0); |
| 92 | __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4), |
| 93 | MCF_MBAR + MCF_GPT_GMS0); |
| 94 | } |
| 95 | |
| 96 | /***************************************************************************/ |
| 97 | |
| 98 | void __init config_BSP(char *commandp, int size) |
| 99 | { |
| 100 | mach_reset = mcf548x_reset; |
| 101 | m548x_uarts_init(); |
| 102 | } |
| 103 | |
| 104 | /***************************************************************************/ |
| 105 | |
| 106 | static int __init init_BSP(void) |
| 107 | { |
| 108 | |
| 109 | platform_add_devices(m548x_devices, ARRAY_SIZE(m548x_devices)); |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | arch_initcall(init_BSP); |
| 114 | |
| 115 | /***************************************************************************/ |