Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 1 | /* |
| 2 | * arch/powerpc/platforms/83xx/mpc832x_rdb.c |
| 3 | * |
| 4 | * Copyright (C) Freescale Semiconductor, Inc. 2007. All rights reserved. |
| 5 | * |
| 6 | * Description: |
| 7 | * MPC832x RDB board specific routines. |
| 8 | * This file is based on mpc832x_mds.c and mpc8313_rdb.c |
| 9 | * Author: Michael Barkowski <michael.barkowski@freescale.com> |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify it |
| 12 | * under the terms of the GNU General Public License as published by the |
| 13 | * Free Software Foundation; either version 2 of the License, or (at your |
| 14 | * option) any later version. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/pci.h> |
Anton Vorontsov | ba3bdff | 2007-11-13 20:00:11 +0300 | [diff] [blame] | 18 | #include <linux/interrupt.h> |
Anton Vorontsov | 8237bf0 | 2007-08-23 15:36:00 +0400 | [diff] [blame] | 19 | #include <linux/spi/spi.h> |
Anton Vorontsov | ba3bdff | 2007-11-13 20:00:11 +0300 | [diff] [blame] | 20 | #include <linux/spi/mmc_spi.h> |
| 21 | #include <linux/mmc/host.h> |
Jon Loeliger | 882407b | 2007-11-06 12:11:13 -0600 | [diff] [blame] | 22 | #include <linux/of_platform.h> |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 23 | |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 24 | #include <asm/time.h> |
| 25 | #include <asm/ipic.h> |
| 26 | #include <asm/udbg.h> |
| 27 | #include <asm/qe.h> |
| 28 | #include <asm/qe_ic.h> |
Anton Vorontsov | 8237bf0 | 2007-08-23 15:36:00 +0400 | [diff] [blame] | 29 | #include <sysdev/fsl_soc.h> |
John Rigby | 76fe1ff | 2008-06-26 11:07:57 -0600 | [diff] [blame] | 30 | #include <sysdev/fsl_pci.h> |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 31 | |
| 32 | #include "mpc83xx.h" |
| 33 | |
| 34 | #undef DEBUG |
| 35 | #ifdef DEBUG |
| 36 | #define DBG(fmt...) udbg_printf(fmt) |
| 37 | #else |
| 38 | #define DBG(fmt...) |
| 39 | #endif |
| 40 | |
Anton Vorontsov | 20cfb41 | 2008-12-05 19:55:04 +0300 | [diff] [blame] | 41 | #ifdef CONFIG_QUICC_ENGINE |
Anton Vorontsov | 364fdbc | 2009-03-31 15:24:36 -0700 | [diff] [blame^] | 42 | static void mpc83xx_spi_cs_control(struct spi_device *spi, bool on) |
Anton Vorontsov | 8237bf0 | 2007-08-23 15:36:00 +0400 | [diff] [blame] | 43 | { |
Anton Vorontsov | 364fdbc | 2009-03-31 15:24:36 -0700 | [diff] [blame^] | 44 | pr_debug("%s %d %d\n", __func__, spi->chip_select, on); |
| 45 | par_io_data_set(3, 13, on); |
Anton Vorontsov | 8237bf0 | 2007-08-23 15:36:00 +0400 | [diff] [blame] | 46 | } |
| 47 | |
Anton Vorontsov | ba3bdff | 2007-11-13 20:00:11 +0300 | [diff] [blame] | 48 | static struct mmc_spi_platform_data mpc832x_mmc_pdata = { |
| 49 | .ocr_mask = MMC_VDD_33_34, |
| 50 | }; |
| 51 | |
Anton Vorontsov | 8237bf0 | 2007-08-23 15:36:00 +0400 | [diff] [blame] | 52 | static struct spi_board_info mpc832x_spi_boardinfo = { |
| 53 | .bus_num = 0x4c0, |
| 54 | .chip_select = 0, |
| 55 | .max_speed_hz = 50000000, |
Anton Vorontsov | ba3bdff | 2007-11-13 20:00:11 +0300 | [diff] [blame] | 56 | .modalias = "mmc_spi", |
| 57 | .platform_data = &mpc832x_mmc_pdata, |
Anton Vorontsov | 8237bf0 | 2007-08-23 15:36:00 +0400 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | static int __init mpc832x_spi_init(void) |
| 61 | { |
Anton Vorontsov | 8237bf0 | 2007-08-23 15:36:00 +0400 | [diff] [blame] | 62 | par_io_config_pin(3, 0, 3, 0, 1, 0); /* SPI1 MOSI, I/O */ |
| 63 | par_io_config_pin(3, 1, 3, 0, 1, 0); /* SPI1 MISO, I/O */ |
| 64 | par_io_config_pin(3, 2, 3, 0, 1, 0); /* SPI1 CLK, I/O */ |
| 65 | par_io_config_pin(3, 3, 2, 0, 1, 0); /* SPI1 SEL, I */ |
| 66 | |
| 67 | par_io_config_pin(3, 13, 1, 0, 0, 0); /* !SD_CS, O */ |
| 68 | par_io_config_pin(3, 14, 2, 0, 0, 0); /* SD_INSERT, I */ |
| 69 | par_io_config_pin(3, 15, 2, 0, 0, 0); /* SD_PROTECT,I */ |
| 70 | |
Anton Vorontsov | 364fdbc | 2009-03-31 15:24:36 -0700 | [diff] [blame^] | 71 | return fsl_spi_init(&mpc832x_spi_boardinfo, 1, mpc83xx_spi_cs_control); |
Anton Vorontsov | 8237bf0 | 2007-08-23 15:36:00 +0400 | [diff] [blame] | 72 | } |
Kumar Gala | 6392f18 | 2008-01-15 09:47:10 -0600 | [diff] [blame] | 73 | machine_device_initcall(mpc832x_rdb, mpc832x_spi_init); |
Anton Vorontsov | 20cfb41 | 2008-12-05 19:55:04 +0300 | [diff] [blame] | 74 | #endif /* CONFIG_QUICC_ENGINE */ |
Anton Vorontsov | 8237bf0 | 2007-08-23 15:36:00 +0400 | [diff] [blame] | 75 | |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 76 | /* ************************************************************************ |
| 77 | * |
| 78 | * Setup the architecture |
| 79 | * |
| 80 | */ |
| 81 | static void __init mpc832x_rdb_setup_arch(void) |
| 82 | { |
Kumar Gala | c9ec87e | 2007-05-09 22:48:53 -0500 | [diff] [blame] | 83 | #if defined(CONFIG_PCI) || defined(CONFIG_QUICC_ENGINE) |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 84 | struct device_node *np; |
Kumar Gala | c9ec87e | 2007-05-09 22:48:53 -0500 | [diff] [blame] | 85 | #endif |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 86 | |
| 87 | if (ppc_md.progress) |
| 88 | ppc_md.progress("mpc832x_rdb_setup_arch()", 0); |
| 89 | |
| 90 | #ifdef CONFIG_PCI |
Kumar Gala | c9438af | 2007-10-04 00:28:43 -0500 | [diff] [blame] | 91 | for_each_compatible_node(np, "pci", "fsl,mpc8349-pci") |
Arnd Bergmann | 09b55f7 | 2007-06-18 01:06:54 +0200 | [diff] [blame] | 92 | mpc83xx_add_bridge(np); |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 93 | #endif |
| 94 | |
| 95 | #ifdef CONFIG_QUICC_ENGINE |
| 96 | qe_reset(); |
| 97 | |
Kim Phillips | aafa195 | 2008-02-01 18:09:54 -0600 | [diff] [blame] | 98 | if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) { |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 99 | par_io_init(np); |
| 100 | of_node_put(np); |
| 101 | |
| 102 | for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;) |
| 103 | par_io_of_config(np); |
| 104 | } |
| 105 | #endif /* CONFIG_QUICC_ENGINE */ |
| 106 | } |
| 107 | |
| 108 | static struct of_device_id mpc832x_ids[] = { |
| 109 | { .type = "soc", }, |
| 110 | { .compatible = "soc", }, |
Kim Phillips | cf0d19f | 2008-07-29 15:29:24 -0500 | [diff] [blame] | 111 | { .compatible = "simple-bus", }, |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 112 | { .type = "qe", }, |
Anton Vorontsov | a2dd70a | 2008-01-24 18:39:59 +0300 | [diff] [blame] | 113 | { .compatible = "fsl,qe", }, |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 114 | {}, |
| 115 | }; |
| 116 | |
| 117 | static int __init mpc832x_declare_of_platform_devices(void) |
| 118 | { |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 119 | /* Publish the QE devices */ |
| 120 | of_platform_bus_probe(NULL, mpc832x_ids, NULL); |
| 121 | |
| 122 | return 0; |
| 123 | } |
Kumar Gala | 6392f18 | 2008-01-15 09:47:10 -0600 | [diff] [blame] | 124 | machine_device_initcall(mpc832x_rdb, mpc832x_declare_of_platform_devices); |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 125 | |
Anton Vorontsov | 81b36a0 | 2008-12-05 18:48:07 +0300 | [diff] [blame] | 126 | static void __init mpc832x_rdb_init_IRQ(void) |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 127 | { |
| 128 | |
| 129 | struct device_node *np; |
| 130 | |
| 131 | np = of_find_node_by_type(NULL, "ipic"); |
| 132 | if (!np) |
| 133 | return; |
| 134 | |
| 135 | ipic_init(np, 0); |
| 136 | |
| 137 | /* Initialize the default interrupt mapping priorities, |
| 138 | * in case the boot rom changed something on us. |
| 139 | */ |
| 140 | ipic_set_default_priority(); |
| 141 | of_node_put(np); |
| 142 | |
| 143 | #ifdef CONFIG_QUICC_ENGINE |
Anton Vorontsov | a2dd70a | 2008-01-24 18:39:59 +0300 | [diff] [blame] | 144 | np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic"); |
| 145 | if (!np) { |
| 146 | np = of_find_node_by_type(NULL, "qeic"); |
| 147 | if (!np) |
| 148 | return; |
| 149 | } |
Anton Vorontsov | cccd210 | 2007-10-05 21:47:29 +0400 | [diff] [blame] | 150 | qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic); |
Michael Barkowski | 23308c5 | 2007-03-19 09:15:28 -0500 | [diff] [blame] | 151 | of_node_put(np); |
| 152 | #endif /* CONFIG_QUICC_ENGINE */ |
| 153 | } |
| 154 | |
| 155 | /* |
| 156 | * Called very early, MMU is off, device-tree isn't unflattened |
| 157 | */ |
| 158 | static int __init mpc832x_rdb_probe(void) |
| 159 | { |
| 160 | unsigned long root = of_get_flat_dt_root(); |
| 161 | |
| 162 | return of_flat_dt_is_compatible(root, "MPC832xRDB"); |
| 163 | } |
| 164 | |
| 165 | define_machine(mpc832x_rdb) { |
| 166 | .name = "MPC832x RDB", |
| 167 | .probe = mpc832x_rdb_probe, |
| 168 | .setup_arch = mpc832x_rdb_setup_arch, |
| 169 | .init_IRQ = mpc832x_rdb_init_IRQ, |
| 170 | .get_irq = ipic_get_irq, |
| 171 | .restart = mpc83xx_restart, |
| 172 | .time_init = mpc83xx_time_init, |
| 173 | .calibrate_decr = generic_calibrate_decr, |
| 174 | .progress = udbg_progress, |
| 175 | }; |