Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 1 | /* |
Chunhe Lan | 7589815 | 2013-07-31 05:39:26 +0800 | [diff] [blame] | 2 | * Copyright 2010-2011, 2013 Freescale Semiconductor, Inc. |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 3 | * |
| 4 | * Author: Roy Zang <tie-fei.zang@freescale.com> |
| 5 | * |
| 6 | * Description: |
| 7 | * P1023 RDS Board Setup |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the |
| 11 | * Free Software Foundation; either version 2 of the License, or (at your |
| 12 | * option) any later version. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/errno.h> |
| 18 | #include <linux/pci.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/fsl_devices.h> |
| 22 | #include <linux/of_platform.h> |
| 23 | #include <linux/of_device.h> |
| 24 | |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 25 | #include <asm/time.h> |
| 26 | #include <asm/machdep.h> |
| 27 | #include <asm/pci-bridge.h> |
| 28 | #include <mm/mmu_decl.h> |
| 29 | #include <asm/prom.h> |
| 30 | #include <asm/udbg.h> |
| 31 | #include <asm/mpic.h> |
Kyle Moffett | 582d3e0 | 2011-12-02 06:27:58 +0000 | [diff] [blame] | 32 | #include "smp.h" |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 33 | |
| 34 | #include <sysdev/fsl_soc.h> |
| 35 | #include <sysdev/fsl_pci.h> |
| 36 | |
Kumar Gala | 199bfbe | 2011-11-24 01:00:10 -0600 | [diff] [blame] | 37 | #include "mpc85xx.h" |
| 38 | |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 39 | /* ************************************************************************ |
| 40 | * |
| 41 | * Setup the architecture |
| 42 | * |
| 43 | */ |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 44 | static void __init mpc85xx_rds_setup_arch(void) |
| 45 | { |
| 46 | struct device_node *np; |
| 47 | |
| 48 | if (ppc_md.progress) |
| 49 | ppc_md.progress("p1023_rds_setup_arch()", 0); |
| 50 | |
| 51 | /* Map BCSR area */ |
| 52 | np = of_find_node_by_name(NULL, "bcsr"); |
| 53 | if (np != NULL) { |
| 54 | static u8 __iomem *bcsr_regs; |
| 55 | |
| 56 | bcsr_regs = of_iomap(np, 0); |
| 57 | of_node_put(np); |
| 58 | |
| 59 | if (!bcsr_regs) { |
| 60 | printk(KERN_ERR |
| 61 | "BCSR: Failed to map bcsr register space\n"); |
| 62 | return; |
| 63 | } else { |
| 64 | #define BCSR15_I2C_BUS0_SEG_CLR 0x07 |
| 65 | #define BCSR15_I2C_BUS0_SEG2 0x02 |
| 66 | /* |
| 67 | * Note: Accessing exclusively i2c devices. |
| 68 | * |
| 69 | * The i2c controller selects initially ID EEPROM in the u-boot; |
| 70 | * but if menu configuration selects RTC support in the kernel, |
| 71 | * the i2c controller switches to select RTC chip in the kernel. |
| 72 | */ |
| 73 | #ifdef CONFIG_RTC_CLASS |
| 74 | /* Enable RTC chip on the segment #2 of i2c */ |
| 75 | clrbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG_CLR); |
| 76 | setbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG2); |
| 77 | #endif |
| 78 | |
| 79 | iounmap(bcsr_regs); |
| 80 | } |
| 81 | } |
| 82 | |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 83 | mpc85xx_smp_init(); |
Jia Hongtao | 905e75c | 2012-08-28 15:44:08 +0800 | [diff] [blame] | 84 | |
| 85 | fsl_pci_assign_primary(); |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 86 | } |
| 87 | |
Jia Hongtao | 905e75c | 2012-08-28 15:44:08 +0800 | [diff] [blame] | 88 | machine_arch_initcall(p1023_rds, mpc85xx_common_publish_devices); |
Chunhe Lan | 7589815 | 2013-07-31 05:39:26 +0800 | [diff] [blame] | 89 | machine_arch_initcall(p1023_rdb, mpc85xx_common_publish_devices); |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 90 | |
| 91 | static void __init mpc85xx_rds_pic_init(void) |
| 92 | { |
Kyle Moffett | e55d7f7 | 2011-12-22 10:19:14 +0000 | [diff] [blame] | 93 | struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN | |
Kyle Moffett | 5019609 | 2011-12-22 10:19:12 +0000 | [diff] [blame] | 94 | MPIC_SINGLE_DEST_CPU, |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 95 | 0, 256, " OpenPIC "); |
| 96 | |
| 97 | BUG_ON(mpic == NULL); |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 98 | |
| 99 | mpic_init(mpic); |
| 100 | } |
| 101 | |
| 102 | static int __init p1023_rds_probe(void) |
| 103 | { |
| 104 | unsigned long root = of_get_flat_dt_root(); |
| 105 | |
| 106 | return of_flat_dt_is_compatible(root, "fsl,P1023RDS"); |
| 107 | |
| 108 | } |
| 109 | |
Chunhe Lan | 7589815 | 2013-07-31 05:39:26 +0800 | [diff] [blame] | 110 | static int __init p1023_rdb_probe(void) |
| 111 | { |
| 112 | unsigned long root = of_get_flat_dt_root(); |
| 113 | |
| 114 | return of_flat_dt_is_compatible(root, "fsl,P1023RDB"); |
| 115 | |
| 116 | } |
| 117 | |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 118 | define_machine(p1023_rds) { |
| 119 | .name = "P1023 RDS", |
| 120 | .probe = p1023_rds_probe, |
| 121 | .setup_arch = mpc85xx_rds_setup_arch, |
| 122 | .init_IRQ = mpc85xx_rds_pic_init, |
| 123 | .get_irq = mpic_get_irq, |
| 124 | .restart = fsl_rstcr_restart, |
| 125 | .calibrate_decr = generic_calibrate_decr, |
| 126 | .progress = udbg_progress, |
| 127 | #ifdef CONFIG_PCI |
| 128 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
Wang Dongsheng | 48b1618 | 2014-03-20 11:19:37 +0800 | [diff] [blame] | 129 | .pcibios_fixup_phb = fsl_pcibios_fixup_phb, |
Roy Zang | 2602a21 | 2011-05-19 20:20:13 -0500 | [diff] [blame] | 130 | #endif |
| 131 | }; |
| 132 | |
Chunhe Lan | 7589815 | 2013-07-31 05:39:26 +0800 | [diff] [blame] | 133 | define_machine(p1023_rdb) { |
| 134 | .name = "P1023 RDB", |
| 135 | .probe = p1023_rdb_probe, |
| 136 | .setup_arch = mpc85xx_rds_setup_arch, |
| 137 | .init_IRQ = mpc85xx_rds_pic_init, |
| 138 | .get_irq = mpic_get_irq, |
| 139 | .restart = fsl_rstcr_restart, |
| 140 | .calibrate_decr = generic_calibrate_decr, |
| 141 | .progress = udbg_progress, |
| 142 | #ifdef CONFIG_PCI |
| 143 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
Wang Dongsheng | 48b1618 | 2014-03-20 11:19:37 +0800 | [diff] [blame] | 144 | .pcibios_fixup_phb = fsl_pcibios_fixup_phb, |
Chunhe Lan | 7589815 | 2013-07-31 05:39:26 +0800 | [diff] [blame] | 145 | #endif |
| 146 | }; |