Heiko Schocher | e14d4af | 2008-06-14 21:02:04 +0200 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Platform setup for the Keymile mgsuvd board |
| 4 | * |
| 5 | * Heiko Schocher <hs@denx.de> |
| 6 | * |
| 7 | * Copyright 2008 DENX Software Engineering GmbH |
| 8 | * |
| 9 | * This file is licensed under the terms of the GNU General Public License |
| 10 | * version 2. This program is licensed "as is" without any warranty of any |
| 11 | * kind, whether express or implied. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/ioport.h> |
| 15 | #include <linux/of_platform.h> |
| 16 | |
| 17 | #include <asm/io.h> |
| 18 | #include <asm/machdep.h> |
| 19 | #include <asm/processor.h> |
| 20 | #include <asm/cpm1.h> |
| 21 | #include <asm/prom.h> |
| 22 | #include <asm/fs_pd.h> |
| 23 | |
| 24 | #include "mpc8xx.h" |
| 25 | |
| 26 | struct cpm_pin { |
| 27 | int port, pin, flags; |
| 28 | }; |
| 29 | |
| 30 | static __initdata struct cpm_pin mgsuvd_pins[] = { |
| 31 | /* SMC1 */ |
| 32 | {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */ |
| 33 | {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ |
| 34 | |
| 35 | /* SCC3 */ |
| 36 | {CPM_PORTA, 10, CPM_PIN_INPUT}, |
| 37 | {CPM_PORTA, 11, CPM_PIN_INPUT}, |
| 38 | {CPM_PORTA, 3, CPM_PIN_INPUT}, |
| 39 | {CPM_PORTA, 2, CPM_PIN_INPUT}, |
| 40 | {CPM_PORTC, 13, CPM_PIN_INPUT}, |
| 41 | }; |
| 42 | |
| 43 | static void __init init_ioports(void) |
| 44 | { |
| 45 | int i; |
| 46 | |
| 47 | for (i = 0; i < ARRAY_SIZE(mgsuvd_pins); i++) { |
| 48 | struct cpm_pin *pin = &mgsuvd_pins[i]; |
| 49 | cpm1_set_pin(pin->port, pin->pin, pin->flags); |
| 50 | } |
| 51 | |
| 52 | setbits16(&mpc8xx_immr->im_ioport.iop_pcso, 0x300); |
| 53 | cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK5, CPM_CLK_RX); |
| 54 | cpm1_clk_setup(CPM_CLK_SCC3, CPM_CLK6, CPM_CLK_TX); |
| 55 | cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX); |
| 56 | } |
| 57 | |
| 58 | static void __init mgsuvd_setup_arch(void) |
| 59 | { |
| 60 | cpm_reset(); |
| 61 | init_ioports(); |
| 62 | } |
| 63 | |
| 64 | static __initdata struct of_device_id of_bus_ids[] = { |
| 65 | { .compatible = "simple-bus" }, |
| 66 | {}, |
| 67 | }; |
| 68 | |
| 69 | static int __init declare_of_platform_devices(void) |
| 70 | { |
| 71 | of_platform_bus_probe(NULL, of_bus_ids, NULL); |
| 72 | return 0; |
| 73 | } |
| 74 | machine_device_initcall(mgsuvd, declare_of_platform_devices); |
| 75 | |
| 76 | static int __init mgsuvd_probe(void) |
| 77 | { |
| 78 | unsigned long root = of_get_flat_dt_root(); |
| 79 | return of_flat_dt_is_compatible(root, "keymile,mgsuvd"); |
| 80 | } |
| 81 | |
| 82 | define_machine(mgsuvd) { |
| 83 | .name = "MGSUVD", |
| 84 | .probe = mgsuvd_probe, |
| 85 | .setup_arch = mgsuvd_setup_arch, |
| 86 | .init_IRQ = mpc8xx_pics_init, |
| 87 | .get_irq = mpc8xx_get_irq, |
| 88 | .restart = mpc8xx_restart, |
| 89 | .calibrate_decr = mpc8xx_calibrate_decr, |
| 90 | .set_rtc_time = mpc8xx_set_rtc_time, |
| 91 | .get_rtc_time = mpc8xx_get_rtc_time, |
| 92 | }; |