Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Yoshihiro Shimoda and committed by
Greg Kroah-Hartman
5effabbe 32ebbe7b

+92 -50
+14 -46
drivers/usb/host/r8a66597-hcd.c
··· 46 46 MODULE_AUTHOR("Yoshihiro Shimoda"); 47 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 51 static const char hcd_name[] = "r8a66597_hcd"; 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 52 74 53 static void packet_write(struct r8a66597 *r8a66597, u16 pipenum); 75 54 static int r8a66597_get_frame(struct usb_hcd *hcd); ··· 115 136 } 116 137 } while ((tmp & USBE) != USBE); 117 138 r8a66597_bclr(r8a66597, USBE, SYSCFG0); 118 - r8a66597_mdfy(r8a66597, clock, XTAL, SYSCFG0); 139 + r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata), XTAL, 140 + SYSCFG0); 119 141 120 142 i = 0; 121 143 r8a66597_bset(r8a66597, XCKE, SYSCFG0); ··· 183 203 static int enable_controller(struct r8a66597 *r8a66597) 184 204 { 185 205 int ret, port; 206 + u16 vif = r8a66597->pdata->vif ? LDRV : 0; 207 + u16 irq_sense = r8a66597->irq_sense_low ? INTL : 0; 208 + u16 endian = r8a66597->pdata->endian ? BIGEND : 0; 186 209 187 210 ret = r8a66597_clock_enable(r8a66597); 188 211 if (ret < 0) ··· 2401 2418 goto clean_up; 2402 2419 } 2403 2420 2421 + if (pdev->dev.platform_data == NULL) { 2422 + dev_err(&pdev->dev, "no platform data\n"); 2423 + ret = -ENODEV; 2424 + goto clean_up; 2425 + } 2426 + 2404 2427 /* initialize hcd */ 2405 2428 hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); 2406 2429 if (!hcd) { ··· 2417 2428 r8a66597 = hcd_to_r8a66597(hcd); 2418 2429 memset(r8a66597, 0, sizeof(struct r8a66597)); 2419 2430 dev_set_drvdata(&pdev->dev, r8a66597); 2431 + r8a66597->pdata = pdev->dev.platform_data; 2432 + r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; 2420 2433 2421 2434 #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) 2422 2435 snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); ··· 2448 2457 INIT_LIST_HEAD(&r8a66597->child_device); 2449 2458 2450 2459 hcd->rsrc_start = res->start; 2451 - 2452 - /* irq_sense setting on cmdline takes precedence over resource 2453 - * settings, so the introduction of irqflags in IRQ resourse 2454 - * won't disturb existing setups */ 2455 - switch (irq_sense) { 2456 - case INTL: 2457 - irq_trigger = IRQF_TRIGGER_LOW; 2458 - break; 2459 - case 0: 2460 - irq_trigger = IRQF_TRIGGER_FALLING; 2461 - break; 2462 - case 0xff: 2463 - if (irq_trigger) 2464 - irq_sense = (irq_trigger & IRQF_TRIGGER_LOW) ? 2465 - INTL : 0; 2466 - else { 2467 - irq_sense = INTL; 2468 - irq_trigger = IRQF_TRIGGER_LOW; 2469 - } 2470 - break; 2471 - default: 2472 - dev_err(&pdev->dev, "Unknown irq_sense value.\n"); 2473 - } 2474 2460 2475 2461 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); 2476 2462 if (ret != 0) {
+34 -4
drivers/usb/host/r8a66597.h
··· 30 30 #include <linux/clk.h> 31 31 #endif 32 32 33 + #include <linux/usb/r8a66597.h> 34 + 33 35 #define SYSCFG0 0x00 34 36 #define SYSCFG1 0x02 35 37 #define SYSSTS0 0x04 ··· 490 488 #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) 491 489 struct clk *clk; 492 490 #endif 491 + struct r8a66597_platdata *pdata; 493 492 struct r8a66597_device device0; 494 493 struct r8a66597_root_hub root_hub[R8A66597_MAX_ROOT_HUB]; 495 494 struct list_head pipe_queue[R8A66597_MAX_NUM_PIPE]; ··· 509 506 unsigned long child_connect_map[4]; 510 507 511 508 unsigned bus_suspended:1; 509 + unsigned irq_sense_low:1; 512 510 }; 513 511 514 512 static inline struct r8a66597 *hcd_to_r8a66597(struct usb_hcd *hcd) ··· 664 660 { 665 661 unsigned long dvstctr_reg = get_dvstctr_reg(port); 666 662 667 - if (power) 668 - r8a66597_bset(r8a66597, VBOUT, dvstctr_reg); 669 - else 670 - r8a66597_bclr(r8a66597, VBOUT, dvstctr_reg); 663 + if (r8a66597->pdata->port_power) { 664 + r8a66597->pdata->port_power(port, power); 665 + } else { 666 + if (power) 667 + r8a66597_bset(r8a66597, VBOUT, dvstctr_reg); 668 + else 669 + r8a66597_bclr(r8a66597, VBOUT, dvstctr_reg); 670 + } 671 + } 672 + 673 + static inline u16 get_xtal_from_pdata(struct r8a66597_platdata *pdata) 674 + { 675 + u16 clock = 0; 676 + 677 + switch (pdata->xtal) { 678 + case R8A66597_PLATDATA_XTAL_12MHZ: 679 + clock = XTAL12; 680 + break; 681 + case R8A66597_PLATDATA_XTAL_24MHZ: 682 + clock = XTAL24; 683 + break; 684 + case R8A66597_PLATDATA_XTAL_48MHZ: 685 + clock = XTAL48; 686 + break; 687 + default: 688 + printk(KERN_ERR "r8a66597: platdata clock is wrong.\n"); 689 + break; 690 + } 691 + 692 + return clock; 671 693 } 672 694 673 695 #define get_pipectr_addr(pipenum) (PIPE1CTR + (pipenum - 1) * 2)
+44
include/linux/usb/r8a66597.h
··· 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 +