static int ohci_hcd_nxp_probe(struct platform_device *pdev) { struct usb_hcd *hcd = 0; const struct hc_driver *driver = &ohci_nxp_hc_driver; struct resource *res; int ret = 0, irq; struct device_node *isp1301_node; if (pdev->dev.of_node) { isp1301_node = of_parse_phandle(pdev->dev.of_node, "transceiver", 0); } else { isp1301_node = NULL; } isp1301_i2c_client = isp1301_get_client(isp1301_node); if (!isp1301_i2c_client) { return -EPROBE_DEFER; } ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (ret) goto fail_disable; dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (nxp)\n", hcd_name); if (usb_disabled()) { dev_err(&pdev->dev, "USB is disabled\n"); ret = -ENODEV; goto fail_disable; } /* Enable AHB slave USB clock, needed for further USB clock control */ __raw_writel(USB_SLAVE_HCLK_EN | PAD_CONTROL_LAST_DRIVEN, USB_CTRL); /* Enable USB PLL */ usb_pll_clk = devm_clk_get(&pdev->dev, "ck_pll5"); if (IS_ERR(usb_pll_clk)) { dev_err(&pdev->dev, "failed to acquire USB PLL\n"); ret = PTR_ERR(usb_pll_clk); goto fail_disable; } ret = clk_enable(usb_pll_clk); if (ret < 0) { dev_err(&pdev->dev, "failed to start USB PLL\n"); goto fail_disable; } ret = clk_set_rate(usb_pll_clk, 48000); if (ret < 0) { dev_err(&pdev->dev, "failed to set USB clock rate\n"); goto fail_rate; } /* Enable USB device clock */ usb_dev_clk = devm_clk_get(&pdev->dev, "ck_usbd"); if (IS_ERR(usb_dev_clk)) { dev_err(&pdev->dev, "failed to acquire USB DEV Clock\n"); ret = PTR_ERR(usb_dev_clk); goto fail_rate; } ret = clk_enable(usb_dev_clk); if (ret < 0) { dev_err(&pdev->dev, "failed to start USB DEV Clock\n"); goto fail_rate; } /* Enable USB otg clocks */ usb_otg_clk = devm_clk_get(&pdev->dev, "ck_usb_otg"); if (IS_ERR(usb_otg_clk)) { dev_err(&pdev->dev, "failed to acquire USB DEV Clock\n"); ret = PTR_ERR(usb_otg_clk); goto fail_otg; } __raw_writel(__raw_readl(USB_CTRL) | USB_HOST_NEED_CLK_EN, USB_CTRL); ret = clk_enable(usb_otg_clk); if (ret < 0) { dev_err(&pdev->dev, "failed to start USB DEV Clock\n"); goto fail_otg; } isp1301_configure(); hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Failed to allocate HC buffer\n"); ret = -ENOMEM; goto fail_hcd; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); hcd->regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(hcd->regs)) { ret = PTR_ERR(hcd->regs); goto fail_resource; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); irq = platform_get_irq(pdev, 0); if (irq < 0) { ret = -ENXIO; goto fail_resource; } ohci_nxp_start_hc(); platform_set_drvdata(pdev, hcd); dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); ret = usb_add_hcd(hcd, irq, 0); if (ret == 0) { device_wakeup_enable(hcd->self.controller); return ret; } ohci_nxp_stop_hc(); fail_resource: usb_put_hcd(hcd); fail_hcd: clk_disable(usb_otg_clk); fail_otg: clk_disable(usb_dev_clk); fail_rate: clk_disable(usb_pll_clk); fail_disable: isp1301_i2c_client = NULL; return ret; }
/*! * zasevb_tcd_mod_init() - initial tcd setup * This performs the platform specific hardware setup for the MX2ADS. */ int zasevb_tcd_mod_init (void) { int i2c = 1; int gpio = 1; /* ------------------------------------------------------------------------ */ #ifdef CONFIG_OTG_ZASEVB_DIFFERENTIAL_UNIDIRECTIONAL int hwmode = XCVR_D_SE0_NEW; int newmode = XCVR_D_D; isp1301_tx_mode_t tx_mode = vp_vm_unidirectional; // MXC91231 ok printk (KERN_INFO"Current setting is DIFFERENTIAL UNIDIRECTIONAL\n"); /* ------------------------------------------------------------------------ */ #elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_UNIDIRECTIONAL int hwmode = XCVR_SE0_D_NEW; int newmode = XCVR_SE0_D_NEW; isp1301_tx_mode_t tx_mode = dat_se0_unidirectional; // MXC91331 ok printk (KERN_INFO"Current setting is SINGLE ENDED UNIDIRECTIONAL\n"); /* ------------------------------------------------------------------------ */ #elif CONFIG_OTG_ZASEVB_DIFFERENTIAL_BIDIRECTIONAL int hwmode = XCVR_D_D; int newmode = XCVR_D_D; isp1301_tx_mode_t tx_mode = vp_vm_bidirectional; // MXC91331 ok printk (KERN_INFO"Current setting is DIFFERENTIAL BIDIRECTIONAL\n"); /* ------------------------------------------------------------------------ */ #elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_BIDIRECTIONAL int hwmode = XCVR_SE0_SE0; int newmode = XCVR_SE0_SE0; isp1301_tx_mode_t tx_mode = dat_se0_bidirectional; //MXC91231 ok printk (KERN_INFO"Current setting is SINGLE ENDED BIDIRECTIONAL\n"); /* ------------------------------------------------------------------------ */ #else #error Please Configure Transceiver Mode #endif /* CONFIG_OTG_ZASEVB_.... */ /* ------------------------------------------------------------------------ */ TRACE_MSG0(TCD, "1. I2C setup"); THROW_IF ((i2c = i2c_configure(ADAPTER_NAME, ISP1301_I2C_ADDR_HIGH)), error); TRACE_MSG0(TCD, "2. ISP1301 module setup"); // isp1301_mod_init(&zasevb_isp1301_bh); TRACE_MSG0(TCD, "3. SET TCD OPS"); THROW_UNLESS(zasevb_tcd_instance = otg_set_tcd_ops(&tcd_ops), error); TRACE_MSG0(TCD, "4. ISP1301 device setup"); mxc_iomux_gpio_isp1301_set (hwmode); #ifdef CONFIG_ARCH_MXC91131 writel (0x00000051, PLL2_DP_HFSOP); writel (0x00000051, PLL2_DP_OP); #endif /* CONFIG_ARCH_MXC91131 */ /* ------------------------------------------------------------------------ */ TRACE_MSG0(TCD, "7. SET HWMODE"); isp1301_configure(tx_mode, spd_susp_reg); mxc_main_clock_on(); //mxc_host_clock_on(); //mxc_func_clock_on(); mxc_set_transceiver_mode(newmode); /* Success! */ TRACE_MSG0(TCD, "8. Success!"); CATCH(error) { printk(KERN_INFO"%s: failed\n", __FUNCTION__); UNLESS (i2c) i2c_close(); // UNLESS (gpio) gpio_free_irq (ZGPIO_PORT, ZGPIO_PIN, GPIO_HIGH_PRIO); return -EINVAL; } TRACE_MSG0(TCD, "MX2_MOD_TCD_INIT FINISHED"); return 0; }
static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) { struct usb_hcd *hcd = 0; struct ohci_hcd *ohci; const struct hc_driver *driver = &ohci_pnx4008_hc_driver; struct i2c_adapter *i2c_adap; struct i2c_board_info i2c_info; int ret = 0, irq; dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (pnx4008)\n", hcd_name); if (usb_disabled()) { err("USB is disabled"); ret = -ENODEV; goto out; } if (pdev->num_resources != 2 || pdev->resource[0].flags != IORESOURCE_MEM || pdev->resource[1].flags != IORESOURCE_IRQ) { err("Invalid resource configuration"); ret = -ENODEV; goto out; } /* Enable AHB slave USB clock, needed for further USB clock control */ __raw_writel(USB_SLAVE_HCLK_EN | (1 << 19), USB_CTRL); ret = i2c_add_driver(&isp1301_driver); if (ret < 0) { err("failed to add ISP1301 driver"); goto out; } i2c_adap = i2c_get_adapter(2); memset(&i2c_info, 0, sizeof(struct i2c_board_info)); strlcpy(i2c_info.type, "isp1301_pnx", I2C_NAME_SIZE); isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, normal_i2c, NULL); i2c_put_adapter(i2c_adap); if (!isp1301_i2c_client) { err("failed to connect I2C to ISP1301 USB Transceiver"); ret = -ENODEV; goto out_i2c_driver; } isp1301_configure(); /* Enable USB PLL */ usb_clk = clk_get(&pdev->dev, "ck_pll5"); if (IS_ERR(usb_clk)) { err("failed to acquire USB PLL"); ret = PTR_ERR(usb_clk); goto out1; } ret = clk_enable(usb_clk); if (ret < 0) { err("failed to start USB PLL"); goto out2; } ret = clk_set_rate(usb_clk, 48000); if (ret < 0) { err("failed to set USB clock rate"); goto out3; } __raw_writel(__raw_readl(USB_CTRL) | USB_HOST_NEED_CLK_EN, USB_CTRL); /* Set to enable all needed USB clocks */ __raw_writel(USB_CLOCK_MASK, USB_OTG_CLK_CTRL); while ((__raw_readl(USB_OTG_CLK_STAT) & USB_CLOCK_MASK) != USB_CLOCK_MASK) ; hcd = usb_create_hcd (driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { err("Failed to allocate HC buffer"); ret = -ENOMEM; goto out3; } /* Set all USB bits in the Start Enable register */ pnx4008_set_usb_bits(); hcd->rsrc_start = pdev->resource[0].start; hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { dev_dbg(&pdev->dev, "request_mem_region failed\n"); ret = -ENOMEM; goto out4; } hcd->regs = (void __iomem *)pdev->resource[0].start; irq = platform_get_irq(pdev, 0); if (irq < 0) { ret = -ENXIO; goto out4; } pnx4008_start_hc(); platform_set_drvdata(pdev, hcd); ohci = hcd_to_ohci(hcd); ohci_hcd_init(ohci); dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); ret = usb_add_hcd(hcd, irq, 0); if (ret == 0) return ret; pnx4008_stop_hc(); out4: pnx4008_unset_usb_bits(); usb_put_hcd(hcd); out3: clk_disable(usb_clk); out2: clk_put(usb_clk); out1: i2c_unregister_device(isp1301_i2c_client); isp1301_i2c_client = NULL; out_i2c_driver: i2c_del_driver(&isp1301_driver); out: return ret; }
static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev) { struct usb_hcd *hcd = 0; struct ohci_hcd *ohci; const struct hc_driver *driver = &ohci_nxp_hc_driver; struct resource *res; int ret = 0, irq; struct device_node *isp1301_node; if (pdev->dev.of_node) { isp1301_node = of_parse_phandle(pdev->dev.of_node, "transceiver", 0); } else { isp1301_node = NULL; } isp1301_i2c_client = isp1301_get_client(isp1301_node); if (!isp1301_i2c_client) { ret = -EPROBE_DEFER; goto out; } pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (nxp)\n", hcd_name); if (usb_disabled()) { dev_err(&pdev->dev, "USB is disabled\n"); ret = -ENODEV; goto out; } /* Enable AHB slave USB clock, needed for further USB clock control */ __raw_writel(USB_SLAVE_HCLK_EN | PAD_CONTROL_LAST_DRIVEN, USB_CTRL); isp1301_configure(); /* Enable USB PLL */ usb_clk = clk_get(&pdev->dev, "ck_pll5"); if (IS_ERR(usb_clk)) { dev_err(&pdev->dev, "failed to acquire USB PLL\n"); ret = PTR_ERR(usb_clk); goto out1; } ret = clk_enable(usb_clk); if (ret < 0) { dev_err(&pdev->dev, "failed to start USB PLL\n"); goto out2; } ret = clk_set_rate(usb_clk, 48000); if (ret < 0) { dev_err(&pdev->dev, "failed to set USB clock rate\n"); goto out3; } __raw_writel(__raw_readl(USB_CTRL) | USB_HOST_NEED_CLK_EN, USB_CTRL); /* Set to enable all needed USB clocks */ __raw_writel(USB_CLOCK_MASK, USB_OTG_CLK_CTRL); while ((__raw_readl(USB_OTG_CLK_STAT) & USB_CLOCK_MASK) != USB_CLOCK_MASK) ; hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Failed to allocate HC buffer\n"); ret = -ENOMEM; goto out3; } /* Set all USB bits in the Start Enable register */ nxp_set_usb_bits(); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Failed to get MEM resource\n"); ret = -ENOMEM; goto out4; } hcd->regs = devm_request_and_ioremap(&pdev->dev, res); if (!hcd->regs) { dev_err(&pdev->dev, "Failed to devm_request_and_ioremap\n"); ret = -ENOMEM; goto out4; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); irq = platform_get_irq(pdev, 0); if (irq < 0) { ret = -ENXIO; goto out4; } nxp_start_hc(); platform_set_drvdata(pdev, hcd); ohci = hcd_to_ohci(hcd); ohci_hcd_init(ohci); dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); ret = usb_add_hcd(hcd, irq, 0); if (ret == 0) return ret; nxp_stop_hc(); out4: nxp_unset_usb_bits(); usb_put_hcd(hcd); out3: clk_disable(usb_clk); out2: clk_put(usb_clk); out1: isp1301_i2c_client = NULL; out: return ret; }