Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 Texas Instruments Inc. |
| 3 | * Mikkel Christensen <mlc@ti.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/kernel.h> |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/gpio.h> |
| 13 | #include <linux/serial_8250.h> |
| 14 | #include <linux/smsc911x.h> |
Vikram Pandita | c426df8 | 2009-08-28 11:24:08 -0700 | [diff] [blame] | 15 | #include <linux/interrupt.h> |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 16 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 17 | #include <plat/gpmc.h> |
Mike Rapoport | 21b4273 | 2011-04-16 22:29:30 +0000 | [diff] [blame] | 18 | #include <plat/gpmc-smsc911x.h> |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 19 | |
Manjunath Kondaiah G | 04aeae7 | 2010-10-08 09:58:35 -0700 | [diff] [blame] | 20 | #include <mach/board-zoom.h> |
| 21 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 22 | #define ZOOM_SMSC911X_CS 7 |
| 23 | #define ZOOM_SMSC911X_GPIO 158 |
| 24 | #define ZOOM_QUADUART_CS 3 |
| 25 | #define ZOOM_QUADUART_GPIO 102 |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 26 | #define QUART_CLK 1843200 |
| 27 | #define DEBUG_BASE 0x08000000 |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 28 | #define ZOOM_ETHR_START DEBUG_BASE |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 29 | |
Mike Rapoport | 21b4273 | 2011-04-16 22:29:30 +0000 | [diff] [blame] | 30 | static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = { |
| 31 | .cs = ZOOM_SMSC911X_CS, |
| 32 | .gpio_irq = ZOOM_SMSC911X_GPIO, |
| 33 | .gpio_reset = -EINVAL, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 34 | .flags = SMSC911X_USE_32BIT, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 37 | static inline void __init zoom_init_smsc911x(void) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 38 | { |
Mike Rapoport | 21b4273 | 2011-04-16 22:29:30 +0000 | [diff] [blame] | 39 | gpmc_smsc911x_init(&zoom_smsc911x_cfg); |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static struct plat_serial8250_port serial_platform_data[] = { |
| 43 | { |
Tony Lindgren | a4f57b8 | 2010-04-30 12:57:14 -0700 | [diff] [blame] | 44 | .mapbase = ZOOM_UART_BASE, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 45 | .irq = OMAP_GPIO_IRQ(102), |
| 46 | .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ, |
Vikram Pandita | c426df8 | 2009-08-28 11:24:08 -0700 | [diff] [blame] | 47 | .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 48 | .iotype = UPIO_MEM, |
| 49 | .regshift = 1, |
| 50 | .uartclk = QUART_CLK, |
| 51 | }, { |
| 52 | .flags = 0 |
| 53 | } |
| 54 | }; |
| 55 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 56 | static struct platform_device zoom_debugboard_serial_device = { |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 57 | .name = "serial8250", |
Sergio Aguirre | fcbcea9 | 2010-03-01 12:17:15 -0600 | [diff] [blame] | 58 | .id = PLAT8250_DEV_PLATFORM, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 59 | .dev = { |
| 60 | .platform_data = serial_platform_data, |
| 61 | }, |
| 62 | }; |
| 63 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 64 | static inline void __init zoom_init_quaduart(void) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 65 | { |
| 66 | int quart_cs; |
| 67 | unsigned long cs_mem_base; |
| 68 | int quart_gpio = 0; |
| 69 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 70 | quart_cs = ZOOM_QUADUART_CS; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 71 | |
| 72 | if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) { |
| 73 | printk(KERN_ERR "Failed to request GPMC mem" |
| 74 | "for Quad UART(TL16CP754C)\n"); |
| 75 | return; |
| 76 | } |
| 77 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 78 | quart_gpio = ZOOM_QUADUART_GPIO; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 79 | |
Igor Grinberg | bc593f5 | 2011-05-03 18:22:09 +0300 | [diff] [blame] | 80 | if (gpio_request_one(quart_gpio, GPIOF_IN, "TL16CP754C GPIO") < 0) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 81 | printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n", |
| 82 | quart_gpio); |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 83 | } |
| 84 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 85 | static inline int omap_zoom_debugboard_detect(void) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 86 | { |
| 87 | int debug_board_detect = 0; |
Vikram Pandita | 2fcc81a | 2009-08-21 13:11:20 -0500 | [diff] [blame] | 88 | int ret = 1; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 89 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 90 | debug_board_detect = ZOOM_SMSC911X_GPIO; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 91 | |
Igor Grinberg | bc593f5 | 2011-05-03 18:22:09 +0300 | [diff] [blame] | 92 | if (gpio_request_one(debug_board_detect, GPIOF_IN, |
| 93 | "Zoom debug board detect") < 0) { |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 94 | printk(KERN_ERR "Failed to request GPIO%d for Zoom debug" |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 95 | "board detect\n", debug_board_detect); |
| 96 | return 0; |
| 97 | } |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 98 | |
| 99 | if (!gpio_get_value(debug_board_detect)) { |
Vikram Pandita | 2fcc81a | 2009-08-21 13:11:20 -0500 | [diff] [blame] | 100 | ret = 0; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 101 | } |
Vikram Pandita | 2fcc81a | 2009-08-21 13:11:20 -0500 | [diff] [blame] | 102 | gpio_free(debug_board_detect); |
| 103 | return ret; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 104 | } |
| 105 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 106 | static struct platform_device *zoom_devices[] __initdata = { |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 107 | &zoom_debugboard_serial_device, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 110 | int __init zoom_debugboard_init(void) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 111 | { |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 112 | if (!omap_zoom_debugboard_detect()) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 113 | return 0; |
| 114 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 115 | zoom_init_smsc911x(); |
| 116 | zoom_init_quaduart(); |
| 117 | return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices)); |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 118 | } |