Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 1 | /* |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 2 | * Copyright 2004-2007 Analog Devices Inc. |
| 3 | * 2005 National ICT Australia (NICTA) |
| 4 | * Aidan Williams <aidan@nicta.com.au> |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 5 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 6 | * Thanks to Jamey Hicks. |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 7 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 8 | * Only SMSC91C1111 was registered, may do more later. |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 9 | * |
Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 10 | * Licensed under the GPL-2 |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <linux/device.h> |
| 14 | #include <linux/platform_device.h> |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 15 | #include <linux/irq.h> |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 16 | |
Mike Frysinger | 066954a | 2007-10-21 22:36:06 +0800 | [diff] [blame] | 17 | const char bfin_board_name[] = "Tepla-BF561"; |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 18 | |
| 19 | /* |
| 20 | * Driver needs to know address, irq and flag pin. |
| 21 | */ |
| 22 | static struct resource smc91x_resources[] = { |
| 23 | { |
| 24 | .start = 0x2C000300, |
| 25 | .end = 0x2C000320, |
| 26 | .flags = IORESOURCE_MEM, |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 27 | }, { |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 28 | .start = IRQ_PROG_INTB, |
| 29 | .end = IRQ_PROG_INTB, |
| 30 | .flags = IORESOURCE_IRQ|IORESOURCE_IRQ_HIGHLEVEL, |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 31 | }, { |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 32 | .start = IRQ_PF7, |
| 33 | .end = IRQ_PF7, |
| 34 | .flags = IORESOURCE_IRQ|IORESOURCE_IRQ_HIGHLEVEL, |
| 35 | }, |
| 36 | }; |
| 37 | |
| 38 | static struct platform_device smc91x_device = { |
| 39 | .name = "smc91x", |
| 40 | .id = 0, |
| 41 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 42 | .resource = smc91x_resources, |
| 43 | }; |
| 44 | |
Steven Miao | c4a2c58 | 2014-04-12 02:07:27 +0800 | [diff] [blame] | 45 | #if IS_ENABLED(CONFIG_SERIAL_BFIN) |
Sonic Zhang | 6bd1fbe | 2009-09-09 10:46:19 +0000 | [diff] [blame] | 46 | #ifdef CONFIG_SERIAL_BFIN_UART0 |
| 47 | static struct resource bfin_uart0_resources[] = { |
| 48 | { |
| 49 | .start = BFIN_UART_THR, |
| 50 | .end = BFIN_UART_GCTL+2, |
| 51 | .flags = IORESOURCE_MEM, |
| 52 | }, |
| 53 | { |
Sonic Zhang | edb0a64 | 2011-08-01 17:53:21 +0800 | [diff] [blame] | 54 | .start = IRQ_UART_TX, |
| 55 | .end = IRQ_UART_TX, |
| 56 | .flags = IORESOURCE_IRQ, |
| 57 | }, |
| 58 | { |
Sonic Zhang | 6bd1fbe | 2009-09-09 10:46:19 +0000 | [diff] [blame] | 59 | .start = IRQ_UART_RX, |
Sonic Zhang | edb0a64 | 2011-08-01 17:53:21 +0800 | [diff] [blame] | 60 | .end = IRQ_UART_RX, |
Sonic Zhang | 6bd1fbe | 2009-09-09 10:46:19 +0000 | [diff] [blame] | 61 | .flags = IORESOURCE_IRQ, |
| 62 | }, |
| 63 | { |
| 64 | .start = IRQ_UART_ERROR, |
| 65 | .end = IRQ_UART_ERROR, |
| 66 | .flags = IORESOURCE_IRQ, |
| 67 | }, |
| 68 | { |
| 69 | .start = CH_UART_TX, |
| 70 | .end = CH_UART_TX, |
| 71 | .flags = IORESOURCE_DMA, |
| 72 | }, |
| 73 | { |
| 74 | .start = CH_UART_RX, |
| 75 | .end = CH_UART_RX, |
| 76 | .flags = IORESOURCE_DMA, |
| 77 | }, |
| 78 | }; |
| 79 | |
Mike Frysinger | a8b1988 | 2010-11-24 09:23:04 +0000 | [diff] [blame] | 80 | static unsigned short bfin_uart0_peripherals[] = { |
Sonic Zhang | 6bd1fbe | 2009-09-09 10:46:19 +0000 | [diff] [blame] | 81 | P_UART0_TX, P_UART0_RX, 0 |
| 82 | }; |
| 83 | |
| 84 | static struct platform_device bfin_uart0_device = { |
| 85 | .name = "bfin-uart", |
| 86 | .id = 0, |
| 87 | .num_resources = ARRAY_SIZE(bfin_uart0_resources), |
| 88 | .resource = bfin_uart0_resources, |
| 89 | .dev = { |
| 90 | .platform_data = &bfin_uart0_peripherals, /* Passed to driver */ |
| 91 | }, |
| 92 | }; |
| 93 | #endif |
| 94 | #endif |
| 95 | |
Steven Miao | c4a2c58 | 2014-04-12 02:07:27 +0800 | [diff] [blame] | 96 | #if IS_ENABLED(CONFIG_BFIN_SIR) |
Graf Yang | 42bd8bc | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 97 | #ifdef CONFIG_BFIN_SIR0 |
| 98 | static struct resource bfin_sir0_resources[] = { |
| 99 | { |
| 100 | .start = 0xFFC00400, |
| 101 | .end = 0xFFC004FF, |
| 102 | .flags = IORESOURCE_MEM, |
| 103 | }, |
| 104 | { |
| 105 | .start = IRQ_UART0_RX, |
| 106 | .end = IRQ_UART0_RX+1, |
| 107 | .flags = IORESOURCE_IRQ, |
| 108 | }, |
| 109 | { |
| 110 | .start = CH_UART0_RX, |
| 111 | .end = CH_UART0_RX+1, |
| 112 | .flags = IORESOURCE_DMA, |
| 113 | }, |
| 114 | }; |
| 115 | |
| 116 | static struct platform_device bfin_sir0_device = { |
| 117 | .name = "bfin_sir", |
| 118 | .id = 0, |
| 119 | .num_resources = ARRAY_SIZE(bfin_sir0_resources), |
| 120 | .resource = bfin_sir0_resources, |
| 121 | }; |
| 122 | #endif |
| 123 | #endif |
| 124 | |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 125 | static struct platform_device *tepla_devices[] __initdata = { |
| 126 | &smc91x_device, |
Sonic Zhang | 6bd1fbe | 2009-09-09 10:46:19 +0000 | [diff] [blame] | 127 | |
Steven Miao | c4a2c58 | 2014-04-12 02:07:27 +0800 | [diff] [blame] | 128 | #if IS_ENABLED(CONFIG_SERIAL_BFIN) |
Sonic Zhang | 6bd1fbe | 2009-09-09 10:46:19 +0000 | [diff] [blame] | 129 | #ifdef CONFIG_SERIAL_BFIN_UART0 |
| 130 | &bfin_uart0_device, |
| 131 | #endif |
| 132 | #endif |
| 133 | |
Steven Miao | c4a2c58 | 2014-04-12 02:07:27 +0800 | [diff] [blame] | 134 | #if IS_ENABLED(CONFIG_BFIN_SIR) |
Graf Yang | 42bd8bc | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 135 | #ifdef CONFIG_BFIN_SIR0 |
| 136 | &bfin_sir0_device, |
| 137 | #endif |
| 138 | #endif |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | static int __init tepla_init(void) |
| 142 | { |
Harvey Harrison | b85d858 | 2008-04-23 09:39:01 +0800 | [diff] [blame] | 143 | printk(KERN_INFO "%s(): registering device resources\n", __func__); |
Mike Frysinger | 0a29059 | 2007-05-21 18:09:21 +0800 | [diff] [blame] | 144 | return platform_add_devices(tepla_devices, ARRAY_SIZE(tepla_devices)); |
| 145 | } |
| 146 | |
| 147 | arch_initcall(tepla_init); |
Sonic Zhang | c13ce9f | 2009-09-23 09:37:46 +0000 | [diff] [blame] | 148 | |
| 149 | static struct platform_device *tepla_early_devices[] __initdata = { |
| 150 | #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK) |
| 151 | #ifdef CONFIG_SERIAL_BFIN_UART0 |
| 152 | &bfin_uart0_device, |
| 153 | #endif |
| 154 | #endif |
| 155 | }; |
| 156 | |
| 157 | void __init native_machine_early_platform_add_devices(void) |
| 158 | { |
| 159 | printk(KERN_INFO "register early platform devices\n"); |
| 160 | early_platform_add_devices(tepla_early_devices, |
| 161 | ARRAY_SIZE(tepla_early_devices)); |
| 162 | } |