Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/527x/config.c |
| 5 | * |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 6 | * Sub-architcture dependent initialization code for the Freescale |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * 5270/5271 CPUs. |
| 8 | * |
| 9 | * Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com) |
| 10 | * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com) |
| 11 | */ |
| 12 | |
| 13 | /***************************************************************************/ |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/param.h> |
| 17 | #include <linux/init.h> |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 18 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm/machdep.h> |
| 20 | #include <asm/coldfire.h> |
| 21 | #include <asm/mcfsim.h> |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 22 | #include <asm/mcfuart.h> |
Greg Ungerer | 748dddb | 2012-04-17 14:21:51 +1000 | [diff] [blame] | 23 | #include <asm/mcfgpio.h> |
| 24 | |
| 25 | /***************************************************************************/ |
| 26 | |
| 27 | struct mcf_gpio_chip mcf_gpio_chips[] = { |
| 28 | #if defined(CONFIG_M5271) |
| 29 | MCFGPS(PIRQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR), |
| 30 | MCFGPF(ADDR, 13, 3), |
| 31 | MCFGPF(DATAH, 16, 8), |
| 32 | MCFGPF(DATAL, 24, 8), |
| 33 | MCFGPF(BUSCTL, 32, 8), |
| 34 | MCFGPF(BS, 40, 4), |
| 35 | MCFGPF(CS, 49, 7), |
| 36 | MCFGPF(SDRAM, 56, 6), |
| 37 | MCFGPF(FECI2C, 64, 4), |
| 38 | MCFGPF(UARTH, 72, 2), |
| 39 | MCFGPF(UARTL, 80, 8), |
| 40 | MCFGPF(QSPI, 88, 5), |
| 41 | MCFGPF(TIMER, 96, 8), |
| 42 | #elif defined(CONFIG_M5275) |
| 43 | MCFGPS(PIRQ, 1, 7, MCFEPORT_EPDDR, MCFEPORT_EPDR, MCFEPORT_EPPDR), |
| 44 | MCFGPF(BUSCTL, 8, 8), |
| 45 | MCFGPF(ADDR, 21, 3), |
| 46 | MCFGPF(CS, 25, 7), |
| 47 | MCFGPF(FEC0H, 32, 8), |
| 48 | MCFGPF(FEC0L, 40, 8), |
| 49 | MCFGPF(FECI2C, 48, 6), |
| 50 | MCFGPF(QSPI, 56, 7), |
| 51 | MCFGPF(SDRAM, 64, 8), |
| 52 | MCFGPF(TIMERH, 72, 4), |
| 53 | MCFGPF(TIMERL, 80, 4), |
| 54 | MCFGPF(UARTL, 88, 8), |
| 55 | MCFGPF(FEC1H, 96, 8), |
| 56 | MCFGPF(FEC1L, 104, 8), |
| 57 | MCFGPF(BS, 114, 2), |
| 58 | MCFGPF(IRQ, 121, 7), |
| 59 | MCFGPF(USBH, 128, 1), |
| 60 | MCFGPF(USBL, 136, 8), |
| 61 | MCFGPF(UARTH, 144, 4), |
| 62 | #endif |
| 63 | }; |
| 64 | |
| 65 | unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | /***************************************************************************/ |
| 68 | |
Steven King | 83ca600 | 2012-05-06 12:22:53 -0700 | [diff] [blame] | 69 | #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) |
Steven King | 91d6041 | 2010-01-22 12:43:03 -0800 | [diff] [blame] | 70 | |
| 71 | static void __init m527x_qspi_init(void) |
| 72 | { |
| 73 | #if defined(CONFIG_M5271) |
| 74 | u16 par; |
| 75 | |
| 76 | /* setup QSPS pins for QSPI with gpio CS control */ |
| 77 | writeb(0x1f, MCFGPIO_PAR_QSPI); |
| 78 | /* and CS2 & CS3 as gpio */ |
| 79 | par = readw(MCFGPIO_PAR_TIMER); |
| 80 | par &= 0x3f3f; |
| 81 | writew(par, MCFGPIO_PAR_TIMER); |
| 82 | #elif defined(CONFIG_M5275) |
| 83 | /* setup QSPS pins for QSPI with gpio CS control */ |
| 84 | writew(0x003e, MCFGPIO_PAR_QSPI); |
| 85 | #endif |
| 86 | } |
Steven King | 91d6041 | 2010-01-22 12:43:03 -0800 | [diff] [blame] | 87 | |
Steven King | 83ca600 | 2012-05-06 12:22:53 -0700 | [diff] [blame] | 88 | #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */ |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 89 | |
| 90 | /***************************************************************************/ |
| 91 | |
Greg Ungerer | 1eb1391 | 2011-12-24 00:59:03 +1000 | [diff] [blame] | 92 | static void __init m527x_uarts_init(void) |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 93 | { |
| 94 | u16 sepmask; |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 95 | |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 96 | /* |
| 97 | * External Pin Mask Setting & Enable External Pin for Interface |
| 98 | */ |
| 99 | sepmask = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART); |
Greg Ungerer | 1eb1391 | 2011-12-24 00:59:03 +1000 | [diff] [blame] | 100 | sepmask |= UART0_ENABLE_MASK | UART1_ENABLE_MASK | UART2_ENABLE_MASK; |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 101 | writew(sepmask, MCF_IPSBAR + MCF_GPIO_PAR_UART); |
| 102 | } |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | /***************************************************************************/ |
| 105 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 106 | static void __init m527x_fec_init(void) |
| 107 | { |
| 108 | u16 par; |
| 109 | u8 v; |
| 110 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 111 | /* Set multi-function pins to ethernet mode for fec0 */ |
Richard Retanubun | 592578a | 2009-04-08 11:51:27 +1000 | [diff] [blame] | 112 | #if defined(CONFIG_M5271) |
| 113 | v = readb(MCF_IPSBAR + 0x100047); |
| 114 | writeb(v | 0xf0, MCF_IPSBAR + 0x100047); |
| 115 | #else |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 116 | par = readw(MCF_IPSBAR + 0x100082); |
| 117 | writew(par | 0xf00, MCF_IPSBAR + 0x100082); |
| 118 | v = readb(MCF_IPSBAR + 0x100078); |
| 119 | writeb(v | 0xc0, MCF_IPSBAR + 0x100078); |
| 120 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 121 | /* Set multi-function pins to ethernet mode for fec1 */ |
| 122 | par = readw(MCF_IPSBAR + 0x100082); |
| 123 | writew(par | 0xa0, MCF_IPSBAR + 0x100082); |
| 124 | v = readb(MCF_IPSBAR + 0x100079); |
| 125 | writeb(v | 0xc0, MCF_IPSBAR + 0x100079); |
| 126 | #endif |
| 127 | } |
| 128 | |
| 129 | /***************************************************************************/ |
| 130 | |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 131 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | { |
Greg Ungerer | 35aefb2 | 2012-01-23 15:34:58 +1000 | [diff] [blame] | 133 | mach_sched_init = hw_timer_init; |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 134 | m527x_uarts_init(); |
| 135 | m527x_fec_init(); |
Steven King | 83ca600 | 2012-05-06 12:22:53 -0700 | [diff] [blame] | 136 | #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) |
Steven King | 91d6041 | 2010-01-22 12:43:03 -0800 | [diff] [blame] | 137 | m527x_qspi_init(); |
| 138 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | /***************************************************************************/ |