diff options
| author | Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> | 2009-05-26 05:24:34 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-16 00:44:46 -0400 |
| commit | 5effabbe9e6e0089f7afdde35cb51e8c8b4cf6bc (patch) | |
| tree | d70e441a981a850a2df1bef79a75b8bad27bccf7 | |
| parent | 32ebbe7b6ad44ae9c276419710b56de6ba705303 (diff) | |
USB: r8a66597-hcd: use platform_data instead of module_param
CPU/board specific parameters (PLL clock, vif etc...) can be set
by platform_data instead of module_param.
v2: remove irq_sense member in platform_data because it can OR in
IRQF_TRIGGER_LOW or IRQF_TRIGGER_FALLING against IORESOURCE_IRQ in
the struct resource.
Signed-off-by: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
Reviewed-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | drivers/usb/host/r8a66597-hcd.c | 60 | ||||
| -rw-r--r-- | drivers/usb/host/r8a66597.h | 38 | ||||
| -rw-r--r-- | include/linux/usb/r8a66597.h | 44 |
3 files changed, 92 insertions, 50 deletions
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 3e1216ad86bd..56976cc0352a 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
| @@ -46,31 +46,10 @@ MODULE_LICENSE("GPL"); | |||
| 46 | MODULE_AUTHOR("Yoshihiro Shimoda"); | 46 | MODULE_AUTHOR("Yoshihiro Shimoda"); |
| 47 | MODULE_ALIAS("platform:r8a66597_hcd"); | 47 | MODULE_ALIAS("platform:r8a66597_hcd"); |
| 48 | 48 | ||
| 49 | #define DRIVER_VERSION "10 Apr 2008" | 49 | #define DRIVER_VERSION "2009-05-26" |
| 50 | 50 | ||
| 51 | static const char hcd_name[] = "r8a66597_hcd"; | 51 | static const char hcd_name[] = "r8a66597_hcd"; |
| 52 | 52 | ||
| 53 | /* module parameters */ | ||
| 54 | #if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
| 55 | static unsigned short clock = XTAL12; | ||
| 56 | module_param(clock, ushort, 0644); | ||
| 57 | MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " | ||
| 58 | "(default=0)"); | ||
| 59 | #endif | ||
| 60 | |||
| 61 | static unsigned short vif = LDRV; | ||
| 62 | module_param(vif, ushort, 0644); | ||
| 63 | MODULE_PARM_DESC(vif, "input VIF: 3.3V=32768, 1.5V=0(default=32768)"); | ||
| 64 | |||
| 65 | static unsigned short endian; | ||
| 66 | module_param(endian, ushort, 0644); | ||
| 67 | MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)"); | ||
| 68 | |||
| 69 | static unsigned short irq_sense = 0xff; | ||
| 70 | module_param(irq_sense, ushort, 0644); | ||
| 71 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 " | ||
| 72 | "(default=32)"); | ||
| 73 | |||
| 74 | static void packet_write(struct r8a66597 *r8a66597, u16 pipenum); | 53 | static void packet_write(struct r8a66597 *r8a66597, u16 pipenum); |
| 75 | static int r8a66597_get_frame(struct usb_hcd *hcd); | 54 | static int r8a66597_get_frame(struct usb_hcd *hcd); |
| 76 | 55 | ||
| @@ -136,7 +115,8 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
| 136 | } | 115 | } |
| 137 | } while ((tmp & USBE) != USBE); | 116 | } while ((tmp & USBE) != USBE); |
| 138 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | 117 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); |
| 139 | r8a66597_mdfy(r8a66597, clock, XTAL, SYSCFG0); | 118 | r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata), XTAL, |
| 119 | SYSCFG0); | ||
| 140 | 120 | ||
| 141 | i = 0; | 121 | i = 0; |
| 142 | r8a66597_bset(r8a66597, XCKE, SYSCFG0); | 122 | r8a66597_bset(r8a66597, XCKE, SYSCFG0); |
| @@ -203,6 +183,9 @@ static void r8a66597_disable_port(struct r8a66597 *r8a66597, int port) | |||
| 203 | static int enable_controller(struct r8a66597 *r8a66597) | 183 | static int enable_controller(struct r8a66597 *r8a66597) |
| 204 | { | 184 | { |
| 205 | int ret, port; | 185 | int ret, port; |
| 186 | u16 vif = r8a66597->pdata->vif ? LDRV : 0; | ||
| 187 | u16 irq_sense = r8a66597->irq_sense_low ? INTL : 0; | ||
| 188 | u16 endian = r8a66597->pdata->endian ? BIGEND : 0; | ||
| 206 | 189 | ||
| 207 | ret = r8a66597_clock_enable(r8a66597); | 190 | ret = r8a66597_clock_enable(r8a66597); |
| 208 | if (ret < 0) | 191 | if (ret < 0) |
| @@ -2418,6 +2401,12 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
| 2418 | goto clean_up; | 2401 | goto clean_up; |
| 2419 | } | 2402 | } |
| 2420 | 2403 | ||
| 2404 | if (pdev->dev.platform_data == NULL) { | ||
| 2405 | dev_err(&pdev->dev, "no platform data\n"); | ||
| 2406 | ret = -ENODEV; | ||
| 2407 | goto clean_up; | ||
| 2408 | } | ||
| 2409 | |||
| 2421 | /* initialize hcd */ | 2410 | /* initialize hcd */ |
| 2422 | hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); | 2411 | hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); |
| 2423 | if (!hcd) { | 2412 | if (!hcd) { |
| @@ -2428,6 +2417,8 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
| 2428 | r8a66597 = hcd_to_r8a66597(hcd); | 2417 | r8a66597 = hcd_to_r8a66597(hcd); |
| 2429 | memset(r8a66597, 0, sizeof(struct r8a66597)); | 2418 | memset(r8a66597, 0, sizeof(struct r8a66597)); |
| 2430 | dev_set_drvdata(&pdev->dev, r8a66597); | 2419 | dev_set_drvdata(&pdev->dev, r8a66597); |
| 2420 | r8a66597->pdata = pdev->dev.platform_data; | ||
| 2421 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; | ||
| 2431 | 2422 | ||
| 2432 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2423 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) |
| 2433 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); | 2424 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); |
| @@ -2458,29 +2449,6 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
| 2458 | 2449 | ||
| 2459 | hcd->rsrc_start = res->start; | 2450 | hcd->rsrc_start = res->start; |
| 2460 | 2451 | ||
| 2461 | /* irq_sense setting on cmdline takes precedence over resource | ||
| 2462 | * settings, so the introduction of irqflags in IRQ resourse | ||
| 2463 | * won't disturb existing setups */ | ||
| 2464 | switch (irq_sense) { | ||
| 2465 | case INTL: | ||
| 2466 | irq_trigger = IRQF_TRIGGER_LOW; | ||
| 2467 | break; | ||
| 2468 | case 0: | ||
| 2469 | irq_trigger = IRQF_TRIGGER_FALLING; | ||
| 2470 | break; | ||
| 2471 | case 0xff: | ||
| 2472 | if (irq_trigger) | ||
| 2473 | irq_sense = (irq_trigger & IRQF_TRIGGER_LOW) ? | ||
| 2474 | INTL : 0; | ||
| 2475 | else { | ||
| 2476 | irq_sense = INTL; | ||
| 2477 | irq_trigger = IRQF_TRIGGER_LOW; | ||
| 2478 | } | ||
| 2479 | break; | ||
| 2480 | default: | ||
| 2481 | dev_err(&pdev->dev, "Unknown irq_sense value.\n"); | ||
| 2482 | } | ||
| 2483 | |||
| 2484 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); | 2452 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); |
| 2485 | if (ret != 0) { | 2453 | if (ret != 0) { |
| 2486 | dev_err(&pdev->dev, "Failed to add hcd\n"); | 2454 | dev_err(&pdev->dev, "Failed to add hcd\n"); |
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index f49208f1bb74..d72680b433f9 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
| @@ -30,6 +30,8 @@ | |||
| 30 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
| 31 | #endif | 31 | #endif |
| 32 | 32 | ||
| 33 | #include <linux/usb/r8a66597.h> | ||
| 34 | |||
| 33 | #define SYSCFG0 0x00 | 35 | #define SYSCFG0 0x00 |
| 34 | #define SYSCFG1 0x02 | 36 | #define SYSCFG1 0x02 |
| 35 | #define SYSSTS0 0x04 | 37 | #define SYSSTS0 0x04 |
| @@ -488,6 +490,7 @@ struct r8a66597 { | |||
| 488 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 490 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) |
| 489 | struct clk *clk; | 491 | struct clk *clk; |
| 490 | #endif | 492 | #endif |
| 493 | struct r8a66597_platdata *pdata; | ||
| 491 | struct r8a66597_device device0; | 494 | struct r8a66597_device device0; |
| 492 | struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB]; | 495 | struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB]; |
| 493 | struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE]; | 496 | struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE]; |
| @@ -506,6 +509,7 @@ struct r8a66597 { | |||
| 506 | unsigned long child_connect_map[4]; | 509 | unsigned long child_connect_map[4]; |
| 507 | 510 | ||
| 508 | unsigned bus_suspended:1; | 511 | unsigned bus_suspended:1; |
| 512 | unsigned irq_sense_low:1; | ||
| 509 | }; | 513 | }; |
| 510 | 514 | ||
| 511 | static inline struct r8a66597 *hcd_to_r8a66597(struct usb_hcd *hcd) | 515 | static inline struct r8a66597 *hcd_to_r8a66597(struct usb_hcd *hcd) |
| @@ -660,10 +664,36 @@ static inline void r8a66597_port_power(struct r8a66597 *r8a66597, int port, | |||
| 660 | { | 664 | { |
| 661 | unsigned long dvstctr_reg = get_dvstctr_reg(port); | 665 | unsigned long dvstctr_reg = get_dvstctr_reg(port); |
| 662 | 666 | ||
| 663 | if (power) | 667 | if (r8a66597->pdata->port_power) { |
| 664 | r8a66597_bset(r8a66597, VBOUT, dvstctr_reg); | 668 | r8a66597->pdata->port_power(port, power); |
| 665 | else | 669 | } else { |
| 666 | r8a66597_bclr(r8a66597, VBOUT, dvstctr_reg); | 670 | if (power) |
| 671 | r8a66597_bset(r8a66597, VBOUT, dvstctr_reg); | ||
| 672 | else | ||
| 673 | r8a66597_bclr(r8a66597, VBOUT, dvstctr_reg); | ||
| 674 | } | ||
| 675 | } | ||
| 676 | |||
| 677 | static inline u16 get_xtal_from_pdata(struct r8a66597_platdata *pdata) | ||
| 678 | { | ||
| 679 | u16 clock = 0; | ||
| 680 | |||
| 681 | switch (pdata->xtal) { | ||
| 682 | case R8A66597_PLATDATA_XTAL_12MHZ: | ||
| 683 | clock = XTAL12; | ||
| 684 | break; | ||
| 685 | case R8A66597_PLATDATA_XTAL_24MHZ: | ||
| 686 | clock = XTAL24; | ||
| 687 | break; | ||
| 688 | case R8A66597_PLATDATA_XTAL_48MHZ: | ||
| 689 | clock = XTAL48; | ||
| 690 | break; | ||
| 691 | default: | ||
| 692 | printk(KERN_ERR "r8a66597: platdata clock is wrong.\n"); | ||
| 693 | break; | ||
| 694 | } | ||
| 695 | |||
| 696 | return clock; | ||
| 667 | } | 697 | } |
| 668 | 698 | ||
| 669 | #define get_pipectr_addr(pipenum) (PIPE1CTR + (pipenum - 1) * 2) | 699 | #define get_pipectr_addr(pipenum) (PIPE1CTR + (pipenum - 1) * 2) |
diff --git a/include/linux/usb/r8a66597.h b/include/linux/usb/r8a66597.h new file mode 100644 index 000000000000..e9f0384fa20c --- /dev/null +++ b/include/linux/usb/r8a66597.h | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | /* | ||
| 2 | * R8A66597 driver platform data | ||
| 3 | * | ||
| 4 | * Copyright (C) 2009 Renesas Solutions Corp. | ||
| 5 | * | ||
| 6 | * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; version 2 of the License. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | * | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifndef __LINUX_USB_R8A66597_H | ||
| 24 | #define __LINUX_USB_R8A66597_H | ||
| 25 | |||
| 26 | #define R8A66597_PLATDATA_XTAL_12MHZ 0x01 | ||
| 27 | #define R8A66597_PLATDATA_XTAL_24MHZ 0x02 | ||
| 28 | #define R8A66597_PLATDATA_XTAL_48MHZ 0x03 | ||
| 29 | |||
| 30 | struct r8a66597_platdata { | ||
| 31 | /* This ops can controll port power instead of DVSTCTR register. */ | ||
| 32 | void (*port_power)(int port, int power); | ||
| 33 | |||
| 34 | /* (external controller only) set R8A66597_PLATDATA_XTAL_nnMHZ */ | ||
| 35 | unsigned xtal:2; | ||
| 36 | |||
| 37 | /* set one = 3.3V, set zero = 1.5V */ | ||
| 38 | unsigned vif:1; | ||
| 39 | |||
| 40 | /* set one = big endian, set zero = little endian */ | ||
| 41 | unsigned endian:1; | ||
| 42 | }; | ||
| 43 | #endif | ||
| 44 | |||
