18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Platform setup for the Embedded Planet EP88xC board 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Author: Scott Wood <scottwood@freescale.com> 58c2ecf20Sopenharmony_ci * Copyright 2007 Freescale Semiconductor, Inc. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public License 88c2ecf20Sopenharmony_ci * version 2. This program is licensed "as is" without any warranty of any 98c2ecf20Sopenharmony_ci * kind, whether express or implied. 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/init.h> 138c2ecf20Sopenharmony_ci#include <linux/of_address.h> 148c2ecf20Sopenharmony_ci#include <linux/of_fdt.h> 158c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <asm/machdep.h> 188c2ecf20Sopenharmony_ci#include <asm/io.h> 198c2ecf20Sopenharmony_ci#include <asm/udbg.h> 208c2ecf20Sopenharmony_ci#include <asm/cpm1.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include "mpc8xx.h" 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistruct cpm_pin { 258c2ecf20Sopenharmony_ci int port, pin, flags; 268c2ecf20Sopenharmony_ci}; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistatic struct cpm_pin ep88xc_pins[] = { 298c2ecf20Sopenharmony_ci /* SMC1 */ 308c2ecf20Sopenharmony_ci {1, 24, CPM_PIN_INPUT}, /* RX */ 318c2ecf20Sopenharmony_ci {1, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci /* SCC2 */ 348c2ecf20Sopenharmony_ci {0, 12, CPM_PIN_INPUT}, /* TX */ 358c2ecf20Sopenharmony_ci {0, 13, CPM_PIN_INPUT}, /* RX */ 368c2ecf20Sopenharmony_ci {2, 8, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CD */ 378c2ecf20Sopenharmony_ci {2, 9, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CTS */ 388c2ecf20Sopenharmony_ci {2, 14, CPM_PIN_INPUT}, /* RTS */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci /* MII1 */ 418c2ecf20Sopenharmony_ci {0, 0, CPM_PIN_INPUT}, 428c2ecf20Sopenharmony_ci {0, 1, CPM_PIN_INPUT}, 438c2ecf20Sopenharmony_ci {0, 2, CPM_PIN_INPUT}, 448c2ecf20Sopenharmony_ci {0, 3, CPM_PIN_INPUT}, 458c2ecf20Sopenharmony_ci {0, 4, CPM_PIN_OUTPUT}, 468c2ecf20Sopenharmony_ci {0, 10, CPM_PIN_OUTPUT}, 478c2ecf20Sopenharmony_ci {0, 11, CPM_PIN_OUTPUT}, 488c2ecf20Sopenharmony_ci {1, 19, CPM_PIN_INPUT}, 498c2ecf20Sopenharmony_ci {1, 31, CPM_PIN_INPUT}, 508c2ecf20Sopenharmony_ci {2, 12, CPM_PIN_INPUT}, 518c2ecf20Sopenharmony_ci {2, 13, CPM_PIN_INPUT}, 528c2ecf20Sopenharmony_ci {3, 8, CPM_PIN_INPUT}, 538c2ecf20Sopenharmony_ci {4, 30, CPM_PIN_OUTPUT}, 548c2ecf20Sopenharmony_ci {4, 31, CPM_PIN_OUTPUT}, 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci /* MII2 */ 578c2ecf20Sopenharmony_ci {4, 14, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 588c2ecf20Sopenharmony_ci {4, 15, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 598c2ecf20Sopenharmony_ci {4, 16, CPM_PIN_OUTPUT}, 608c2ecf20Sopenharmony_ci {4, 17, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 618c2ecf20Sopenharmony_ci {4, 18, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 628c2ecf20Sopenharmony_ci {4, 19, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 638c2ecf20Sopenharmony_ci {4, 20, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, 648c2ecf20Sopenharmony_ci {4, 21, CPM_PIN_OUTPUT}, 658c2ecf20Sopenharmony_ci {4, 22, CPM_PIN_OUTPUT}, 668c2ecf20Sopenharmony_ci {4, 23, CPM_PIN_OUTPUT}, 678c2ecf20Sopenharmony_ci {4, 24, CPM_PIN_OUTPUT}, 688c2ecf20Sopenharmony_ci {4, 25, CPM_PIN_OUTPUT}, 698c2ecf20Sopenharmony_ci {4, 26, CPM_PIN_OUTPUT}, 708c2ecf20Sopenharmony_ci {4, 27, CPM_PIN_OUTPUT}, 718c2ecf20Sopenharmony_ci {4, 28, CPM_PIN_OUTPUT}, 728c2ecf20Sopenharmony_ci {4, 29, CPM_PIN_OUTPUT}, 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci /* USB */ 758c2ecf20Sopenharmony_ci {0, 6, CPM_PIN_INPUT}, /* CLK2 */ 768c2ecf20Sopenharmony_ci {0, 14, CPM_PIN_INPUT}, /* USBOE */ 778c2ecf20Sopenharmony_ci {0, 15, CPM_PIN_INPUT}, /* USBRXD */ 788c2ecf20Sopenharmony_ci {2, 6, CPM_PIN_OUTPUT}, /* USBTXN */ 798c2ecf20Sopenharmony_ci {2, 7, CPM_PIN_OUTPUT}, /* USBTXP */ 808c2ecf20Sopenharmony_ci {2, 10, CPM_PIN_INPUT}, /* USBRXN */ 818c2ecf20Sopenharmony_ci {2, 11, CPM_PIN_INPUT}, /* USBRXP */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci /* Misc */ 848c2ecf20Sopenharmony_ci {1, 26, CPM_PIN_INPUT}, /* BRGO2 */ 858c2ecf20Sopenharmony_ci {1, 27, CPM_PIN_INPUT}, /* BRGO1 */ 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistatic void __init init_ioports(void) 898c2ecf20Sopenharmony_ci{ 908c2ecf20Sopenharmony_ci int i; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(ep88xc_pins); i++) { 938c2ecf20Sopenharmony_ci struct cpm_pin *pin = &ep88xc_pins[i]; 948c2ecf20Sopenharmony_ci cpm1_set_pin(pin->port, pin->pin, pin->flags); 958c2ecf20Sopenharmony_ci } 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX); 988c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_TX); /* USB */ 998c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_RX); 1008c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX); 1018c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX); 1028c2ecf20Sopenharmony_ci} 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistatic u8 __iomem *ep88xc_bcsr; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#define BCSR7_SCC2_ENABLE 0x10 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#define BCSR8_PHY1_ENABLE 0x80 1098c2ecf20Sopenharmony_ci#define BCSR8_PHY1_POWER 0x40 1108c2ecf20Sopenharmony_ci#define BCSR8_PHY2_ENABLE 0x20 1118c2ecf20Sopenharmony_ci#define BCSR8_PHY2_POWER 0x10 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define BCSR9_USB_ENABLE 0x80 1148c2ecf20Sopenharmony_ci#define BCSR9_USB_POWER 0x40 1158c2ecf20Sopenharmony_ci#define BCSR9_USB_HOST 0x20 1168c2ecf20Sopenharmony_ci#define BCSR9_USB_FULL_SPEED_TARGET 0x10 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_cistatic void __init ep88xc_setup_arch(void) 1198c2ecf20Sopenharmony_ci{ 1208c2ecf20Sopenharmony_ci struct device_node *np; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci cpm_reset(); 1238c2ecf20Sopenharmony_ci init_ioports(); 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci np = of_find_compatible_node(NULL, NULL, "fsl,ep88xc-bcsr"); 1268c2ecf20Sopenharmony_ci if (!np) { 1278c2ecf20Sopenharmony_ci printk(KERN_CRIT "Could not find fsl,ep88xc-bcsr node\n"); 1288c2ecf20Sopenharmony_ci return; 1298c2ecf20Sopenharmony_ci } 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci ep88xc_bcsr = of_iomap(np, 0); 1328c2ecf20Sopenharmony_ci of_node_put(np); 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci if (!ep88xc_bcsr) { 1358c2ecf20Sopenharmony_ci printk(KERN_CRIT "Could not remap BCSR\n"); 1368c2ecf20Sopenharmony_ci return; 1378c2ecf20Sopenharmony_ci } 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci setbits8(&ep88xc_bcsr[7], BCSR7_SCC2_ENABLE); 1408c2ecf20Sopenharmony_ci setbits8(&ep88xc_bcsr[8], BCSR8_PHY1_ENABLE | BCSR8_PHY1_POWER | 1418c2ecf20Sopenharmony_ci BCSR8_PHY2_ENABLE | BCSR8_PHY2_POWER); 1428c2ecf20Sopenharmony_ci} 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_cistatic int __init ep88xc_probe(void) 1458c2ecf20Sopenharmony_ci{ 1468c2ecf20Sopenharmony_ci return of_machine_is_compatible("fsl,ep88xc"); 1478c2ecf20Sopenharmony_ci} 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistatic const struct of_device_id of_bus_ids[] __initconst = { 1508c2ecf20Sopenharmony_ci { .name = "soc", }, 1518c2ecf20Sopenharmony_ci { .name = "cpm", }, 1528c2ecf20Sopenharmony_ci { .name = "localbus", }, 1538c2ecf20Sopenharmony_ci {}, 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistatic int __init declare_of_platform_devices(void) 1578c2ecf20Sopenharmony_ci{ 1588c2ecf20Sopenharmony_ci /* Publish the QE devices */ 1598c2ecf20Sopenharmony_ci of_platform_bus_probe(NULL, of_bus_ids, NULL); 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci return 0; 1628c2ecf20Sopenharmony_ci} 1638c2ecf20Sopenharmony_cimachine_device_initcall(ep88xc, declare_of_platform_devices); 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_cidefine_machine(ep88xc) { 1668c2ecf20Sopenharmony_ci .name = "Embedded Planet EP88xC", 1678c2ecf20Sopenharmony_ci .probe = ep88xc_probe, 1688c2ecf20Sopenharmony_ci .setup_arch = ep88xc_setup_arch, 1698c2ecf20Sopenharmony_ci .init_IRQ = mpc8xx_pics_init, 1708c2ecf20Sopenharmony_ci .get_irq = mpc8xx_get_irq, 1718c2ecf20Sopenharmony_ci .restart = mpc8xx_restart, 1728c2ecf20Sopenharmony_ci .calibrate_decr = mpc8xx_calibrate_decr, 1738c2ecf20Sopenharmony_ci .progress = udbg_progress, 1748c2ecf20Sopenharmony_ci}; 175