18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Platform setup for the Freescale mpc885ads board 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Vitaly Bordug <vbordug@ru.mvista.com> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright 2005 MontaVista Software Inc. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Heavily modified by Scott Wood <scottwood@freescale.com> 98c2ecf20Sopenharmony_ci * Copyright 2007 Freescale Semiconductor, Inc. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public License 128c2ecf20Sopenharmony_ci * version 2. This program is licensed "as is" without any warranty of any 138c2ecf20Sopenharmony_ci * kind, whether express or implied. 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/init.h> 178c2ecf20Sopenharmony_ci#include <linux/module.h> 188c2ecf20Sopenharmony_ci#include <linux/param.h> 198c2ecf20Sopenharmony_ci#include <linux/string.h> 208c2ecf20Sopenharmony_ci#include <linux/ioport.h> 218c2ecf20Sopenharmony_ci#include <linux/device.h> 228c2ecf20Sopenharmony_ci#include <linux/delay.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include <linux/fs_enet_pd.h> 258c2ecf20Sopenharmony_ci#include <linux/fs_uart_pd.h> 268c2ecf20Sopenharmony_ci#include <linux/fsl_devices.h> 278c2ecf20Sopenharmony_ci#include <linux/mii.h> 288c2ecf20Sopenharmony_ci#include <linux/of_address.h> 298c2ecf20Sopenharmony_ci#include <linux/of_fdt.h> 308c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#include <asm/delay.h> 338c2ecf20Sopenharmony_ci#include <asm/io.h> 348c2ecf20Sopenharmony_ci#include <asm/machdep.h> 358c2ecf20Sopenharmony_ci#include <asm/page.h> 368c2ecf20Sopenharmony_ci#include <asm/processor.h> 378c2ecf20Sopenharmony_ci#include <asm/time.h> 388c2ecf20Sopenharmony_ci#include <asm/8xx_immap.h> 398c2ecf20Sopenharmony_ci#include <asm/cpm1.h> 408c2ecf20Sopenharmony_ci#include <asm/fs_pd.h> 418c2ecf20Sopenharmony_ci#include <asm/udbg.h> 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#include "mpc885ads.h" 448c2ecf20Sopenharmony_ci#include "mpc8xx.h" 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic u32 __iomem *bcsr, *bcsr5; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistruct cpm_pin { 498c2ecf20Sopenharmony_ci int port, pin, flags; 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic struct cpm_pin mpc885ads_pins[] = { 538c2ecf20Sopenharmony_ci /* SMC1 */ 548c2ecf20Sopenharmony_ci {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */ 558c2ecf20Sopenharmony_ci {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci /* SMC2 */ 588c2ecf20Sopenharmony_ci#ifndef CONFIG_MPC8xx_SECOND_ETH_FEC2 598c2ecf20Sopenharmony_ci {CPM_PORTE, 21, CPM_PIN_INPUT}, /* RX */ 608c2ecf20Sopenharmony_ci {CPM_PORTE, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ 618c2ecf20Sopenharmony_ci#endif 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci /* SCC3 */ 648c2ecf20Sopenharmony_ci {CPM_PORTA, 9, CPM_PIN_INPUT}, /* RX */ 658c2ecf20Sopenharmony_ci {CPM_PORTA, 8, CPM_PIN_INPUT}, /* TX */ 668c2ecf20Sopenharmony_ci {CPM_PORTC, 4, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */ 678c2ecf20Sopenharmony_ci {CPM_PORTC, 5, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */ 688c2ecf20Sopenharmony_ci {CPM_PORTE, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */ 698c2ecf20Sopenharmony_ci {CPM_PORTE, 17, CPM_PIN_INPUT}, /* CLK5 */ 708c2ecf20Sopenharmony_ci {CPM_PORTE, 16, CPM_PIN_INPUT}, /* CLK6 */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci /* MII1 */ 738c2ecf20Sopenharmony_ci {CPM_PORTA, 0, CPM_PIN_INPUT}, 748c2ecf20Sopenharmony_ci {CPM_PORTA, 1, CPM_PIN_INPUT}, 758c2ecf20Sopenharmony_ci {CPM_PORTA, 2, CPM_PIN_INPUT}, 768c2ecf20Sopenharmony_ci {CPM_PORTA, 3, CPM_PIN_INPUT}, 778c2ecf20Sopenharmony_ci {CPM_PORTA, 4, CPM_PIN_OUTPUT}, 788c2ecf20Sopenharmony_ci {CPM_PORTA, 10, CPM_PIN_OUTPUT}, 798c2ecf20Sopenharmony_ci {CPM_PORTA, 11, CPM_PIN_OUTPUT}, 808c2ecf20Sopenharmony_ci {CPM_PORTB, 19, CPM_PIN_INPUT}, 818c2ecf20Sopenharmony_ci {CPM_PORTB, 31, CPM_PIN_INPUT}, 828c2ecf20Sopenharmony_ci {CPM_PORTC, 12, CPM_PIN_INPUT}, 838c2ecf20Sopenharmony_ci {CPM_PORTC, 13, CPM_PIN_INPUT}, 848c2ecf20Sopenharmony_ci {CPM_PORTE, 30, CPM_PIN_OUTPUT}, 858c2ecf20Sopenharmony_ci {CPM_PORTE, 31, CPM_PIN_OUTPUT}, 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci /* MII2 */ 888c2ecf20Sopenharmony_ci#ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2 898c2ecf20Sopenharmony_ci {CPM_PORTE, 14, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 908c2ecf20Sopenharmony_ci {CPM_PORTE, 15, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 918c2ecf20Sopenharmony_ci {CPM_PORTE, 16, CPM_PIN_OUTPUT}, 928c2ecf20Sopenharmony_ci {CPM_PORTE, 17, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 938c2ecf20Sopenharmony_ci {CPM_PORTE, 18, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 948c2ecf20Sopenharmony_ci {CPM_PORTE, 19, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 958c2ecf20Sopenharmony_ci {CPM_PORTE, 20, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 968c2ecf20Sopenharmony_ci {CPM_PORTE, 21, CPM_PIN_OUTPUT}, 978c2ecf20Sopenharmony_ci {CPM_PORTE, 22, CPM_PIN_OUTPUT}, 988c2ecf20Sopenharmony_ci {CPM_PORTE, 23, CPM_PIN_OUTPUT}, 998c2ecf20Sopenharmony_ci {CPM_PORTE, 24, CPM_PIN_OUTPUT}, 1008c2ecf20Sopenharmony_ci {CPM_PORTE, 25, CPM_PIN_OUTPUT}, 1018c2ecf20Sopenharmony_ci {CPM_PORTE, 26, CPM_PIN_OUTPUT}, 1028c2ecf20Sopenharmony_ci {CPM_PORTE, 27, CPM_PIN_OUTPUT}, 1038c2ecf20Sopenharmony_ci {CPM_PORTE, 28, CPM_PIN_OUTPUT}, 1048c2ecf20Sopenharmony_ci {CPM_PORTE, 29, CPM_PIN_OUTPUT}, 1058c2ecf20Sopenharmony_ci#endif 1068c2ecf20Sopenharmony_ci /* I2C */ 1078c2ecf20Sopenharmony_ci {CPM_PORTB, 26, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN}, 1088c2ecf20Sopenharmony_ci {CPM_PORTB, 27, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN}, 1098c2ecf20Sopenharmony_ci}; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_cistatic void __init init_ioports(void) 1128c2ecf20Sopenharmony_ci{ 1138c2ecf20Sopenharmony_ci int i; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(mpc885ads_pins); i++) { 1168c2ecf20Sopenharmony_ci struct cpm_pin *pin = &mpc885ads_pins[i]; 1178c2ecf20Sopenharmony_ci cpm1_set_pin(pin->port, pin->pin, pin->flags); 1188c2ecf20Sopenharmony_ci } 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX); 1218c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX); 1228c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK5, CPM_CLK_TX); 1238c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK6, CPM_CLK_RX); 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci /* Set FEC1 and FEC2 to MII mode */ 1268c2ecf20Sopenharmony_ci clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180); 1278c2ecf20Sopenharmony_ci} 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cistatic void __init mpc885ads_setup_arch(void) 1308c2ecf20Sopenharmony_ci{ 1318c2ecf20Sopenharmony_ci struct device_node *np; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci cpm_reset(); 1348c2ecf20Sopenharmony_ci init_ioports(); 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci np = of_find_compatible_node(NULL, NULL, "fsl,mpc885ads-bcsr"); 1378c2ecf20Sopenharmony_ci if (!np) { 1388c2ecf20Sopenharmony_ci printk(KERN_CRIT "Could not find fsl,mpc885ads-bcsr node\n"); 1398c2ecf20Sopenharmony_ci return; 1408c2ecf20Sopenharmony_ci } 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci bcsr = of_iomap(np, 0); 1438c2ecf20Sopenharmony_ci bcsr5 = of_iomap(np, 1); 1448c2ecf20Sopenharmony_ci of_node_put(np); 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci if (!bcsr || !bcsr5) { 1478c2ecf20Sopenharmony_ci printk(KERN_CRIT "Could not remap BCSR\n"); 1488c2ecf20Sopenharmony_ci return; 1498c2ecf20Sopenharmony_ci } 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci clrbits32(&bcsr[1], BCSR1_RS232EN_1); 1528c2ecf20Sopenharmony_ci#ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2 1538c2ecf20Sopenharmony_ci setbits32(&bcsr[1], BCSR1_RS232EN_2); 1548c2ecf20Sopenharmony_ci#else 1558c2ecf20Sopenharmony_ci clrbits32(&bcsr[1], BCSR1_RS232EN_2); 1568c2ecf20Sopenharmony_ci#endif 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci clrbits32(bcsr5, BCSR5_MII1_EN); 1598c2ecf20Sopenharmony_ci setbits32(bcsr5, BCSR5_MII1_RST); 1608c2ecf20Sopenharmony_ci udelay(1000); 1618c2ecf20Sopenharmony_ci clrbits32(bcsr5, BCSR5_MII1_RST); 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci#ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2 1648c2ecf20Sopenharmony_ci clrbits32(bcsr5, BCSR5_MII2_EN); 1658c2ecf20Sopenharmony_ci setbits32(bcsr5, BCSR5_MII2_RST); 1668c2ecf20Sopenharmony_ci udelay(1000); 1678c2ecf20Sopenharmony_ci clrbits32(bcsr5, BCSR5_MII2_RST); 1688c2ecf20Sopenharmony_ci#else 1698c2ecf20Sopenharmony_ci setbits32(bcsr5, BCSR5_MII2_EN); 1708c2ecf20Sopenharmony_ci#endif 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci#ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3 1738c2ecf20Sopenharmony_ci clrbits32(&bcsr[4], BCSR4_ETH10_RST); 1748c2ecf20Sopenharmony_ci udelay(1000); 1758c2ecf20Sopenharmony_ci setbits32(&bcsr[4], BCSR4_ETH10_RST); 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci setbits32(&bcsr[1], BCSR1_ETHEN); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci np = of_find_node_by_path("/soc@ff000000/cpm@9c0/serial@a80"); 1808c2ecf20Sopenharmony_ci#else 1818c2ecf20Sopenharmony_ci np = of_find_node_by_path("/soc@ff000000/cpm@9c0/ethernet@a40"); 1828c2ecf20Sopenharmony_ci#endif 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci /* The SCC3 enet registers overlap the SMC1 registers, so 1858c2ecf20Sopenharmony_ci * one of the two must be removed from the device tree. 1868c2ecf20Sopenharmony_ci */ 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci if (np) { 1898c2ecf20Sopenharmony_ci of_detach_node(np); 1908c2ecf20Sopenharmony_ci of_node_put(np); 1918c2ecf20Sopenharmony_ci } 1928c2ecf20Sopenharmony_ci} 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_cistatic int __init mpc885ads_probe(void) 1958c2ecf20Sopenharmony_ci{ 1968c2ecf20Sopenharmony_ci return of_machine_is_compatible("fsl,mpc885ads"); 1978c2ecf20Sopenharmony_ci} 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_cistatic const struct of_device_id of_bus_ids[] __initconst = { 2008c2ecf20Sopenharmony_ci { .name = "soc", }, 2018c2ecf20Sopenharmony_ci { .name = "cpm", }, 2028c2ecf20Sopenharmony_ci { .name = "localbus", }, 2038c2ecf20Sopenharmony_ci {}, 2048c2ecf20Sopenharmony_ci}; 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_cistatic int __init declare_of_platform_devices(void) 2078c2ecf20Sopenharmony_ci{ 2088c2ecf20Sopenharmony_ci /* Publish the QE devices */ 2098c2ecf20Sopenharmony_ci of_platform_bus_probe(NULL, of_bus_ids, NULL); 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci return 0; 2128c2ecf20Sopenharmony_ci} 2138c2ecf20Sopenharmony_cimachine_device_initcall(mpc885_ads, declare_of_platform_devices); 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_cidefine_machine(mpc885_ads) { 2168c2ecf20Sopenharmony_ci .name = "Freescale MPC885 ADS", 2178c2ecf20Sopenharmony_ci .probe = mpc885ads_probe, 2188c2ecf20Sopenharmony_ci .setup_arch = mpc885ads_setup_arch, 2198c2ecf20Sopenharmony_ci .init_IRQ = mpc8xx_pics_init, 2208c2ecf20Sopenharmony_ci .get_irq = mpc8xx_get_irq, 2218c2ecf20Sopenharmony_ci .restart = mpc8xx_restart, 2228c2ecf20Sopenharmony_ci .calibrate_decr = mpc8xx_calibrate_decr, 2238c2ecf20Sopenharmony_ci .progress = udbg_progress, 2248c2ecf20Sopenharmony_ci}; 225