Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Renesas Technology Sales RTS7751R2D Support. |
| 3 | * |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 4 | * Copyright (C) 2002 Atom Create Engineering Co., Ltd. |
| 5 | * Copyright (C) 2004 - 2006 Paul Mundt |
| 6 | * |
| 7 | * This file is subject to the terms and conditions of the GNU General Public |
| 8 | * License. See the file "COPYING" in the main directory of this archive |
| 9 | * for more details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/init.h> |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 12 | #include <linux/platform_device.h> |
| 13 | #include <linux/serial_8250.h> |
Paul Mundt | a56d276 | 2006-09-27 11:43:24 +0900 | [diff] [blame] | 14 | #include <linux/pm.h> |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 15 | #include <asm/machvec.h> |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 16 | #include <asm/mach/rts7751r2d.h> |
Paul Mundt | 082c44d | 2006-10-19 16:16:18 +0900 | [diff] [blame] | 17 | #include <asm/io.h> |
Paul Mundt | adf1890 | 2006-09-27 17:17:27 +0900 | [diff] [blame] | 18 | #include <asm/voyagergx.h> |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 19 | |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 20 | extern void heartbeat_rts7751r2d(void); |
| 21 | extern void init_rts7751r2d_IRQ(void); |
| 22 | extern int rts7751r2d_irq_demux(int irq); |
| 23 | |
| 24 | extern void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, gfp_t); |
| 25 | extern int voyagergx_consistent_free(struct device *, size_t, void *, dma_addr_t); |
| 26 | |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 27 | static struct plat_serial8250_port uart_platform_data[] = { |
| 28 | { |
| 29 | .membase = (void *)VOYAGER_UART_BASE, |
| 30 | .mapbase = VOYAGER_UART_BASE, |
| 31 | .iotype = UPIO_MEM, |
| 32 | .irq = VOYAGER_UART0_IRQ, |
| 33 | .flags = UPF_BOOT_AUTOCONF, |
| 34 | .regshift = 2, |
| 35 | .uartclk = (9600 * 16), |
| 36 | }, { |
| 37 | .flags = 0, |
| 38 | }, |
| 39 | }; |
| 40 | |
| 41 | static void __init voyagergx_serial_init(void) |
| 42 | { |
| 43 | unsigned long val; |
| 44 | |
| 45 | /* |
| 46 | * GPIO Control |
| 47 | */ |
| 48 | val = inl(GPIO_MUX_HIGH); |
| 49 | val |= 0x00001fe0; |
| 50 | outl(val, GPIO_MUX_HIGH); |
| 51 | |
| 52 | /* |
| 53 | * Power Mode Gate |
| 54 | */ |
| 55 | val = inl(POWER_MODE0_GATE); |
| 56 | val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1); |
| 57 | outl(val, POWER_MODE0_GATE); |
| 58 | |
| 59 | val = inl(POWER_MODE1_GATE); |
| 60 | val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1); |
| 61 | outl(val, POWER_MODE1_GATE); |
| 62 | } |
| 63 | |
| 64 | static struct platform_device uart_device = { |
| 65 | .name = "serial8250", |
| 66 | .id = -1, |
| 67 | .dev = { |
| 68 | .platform_data = uart_platform_data, |
| 69 | }, |
| 70 | }; |
| 71 | |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame^] | 72 | static struct resource heartbeat_resources[] = { |
| 73 | [0] = { |
| 74 | .start = PA_OUTPORT, |
| 75 | .end = PA_OUTPORT + 8 - 1, |
| 76 | .flags = IORESOURCE_MEM, |
| 77 | }, |
| 78 | }; |
| 79 | |
| 80 | static struct platform_device heartbeat_device = { |
| 81 | .name = "heartbeat", |
| 82 | .id = -1, |
| 83 | .num_resources = ARRAY_SIZE(heartbeat_resources), |
| 84 | .resource = heartbeat_resources, |
| 85 | }; |
| 86 | |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 87 | static struct platform_device *rts7751r2d_devices[] __initdata = { |
| 88 | &uart_device, |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame^] | 89 | &heartbeat_device, |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | static int __init rts7751r2d_devices_setup(void) |
| 93 | { |
| 94 | return platform_add_devices(rts7751r2d_devices, |
| 95 | ARRAY_SIZE(rts7751r2d_devices)); |
| 96 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
Paul Mundt | a56d276 | 2006-09-27 11:43:24 +0900 | [diff] [blame] | 98 | static void rts7751r2d_power_off(void) |
| 99 | { |
| 100 | ctrl_outw(0x0001, PA_POWOFF); |
| 101 | } |
| 102 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | /* |
| 104 | * Initialize the board |
| 105 | */ |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 106 | static void __init rts7751r2d_setup(char **cmdline_p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | { |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 108 | device_initcall(rts7751r2d_devices_setup); |
| 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | ctrl_outw(0x0000, PA_OUTPORT); |
Paul Mundt | a56d276 | 2006-09-27 11:43:24 +0900 | [diff] [blame] | 111 | pm_power_off = rts7751r2d_power_off; |
Paul Mundt | ade2b3f | 2006-09-27 16:48:46 +0900 | [diff] [blame] | 112 | |
| 113 | voyagergx_serial_init(); |
| 114 | |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 115 | printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | } |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 117 | |
| 118 | /* |
| 119 | * The Machine Vector |
| 120 | */ |
| 121 | struct sh_machine_vector mv_rts7751r2d __initmv = { |
| 122 | .mv_name = "RTS7751R2D", |
| 123 | .mv_setup = rts7751r2d_setup, |
| 124 | .mv_nr_irqs = 72, |
| 125 | |
| 126 | .mv_inb = rts7751r2d_inb, |
| 127 | .mv_inw = rts7751r2d_inw, |
| 128 | .mv_inl = rts7751r2d_inl, |
| 129 | .mv_outb = rts7751r2d_outb, |
| 130 | .mv_outw = rts7751r2d_outw, |
| 131 | .mv_outl = rts7751r2d_outl, |
| 132 | |
| 133 | .mv_inb_p = rts7751r2d_inb_p, |
| 134 | .mv_inw_p = rts7751r2d_inw, |
| 135 | .mv_inl_p = rts7751r2d_inl, |
| 136 | .mv_outb_p = rts7751r2d_outb_p, |
| 137 | .mv_outw_p = rts7751r2d_outw, |
| 138 | .mv_outl_p = rts7751r2d_outl, |
| 139 | |
| 140 | .mv_insb = rts7751r2d_insb, |
| 141 | .mv_insw = rts7751r2d_insw, |
| 142 | .mv_insl = rts7751r2d_insl, |
| 143 | .mv_outsb = rts7751r2d_outsb, |
| 144 | .mv_outsw = rts7751r2d_outsw, |
| 145 | .mv_outsl = rts7751r2d_outsl, |
| 146 | |
| 147 | .mv_init_irq = init_rts7751r2d_IRQ, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 148 | .mv_irq_demux = rts7751r2d_irq_demux, |
| 149 | |
| 150 | #ifdef CONFIG_USB_SM501 |
| 151 | .mv_consistent_alloc = voyagergx_consistent_alloc, |
| 152 | .mv_consistent_free = voyagergx_consistent_free, |
| 153 | #endif |
| 154 | }; |
| 155 | ALIAS_MV(rts7751r2d) |