Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/usb-musb.c |
| 3 | * |
| 4 | * This file will contain the board specific details for the |
| 5 | * MENTOR USB OTG controller on OMAP3430 |
| 6 | * |
| 7 | * Copyright (C) 2007-2008 Texas Instruments |
| 8 | * Copyright (C) 2008 Nokia Corporation |
| 9 | * Author: Vikram Pandita |
| 10 | * |
| 11 | * Generalization by: |
| 12 | * Felipe Balbi <felipe.balbi@nokia.com> |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License version 2 as |
| 16 | * published by the Free Software Foundation. |
| 17 | */ |
| 18 | |
| 19 | #include <linux/types.h> |
| 20 | #include <linux/errno.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/clk.h> |
| 24 | #include <linux/dma-mapping.h> |
| 25 | #include <linux/io.h> |
| 26 | |
| 27 | #include <linux/usb/musb.h> |
| 28 | |
| 29 | #include <mach/hardware.h> |
| 30 | #include <mach/irqs.h> |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 31 | #include <plat/usb.h> |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 32 | |
Peter 'p2' De Schrijver | 94a3ef6 | 2009-01-19 19:09:22 +0200 | [diff] [blame] | 33 | #ifdef CONFIG_USB_MUSB_SOC |
| 34 | |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 35 | static struct resource musb_resources[] = { |
| 36 | [0] = { /* start and end set dynamically */ |
| 37 | .flags = IORESOURCE_MEM, |
| 38 | }, |
| 39 | [1] = { /* general IRQ */ |
| 40 | .start = INT_243X_HS_USB_MC, |
| 41 | .flags = IORESOURCE_IRQ, |
| 42 | }, |
| 43 | [2] = { /* DMA IRQ */ |
| 44 | .start = INT_243X_HS_USB_DMA, |
| 45 | .flags = IORESOURCE_IRQ, |
| 46 | }, |
| 47 | }; |
| 48 | |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 49 | static struct musb_hdrc_config musb_config = { |
| 50 | .multipoint = 1, |
| 51 | .dyn_fifo = 1, |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 52 | .num_eps = 16, |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 53 | .ram_bits = 12, |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | static struct musb_hdrc_platform_data musb_plat = { |
| 57 | #ifdef CONFIG_USB_MUSB_OTG |
| 58 | .mode = MUSB_OTG, |
| 59 | #elif defined(CONFIG_USB_MUSB_HDRC_HCD) |
| 60 | .mode = MUSB_HOST, |
| 61 | #elif defined(CONFIG_USB_GADGET_MUSB_HDRC) |
| 62 | .mode = MUSB_PERIPHERAL, |
| 63 | #endif |
| 64 | /* .clock is set dynamically */ |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 65 | .config = &musb_config, |
| 66 | |
| 67 | /* REVISIT charge pump on TWL4030 can supply up to |
| 68 | * 100 mA ... but this value is board-specific, like |
| 69 | * "mode", and should be passed to usb_musb_init(). |
| 70 | */ |
| 71 | .power = 50, /* up to 100 mA */ |
| 72 | }; |
| 73 | |
Yang Hongyang | e930438 | 2009-04-13 14:40:14 -0700 | [diff] [blame] | 74 | static u64 musb_dmamask = DMA_BIT_MASK(32); |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 75 | |
| 76 | static struct platform_device musb_device = { |
| 77 | .name = "musb_hdrc", |
| 78 | .id = -1, |
| 79 | .dev = { |
| 80 | .dma_mask = &musb_dmamask, |
Yang Hongyang | e930438 | 2009-04-13 14:40:14 -0700 | [diff] [blame] | 81 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 82 | .platform_data = &musb_plat, |
| 83 | }, |
| 84 | .num_resources = ARRAY_SIZE(musb_resources), |
| 85 | .resource = musb_resources, |
| 86 | }; |
| 87 | |
Maulik Mankad | 884b836 | 2010-02-17 14:09:30 -0800 | [diff] [blame] | 88 | void __init usb_musb_init(struct omap_musb_board_data *board_data) |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 89 | { |
Maulik Mankad | bce0668 | 2010-02-17 14:09:32 -0800 | [diff] [blame] | 90 | if (cpu_is_omap243x()) { |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 91 | musb_resources[0].start = OMAP243X_HS_BASE; |
Maulik Mankad | bce0668 | 2010-02-17 14:09:32 -0800 | [diff] [blame] | 92 | } else if (cpu_is_omap34xx()) { |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 93 | musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE; |
Maulik Mankad | bce0668 | 2010-02-17 14:09:32 -0800 | [diff] [blame] | 94 | } else if (cpu_is_omap44xx()) { |
| 95 | musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE; |
Santosh Shilimkar | 5772ca7 | 2010-02-18 03:14:12 +0530 | [diff] [blame] | 96 | musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N; |
| 97 | musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N; |
Maulik Mankad | bce0668 | 2010-02-17 14:09:32 -0800 | [diff] [blame] | 98 | } |
Felipe Balbi | f982855 | 2010-02-17 14:09:29 -0800 | [diff] [blame] | 99 | musb_resources[0].end = musb_resources[0].start + SZ_4K - 1; |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 100 | |
| 101 | /* |
| 102 | * REVISIT: This line can be removed once all the platforms using |
| 103 | * musb_core.c have been converted to use use clkdev. |
| 104 | */ |
| 105 | musb_plat.clock = "ick"; |
Maulik Mankad | 884b836 | 2010-02-17 14:09:30 -0800 | [diff] [blame] | 106 | musb_plat.board_data = board_data; |
| 107 | musb_plat.power = board_data->power >> 1; |
| 108 | musb_plat.mode = board_data->mode; |
Ajay Kumar Gupta | 58815fa | 2010-03-25 13:25:27 +0200 | [diff] [blame] | 109 | musb_plat.extvbus = board_data->extvbus; |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 110 | |
Felipe Balbi | bdfa351 | 2010-02-17 14:09:31 -0800 | [diff] [blame] | 111 | if (platform_device_register(&musb_device) < 0) |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 112 | printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n"); |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 113 | } |
Peter 'p2' De Schrijver | 94a3ef6 | 2009-01-19 19:09:22 +0200 | [diff] [blame] | 114 | |
| 115 | #else |
Maulik Mankad | 884b836 | 2010-02-17 14:09:30 -0800 | [diff] [blame] | 116 | void __init usb_musb_init(struct omap_musb_board_data *board_data) |
Peter 'p2' De Schrijver | 94a3ef6 | 2009-01-19 19:09:22 +0200 | [diff] [blame] | 117 | { |
Peter 'p2' De Schrijver | 94a3ef6 | 2009-01-19 19:09:22 +0200 | [diff] [blame] | 118 | } |
| 119 | #endif /* CONFIG_USB_MUSB_SOC */ |