18c2ecf20Sopenharmony_ci/*arch/powerpc/platforms/8xx/mpc86xads_setup.c 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * Platform setup for the Freescale mpc86xads board 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Vitaly Bordug <vbordug@ru.mvista.com> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright 2005 MontaVista Software Inc. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Heavily modified by Scott Wood <scottwood@freescale.com> 108c2ecf20Sopenharmony_ci * Copyright 2007 Freescale Semiconductor, Inc. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * This file is licensed under the terms of the GNU General Public License 138c2ecf20Sopenharmony_ci * version 2. This program is licensed "as is" without any warranty of any 148c2ecf20Sopenharmony_ci * kind, whether express or implied. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <linux/init.h> 188c2ecf20Sopenharmony_ci#include <linux/of_address.h> 198c2ecf20Sopenharmony_ci#include <linux/of_fdt.h> 208c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <asm/io.h> 238c2ecf20Sopenharmony_ci#include <asm/machdep.h> 248c2ecf20Sopenharmony_ci#include <asm/time.h> 258c2ecf20Sopenharmony_ci#include <asm/8xx_immap.h> 268c2ecf20Sopenharmony_ci#include <asm/cpm1.h> 278c2ecf20Sopenharmony_ci#include <asm/fs_pd.h> 288c2ecf20Sopenharmony_ci#include <asm/udbg.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include "mpc86xads.h" 318c2ecf20Sopenharmony_ci#include "mpc8xx.h" 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct cpm_pin { 348c2ecf20Sopenharmony_ci int port, pin, flags; 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistatic struct cpm_pin mpc866ads_pins[] = { 388c2ecf20Sopenharmony_ci /* SMC1 */ 398c2ecf20Sopenharmony_ci {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */ 408c2ecf20Sopenharmony_ci {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci /* SMC2 */ 438c2ecf20Sopenharmony_ci {CPM_PORTB, 21, CPM_PIN_INPUT}, /* RX */ 448c2ecf20Sopenharmony_ci {CPM_PORTB, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci /* SCC1 */ 478c2ecf20Sopenharmony_ci {CPM_PORTA, 6, CPM_PIN_INPUT}, /* CLK1 */ 488c2ecf20Sopenharmony_ci {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */ 498c2ecf20Sopenharmony_ci {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */ 508c2ecf20Sopenharmony_ci {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */ 518c2ecf20Sopenharmony_ci {CPM_PORTB, 19, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */ 528c2ecf20Sopenharmony_ci {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */ 538c2ecf20Sopenharmony_ci {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */ 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci /* MII */ 568c2ecf20Sopenharmony_ci {CPM_PORTD, 3, CPM_PIN_OUTPUT}, 578c2ecf20Sopenharmony_ci {CPM_PORTD, 4, CPM_PIN_OUTPUT}, 588c2ecf20Sopenharmony_ci {CPM_PORTD, 5, CPM_PIN_OUTPUT}, 598c2ecf20Sopenharmony_ci {CPM_PORTD, 6, CPM_PIN_OUTPUT}, 608c2ecf20Sopenharmony_ci {CPM_PORTD, 7, CPM_PIN_OUTPUT}, 618c2ecf20Sopenharmony_ci {CPM_PORTD, 8, CPM_PIN_OUTPUT}, 628c2ecf20Sopenharmony_ci {CPM_PORTD, 9, CPM_PIN_OUTPUT}, 638c2ecf20Sopenharmony_ci {CPM_PORTD, 10, CPM_PIN_OUTPUT}, 648c2ecf20Sopenharmony_ci {CPM_PORTD, 11, CPM_PIN_OUTPUT}, 658c2ecf20Sopenharmony_ci {CPM_PORTD, 12, CPM_PIN_OUTPUT}, 668c2ecf20Sopenharmony_ci {CPM_PORTD, 13, CPM_PIN_OUTPUT}, 678c2ecf20Sopenharmony_ci {CPM_PORTD, 14, CPM_PIN_OUTPUT}, 688c2ecf20Sopenharmony_ci {CPM_PORTD, 15, CPM_PIN_OUTPUT}, 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci /* I2C */ 718c2ecf20Sopenharmony_ci {CPM_PORTB, 26, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN}, 728c2ecf20Sopenharmony_ci {CPM_PORTB, 27, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN}, 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistatic void __init init_ioports(void) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci int i; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(mpc866ads_pins); i++) { 808c2ecf20Sopenharmony_ci struct cpm_pin *pin = &mpc866ads_pins[i]; 818c2ecf20Sopenharmony_ci cpm1_set_pin(pin->port, pin->pin, pin->flags); 828c2ecf20Sopenharmony_ci } 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX); 858c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX); 868c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK1, CPM_CLK_TX); 878c2ecf20Sopenharmony_ci cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_RX); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci /* Set FEC1 and FEC2 to MII mode */ 908c2ecf20Sopenharmony_ci clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180); 918c2ecf20Sopenharmony_ci} 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistatic void __init mpc86xads_setup_arch(void) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci struct device_node *np; 968c2ecf20Sopenharmony_ci u32 __iomem *bcsr_io; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci cpm_reset(); 998c2ecf20Sopenharmony_ci init_ioports(); 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci np = of_find_compatible_node(NULL, NULL, "fsl,mpc866ads-bcsr"); 1028c2ecf20Sopenharmony_ci if (!np) { 1038c2ecf20Sopenharmony_ci printk(KERN_CRIT "Could not find fsl,mpc866ads-bcsr node\n"); 1048c2ecf20Sopenharmony_ci return; 1058c2ecf20Sopenharmony_ci } 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci bcsr_io = of_iomap(np, 0); 1088c2ecf20Sopenharmony_ci of_node_put(np); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci if (bcsr_io == NULL) { 1118c2ecf20Sopenharmony_ci printk(KERN_CRIT "Could not remap BCSR\n"); 1128c2ecf20Sopenharmony_ci return; 1138c2ecf20Sopenharmony_ci } 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci clrbits32(bcsr_io, BCSR1_RS232EN_1 | BCSR1_RS232EN_2 | BCSR1_ETHEN); 1168c2ecf20Sopenharmony_ci iounmap(bcsr_io); 1178c2ecf20Sopenharmony_ci} 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cistatic int __init mpc86xads_probe(void) 1208c2ecf20Sopenharmony_ci{ 1218c2ecf20Sopenharmony_ci return of_machine_is_compatible("fsl,mpc866ads"); 1228c2ecf20Sopenharmony_ci} 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistatic const struct of_device_id of_bus_ids[] __initconst = { 1258c2ecf20Sopenharmony_ci { .name = "soc", }, 1268c2ecf20Sopenharmony_ci { .name = "cpm", }, 1278c2ecf20Sopenharmony_ci { .name = "localbus", }, 1288c2ecf20Sopenharmony_ci {}, 1298c2ecf20Sopenharmony_ci}; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistatic int __init declare_of_platform_devices(void) 1328c2ecf20Sopenharmony_ci{ 1338c2ecf20Sopenharmony_ci of_platform_bus_probe(NULL, of_bus_ids, NULL); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci return 0; 1368c2ecf20Sopenharmony_ci} 1378c2ecf20Sopenharmony_cimachine_device_initcall(mpc86x_ads, declare_of_platform_devices); 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_cidefine_machine(mpc86x_ads) { 1408c2ecf20Sopenharmony_ci .name = "MPC86x ADS", 1418c2ecf20Sopenharmony_ci .probe = mpc86xads_probe, 1428c2ecf20Sopenharmony_ci .setup_arch = mpc86xads_setup_arch, 1438c2ecf20Sopenharmony_ci .init_IRQ = mpc8xx_pics_init, 1448c2ecf20Sopenharmony_ci .get_irq = mpc8xx_get_irq, 1458c2ecf20Sopenharmony_ci .restart = mpc8xx_restart, 1468c2ecf20Sopenharmony_ci .calibrate_decr = mpc8xx_calibrate_decr, 1478c2ecf20Sopenharmony_ci .set_rtc_time = mpc8xx_set_rtc_time, 1488c2ecf20Sopenharmony_ci .get_rtc_time = mpc8xx_get_rtc_time, 1498c2ecf20Sopenharmony_ci .progress = udbg_progress, 1508c2ecf20Sopenharmony_ci}; 151