Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ep93xx/ts72xx.c |
| 3 | * Technologic Systems TS72xx SBC support. |
| 4 | * |
| 5 | * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | */ |
| 12 | |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/mm.h> |
| 16 | #include <linux/sched.h> |
| 17 | #include <linux/interrupt.h> |
Lennert Buytenhek | 0967b5f | 2006-06-22 10:30:51 +0100 | [diff] [blame] | 18 | #include <linux/ioport.h> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 19 | #include <linux/mtd/physmap.h> |
Lennert Buytenhek | 7ba01f97 | 2006-04-02 16:17:40 +0100 | [diff] [blame] | 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/m48t86.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 22 | #include <linux/io.h> |
Hartley Sweeten | 3e7a728 | 2008-12-10 23:39:54 +0100 | [diff] [blame] | 23 | #include <linux/i2c.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/hardware.h> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 25 | #include <asm/mach-types.h> |
| 26 | #include <asm/mach/arch.h> |
| 27 | #include <asm/mach/map.h> |
| 28 | |
| 29 | static struct map_desc ts72xx_io_desc[] __initdata = { |
| 30 | { |
| 31 | .virtual = TS72XX_MODEL_VIRT_BASE, |
| 32 | .pfn = __phys_to_pfn(TS72XX_MODEL_PHYS_BASE), |
| 33 | .length = TS72XX_MODEL_SIZE, |
| 34 | .type = MT_DEVICE, |
| 35 | }, { |
| 36 | .virtual = TS72XX_OPTIONS_VIRT_BASE, |
| 37 | .pfn = __phys_to_pfn(TS72XX_OPTIONS_PHYS_BASE), |
| 38 | .length = TS72XX_OPTIONS_SIZE, |
| 39 | .type = MT_DEVICE, |
| 40 | }, { |
| 41 | .virtual = TS72XX_OPTIONS2_VIRT_BASE, |
| 42 | .pfn = __phys_to_pfn(TS72XX_OPTIONS2_PHYS_BASE), |
| 43 | .length = TS72XX_OPTIONS2_SIZE, |
| 44 | .type = MT_DEVICE, |
Lennert Buytenhek | 7ba01f97 | 2006-04-02 16:17:40 +0100 | [diff] [blame] | 45 | }, { |
| 46 | .virtual = TS72XX_RTC_INDEX_VIRT_BASE, |
| 47 | .pfn = __phys_to_pfn(TS72XX_RTC_INDEX_PHYS_BASE), |
| 48 | .length = TS72XX_RTC_INDEX_SIZE, |
| 49 | .type = MT_DEVICE, |
| 50 | }, { |
| 51 | .virtual = TS72XX_RTC_DATA_VIRT_BASE, |
| 52 | .pfn = __phys_to_pfn(TS72XX_RTC_DATA_PHYS_BASE), |
| 53 | .length = TS72XX_RTC_DATA_SIZE, |
| 54 | .type = MT_DEVICE, |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 55 | } |
| 56 | }; |
| 57 | |
| 58 | static struct map_desc ts72xx_nand_io_desc[] __initdata = { |
| 59 | { |
| 60 | .virtual = TS72XX_NAND_DATA_VIRT_BASE, |
| 61 | .pfn = __phys_to_pfn(TS72XX_NAND1_DATA_PHYS_BASE), |
| 62 | .length = TS72XX_NAND_DATA_SIZE, |
| 63 | .type = MT_DEVICE, |
| 64 | }, { |
| 65 | .virtual = TS72XX_NAND_CONTROL_VIRT_BASE, |
| 66 | .pfn = __phys_to_pfn(TS72XX_NAND1_CONTROL_PHYS_BASE), |
| 67 | .length = TS72XX_NAND_CONTROL_SIZE, |
| 68 | .type = MT_DEVICE, |
| 69 | }, { |
| 70 | .virtual = TS72XX_NAND_BUSY_VIRT_BASE, |
| 71 | .pfn = __phys_to_pfn(TS72XX_NAND1_BUSY_PHYS_BASE), |
| 72 | .length = TS72XX_NAND_BUSY_SIZE, |
| 73 | .type = MT_DEVICE, |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | static struct map_desc ts72xx_alternate_nand_io_desc[] __initdata = { |
| 78 | { |
| 79 | .virtual = TS72XX_NAND_DATA_VIRT_BASE, |
| 80 | .pfn = __phys_to_pfn(TS72XX_NAND2_DATA_PHYS_BASE), |
| 81 | .length = TS72XX_NAND_DATA_SIZE, |
| 82 | .type = MT_DEVICE, |
| 83 | }, { |
| 84 | .virtual = TS72XX_NAND_CONTROL_VIRT_BASE, |
| 85 | .pfn = __phys_to_pfn(TS72XX_NAND2_CONTROL_PHYS_BASE), |
| 86 | .length = TS72XX_NAND_CONTROL_SIZE, |
| 87 | .type = MT_DEVICE, |
| 88 | }, { |
| 89 | .virtual = TS72XX_NAND_BUSY_VIRT_BASE, |
| 90 | .pfn = __phys_to_pfn(TS72XX_NAND2_BUSY_PHYS_BASE), |
| 91 | .length = TS72XX_NAND_BUSY_SIZE, |
| 92 | .type = MT_DEVICE, |
| 93 | } |
| 94 | }; |
| 95 | |
| 96 | static void __init ts72xx_map_io(void) |
| 97 | { |
| 98 | ep93xx_map_io(); |
| 99 | iotable_init(ts72xx_io_desc, ARRAY_SIZE(ts72xx_io_desc)); |
| 100 | |
| 101 | /* |
| 102 | * The TS-7200 has NOR flash, the other models have NAND flash. |
| 103 | */ |
| 104 | if (!board_is_ts7200()) { |
| 105 | if (is_ts9420_installed()) { |
| 106 | iotable_init(ts72xx_alternate_nand_io_desc, |
| 107 | ARRAY_SIZE(ts72xx_alternate_nand_io_desc)); |
| 108 | } else { |
| 109 | iotable_init(ts72xx_nand_io_desc, |
| 110 | ARRAY_SIZE(ts72xx_nand_io_desc)); |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
Lennert Buytenhek | 0967b5f | 2006-06-22 10:30:51 +0100 | [diff] [blame] | 115 | static struct physmap_flash_data ts72xx_flash_data = { |
| 116 | .width = 1, |
| 117 | }; |
| 118 | |
| 119 | static struct resource ts72xx_flash_resource = { |
| 120 | .start = TS72XX_NOR_PHYS_BASE, |
Hartley Sweeten | e48f3fa | 2008-12-08 17:57:22 +0100 | [diff] [blame] | 121 | .end = TS72XX_NOR_PHYS_BASE + SZ_16M - 1, |
Lennert Buytenhek | 0967b5f | 2006-06-22 10:30:51 +0100 | [diff] [blame] | 122 | .flags = IORESOURCE_MEM, |
| 123 | }; |
| 124 | |
| 125 | static struct platform_device ts72xx_flash = { |
| 126 | .name = "physmap-flash", |
| 127 | .id = 0, |
| 128 | .dev = { |
| 129 | .platform_data = &ts72xx_flash_data, |
| 130 | }, |
| 131 | .num_resources = 1, |
| 132 | .resource = &ts72xx_flash_resource, |
| 133 | }; |
| 134 | |
Lennert Buytenhek | fd0a0ac | 2006-06-08 00:43:40 -0700 | [diff] [blame] | 135 | static unsigned char ts72xx_rtc_readbyte(unsigned long addr) |
Lennert Buytenhek | 7ba01f97 | 2006-04-02 16:17:40 +0100 | [diff] [blame] | 136 | { |
| 137 | __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE); |
| 138 | return __raw_readb(TS72XX_RTC_DATA_VIRT_BASE); |
| 139 | } |
| 140 | |
Lennert Buytenhek | fd0a0ac | 2006-06-08 00:43:40 -0700 | [diff] [blame] | 141 | static void ts72xx_rtc_writebyte(unsigned char value, unsigned long addr) |
Lennert Buytenhek | 7ba01f97 | 2006-04-02 16:17:40 +0100 | [diff] [blame] | 142 | { |
| 143 | __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE); |
| 144 | __raw_writeb(value, TS72XX_RTC_DATA_VIRT_BASE); |
| 145 | } |
| 146 | |
| 147 | static struct m48t86_ops ts72xx_rtc_ops = { |
Hartley Sweeten | e48f3fa | 2008-12-08 17:57:22 +0100 | [diff] [blame] | 148 | .readbyte = ts72xx_rtc_readbyte, |
| 149 | .writebyte = ts72xx_rtc_writebyte, |
Lennert Buytenhek | 7ba01f97 | 2006-04-02 16:17:40 +0100 | [diff] [blame] | 150 | }; |
| 151 | |
| 152 | static struct platform_device ts72xx_rtc_device = { |
Hartley Sweeten | e48f3fa | 2008-12-08 17:57:22 +0100 | [diff] [blame] | 153 | .name = "rtc-m48t86", |
| 154 | .id = -1, |
| 155 | .dev = { |
| 156 | .platform_data = &ts72xx_rtc_ops, |
Lennert Buytenhek | 7ba01f97 | 2006-04-02 16:17:40 +0100 | [diff] [blame] | 157 | }, |
Hartley Sweeten | e48f3fa | 2008-12-08 17:57:22 +0100 | [diff] [blame] | 158 | .num_resources = 0, |
Lennert Buytenhek | 7ba01f97 | 2006-04-02 16:17:40 +0100 | [diff] [blame] | 159 | }; |
| 160 | |
Lennert Buytenhek | 730ee9f | 2006-09-29 21:17:36 +0100 | [diff] [blame] | 161 | static struct ep93xx_eth_data ts72xx_eth_data = { |
Hartley Sweeten | e48f3fa | 2008-12-08 17:57:22 +0100 | [diff] [blame] | 162 | .phy_id = 1, |
Lennert Buytenhek | 730ee9f | 2006-09-29 21:17:36 +0100 | [diff] [blame] | 163 | }; |
| 164 | |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 165 | static void __init ts72xx_init_machine(void) |
| 166 | { |
| 167 | ep93xx_init_devices(); |
| 168 | if (board_is_ts7200()) |
Lennert Buytenhek | 0967b5f | 2006-06-22 10:30:51 +0100 | [diff] [blame] | 169 | platform_device_register(&ts72xx_flash); |
Lennert Buytenhek | 7ba01f97 | 2006-04-02 16:17:40 +0100 | [diff] [blame] | 170 | platform_device_register(&ts72xx_rtc_device); |
Lennert Buytenhek | 730ee9f | 2006-09-29 21:17:36 +0100 | [diff] [blame] | 171 | |
Hartley Sweeten | a0a08fd | 2008-10-04 20:01:49 +0100 | [diff] [blame] | 172 | ep93xx_register_eth(&ts72xx_eth_data, 1); |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC") |
| 176 | /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ |
| 177 | .phys_io = EP93XX_APB_PHYS_BASE, |
| 178 | .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc, |
Hartley Sweeten | e48f3fa | 2008-12-08 17:57:22 +0100 | [diff] [blame] | 179 | .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 180 | .map_io = ts72xx_map_io, |
| 181 | .init_irq = ep93xx_init_irq, |
| 182 | .timer = &ep93xx_timer, |
| 183 | .init_machine = ts72xx_init_machine, |
| 184 | MACHINE_END |