Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ep93xx/core.c |
| 3 | * Core routines for Cirrus EP93xx chips. |
| 4 | * |
| 5 | * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org> |
Herbert Valerio Riedel | 3c9a071 | 2007-11-26 18:49:08 +0100 | [diff] [blame] | 6 | * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 7 | * |
| 8 | * Thanks go to Michael Burian and Ray Lehtiniemi for their key |
| 9 | * role in the ep93xx linux community. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or (at |
| 14 | * your option) any later version. |
| 15 | */ |
| 16 | |
Hartley Sweeten | 64d6882 | 2010-01-11 19:33:16 +0100 | [diff] [blame] | 17 | #define pr_fmt(fmt) "ep93xx " KBUILD_MODNAME ": " fmt |
| 18 | |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/init.h> |
Hartley Sweeten | 583ddaf | 2009-07-06 17:39:50 +0100 | [diff] [blame] | 21 | #include <linux/platform_device.h> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 22 | #include <linux/interrupt.h> |
Matthias Kaehlcke | 63890a0 | 2008-10-29 14:14:52 -0700 | [diff] [blame] | 23 | #include <linux/dma-mapping.h> |
H Hartley Sweeten | b19e11f | 2013-11-19 10:23:06 +1100 | [diff] [blame] | 24 | #include <linux/sys_soc.h> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 25 | #include <linux/timex.h> |
Hartley Sweeten | 6bd4b38 | 2010-02-18 18:16:11 +0100 | [diff] [blame] | 26 | #include <linux/irq.h> |
Hartley Sweeten | 583ddaf | 2009-07-06 17:39:50 +0100 | [diff] [blame] | 27 | #include <linux/io.h> |
| 28 | #include <linux/gpio.h> |
Hartley Sweeten | 3aa7a9a | 2009-07-20 18:22:36 +0100 | [diff] [blame] | 29 | #include <linux/leds.h> |
Lennert Buytenhek | aee85fe | 2006-03-26 23:16:39 +0100 | [diff] [blame] | 30 | #include <linux/termios.h> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 31 | #include <linux/amba/bus.h> |
Lennert Buytenhek | aee85fe | 2006-03-26 23:16:39 +0100 | [diff] [blame] | 32 | #include <linux/amba/serial.h> |
Hartley Sweeten | 16bcf78 | 2010-06-10 16:19:08 +0100 | [diff] [blame] | 33 | #include <linux/mtd/physmap.h> |
Hartley Sweeten | d52a26a | 2008-10-16 23:57:03 +0100 | [diff] [blame] | 34 | #include <linux/i2c.h> |
| 35 | #include <linux/i2c-gpio.h> |
Mika Westerberg | 4fec997 | 2010-05-11 15:34:54 +0100 | [diff] [blame] | 36 | #include <linux/spi/spi.h> |
Paul Gortmaker | dc28094 | 2011-07-31 16:17:29 -0400 | [diff] [blame] | 37 | #include <linux/export.h> |
Rob Herring | 9e47b8b | 2013-01-07 09:45:59 -0600 | [diff] [blame] | 38 | #include <linux/irqchip/arm-vic.h> |
Robin Holt | 7b6d864 | 2013-07-08 16:01:40 -0700 | [diff] [blame] | 39 | #include <linux/reboot.h> |
H Hartley Sweeten | e55f7cd | 2013-10-21 13:39:04 -0700 | [diff] [blame] | 40 | #include <linux/usb/ohci_pdriver.h> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 41 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 42 | #include <mach/hardware.h> |
Arnd Bergmann | a3b2924 | 2012-08-24 15:12:11 +0200 | [diff] [blame] | 43 | #include <linux/platform_data/video-ep93xx.h> |
| 44 | #include <linux/platform_data/keypad-ep93xx.h> |
| 45 | #include <linux/platform_data/spi-ep93xx.h> |
Linus Walleij | bd5f12a | 2011-09-22 08:07:00 +0100 | [diff] [blame] | 46 | #include <mach/gpio-ep93xx.h> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 47 | |
H Hartley Sweeten | b19e11f | 2013-11-19 10:23:06 +1100 | [diff] [blame] | 48 | #include <asm/mach/arch.h> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 49 | #include <asm/mach/map.h> |
| 50 | #include <asm/mach/time.h> |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 51 | |
Ryan Mallon | a05baf3 | 2012-01-11 09:29:26 +1100 | [diff] [blame] | 52 | #include "soc.h" |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 53 | |
| 54 | /************************************************************************* |
| 55 | * Static I/O mappings that are needed for all EP93xx platforms |
| 56 | *************************************************************************/ |
| 57 | static struct map_desc ep93xx_io_desc[] __initdata = { |
| 58 | { |
| 59 | .virtual = EP93XX_AHB_VIRT_BASE, |
| 60 | .pfn = __phys_to_pfn(EP93XX_AHB_PHYS_BASE), |
| 61 | .length = EP93XX_AHB_SIZE, |
| 62 | .type = MT_DEVICE, |
| 63 | }, { |
| 64 | .virtual = EP93XX_APB_VIRT_BASE, |
| 65 | .pfn = __phys_to_pfn(EP93XX_APB_PHYS_BASE), |
| 66 | .length = EP93XX_APB_SIZE, |
| 67 | .type = MT_DEVICE, |
| 68 | }, |
| 69 | }; |
| 70 | |
| 71 | void __init ep93xx_map_io(void) |
| 72 | { |
| 73 | iotable_init(ep93xx_io_desc, ARRAY_SIZE(ep93xx_io_desc)); |
| 74 | } |
| 75 | |
| 76 | |
| 77 | /************************************************************************* |
| 78 | * Timer handling for EP93xx |
| 79 | ************************************************************************* |
| 80 | * The ep93xx has four internal timers. Timers 1, 2 (both 16 bit) and |
| 81 | * 3 (32 bit) count down at 508 kHz, are self-reloading, and can generate |
| 82 | * an interrupt on underflow. Timer 4 (40 bit) counts down at 983.04 kHz, |
| 83 | * is free-running, and can't generate interrupts. |
| 84 | * |
| 85 | * The 508 kHz timers are ideal for use for the timer interrupt, as the |
| 86 | * most common values of HZ divide 508 kHz nicely. We pick one of the 16 |
| 87 | * bit timers (timer 1) since we don't need more than 16 bits of reload |
| 88 | * value as long as HZ >= 8. |
| 89 | * |
| 90 | * The higher clock rate of timer 4 makes it a better choice than the |
| 91 | * other timers for use in gettimeoffset(), while the fact that it can't |
| 92 | * generate interrupts means we don't have to worry about not being able |
| 93 | * to use this timer for something else. We also use timer 4 for keeping |
| 94 | * track of lost jiffies. |
| 95 | */ |
Hartley Sweeten | 1587a37 | 2010-02-23 21:45:22 +0100 | [diff] [blame] | 96 | #define EP93XX_TIMER_REG(x) (EP93XX_TIMER_BASE + (x)) |
| 97 | #define EP93XX_TIMER1_LOAD EP93XX_TIMER_REG(0x00) |
| 98 | #define EP93XX_TIMER1_VALUE EP93XX_TIMER_REG(0x04) |
| 99 | #define EP93XX_TIMER1_CONTROL EP93XX_TIMER_REG(0x08) |
| 100 | #define EP93XX_TIMER123_CONTROL_ENABLE (1 << 7) |
| 101 | #define EP93XX_TIMER123_CONTROL_MODE (1 << 6) |
| 102 | #define EP93XX_TIMER123_CONTROL_CLKSEL (1 << 3) |
| 103 | #define EP93XX_TIMER1_CLEAR EP93XX_TIMER_REG(0x0c) |
| 104 | #define EP93XX_TIMER2_LOAD EP93XX_TIMER_REG(0x20) |
| 105 | #define EP93XX_TIMER2_VALUE EP93XX_TIMER_REG(0x24) |
| 106 | #define EP93XX_TIMER2_CONTROL EP93XX_TIMER_REG(0x28) |
| 107 | #define EP93XX_TIMER2_CLEAR EP93XX_TIMER_REG(0x2c) |
| 108 | #define EP93XX_TIMER4_VALUE_LOW EP93XX_TIMER_REG(0x60) |
| 109 | #define EP93XX_TIMER4_VALUE_HIGH EP93XX_TIMER_REG(0x64) |
| 110 | #define EP93XX_TIMER4_VALUE_HIGH_ENABLE (1 << 8) |
| 111 | #define EP93XX_TIMER3_LOAD EP93XX_TIMER_REG(0x80) |
| 112 | #define EP93XX_TIMER3_VALUE EP93XX_TIMER_REG(0x84) |
| 113 | #define EP93XX_TIMER3_CONTROL EP93XX_TIMER_REG(0x88) |
| 114 | #define EP93XX_TIMER3_CLEAR EP93XX_TIMER_REG(0x8c) |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 115 | |
Hartley Sweeten | 1587a37 | 2010-02-23 21:45:22 +0100 | [diff] [blame] | 116 | #define EP93XX_TIMER123_CLOCK 508469 |
| 117 | #define EP93XX_TIMER4_CLOCK 983040 |
| 118 | |
| 119 | #define TIMER1_RELOAD ((EP93XX_TIMER123_CLOCK / HZ) - 1) |
Uwe Kleine-König | a509ad0 | 2013-11-12 20:56:02 +0100 | [diff] [blame] | 120 | #define TIMER4_TICKS_PER_JIFFY DIV_ROUND_CLOSEST(EP93XX_TIMER4_CLOCK, HZ) |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 121 | |
Hartley Sweeten | 1587a37 | 2010-02-23 21:45:22 +0100 | [diff] [blame] | 122 | static unsigned int last_jiffy_time; |
| 123 | |
Hartley Sweeten | d5565f7 | 2009-04-14 21:38:07 +0100 | [diff] [blame] | 124 | static irqreturn_t ep93xx_timer_interrupt(int irq, void *dev_id) |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 125 | { |
Hartley Sweeten | 1587a37 | 2010-02-23 21:45:22 +0100 | [diff] [blame] | 126 | /* Writing any value clears the timer interrupt */ |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 127 | __raw_writel(1, EP93XX_TIMER1_CLEAR); |
Hartley Sweeten | 1587a37 | 2010-02-23 21:45:22 +0100 | [diff] [blame] | 128 | |
| 129 | /* Recover lost jiffies */ |
Lennert Buytenhek | f869afa | 2006-06-22 10:30:53 +0100 | [diff] [blame] | 130 | while ((signed long) |
| 131 | (__raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time) |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 132 | >= TIMER4_TICKS_PER_JIFFY) { |
| 133 | last_jiffy_time += TIMER4_TICKS_PER_JIFFY; |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 134 | timer_tick(); |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 135 | } |
| 136 | |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 137 | return IRQ_HANDLED; |
| 138 | } |
| 139 | |
| 140 | static struct irqaction ep93xx_timer_irq = { |
| 141 | .name = "ep93xx timer", |
Michael Opdenacker | 3a71ae4 | 2013-11-19 10:22:11 +1100 | [diff] [blame] | 142 | .flags = IRQF_TIMER | IRQF_IRQPOLL, |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 143 | .handler = ep93xx_timer_interrupt, |
| 144 | }; |
| 145 | |
Stephen Warren | 23c197b | 2012-11-08 11:51:58 -0700 | [diff] [blame] | 146 | static u32 ep93xx_gettimeoffset(void) |
| 147 | { |
| 148 | int offset; |
| 149 | |
| 150 | offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time; |
| 151 | |
| 152 | /* |
| 153 | * Timer 4 is based on a 983.04 kHz reference clock, |
| 154 | * so dividing by 983040 gives the fraction of a second, |
| 155 | * so dividing by 0.983040 converts to uS. |
| 156 | * Refactor the calculation to avoid overflow. |
| 157 | * Finally, multiply by 1000 to give nS. |
| 158 | */ |
| 159 | return (offset + (53 * offset / 3072)) * 1000; |
| 160 | } |
| 161 | |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 162 | void __init ep93xx_timer_init(void) |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 163 | { |
Hartley Sweeten | 1587a37 | 2010-02-23 21:45:22 +0100 | [diff] [blame] | 164 | u32 tmode = EP93XX_TIMER123_CONTROL_MODE | |
| 165 | EP93XX_TIMER123_CONTROL_CLKSEL; |
| 166 | |
Stephen Warren | 23c197b | 2012-11-08 11:51:58 -0700 | [diff] [blame] | 167 | arch_gettimeoffset = ep93xx_gettimeoffset; |
| 168 | |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 169 | /* Enable periodic HZ timer. */ |
Hartley Sweeten | 1587a37 | 2010-02-23 21:45:22 +0100 | [diff] [blame] | 170 | __raw_writel(tmode, EP93XX_TIMER1_CONTROL); |
| 171 | __raw_writel(TIMER1_RELOAD, EP93XX_TIMER1_LOAD); |
| 172 | __raw_writel(tmode | EP93XX_TIMER123_CONTROL_ENABLE, |
| 173 | EP93XX_TIMER1_CONTROL); |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 174 | |
| 175 | /* Enable lost jiffy timer. */ |
Hartley Sweeten | 1587a37 | 2010-02-23 21:45:22 +0100 | [diff] [blame] | 176 | __raw_writel(EP93XX_TIMER4_VALUE_HIGH_ENABLE, |
| 177 | EP93XX_TIMER4_VALUE_HIGH); |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 178 | |
| 179 | setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq); |
| 180 | } |
| 181 | |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 182 | |
| 183 | /************************************************************************* |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 184 | * EP93xx IRQ handling |
| 185 | *************************************************************************/ |
| 186 | void __init ep93xx_init_irq(void) |
| 187 | { |
Hartley Sweeten | 5396730 | 2009-07-09 23:22:07 +0100 | [diff] [blame] | 188 | vic_init(EP93XX_VIC1_BASE, 0, EP93XX_VIC1_VALID_IRQ_MASK, 0); |
| 189 | vic_init(EP93XX_VIC2_BASE, 32, EP93XX_VIC2_VALID_IRQ_MASK, 0); |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | |
| 193 | /************************************************************************* |
Hartley Sweeten | 02239f0 | 2009-07-08 02:00:49 +0100 | [diff] [blame] | 194 | * EP93xx System Controller Software Locked register handling |
| 195 | *************************************************************************/ |
| 196 | |
| 197 | /* |
| 198 | * syscon_swlock prevents anything else from writing to the syscon |
| 199 | * block while a software locked register is being written. |
| 200 | */ |
| 201 | static DEFINE_SPINLOCK(syscon_swlock); |
| 202 | |
Ryan Mallon | fbeeea5 | 2009-07-15 21:51:59 +0100 | [diff] [blame] | 203 | void ep93xx_syscon_swlocked_write(unsigned int val, void __iomem *reg) |
Hartley Sweeten | 02239f0 | 2009-07-08 02:00:49 +0100 | [diff] [blame] | 204 | { |
| 205 | unsigned long flags; |
| 206 | |
| 207 | spin_lock_irqsave(&syscon_swlock, flags); |
| 208 | |
| 209 | __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK); |
| 210 | __raw_writel(val, reg); |
| 211 | |
| 212 | spin_unlock_irqrestore(&syscon_swlock, flags); |
| 213 | } |
Hartley Sweeten | 02239f0 | 2009-07-08 02:00:49 +0100 | [diff] [blame] | 214 | |
| 215 | void ep93xx_devcfg_set_clear(unsigned int set_bits, unsigned int clear_bits) |
| 216 | { |
| 217 | unsigned long flags; |
| 218 | unsigned int val; |
| 219 | |
| 220 | spin_lock_irqsave(&syscon_swlock, flags); |
| 221 | |
| 222 | val = __raw_readl(EP93XX_SYSCON_DEVCFG); |
Hartley Sweeten | 02239f0 | 2009-07-08 02:00:49 +0100 | [diff] [blame] | 223 | val &= ~clear_bits; |
Hartley Sweeten | a0fb007 | 2010-06-14 16:54:16 +0100 | [diff] [blame] | 224 | val |= set_bits; |
Hartley Sweeten | 02239f0 | 2009-07-08 02:00:49 +0100 | [diff] [blame] | 225 | __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK); |
| 226 | __raw_writel(val, EP93XX_SYSCON_DEVCFG); |
| 227 | |
| 228 | spin_unlock_irqrestore(&syscon_swlock, flags); |
| 229 | } |
Hartley Sweeten | 02239f0 | 2009-07-08 02:00:49 +0100 | [diff] [blame] | 230 | |
Mika Westerberg | 99e6a23 | 2010-03-27 12:05:14 +0100 | [diff] [blame] | 231 | /** |
| 232 | * ep93xx_chip_revision() - returns the EP93xx chip revision |
| 233 | * |
| 234 | * See <mach/platform.h> for more information. |
| 235 | */ |
| 236 | unsigned int ep93xx_chip_revision(void) |
| 237 | { |
| 238 | unsigned int v; |
| 239 | |
| 240 | v = __raw_readl(EP93XX_SYSCON_SYSCFG); |
| 241 | v &= EP93XX_SYSCON_SYSCFG_REV_MASK; |
| 242 | v >>= EP93XX_SYSCON_SYSCFG_REV_SHIFT; |
| 243 | return v; |
| 244 | } |
Arnd Bergmann | 67e108c | 2014-03-13 17:52:39 +0100 | [diff] [blame] | 245 | EXPORT_SYMBOL_GPL(ep93xx_chip_revision); |
Hartley Sweeten | 02239f0 | 2009-07-08 02:00:49 +0100 | [diff] [blame] | 246 | |
| 247 | /************************************************************************* |
H Hartley Sweeten | 1e4c884 | 2011-06-08 14:35:33 -0700 | [diff] [blame] | 248 | * EP93xx GPIO |
| 249 | *************************************************************************/ |
| 250 | static struct resource ep93xx_gpio_resource[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 251 | DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE, 0xcc), |
H Hartley Sweeten | 1e4c884 | 2011-06-08 14:35:33 -0700 | [diff] [blame] | 252 | }; |
| 253 | |
| 254 | static struct platform_device ep93xx_gpio_device = { |
| 255 | .name = "gpio-ep93xx", |
| 256 | .id = -1, |
| 257 | .num_resources = ARRAY_SIZE(ep93xx_gpio_resource), |
| 258 | .resource = ep93xx_gpio_resource, |
| 259 | }; |
| 260 | |
| 261 | /************************************************************************* |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 262 | * EP93xx peripheral handling |
| 263 | *************************************************************************/ |
Lennert Buytenhek | aee85fe | 2006-03-26 23:16:39 +0100 | [diff] [blame] | 264 | #define EP93XX_UART_MCR_OFFSET (0x0100) |
| 265 | |
| 266 | static void ep93xx_uart_set_mctrl(struct amba_device *dev, |
| 267 | void __iomem *base, unsigned int mctrl) |
| 268 | { |
| 269 | unsigned int mcr; |
| 270 | |
| 271 | mcr = 0; |
Petr Štetiar | 186dcaa | 2011-06-17 11:10:04 +0100 | [diff] [blame] | 272 | if (mctrl & TIOCM_RTS) |
Lennert Buytenhek | aee85fe | 2006-03-26 23:16:39 +0100 | [diff] [blame] | 273 | mcr |= 2; |
Petr Štetiar | 186dcaa | 2011-06-17 11:10:04 +0100 | [diff] [blame] | 274 | if (mctrl & TIOCM_DTR) |
Lennert Buytenhek | aee85fe | 2006-03-26 23:16:39 +0100 | [diff] [blame] | 275 | mcr |= 1; |
| 276 | |
| 277 | __raw_writel(mcr, base + EP93XX_UART_MCR_OFFSET); |
| 278 | } |
| 279 | |
| 280 | static struct amba_pl010_data ep93xx_uart_data = { |
| 281 | .set_mctrl = ep93xx_uart_set_mctrl, |
| 282 | }; |
| 283 | |
Russell King | 0b26051 | 2011-12-18 15:16:40 +0000 | [diff] [blame] | 284 | static AMBA_APB_DEVICE(uart1, "apb:uart1", 0x00041010, EP93XX_UART1_PHYS_BASE, |
| 285 | { IRQ_EP93XX_UART1 }, &ep93xx_uart_data); |
Lennert Buytenhek | aee85fe | 2006-03-26 23:16:39 +0100 | [diff] [blame] | 286 | |
Russell King | 0b26051 | 2011-12-18 15:16:40 +0000 | [diff] [blame] | 287 | static AMBA_APB_DEVICE(uart2, "apb:uart2", 0x00041010, EP93XX_UART2_PHYS_BASE, |
Petr Štetiar | cc3874f | 2013-08-29 16:28:11 +0200 | [diff] [blame] | 288 | { IRQ_EP93XX_UART2 }, NULL); |
Lennert Buytenhek | aee85fe | 2006-03-26 23:16:39 +0100 | [diff] [blame] | 289 | |
Russell King | 0b26051 | 2011-12-18 15:16:40 +0000 | [diff] [blame] | 290 | static AMBA_APB_DEVICE(uart3, "apb:uart3", 0x00041010, EP93XX_UART3_PHYS_BASE, |
| 291 | { IRQ_EP93XX_UART3 }, &ep93xx_uart_data); |
Lennert Buytenhek | 4165813 | 2006-04-02 16:17:34 +0100 | [diff] [blame] | 292 | |
Hartley Sweeten | 38f7b00 | 2009-04-15 23:18:26 +0100 | [diff] [blame] | 293 | static struct resource ep93xx_rtc_resource[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 294 | DEFINE_RES_MEM(EP93XX_RTC_PHYS_BASE, 0x10c), |
Hartley Sweeten | 38f7b00 | 2009-04-15 23:18:26 +0100 | [diff] [blame] | 295 | }; |
| 296 | |
Lennert Buytenhek | 4165813 | 2006-04-02 16:17:34 +0100 | [diff] [blame] | 297 | static struct platform_device ep93xx_rtc_device = { |
Hartley Sweeten | 38f7b00 | 2009-04-15 23:18:26 +0100 | [diff] [blame] | 298 | .name = "ep93xx-rtc", |
| 299 | .id = -1, |
| 300 | .num_resources = ARRAY_SIZE(ep93xx_rtc_resource), |
| 301 | .resource = ep93xx_rtc_resource, |
Lennert Buytenhek | 4165813 | 2006-04-02 16:17:34 +0100 | [diff] [blame] | 302 | }; |
| 303 | |
H Hartley Sweeten | e55f7cd | 2013-10-21 13:39:04 -0700 | [diff] [blame] | 304 | /************************************************************************* |
| 305 | * EP93xx OHCI USB Host |
| 306 | *************************************************************************/ |
| 307 | |
| 308 | static struct clk *ep93xx_ohci_host_clock; |
| 309 | |
| 310 | static int ep93xx_ohci_power_on(struct platform_device *pdev) |
| 311 | { |
| 312 | if (!ep93xx_ohci_host_clock) { |
| 313 | ep93xx_ohci_host_clock = devm_clk_get(&pdev->dev, NULL); |
| 314 | if (IS_ERR(ep93xx_ohci_host_clock)) |
| 315 | return PTR_ERR(ep93xx_ohci_host_clock); |
| 316 | } |
| 317 | |
| 318 | return clk_enable(ep93xx_ohci_host_clock); |
| 319 | } |
| 320 | |
| 321 | static void ep93xx_ohci_power_off(struct platform_device *pdev) |
| 322 | { |
| 323 | clk_disable(ep93xx_ohci_host_clock); |
| 324 | } |
| 325 | |
| 326 | static struct usb_ohci_pdata ep93xx_ohci_pdata = { |
| 327 | .power_on = ep93xx_ohci_power_on, |
| 328 | .power_off = ep93xx_ohci_power_off, |
| 329 | .power_suspend = ep93xx_ohci_power_off, |
| 330 | }; |
Lennert Buytenhek | 4165813 | 2006-04-02 16:17:34 +0100 | [diff] [blame] | 331 | |
Lennert Buytenhek | 1f64eb3 | 2006-06-24 10:33:03 +0100 | [diff] [blame] | 332 | static struct resource ep93xx_ohci_resources[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 333 | DEFINE_RES_MEM(EP93XX_USB_PHYS_BASE, 0x1000), |
| 334 | DEFINE_RES_IRQ(IRQ_EP93XX_USB), |
Lennert Buytenhek | 1f64eb3 | 2006-06-24 10:33:03 +0100 | [diff] [blame] | 335 | }; |
| 336 | |
H Hartley Sweeten | e55f7cd | 2013-10-21 13:39:04 -0700 | [diff] [blame] | 337 | static u64 ep93xx_ohci_dma_mask = DMA_BIT_MASK(32); |
Matthias Kaehlcke | 63890a0 | 2008-10-29 14:14:52 -0700 | [diff] [blame] | 338 | |
Lennert Buytenhek | 1f64eb3 | 2006-06-24 10:33:03 +0100 | [diff] [blame] | 339 | static struct platform_device ep93xx_ohci_device = { |
H Hartley Sweeten | e55f7cd | 2013-10-21 13:39:04 -0700 | [diff] [blame] | 340 | .name = "ohci-platform", |
Lennert Buytenhek | 1f64eb3 | 2006-06-24 10:33:03 +0100 | [diff] [blame] | 341 | .id = -1, |
Lennert Buytenhek | 1f64eb3 | 2006-06-24 10:33:03 +0100 | [diff] [blame] | 342 | .num_resources = ARRAY_SIZE(ep93xx_ohci_resources), |
| 343 | .resource = ep93xx_ohci_resources, |
H Hartley Sweeten | e55f7cd | 2013-10-21 13:39:04 -0700 | [diff] [blame] | 344 | .dev = { |
| 345 | .dma_mask = &ep93xx_ohci_dma_mask, |
| 346 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 347 | .platform_data = &ep93xx_ohci_pdata, |
| 348 | }, |
Lennert Buytenhek | 1f64eb3 | 2006-06-24 10:33:03 +0100 | [diff] [blame] | 349 | }; |
| 350 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 351 | /************************************************************************* |
Hartley Sweeten | 16bcf78 | 2010-06-10 16:19:08 +0100 | [diff] [blame] | 352 | * EP93xx physmap'ed flash |
| 353 | *************************************************************************/ |
| 354 | static struct physmap_flash_data ep93xx_flash_data; |
| 355 | |
| 356 | static struct resource ep93xx_flash_resource = { |
| 357 | .flags = IORESOURCE_MEM, |
| 358 | }; |
| 359 | |
| 360 | static struct platform_device ep93xx_flash = { |
| 361 | .name = "physmap-flash", |
| 362 | .id = 0, |
| 363 | .dev = { |
| 364 | .platform_data = &ep93xx_flash_data, |
| 365 | }, |
| 366 | .num_resources = 1, |
| 367 | .resource = &ep93xx_flash_resource, |
| 368 | }; |
| 369 | |
| 370 | /** |
| 371 | * ep93xx_register_flash() - Register the external flash device. |
| 372 | * @width: bank width in octets |
| 373 | * @start: resource start address |
| 374 | * @size: resource size |
| 375 | */ |
| 376 | void __init ep93xx_register_flash(unsigned int width, |
| 377 | resource_size_t start, resource_size_t size) |
| 378 | { |
| 379 | ep93xx_flash_data.width = width; |
| 380 | |
| 381 | ep93xx_flash_resource.start = start; |
| 382 | ep93xx_flash_resource.end = start + size - 1; |
| 383 | |
| 384 | platform_device_register(&ep93xx_flash); |
| 385 | } |
| 386 | |
| 387 | |
| 388 | /************************************************************************* |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 389 | * EP93xx ethernet peripheral handling |
| 390 | *************************************************************************/ |
Hartley Sweeten | a0a08fd | 2008-10-04 20:01:49 +0100 | [diff] [blame] | 391 | static struct ep93xx_eth_data ep93xx_eth_data; |
| 392 | |
| 393 | static struct resource ep93xx_eth_resource[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 394 | DEFINE_RES_MEM(EP93XX_ETHERNET_PHYS_BASE, 0x10000), |
Ryan Mallon | 011b2e8 | 2012-04-12 09:11:55 +1000 | [diff] [blame] | 395 | DEFINE_RES_IRQ(IRQ_EP93XX_ETHERNET), |
Hartley Sweeten | a0a08fd | 2008-10-04 20:01:49 +0100 | [diff] [blame] | 396 | }; |
| 397 | |
Mika Westerberg | fa70cf4 | 2011-06-11 08:39:54 +0000 | [diff] [blame] | 398 | static u64 ep93xx_eth_dma_mask = DMA_BIT_MASK(32); |
| 399 | |
Hartley Sweeten | a0a08fd | 2008-10-04 20:01:49 +0100 | [diff] [blame] | 400 | static struct platform_device ep93xx_eth_device = { |
| 401 | .name = "ep93xx-eth", |
| 402 | .id = -1, |
| 403 | .dev = { |
Mika Westerberg | fa70cf4 | 2011-06-11 08:39:54 +0000 | [diff] [blame] | 404 | .platform_data = &ep93xx_eth_data, |
| 405 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 406 | .dma_mask = &ep93xx_eth_dma_mask, |
Hartley Sweeten | a0a08fd | 2008-10-04 20:01:49 +0100 | [diff] [blame] | 407 | }, |
| 408 | .num_resources = ARRAY_SIZE(ep93xx_eth_resource), |
| 409 | .resource = ep93xx_eth_resource, |
| 410 | }; |
| 411 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 412 | /** |
| 413 | * ep93xx_register_eth - Register the built-in ethernet platform device. |
| 414 | * @data: platform specific ethernet configuration (__initdata) |
| 415 | * @copy_addr: flag indicating that the MAC address should be copied |
| 416 | * from the IndAd registers (as programmed by the bootloader) |
| 417 | */ |
Hartley Sweeten | a0a08fd | 2008-10-04 20:01:49 +0100 | [diff] [blame] | 418 | void __init ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr) |
| 419 | { |
Hartley Sweeten | 5b1c3c8 | 2009-07-13 19:50:10 +0100 | [diff] [blame] | 420 | if (copy_addr) |
| 421 | memcpy_fromio(data->dev_addr, EP93XX_ETHERNET_BASE + 0x50, 6); |
Hartley Sweeten | a0a08fd | 2008-10-04 20:01:49 +0100 | [diff] [blame] | 422 | |
| 423 | ep93xx_eth_data = *data; |
| 424 | platform_device_register(&ep93xx_eth_device); |
| 425 | } |
| 426 | |
Hartley Sweeten | 6531a99 | 2009-10-08 00:45:00 +0100 | [diff] [blame] | 427 | |
| 428 | /************************************************************************* |
| 429 | * EP93xx i2c peripheral handling |
| 430 | *************************************************************************/ |
| 431 | static struct i2c_gpio_platform_data ep93xx_i2c_data; |
Hartley Sweeten | d52a26a | 2008-10-16 23:57:03 +0100 | [diff] [blame] | 432 | |
| 433 | static struct platform_device ep93xx_i2c_device = { |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 434 | .name = "i2c-gpio", |
| 435 | .id = 0, |
| 436 | .dev = { |
| 437 | .platform_data = &ep93xx_i2c_data, |
| 438 | }, |
Hartley Sweeten | d52a26a | 2008-10-16 23:57:03 +0100 | [diff] [blame] | 439 | }; |
| 440 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 441 | /** |
| 442 | * ep93xx_register_i2c - Register the i2c platform device. |
| 443 | * @data: platform specific i2c-gpio configuration (__initdata) |
| 444 | * @devices: platform specific i2c bus device information (__initdata) |
| 445 | * @num: the number of devices on the i2c bus |
| 446 | */ |
Hartley Sweeten | 6531a99 | 2009-10-08 00:45:00 +0100 | [diff] [blame] | 447 | void __init ep93xx_register_i2c(struct i2c_gpio_platform_data *data, |
| 448 | struct i2c_board_info *devices, int num) |
Hartley Sweeten | d52a26a | 2008-10-16 23:57:03 +0100 | [diff] [blame] | 449 | { |
Hartley Sweeten | 6531a99 | 2009-10-08 00:45:00 +0100 | [diff] [blame] | 450 | /* |
| 451 | * Set the EEPROM interface pin drive type control. |
| 452 | * Defines the driver type for the EECLK and EEDAT pins as either |
| 453 | * open drain, which will require an external pull-up, or a normal |
| 454 | * CMOS driver. |
| 455 | */ |
| 456 | if (data->sda_is_open_drain && data->sda_pin != EP93XX_GPIO_LINE_EEDAT) |
Hartley Sweeten | 64d6882 | 2010-01-11 19:33:16 +0100 | [diff] [blame] | 457 | pr_warning("sda != EEDAT, open drain has no effect\n"); |
Hartley Sweeten | 6531a99 | 2009-10-08 00:45:00 +0100 | [diff] [blame] | 458 | if (data->scl_is_open_drain && data->scl_pin != EP93XX_GPIO_LINE_EECLK) |
Hartley Sweeten | 64d6882 | 2010-01-11 19:33:16 +0100 | [diff] [blame] | 459 | pr_warning("scl != EECLK, open drain has no effect\n"); |
Hartley Sweeten | 6531a99 | 2009-10-08 00:45:00 +0100 | [diff] [blame] | 460 | |
| 461 | __raw_writel((data->sda_is_open_drain << 1) | |
| 462 | (data->scl_is_open_drain << 0), |
| 463 | EP93XX_GPIO_EEDRIVE); |
| 464 | |
| 465 | ep93xx_i2c_data = *data; |
Hartley Sweeten | d52a26a | 2008-10-16 23:57:03 +0100 | [diff] [blame] | 466 | i2c_register_board_info(0, devices, num); |
| 467 | platform_device_register(&ep93xx_i2c_device); |
| 468 | } |
| 469 | |
Mika Westerberg | 4fec997 | 2010-05-11 15:34:54 +0100 | [diff] [blame] | 470 | /************************************************************************* |
| 471 | * EP93xx SPI peripheral handling |
| 472 | *************************************************************************/ |
| 473 | static struct ep93xx_spi_info ep93xx_spi_master_data; |
| 474 | |
| 475 | static struct resource ep93xx_spi_resources[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 476 | DEFINE_RES_MEM(EP93XX_SPI_PHYS_BASE, 0x18), |
| 477 | DEFINE_RES_IRQ(IRQ_EP93XX_SSP), |
Mika Westerberg | 4fec997 | 2010-05-11 15:34:54 +0100 | [diff] [blame] | 478 | }; |
| 479 | |
Mika Westerberg | 626a96d | 2011-05-29 13:10:06 +0300 | [diff] [blame] | 480 | static u64 ep93xx_spi_dma_mask = DMA_BIT_MASK(32); |
| 481 | |
Mika Westerberg | 4fec997 | 2010-05-11 15:34:54 +0100 | [diff] [blame] | 482 | static struct platform_device ep93xx_spi_device = { |
| 483 | .name = "ep93xx-spi", |
| 484 | .id = 0, |
| 485 | .dev = { |
Mika Westerberg | 626a96d | 2011-05-29 13:10:06 +0300 | [diff] [blame] | 486 | .platform_data = &ep93xx_spi_master_data, |
| 487 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 488 | .dma_mask = &ep93xx_spi_dma_mask, |
Mika Westerberg | 4fec997 | 2010-05-11 15:34:54 +0100 | [diff] [blame] | 489 | }, |
| 490 | .num_resources = ARRAY_SIZE(ep93xx_spi_resources), |
| 491 | .resource = ep93xx_spi_resources, |
| 492 | }; |
| 493 | |
| 494 | /** |
| 495 | * ep93xx_register_spi() - registers spi platform device |
| 496 | * @info: ep93xx board specific spi master info (__initdata) |
| 497 | * @devices: SPI devices to register (__initdata) |
| 498 | * @num: number of SPI devices to register |
| 499 | * |
| 500 | * This function registers platform device for the EP93xx SPI controller and |
| 501 | * also makes sure that SPI pins are muxed so that I2S is not using those pins. |
| 502 | */ |
| 503 | void __init ep93xx_register_spi(struct ep93xx_spi_info *info, |
| 504 | struct spi_board_info *devices, int num) |
| 505 | { |
| 506 | /* |
| 507 | * When SPI is used, we need to make sure that I2S is muxed off from |
| 508 | * SPI pins. |
| 509 | */ |
| 510 | ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONSSP); |
| 511 | |
| 512 | ep93xx_spi_master_data = *info; |
| 513 | spi_register_board_info(devices, num); |
| 514 | platform_device_register(&ep93xx_spi_device); |
| 515 | } |
Hartley Sweeten | 3aa7a9a | 2009-07-20 18:22:36 +0100 | [diff] [blame] | 516 | |
| 517 | /************************************************************************* |
| 518 | * EP93xx LEDs |
| 519 | *************************************************************************/ |
H Hartley Sweeten | a1eacd7 | 2012-04-11 15:44:42 -0700 | [diff] [blame] | 520 | static const struct gpio_led ep93xx_led_pins[] __initconst = { |
Hartley Sweeten | 3aa7a9a | 2009-07-20 18:22:36 +0100 | [diff] [blame] | 521 | { |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 522 | .name = "platform:grled", |
| 523 | .gpio = EP93XX_GPIO_LINE_GRLED, |
Hartley Sweeten | 3aa7a9a | 2009-07-20 18:22:36 +0100 | [diff] [blame] | 524 | }, { |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 525 | .name = "platform:rdled", |
| 526 | .gpio = EP93XX_GPIO_LINE_RDLED, |
Hartley Sweeten | 3aa7a9a | 2009-07-20 18:22:36 +0100 | [diff] [blame] | 527 | }, |
| 528 | }; |
| 529 | |
H Hartley Sweeten | a1eacd7 | 2012-04-11 15:44:42 -0700 | [diff] [blame] | 530 | static const struct gpio_led_platform_data ep93xx_led_data __initconst = { |
Hartley Sweeten | 3aa7a9a | 2009-07-20 18:22:36 +0100 | [diff] [blame] | 531 | .num_leds = ARRAY_SIZE(ep93xx_led_pins), |
| 532 | .leds = ep93xx_led_pins, |
| 533 | }; |
| 534 | |
Hartley Sweeten | ef12379 | 2009-07-29 22:41:06 +0100 | [diff] [blame] | 535 | /************************************************************************* |
| 536 | * EP93xx pwm peripheral handling |
| 537 | *************************************************************************/ |
| 538 | static struct resource ep93xx_pwm0_resource[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 539 | DEFINE_RES_MEM(EP93XX_PWM_PHYS_BASE, 0x10), |
Hartley Sweeten | ef12379 | 2009-07-29 22:41:06 +0100 | [diff] [blame] | 540 | }; |
| 541 | |
| 542 | static struct platform_device ep93xx_pwm0_device = { |
| 543 | .name = "ep93xx-pwm", |
| 544 | .id = 0, |
| 545 | .num_resources = ARRAY_SIZE(ep93xx_pwm0_resource), |
| 546 | .resource = ep93xx_pwm0_resource, |
| 547 | }; |
| 548 | |
| 549 | static struct resource ep93xx_pwm1_resource[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 550 | DEFINE_RES_MEM(EP93XX_PWM_PHYS_BASE + 0x20, 0x10), |
Hartley Sweeten | ef12379 | 2009-07-29 22:41:06 +0100 | [diff] [blame] | 551 | }; |
| 552 | |
| 553 | static struct platform_device ep93xx_pwm1_device = { |
| 554 | .name = "ep93xx-pwm", |
| 555 | .id = 1, |
| 556 | .num_resources = ARRAY_SIZE(ep93xx_pwm1_resource), |
| 557 | .resource = ep93xx_pwm1_resource, |
| 558 | }; |
| 559 | |
| 560 | void __init ep93xx_register_pwm(int pwm0, int pwm1) |
| 561 | { |
| 562 | if (pwm0) |
| 563 | platform_device_register(&ep93xx_pwm0_device); |
| 564 | |
| 565 | /* NOTE: EP9307 does not have PWMOUT1 (pin EGPIO14) */ |
| 566 | if (pwm1) |
| 567 | platform_device_register(&ep93xx_pwm1_device); |
| 568 | } |
| 569 | |
| 570 | int ep93xx_pwm_acquire_gpio(struct platform_device *pdev) |
| 571 | { |
| 572 | int err; |
| 573 | |
| 574 | if (pdev->id == 0) { |
| 575 | err = 0; |
| 576 | } else if (pdev->id == 1) { |
| 577 | err = gpio_request(EP93XX_GPIO_LINE_EGPIO14, |
| 578 | dev_name(&pdev->dev)); |
| 579 | if (err) |
| 580 | return err; |
| 581 | err = gpio_direction_output(EP93XX_GPIO_LINE_EGPIO14, 0); |
| 582 | if (err) |
| 583 | goto fail; |
| 584 | |
| 585 | /* PWM 1 output on EGPIO[14] */ |
| 586 | ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_PONG); |
| 587 | } else { |
| 588 | err = -ENODEV; |
| 589 | } |
| 590 | |
| 591 | return err; |
| 592 | |
| 593 | fail: |
| 594 | gpio_free(EP93XX_GPIO_LINE_EGPIO14); |
| 595 | return err; |
| 596 | } |
| 597 | EXPORT_SYMBOL(ep93xx_pwm_acquire_gpio); |
| 598 | |
| 599 | void ep93xx_pwm_release_gpio(struct platform_device *pdev) |
| 600 | { |
| 601 | if (pdev->id == 1) { |
| 602 | gpio_direction_input(EP93XX_GPIO_LINE_EGPIO14); |
| 603 | gpio_free(EP93XX_GPIO_LINE_EGPIO14); |
| 604 | |
| 605 | /* EGPIO[14] used for GPIO */ |
| 606 | ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_PONG); |
| 607 | } |
| 608 | } |
| 609 | EXPORT_SYMBOL(ep93xx_pwm_release_gpio); |
| 610 | |
| 611 | |
Ryan Mallon | c601218 | 2009-09-22 16:47:09 -0700 | [diff] [blame] | 612 | /************************************************************************* |
| 613 | * EP93xx video peripheral handling |
| 614 | *************************************************************************/ |
| 615 | static struct ep93xxfb_mach_info ep93xxfb_data; |
| 616 | |
| 617 | static struct resource ep93xx_fb_resource[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 618 | DEFINE_RES_MEM(EP93XX_RASTER_PHYS_BASE, 0x800), |
Ryan Mallon | c601218 | 2009-09-22 16:47:09 -0700 | [diff] [blame] | 619 | }; |
| 620 | |
| 621 | static struct platform_device ep93xx_fb_device = { |
| 622 | .name = "ep93xx-fb", |
| 623 | .id = -1, |
| 624 | .dev = { |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 625 | .platform_data = &ep93xxfb_data, |
Ryan Mallon | c601218 | 2009-09-22 16:47:09 -0700 | [diff] [blame] | 626 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 627 | .dma_mask = &ep93xx_fb_device.dev.coherent_dma_mask, |
| 628 | }, |
| 629 | .num_resources = ARRAY_SIZE(ep93xx_fb_resource), |
| 630 | .resource = ep93xx_fb_resource, |
| 631 | }; |
| 632 | |
Ryan Mallon | 0fd1958 | 2012-01-22 20:31:32 +1100 | [diff] [blame] | 633 | /* The backlight use a single register in the framebuffer's register space */ |
| 634 | #define EP93XX_RASTER_REG_BRIGHTNESS 0x20 |
| 635 | |
| 636 | static struct resource ep93xx_bl_resources[] = { |
| 637 | DEFINE_RES_MEM(EP93XX_RASTER_PHYS_BASE + |
| 638 | EP93XX_RASTER_REG_BRIGHTNESS, 0x04), |
| 639 | }; |
| 640 | |
Hartley Sweeten | 6ea4b74 | 2010-06-09 21:15:12 +0100 | [diff] [blame] | 641 | static struct platform_device ep93xx_bl_device = { |
| 642 | .name = "ep93xx-bl", |
| 643 | .id = -1, |
Ryan Mallon | 0fd1958 | 2012-01-22 20:31:32 +1100 | [diff] [blame] | 644 | .num_resources = ARRAY_SIZE(ep93xx_bl_resources), |
| 645 | .resource = ep93xx_bl_resources, |
Hartley Sweeten | 6ea4b74 | 2010-06-09 21:15:12 +0100 | [diff] [blame] | 646 | }; |
| 647 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 648 | /** |
| 649 | * ep93xx_register_fb - Register the framebuffer platform device. |
| 650 | * @data: platform specific framebuffer configuration (__initdata) |
| 651 | */ |
Ryan Mallon | c601218 | 2009-09-22 16:47:09 -0700 | [diff] [blame] | 652 | void __init ep93xx_register_fb(struct ep93xxfb_mach_info *data) |
| 653 | { |
| 654 | ep93xxfb_data = *data; |
| 655 | platform_device_register(&ep93xx_fb_device); |
Hartley Sweeten | 6ea4b74 | 2010-06-09 21:15:12 +0100 | [diff] [blame] | 656 | platform_device_register(&ep93xx_bl_device); |
Ryan Mallon | c601218 | 2009-09-22 16:47:09 -0700 | [diff] [blame] | 657 | } |
| 658 | |
Hartley Sweeten | 12f56c6 | 2009-10-28 21:04:46 +0100 | [diff] [blame] | 659 | |
| 660 | /************************************************************************* |
| 661 | * EP93xx matrix keypad peripheral handling |
| 662 | *************************************************************************/ |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 663 | static struct ep93xx_keypad_platform_data ep93xx_keypad_data; |
| 664 | |
Hartley Sweeten | 12f56c6 | 2009-10-28 21:04:46 +0100 | [diff] [blame] | 665 | static struct resource ep93xx_keypad_resource[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 666 | DEFINE_RES_MEM(EP93XX_KEY_MATRIX_PHYS_BASE, 0x0c), |
| 667 | DEFINE_RES_IRQ(IRQ_EP93XX_KEY), |
Hartley Sweeten | 12f56c6 | 2009-10-28 21:04:46 +0100 | [diff] [blame] | 668 | }; |
| 669 | |
| 670 | static struct platform_device ep93xx_keypad_device = { |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 671 | .name = "ep93xx-keypad", |
| 672 | .id = -1, |
| 673 | .dev = { |
| 674 | .platform_data = &ep93xx_keypad_data, |
| 675 | }, |
| 676 | .num_resources = ARRAY_SIZE(ep93xx_keypad_resource), |
| 677 | .resource = ep93xx_keypad_resource, |
Hartley Sweeten | 12f56c6 | 2009-10-28 21:04:46 +0100 | [diff] [blame] | 678 | }; |
| 679 | |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 680 | /** |
| 681 | * ep93xx_register_keypad - Register the keypad platform device. |
| 682 | * @data: platform specific keypad configuration (__initdata) |
| 683 | */ |
Hartley Sweeten | 12f56c6 | 2009-10-28 21:04:46 +0100 | [diff] [blame] | 684 | void __init ep93xx_register_keypad(struct ep93xx_keypad_platform_data *data) |
| 685 | { |
Hartley Sweeten | b370e08 | 2010-03-18 18:04:06 +0100 | [diff] [blame] | 686 | ep93xx_keypad_data = *data; |
Hartley Sweeten | 12f56c6 | 2009-10-28 21:04:46 +0100 | [diff] [blame] | 687 | platform_device_register(&ep93xx_keypad_device); |
| 688 | } |
| 689 | |
| 690 | int ep93xx_keypad_acquire_gpio(struct platform_device *pdev) |
| 691 | { |
| 692 | int err; |
| 693 | int i; |
| 694 | |
| 695 | for (i = 0; i < 8; i++) { |
| 696 | err = gpio_request(EP93XX_GPIO_LINE_C(i), dev_name(&pdev->dev)); |
| 697 | if (err) |
| 698 | goto fail_gpio_c; |
| 699 | err = gpio_request(EP93XX_GPIO_LINE_D(i), dev_name(&pdev->dev)); |
| 700 | if (err) |
| 701 | goto fail_gpio_d; |
| 702 | } |
| 703 | |
| 704 | /* Enable the keypad controller; GPIO ports C and D used for keypad */ |
| 705 | ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_KEYS | |
| 706 | EP93XX_SYSCON_DEVCFG_GONK); |
| 707 | |
| 708 | return 0; |
| 709 | |
| 710 | fail_gpio_d: |
| 711 | gpio_free(EP93XX_GPIO_LINE_C(i)); |
| 712 | fail_gpio_c: |
Rafal Prylowski | 5528a84 | 2012-04-05 13:44:07 +0200 | [diff] [blame] | 713 | for (--i; i >= 0; --i) { |
Hartley Sweeten | 12f56c6 | 2009-10-28 21:04:46 +0100 | [diff] [blame] | 714 | gpio_free(EP93XX_GPIO_LINE_C(i)); |
| 715 | gpio_free(EP93XX_GPIO_LINE_D(i)); |
| 716 | } |
| 717 | return err; |
| 718 | } |
| 719 | EXPORT_SYMBOL(ep93xx_keypad_acquire_gpio); |
| 720 | |
| 721 | void ep93xx_keypad_release_gpio(struct platform_device *pdev) |
| 722 | { |
| 723 | int i; |
| 724 | |
| 725 | for (i = 0; i < 8; i++) { |
| 726 | gpio_free(EP93XX_GPIO_LINE_C(i)); |
| 727 | gpio_free(EP93XX_GPIO_LINE_D(i)); |
| 728 | } |
| 729 | |
| 730 | /* Disable the keypad controller; GPIO ports C and D used for GPIO */ |
| 731 | ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS | |
| 732 | EP93XX_SYSCON_DEVCFG_GONK); |
| 733 | } |
| 734 | EXPORT_SYMBOL(ep93xx_keypad_release_gpio); |
| 735 | |
Ryan Mallon | ed67ea8 | 2010-06-08 22:01:10 +1200 | [diff] [blame] | 736 | /************************************************************************* |
| 737 | * EP93xx I2S audio peripheral handling |
| 738 | *************************************************************************/ |
| 739 | static struct resource ep93xx_i2s_resource[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 740 | DEFINE_RES_MEM(EP93XX_I2S_PHYS_BASE, 0x100), |
Ryan Mallon | ed67ea8 | 2010-06-08 22:01:10 +1200 | [diff] [blame] | 741 | }; |
| 742 | |
| 743 | static struct platform_device ep93xx_i2s_device = { |
| 744 | .name = "ep93xx-i2s", |
| 745 | .id = -1, |
| 746 | .num_resources = ARRAY_SIZE(ep93xx_i2s_resource), |
| 747 | .resource = ep93xx_i2s_resource, |
| 748 | }; |
| 749 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 750 | static struct platform_device ep93xx_pcm_device = { |
| 751 | .name = "ep93xx-pcm-audio", |
| 752 | .id = -1, |
| 753 | }; |
| 754 | |
Ryan Mallon | ed67ea8 | 2010-06-08 22:01:10 +1200 | [diff] [blame] | 755 | void __init ep93xx_register_i2s(void) |
| 756 | { |
| 757 | platform_device_register(&ep93xx_i2s_device); |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 758 | platform_device_register(&ep93xx_pcm_device); |
Ryan Mallon | ed67ea8 | 2010-06-08 22:01:10 +1200 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | #define EP93XX_SYSCON_DEVCFG_I2S_MASK (EP93XX_SYSCON_DEVCFG_I2SONSSP | \ |
| 762 | EP93XX_SYSCON_DEVCFG_I2SONAC97) |
| 763 | |
| 764 | #define EP93XX_I2SCLKDIV_MASK (EP93XX_SYSCON_I2SCLKDIV_ORIDE | \ |
| 765 | EP93XX_SYSCON_I2SCLKDIV_SPOL) |
| 766 | |
Ryan Mallon | f15855b | 2012-01-11 11:04:42 +1100 | [diff] [blame] | 767 | int ep93xx_i2s_acquire(void) |
Ryan Mallon | ed67ea8 | 2010-06-08 22:01:10 +1200 | [diff] [blame] | 768 | { |
| 769 | unsigned val; |
| 770 | |
Ryan Mallon | f15855b | 2012-01-11 11:04:42 +1100 | [diff] [blame] | 771 | ep93xx_devcfg_set_clear(EP93XX_SYSCON_DEVCFG_I2SONAC97, |
| 772 | EP93XX_SYSCON_DEVCFG_I2S_MASK); |
Ryan Mallon | ed67ea8 | 2010-06-08 22:01:10 +1200 | [diff] [blame] | 773 | |
| 774 | /* |
| 775 | * This is potentially racy with the clock api for i2s_mclk, sclk and |
| 776 | * lrclk. Since the i2s driver is the only user of those clocks we |
| 777 | * rely on it to prevent parallel use of this function and the |
| 778 | * clock api for the i2s clocks. |
| 779 | */ |
| 780 | val = __raw_readl(EP93XX_SYSCON_I2SCLKDIV); |
| 781 | val &= ~EP93XX_I2SCLKDIV_MASK; |
Ryan Mallon | f15855b | 2012-01-11 11:04:42 +1100 | [diff] [blame] | 782 | val |= EP93XX_SYSCON_I2SCLKDIV_ORIDE | EP93XX_SYSCON_I2SCLKDIV_SPOL; |
Ryan Mallon | ed67ea8 | 2010-06-08 22:01:10 +1200 | [diff] [blame] | 783 | ep93xx_syscon_swlocked_write(val, EP93XX_SYSCON_I2SCLKDIV); |
| 784 | |
| 785 | return 0; |
| 786 | } |
| 787 | EXPORT_SYMBOL(ep93xx_i2s_acquire); |
| 788 | |
| 789 | void ep93xx_i2s_release(void) |
| 790 | { |
| 791 | ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2S_MASK); |
| 792 | } |
| 793 | EXPORT_SYMBOL(ep93xx_i2s_release); |
Hartley Sweeten | 12f56c6 | 2009-10-28 21:04:46 +0100 | [diff] [blame] | 794 | |
Mika Westerberg | 534bc7f | 2010-10-14 17:49:07 +0300 | [diff] [blame] | 795 | /************************************************************************* |
| 796 | * EP93xx AC97 audio peripheral handling |
| 797 | *************************************************************************/ |
| 798 | static struct resource ep93xx_ac97_resources[] = { |
H Hartley Sweeten | ede55aa | 2012-03-21 11:35:49 -0700 | [diff] [blame] | 799 | DEFINE_RES_MEM(EP93XX_AAC_PHYS_BASE, 0xac), |
| 800 | DEFINE_RES_IRQ(IRQ_EP93XX_AACINTR), |
Mika Westerberg | 534bc7f | 2010-10-14 17:49:07 +0300 | [diff] [blame] | 801 | }; |
| 802 | |
| 803 | static struct platform_device ep93xx_ac97_device = { |
| 804 | .name = "ep93xx-ac97", |
| 805 | .id = -1, |
| 806 | .num_resources = ARRAY_SIZE(ep93xx_ac97_resources), |
| 807 | .resource = ep93xx_ac97_resources, |
| 808 | }; |
| 809 | |
| 810 | void __init ep93xx_register_ac97(void) |
| 811 | { |
| 812 | /* |
| 813 | * Make sure that the AC97 pins are not used by I2S. |
| 814 | */ |
| 815 | ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONAC97); |
| 816 | |
| 817 | platform_device_register(&ep93xx_ac97_device); |
| 818 | platform_device_register(&ep93xx_pcm_device); |
| 819 | } |
| 820 | |
H Hartley Sweeten | 73303d1 | 2012-01-22 20:01:16 +1100 | [diff] [blame] | 821 | /************************************************************************* |
| 822 | * EP93xx Watchdog |
| 823 | *************************************************************************/ |
| 824 | static struct resource ep93xx_wdt_resources[] = { |
| 825 | DEFINE_RES_MEM(EP93XX_WATCHDOG_PHYS_BASE, 0x08), |
| 826 | }; |
| 827 | |
| 828 | static struct platform_device ep93xx_wdt_device = { |
| 829 | .name = "ep93xx-wdt", |
| 830 | .id = -1, |
| 831 | .num_resources = ARRAY_SIZE(ep93xx_wdt_resources), |
| 832 | .resource = ep93xx_wdt_resources, |
| 833 | }; |
| 834 | |
Rafal Prylowski | eb774a0 | 2012-04-12 14:14:12 +0200 | [diff] [blame] | 835 | /************************************************************************* |
| 836 | * EP93xx IDE |
| 837 | *************************************************************************/ |
| 838 | static struct resource ep93xx_ide_resources[] = { |
| 839 | DEFINE_RES_MEM(EP93XX_IDE_PHYS_BASE, 0x38), |
| 840 | DEFINE_RES_IRQ(IRQ_EP93XX_EXT3), |
| 841 | }; |
| 842 | |
| 843 | static struct platform_device ep93xx_ide_device = { |
| 844 | .name = "ep93xx-ide", |
| 845 | .id = -1, |
| 846 | .dev = { |
| 847 | .dma_mask = &ep93xx_ide_device.dev.coherent_dma_mask, |
| 848 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 849 | }, |
| 850 | .num_resources = ARRAY_SIZE(ep93xx_ide_resources), |
| 851 | .resource = ep93xx_ide_resources, |
| 852 | }; |
| 853 | |
| 854 | void __init ep93xx_register_ide(void) |
| 855 | { |
| 856 | platform_device_register(&ep93xx_ide_device); |
| 857 | } |
| 858 | |
| 859 | int ep93xx_ide_acquire_gpio(struct platform_device *pdev) |
| 860 | { |
| 861 | int err; |
| 862 | int i; |
| 863 | |
| 864 | err = gpio_request(EP93XX_GPIO_LINE_EGPIO2, dev_name(&pdev->dev)); |
| 865 | if (err) |
| 866 | return err; |
| 867 | err = gpio_request(EP93XX_GPIO_LINE_EGPIO15, dev_name(&pdev->dev)); |
| 868 | if (err) |
| 869 | goto fail_egpio15; |
| 870 | for (i = 2; i < 8; i++) { |
| 871 | err = gpio_request(EP93XX_GPIO_LINE_E(i), dev_name(&pdev->dev)); |
| 872 | if (err) |
| 873 | goto fail_gpio_e; |
| 874 | } |
| 875 | for (i = 4; i < 8; i++) { |
| 876 | err = gpio_request(EP93XX_GPIO_LINE_G(i), dev_name(&pdev->dev)); |
| 877 | if (err) |
| 878 | goto fail_gpio_g; |
| 879 | } |
| 880 | for (i = 0; i < 8; i++) { |
| 881 | err = gpio_request(EP93XX_GPIO_LINE_H(i), dev_name(&pdev->dev)); |
| 882 | if (err) |
| 883 | goto fail_gpio_h; |
| 884 | } |
| 885 | |
| 886 | /* GPIO ports E[7:2], G[7:4] and H used by IDE */ |
| 887 | ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_EONIDE | |
| 888 | EP93XX_SYSCON_DEVCFG_GONIDE | |
| 889 | EP93XX_SYSCON_DEVCFG_HONIDE); |
| 890 | return 0; |
| 891 | |
| 892 | fail_gpio_h: |
| 893 | for (--i; i >= 0; --i) |
| 894 | gpio_free(EP93XX_GPIO_LINE_H(i)); |
| 895 | i = 8; |
| 896 | fail_gpio_g: |
| 897 | for (--i; i >= 4; --i) |
| 898 | gpio_free(EP93XX_GPIO_LINE_G(i)); |
| 899 | i = 8; |
| 900 | fail_gpio_e: |
| 901 | for (--i; i >= 2; --i) |
| 902 | gpio_free(EP93XX_GPIO_LINE_E(i)); |
| 903 | gpio_free(EP93XX_GPIO_LINE_EGPIO15); |
| 904 | fail_egpio15: |
| 905 | gpio_free(EP93XX_GPIO_LINE_EGPIO2); |
| 906 | return err; |
| 907 | } |
| 908 | EXPORT_SYMBOL(ep93xx_ide_acquire_gpio); |
| 909 | |
| 910 | void ep93xx_ide_release_gpio(struct platform_device *pdev) |
| 911 | { |
| 912 | int i; |
| 913 | |
| 914 | for (i = 2; i < 8; i++) |
| 915 | gpio_free(EP93XX_GPIO_LINE_E(i)); |
| 916 | for (i = 4; i < 8; i++) |
| 917 | gpio_free(EP93XX_GPIO_LINE_G(i)); |
| 918 | for (i = 0; i < 8; i++) |
| 919 | gpio_free(EP93XX_GPIO_LINE_H(i)); |
| 920 | gpio_free(EP93XX_GPIO_LINE_EGPIO15); |
| 921 | gpio_free(EP93XX_GPIO_LINE_EGPIO2); |
| 922 | |
| 923 | |
| 924 | /* GPIO ports E[7:2], G[7:4] and H used by GPIO */ |
| 925 | ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_EONIDE | |
| 926 | EP93XX_SYSCON_DEVCFG_GONIDE | |
| 927 | EP93XX_SYSCON_DEVCFG_HONIDE); |
| 928 | } |
| 929 | EXPORT_SYMBOL(ep93xx_ide_release_gpio); |
| 930 | |
H Hartley Sweeten | b19e11f | 2013-11-19 10:23:06 +1100 | [diff] [blame] | 931 | /************************************************************************* |
| 932 | * EP93xx Security peripheral |
| 933 | *************************************************************************/ |
| 934 | |
| 935 | /* |
| 936 | * The Maverick Key is 256 bits of micro fuses blown at the factory during |
| 937 | * manufacturing to uniquely identify a part. |
| 938 | * |
| 939 | * See: http://arm.cirrus.com/forum/viewtopic.php?t=486&highlight=maverick+key |
| 940 | */ |
| 941 | #define EP93XX_SECURITY_REG(x) (EP93XX_SECURITY_BASE + (x)) |
| 942 | #define EP93XX_SECURITY_SECFLG EP93XX_SECURITY_REG(0x2400) |
| 943 | #define EP93XX_SECURITY_FUSEFLG EP93XX_SECURITY_REG(0x2410) |
| 944 | #define EP93XX_SECURITY_UNIQID EP93XX_SECURITY_REG(0x2440) |
| 945 | #define EP93XX_SECURITY_UNIQCHK EP93XX_SECURITY_REG(0x2450) |
| 946 | #define EP93XX_SECURITY_UNIQVAL EP93XX_SECURITY_REG(0x2460) |
| 947 | #define EP93XX_SECURITY_SECID1 EP93XX_SECURITY_REG(0x2500) |
| 948 | #define EP93XX_SECURITY_SECID2 EP93XX_SECURITY_REG(0x2504) |
| 949 | #define EP93XX_SECURITY_SECCHK1 EP93XX_SECURITY_REG(0x2520) |
| 950 | #define EP93XX_SECURITY_SECCHK2 EP93XX_SECURITY_REG(0x2524) |
| 951 | #define EP93XX_SECURITY_UNIQID2 EP93XX_SECURITY_REG(0x2700) |
| 952 | #define EP93XX_SECURITY_UNIQID3 EP93XX_SECURITY_REG(0x2704) |
| 953 | #define EP93XX_SECURITY_UNIQID4 EP93XX_SECURITY_REG(0x2708) |
| 954 | #define EP93XX_SECURITY_UNIQID5 EP93XX_SECURITY_REG(0x270c) |
| 955 | |
| 956 | static char ep93xx_soc_id[33]; |
| 957 | |
| 958 | static const char __init *ep93xx_get_soc_id(void) |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 959 | { |
H Hartley Sweeten | b19e11f | 2013-11-19 10:23:06 +1100 | [diff] [blame] | 960 | unsigned int id, id2, id3, id4, id5; |
| 961 | |
| 962 | if (__raw_readl(EP93XX_SECURITY_UNIQVAL) != 1) |
| 963 | return "bad Hamming code"; |
| 964 | |
| 965 | id = __raw_readl(EP93XX_SECURITY_UNIQID); |
| 966 | id2 = __raw_readl(EP93XX_SECURITY_UNIQID2); |
| 967 | id3 = __raw_readl(EP93XX_SECURITY_UNIQID3); |
| 968 | id4 = __raw_readl(EP93XX_SECURITY_UNIQID4); |
| 969 | id5 = __raw_readl(EP93XX_SECURITY_UNIQID5); |
| 970 | |
| 971 | if (id != id2) |
| 972 | return "invalid"; |
| 973 | |
| 974 | snprintf(ep93xx_soc_id, sizeof(ep93xx_soc_id), |
| 975 | "%08x%08x%08x%08x", id2, id3, id4, id5); |
| 976 | |
| 977 | return ep93xx_soc_id; |
| 978 | } |
| 979 | |
| 980 | static const char __init *ep93xx_get_soc_rev(void) |
| 981 | { |
| 982 | int rev = ep93xx_chip_revision(); |
| 983 | |
| 984 | switch (rev) { |
| 985 | case EP93XX_CHIP_REV_D0: |
| 986 | return "D0"; |
| 987 | case EP93XX_CHIP_REV_D1: |
| 988 | return "D1"; |
| 989 | case EP93XX_CHIP_REV_E0: |
| 990 | return "E0"; |
| 991 | case EP93XX_CHIP_REV_E1: |
| 992 | return "E1"; |
| 993 | case EP93XX_CHIP_REV_E2: |
| 994 | return "E2"; |
| 995 | default: |
| 996 | return "unknown"; |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | static const char __init *ep93xx_get_machine_name(void) |
| 1001 | { |
| 1002 | return kasprintf(GFP_KERNEL,"%s", machine_desc->name); |
| 1003 | } |
| 1004 | |
| 1005 | static struct device __init *ep93xx_init_soc(void) |
| 1006 | { |
| 1007 | struct soc_device_attribute *soc_dev_attr; |
| 1008 | struct soc_device *soc_dev; |
| 1009 | |
| 1010 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); |
| 1011 | if (!soc_dev_attr) |
| 1012 | return NULL; |
| 1013 | |
| 1014 | soc_dev_attr->machine = ep93xx_get_machine_name(); |
| 1015 | soc_dev_attr->family = "Cirrus Logic EP93xx"; |
| 1016 | soc_dev_attr->revision = ep93xx_get_soc_rev(); |
| 1017 | soc_dev_attr->soc_id = ep93xx_get_soc_id(); |
| 1018 | |
| 1019 | soc_dev = soc_device_register(soc_dev_attr); |
| 1020 | if (IS_ERR(soc_dev)) { |
| 1021 | kfree(soc_dev_attr->machine); |
| 1022 | kfree(soc_dev_attr); |
| 1023 | return NULL; |
| 1024 | } |
| 1025 | |
| 1026 | return soc_device_to_device(soc_dev); |
| 1027 | } |
| 1028 | |
| 1029 | struct device __init *ep93xx_init_devices(void) |
| 1030 | { |
| 1031 | struct device *parent; |
| 1032 | |
Hartley Sweeten | 02239f0 | 2009-07-08 02:00:49 +0100 | [diff] [blame] | 1033 | /* Disallow access to MaverickCrunch initially */ |
| 1034 | ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA); |
Lennert Buytenhek | aee85fe | 2006-03-26 23:16:39 +0100 | [diff] [blame] | 1035 | |
Ryan Mallon | 08932d8 | 2012-01-11 09:58:30 +1100 | [diff] [blame] | 1036 | /* Default all ports to GPIO */ |
| 1037 | ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS | |
| 1038 | EP93XX_SYSCON_DEVCFG_GONK | |
| 1039 | EP93XX_SYSCON_DEVCFG_EONIDE | |
| 1040 | EP93XX_SYSCON_DEVCFG_GONIDE | |
| 1041 | EP93XX_SYSCON_DEVCFG_HONIDE); |
| 1042 | |
H Hartley Sweeten | b19e11f | 2013-11-19 10:23:06 +1100 | [diff] [blame] | 1043 | parent = ep93xx_init_soc(); |
| 1044 | |
H Hartley Sweeten | 1e4c884 | 2011-06-08 14:35:33 -0700 | [diff] [blame] | 1045 | /* Get the GPIO working early, other devices need it */ |
| 1046 | platform_device_register(&ep93xx_gpio_device); |
Ryan Mallon | b685004 | 2008-04-16 02:56:35 +0100 | [diff] [blame] | 1047 | |
Lennert Buytenhek | aee85fe | 2006-03-26 23:16:39 +0100 | [diff] [blame] | 1048 | amba_device_register(&uart1_device, &iomem_resource); |
| 1049 | amba_device_register(&uart2_device, &iomem_resource); |
| 1050 | amba_device_register(&uart3_device, &iomem_resource); |
Lennert Buytenhek | 4165813 | 2006-04-02 16:17:34 +0100 | [diff] [blame] | 1051 | |
| 1052 | platform_device_register(&ep93xx_rtc_device); |
Lennert Buytenhek | 1f64eb3 | 2006-06-24 10:33:03 +0100 | [diff] [blame] | 1053 | platform_device_register(&ep93xx_ohci_device); |
H Hartley Sweeten | 73303d1 | 2012-01-22 20:01:16 +1100 | [diff] [blame] | 1054 | platform_device_register(&ep93xx_wdt_device); |
H Hartley Sweeten | a1eacd7 | 2012-04-11 15:44:42 -0700 | [diff] [blame] | 1055 | |
| 1056 | gpio_led_register_device(-1, &ep93xx_led_data); |
H Hartley Sweeten | b19e11f | 2013-11-19 10:23:06 +1100 | [diff] [blame] | 1057 | |
| 1058 | return parent; |
Lennert Buytenhek | e7736d4 | 2006-03-20 17:10:13 +0000 | [diff] [blame] | 1059 | } |
Russell King | 3275166 | 2011-11-05 09:54:14 +0000 | [diff] [blame] | 1060 | |
Robin Holt | 7b6d864 | 2013-07-08 16:01:40 -0700 | [diff] [blame] | 1061 | void ep93xx_restart(enum reboot_mode mode, const char *cmd) |
Russell King | 3275166 | 2011-11-05 09:54:14 +0000 | [diff] [blame] | 1062 | { |
| 1063 | /* |
| 1064 | * Set then clear the SWRST bit to initiate a software reset |
| 1065 | */ |
| 1066 | ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_SWRST); |
| 1067 | ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_SWRST); |
| 1068 | |
| 1069 | while (1) |
| 1070 | ; |
| 1071 | } |
Shawn Guo | c914283 | 2012-04-26 10:05:15 +0800 | [diff] [blame] | 1072 | |
| 1073 | void __init ep93xx_init_late(void) |
| 1074 | { |
| 1075 | crunch_init(); |
| 1076 | } |