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> |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 18 | |
Manjunath Kondaiah G | 04aeae7 | 2010-10-08 09:58:35 -0700 | [diff] [blame] | 19 | #include <mach/board-zoom.h> |
| 20 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 21 | #define ZOOM_SMSC911X_CS 7 |
| 22 | #define ZOOM_SMSC911X_GPIO 158 |
| 23 | #define ZOOM_QUADUART_CS 3 |
| 24 | #define ZOOM_QUADUART_GPIO 102 |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 25 | #define QUART_CLK 1843200 |
| 26 | #define DEBUG_BASE 0x08000000 |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 27 | #define ZOOM_ETHR_START DEBUG_BASE |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 28 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 29 | static struct resource zoom_smsc911x_resources[] = { |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 30 | [0] = { |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 31 | .start = ZOOM_ETHR_START, |
| 32 | .end = ZOOM_ETHR_START + SZ_4K, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 33 | .flags = IORESOURCE_MEM, |
| 34 | }, |
| 35 | [1] = { |
| 36 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
| 37 | }, |
| 38 | }; |
| 39 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 40 | static struct smsc911x_platform_config zoom_smsc911x_config = { |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 41 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 42 | .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN, |
| 43 | .flags = SMSC911X_USE_32BIT, |
| 44 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 45 | }; |
| 46 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 47 | static struct platform_device zoom_smsc911x_device = { |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 48 | .name = "smsc911x", |
| 49 | .id = -1, |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 50 | .num_resources = ARRAY_SIZE(zoom_smsc911x_resources), |
| 51 | .resource = zoom_smsc911x_resources, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 52 | .dev = { |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 53 | .platform_data = &zoom_smsc911x_config, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 54 | }, |
| 55 | }; |
| 56 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 57 | static inline void __init zoom_init_smsc911x(void) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 58 | { |
| 59 | int eth_cs; |
| 60 | unsigned long cs_mem_base; |
| 61 | int eth_gpio = 0; |
| 62 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 63 | eth_cs = ZOOM_SMSC911X_CS; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 64 | |
| 65 | if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { |
| 66 | printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n"); |
| 67 | return; |
| 68 | } |
| 69 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 70 | zoom_smsc911x_resources[0].start = cs_mem_base + 0x0; |
| 71 | zoom_smsc911x_resources[0].end = cs_mem_base + 0xff; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 72 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 73 | eth_gpio = ZOOM_SMSC911X_GPIO; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 74 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 75 | zoom_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio); |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 76 | |
| 77 | if (gpio_request(eth_gpio, "smsc911x irq") < 0) { |
| 78 | printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n", |
| 79 | eth_gpio); |
| 80 | return; |
| 81 | } |
| 82 | gpio_direction_input(eth_gpio); |
| 83 | } |
| 84 | |
| 85 | static struct plat_serial8250_port serial_platform_data[] = { |
| 86 | { |
Tony Lindgren | a4f57b8 | 2010-04-30 12:57:14 -0700 | [diff] [blame] | 87 | .mapbase = ZOOM_UART_BASE, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 88 | .irq = OMAP_GPIO_IRQ(102), |
| 89 | .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ, |
Vikram Pandita | c426df8 | 2009-08-28 11:24:08 -0700 | [diff] [blame] | 90 | .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 91 | .iotype = UPIO_MEM, |
| 92 | .regshift = 1, |
| 93 | .uartclk = QUART_CLK, |
| 94 | }, { |
| 95 | .flags = 0 |
| 96 | } |
| 97 | }; |
| 98 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 99 | static struct platform_device zoom_debugboard_serial_device = { |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 100 | .name = "serial8250", |
Sergio Aguirre | fcbcea9 | 2010-03-01 12:17:15 -0600 | [diff] [blame] | 101 | .id = PLAT8250_DEV_PLATFORM, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 102 | .dev = { |
| 103 | .platform_data = serial_platform_data, |
| 104 | }, |
| 105 | }; |
| 106 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 107 | static inline void __init zoom_init_quaduart(void) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 108 | { |
| 109 | int quart_cs; |
| 110 | unsigned long cs_mem_base; |
| 111 | int quart_gpio = 0; |
| 112 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 113 | quart_cs = ZOOM_QUADUART_CS; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 114 | |
| 115 | if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) { |
| 116 | printk(KERN_ERR "Failed to request GPMC mem" |
| 117 | "for Quad UART(TL16CP754C)\n"); |
| 118 | return; |
| 119 | } |
| 120 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 121 | quart_gpio = ZOOM_QUADUART_GPIO; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 122 | |
| 123 | if (gpio_request(quart_gpio, "TL16CP754C GPIO") < 0) { |
| 124 | printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n", |
| 125 | quart_gpio); |
| 126 | return; |
| 127 | } |
| 128 | gpio_direction_input(quart_gpio); |
| 129 | } |
| 130 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 131 | static inline int omap_zoom_debugboard_detect(void) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 132 | { |
| 133 | int debug_board_detect = 0; |
Vikram Pandita | 2fcc81a | 2009-08-21 13:11:20 -0500 | [diff] [blame] | 134 | int ret = 1; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 135 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 136 | debug_board_detect = ZOOM_SMSC911X_GPIO; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 137 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 138 | if (gpio_request(debug_board_detect, "Zoom debug board detect") < 0) { |
| 139 | printk(KERN_ERR "Failed to request GPIO%d for Zoom debug" |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 140 | "board detect\n", debug_board_detect); |
| 141 | return 0; |
| 142 | } |
| 143 | gpio_direction_input(debug_board_detect); |
| 144 | |
| 145 | if (!gpio_get_value(debug_board_detect)) { |
Vikram Pandita | 2fcc81a | 2009-08-21 13:11:20 -0500 | [diff] [blame] | 146 | ret = 0; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 147 | } |
Vikram Pandita | 2fcc81a | 2009-08-21 13:11:20 -0500 | [diff] [blame] | 148 | gpio_free(debug_board_detect); |
| 149 | return ret; |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 150 | } |
| 151 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 152 | static struct platform_device *zoom_devices[] __initdata = { |
| 153 | &zoom_smsc911x_device, |
| 154 | &zoom_debugboard_serial_device, |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 155 | }; |
| 156 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 157 | int __init zoom_debugboard_init(void) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 158 | { |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 159 | if (!omap_zoom_debugboard_detect()) |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 160 | return 0; |
| 161 | |
vikram pandita | 62d0b336 | 2009-11-22 10:11:31 -0800 | [diff] [blame] | 162 | zoom_init_smsc911x(); |
| 163 | zoom_init_quaduart(); |
| 164 | return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices)); |
Vikram Pandita | 577145f | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 165 | } |