blob: e70feec6fad5e296b869d76e90d31bf5b71d1334 [file] [log] [blame]
Lennert Buytenheke7736d42006-03-20 17:10:13 +00001/*
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 Riedel3c9a0712007-11-26 18:49:08 +01006 * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
Lennert Buytenheke7736d42006-03-20 17:10:13 +00007 *
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 Sweeten64d68822010-01-11 19:33:16 +010017#define pr_fmt(fmt) "ep93xx " KBUILD_MODNAME ": " fmt
18
Lennert Buytenheke7736d42006-03-20 17:10:13 +000019#include <linux/kernel.h>
20#include <linux/init.h>
Hartley Sweeten583ddaf2009-07-06 17:39:50 +010021#include <linux/platform_device.h>
Lennert Buytenheke7736d42006-03-20 17:10:13 +000022#include <linux/interrupt.h>
Matthias Kaehlcke63890a02008-10-29 14:14:52 -070023#include <linux/dma-mapping.h>
H Hartley Sweetenb19e11f2013-11-19 10:23:06 +110024#include <linux/sys_soc.h>
Hartley Sweeten6bd4b382010-02-18 18:16:11 +010025#include <linux/irq.h>
Hartley Sweeten583ddaf2009-07-06 17:39:50 +010026#include <linux/io.h>
27#include <linux/gpio.h>
Hartley Sweeten3aa7a9a2009-07-20 18:22:36 +010028#include <linux/leds.h>
Lennert Buytenhekaee85fe2006-03-26 23:16:39 +010029#include <linux/termios.h>
Lennert Buytenheke7736d42006-03-20 17:10:13 +000030#include <linux/amba/bus.h>
Lennert Buytenhekaee85fe2006-03-26 23:16:39 +010031#include <linux/amba/serial.h>
Hartley Sweeten16bcf782010-06-10 16:19:08 +010032#include <linux/mtd/physmap.h>
Hartley Sweetend52a26a2008-10-16 23:57:03 +010033#include <linux/i2c.h>
Linus Walleijb2e63552017-09-10 01:30:46 +020034#include <linux/gpio/machine.h>
Mika Westerberg4fec9972010-05-11 15:34:54 +010035#include <linux/spi/spi.h>
Paul Gortmakerdc280942011-07-31 16:17:29 -040036#include <linux/export.h>
Rob Herring9e47b8b2013-01-07 09:45:59 -060037#include <linux/irqchip/arm-vic.h>
Robin Holt7b6d8642013-07-08 16:01:40 -070038#include <linux/reboot.h>
H Hartley Sweetene55f7cd2013-10-21 13:39:04 -070039#include <linux/usb/ohci_pdriver.h>
Linus Walleije8a7d2b2015-06-18 16:46:34 +020040#include <linux/random.h>
Lennert Buytenheke7736d42006-03-20 17:10:13 +000041
Russell Kinga09e64f2008-08-05 16:14:15 +010042#include <mach/hardware.h>
Arnd Bergmanna3b29242012-08-24 15:12:11 +020043#include <linux/platform_data/video-ep93xx.h>
44#include <linux/platform_data/keypad-ep93xx.h>
45#include <linux/platform_data/spi-ep93xx.h>
Linus Walleijbd5f12a2011-09-22 08:07:00 +010046#include <mach/gpio-ep93xx.h>
Lennert Buytenheke7736d42006-03-20 17:10:13 +000047
H Hartley Sweetenb19e11f2013-11-19 10:23:06 +110048#include <asm/mach/arch.h>
Lennert Buytenheke7736d42006-03-20 17:10:13 +000049#include <asm/mach/map.h>
Lennert Buytenheke7736d42006-03-20 17:10:13 +000050
Ryan Mallona05baf32012-01-11 09:29:26 +110051#include "soc.h"
Lennert Buytenheke7736d42006-03-20 17:10:13 +000052
53/*************************************************************************
54 * Static I/O mappings that are needed for all EP93xx platforms
55 *************************************************************************/
56static struct map_desc ep93xx_io_desc[] __initdata = {
57 {
58 .virtual = EP93XX_AHB_VIRT_BASE,
59 .pfn = __phys_to_pfn(EP93XX_AHB_PHYS_BASE),
60 .length = EP93XX_AHB_SIZE,
61 .type = MT_DEVICE,
62 }, {
63 .virtual = EP93XX_APB_VIRT_BASE,
64 .pfn = __phys_to_pfn(EP93XX_APB_PHYS_BASE),
65 .length = EP93XX_APB_SIZE,
66 .type = MT_DEVICE,
67 },
68};
69
70void __init ep93xx_map_io(void)
71{
72 iotable_init(ep93xx_io_desc, ARRAY_SIZE(ep93xx_io_desc));
73}
74
Lennert Buytenheke7736d42006-03-20 17:10:13 +000075/*************************************************************************
Lennert Buytenheke7736d42006-03-20 17:10:13 +000076 * EP93xx IRQ handling
77 *************************************************************************/
78void __init ep93xx_init_irq(void)
79{
Hartley Sweeten53967302009-07-09 23:22:07 +010080 vic_init(EP93XX_VIC1_BASE, 0, EP93XX_VIC1_VALID_IRQ_MASK, 0);
81 vic_init(EP93XX_VIC2_BASE, 32, EP93XX_VIC2_VALID_IRQ_MASK, 0);
Lennert Buytenheke7736d42006-03-20 17:10:13 +000082}
83
84
85/*************************************************************************
Hartley Sweeten02239f02009-07-08 02:00:49 +010086 * EP93xx System Controller Software Locked register handling
87 *************************************************************************/
88
89/*
90 * syscon_swlock prevents anything else from writing to the syscon
91 * block while a software locked register is being written.
92 */
93static DEFINE_SPINLOCK(syscon_swlock);
94
Ryan Mallonfbeeea52009-07-15 21:51:59 +010095void ep93xx_syscon_swlocked_write(unsigned int val, void __iomem *reg)
Hartley Sweeten02239f02009-07-08 02:00:49 +010096{
97 unsigned long flags;
98
99 spin_lock_irqsave(&syscon_swlock, flags);
100
101 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
102 __raw_writel(val, reg);
103
104 spin_unlock_irqrestore(&syscon_swlock, flags);
105}
Hartley Sweeten02239f02009-07-08 02:00:49 +0100106
107void ep93xx_devcfg_set_clear(unsigned int set_bits, unsigned int clear_bits)
108{
109 unsigned long flags;
110 unsigned int val;
111
112 spin_lock_irqsave(&syscon_swlock, flags);
113
114 val = __raw_readl(EP93XX_SYSCON_DEVCFG);
Hartley Sweeten02239f02009-07-08 02:00:49 +0100115 val &= ~clear_bits;
Hartley Sweetena0fb0072010-06-14 16:54:16 +0100116 val |= set_bits;
Hartley Sweeten02239f02009-07-08 02:00:49 +0100117 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
118 __raw_writel(val, EP93XX_SYSCON_DEVCFG);
119
120 spin_unlock_irqrestore(&syscon_swlock, flags);
121}
Hartley Sweeten02239f02009-07-08 02:00:49 +0100122
Mika Westerberg99e6a232010-03-27 12:05:14 +0100123/**
124 * ep93xx_chip_revision() - returns the EP93xx chip revision
125 *
126 * See <mach/platform.h> for more information.
127 */
128unsigned int ep93xx_chip_revision(void)
129{
130 unsigned int v;
131
132 v = __raw_readl(EP93XX_SYSCON_SYSCFG);
133 v &= EP93XX_SYSCON_SYSCFG_REV_MASK;
134 v >>= EP93XX_SYSCON_SYSCFG_REV_SHIFT;
135 return v;
136}
Arnd Bergmann67e108c2014-03-13 17:52:39 +0100137EXPORT_SYMBOL_GPL(ep93xx_chip_revision);
Hartley Sweeten02239f02009-07-08 02:00:49 +0100138
139/*************************************************************************
H Hartley Sweeten1e4c8842011-06-08 14:35:33 -0700140 * EP93xx GPIO
141 *************************************************************************/
142static struct resource ep93xx_gpio_resource[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700143 DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE, 0xcc),
H Hartley Sweeten1e4c8842011-06-08 14:35:33 -0700144};
145
146static struct platform_device ep93xx_gpio_device = {
147 .name = "gpio-ep93xx",
148 .id = -1,
149 .num_resources = ARRAY_SIZE(ep93xx_gpio_resource),
150 .resource = ep93xx_gpio_resource,
151};
152
153/*************************************************************************
Lennert Buytenheke7736d42006-03-20 17:10:13 +0000154 * EP93xx peripheral handling
155 *************************************************************************/
Lennert Buytenhekaee85fe2006-03-26 23:16:39 +0100156#define EP93XX_UART_MCR_OFFSET (0x0100)
157
158static void ep93xx_uart_set_mctrl(struct amba_device *dev,
159 void __iomem *base, unsigned int mctrl)
160{
161 unsigned int mcr;
162
163 mcr = 0;
Petr Å tetiar186dcaa2011-06-17 11:10:04 +0100164 if (mctrl & TIOCM_RTS)
Lennert Buytenhekaee85fe2006-03-26 23:16:39 +0100165 mcr |= 2;
Petr Å tetiar186dcaa2011-06-17 11:10:04 +0100166 if (mctrl & TIOCM_DTR)
Lennert Buytenhekaee85fe2006-03-26 23:16:39 +0100167 mcr |= 1;
168
169 __raw_writel(mcr, base + EP93XX_UART_MCR_OFFSET);
170}
171
172static struct amba_pl010_data ep93xx_uart_data = {
173 .set_mctrl = ep93xx_uart_set_mctrl,
174};
175
Russell King0b260512011-12-18 15:16:40 +0000176static AMBA_APB_DEVICE(uart1, "apb:uart1", 0x00041010, EP93XX_UART1_PHYS_BASE,
177 { IRQ_EP93XX_UART1 }, &ep93xx_uart_data);
Lennert Buytenhekaee85fe2006-03-26 23:16:39 +0100178
Russell King0b260512011-12-18 15:16:40 +0000179static AMBA_APB_DEVICE(uart2, "apb:uart2", 0x00041010, EP93XX_UART2_PHYS_BASE,
Petr Å tetiarcc3874f2013-08-29 16:28:11 +0200180 { IRQ_EP93XX_UART2 }, NULL);
Lennert Buytenhekaee85fe2006-03-26 23:16:39 +0100181
Russell King0b260512011-12-18 15:16:40 +0000182static AMBA_APB_DEVICE(uart3, "apb:uart3", 0x00041010, EP93XX_UART3_PHYS_BASE,
183 { IRQ_EP93XX_UART3 }, &ep93xx_uart_data);
Lennert Buytenhek41658132006-04-02 16:17:34 +0100184
Hartley Sweeten38f7b002009-04-15 23:18:26 +0100185static struct resource ep93xx_rtc_resource[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700186 DEFINE_RES_MEM(EP93XX_RTC_PHYS_BASE, 0x10c),
Hartley Sweeten38f7b002009-04-15 23:18:26 +0100187};
188
Lennert Buytenhek41658132006-04-02 16:17:34 +0100189static struct platform_device ep93xx_rtc_device = {
Hartley Sweeten38f7b002009-04-15 23:18:26 +0100190 .name = "ep93xx-rtc",
191 .id = -1,
192 .num_resources = ARRAY_SIZE(ep93xx_rtc_resource),
193 .resource = ep93xx_rtc_resource,
Lennert Buytenhek41658132006-04-02 16:17:34 +0100194};
195
H Hartley Sweetene55f7cd2013-10-21 13:39:04 -0700196/*************************************************************************
197 * EP93xx OHCI USB Host
198 *************************************************************************/
199
200static struct clk *ep93xx_ohci_host_clock;
201
202static int ep93xx_ohci_power_on(struct platform_device *pdev)
203{
204 if (!ep93xx_ohci_host_clock) {
205 ep93xx_ohci_host_clock = devm_clk_get(&pdev->dev, NULL);
206 if (IS_ERR(ep93xx_ohci_host_clock))
207 return PTR_ERR(ep93xx_ohci_host_clock);
208 }
209
210 return clk_enable(ep93xx_ohci_host_clock);
211}
212
213static void ep93xx_ohci_power_off(struct platform_device *pdev)
214{
215 clk_disable(ep93xx_ohci_host_clock);
216}
217
218static struct usb_ohci_pdata ep93xx_ohci_pdata = {
219 .power_on = ep93xx_ohci_power_on,
220 .power_off = ep93xx_ohci_power_off,
221 .power_suspend = ep93xx_ohci_power_off,
222};
Lennert Buytenhek41658132006-04-02 16:17:34 +0100223
Lennert Buytenhek1f64eb32006-06-24 10:33:03 +0100224static struct resource ep93xx_ohci_resources[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700225 DEFINE_RES_MEM(EP93XX_USB_PHYS_BASE, 0x1000),
226 DEFINE_RES_IRQ(IRQ_EP93XX_USB),
Lennert Buytenhek1f64eb32006-06-24 10:33:03 +0100227};
228
H Hartley Sweetene55f7cd2013-10-21 13:39:04 -0700229static u64 ep93xx_ohci_dma_mask = DMA_BIT_MASK(32);
Matthias Kaehlcke63890a02008-10-29 14:14:52 -0700230
Lennert Buytenhek1f64eb32006-06-24 10:33:03 +0100231static struct platform_device ep93xx_ohci_device = {
H Hartley Sweetene55f7cd2013-10-21 13:39:04 -0700232 .name = "ohci-platform",
Lennert Buytenhek1f64eb32006-06-24 10:33:03 +0100233 .id = -1,
Lennert Buytenhek1f64eb32006-06-24 10:33:03 +0100234 .num_resources = ARRAY_SIZE(ep93xx_ohci_resources),
235 .resource = ep93xx_ohci_resources,
H Hartley Sweetene55f7cd2013-10-21 13:39:04 -0700236 .dev = {
237 .dma_mask = &ep93xx_ohci_dma_mask,
238 .coherent_dma_mask = DMA_BIT_MASK(32),
239 .platform_data = &ep93xx_ohci_pdata,
240 },
Lennert Buytenhek1f64eb32006-06-24 10:33:03 +0100241};
242
Hartley Sweetenb370e082010-03-18 18:04:06 +0100243/*************************************************************************
Hartley Sweeten16bcf782010-06-10 16:19:08 +0100244 * EP93xx physmap'ed flash
245 *************************************************************************/
246static struct physmap_flash_data ep93xx_flash_data;
247
248static struct resource ep93xx_flash_resource = {
249 .flags = IORESOURCE_MEM,
250};
251
252static struct platform_device ep93xx_flash = {
253 .name = "physmap-flash",
254 .id = 0,
255 .dev = {
256 .platform_data = &ep93xx_flash_data,
257 },
258 .num_resources = 1,
259 .resource = &ep93xx_flash_resource,
260};
261
262/**
263 * ep93xx_register_flash() - Register the external flash device.
264 * @width: bank width in octets
265 * @start: resource start address
266 * @size: resource size
267 */
268void __init ep93xx_register_flash(unsigned int width,
269 resource_size_t start, resource_size_t size)
270{
271 ep93xx_flash_data.width = width;
272
273 ep93xx_flash_resource.start = start;
274 ep93xx_flash_resource.end = start + size - 1;
275
276 platform_device_register(&ep93xx_flash);
277}
278
279
280/*************************************************************************
Hartley Sweetenb370e082010-03-18 18:04:06 +0100281 * EP93xx ethernet peripheral handling
282 *************************************************************************/
Hartley Sweetena0a08fd2008-10-04 20:01:49 +0100283static struct ep93xx_eth_data ep93xx_eth_data;
284
285static struct resource ep93xx_eth_resource[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700286 DEFINE_RES_MEM(EP93XX_ETHERNET_PHYS_BASE, 0x10000),
Ryan Mallon011b2e82012-04-12 09:11:55 +1000287 DEFINE_RES_IRQ(IRQ_EP93XX_ETHERNET),
Hartley Sweetena0a08fd2008-10-04 20:01:49 +0100288};
289
Mika Westerbergfa70cf42011-06-11 08:39:54 +0000290static u64 ep93xx_eth_dma_mask = DMA_BIT_MASK(32);
291
Hartley Sweetena0a08fd2008-10-04 20:01:49 +0100292static struct platform_device ep93xx_eth_device = {
293 .name = "ep93xx-eth",
294 .id = -1,
295 .dev = {
Mika Westerbergfa70cf42011-06-11 08:39:54 +0000296 .platform_data = &ep93xx_eth_data,
297 .coherent_dma_mask = DMA_BIT_MASK(32),
298 .dma_mask = &ep93xx_eth_dma_mask,
Hartley Sweetena0a08fd2008-10-04 20:01:49 +0100299 },
300 .num_resources = ARRAY_SIZE(ep93xx_eth_resource),
301 .resource = ep93xx_eth_resource,
302};
303
Hartley Sweetenb370e082010-03-18 18:04:06 +0100304/**
305 * ep93xx_register_eth - Register the built-in ethernet platform device.
306 * @data: platform specific ethernet configuration (__initdata)
307 * @copy_addr: flag indicating that the MAC address should be copied
308 * from the IndAd registers (as programmed by the bootloader)
309 */
Hartley Sweetena0a08fd2008-10-04 20:01:49 +0100310void __init ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr)
311{
Hartley Sweeten5b1c3c82009-07-13 19:50:10 +0100312 if (copy_addr)
313 memcpy_fromio(data->dev_addr, EP93XX_ETHERNET_BASE + 0x50, 6);
Hartley Sweetena0a08fd2008-10-04 20:01:49 +0100314
315 ep93xx_eth_data = *data;
316 platform_device_register(&ep93xx_eth_device);
317}
318
Hartley Sweeten6531a992009-10-08 00:45:00 +0100319
320/*************************************************************************
321 * EP93xx i2c peripheral handling
322 *************************************************************************/
Linus Walleijb2e63552017-09-10 01:30:46 +0200323
324/* All EP93xx devices use the same two GPIO pins for I2C bit-banging */
325static struct gpiod_lookup_table ep93xx_i2c_gpiod_table = {
326 .dev_id = "i2c-gpio",
327 .table = {
328 /* Use local offsets on gpiochip/port "G" */
Linus Walleij4d0ce622017-09-10 23:03:32 +0200329 GPIO_LOOKUP_IDX("G", 1, NULL, 0,
330 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
331 GPIO_LOOKUP_IDX("G", 0, NULL, 1,
332 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
Linus Walleijb2e63552017-09-10 01:30:46 +0200333 },
334};
Hartley Sweetend52a26a2008-10-16 23:57:03 +0100335
336static struct platform_device ep93xx_i2c_device = {
Hartley Sweetenb370e082010-03-18 18:04:06 +0100337 .name = "i2c-gpio",
338 .id = 0,
339 .dev = {
Linus Walleijb2e63552017-09-10 01:30:46 +0200340 .platform_data = NULL,
Hartley Sweetenb370e082010-03-18 18:04:06 +0100341 },
Hartley Sweetend52a26a2008-10-16 23:57:03 +0100342};
343
Hartley Sweetenb370e082010-03-18 18:04:06 +0100344/**
345 * ep93xx_register_i2c - Register the i2c platform device.
Hartley Sweetenb370e082010-03-18 18:04:06 +0100346 * @devices: platform specific i2c bus device information (__initdata)
347 * @num: the number of devices on the i2c bus
348 */
Linus Walleijb2e63552017-09-10 01:30:46 +0200349void __init ep93xx_register_i2c(struct i2c_board_info *devices, int num)
Hartley Sweetend52a26a2008-10-16 23:57:03 +0100350{
Hartley Sweeten6531a992009-10-08 00:45:00 +0100351 /*
Linus Walleijb2e63552017-09-10 01:30:46 +0200352 * FIXME: this just sets the two pins as non-opendrain, as no
353 * platforms tries to do that anyway. Flag the applicable lines
354 * as open drain in the GPIO_LOOKUP above and the driver or
355 * gpiolib will handle open drain/open drain emulation as need
356 * be. Right now i2c-gpio emulates open drain which is not
357 * optimal.
Hartley Sweeten6531a992009-10-08 00:45:00 +0100358 */
Linus Walleijb2e63552017-09-10 01:30:46 +0200359 __raw_writel((0 << 1) | (0 << 0),
Hartley Sweeten6531a992009-10-08 00:45:00 +0100360 EP93XX_GPIO_EEDRIVE);
361
Hartley Sweetend52a26a2008-10-16 23:57:03 +0100362 i2c_register_board_info(0, devices, num);
Linus Walleijb2e63552017-09-10 01:30:46 +0200363 gpiod_add_lookup_table(&ep93xx_i2c_gpiod_table);
Hartley Sweetend52a26a2008-10-16 23:57:03 +0100364 platform_device_register(&ep93xx_i2c_device);
365}
366
Mika Westerberg4fec9972010-05-11 15:34:54 +0100367/*************************************************************************
368 * EP93xx SPI peripheral handling
369 *************************************************************************/
370static struct ep93xx_spi_info ep93xx_spi_master_data;
371
372static struct resource ep93xx_spi_resources[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700373 DEFINE_RES_MEM(EP93XX_SPI_PHYS_BASE, 0x18),
374 DEFINE_RES_IRQ(IRQ_EP93XX_SSP),
Mika Westerberg4fec9972010-05-11 15:34:54 +0100375};
376
Mika Westerberg626a96d2011-05-29 13:10:06 +0300377static u64 ep93xx_spi_dma_mask = DMA_BIT_MASK(32);
378
Mika Westerberg4fec9972010-05-11 15:34:54 +0100379static struct platform_device ep93xx_spi_device = {
380 .name = "ep93xx-spi",
381 .id = 0,
382 .dev = {
Mika Westerberg626a96d2011-05-29 13:10:06 +0300383 .platform_data = &ep93xx_spi_master_data,
384 .coherent_dma_mask = DMA_BIT_MASK(32),
385 .dma_mask = &ep93xx_spi_dma_mask,
Mika Westerberg4fec9972010-05-11 15:34:54 +0100386 },
387 .num_resources = ARRAY_SIZE(ep93xx_spi_resources),
388 .resource = ep93xx_spi_resources,
389};
390
391/**
392 * ep93xx_register_spi() - registers spi platform device
393 * @info: ep93xx board specific spi master info (__initdata)
394 * @devices: SPI devices to register (__initdata)
395 * @num: number of SPI devices to register
396 *
397 * This function registers platform device for the EP93xx SPI controller and
398 * also makes sure that SPI pins are muxed so that I2S is not using those pins.
399 */
400void __init ep93xx_register_spi(struct ep93xx_spi_info *info,
401 struct spi_board_info *devices, int num)
402{
403 /*
404 * When SPI is used, we need to make sure that I2S is muxed off from
405 * SPI pins.
406 */
407 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONSSP);
408
409 ep93xx_spi_master_data = *info;
410 spi_register_board_info(devices, num);
411 platform_device_register(&ep93xx_spi_device);
412}
Hartley Sweeten3aa7a9a2009-07-20 18:22:36 +0100413
414/*************************************************************************
415 * EP93xx LEDs
416 *************************************************************************/
H Hartley Sweetena1eacd72012-04-11 15:44:42 -0700417static const struct gpio_led ep93xx_led_pins[] __initconst = {
Hartley Sweeten3aa7a9a2009-07-20 18:22:36 +0100418 {
Hartley Sweetenb370e082010-03-18 18:04:06 +0100419 .name = "platform:grled",
420 .gpio = EP93XX_GPIO_LINE_GRLED,
Hartley Sweeten3aa7a9a2009-07-20 18:22:36 +0100421 }, {
Hartley Sweetenb370e082010-03-18 18:04:06 +0100422 .name = "platform:rdled",
423 .gpio = EP93XX_GPIO_LINE_RDLED,
Hartley Sweeten3aa7a9a2009-07-20 18:22:36 +0100424 },
425};
426
H Hartley Sweetena1eacd72012-04-11 15:44:42 -0700427static const struct gpio_led_platform_data ep93xx_led_data __initconst = {
Hartley Sweeten3aa7a9a2009-07-20 18:22:36 +0100428 .num_leds = ARRAY_SIZE(ep93xx_led_pins),
429 .leds = ep93xx_led_pins,
430};
431
Hartley Sweetenef123792009-07-29 22:41:06 +0100432/*************************************************************************
433 * EP93xx pwm peripheral handling
434 *************************************************************************/
435static struct resource ep93xx_pwm0_resource[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700436 DEFINE_RES_MEM(EP93XX_PWM_PHYS_BASE, 0x10),
Hartley Sweetenef123792009-07-29 22:41:06 +0100437};
438
439static struct platform_device ep93xx_pwm0_device = {
440 .name = "ep93xx-pwm",
441 .id = 0,
442 .num_resources = ARRAY_SIZE(ep93xx_pwm0_resource),
443 .resource = ep93xx_pwm0_resource,
444};
445
446static struct resource ep93xx_pwm1_resource[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700447 DEFINE_RES_MEM(EP93XX_PWM_PHYS_BASE + 0x20, 0x10),
Hartley Sweetenef123792009-07-29 22:41:06 +0100448};
449
450static struct platform_device ep93xx_pwm1_device = {
451 .name = "ep93xx-pwm",
452 .id = 1,
453 .num_resources = ARRAY_SIZE(ep93xx_pwm1_resource),
454 .resource = ep93xx_pwm1_resource,
455};
456
457void __init ep93xx_register_pwm(int pwm0, int pwm1)
458{
459 if (pwm0)
460 platform_device_register(&ep93xx_pwm0_device);
461
462 /* NOTE: EP9307 does not have PWMOUT1 (pin EGPIO14) */
463 if (pwm1)
464 platform_device_register(&ep93xx_pwm1_device);
465}
466
467int ep93xx_pwm_acquire_gpio(struct platform_device *pdev)
468{
469 int err;
470
471 if (pdev->id == 0) {
472 err = 0;
473 } else if (pdev->id == 1) {
474 err = gpio_request(EP93XX_GPIO_LINE_EGPIO14,
475 dev_name(&pdev->dev));
476 if (err)
477 return err;
478 err = gpio_direction_output(EP93XX_GPIO_LINE_EGPIO14, 0);
479 if (err)
480 goto fail;
481
482 /* PWM 1 output on EGPIO[14] */
483 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_PONG);
484 } else {
485 err = -ENODEV;
486 }
487
488 return err;
489
490fail:
491 gpio_free(EP93XX_GPIO_LINE_EGPIO14);
492 return err;
493}
494EXPORT_SYMBOL(ep93xx_pwm_acquire_gpio);
495
496void ep93xx_pwm_release_gpio(struct platform_device *pdev)
497{
498 if (pdev->id == 1) {
499 gpio_direction_input(EP93XX_GPIO_LINE_EGPIO14);
500 gpio_free(EP93XX_GPIO_LINE_EGPIO14);
501
502 /* EGPIO[14] used for GPIO */
503 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_PONG);
504 }
505}
506EXPORT_SYMBOL(ep93xx_pwm_release_gpio);
507
508
Ryan Mallonc6012182009-09-22 16:47:09 -0700509/*************************************************************************
510 * EP93xx video peripheral handling
511 *************************************************************************/
512static struct ep93xxfb_mach_info ep93xxfb_data;
513
514static struct resource ep93xx_fb_resource[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700515 DEFINE_RES_MEM(EP93XX_RASTER_PHYS_BASE, 0x800),
Ryan Mallonc6012182009-09-22 16:47:09 -0700516};
517
518static struct platform_device ep93xx_fb_device = {
519 .name = "ep93xx-fb",
520 .id = -1,
521 .dev = {
Hartley Sweetenb370e082010-03-18 18:04:06 +0100522 .platform_data = &ep93xxfb_data,
Ryan Mallonc6012182009-09-22 16:47:09 -0700523 .coherent_dma_mask = DMA_BIT_MASK(32),
524 .dma_mask = &ep93xx_fb_device.dev.coherent_dma_mask,
525 },
526 .num_resources = ARRAY_SIZE(ep93xx_fb_resource),
527 .resource = ep93xx_fb_resource,
528};
529
Ryan Mallon0fd19582012-01-22 20:31:32 +1100530/* The backlight use a single register in the framebuffer's register space */
531#define EP93XX_RASTER_REG_BRIGHTNESS 0x20
532
533static struct resource ep93xx_bl_resources[] = {
534 DEFINE_RES_MEM(EP93XX_RASTER_PHYS_BASE +
535 EP93XX_RASTER_REG_BRIGHTNESS, 0x04),
536};
537
Hartley Sweeten6ea4b742010-06-09 21:15:12 +0100538static struct platform_device ep93xx_bl_device = {
539 .name = "ep93xx-bl",
540 .id = -1,
Ryan Mallon0fd19582012-01-22 20:31:32 +1100541 .num_resources = ARRAY_SIZE(ep93xx_bl_resources),
542 .resource = ep93xx_bl_resources,
Hartley Sweeten6ea4b742010-06-09 21:15:12 +0100543};
544
Hartley Sweetenb370e082010-03-18 18:04:06 +0100545/**
546 * ep93xx_register_fb - Register the framebuffer platform device.
547 * @data: platform specific framebuffer configuration (__initdata)
548 */
Ryan Mallonc6012182009-09-22 16:47:09 -0700549void __init ep93xx_register_fb(struct ep93xxfb_mach_info *data)
550{
551 ep93xxfb_data = *data;
552 platform_device_register(&ep93xx_fb_device);
Hartley Sweeten6ea4b742010-06-09 21:15:12 +0100553 platform_device_register(&ep93xx_bl_device);
Ryan Mallonc6012182009-09-22 16:47:09 -0700554}
555
Hartley Sweeten12f56c62009-10-28 21:04:46 +0100556
557/*************************************************************************
558 * EP93xx matrix keypad peripheral handling
559 *************************************************************************/
Hartley Sweetenb370e082010-03-18 18:04:06 +0100560static struct ep93xx_keypad_platform_data ep93xx_keypad_data;
561
Hartley Sweeten12f56c62009-10-28 21:04:46 +0100562static struct resource ep93xx_keypad_resource[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700563 DEFINE_RES_MEM(EP93XX_KEY_MATRIX_PHYS_BASE, 0x0c),
564 DEFINE_RES_IRQ(IRQ_EP93XX_KEY),
Hartley Sweeten12f56c62009-10-28 21:04:46 +0100565};
566
567static struct platform_device ep93xx_keypad_device = {
Hartley Sweetenb370e082010-03-18 18:04:06 +0100568 .name = "ep93xx-keypad",
569 .id = -1,
570 .dev = {
571 .platform_data = &ep93xx_keypad_data,
572 },
573 .num_resources = ARRAY_SIZE(ep93xx_keypad_resource),
574 .resource = ep93xx_keypad_resource,
Hartley Sweeten12f56c62009-10-28 21:04:46 +0100575};
576
Hartley Sweetenb370e082010-03-18 18:04:06 +0100577/**
578 * ep93xx_register_keypad - Register the keypad platform device.
579 * @data: platform specific keypad configuration (__initdata)
580 */
Hartley Sweeten12f56c62009-10-28 21:04:46 +0100581void __init ep93xx_register_keypad(struct ep93xx_keypad_platform_data *data)
582{
Hartley Sweetenb370e082010-03-18 18:04:06 +0100583 ep93xx_keypad_data = *data;
Hartley Sweeten12f56c62009-10-28 21:04:46 +0100584 platform_device_register(&ep93xx_keypad_device);
585}
586
587int ep93xx_keypad_acquire_gpio(struct platform_device *pdev)
588{
589 int err;
590 int i;
591
592 for (i = 0; i < 8; i++) {
593 err = gpio_request(EP93XX_GPIO_LINE_C(i), dev_name(&pdev->dev));
594 if (err)
595 goto fail_gpio_c;
596 err = gpio_request(EP93XX_GPIO_LINE_D(i), dev_name(&pdev->dev));
597 if (err)
598 goto fail_gpio_d;
599 }
600
601 /* Enable the keypad controller; GPIO ports C and D used for keypad */
602 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_KEYS |
603 EP93XX_SYSCON_DEVCFG_GONK);
604
605 return 0;
606
607fail_gpio_d:
608 gpio_free(EP93XX_GPIO_LINE_C(i));
609fail_gpio_c:
Rafal Prylowski5528a842012-04-05 13:44:07 +0200610 for (--i; i >= 0; --i) {
Hartley Sweeten12f56c62009-10-28 21:04:46 +0100611 gpio_free(EP93XX_GPIO_LINE_C(i));
612 gpio_free(EP93XX_GPIO_LINE_D(i));
613 }
614 return err;
615}
616EXPORT_SYMBOL(ep93xx_keypad_acquire_gpio);
617
618void ep93xx_keypad_release_gpio(struct platform_device *pdev)
619{
620 int i;
621
622 for (i = 0; i < 8; i++) {
623 gpio_free(EP93XX_GPIO_LINE_C(i));
624 gpio_free(EP93XX_GPIO_LINE_D(i));
625 }
626
627 /* Disable the keypad controller; GPIO ports C and D used for GPIO */
628 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS |
629 EP93XX_SYSCON_DEVCFG_GONK);
630}
631EXPORT_SYMBOL(ep93xx_keypad_release_gpio);
632
Ryan Malloned67ea82010-06-08 22:01:10 +1200633/*************************************************************************
634 * EP93xx I2S audio peripheral handling
635 *************************************************************************/
636static struct resource ep93xx_i2s_resource[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700637 DEFINE_RES_MEM(EP93XX_I2S_PHYS_BASE, 0x100),
Ryan Malloned67ea82010-06-08 22:01:10 +1200638};
639
640static struct platform_device ep93xx_i2s_device = {
641 .name = "ep93xx-i2s",
642 .id = -1,
643 .num_resources = ARRAY_SIZE(ep93xx_i2s_resource),
644 .resource = ep93xx_i2s_resource,
645};
646
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000647static struct platform_device ep93xx_pcm_device = {
648 .name = "ep93xx-pcm-audio",
649 .id = -1,
650};
651
Ryan Malloned67ea82010-06-08 22:01:10 +1200652void __init ep93xx_register_i2s(void)
653{
654 platform_device_register(&ep93xx_i2s_device);
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000655 platform_device_register(&ep93xx_pcm_device);
Ryan Malloned67ea82010-06-08 22:01:10 +1200656}
657
658#define EP93XX_SYSCON_DEVCFG_I2S_MASK (EP93XX_SYSCON_DEVCFG_I2SONSSP | \
659 EP93XX_SYSCON_DEVCFG_I2SONAC97)
660
661#define EP93XX_I2SCLKDIV_MASK (EP93XX_SYSCON_I2SCLKDIV_ORIDE | \
662 EP93XX_SYSCON_I2SCLKDIV_SPOL)
663
Ryan Mallonf15855b2012-01-11 11:04:42 +1100664int ep93xx_i2s_acquire(void)
Ryan Malloned67ea82010-06-08 22:01:10 +1200665{
666 unsigned val;
667
Ryan Mallonf15855b2012-01-11 11:04:42 +1100668 ep93xx_devcfg_set_clear(EP93XX_SYSCON_DEVCFG_I2SONAC97,
669 EP93XX_SYSCON_DEVCFG_I2S_MASK);
Ryan Malloned67ea82010-06-08 22:01:10 +1200670
671 /*
672 * This is potentially racy with the clock api for i2s_mclk, sclk and
673 * lrclk. Since the i2s driver is the only user of those clocks we
674 * rely on it to prevent parallel use of this function and the
675 * clock api for the i2s clocks.
676 */
677 val = __raw_readl(EP93XX_SYSCON_I2SCLKDIV);
678 val &= ~EP93XX_I2SCLKDIV_MASK;
Ryan Mallonf15855b2012-01-11 11:04:42 +1100679 val |= EP93XX_SYSCON_I2SCLKDIV_ORIDE | EP93XX_SYSCON_I2SCLKDIV_SPOL;
Ryan Malloned67ea82010-06-08 22:01:10 +1200680 ep93xx_syscon_swlocked_write(val, EP93XX_SYSCON_I2SCLKDIV);
681
682 return 0;
683}
684EXPORT_SYMBOL(ep93xx_i2s_acquire);
685
686void ep93xx_i2s_release(void)
687{
688 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2S_MASK);
689}
690EXPORT_SYMBOL(ep93xx_i2s_release);
Hartley Sweeten12f56c62009-10-28 21:04:46 +0100691
Mika Westerberg534bc7f2010-10-14 17:49:07 +0300692/*************************************************************************
693 * EP93xx AC97 audio peripheral handling
694 *************************************************************************/
695static struct resource ep93xx_ac97_resources[] = {
H Hartley Sweetenede55aa2012-03-21 11:35:49 -0700696 DEFINE_RES_MEM(EP93XX_AAC_PHYS_BASE, 0xac),
697 DEFINE_RES_IRQ(IRQ_EP93XX_AACINTR),
Mika Westerberg534bc7f2010-10-14 17:49:07 +0300698};
699
700static struct platform_device ep93xx_ac97_device = {
701 .name = "ep93xx-ac97",
702 .id = -1,
703 .num_resources = ARRAY_SIZE(ep93xx_ac97_resources),
704 .resource = ep93xx_ac97_resources,
705};
706
707void __init ep93xx_register_ac97(void)
708{
709 /*
710 * Make sure that the AC97 pins are not used by I2S.
711 */
712 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONAC97);
713
714 platform_device_register(&ep93xx_ac97_device);
715 platform_device_register(&ep93xx_pcm_device);
716}
717
H Hartley Sweeten73303d12012-01-22 20:01:16 +1100718/*************************************************************************
719 * EP93xx Watchdog
720 *************************************************************************/
721static struct resource ep93xx_wdt_resources[] = {
722 DEFINE_RES_MEM(EP93XX_WATCHDOG_PHYS_BASE, 0x08),
723};
724
725static struct platform_device ep93xx_wdt_device = {
726 .name = "ep93xx-wdt",
727 .id = -1,
728 .num_resources = ARRAY_SIZE(ep93xx_wdt_resources),
729 .resource = ep93xx_wdt_resources,
730};
731
Rafal Prylowskieb774a02012-04-12 14:14:12 +0200732/*************************************************************************
733 * EP93xx IDE
734 *************************************************************************/
735static struct resource ep93xx_ide_resources[] = {
736 DEFINE_RES_MEM(EP93XX_IDE_PHYS_BASE, 0x38),
737 DEFINE_RES_IRQ(IRQ_EP93XX_EXT3),
738};
739
740static struct platform_device ep93xx_ide_device = {
741 .name = "ep93xx-ide",
742 .id = -1,
743 .dev = {
744 .dma_mask = &ep93xx_ide_device.dev.coherent_dma_mask,
745 .coherent_dma_mask = DMA_BIT_MASK(32),
746 },
747 .num_resources = ARRAY_SIZE(ep93xx_ide_resources),
748 .resource = ep93xx_ide_resources,
749};
750
751void __init ep93xx_register_ide(void)
752{
753 platform_device_register(&ep93xx_ide_device);
754}
755
756int ep93xx_ide_acquire_gpio(struct platform_device *pdev)
757{
758 int err;
759 int i;
760
761 err = gpio_request(EP93XX_GPIO_LINE_EGPIO2, dev_name(&pdev->dev));
762 if (err)
763 return err;
764 err = gpio_request(EP93XX_GPIO_LINE_EGPIO15, dev_name(&pdev->dev));
765 if (err)
766 goto fail_egpio15;
767 for (i = 2; i < 8; i++) {
768 err = gpio_request(EP93XX_GPIO_LINE_E(i), dev_name(&pdev->dev));
769 if (err)
770 goto fail_gpio_e;
771 }
772 for (i = 4; i < 8; i++) {
773 err = gpio_request(EP93XX_GPIO_LINE_G(i), dev_name(&pdev->dev));
774 if (err)
775 goto fail_gpio_g;
776 }
777 for (i = 0; i < 8; i++) {
778 err = gpio_request(EP93XX_GPIO_LINE_H(i), dev_name(&pdev->dev));
779 if (err)
780 goto fail_gpio_h;
781 }
782
783 /* GPIO ports E[7:2], G[7:4] and H used by IDE */
784 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_EONIDE |
785 EP93XX_SYSCON_DEVCFG_GONIDE |
786 EP93XX_SYSCON_DEVCFG_HONIDE);
787 return 0;
788
789fail_gpio_h:
790 for (--i; i >= 0; --i)
791 gpio_free(EP93XX_GPIO_LINE_H(i));
792 i = 8;
793fail_gpio_g:
794 for (--i; i >= 4; --i)
795 gpio_free(EP93XX_GPIO_LINE_G(i));
796 i = 8;
797fail_gpio_e:
798 for (--i; i >= 2; --i)
799 gpio_free(EP93XX_GPIO_LINE_E(i));
800 gpio_free(EP93XX_GPIO_LINE_EGPIO15);
801fail_egpio15:
802 gpio_free(EP93XX_GPIO_LINE_EGPIO2);
803 return err;
804}
805EXPORT_SYMBOL(ep93xx_ide_acquire_gpio);
806
807void ep93xx_ide_release_gpio(struct platform_device *pdev)
808{
809 int i;
810
811 for (i = 2; i < 8; i++)
812 gpio_free(EP93XX_GPIO_LINE_E(i));
813 for (i = 4; i < 8; i++)
814 gpio_free(EP93XX_GPIO_LINE_G(i));
815 for (i = 0; i < 8; i++)
816 gpio_free(EP93XX_GPIO_LINE_H(i));
817 gpio_free(EP93XX_GPIO_LINE_EGPIO15);
818 gpio_free(EP93XX_GPIO_LINE_EGPIO2);
819
820
821 /* GPIO ports E[7:2], G[7:4] and H used by GPIO */
822 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_EONIDE |
823 EP93XX_SYSCON_DEVCFG_GONIDE |
824 EP93XX_SYSCON_DEVCFG_HONIDE);
825}
826EXPORT_SYMBOL(ep93xx_ide_release_gpio);
827
H Hartley Sweetenb19e11f2013-11-19 10:23:06 +1100828/*************************************************************************
Alexander Sverdlin5364c642015-11-22 09:49:22 +0100829 * EP93xx ADC
830 *************************************************************************/
831static struct resource ep93xx_adc_resources[] = {
832 DEFINE_RES_MEM(EP93XX_ADC_PHYS_BASE, 0x28),
833 DEFINE_RES_IRQ(IRQ_EP93XX_TOUCH),
834};
835
836static struct platform_device ep93xx_adc_device = {
837 .name = "ep93xx-adc",
838 .id = -1,
839 .num_resources = ARRAY_SIZE(ep93xx_adc_resources),
840 .resource = ep93xx_adc_resources,
841};
842
843void __init ep93xx_register_adc(void)
844{
845 /* Power up ADC, deactivate Touch Screen Controller */
846 ep93xx_devcfg_set_clear(EP93XX_SYSCON_DEVCFG_TIN,
847 EP93XX_SYSCON_DEVCFG_ADCPD);
848
849 platform_device_register(&ep93xx_adc_device);
850}
851
852/*************************************************************************
H Hartley Sweetenb19e11f2013-11-19 10:23:06 +1100853 * EP93xx Security peripheral
854 *************************************************************************/
855
856/*
857 * The Maverick Key is 256 bits of micro fuses blown at the factory during
858 * manufacturing to uniquely identify a part.
859 *
860 * See: http://arm.cirrus.com/forum/viewtopic.php?t=486&highlight=maverick+key
861 */
862#define EP93XX_SECURITY_REG(x) (EP93XX_SECURITY_BASE + (x))
863#define EP93XX_SECURITY_SECFLG EP93XX_SECURITY_REG(0x2400)
864#define EP93XX_SECURITY_FUSEFLG EP93XX_SECURITY_REG(0x2410)
865#define EP93XX_SECURITY_UNIQID EP93XX_SECURITY_REG(0x2440)
866#define EP93XX_SECURITY_UNIQCHK EP93XX_SECURITY_REG(0x2450)
867#define EP93XX_SECURITY_UNIQVAL EP93XX_SECURITY_REG(0x2460)
868#define EP93XX_SECURITY_SECID1 EP93XX_SECURITY_REG(0x2500)
869#define EP93XX_SECURITY_SECID2 EP93XX_SECURITY_REG(0x2504)
870#define EP93XX_SECURITY_SECCHK1 EP93XX_SECURITY_REG(0x2520)
871#define EP93XX_SECURITY_SECCHK2 EP93XX_SECURITY_REG(0x2524)
872#define EP93XX_SECURITY_UNIQID2 EP93XX_SECURITY_REG(0x2700)
873#define EP93XX_SECURITY_UNIQID3 EP93XX_SECURITY_REG(0x2704)
874#define EP93XX_SECURITY_UNIQID4 EP93XX_SECURITY_REG(0x2708)
875#define EP93XX_SECURITY_UNIQID5 EP93XX_SECURITY_REG(0x270c)
876
877static char ep93xx_soc_id[33];
878
879static const char __init *ep93xx_get_soc_id(void)
Lennert Buytenheke7736d42006-03-20 17:10:13 +0000880{
H Hartley Sweetenb19e11f2013-11-19 10:23:06 +1100881 unsigned int id, id2, id3, id4, id5;
882
883 if (__raw_readl(EP93XX_SECURITY_UNIQVAL) != 1)
884 return "bad Hamming code";
885
886 id = __raw_readl(EP93XX_SECURITY_UNIQID);
887 id2 = __raw_readl(EP93XX_SECURITY_UNIQID2);
888 id3 = __raw_readl(EP93XX_SECURITY_UNIQID3);
889 id4 = __raw_readl(EP93XX_SECURITY_UNIQID4);
890 id5 = __raw_readl(EP93XX_SECURITY_UNIQID5);
891
892 if (id != id2)
893 return "invalid";
894
Linus Walleije8a7d2b2015-06-18 16:46:34 +0200895 /* Toss the unique ID into the entropy pool */
896 add_device_randomness(&id2, 4);
897 add_device_randomness(&id3, 4);
898 add_device_randomness(&id4, 4);
899 add_device_randomness(&id5, 4);
900
H Hartley Sweetenb19e11f2013-11-19 10:23:06 +1100901 snprintf(ep93xx_soc_id, sizeof(ep93xx_soc_id),
902 "%08x%08x%08x%08x", id2, id3, id4, id5);
903
904 return ep93xx_soc_id;
905}
906
907static const char __init *ep93xx_get_soc_rev(void)
908{
909 int rev = ep93xx_chip_revision();
910
911 switch (rev) {
912 case EP93XX_CHIP_REV_D0:
913 return "D0";
914 case EP93XX_CHIP_REV_D1:
915 return "D1";
916 case EP93XX_CHIP_REV_E0:
917 return "E0";
918 case EP93XX_CHIP_REV_E1:
919 return "E1";
920 case EP93XX_CHIP_REV_E2:
921 return "E2";
922 default:
923 return "unknown";
924 }
925}
926
927static const char __init *ep93xx_get_machine_name(void)
928{
929 return kasprintf(GFP_KERNEL,"%s", machine_desc->name);
930}
931
932static struct device __init *ep93xx_init_soc(void)
933{
934 struct soc_device_attribute *soc_dev_attr;
935 struct soc_device *soc_dev;
936
937 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
938 if (!soc_dev_attr)
939 return NULL;
940
941 soc_dev_attr->machine = ep93xx_get_machine_name();
942 soc_dev_attr->family = "Cirrus Logic EP93xx";
943 soc_dev_attr->revision = ep93xx_get_soc_rev();
944 soc_dev_attr->soc_id = ep93xx_get_soc_id();
945
946 soc_dev = soc_device_register(soc_dev_attr);
947 if (IS_ERR(soc_dev)) {
948 kfree(soc_dev_attr->machine);
949 kfree(soc_dev_attr);
950 return NULL;
951 }
952
953 return soc_device_to_device(soc_dev);
954}
955
956struct device __init *ep93xx_init_devices(void)
957{
958 struct device *parent;
959
Hartley Sweeten02239f02009-07-08 02:00:49 +0100960 /* Disallow access to MaverickCrunch initially */
961 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA);
Lennert Buytenhekaee85fe2006-03-26 23:16:39 +0100962
Ryan Mallon08932d82012-01-11 09:58:30 +1100963 /* Default all ports to GPIO */
964 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS |
965 EP93XX_SYSCON_DEVCFG_GONK |
966 EP93XX_SYSCON_DEVCFG_EONIDE |
967 EP93XX_SYSCON_DEVCFG_GONIDE |
968 EP93XX_SYSCON_DEVCFG_HONIDE);
969
H Hartley Sweetenb19e11f2013-11-19 10:23:06 +1100970 parent = ep93xx_init_soc();
971
H Hartley Sweeten1e4c8842011-06-08 14:35:33 -0700972 /* Get the GPIO working early, other devices need it */
973 platform_device_register(&ep93xx_gpio_device);
Ryan Mallonb6850042008-04-16 02:56:35 +0100974
Lennert Buytenhekaee85fe2006-03-26 23:16:39 +0100975 amba_device_register(&uart1_device, &iomem_resource);
976 amba_device_register(&uart2_device, &iomem_resource);
977 amba_device_register(&uart3_device, &iomem_resource);
Lennert Buytenhek41658132006-04-02 16:17:34 +0100978
979 platform_device_register(&ep93xx_rtc_device);
Lennert Buytenhek1f64eb32006-06-24 10:33:03 +0100980 platform_device_register(&ep93xx_ohci_device);
H Hartley Sweeten73303d12012-01-22 20:01:16 +1100981 platform_device_register(&ep93xx_wdt_device);
H Hartley Sweetena1eacd72012-04-11 15:44:42 -0700982
983 gpio_led_register_device(-1, &ep93xx_led_data);
H Hartley Sweetenb19e11f2013-11-19 10:23:06 +1100984
985 return parent;
Lennert Buytenheke7736d42006-03-20 17:10:13 +0000986}
Russell King32751662011-11-05 09:54:14 +0000987
Robin Holt7b6d8642013-07-08 16:01:40 -0700988void ep93xx_restart(enum reboot_mode mode, const char *cmd)
Russell King32751662011-11-05 09:54:14 +0000989{
990 /*
991 * Set then clear the SWRST bit to initiate a software reset
992 */
993 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_SWRST);
994 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_SWRST);
995
996 while (1)
997 ;
998}
Shawn Guoc9142832012-04-26 10:05:15 +0800999
1000void __init ep93xx_init_late(void)
1001{
1002 crunch_init();
1003}