aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Stigge <stigge@antcom.de>2012-04-29 10:47:02 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-01 13:30:00 -0400
commita6a99cf0713c5336ad564b055d4ed34537700df4 (patch)
treef13a028e6a88fb1f385378c07cd45f60f734dd5b
parent8815bb09af21316aeb5f8948b24ac62181670db2 (diff)
ohci-nxp: Driver cleanup
Cleanup for ohci-nxp.c: * Cleanup of resource handling (mem and irq), use devm_request_and_ioremap() * Use DMA_BIT_MASK() * Don't remove __devinit * Removed obsolete gpio.h include * More consistent bit access symbols * Removed unused extern declaration ocpi_enable() * Added error handling on i2c_get_adapter() * Whitespace cleanup Signed-off-by: Roland Stigge <stigge@antcom.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/host/ohci-nxp.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
index d02abc349044..63261f7c2f79 100644
--- a/drivers/usb/host/ohci-nxp.c
+++ b/drivers/usb/host/ohci-nxp.c
@@ -29,7 +29,6 @@
29 29
30#include <mach/platform.h> 30#include <mach/platform.h>
31#include <mach/irqs.h> 31#include <mach/irqs.h>
32#include <asm/gpio.h>
33 32
34#define USB_CONFIG_BASE 0x31020000 33#define USB_CONFIG_BASE 0x31020000
35#define PWRMAN_BASE 0x40004000 34#define PWRMAN_BASE 0x40004000
@@ -38,7 +37,9 @@
38 37
39/* USB_CTRL bit defines */ 38/* USB_CTRL bit defines */
40#define USB_SLAVE_HCLK_EN (1 << 24) 39#define USB_SLAVE_HCLK_EN (1 << 24)
40#define USB_DEV_NEED_CLK_EN (1 << 22)
41#define USB_HOST_NEED_CLK_EN (1 << 21) 41#define USB_HOST_NEED_CLK_EN (1 << 21)
42#define PAD_CONTROL_LAST_DRIVEN (1 << 19)
42 43
43#define USB_OTG_CLK_CTRL IO_ADDRESS(USB_CONFIG_BASE + 0xFF4) 44#define USB_OTG_CLK_CTRL IO_ADDRESS(USB_CONFIG_BASE + 0xFF4)
44#define USB_OTG_CLK_STAT IO_ADDRESS(USB_CONFIG_BASE + 0xFF8) 45#define USB_OTG_CLK_STAT IO_ADDRESS(USB_CONFIG_BASE + 0xFF8)
@@ -117,7 +118,6 @@ static struct i2c_driver isp1301_driver;
117static struct i2c_client *isp1301_i2c_client; 118static struct i2c_client *isp1301_i2c_client;
118 119
119extern int usb_disabled(void); 120extern int usb_disabled(void);
120extern int ocpi_enable(void);
121 121
122static struct clk *usb_clk; 122static struct clk *usb_clk;
123 123
@@ -220,7 +220,7 @@ static void isp1301_configure_lpc32xx(void)
220 ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR, ~0); 220 ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR, ~0);
221 221
222 /* Enable usb_need_clk clock after transceiver is initialized */ 222 /* Enable usb_need_clk clock after transceiver is initialized */
223 __raw_writel((__raw_readl(USB_CTRL) | (1 << 22)), USB_CTRL); 223 __raw_writel(__raw_readl(USB_CTRL) | USB_HOST_NEED_CLK_EN, USB_CTRL);
224 224
225 printk(KERN_INFO "ISP1301 Vendor ID : 0x%04x\n", 225 printk(KERN_INFO "ISP1301 Vendor ID : 0x%04x\n",
226 i2c_smbus_read_word_data(isp1301_i2c_client, 0x00)); 226 i2c_smbus_read_word_data(isp1301_i2c_client, 0x00));
@@ -374,9 +374,13 @@ static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev)
374 const struct hc_driver *driver = &ohci_nxp_hc_driver; 374 const struct hc_driver *driver = &ohci_nxp_hc_driver;
375 struct i2c_adapter *i2c_adap; 375 struct i2c_adapter *i2c_adap;
376 struct i2c_board_info i2c_info; 376 struct i2c_board_info i2c_info;
377 struct resource *res;
377 378
378 int ret = 0, irq; 379 int ret = 0, irq;
379 380
381 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
382 pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
383
380 dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (nxp)\n", hcd_name); 384 dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (nxp)\n", hcd_name);
381 if (usb_disabled()) { 385 if (usb_disabled()) {
382 dev_err(&pdev->dev, "USB is disabled\n"); 386 dev_err(&pdev->dev, "USB is disabled\n");
@@ -384,16 +388,8 @@ static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev)
384 goto out; 388 goto out;
385 } 389 }
386 390
387 if (pdev->num_resources != 2
388 || pdev->resource[0].flags != IORESOURCE_MEM
389 || pdev->resource[1].flags != IORESOURCE_IRQ) {
390 dev_err(&pdev->dev, "Invalid resource configuration\\nn");
391 ret = -ENODEV;
392 goto out;
393 }
394
395 /* Enable AHB slave USB clock, needed for further USB clock control */ 391 /* Enable AHB slave USB clock, needed for further USB clock control */
396 __raw_writel(USB_SLAVE_HCLK_EN | (1 << 19), USB_CTRL); 392 __raw_writel(USB_SLAVE_HCLK_EN | PAD_CONTROL_LAST_DRIVEN, USB_CTRL);
397 393
398 ret = i2c_add_driver(&isp1301_driver); 394 ret = i2c_add_driver(&isp1301_driver);
399 if (ret < 0) { 395 if (ret < 0) {
@@ -401,6 +397,11 @@ static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev)
401 goto out; 397 goto out;
402 } 398 }
403 i2c_adap = i2c_get_adapter(2); 399 i2c_adap = i2c_get_adapter(2);
400 if (!i2c_adap) {
401 dev_err(&pdev->dev, "failed on i2c_get_adapter");
402 goto out_i2c_driver;
403 }
404
404 memset(&i2c_info, 0, sizeof(struct i2c_board_info)); 405 memset(&i2c_info, 0, sizeof(struct i2c_board_info));
405 strlcpy(i2c_info.type, "isp1301_nxp", I2C_NAME_SIZE); 406 strlcpy(i2c_info.type, "isp1301_nxp", I2C_NAME_SIZE);
406 isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, 407 isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info,
@@ -442,7 +443,7 @@ static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev)
442 while ((__raw_readl(USB_OTG_CLK_STAT) & USB_CLOCK_MASK) != 443 while ((__raw_readl(USB_OTG_CLK_STAT) & USB_CLOCK_MASK) !=
443 USB_CLOCK_MASK) ; 444 USB_CLOCK_MASK) ;
444 445
445 hcd = usb_create_hcd (driver, &pdev->dev, dev_name(&pdev->dev)); 446 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
446 if (!hcd) { 447 if (!hcd) {
447 dev_err(&pdev->dev, "Failed to allocate HC buffer\n"); 448 dev_err(&pdev->dev, "Failed to allocate HC buffer\n");
448 ret = -ENOMEM; 449 ret = -ENOMEM;
@@ -452,14 +453,21 @@ static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev)
452 /* Set all USB bits in the Start Enable register */ 453 /* Set all USB bits in the Start Enable register */
453 nxp_set_usb_bits(); 454 nxp_set_usb_bits();
454 455
455 hcd->rsrc_start = pdev->resource[0].start; 456 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
456 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; 457 if (!res) {
457 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 458 dev_err(&pdev->dev, "Failed to get MEM resource\n");
458 dev_dbg(&pdev->dev, "request_mem_region failed\n"); 459 ret = -ENOMEM;
460 goto out4;
461 }
462
463 hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
464 if (!hcd->regs) {
465 dev_err(&pdev->dev, "Failed to devm_request_and_ioremap\n");
459 ret = -ENOMEM; 466 ret = -ENOMEM;
460 goto out4; 467 goto out4;
461 } 468 }
462 hcd->regs = (void __iomem *)pdev->resource[0].start; 469 hcd->rsrc_start = res->start;
470 hcd->rsrc_len = resource_size(res);
463 471
464 irq = platform_get_irq(pdev, 0); 472 irq = platform_get_irq(pdev, 0);
465 if (irq < 0) { 473 if (irq < 0) {