Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /***************************************************************************/ |
| 3 | |
| 4 | /* |
Greg Ungerer | ece9ae6 | 2014-08-19 11:55:24 +1000 | [diff] [blame] | 5 | * m527x.c -- platform support for ColdFire 527x based boards |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 7 | * Sub-architcture dependent initialization code for the Freescale |
Greg Ungerer | ece9ae6 | 2014-08-19 11:55:24 +1000 | [diff] [blame] | 8 | * 5270/5271 and 5274/5275 CPUs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
| 10 | * Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com) |
| 11 | * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com) |
| 12 | */ |
| 13 | |
| 14 | /***************************************************************************/ |
| 15 | |
Arnd Bergmann | 63aadb7 | 2021-05-31 11:12:55 +0200 | [diff] [blame] | 16 | #include <linux/clkdev.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/param.h> |
| 19 | #include <linux/init.h> |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 20 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/machdep.h> |
| 22 | #include <asm/coldfire.h> |
| 23 | #include <asm/mcfsim.h> |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 24 | #include <asm/mcfuart.h> |
Greg Ungerer | a3d8eb0 | 2012-07-13 16:03:52 +1000 | [diff] [blame] | 25 | #include <asm/mcfclk.h> |
| 26 | |
| 27 | /***************************************************************************/ |
| 28 | |
| 29 | DEFINE_CLK(pll, "pll.0", MCF_CLK); |
| 30 | DEFINE_CLK(sys, "sys.0", MCF_BUSCLK); |
Greg Ungerer | a3d8eb0 | 2012-07-13 16:03:52 +1000 | [diff] [blame] | 31 | |
Arnd Bergmann | 63aadb7 | 2021-05-31 11:12:55 +0200 | [diff] [blame] | 32 | static struct clk_lookup m527x_clk_lookup[] = { |
| 33 | CLKDEV_INIT(NULL, "pll.0", &clk_pll), |
| 34 | CLKDEV_INIT(NULL, "sys.0", &clk_sys), |
| 35 | CLKDEV_INIT("mcfpit.0", NULL, &clk_pll), |
| 36 | CLKDEV_INIT("mcfpit.1", NULL, &clk_pll), |
| 37 | CLKDEV_INIT("mcfpit.2", NULL, &clk_pll), |
| 38 | CLKDEV_INIT("mcfpit.3", NULL, &clk_pll), |
| 39 | CLKDEV_INIT("mcfuart.0", NULL, &clk_sys), |
| 40 | CLKDEV_INIT("mcfuart.1", NULL, &clk_sys), |
| 41 | CLKDEV_INIT("mcfuart.2", NULL, &clk_sys), |
| 42 | CLKDEV_INIT("mcfqspi.0", NULL, &clk_sys), |
| 43 | CLKDEV_INIT("fec.0", NULL, &clk_sys), |
| 44 | CLKDEV_INIT("fec.1", NULL, &clk_sys), |
| 45 | CLKDEV_INIT("imx1-i2c.0", NULL, &clk_sys), |
Greg Ungerer | a3d8eb0 | 2012-07-13 16:03:52 +1000 | [diff] [blame] | 46 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | /***************************************************************************/ |
| 49 | |
Steven King | 91d6041 | 2010-01-22 12:43:03 -0800 | [diff] [blame] | 50 | static void __init m527x_qspi_init(void) |
| 51 | { |
Steven King | 151d14f | 2014-05-14 10:07:55 -0700 | [diff] [blame] | 52 | #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) |
Steven King | 91d6041 | 2010-01-22 12:43:03 -0800 | [diff] [blame] | 53 | #if defined(CONFIG_M5271) |
| 54 | u16 par; |
| 55 | |
| 56 | /* setup QSPS pins for QSPI with gpio CS control */ |
| 57 | writeb(0x1f, MCFGPIO_PAR_QSPI); |
| 58 | /* and CS2 & CS3 as gpio */ |
| 59 | par = readw(MCFGPIO_PAR_TIMER); |
| 60 | par &= 0x3f3f; |
| 61 | writew(par, MCFGPIO_PAR_TIMER); |
| 62 | #elif defined(CONFIG_M5275) |
| 63 | /* setup QSPS pins for QSPI with gpio CS control */ |
| 64 | writew(0x003e, MCFGPIO_PAR_QSPI); |
| 65 | #endif |
Steven King | 83ca600 | 2012-05-06 12:22:53 -0700 | [diff] [blame] | 66 | #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */ |
Steven King | 151d14f | 2014-05-14 10:07:55 -0700 | [diff] [blame] | 67 | } |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 68 | |
| 69 | /***************************************************************************/ |
| 70 | |
Steven King | 2d24b53 | 2014-06-30 09:53:19 -0700 | [diff] [blame] | 71 | static void __init m527x_i2c_init(void) |
| 72 | { |
| 73 | #if IS_ENABLED(CONFIG_I2C_IMX) |
| 74 | #if defined(CONFIG_M5271) |
| 75 | u8 par; |
| 76 | |
| 77 | /* setup Port FECI2C Pin Assignment Register for I2C */ |
| 78 | /* set PAR_SCL to SCL and PAR_SDA to SDA */ |
| 79 | par = readb(MCFGPIO_PAR_FECI2C); |
| 80 | par |= 0x0f; |
| 81 | writeb(par, MCFGPIO_PAR_FECI2C); |
| 82 | #elif defined(CONFIG_M5275) |
| 83 | u16 par; |
| 84 | |
| 85 | /* setup Port FECI2C Pin Assignment Register for I2C */ |
| 86 | /* set PAR_SCL to SCL and PAR_SDA to SDA */ |
| 87 | par = readw(MCFGPIO_PAR_FECI2C); |
| 88 | par |= 0x0f; |
| 89 | writew(par, MCFGPIO_PAR_FECI2C); |
| 90 | #endif |
| 91 | #endif /* IS_ENABLED(CONFIG_I2C_IMX) */ |
| 92 | } |
| 93 | |
| 94 | /***************************************************************************/ |
| 95 | |
Greg Ungerer | 1eb1391 | 2011-12-24 00:59:03 +1000 | [diff] [blame] | 96 | static void __init m527x_uarts_init(void) |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 97 | { |
| 98 | u16 sepmask; |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 99 | |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 100 | /* |
| 101 | * External Pin Mask Setting & Enable External Pin for Interface |
| 102 | */ |
Greg Ungerer | f821e34 | 2012-09-17 12:07:21 +1000 | [diff] [blame] | 103 | sepmask = readw(MCFGPIO_PAR_UART); |
Greg Ungerer | 1eb1391 | 2011-12-24 00:59:03 +1000 | [diff] [blame] | 104 | sepmask |= UART0_ENABLE_MASK | UART1_ENABLE_MASK | UART2_ENABLE_MASK; |
Greg Ungerer | f821e34 | 2012-09-17 12:07:21 +1000 | [diff] [blame] | 105 | writew(sepmask, MCFGPIO_PAR_UART); |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 106 | } |
| 107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | /***************************************************************************/ |
| 109 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 110 | static void __init m527x_fec_init(void) |
| 111 | { |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 112 | u8 v; |
| 113 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 114 | /* Set multi-function pins to ethernet mode for fec0 */ |
Richard Retanubun | 592578a | 2009-04-08 11:51:27 +1000 | [diff] [blame] | 115 | #if defined(CONFIG_M5271) |
Greg Ungerer | f821e34 | 2012-09-17 12:07:21 +1000 | [diff] [blame] | 116 | v = readb(MCFGPIO_PAR_FECI2C); |
| 117 | writeb(v | 0xf0, MCFGPIO_PAR_FECI2C); |
Richard Retanubun | 592578a | 2009-04-08 11:51:27 +1000 | [diff] [blame] | 118 | #else |
Greg Ungerer | 6e42061 | 2015-03-24 11:08:22 +1000 | [diff] [blame] | 119 | u16 par; |
| 120 | |
Greg Ungerer | f821e34 | 2012-09-17 12:07:21 +1000 | [diff] [blame] | 121 | par = readw(MCFGPIO_PAR_FECI2C); |
| 122 | writew(par | 0xf00, MCFGPIO_PAR_FECI2C); |
| 123 | v = readb(MCFGPIO_PAR_FEC0HL); |
| 124 | writeb(v | 0xc0, MCFGPIO_PAR_FEC0HL); |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 125 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 126 | /* Set multi-function pins to ethernet mode for fec1 */ |
Greg Ungerer | f821e34 | 2012-09-17 12:07:21 +1000 | [diff] [blame] | 127 | par = readw(MCFGPIO_PAR_FECI2C); |
| 128 | writew(par | 0xa0, MCFGPIO_PAR_FECI2C); |
| 129 | v = readb(MCFGPIO_PAR_FEC1HL); |
| 130 | writeb(v | 0xc0, MCFGPIO_PAR_FEC1HL); |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 131 | #endif |
| 132 | } |
| 133 | |
| 134 | /***************************************************************************/ |
| 135 | |
Greg Ungerer | e206da0 | 2008-02-01 17:34:40 +1000 | [diff] [blame] | 136 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { |
Greg Ungerer | 35aefb2 | 2012-01-23 15:34:58 +1000 | [diff] [blame] | 138 | mach_sched_init = hw_timer_init; |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 139 | m527x_uarts_init(); |
| 140 | m527x_fec_init(); |
Steven King | 91d6041 | 2010-01-22 12:43:03 -0800 | [diff] [blame] | 141 | m527x_qspi_init(); |
Steven King | 2d24b53 | 2014-06-30 09:53:19 -0700 | [diff] [blame] | 142 | m527x_i2c_init(); |
Arnd Bergmann | 63aadb7 | 2021-05-31 11:12:55 +0200 | [diff] [blame] | 143 | clkdev_add_table(m527x_clk_lookup, ARRAY_SIZE(m527x_clk_lookup)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | /***************************************************************************/ |