diff options
Diffstat (limited to 'arch/arm/mach-cns3xxx/cns3420vb.c')
-rw-r--r-- | arch/arm/mach-cns3xxx/cns3420vb.c | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/arch/arm/mach-cns3xxx/cns3420vb.c b/arch/arm/mach-cns3xxx/cns3420vb.c index 2c5fb4c7e509..ae305397003c 100644 --- a/arch/arm/mach-cns3xxx/cns3420vb.c +++ b/arch/arm/mach-cns3xxx/cns3420vb.c | |||
@@ -24,6 +24,8 @@ | |||
24 | #include <linux/mtd/mtd.h> | 24 | #include <linux/mtd/mtd.h> |
25 | #include <linux/mtd/physmap.h> | 25 | #include <linux/mtd/physmap.h> |
26 | #include <linux/mtd/partitions.h> | 26 | #include <linux/mtd/partitions.h> |
27 | #include <linux/usb/ehci_pdriver.h> | ||
28 | #include <linux/usb/ohci_pdriver.h> | ||
27 | #include <asm/setup.h> | 29 | #include <asm/setup.h> |
28 | #include <asm/mach-types.h> | 30 | #include <asm/mach-types.h> |
29 | #include <asm/hardware/gic.h> | 31 | #include <asm/hardware/gic.h> |
@@ -32,6 +34,7 @@ | |||
32 | #include <asm/mach/time.h> | 34 | #include <asm/mach/time.h> |
33 | #include <mach/cns3xxx.h> | 35 | #include <mach/cns3xxx.h> |
34 | #include <mach/irqs.h> | 36 | #include <mach/irqs.h> |
37 | #include <mach/pm.h> | ||
35 | #include "core.h" | 38 | #include "core.h" |
36 | #include "devices.h" | 39 | #include "devices.h" |
37 | 40 | ||
@@ -125,13 +128,52 @@ static struct resource cns3xxx_usb_ehci_resources[] = { | |||
125 | 128 | ||
126 | static u64 cns3xxx_usb_ehci_dma_mask = DMA_BIT_MASK(32); | 129 | static u64 cns3xxx_usb_ehci_dma_mask = DMA_BIT_MASK(32); |
127 | 130 | ||
131 | static int csn3xxx_usb_power_on(struct platform_device *pdev) | ||
132 | { | ||
133 | /* | ||
134 | * EHCI and OHCI share the same clock and power, | ||
135 | * resetting twice would cause the 1st controller been reset. | ||
136 | * Therefore only do power up at the first up device, and | ||
137 | * power down at the last down device. | ||
138 | * | ||
139 | * Set USB AHB INCR length to 16 | ||
140 | */ | ||
141 | if (atomic_inc_return(&usb_pwr_ref) == 1) { | ||
142 | cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB); | ||
143 | cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST); | ||
144 | cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST); | ||
145 | __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)), | ||
146 | MISC_CHIP_CONFIG_REG); | ||
147 | } | ||
148 | |||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | static void csn3xxx_usb_power_off(struct platform_device *pdev) | ||
153 | { | ||
154 | /* | ||
155 | * EHCI and OHCI share the same clock and power, | ||
156 | * resetting twice would cause the 1st controller been reset. | ||
157 | * Therefore only do power up at the first up device, and | ||
158 | * power down at the last down device. | ||
159 | */ | ||
160 | if (atomic_dec_return(&usb_pwr_ref) == 0) | ||
161 | cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST); | ||
162 | } | ||
163 | |||
164 | static struct usb_ehci_pdata cns3xxx_usb_ehci_pdata = { | ||
165 | .power_on = csn3xxx_usb_power_on, | ||
166 | .power_off = csn3xxx_usb_power_off, | ||
167 | }; | ||
168 | |||
128 | static struct platform_device cns3xxx_usb_ehci_device = { | 169 | static struct platform_device cns3xxx_usb_ehci_device = { |
129 | .name = "cns3xxx-ehci", | 170 | .name = "ehci-platform", |
130 | .num_resources = ARRAY_SIZE(cns3xxx_usb_ehci_resources), | 171 | .num_resources = ARRAY_SIZE(cns3xxx_usb_ehci_resources), |
131 | .resource = cns3xxx_usb_ehci_resources, | 172 | .resource = cns3xxx_usb_ehci_resources, |
132 | .dev = { | 173 | .dev = { |
133 | .dma_mask = &cns3xxx_usb_ehci_dma_mask, | 174 | .dma_mask = &cns3xxx_usb_ehci_dma_mask, |
134 | .coherent_dma_mask = DMA_BIT_MASK(32), | 175 | .coherent_dma_mask = DMA_BIT_MASK(32), |
176 | .platform_data = &cns3xxx_usb_ehci_pdata, | ||
135 | }, | 177 | }, |
136 | }; | 178 | }; |
137 | 179 | ||
@@ -149,13 +191,20 @@ static struct resource cns3xxx_usb_ohci_resources[] = { | |||
149 | 191 | ||
150 | static u64 cns3xxx_usb_ohci_dma_mask = DMA_BIT_MASK(32); | 192 | static u64 cns3xxx_usb_ohci_dma_mask = DMA_BIT_MASK(32); |
151 | 193 | ||
194 | static struct usb_ohci_pdata cns3xxx_usb_ohci_pdata = { | ||
195 | .num_ports = 1, | ||
196 | .power_on = csn3xxx_usb_power_on, | ||
197 | .power_off = csn3xxx_usb_power_off, | ||
198 | }; | ||
199 | |||
152 | static struct platform_device cns3xxx_usb_ohci_device = { | 200 | static struct platform_device cns3xxx_usb_ohci_device = { |
153 | .name = "cns3xxx-ohci", | 201 | .name = "ohci-platform", |
154 | .num_resources = ARRAY_SIZE(cns3xxx_usb_ohci_resources), | 202 | .num_resources = ARRAY_SIZE(cns3xxx_usb_ohci_resources), |
155 | .resource = cns3xxx_usb_ohci_resources, | 203 | .resource = cns3xxx_usb_ohci_resources, |
156 | .dev = { | 204 | .dev = { |
157 | .dma_mask = &cns3xxx_usb_ohci_dma_mask, | 205 | .dma_mask = &cns3xxx_usb_ohci_dma_mask, |
158 | .coherent_dma_mask = DMA_BIT_MASK(32), | 206 | .coherent_dma_mask = DMA_BIT_MASK(32), |
207 | .platform_data = &cns3xxx_usb_ohci_pdata, | ||
159 | }, | 208 | }, |
160 | }; | 209 | }; |
161 | 210 | ||