aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2012-07-05 04:27:14 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-07-06 14:42:55 -0400
commitd483b983a5efaa101714186a8485a5fd4de42fba (patch)
tree61d0a8c9c6d7a789b342bf9d348e09f9ff66e5b3 /arch/arm/mach-shmobile
parent93bcfdc56522a88b440cf6c4fee09e9ecf6605da (diff)
ARM: shmobile: armadillo800eva: USB Func enables external IRQ mode
We can control renesas_usbhs driver as 2 way which are autonomy mode and external IRQ trigger mode. Autonomy mode is very easy settings for platform, but it required USB power domain always ON, since its connection/disconnection IRQ come from it. If platform uses external IRQ trigger mode, USB power domain can be OFF, since its connection/disconnection IRQ come from external IRQ. This patch enable external IRQ mode. Now it is possible to add USB support on A4SP domain. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Acked-by: Magnus Damm <damm@opensource.se> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'arch/arm/mach-shmobile')
-rw-r--r--arch/arm/mach-shmobile/board-armadillo800eva.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index 12f9666302fc..79891a6d0dec 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -133,14 +133,8 @@
133 * These are a little bit complex. 133 * These are a little bit complex.
134 * see 134 * see
135 * usbhsf_power_ctrl() 135 * usbhsf_power_ctrl()
136 *
137 * CAUTION
138 *
139 * It uses autonomy mode for USB hotplug at this point
140 * (= usbhs_private.platform_callback.get_vbus is NULL),
141 * since we don't know what's happen on PM control
142 * on this workaround.
143 */ 136 */
137#define IRQ7 evt2irq(0x02e0)
144#define USBCR1 0xe605810a 138#define USBCR1 0xe605810a
145#define USBH 0xC6700000 139#define USBH 0xC6700000
146#define USBH_USBCTR 0x10834 140#define USBH_USBCTR 0x10834
@@ -220,6 +214,20 @@ static void usbhsf_power_ctrl(struct platform_device *pdev,
220 } 214 }
221} 215}
222 216
217static int usbhsf_get_vbus(struct platform_device *pdev)
218{
219 return gpio_get_value(GPIO_PORT209);
220}
221
222static irqreturn_t usbhsf_interrupt(int irq, void *data)
223{
224 struct platform_device *pdev = data;
225
226 renesas_usbhs_call_notify_hotplug(pdev);
227
228 return IRQ_HANDLED;
229}
230
223static void usbhsf_hardware_exit(struct platform_device *pdev) 231static void usbhsf_hardware_exit(struct platform_device *pdev)
224{ 232{
225 struct usbhsf_private *priv = usbhsf_get_priv(pdev); 233 struct usbhsf_private *priv = usbhsf_get_priv(pdev);
@@ -243,11 +251,14 @@ static void usbhsf_hardware_exit(struct platform_device *pdev)
243 priv->host = NULL; 251 priv->host = NULL;
244 priv->func = NULL; 252 priv->func = NULL;
245 priv->usbh_base = NULL; 253 priv->usbh_base = NULL;
254
255 free_irq(IRQ7, pdev);
246} 256}
247 257
248static int usbhsf_hardware_init(struct platform_device *pdev) 258static int usbhsf_hardware_init(struct platform_device *pdev)
249{ 259{
250 struct usbhsf_private *priv = usbhsf_get_priv(pdev); 260 struct usbhsf_private *priv = usbhsf_get_priv(pdev);
261 int ret;
251 262
252 priv->phy = clk_get(&pdev->dev, "phy"); 263 priv->phy = clk_get(&pdev->dev, "phy");
253 priv->usb24 = clk_get(&pdev->dev, "usb24"); 264 priv->usb24 = clk_get(&pdev->dev, "usb24");
@@ -267,6 +278,14 @@ static int usbhsf_hardware_init(struct platform_device *pdev)
267 return -EIO; 278 return -EIO;
268 } 279 }
269 280
281 ret = request_irq(IRQ7, usbhsf_interrupt, IRQF_TRIGGER_NONE,
282 dev_name(&pdev->dev), pdev);
283 if (ret) {
284 dev_err(&pdev->dev, "request_irq err\n");
285 return ret;
286 }
287 irq_set_irq_type(IRQ7, IRQ_TYPE_EDGE_BOTH);
288
270 /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */ 289 /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */
271 clk_set_rate(priv->usb24, 290 clk_set_rate(priv->usb24,
272 clk_get_rate(clk_get_parent(priv->usb24))); 291 clk_get_rate(clk_get_parent(priv->usb24)));
@@ -278,6 +297,7 @@ static struct usbhsf_private usbhsf_private = {
278 .info = { 297 .info = {
279 .platform_callback = { 298 .platform_callback = {
280 .get_id = usbhsf_get_id, 299 .get_id = usbhsf_get_id,
300 .get_vbus = usbhsf_get_vbus,
281 .hardware_init = usbhsf_hardware_init, 301 .hardware_init = usbhsf_hardware_init,
282 .hardware_exit = usbhsf_hardware_exit, 302 .hardware_exit = usbhsf_hardware_exit,
283 .power_ctrl = usbhsf_power_ctrl, 303 .power_ctrl = usbhsf_power_ctrl,
@@ -1018,7 +1038,17 @@ static void __init eva_init(void)
1018 /* USB Host */ 1038 /* USB Host */
1019 } else { 1039 } else {
1020 /* USB Func */ 1040 /* USB Func */
1021 gpio_request(GPIO_FN_VBUS, NULL); 1041 /*
1042 * A1 chip has 2 IRQ7 pin and it was controled by MSEL register.
1043 * OTOH, usbhs interrupt needs its value (HI/LOW) to decide
1044 * USB connection/disconnection (usbhsf_get_vbus()).
1045 * This means we needs to select GPIO_FN_IRQ7_PORT209 first,
1046 * and select GPIO_PORT209 here
1047 */
1048 gpio_request(GPIO_FN_IRQ7_PORT209, NULL);
1049 gpio_request(GPIO_PORT209, NULL);
1050 gpio_direction_input(GPIO_PORT209);
1051
1022 platform_device_register(&usbhsf_device); 1052 platform_device_register(&usbhsf_device);
1023 } 1053 }
1024 1054