diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2006-01-07 09:40:05 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-01-07 09:40:05 -0500 |
commit | 123656d4cc8c946f578ebd18c2050f5251720428 (patch) | |
tree | 3d5432eff034a3b9cfdc98b37e245abe5695342d /drivers/serial | |
parent | a62c80e559809e6c7851ec04d30575e85ad6f6ed (diff) | |
parent | 0aec63e67c69545ca757a73a66f5dcf05fa484bf (diff) |
Merge with Linus' kernel.
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/mpc52xx_uart.c | 28 | ||||
-rw-r--r-- | drivers/serial/serial_cs.c | 119 |
2 files changed, 38 insertions, 109 deletions
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index b8727d9bf690..1288d6203e94 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -37,11 +37,11 @@ | |||
37 | * by the bootloader or in the platform init code. | 37 | * by the bootloader or in the platform init code. |
38 | * | 38 | * |
39 | * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2, | 39 | * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2, |
40 | * and so on). So the PSC1 is mapped to /dev/ttyS0, PSC2 to /dev/ttyS1 and so | 40 | * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and |
41 | * on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly for | 41 | * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly |
42 | * the console code : without this 1:1 mapping, at early boot time, when we are | 42 | * fpr the console code : without this 1:1 mapping, at early boot time, when we |
43 | * parsing the kernel args console=ttyS?, we wouldn't know wich PSC it will be | 43 | * are parsing the kernel args console=ttyPSC?, we wouldn't know wich PSC it |
44 | * mapped to. | 44 | * will be mapped to. |
45 | */ | 45 | */ |
46 | 46 | ||
47 | #include <linux/config.h> | 47 | #include <linux/config.h> |
@@ -65,6 +65,10 @@ | |||
65 | #include <linux/serial_core.h> | 65 | #include <linux/serial_core.h> |
66 | 66 | ||
67 | 67 | ||
68 | /* We've been assigned a range on the "Low-density serial ports" major */ | ||
69 | #define SERIAL_PSC_MAJOR 204 | ||
70 | #define SERIAL_PSC_MINOR 148 | ||
71 | |||
68 | 72 | ||
69 | #define ISR_PASS_LIMIT 256 /* Max number of iteration in the interrupt */ | 73 | #define ISR_PASS_LIMIT 256 /* Max number of iteration in the interrupt */ |
70 | 74 | ||
@@ -668,15 +672,15 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
668 | } | 672 | } |
669 | 673 | ||
670 | 674 | ||
671 | extern struct uart_driver mpc52xx_uart_driver; | 675 | static struct uart_driver mpc52xx_uart_driver; |
672 | 676 | ||
673 | static struct console mpc52xx_console = { | 677 | static struct console mpc52xx_console = { |
674 | .name = "ttyS", | 678 | .name = "ttyPSC", |
675 | .write = mpc52xx_console_write, | 679 | .write = mpc52xx_console_write, |
676 | .device = uart_console_device, | 680 | .device = uart_console_device, |
677 | .setup = mpc52xx_console_setup, | 681 | .setup = mpc52xx_console_setup, |
678 | .flags = CON_PRINTBUFFER, | 682 | .flags = CON_PRINTBUFFER, |
679 | .index = -1, /* Specified on the cmdline (e.g. console=ttyS0 ) */ | 683 | .index = -1, /* Specified on the cmdline (e.g. console=ttyPSC0 ) */ |
680 | .data = &mpc52xx_uart_driver, | 684 | .data = &mpc52xx_uart_driver, |
681 | }; | 685 | }; |
682 | 686 | ||
@@ -703,10 +707,10 @@ console_initcall(mpc52xx_console_init); | |||
703 | static struct uart_driver mpc52xx_uart_driver = { | 707 | static struct uart_driver mpc52xx_uart_driver = { |
704 | .owner = THIS_MODULE, | 708 | .owner = THIS_MODULE, |
705 | .driver_name = "mpc52xx_psc_uart", | 709 | .driver_name = "mpc52xx_psc_uart", |
706 | .dev_name = "ttyS", | 710 | .dev_name = "ttyPSC", |
707 | .devfs_name = "ttyS", | 711 | .devfs_name = "ttyPSC", |
708 | .major = TTY_MAJOR, | 712 | .major = SERIAL_PSC_MAJOR, |
709 | .minor = 64, | 713 | .minor = SERIAL_PSC_MINOR, |
710 | .nr = MPC52xx_PSC_MAXNUM, | 714 | .nr = MPC52xx_PSC_MAXNUM, |
711 | .cons = MPC52xx_PSC_CONSOLE, | 715 | .cons = MPC52xx_PSC_CONSOLE, |
712 | }; | 716 | }; |
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 7ce0c7e66d37..96969cb960a9 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c | |||
@@ -114,15 +114,7 @@ struct serial_cfg_mem { | |||
114 | 114 | ||
115 | 115 | ||
116 | static void serial_config(dev_link_t * link); | 116 | static void serial_config(dev_link_t * link); |
117 | static int serial_event(event_t event, int priority, | ||
118 | event_callback_args_t * args); | ||
119 | 117 | ||
120 | static dev_info_t dev_info = "serial_cs"; | ||
121 | |||
122 | static dev_link_t *serial_attach(void); | ||
123 | static void serial_detach(dev_link_t *); | ||
124 | |||
125 | static dev_link_t *dev_list = NULL; | ||
126 | 118 | ||
127 | /*====================================================================== | 119 | /*====================================================================== |
128 | 120 | ||
@@ -159,8 +151,9 @@ static void serial_remove(dev_link_t *link) | |||
159 | } | 151 | } |
160 | } | 152 | } |
161 | 153 | ||
162 | static void serial_suspend(dev_link_t *link) | 154 | static int serial_suspend(struct pcmcia_device *dev) |
163 | { | 155 | { |
156 | dev_link_t *link = dev_to_instance(dev); | ||
164 | link->state |= DEV_SUSPEND; | 157 | link->state |= DEV_SUSPEND; |
165 | 158 | ||
166 | if (link->state & DEV_CONFIG) { | 159 | if (link->state & DEV_CONFIG) { |
@@ -173,10 +166,13 @@ static void serial_suspend(dev_link_t *link) | |||
173 | if (!info->slave) | 166 | if (!info->slave) |
174 | pcmcia_release_configuration(link->handle); | 167 | pcmcia_release_configuration(link->handle); |
175 | } | 168 | } |
169 | |||
170 | return 0; | ||
176 | } | 171 | } |
177 | 172 | ||
178 | static void serial_resume(dev_link_t *link) | 173 | static int serial_resume(struct pcmcia_device *dev) |
179 | { | 174 | { |
175 | dev_link_t *link = dev_to_instance(dev); | ||
180 | link->state &= ~DEV_SUSPEND; | 176 | link->state &= ~DEV_SUSPEND; |
181 | 177 | ||
182 | if (DEV_OK(link)) { | 178 | if (DEV_OK(link)) { |
@@ -189,6 +185,8 @@ static void serial_resume(dev_link_t *link) | |||
189 | for (i = 0; i < info->ndev; i++) | 185 | for (i = 0; i < info->ndev; i++) |
190 | serial8250_resume_port(info->line[i]); | 186 | serial8250_resume_port(info->line[i]); |
191 | } | 187 | } |
188 | |||
189 | return 0; | ||
192 | } | 190 | } |
193 | 191 | ||
194 | /*====================================================================== | 192 | /*====================================================================== |
@@ -199,19 +197,17 @@ static void serial_resume(dev_link_t *link) | |||
199 | 197 | ||
200 | ======================================================================*/ | 198 | ======================================================================*/ |
201 | 199 | ||
202 | static dev_link_t *serial_attach(void) | 200 | static int serial_probe(struct pcmcia_device *p_dev) |
203 | { | 201 | { |
204 | struct serial_info *info; | 202 | struct serial_info *info; |
205 | client_reg_t client_reg; | ||
206 | dev_link_t *link; | 203 | dev_link_t *link; |
207 | int ret; | ||
208 | 204 | ||
209 | DEBUG(0, "serial_attach()\n"); | 205 | DEBUG(0, "serial_attach()\n"); |
210 | 206 | ||
211 | /* Create new serial device */ | 207 | /* Create new serial device */ |
212 | info = kmalloc(sizeof (*info), GFP_KERNEL); | 208 | info = kmalloc(sizeof (*info), GFP_KERNEL); |
213 | if (!info) | 209 | if (!info) |
214 | return NULL; | 210 | return -ENOMEM; |
215 | memset(info, 0, sizeof (*info)); | 211 | memset(info, 0, sizeof (*info)); |
216 | link = &info->link; | 212 | link = &info->link; |
217 | link->priv = info; | 213 | link->priv = info; |
@@ -227,20 +223,12 @@ static dev_link_t *serial_attach(void) | |||
227 | } | 223 | } |
228 | link->conf.IntType = INT_MEMORY_AND_IO; | 224 | link->conf.IntType = INT_MEMORY_AND_IO; |
229 | 225 | ||
230 | /* Register with Card Services */ | 226 | link->handle = p_dev; |
231 | link->next = dev_list; | 227 | p_dev->instance = link; |
232 | dev_list = link; | 228 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
233 | client_reg.dev_info = &dev_info; | 229 | serial_config(link); |
234 | client_reg.Version = 0x0210; | ||
235 | client_reg.event_callback_args.client_data = link; | ||
236 | ret = pcmcia_register_client(&link->handle, &client_reg); | ||
237 | if (ret != CS_SUCCESS) { | ||
238 | cs_error(link->handle, RegisterClient, ret); | ||
239 | serial_detach(link); | ||
240 | return NULL; | ||
241 | } | ||
242 | 230 | ||
243 | return link; | 231 | return 0; |
244 | } | 232 | } |
245 | 233 | ||
246 | /*====================================================================== | 234 | /*====================================================================== |
@@ -252,21 +240,13 @@ static dev_link_t *serial_attach(void) | |||
252 | 240 | ||
253 | ======================================================================*/ | 241 | ======================================================================*/ |
254 | 242 | ||
255 | static void serial_detach(dev_link_t * link) | 243 | static void serial_detach(struct pcmcia_device *p_dev) |
256 | { | 244 | { |
245 | dev_link_t *link = dev_to_instance(p_dev); | ||
257 | struct serial_info *info = link->priv; | 246 | struct serial_info *info = link->priv; |
258 | dev_link_t **linkp; | ||
259 | int ret; | ||
260 | 247 | ||
261 | DEBUG(0, "serial_detach(0x%p)\n", link); | 248 | DEBUG(0, "serial_detach(0x%p)\n", link); |
262 | 249 | ||
263 | /* Locate device structure */ | ||
264 | for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) | ||
265 | if (*linkp == link) | ||
266 | break; | ||
267 | if (*linkp == NULL) | ||
268 | return; | ||
269 | |||
270 | /* | 250 | /* |
271 | * Ensure any outstanding scheduled tasks are completed. | 251 | * Ensure any outstanding scheduled tasks are completed. |
272 | */ | 252 | */ |
@@ -277,14 +257,7 @@ static void serial_detach(dev_link_t * link) | |||
277 | */ | 257 | */ |
278 | serial_remove(link); | 258 | serial_remove(link); |
279 | 259 | ||
280 | if (link->handle) { | 260 | /* free bits */ |
281 | ret = pcmcia_deregister_client(link->handle); | ||
282 | if (ret != CS_SUCCESS) | ||
283 | cs_error(link->handle, DeregisterClient, ret); | ||
284 | } | ||
285 | |||
286 | /* Unlink device structure, free bits */ | ||
287 | *linkp = link->next; | ||
288 | kfree(info); | 261 | kfree(info); |
289 | } | 262 | } |
290 | 263 | ||
@@ -718,54 +691,6 @@ void serial_config(dev_link_t * link) | |||
718 | kfree(cfg_mem); | 691 | kfree(cfg_mem); |
719 | } | 692 | } |
720 | 693 | ||
721 | /*====================================================================== | ||
722 | |||
723 | The card status event handler. Mostly, this schedules other | ||
724 | stuff to run after an event is received. A CARD_REMOVAL event | ||
725 | also sets some flags to discourage the serial drivers from | ||
726 | talking to the ports. | ||
727 | |||
728 | ======================================================================*/ | ||
729 | |||
730 | static int | ||
731 | serial_event(event_t event, int priority, event_callback_args_t * args) | ||
732 | { | ||
733 | dev_link_t *link = args->client_data; | ||
734 | struct serial_info *info = link->priv; | ||
735 | |||
736 | DEBUG(1, "serial_event(0x%06x)\n", event); | ||
737 | |||
738 | switch (event) { | ||
739 | case CS_EVENT_CARD_REMOVAL: | ||
740 | serial_remove(link); | ||
741 | break; | ||
742 | |||
743 | case CS_EVENT_CARD_INSERTION: | ||
744 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
745 | serial_config(link); | ||
746 | break; | ||
747 | |||
748 | case CS_EVENT_PM_SUSPEND: | ||
749 | serial_suspend(link); | ||
750 | break; | ||
751 | |||
752 | case CS_EVENT_RESET_PHYSICAL: | ||
753 | if ((link->state & DEV_CONFIG) && !info->slave) | ||
754 | pcmcia_release_configuration(link->handle); | ||
755 | break; | ||
756 | |||
757 | case CS_EVENT_PM_RESUME: | ||
758 | serial_resume(link); | ||
759 | break; | ||
760 | |||
761 | case CS_EVENT_CARD_RESET: | ||
762 | if (DEV_OK(link) && !info->slave) | ||
763 | pcmcia_request_configuration(link->handle, &link->conf); | ||
764 | break; | ||
765 | } | ||
766 | return 0; | ||
767 | } | ||
768 | |||
769 | static struct pcmcia_device_id serial_ids[] = { | 694 | static struct pcmcia_device_id serial_ids[] = { |
770 | PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), | 695 | PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), |
771 | PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), | 696 | PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), |
@@ -877,10 +802,11 @@ static struct pcmcia_driver serial_cs_driver = { | |||
877 | .drv = { | 802 | .drv = { |
878 | .name = "serial_cs", | 803 | .name = "serial_cs", |
879 | }, | 804 | }, |
880 | .attach = serial_attach, | 805 | .probe = serial_probe, |
881 | .event = serial_event, | 806 | .remove = serial_detach, |
882 | .detach = serial_detach, | ||
883 | .id_table = serial_ids, | 807 | .id_table = serial_ids, |
808 | .suspend = serial_suspend, | ||
809 | .resume = serial_resume, | ||
884 | }; | 810 | }; |
885 | 811 | ||
886 | static int __init init_serial_cs(void) | 812 | static int __init init_serial_cs(void) |
@@ -891,7 +817,6 @@ static int __init init_serial_cs(void) | |||
891 | static void __exit exit_serial_cs(void) | 817 | static void __exit exit_serial_cs(void) |
892 | { | 818 | { |
893 | pcmcia_unregister_driver(&serial_cs_driver); | 819 | pcmcia_unregister_driver(&serial_cs_driver); |
894 | BUG_ON(dev_list != NULL); | ||
895 | } | 820 | } |
896 | 821 | ||
897 | module_init(init_serial_cs); | 822 | module_init(init_serial_cs); |