/** * usb_hcd_at91_probe - initialize AT91-based HCDs * Context: !in_interrupt() * * Allocates basic resources for this USB host controller, and * then invokes the start() method for the HCD associated with it * through the hotplug entry's driver_data. */ static int usb_hcd_at91_probe(const struct hc_driver *driver, struct platform_device *pdev) { int retval; struct usb_hcd *hcd = NULL; if (pdev->num_resources != 2) { pr_debug("hcd probe: invalid num_resources"); return -ENODEV; } if ((pdev->resource[0].flags != IORESOURCE_MEM) || (pdev->resource[1].flags != IORESOURCE_IRQ)) { pr_debug("hcd probe: invalid resource type\n"); return -ENODEV; } hcd = usb_create_hcd(driver, &pdev->dev, "at91"); if (!hcd) return -ENOMEM; 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)) { pr_debug("request_mem_region failed\n"); retval = -EBUSY; goto err1; } hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); if (!hcd->regs) { pr_debug("ioremap failed\n"); retval = -EIO; goto err2; } iclk = clk_get(&pdev->dev, "ohci_clk"); fclk = clk_get(&pdev->dev, "uhpck"); if (cpu_is_at91sam9261()) hclk = clk_get(&pdev->dev, "hck0"); at91_start_hc(pdev); ohci_hcd_init(hcd_to_ohci(hcd)); retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED); if (retval == 0) return retval; /* Error handling */ at91_stop_hc(pdev); if (cpu_is_at91sam9261()) clk_put(hclk); clk_put(fclk); clk_put(iclk); iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: usb_put_hcd(hcd); return retval; }
static int serial_pxa_probe(struct platform_device *dev) { struct uart_pxa_port *sport; struct resource *mmres, *irqres; int ret; mmres = platform_get_resource(dev, IORESOURCE_MEM, 0); irqres = platform_get_resource(dev, IORESOURCE_IRQ, 0); if (!mmres || !irqres) return -ENODEV; sport = kzalloc(sizeof(struct uart_pxa_port), GFP_KERNEL); if (!sport) return -ENOMEM; sport->clk = clk_get(&dev->dev, NULL); if (IS_ERR(sport->clk)) { ret = PTR_ERR(sport->clk); goto err_free; } ret = clk_prepare(sport->clk); if (ret) { clk_put(sport->clk); goto err_free; } sport->port.type = PORT_PXA; sport->port.iotype = UPIO_MEM; sport->port.mapbase = mmres->start; sport->port.irq = irqres->start; sport->port.fifosize = 64; sport->port.ops = &serial_pxa_pops; sport->port.dev = &dev->dev; sport->port.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF; sport->port.uartclk = clk_get_rate(sport->clk); ret = serial_pxa_probe_dt(dev, sport); if (ret > 0) sport->port.line = dev->id; else if (ret < 0) goto err_clk; snprintf(sport->name, PXA_NAME_LEN - 1, "UART%d", sport->port.line + 1); sport->port.membase = ioremap(mmres->start, resource_size(mmres)); if (!sport->port.membase) { ret = -ENOMEM; goto err_clk; } serial_pxa_ports[sport->port.line] = sport; uart_add_one_port(&serial_pxa_reg, &sport->port); platform_set_drvdata(dev, sport); return 0; err_clk: clk_unprepare(sport->clk); clk_put(sport->clk); err_free: kfree(sport); return ret; }
static int __init msm_otg_probe(struct platform_device *pdev) { int ret; struct resource *res; xceiv = kzalloc(sizeof(struct msm_otg_transceiver), GFP_KERNEL); if (!xceiv) return -ENOMEM; xceiv->clk = clk_get(NULL, "usb_hs_clk"); if (IS_ERR(xceiv->clk)) { ret = PTR_ERR(xceiv->clk); goto free_xceiv; } xceiv->pclk = clk_get(NULL, "usb_hs_pclk"); if (IS_ERR(xceiv->clk)) { ret = PTR_ERR(xceiv->pclk); goto put_clk; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { ret = -ENODEV; goto put_pclk; } xceiv->regs = ioremap(res->start, resource_size(res)); if (!xceiv->regs) { ret = -ENOMEM; goto put_pclk; } xceiv->irq = platform_get_irq(pdev, 0); if (!xceiv->irq) { ret = -ENODEV; goto free_regs; } msm_otg_set_clk(1); writel(0, USB_USBINTR); writel(readl(USB_OTGSC) & ~OTGSC_INTR_MASK, USB_OTGSC); msm_otg_set_clk(0); ret = request_irq(xceiv->irq, msm_otg_irq, IRQF_SHARED, "msm_otg", pdev); if (ret) goto free_regs; disable_irq(xceiv->irq); INIT_WORK(&xceiv->work, msm_otg_do_work); spin_lock_init(&xceiv->lock); wake_lock_init(&xceiv->wlock, WAKE_LOCK_SUSPEND, "usb_otg"); wake_lock(&xceiv->wlock); xceiv->set_host = msm_otg_set_host; xceiv->set_peripheral = msm_otg_set_peripheral; xceiv->set_suspend = msm_otg_set_suspend; return 0; free_regs: iounmap(xceiv->regs); put_pclk: clk_put(xceiv->pclk); put_clk: clk_put(xceiv->clk); free_xceiv: kfree(xceiv); return ret; }
static __devinit int tegra30_spdif_platform_probe(struct platform_device *pdev) { struct tegra30_spdif *spdif; struct resource *mem, *memregion; int ret; u32 reg_val; spdif = kzalloc(sizeof(struct tegra30_spdif), GFP_KERNEL); if (!spdif) { #if HDMI_DEBUG printk("HDMI_DEBUG: Can't allocate tegra30_spdif\n"); #endif dev_err(&pdev->dev, "Can't allocate tegra30_spdif\n"); ret = -ENOMEM; goto exit; } dev_set_drvdata(&pdev->dev, spdif); spdif->clk_spdif_out = clk_get(&pdev->dev, "spdif_out"); if (IS_ERR(spdif->clk_spdif_out)) { #if HDMI_DEBUG printk("HDMI_DEBUG: Can't retrieve spdif clock\n"); #endif dev_err(&pdev->dev, "Can't retrieve spdif clock\n"); ret = PTR_ERR(spdif->clk_spdif_out); goto err_free; } mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { #if HDMI_DEBUG printk("HDMI_DEBUG: No memory resource\n"); #endif dev_err(&pdev->dev, "No memory resource\n"); ret = -ENODEV; goto err_clk_put_spdif; } memregion = request_mem_region(mem->start, resource_size(mem), DRV_NAME); if (!memregion) { #if HDMI_DEBUG printk("HDMI_DEBUG: Memory region already claimed\n"); #endif dev_err(&pdev->dev, "Memory region already claimed\n"); ret = -EBUSY; goto err_clk_put_spdif; } spdif->regs = ioremap(mem->start, resource_size(mem)); if (!spdif->regs) { #if HDMI_DEBUG printk("HDMI_DEBUG: ioremap failed\n"); #endif dev_err(&pdev->dev, "ioremap failed\n"); ret = -ENOMEM; goto err_release; } tegra30_spdif_enable_clocks(spdif); reg_val = TEGRA30_SPDIF_CIF_TXD_CTRL_DIRECTION_RXCIF | TEGRA30_SPDIF_CIF_TXD_CTRL_AUDIO_BIT16 | TEGRA30_SPDIF_CIF_TXD_CTRL_CLIENT_BIT16 | TEGRA30_SPDIF_CIF_TXD_CTRL_AUDIO_CH2 | TEGRA30_SPDIF_CIF_TXD_CTRL_CLIENT_CH2 | (3 << TEGRA30_SPDIF_CIF_TXD_CTRL_FIFO_TH_SHIFT); tegra30_spdif_write(spdif, TEGRA30_SPDIF_CIF_TXD_CTRL, reg_val); tegra30_spdif_disable_clocks(spdif); ret = snd_soc_register_dai(&pdev->dev, &tegra30_spdif_dai); if (ret) { #if HDMI_DEBUG printk("HDMI_DEBUG: Could not register DAI: %d\n", ret); #endif dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); ret = -ENOMEM; goto err_unmap; } tegra30_spdif_debug_add(spdif); return 0; err_unmap: iounmap(spdif->regs); err_release: release_mem_region(mem->start, resource_size(mem)); err_clk_put_spdif: clk_put(spdif->clk_spdif_out); err_free: kfree(spdif); exit: return ret; }
static int __devinit s3c2410wdt_probe(struct platform_device *pdev) { struct resource *res; struct device *dev; unsigned int wtcon; int started = 0; int ret; int size; DBG("%s: probe=%p\n", __func__, pdev); dev = &pdev->dev; wdt_dev = &pdev->dev; /* get the memory region for the watchdog timer */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(dev, "no memory resource specified\n"); return -ENOENT; } size = resource_size(res); wdt_mem = request_mem_region(res->start, size, pdev->name); if (wdt_mem == NULL) { dev_err(dev, "failed to get memory region\n"); return -EBUSY; } wdt_base = ioremap(res->start, size); if (wdt_base == NULL) { dev_err(dev, "failed to ioremap() region\n"); ret = -EINVAL; goto err_req; } DBG("probe: mapped wdt_base=%p\n", wdt_base); wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (wdt_irq == NULL) { dev_err(dev, "no irq resource specified\n"); ret = -ENOENT; goto err_map; } ret = request_irq(wdt_irq->start, s3c2410wdt_irq, 0, pdev->name, pdev); if (ret != 0) { dev_err(dev, "failed to install irq (%d)\n", ret); goto err_map; } wdt_clock = clk_get(&pdev->dev, "watchdog"); if (IS_ERR(wdt_clock)) { dev_err(dev, "failed to find watchdog clock source\n"); ret = PTR_ERR(wdt_clock); goto err_irq; } clk_enable(wdt_clock); if (s3c2410wdt_cpufreq_register() < 0) { printk(KERN_ERR PFX "failed to register cpufreq\n"); goto err_clk; } /* see if we can actually set the requested timer margin, and if * not, try the default value */ if (s3c2410wdt_set_heartbeat(tmr_margin)) { started = s3c2410wdt_set_heartbeat(CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME); if (started == 0) dev_info(dev, "tmr_margin value out of range, default %d used\n", CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME); else dev_info(dev, "default timer value is out of range, cannot start\n"); } ret = misc_register(&s3c2410wdt_miscdev); if (ret) { dev_err(dev, "cannot register miscdev on minor=%d (%d)\n", WATCHDOG_MINOR, ret); goto err_cpufreq; } if (tmr_atboot && started == 0) { dev_info(dev, "starting watchdog timer\n"); DEBG("--------------- starting watchdog timer: timeout = %d --------------\n", tmr_margin); s3c2410wdt_start(); #ifdef CONFIG_START_S3C2410_WDT_AT_BOOT wdt_ktd = kthread_create(wdt_thread, NULL, "s3c2410_watchdog_thread"); if (wdt_ktd == (struct task_struct*)ERR_PTR) { wdt_ktd = NULL; DEBG("--- kthread create, error ---\n"); } else { wake_up_process(wdt_ktd); } #endif } else if (!tmr_atboot) { /* if we're not enabling the watchdog, then ensure it is * disabled if it has been left running from the bootloader * or other source */ DEBG("--- not starting watchdog timer at boot time ---\n"); s3c2410wdt_stop(); } /* print out a statement of readiness */ wtcon = readl(wdt_base + S3C2410_WTCON); dev_info(dev, "watchdog %sactive, reset %sabled, irq %sabled\n", (wtcon & S3C2410_WTCON_ENABLE) ? "" : "in", (wtcon & S3C2410_WTCON_RSTEN) ? "" : "dis", (wtcon & S3C2410_WTCON_INTEN) ? "" : "en"); return 0; err_cpufreq: s3c2410wdt_cpufreq_deregister(); err_clk: clk_disable(wdt_clock); clk_put(wdt_clock); err_irq: free_irq(wdt_irq->start, pdev); err_map: iounmap(wdt_base); err_req: release_resource(wdt_mem); kfree(wdt_mem); return ret; }
static int __init playpaq_asoc_init(void) { int ret = 0; struct at32_ssc_info *ssc_p = playpaq_wm8510_dai.cpu_dai->private_data; struct ssc_device *ssc = NULL; /* * Request SSC device */ ssc = ssc_request(0); if (IS_ERR(ssc)) { ret = PTR_ERR(ssc); goto err_ssc; } ssc_p->ssc = ssc; /* * Configure MCLK for WM8510 */ _gclk0 = clk_get(NULL, "gclk0"); if (IS_ERR(_gclk0)) { _gclk0 = NULL; goto err_gclk0; } _pll0 = clk_get(NULL, "pll0"); if (IS_ERR(_pll0)) { _pll0 = NULL; goto err_pll0; } if (clk_set_parent(_gclk0, _pll0)) { pr_warning("snd-soc-playpaq: " "Failed to set PLL0 as parent for DAC clock\n"); goto err_set_clk; } clk_set_rate(CODEC_CLK, 12000000); clk_enable(CODEC_CLK); #if defined CONFIG_AT32_ENHANCED_PORTMUX at32_select_periph(MCLK_PIN, MCLK_PERIPH, 0); #endif /* * Create and register platform device */ playpaq_snd_device = platform_device_alloc("soc-audio", 0); if (playpaq_snd_device == NULL) { ret = -ENOMEM; goto err_device_alloc; } platform_set_drvdata(playpaq_snd_device, &playpaq_wm8510_snd_devdata); playpaq_wm8510_snd_devdata.dev = &playpaq_snd_device->dev; ret = platform_device_add(playpaq_snd_device); if (ret) { pr_warning("playpaq_wm8510: platform_device_add failed (%d)\n", ret); goto err_device_add; } return 0; err_device_add: if (playpaq_snd_device != NULL) { platform_device_put(playpaq_snd_device); playpaq_snd_device = NULL; } err_device_alloc: err_set_clk: if (_pll0 != NULL) { clk_put(_pll0); _pll0 = NULL; } err_pll0: if (_gclk0 != NULL) { clk_put(_gclk0); _gclk0 = NULL; } err_gclk0: ssc_free(ssc); err_ssc: return ret; }
/*! MXC RTC Power management control */ static int mxc_rtc_probe(struct platform_device *pdev) { struct clk *clk; struct timespec tv; struct resource *res; struct rtc_device *rtc; struct rtc_drv_data *pdata = NULL; struct mxc_srtc_platform_data *plat_data = NULL; void __iomem *ioaddr; void __iomem *srtc_secmode_addr; int ret = 0; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; pdata->clk = clk_get(&pdev->dev, "rtc_clk"); clk_enable(pdata->clk); pdata->baseaddr = res->start; pdata->ioaddr = ioremap(pdata->baseaddr, 0x40); ioaddr = pdata->ioaddr; /* Configure and enable the RTC */ pdata->irq = platform_get_irq(pdev, 0); if (pdata->irq >= 0) { if (request_irq(pdata->irq, mxc_rtc_interrupt, IRQF_SHARED, pdev->name, pdev) < 0) { dev_warn(&pdev->dev, "interrupt not available.\n"); pdata->irq = -1; } else { disable_irq(pdata->irq); pdata->irq_enable = false; } } clk = clk_get(NULL, "rtc_clk"); if (clk_get_rate(clk) != 32768) { printk(KERN_ALERT "rtc clock is not valid"); ret = -EINVAL; clk_put(clk); goto err_out; } clk_put(clk); /* initialize glitch detect */ __raw_writel(SRTC_LPPDR_INIT, ioaddr + SRTC_LPPDR); udelay(100); /* clear lp interrupt status */ __raw_writel(0xFFFFFFFF, ioaddr + SRTC_LPSR); udelay(100); plat_data = (struct mxc_srtc_platform_data *)pdev->dev.platform_data; /* move out of init state */ __raw_writel((SRTC_LPCR_IE | SRTC_LPCR_NSA), ioaddr + SRTC_LPCR); udelay(100); while ((__raw_readl(ioaddr + SRTC_LPSR) & SRTC_LPSR_IES) == 0) ; /* move out of non-valid state */ __raw_writel((SRTC_LPCR_IE | SRTC_LPCR_NVE | SRTC_LPCR_NSA | SRTC_LPCR_EN_LP), ioaddr + SRTC_LPCR); udelay(100); while ((__raw_readl(ioaddr + SRTC_LPSR) & SRTC_LPSR_NVES) == 0) ; __raw_writel(0xFFFFFFFF, ioaddr + SRTC_LPSR); udelay(100); rtc = rtc_device_register(pdev->name, &pdev->dev, &mxc_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) { ret = PTR_ERR(rtc); goto err_out; } pdata->rtc = rtc; platform_set_drvdata(pdev, pdata); tv.tv_nsec = 0; tv.tv_sec = __raw_readl(ioaddr + SRTC_LPSCMR); /* By default, devices should wakeup if they can */ /* So srtc is set as "should wakeup" as it can */ device_init_wakeup(&pdev->dev, 1); clk_disable(pdata->clk); return ret; err_out: clk_disable(pdata->clk); iounmap(ioaddr); if (pdata->irq >= 0) free_irq(pdata->irq, pdev); kfree(pdata); return ret; }
static int sdhci_zynq_probe(struct platform_device *pdev) { int ret; int irq = platform_get_irq(pdev, 0); const void *prop; struct device_node *np = pdev->dev.of_node; struct sdhci_host *host; struct sdhci_pltfm_host *pltfm_host; struct xsdhcips *xsdhcips; xsdhcips = kmalloc(sizeof(*xsdhcips), GFP_KERNEL); if (!xsdhcips) { dev_err(&pdev->dev, "unable to allocate memory\n"); return -ENOMEM; } if (irq == 56) xsdhcips->aperclk = clk_get_sys("SDIO0_APER", NULL); else xsdhcips->aperclk = clk_get_sys("SDIO1_APER", NULL); if (IS_ERR(xsdhcips->aperclk)) { dev_err(&pdev->dev, "APER clock not found.\n"); ret = PTR_ERR(xsdhcips->aperclk); goto err_free; } if (irq == 56) xsdhcips->devclk = clk_get_sys("SDIO0", NULL); else xsdhcips->devclk = clk_get_sys("SDIO1", NULL); if (IS_ERR(xsdhcips->devclk)) { dev_err(&pdev->dev, "Device clock not found.\n"); ret = PTR_ERR(xsdhcips->devclk); goto clk_put_aper; } ret = clk_prepare_enable(xsdhcips->aperclk); if (ret) { dev_err(&pdev->dev, "Unable to enable APER clock.\n"); goto clk_put; } ret = clk_prepare_enable(xsdhcips->devclk); if (ret) { dev_err(&pdev->dev, "Unable to enable device clock.\n"); goto clk_dis_aper; } xsdhcips->clk_rate_change_nb.notifier_call = xsdhcips_clk_notifier_cb; xsdhcips->clk_rate_change_nb.next = NULL; if (clk_notifier_register(xsdhcips->devclk, &xsdhcips->clk_rate_change_nb)) dev_warn(&pdev->dev, "Unable to register clock notifier.\n"); ret = sdhci_pltfm_register(pdev, &sdhci_zynq_pdata); if (ret) { dev_err(&pdev->dev, "Platform registration failed\n"); goto clk_notif_unreg; } host = platform_get_drvdata(pdev); pltfm_host = sdhci_priv(host); pltfm_host->priv = xsdhcips; prop = of_get_property(np, "xlnx,has-cd", NULL); if (prop == NULL || (!(u32) be32_to_cpup(prop))) host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; return 0; clk_notif_unreg: clk_notifier_unregister(xsdhcips->devclk, &xsdhcips->clk_rate_change_nb); clk_disable_unprepare(xsdhcips->devclk); clk_dis_aper: clk_disable_unprepare(xsdhcips->aperclk); clk_put: clk_put(xsdhcips->devclk); clk_put_aper: clk_put(xsdhcips->aperclk); err_free: kfree(xsdhcips); return ret; }
static int loongson2_cpufreq_exit(struct cpufreq_policy *policy) { cpufreq_frequency_table_put_attr(policy->cpu); clk_put(policy->clk); return 0; }
/* * Set s3c_ Clock source * Since, we set frequencies using PreScaler and BFS, RFS, we select input clock source to the IIS here. */ static int s3c_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int dir) { #if USE_CLKAUDIO struct clk *clk; #endif u32 iismod = readl(s3c_i2s.regs + S3C_IISMOD); debug_msg("%s\n", __FUNCTION__); switch (clk_id) { case S3C_CLKSRC_PCLK: if(s3c_i2s.slave) return -EINVAL; iismod &= ~S3C_IISMOD_IMSMASK; iismod |= clk_id; s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.iis_clk); break; #if USE_CLKAUDIO case S3C_CLKSRC_CLKAUDIO: if(s3c_i2s.slave) return -EINVAL; iismod &= ~S3C_IISMOD_IMSMASK; iismod |= clk_id; /* 8000 x 256 = 2048000 49152000 mod 2048000 = 0 32768000 mod 2048000 = 0 73728000 mod 2048000 = 0 11025 x 256 = 2822400 67738000 mod 2822400 = 400 16000 x 256 = 4096000 49152000 mod 4096000 = 0 32768000 mod 4096000 = 0 73728000 mod 4096000 = 0 22050 x 256 = 5644800 67738000 mod 5644800 = 400 32000 x 256 = 8192000 49152000 mod 8192000 = 0 32768000 mod 8192000 = 0 73728000 mod 8192000 = 0 44100 x 256 = 11289600 67738000 mod 11289600 = 400 48000 x 256 = 12288000 49152000 mod 12288000 = 0 73728000 mod 12288000 = 0 64000 x 256 = 16384000 49152000 mod 16384000 = 0 32768000 mod 16384000 = 0 88200 x 256 = 22579200 67738000 mod 22579200 = 400 96000 x 256 = 24576000 49152000 mod 24576000 = 0 73728000 mod 24576000 = 0 From the table above, we find that 49152000 gives least(0) residue for most sample rates, followed by 67738000. */ clk = clk_get(NULL, "fout_epll"); if (IS_ERR(clk)) { printk("failed to get FOUTepll\n"); return -EBUSY; } clk_disable(clk); switch (freq) { case 8000: #ifdef CONFIG_SND_S3C64XX_SOC_I2S_REC_DOWNSAMPLING // sangsu fix clk_set_rate(clk, 67738000); break; #endif // sangsu fix case 16000: case 32000: case 48000: case 64000: case 96000: clk_set_rate(clk, 49152000); break; case 11025: case 22050: case 44100: case 88200: default: clk_set_rate(clk, 67738000); break; } clk_enable(clk); s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.audio_bus); //printk("Setting FOUTepll to %dHz", s3c_i2s.clk_rate); clk_put(clk); break; #endif case S3C_CLKSRC_SLVPCLK: case S3C_CLKSRC_I2SEXT: #if USE_AP_MASTER if(!s3c_i2s.slave) { printk("[warning]slave is not set\n"); return -EINVAL; } #endif iismod &= ~S3C_IISMOD_IMSMASK; iismod |= clk_id; break; /* Not sure about these two! */ case S3C_CDCLKSRC_INT: iismod &= ~S3C_IISMOD_CDCLKCON; break; case S3C_CDCLKSRC_EXT: iismod |= S3C_IISMOD_CDCLKCON; break; default: return -EINVAL; } writel(iismod, s3c_i2s.regs + S3C_IISMOD); return 0; }
static int s3c_i2s_probe(struct platform_device *pdev, struct snd_soc_dai *dai) { int ret = 0; #if USE_CLKAUDIO struct clk *cm, *cf; #endif debug_msg("%s\n", __FUNCTION__); s3c_i2s.regs = ioremap(S3C_IIS_PABASE, 0x100); /* Configure the I2S pins in correct mode */ s3c_gpio_cfgpin(GPIO_I2S_LRCLK, S3C_GPIO_SFN(GPIO_I2S_LRCLK_AF)); s3c_gpio_cfgpin(GPIO_I2S_CLK, S3C_GPIO_SFN(GPIO_I2S_CLK_AF)); s3c_gpio_cfgpin(GPIO_I2S_DI, S3C_GPIO_SFN(GPIO_I2S_DI_AF)); s3c_gpio_cfgpin(GPIO_I2S_DO, S3C_GPIO_SFN(GPIO_I2S_DO_AF)); /* pull-up-enable, pull-down-disable*/ s3c_gpio_setpull(GPIO_I2S_CLK, S3C_GPIO_PULL_UP); s3c_gpio_setpull(GPIO_I2S_LRCLK, S3C_GPIO_PULL_UP); s3c_gpio_setpull(GPIO_I2S_DI, S3C_GPIO_PULL_UP); s3c_gpio_setpull(GPIO_I2S_DO, S3C_GPIO_PULL_UP); if (s3c_i2s.regs == NULL) return -ENXIO; ret = request_irq(S3C_IISIRQ, s3c_iis_irq, 0, "s3c-i2s", pdev); if (ret < 0) { printk("fail to claim i2s irq , ret = %d\n", ret); iounmap(s3c_i2s.regs); return -ENODEV; } s3c_i2s.iis_clk = clk_get(&pdev->dev, PCLKCLK); if (IS_ERR(s3c_i2s.iis_clk)) { printk("failed to get clk(%s)\n", PCLKCLK); goto lb5; } clk_enable(s3c_i2s.iis_clk); s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.iis_clk); #if USE_CLKAUDIO s3c_i2s.audio_bus = clk_get(NULL, EXTCLK); if (IS_ERR(s3c_i2s.audio_bus)) { printk("failed to get clk(%s)\n", EXTCLK); goto lb4; } cm = clk_get(NULL, "mout_epll"); if (IS_ERR(cm)) { printk("failed to get mout_epll\n"); goto lb3; } if(clk_set_parent(s3c_i2s.audio_bus, cm)){ printk("failed to set MOUTepll as parent of CLKAUDIO0\n"); goto lb2; } cf = clk_get(NULL, "fout_epll"); if (IS_ERR(cf)) { printk("failed to get fout_epll\n"); goto lb2; } clk_enable(cf); if(clk_set_parent(cm, cf)){ printk("failed to set FOUTepll as parent of MOUTepll\n"); goto lb1; } s3c_i2s.clk_rate = clk_get_rate(s3c_i2s.audio_bus); clk_put(cf); clk_put(cm); #endif #if defined(CONFIG_SND_S3C_I2S_V50) writel(readl(s3c_i2s.regs + S3C_IISCON) | S3C_IISCON_SWRESET, s3c_i2s.regs + S3C_IISCON); #else writel(S3C_IISCON_I2SACTIVE, s3c_i2s.regs + S3C_IISCON); #endif s3c_snd_txctrl(0); s3c_snd_rxctrl(0); return 0; #if USE_CLKAUDIO lb1: clk_put(cf); lb2: clk_put(cm); lb3: clk_put(s3c_i2s.audio_bus); lb4: clk_disable(s3c_i2s.iis_clk); clk_put(s3c_i2s.iis_clk); #endif lb5: free_irq(S3C_IISIRQ, pdev); iounmap(s3c_i2s.regs); return -ENODEV; }
/* * Probe for the device */ static int __init at91_mci_probe(struct platform_device *pdev) { struct mmc_host *mmc; struct at91mci_host *host; struct resource *res; int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENXIO; if (!request_mem_region(res->start, resource_size(res), DRIVER_NAME)) return -EBUSY; mmc = mmc_alloc_host(sizeof(struct at91mci_host), &pdev->dev); if (!mmc) { ret = -ENOMEM; dev_dbg(&pdev->dev, "couldn't allocate mmc host\n"); goto fail6; } mmc->ops = &at91_mci_ops; mmc->f_min = 375000; mmc->f_max = 25000000; mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; mmc->caps = 0; mmc->max_blk_size = MCI_MAXBLKSIZE; mmc->max_blk_count = MCI_BLKATONCE; mmc->max_req_size = MCI_BUFSIZE; mmc->max_segs = MCI_BLKATONCE; mmc->max_seg_size = MCI_BUFSIZE; host = mmc_priv(mmc); host->mmc = mmc; host->bus_mode = 0; host->board = pdev->dev.platform_data; if (host->board->wire4) { if (at91mci_is_mci1rev2xx()) mmc->caps |= MMC_CAP_4_BIT_DATA; else dev_warn(&pdev->dev, "4 wire bus mode not supported" " - using 1 wire\n"); } host->buffer = dma_alloc_coherent(&pdev->dev, MCI_BUFSIZE, &host->physical_address, GFP_KERNEL); if (!host->buffer) { ret = -ENOMEM; dev_err(&pdev->dev, "Can't allocate transmit buffer\n"); goto fail5; } /* Add SDIO capability when available */ if (at91mci_is_mci1rev2xx()) { /* at91mci MCI1 rev2xx sdio interrupt erratum */ if (host->board->wire4 || !host->board->slot_b) mmc->caps |= MMC_CAP_SDIO_IRQ; } /* * Reserve GPIOs ... board init code makes sure these pins are set * up as GPIOs with the right direction (input, except for vcc) */ if (host->board->det_pin) { ret = gpio_request(host->board->det_pin, "mmc_detect"); if (ret < 0) { dev_dbg(&pdev->dev, "couldn't claim card detect pin\n"); goto fail4b; } } if (host->board->wp_pin) { ret = gpio_request(host->board->wp_pin, "mmc_wp"); if (ret < 0) { dev_dbg(&pdev->dev, "couldn't claim wp sense pin\n"); goto fail4; } } if (host->board->vcc_pin) { ret = gpio_request(host->board->vcc_pin, "mmc_vcc"); if (ret < 0) { dev_dbg(&pdev->dev, "couldn't claim vcc switch pin\n"); goto fail3; } } /* * Get Clock */ host->mci_clk = clk_get(&pdev->dev, "mci_clk"); if (IS_ERR(host->mci_clk)) { ret = -ENODEV; dev_dbg(&pdev->dev, "no mci_clk?\n"); goto fail2; } /* * Map I/O region */ host->baseaddr = ioremap(res->start, resource_size(res)); if (!host->baseaddr) { ret = -ENOMEM; goto fail1; } /* * Reset hardware */ clk_enable(host->mci_clk); /* Enable the peripheral clock */ at91_mci_disable(host); at91_mci_enable(host); /* * Allocate the MCI interrupt */ host->irq = platform_get_irq(pdev, 0); ret = request_irq(host->irq, at91_mci_irq, IRQF_SHARED, mmc_hostname(mmc), host); if (ret) { dev_dbg(&pdev->dev, "request MCI interrupt failed\n"); goto fail0; } setup_timer(&host->timer, at91_timeout_timer, (unsigned long)host); platform_set_drvdata(pdev, mmc); /* * Add host to MMC layer */ if (host->board->det_pin) { host->present = !gpio_get_value(host->board->det_pin); } else host->present = -1; mmc_add_host(mmc); /* * monitor card insertion/removal if we can */ if (host->board->det_pin) { ret = request_irq(gpio_to_irq(host->board->det_pin), at91_mmc_det_irq, 0, mmc_hostname(mmc), host); if (ret) dev_warn(&pdev->dev, "request MMC detect irq failed\n"); else device_init_wakeup(&pdev->dev, 1); } pr_debug("Added MCI driver\n"); return 0; fail0: clk_disable(host->mci_clk); iounmap(host->baseaddr); fail1: clk_put(host->mci_clk); fail2: if (host->board->vcc_pin) gpio_free(host->board->vcc_pin); fail3: if (host->board->wp_pin) gpio_free(host->board->wp_pin); fail4: if (host->board->det_pin) gpio_free(host->board->det_pin); fail4b: if (host->buffer) dma_free_coherent(&pdev->dev, MCI_BUFSIZE, host->buffer, host->physical_address); fail5: mmc_free_host(mmc); fail6: release_mem_region(res->start, resource_size(res)); dev_err(&pdev->dev, "probe failed, err %d\n", ret); return ret; }
static int __devinit exynos_ohci_probe(struct platform_device *pdev) { struct s5p_ohci_platdata *pdata; struct exynos_ohci_hcd *exynos_ohci; struct usb_hcd *hcd; struct ohci_hcd *ohci; struct resource *res; int irq; int err; pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "No platform data defined\n"); return -EINVAL; } exynos_ohci = kzalloc(sizeof(struct exynos_ohci_hcd), GFP_KERNEL); if (!exynos_ohci) return -ENOMEM; exynos_ohci->dev = &pdev->dev; hcd = usb_create_hcd(&exynos_ohci_hc_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Unable to create HCD\n"); err = -ENOMEM; goto fail_hcd; } exynos_ohci->hcd = hcd; exynos_ohci->clk = clk_get(&pdev->dev, "usbhost"); if (IS_ERR(exynos_ohci->clk)) { dev_err(&pdev->dev, "Failed to get usbhost clock\n"); err = PTR_ERR(exynos_ohci->clk); goto fail_clk; } err = clk_enable(exynos_ohci->clk); if (err) goto fail_clken; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Failed to get I/O memory\n"); err = -ENXIO; goto fail_io; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = ioremap(res->start, resource_size(res)); if (!hcd->regs) { dev_err(&pdev->dev, "Failed to remap I/O memory\n"); err = -ENOMEM; goto fail_io; } irq = platform_get_irq(pdev, 0); if (!irq) { dev_err(&pdev->dev, "Failed to get IRQ\n"); err = -ENODEV; goto fail; } if (pdata->phy_init) pdata->phy_init(pdev, S5P_USB_PHY_HOST); ohci = hcd_to_ohci(hcd); ohci_hcd_init(ohci); err = usb_add_hcd(hcd, irq, IRQF_SHARED); if (err) { dev_err(&pdev->dev, "Failed to add USB HCD\n"); goto fail; } platform_set_drvdata(pdev, exynos_ohci); return 0; fail: iounmap(hcd->regs); fail_io: clk_disable(exynos_ohci->clk); fail_clken: clk_put(exynos_ohci->clk); fail_clk: usb_put_hcd(hcd); fail_hcd: kfree(exynos_ohci); return err; }
static int __devinit s5p_ehci_probe(struct platform_device *pdev) { struct s5p_ehci_platdata *pdata; struct s5p_ehci_hcd *s5p_ehci; struct usb_hcd *hcd; struct ehci_hcd *ehci; struct resource *res; int irq; int err; pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "No platform data defined\n"); return -EINVAL; } s5p_ehci = kzalloc(sizeof(struct s5p_ehci_hcd), GFP_KERNEL); if (!s5p_ehci) return -ENOMEM; s5p_ehci->dev = &pdev->dev; hcd = usb_create_hcd(&s5p_ehci_hc_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "Unable to create HCD\n"); err = -ENOMEM; goto fail_hcd; } s5p_ehci->hcd = hcd; s5p_ehci->clk = clk_get(&pdev->dev, "usbhost"); if (IS_ERR(s5p_ehci->clk)) { dev_err(&pdev->dev, "Failed to get usbhost clock\n"); err = PTR_ERR(s5p_ehci->clk); goto fail_clk; } err = clk_enable(s5p_ehci->clk); if (err) goto fail_clken; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Failed to get I/O memory\n"); err = -ENXIO; goto fail_io; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = ioremap(res->start, resource_size(res)); if (!hcd->regs) { dev_err(&pdev->dev, "Failed to remap I/O memory\n"); err = -ENOMEM; goto fail_io; } irq = platform_get_irq(pdev, 0); if (!irq) { dev_err(&pdev->dev, "Failed to get IRQ\n"); err = -ENODEV; goto fail; } platform_set_drvdata(pdev, s5p_ehci); s5p_ehci_phy_init(pdev); ehci = hcd_to_ehci(hcd); ehci->caps = hcd->regs; ehci->regs = hcd->regs + HC_LENGTH(ehci, readl(&ehci->caps->hc_capbase)); dbg_hcs_params(ehci, "reset"); dbg_hcc_params(ehci, "reset"); /* cache this readonly data; minimize chip reads */ ehci->hcs_params = readl(&ehci->caps->hcs_params); err = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); if (err) { dev_err(&pdev->dev, "Failed to add USB HCD\n"); goto fail; } /* * EHCI root hubs are expected to handle remote wakeup. * So, wakeup flag init defaults for root hubs. */ device_wakeup_enable(&hcd->self.root_hub->dev); create_ehci_sys_file(ehci); s5p_ehci->power_on = 1; #ifdef CONFIG_USB_SUSPEND pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); pm_runtime_get(hcd->self.controller); #endif return 0; fail: iounmap(hcd->regs); fail_io: clk_disable(s5p_ehci->clk); fail_clken: clk_put(s5p_ehci->clk); fail_clk: usb_put_hcd(hcd); fail_hcd: kfree(s5p_ehci); return err; }
static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) { struct sh_mobile_sdhi *priv; struct tmio_mmc_data *mmc_data; struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; struct tmio_mmc_host *host; char clk_name[8]; int irq, ret, i = 0; bool multiplexed_isr = true; priv = kzalloc(sizeof(struct sh_mobile_sdhi), GFP_KERNEL); if (priv == NULL) { dev_err(&pdev->dev, "kzalloc failed\n"); return -ENOMEM; } mmc_data = &priv->mmc_data; p->pdata = mmc_data; snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id); priv->clk = clk_get(&pdev->dev, clk_name); if (IS_ERR(priv->clk)) { dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); ret = PTR_ERR(priv->clk); goto eclkget; } clk_enable(priv->clk); mmc_data->hclk = clk_get_rate(priv->clk); mmc_data->set_pwr = sh_mobile_sdhi_set_pwr; mmc_data->get_cd = sh_mobile_sdhi_get_cd; mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED; if (p) { mmc_data->flags = p->tmio_flags; if (mmc_data->flags & TMIO_MMC_HAS_IDLE_WAIT) mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; mmc_data->ocr_mask = p->tmio_ocr_mask; mmc_data->capabilities |= p->tmio_caps; if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) { priv->param_tx.slave_id = p->dma_slave_tx; priv->param_rx.slave_id = p->dma_slave_rx; priv->dma_priv.chan_priv_tx = &priv->param_tx; priv->dma_priv.chan_priv_rx = &priv->param_rx; priv->dma_priv.alignment_shift = 1; /* 2-byte alignment */ mmc_data->dma = &priv->dma_priv; } } /* * All SDHI blocks support 2-byte and larger block sizes in 4-bit * bus width mode. */ mmc_data->flags |= TMIO_MMC_BLKSZ_2BYTES; /* * All SDHI blocks support SDIO IRQ signalling. */ mmc_data->flags |= TMIO_MMC_SDIO_IRQ; ret = tmio_mmc_host_probe(&host, pdev, mmc_data); if (ret < 0) goto eprobe; /* * Allow one or more specific (named) ISRs or * one or more multiplexed (un-named) ISRs. */ irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_CARD_DETECT); if (irq >= 0) { multiplexed_isr = false; ret = request_irq(irq, tmio_mmc_card_detect_irq, 0, dev_name(&pdev->dev), host); if (ret) goto eirq_card_detect; } irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_SDIO); if (irq >= 0) { multiplexed_isr = false; ret = request_irq(irq, tmio_mmc_sdio_irq, 0, dev_name(&pdev->dev), host); if (ret) goto eirq_sdio; } irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_SDCARD); if (irq >= 0) { multiplexed_isr = false; ret = request_irq(irq, tmio_mmc_sdcard_irq, 0, dev_name(&pdev->dev), host); if (ret) goto eirq_sdcard; } else if (!multiplexed_isr) { dev_err(&pdev->dev, "Principal SD-card IRQ is missing among named interrupts\n"); ret = irq; goto eirq_sdcard; } if (multiplexed_isr) { while (1) { irq = platform_get_irq(pdev, i); if (irq < 0) break; i++; ret = request_irq(irq, tmio_mmc_irq, 0, dev_name(&pdev->dev), host); if (ret) goto eirq_multiplexed; } /* There must be at least one IRQ source */ if (!i) goto eirq_multiplexed; } dev_info(&pdev->dev, "%s base at 0x%08lx clock rate %u MHz\n", mmc_hostname(host->mmc), (unsigned long) (platform_get_resource(pdev,IORESOURCE_MEM, 0)->start), mmc_data->hclk / 1000000); return ret; eirq_multiplexed: while (i--) { irq = platform_get_irq(pdev, i); free_irq(irq, host); } eirq_sdcard: irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_SDIO); if (irq >= 0) free_irq(irq, host); eirq_sdio: irq = platform_get_irq_byname(pdev, SH_MOBILE_SDHI_IRQ_CARD_DETECT); if (irq >= 0) free_irq(irq, host); eirq_card_detect: tmio_mmc_host_remove(host); eprobe: clk_disable(priv->clk); clk_put(priv->clk); eclkget: kfree(priv); return ret; }
static int tegra_ehci_probe(struct platform_device *pdev) { struct resource *res; struct usb_hcd *hcd; struct tegra_ehci_hcd *tegra; int err = 0; int irq; pr_info("%s: ehci.id = %d\n", __func__, pdev->id); device_ehci_shutdown = false; tegra = devm_kzalloc(&pdev->dev, sizeof(struct tegra_ehci_hcd), GFP_KERNEL); if (!tegra) { dev_err(&pdev->dev, "memory alloc failed\n"); return -ENOMEM; } mutex_init(&tegra->sync_lock); hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) { dev_err(&pdev->dev, "unable to create HCD\n"); return -ENOMEM; } platform_set_drvdata(pdev, tegra); //+Sophia:0608 tegra->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(tegra->clk)) { dev_err(&pdev->dev, "Can't get ehci clock\n"); err = PTR_ERR(tegra->clk); goto fail_io; } err = clk_enable(tegra->clk); if (err) goto fail_clken; tegra_periph_reset_assert(tegra->clk); udelay(2); tegra_periph_reset_deassert(tegra->clk); udelay(2); //+Sophia:0608 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get I/O memory\n"); err = -ENXIO; goto fail_io; } hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = ioremap(res->start, resource_size(res)); if (!hcd->regs) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); err = -ENOMEM; goto fail_io; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get IRQ\n"); err = -ENODEV; goto fail_irq; } set_irq_flags(irq, IRQF_VALID); tegra->irq = irq; tegra->phy = tegra_usb_phy_open(pdev); if (IS_ERR(tegra->phy)) { dev_err(&pdev->dev, "failed to open USB phy\n"); err = -ENXIO; goto fail_irq; } err = tegra_usb_phy_power_on(tegra->phy); if (err) { dev_err(&pdev->dev, "failed to power on the phy\n"); goto fail_phy; } err = tegra_usb_phy_init(tegra->phy); if (err) { dev_err(&pdev->dev, "failed to init the phy\n"); goto fail_phy; } err = usb_add_hcd(hcd, irq, IRQF_SHARED | IRQF_TRIGGER_HIGH); if (err) { dev_err(&pdev->dev, "Failed to add USB HCD, error=%d\n", err); goto fail_phy; } err = enable_irq_wake(tegra->irq); if (err < 0) { dev_warn(&pdev->dev, "Couldn't enable USB host mode wakeup, irq=%d, " "error=%d\n", irq, err); err = 0; tegra->irq = 0; } tegra->ehci = hcd_to_ehci(hcd); //htc++ #ifdef CONFIG_QCT_9K_MODEM if (Modem_is_QCT_MDM9K()) { extern struct platform_device tegra_ehci2_device; if (&tegra_ehci2_device == pdev) { mdm_hsic_ehci_hcd = tegra->ehci; mdm_hsic_usb_hcd = hcd; mdm_hsic_phy = tegra->phy; pr_info("%s:: mdm_hsic_ehci_hcd = %x, mdm_hsic_usb_hcd = %x, mdm_hsic_phy = %x\n", __func__, (unsigned int)mdm_hsic_ehci_hcd, (unsigned int)mdm_hsic_usb_hcd, (unsigned int)mdm_hsic_phy); } } #endif //CONFIG_QCT_9K_MODEM //htc-- #ifdef CONFIG_USB_OTG_UTILS if (tegra_usb_phy_otg_supported(tegra->phy)) { tegra->transceiver = otg_get_transceiver(); if (tegra->transceiver) otg_set_host(tegra->transceiver, &hcd->self); } #endif return err; fail_phy: tegra_usb_phy_close(tegra->phy); fail_irq: iounmap(hcd->regs); fail_clken: clk_put(tegra->clk); fail_io: usb_put_hcd(hcd); return err; }
static int __init keystone_timer_init(struct device_node *np) { struct clock_event_device *event_dev = &timer.event_dev; unsigned long rate; struct clk *clk; int irq, error; irq = irq_of_parse_and_map(np, 0); if (!irq) { pr_err("%s: failed to map interrupts\n", __func__); return -EINVAL; } timer.base = of_iomap(np, 0); if (!timer.base) { pr_err("%s: failed to map registers\n", __func__); return -ENXIO; } clk = of_clk_get(np, 0); if (IS_ERR(clk)) { pr_err("%s: failed to get clock\n", __func__); iounmap(timer.base); return PTR_ERR(clk); } error = clk_prepare_enable(clk); if (error) { pr_err("%s: failed to enable clock\n", __func__); goto err; } rate = clk_get_rate(clk); /* disable, use internal clock source */ keystone_timer_writel(0, TCR); /* here we have to be sure the timer has been disabled */ keystone_timer_barrier(); /* reset timer as 64-bit, no pre-scaler, plus features are disabled */ keystone_timer_writel(0, TGCR); /* unreset timer */ keystone_timer_writel(TGCR_TIM_UNRESET_MASK, TGCR); /* init counter to zero */ keystone_timer_writel(0, TIM12); keystone_timer_writel(0, TIM34); timer.hz_period = DIV_ROUND_UP(rate, HZ); /* enable timer interrupts */ keystone_timer_writel(INTCTLSTAT_ENINT_MASK, INTCTLSTAT); error = request_irq(irq, keystone_timer_interrupt, IRQF_TIMER, TIMER_NAME, event_dev); if (error) { pr_err("%s: failed to setup irq\n", __func__); goto err; } /* setup clockevent */ event_dev->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; event_dev->set_next_event = keystone_set_next_event; event_dev->set_state_shutdown = keystone_shutdown; event_dev->set_state_periodic = keystone_set_periodic; event_dev->set_state_oneshot = keystone_shutdown; event_dev->cpumask = cpu_possible_mask; event_dev->owner = THIS_MODULE; event_dev->name = TIMER_NAME; event_dev->irq = irq; clockevents_config_and_register(event_dev, rate, 1, ULONG_MAX); pr_info("keystone timer clock @%lu Hz\n", rate); return 0; err: clk_put(clk); iounmap(timer.base); return error; }
static int exynos4_ahci_init(struct device *dev, void __iomem *mmio) { struct clk *clk_sata, *clk_sataphy, *clk_sclk_sata; int val, ret; phy_base = ioremap(EXYNOS4_PA_SATAPHY, SZ_64K); if (!phy_base) { dev_err(dev, "failed to allocate memory for SATA PHY\n"); return -ENOMEM; } phy_ctrl = ioremap(EXYNOS4_PA_SATAPHY_CTRL, SZ_16); if (!phy_ctrl) { dev_err(dev, "failed to allocate memory for SATA PHY CTRL\n"); ret = -ENOMEM; goto err1; } clk_sata = clk_get(dev, "sata"); if (IS_ERR(clk_sata)) { dev_err(dev, "failed to get sata clock\n"); ret = PTR_ERR(clk_sata); clk_sata = NULL; goto err2; } clk_enable(clk_sata); clk_sataphy = clk_get(dev, "sataphy"); if (IS_ERR(clk_sataphy)) { dev_err(dev, "failed to get sataphy clock\n"); ret = PTR_ERR(clk_sataphy); clk_sataphy = NULL; goto err3; } clk_enable(clk_sataphy); clk_sclk_sata = clk_get(dev, "sclk_sata"); if (IS_ERR(clk_sclk_sata)) { dev_err(dev, "failed to get sclk_sata\n"); ret = PTR_ERR(clk_sclk_sata); clk_sclk_sata = NULL; goto err4; } clk_enable(clk_sclk_sata); clk_set_rate(clk_sclk_sata, SCLK_SATA_FREQ); __raw_writel(S5P_PMU_SATA_PHY_CONTROL_EN, S5P_PMU_SATA_PHY_CONTROL); /* */ val = SATA_CTRL1_RST_PMALIVE_N | SATA_CTRL1_RST_RXOOB_N | SATA_CTRL1_RST_RX_N | SATA_CTRL1_RST_TX_N; __raw_writel(val, phy_ctrl + SATA_CTRL1); /* */ val = SATA_CTRL0_RX_DATA_VALID(3) | SATA_CTRL0_SPEED_MODE | SATA_CTRL0_PHY_POR_N; __raw_writel(val, phy_ctrl + SATA_CTRL0); /* */ __raw_writel(0x1, mmio + HOST_PORTS_IMPL); return ahci_phy_init(mmio); err4: clk_disable(clk_sataphy); clk_put(clk_sataphy); err3: clk_disable(clk_sata); clk_put(clk_sata); err2: iounmap(phy_ctrl); err1: iounmap(phy_base); return ret; }
static int __devinit s3cmci_probe(struct platform_device *pdev, int is2440) { struct s3cmci_host *host; struct mmc_host *mmc; int ret; mmc = mmc_alloc_host(sizeof(struct s3cmci_host), &pdev->dev); if (!mmc) { ret = -ENOMEM; goto probe_out; } host = mmc_priv(mmc); host->mmc = mmc; host->pdev = pdev; host->is2440 = is2440; host->pdata = pdev->dev.platform_data; if (!host->pdata) { pdev->dev.platform_data = &s3cmci_def_pdata; host->pdata = &s3cmci_def_pdata; } spin_lock_init(&host->complete_lock); tasklet_init(&host->pio_tasklet, pio_tasklet, (unsigned long) host); if (is2440) { host->sdiimsk = S3C2440_SDIIMSK; host->sdidata = S3C2440_SDIDATA; host->clk_div = 1; } else { host->sdiimsk = S3C2410_SDIIMSK; host->sdidata = S3C2410_SDIDATA; host->clk_div = 2; } host->dodma = 0; host->complete_what = COMPLETION_NONE; host->pio_active = XFER_NONE; host->dma = S3CMCI_DMA; host->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!host->mem) { dev_err(&pdev->dev, "failed to get io memory region resouce.\n"); ret = -ENOENT; goto probe_free_host; } host->mem = request_mem_region(host->mem->start, RESSIZE(host->mem), pdev->name); if (!host->mem) { dev_err(&pdev->dev, "failed to request io memory region.\n"); ret = -ENOENT; goto probe_free_host; } host->base = ioremap(host->mem->start, RESSIZE(host->mem)); if (!host->base) { dev_err(&pdev->dev, "failed to ioremap() io memory region.\n"); ret = -EINVAL; goto probe_free_mem_region; } host->irq = platform_get_irq(pdev, 0); if (host->irq == 0) { dev_err(&pdev->dev, "failed to get interrupt resouce.\n"); ret = -EINVAL; goto probe_iounmap; } if (request_irq(host->irq, s3cmci_irq, 0, DRIVER_NAME, host)) { dev_err(&pdev->dev, "failed to request mci interrupt.\n"); ret = -ENOENT; goto probe_iounmap; } /* We get spurious interrupts even when we have set the IMSK * register to ignore everything, so use disable_irq() to make * ensure we don't lock the system with un-serviceable requests. */ disable_irq(host->irq); host->irq_cd = s3c2410_gpio_getirq(host->pdata->gpio_detect); if (host->irq_cd >= 0) { if (request_irq(host->irq_cd, s3cmci_irq_cd, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, DRIVER_NAME, host)) { dev_err(&pdev->dev, "can't get card detect irq.\n"); ret = -ENOENT; goto probe_free_irq; } } else { dev_warn(&pdev->dev, "host detect has no irq available\n"); s3c2410_gpio_cfgpin(host->pdata->gpio_detect, S3C2410_GPIO_INPUT); } if (host->pdata->gpio_wprotect) s3c2410_gpio_cfgpin(host->pdata->gpio_wprotect, S3C2410_GPIO_INPUT); if (s3c2410_dma_request(S3CMCI_DMA, &s3cmci_dma_client, NULL) < 0) { dev_err(&pdev->dev, "unable to get DMA channel.\n"); ret = -EBUSY; goto probe_free_irq_cd; } host->clk = clk_get(&pdev->dev, "sdi"); if (IS_ERR(host->clk)) { dev_err(&pdev->dev, "failed to find clock source.\n"); ret = PTR_ERR(host->clk); host->clk = NULL; goto probe_free_host; } ret = clk_enable(host->clk); if (ret) { dev_err(&pdev->dev, "failed to enable clock source.\n"); goto clk_free; } host->clk_rate = clk_get_rate(host->clk); mmc->ops = &s3cmci_ops; mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; mmc->caps = MMC_CAP_4_BIT_DATA; mmc->f_min = host->clk_rate / (host->clk_div * 256); mmc->f_max = host->clk_rate / host->clk_div; if (host->pdata->ocr_avail) mmc->ocr_avail = host->pdata->ocr_avail; mmc->max_blk_count = 4095; mmc->max_blk_size = 4095; mmc->max_req_size = 4095 * 512; mmc->max_seg_size = mmc->max_req_size; mmc->max_phys_segs = 128; mmc->max_hw_segs = 128; dbg(host, dbg_debug, "probe: mode:%s mapped mci_base:%p irq:%u irq_cd:%u dma:%u.\n", (host->is2440?"2440":""), host->base, host->irq, host->irq_cd, host->dma); ret = mmc_add_host(mmc); if (ret) { dev_err(&pdev->dev, "failed to add mmc host.\n"); goto free_dmabuf; } platform_set_drvdata(pdev, mmc); dev_info(&pdev->dev, "initialisation done.\n"); return 0; free_dmabuf: clk_disable(host->clk); clk_free: clk_put(host->clk); probe_free_irq_cd: if (host->irq_cd >= 0) free_irq(host->irq_cd, host); probe_free_irq: free_irq(host->irq, host); probe_iounmap: iounmap(host->base); probe_free_mem_region: release_mem_region(host->mem->start, RESSIZE(host->mem)); probe_free_host: mmc_free_host(mmc); probe_out: return ret; }
static int msm_iommu_probe(struct platform_device *pdev) { struct resource *r, *r2; struct clk *iommu_clk = NULL; struct clk *iommu_pclk = NULL; struct msm_iommu_drvdata *drvdata; struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data; void __iomem *regs_base; resource_size_t len; int ret, par; if (pdev->id == -1) { msm_iommu_root_dev = pdev; return 0; } drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); if (!drvdata) { ret = -ENOMEM; goto fail; } if (!iommu_dev) { ret = -ENODEV; goto fail; } iommu_pclk = clk_get_sys("msm_iommu", "iface_clk"); if (IS_ERR(iommu_pclk)) { ret = -ENODEV; goto fail; } ret = clk_prepare_enable(iommu_pclk); if (ret) goto fail_enable; iommu_clk = clk_get(&pdev->dev, "core_clk"); if (!IS_ERR(iommu_clk)) { if (clk_get_rate(iommu_clk) == 0) { ret = clk_round_rate(iommu_clk, 1); clk_set_rate(iommu_clk, ret); } ret = clk_prepare_enable(iommu_clk); if (ret) { clk_put(iommu_clk); goto fail_pclk; } } else iommu_clk = NULL; r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "physbase"); if (!r) { ret = -ENODEV; goto fail_clk; } len = resource_size(r); r2 = request_mem_region(r->start, len, r->name); if (!r2) { pr_err("Could not request memory region: start=%p, len=%d\n", (void *) r->start, len); ret = -EBUSY; goto fail_clk; } regs_base = ioremap(r2->start, len); if (!regs_base) { pr_err("Could not ioremap: start=%p, len=%d\n", (void *) r2->start, len); ret = -EBUSY; goto fail_mem; } msm_iommu_reset(regs_base, iommu_dev->ncb); SET_M(regs_base, 0, 1); SET_PAR(regs_base, 0, 0); SET_V2PCFG(regs_base, 0, 1); SET_V2PPR(regs_base, 0, 0); mb(); par = GET_PAR(regs_base, 0); SET_V2PCFG(regs_base, 0, 0); SET_M(regs_base, 0, 0); mb(); if (!par) { pr_err("%s: Invalid PAR value detected\n", iommu_dev->name); ret = -ENODEV; goto fail_io; } drvdata->pclk = iommu_pclk; drvdata->clk = iommu_clk; drvdata->base = regs_base; drvdata->ncb = iommu_dev->ncb; drvdata->ttbr_split = iommu_dev->ttbr_split; drvdata->name = iommu_dev->name; pr_info("device %s mapped at %p, with %d ctx banks\n", iommu_dev->name, regs_base, iommu_dev->ncb); platform_set_drvdata(pdev, drvdata); if (iommu_clk) clk_disable_unprepare(iommu_clk); clk_disable_unprepare(iommu_pclk); return 0; fail_io: iounmap(regs_base); fail_mem: release_mem_region(r->start, len); fail_clk: if (iommu_clk) { clk_disable_unprepare(iommu_clk); clk_put(iommu_clk); } fail_pclk: clk_disable_unprepare(iommu_pclk); fail_enable: clk_put(iommu_pclk); fail: kfree(drvdata); return ret; }
static int spear_cpufreq_driver_init(void) { struct device_node *np; const struct property *prop; struct cpufreq_frequency_table *freq_tbl; const __be32 *val; int cnt, i, ret; np = of_cpu_device_node_get(0); if (!np) { pr_err("No cpu node found"); return -ENODEV; } if (of_property_read_u32(np, "clock-latency", &spear_cpufreq.transition_latency)) spear_cpufreq.transition_latency = CPUFREQ_ETERNAL; prop = of_find_property(np, "cpufreq_tbl", NULL); if (!prop || !prop->value) { pr_err("Invalid cpufreq_tbl"); ret = -ENODEV; goto out_put_node; } cnt = prop->length / sizeof(u32); val = prop->value; freq_tbl = kmalloc(sizeof(*freq_tbl) * (cnt + 1), GFP_KERNEL); if (!freq_tbl) { ret = -ENOMEM; goto out_put_node; } for (i = 0; i < cnt; i++) { freq_tbl[i].driver_data = i; freq_tbl[i].frequency = be32_to_cpup(val++); } freq_tbl[i].driver_data = i; freq_tbl[i].frequency = CPUFREQ_TABLE_END; spear_cpufreq.freq_tbl = freq_tbl; of_node_put(np); spear_cpufreq.clk = clk_get(NULL, "cpu_clk"); if (IS_ERR(spear_cpufreq.clk)) { pr_err("Unable to get CPU clock\n"); ret = PTR_ERR(spear_cpufreq.clk); goto out_put_mem; } ret = cpufreq_register_driver(&spear_cpufreq_driver); if (!ret) return 0; pr_err("failed register driver: %d\n", ret); clk_put(spear_cpufreq.clk); out_put_mem: kfree(freq_tbl); return ret; out_put_node: of_node_put(np); return ret; }
/* * probe for dryice rtc device */ static int dryice_rtc_probe(struct platform_device *pdev) { struct resource *res; struct imxdi_dev *imxdi; int rc; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; imxdi = devm_kzalloc(&pdev->dev, sizeof(*imxdi), GFP_KERNEL); if (!imxdi) return -ENOMEM; imxdi->pdev = pdev; if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), pdev->name)) return -EBUSY; imxdi->ioaddr = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (imxdi->ioaddr == NULL) return -ENOMEM; imxdi->irq = platform_get_irq(pdev, 0); if (imxdi->irq < 0) return imxdi->irq; init_waitqueue_head(&imxdi->write_wait); INIT_WORK(&imxdi->work, dryice_work); mutex_init(&imxdi->write_mutex); imxdi->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(imxdi->clk)) return PTR_ERR(imxdi->clk); clk_enable(imxdi->clk); /* * Initialize dryice hardware */ /* mask all interrupts */ __raw_writel(0, imxdi->ioaddr + DIER); rc = devm_request_irq(&pdev->dev, imxdi->irq, dryice_norm_irq, IRQF_SHARED, pdev->name, imxdi); if (rc) { dev_warn(&pdev->dev, "interrupt not available.\n"); goto err; } /* put dryice into valid state */ if (__raw_readl(imxdi->ioaddr + DSR) & DSR_NVF) { rc = di_write_wait(imxdi, DSR_NVF | DSR_SVF, DSR); if (rc) goto err; } /* initialize alarm */ rc = di_write_wait(imxdi, DCAMR_UNSET, DCAMR); if (rc) goto err; rc = di_write_wait(imxdi, 0, DCALR); if (rc) goto err; /* clear alarm flag */ if (__raw_readl(imxdi->ioaddr + DSR) & DSR_CAF) { rc = di_write_wait(imxdi, DSR_CAF, DSR); if (rc) goto err; } /* the timer won't count if it has never been written to */ if (__raw_readl(imxdi->ioaddr + DTCMR) == 0) { rc = di_write_wait(imxdi, 0, DTCMR); if (rc) goto err; } /* start keeping time */ if (!(__raw_readl(imxdi->ioaddr + DCR) & DCR_TCE)) { rc = di_write_wait(imxdi, __raw_readl(imxdi->ioaddr + DCR) | DCR_TCE, DCR); if (rc) goto err; } platform_set_drvdata(pdev, imxdi); imxdi->rtc = rtc_device_register(pdev->name, &pdev->dev, &dryice_rtc_ops, THIS_MODULE); if (IS_ERR(imxdi->rtc)) { rc = PTR_ERR(imxdi->rtc); goto err; } return 0; err: clk_disable(imxdi->clk); clk_put(imxdi->clk); return rc; }
static int __devinit nmk_gpio_probe(struct platform_device *dev) { struct nmk_gpio_platform_data *pdata = dev->dev.platform_data; struct nmk_gpio_chip *nmk_chip; struct gpio_chip *chip; struct resource *res; struct clk *clk; int secondary_irq; int irq; int ret; if (!pdata) return -ENODEV; res = platform_get_resource(dev, IORESOURCE_MEM, 0); if (!res) { ret = -ENOENT; goto out; } irq = platform_get_irq(dev, 0); if (irq < 0) { ret = irq; goto out; } secondary_irq = platform_get_irq(dev, 1); if (secondary_irq >= 0 && !pdata->get_secondary_status) { ret = -EINVAL; goto out; } if (request_mem_region(res->start, resource_size(res), dev_name(&dev->dev)) == NULL) { ret = -EBUSY; goto out; } clk = clk_get(&dev->dev, NULL); if (IS_ERR(clk)) { ret = PTR_ERR(clk); goto out_release; } clk_enable(clk); nmk_chip = kzalloc(sizeof(*nmk_chip), GFP_KERNEL); if (!nmk_chip) { ret = -ENOMEM; goto out_clk; } /* * The virt address in nmk_chip->addr is in the nomadik register space, * so we can simply convert the resource address, without remapping */ nmk_chip->bank = dev->id; nmk_chip->clk = clk; nmk_chip->addr = io_p2v(res->start); nmk_chip->chip = nmk_gpio_template; nmk_chip->parent_irq = irq; nmk_chip->secondary_parent_irq = secondary_irq; nmk_chip->get_secondary_status = pdata->get_secondary_status; nmk_chip->set_ioforce = pdata->set_ioforce; spin_lock_init(&nmk_chip->lock); chip = &nmk_chip->chip; chip->base = pdata->first_gpio; chip->ngpio = pdata->num_gpio; chip->label = pdata->name ?: dev_name(&dev->dev); chip->dev = &dev->dev; chip->owner = THIS_MODULE; ret = gpiochip_add(&nmk_chip->chip); if (ret) goto out_free; BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips)); nmk_gpio_chips[nmk_chip->bank] = nmk_chip; platform_set_drvdata(dev, nmk_chip); nmk_gpio_init_irq(nmk_chip); dev_info(&dev->dev, "Bits %i-%i at address %p\n", nmk_chip->chip.base, nmk_chip->chip.base+31, nmk_chip->addr); return 0; out_free: kfree(nmk_chip); out_clk: clk_disable(clk); clk_put(clk); out_release: release_mem_region(res->start, resource_size(res)); out: dev_err(&dev->dev, "Failure %i for GPIO %i-%i\n", ret, pdata->first_gpio, pdata->first_gpio+31); return ret; }
static void __init ap4evb_init(void) { struct pm_domain_device domain_devices[] = { { "A4LC", &lcdc1_device, }, { "A4LC", &lcdc_device, }, { "A4MP", &fsi_device, }, { "A3SP", &sh_mmcif_device, }, { "A3SP", &sdhi0_device, }, { "A3SP", &sdhi1_device, }, { "A4R", &ceu_device, }, }; u32 srcr4; struct clk *clk; regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers, ARRAY_SIZE(fixed1v8_power_consumers), 1800000); regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers, ARRAY_SIZE(fixed3v3_power_consumers), 3300000); regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies)); /* External clock source */ clk_set_rate(&sh7372_dv_clki_clk, 27000000); sh7372_pinmux_init(); /* enable SCIFA0 */ gpio_request(GPIO_FN_SCIFA0_TXD, NULL); gpio_request(GPIO_FN_SCIFA0_RXD, NULL); /* enable SMSC911X */ gpio_request(GPIO_FN_CS5A, NULL); gpio_request(GPIO_FN_IRQ6_39, NULL); /* enable Debug switch (S6) */ gpio_request(GPIO_PORT32, NULL); gpio_request(GPIO_PORT33, NULL); gpio_request(GPIO_PORT34, NULL); gpio_request(GPIO_PORT35, NULL); gpio_direction_input(GPIO_PORT32); gpio_direction_input(GPIO_PORT33); gpio_direction_input(GPIO_PORT34); gpio_direction_input(GPIO_PORT35); gpio_export(GPIO_PORT32, 0); gpio_export(GPIO_PORT33, 0); gpio_export(GPIO_PORT34, 0); gpio_export(GPIO_PORT35, 0); /* SDHI0 */ gpio_request(GPIO_FN_SDHICD0, NULL); gpio_request(GPIO_FN_SDHIWP0, NULL); gpio_request(GPIO_FN_SDHICMD0, NULL); gpio_request(GPIO_FN_SDHICLK0, NULL); gpio_request(GPIO_FN_SDHID0_3, NULL); gpio_request(GPIO_FN_SDHID0_2, NULL); gpio_request(GPIO_FN_SDHID0_1, NULL); gpio_request(GPIO_FN_SDHID0_0, NULL); /* SDHI1 */ gpio_request(GPIO_FN_SDHICMD1, NULL); gpio_request(GPIO_FN_SDHICLK1, NULL); gpio_request(GPIO_FN_SDHID1_3, NULL); gpio_request(GPIO_FN_SDHID1_2, NULL); gpio_request(GPIO_FN_SDHID1_1, NULL); gpio_request(GPIO_FN_SDHID1_0, NULL); /* MMCIF */ gpio_request(GPIO_FN_MMCD0_0, NULL); gpio_request(GPIO_FN_MMCD0_1, NULL); gpio_request(GPIO_FN_MMCD0_2, NULL); gpio_request(GPIO_FN_MMCD0_3, NULL); gpio_request(GPIO_FN_MMCD0_4, NULL); gpio_request(GPIO_FN_MMCD0_5, NULL); gpio_request(GPIO_FN_MMCD0_6, NULL); gpio_request(GPIO_FN_MMCD0_7, NULL); gpio_request(GPIO_FN_MMCCMD0, NULL); gpio_request(GPIO_FN_MMCCLK0, NULL); /* USB enable */ gpio_request(GPIO_FN_VBUS0_1, NULL); gpio_request(GPIO_FN_IDIN_1_18, NULL); gpio_request(GPIO_FN_PWEN_1_115, NULL); gpio_request(GPIO_FN_OVCN_1_114, NULL); gpio_request(GPIO_FN_EXTLP_1, NULL); gpio_request(GPIO_FN_OVCN2_1, NULL); /* setup USB phy */ __raw_writew(0x8a0a, IOMEM(0xE6058130)); /* USBCR4 */ /* enable FSI2 port A (ak4643) */ gpio_request(GPIO_FN_FSIAIBT, NULL); gpio_request(GPIO_FN_FSIAILR, NULL); gpio_request(GPIO_FN_FSIAISLD, NULL); gpio_request(GPIO_FN_FSIAOSLD, NULL); gpio_request(GPIO_PORT161, NULL); gpio_direction_output(GPIO_PORT161, 0); /* slave */ gpio_request(GPIO_PORT9, NULL); gpio_request(GPIO_PORT10, NULL); gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */ gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */ /* card detect pin for MMC slot (CN7) */ gpio_request(GPIO_PORT41, NULL); gpio_direction_input(GPIO_PORT41); /* setup FSI2 port B (HDMI) */ gpio_request(GPIO_FN_FSIBCK, NULL); __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */ /* set SPU2 clock to 119.6 MHz */ clk = clk_get(NULL, "spu_clk"); if (!IS_ERR(clk)) { clk_set_rate(clk, clk_round_rate(clk, 119600000)); clk_put(clk); } /* * set irq priority, to avoid sound chopping * when NFS rootfs is used * FSI(3) > SMSC911X(2) */ intc_set_priority(IRQ_FSI, 3); i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices)); i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices)); #ifdef CONFIG_AP4EVB_QHD /* * For QHD Panel (MIPI-DSI, CONFIG_AP4EVB_QHD=y) and * IRQ28 for Touch Panel, set dip switches S3, S43 as OFF, ON. */ /* enable KEYSC */ gpio_request(GPIO_FN_KEYOUT0, NULL); gpio_request(GPIO_FN_KEYOUT1, NULL); gpio_request(GPIO_FN_KEYOUT2, NULL); gpio_request(GPIO_FN_KEYOUT3, NULL); gpio_request(GPIO_FN_KEYOUT4, NULL); gpio_request(GPIO_FN_KEYIN0_136, NULL); gpio_request(GPIO_FN_KEYIN1_135, NULL); gpio_request(GPIO_FN_KEYIN2_134, NULL); gpio_request(GPIO_FN_KEYIN3_133, NULL); gpio_request(GPIO_FN_KEYIN4, NULL); /* enable TouchScreen */ irq_set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW); tsc_device.irq = IRQ28; i2c_register_board_info(1, &tsc_device, 1); /* LCDC0 */ lcdc_info.clock_source = LCDC_CLK_PERIPHERAL; lcdc_info.ch[0].interface_type = RGB24; lcdc_info.ch[0].clock_divider = 1; lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL; lcdc_info.ch[0].panel_cfg.width = 44; lcdc_info.ch[0].panel_cfg.height = 79; platform_add_devices(qhd_devices, ARRAY_SIZE(qhd_devices)); #else /* * For WVGA Panel (18-bit RGB, CONFIG_AP4EVB_WVGA=y) and * IRQ7 for Touch Panel, set dip switches S3, S43 to ON, OFF. */ gpio_request(GPIO_FN_LCDD17, NULL); gpio_request(GPIO_FN_LCDD16, NULL); gpio_request(GPIO_FN_LCDD15, NULL); gpio_request(GPIO_FN_LCDD14, NULL); gpio_request(GPIO_FN_LCDD13, NULL); gpio_request(GPIO_FN_LCDD12, NULL); gpio_request(GPIO_FN_LCDD11, NULL); gpio_request(GPIO_FN_LCDD10, NULL); gpio_request(GPIO_FN_LCDD9, NULL); gpio_request(GPIO_FN_LCDD8, NULL); gpio_request(GPIO_FN_LCDD7, NULL); gpio_request(GPIO_FN_LCDD6, NULL); gpio_request(GPIO_FN_LCDD5, NULL); gpio_request(GPIO_FN_LCDD4, NULL); gpio_request(GPIO_FN_LCDD3, NULL); gpio_request(GPIO_FN_LCDD2, NULL); gpio_request(GPIO_FN_LCDD1, NULL); gpio_request(GPIO_FN_LCDD0, NULL); gpio_request(GPIO_FN_LCDDISP, NULL); gpio_request(GPIO_FN_LCDDCK, NULL); gpio_request(GPIO_PORT189, NULL); /* backlight */ gpio_direction_output(GPIO_PORT189, 1); gpio_request(GPIO_PORT151, NULL); /* LCDDON */ gpio_direction_output(GPIO_PORT151, 1); lcdc_info.clock_source = LCDC_CLK_BUS; lcdc_info.ch[0].interface_type = RGB18; lcdc_info.ch[0].clock_divider = 3; lcdc_info.ch[0].flags = 0; lcdc_info.ch[0].panel_cfg.width = 152; lcdc_info.ch[0].panel_cfg.height = 91; /* enable TouchScreen */ irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW); tsc_device.irq = IRQ7; i2c_register_board_info(0, &tsc_device, 1); #endif /* CONFIG_AP4EVB_QHD */ /* CEU */ /* * TODO: reserve memory for V4L2 DMA buffers, when a suitable API * becomes available */ /* MIPI-CSI stuff */ gpio_request(GPIO_FN_VIO_CKO, NULL); clk = clk_get(NULL, "vck1_clk"); if (!IS_ERR(clk)) { clk_set_rate(clk, clk_round_rate(clk, 13000000)); clk_enable(clk); clk_put(clk); } sh7372_add_standard_devices(); /* HDMI */ gpio_request(GPIO_FN_HDMI_HPD, NULL); gpio_request(GPIO_FN_HDMI_CEC, NULL); /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */ #define SRCR4 IOMEM(0xe61580bc) srcr4 = __raw_readl(SRCR4); __raw_writel(srcr4 | (1 << 13), SRCR4); udelay(50); __raw_writel(srcr4 & ~(1 << 13), SRCR4); platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices)); rmobile_add_devices_to_domains(domain_devices, ARRAY_SIZE(domain_devices)); hdmi_init_pm_clock(); sh7372_pm_init(); pm_clk_add(&fsi_device.dev, "spu2"); pm_clk_add(&lcdc1_device.dev, "hdmi"); }
static int __devinit ske_keypad_probe(struct platform_device *pdev) { const struct ske_keypad_platform_data *plat = pdev->dev.platform_data; struct ske_keypad *keypad; struct input_dev *input; struct resource *res; int irq; int error; if (!plat) { dev_err(&pdev->dev, "invalid keypad platform data\n"); return -EINVAL; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get keypad irq\n"); return -EINVAL; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "missing platform resources\n"); return -EINVAL; } keypad = kzalloc(sizeof(struct ske_keypad), GFP_KERNEL); input = input_allocate_device(); if (!keypad || !input) { dev_err(&pdev->dev, "failed to allocate keypad memory\n"); error = -ENOMEM; goto err_free_mem; } keypad->irq = irq; keypad->board = plat; keypad->input = input; spin_lock_init(&keypad->ske_keypad_lock); if (!request_mem_region(res->start, resource_size(res), pdev->name)) { dev_err(&pdev->dev, "failed to request I/O memory\n"); error = -EBUSY; goto err_free_mem; } keypad->reg_base = ioremap(res->start, resource_size(res)); if (!keypad->reg_base) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); error = -ENXIO; goto err_free_mem_region; } keypad->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(keypad->clk)) { dev_err(&pdev->dev, "failed to get clk\n"); error = PTR_ERR(keypad->clk); goto err_iounmap; } input->id.bustype = BUS_HOST; input->name = "ux500-ske-keypad"; input->dev.parent = &pdev->dev; input->keycode = keypad->keymap; input->keycodesize = sizeof(keypad->keymap[0]); input->keycodemax = ARRAY_SIZE(keypad->keymap); input_set_capability(input, EV_MSC, MSC_SCAN); __set_bit(EV_KEY, input->evbit); if (!plat->no_autorepeat) __set_bit(EV_REP, input->evbit); matrix_keypad_build_keymap(plat->keymap_data, SKE_KEYPAD_ROW_SHIFT, input->keycode, input->keybit); clk_enable(keypad->clk); /* go through board initialization helpers */ if (keypad->board->init) keypad->board->init(); error = ske_keypad_chip_init(keypad); if (error) { dev_err(&pdev->dev, "unable to init keypad hardware\n"); goto err_clk_disable; } error = request_threaded_irq(keypad->irq, NULL, ske_keypad_irq, IRQF_ONESHOT, "ske-keypad", keypad); if (error) { dev_err(&pdev->dev, "allocate irq %d failed\n", keypad->irq); goto err_clk_disable; } error = input_register_device(input); if (error) { dev_err(&pdev->dev, "unable to register input device: %d\n", error); goto err_free_irq; } if (plat->wakeup_enable) device_init_wakeup(&pdev->dev, true); platform_set_drvdata(pdev, keypad); return 0; err_free_irq: free_irq(keypad->irq, keypad); err_clk_disable: clk_disable(keypad->clk); clk_put(keypad->clk); err_iounmap: iounmap(keypad->reg_base); err_free_mem_region: release_mem_region(res->start, resource_size(res)); err_free_mem: input_free_device(input); kfree(keypad); return error; }
static int __devinit s3c_rtc_probe(struct platform_device *pdev) { struct rtc_device *rtc; struct rtc_time rtc_tm; struct resource *res; int ret; pr_debug("%s: probe=%p\n", __func__, pdev); /* find the IRQs */ s3c_rtc_tickno = platform_get_irq(pdev, 1); if (s3c_rtc_tickno < 0) { dev_err(&pdev->dev, "no irq for rtc tick\n"); return -ENOENT; } s3c_rtc_alarmno = platform_get_irq(pdev, 0); if (s3c_rtc_alarmno < 0) { dev_err(&pdev->dev, "no irq for alarm\n"); return -ENOENT; } pr_debug("s3c2410_rtc: tick irq %d, alarm irq %d\n", s3c_rtc_tickno, s3c_rtc_alarmno); /* get the memory region */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get memory region resource\n"); return -ENOENT; } s3c_rtc_mem = request_mem_region(res->start, res->end-res->start+1, pdev->name); if (s3c_rtc_mem == NULL) { dev_err(&pdev->dev, "failed to reserve memory region\n"); ret = -ENOENT; goto err_nores; } s3c_rtc_base = ioremap(res->start, res->end - res->start + 1); if (s3c_rtc_base == NULL) { dev_err(&pdev->dev, "failed ioremap()\n"); ret = -EINVAL; goto err_nomap; } rtc_clk = clk_get(&pdev->dev, "rtc"); if (IS_ERR(rtc_clk)) { dev_err(&pdev->dev, "failed to find rtc clock source\n"); ret = PTR_ERR(rtc_clk); rtc_clk = NULL; goto err_clk; } clk_enable(rtc_clk); /* check to see if everything is setup correctly */ s3c_rtc_enable(pdev, 1); pr_debug("s3c2410_rtc: RTCCON=%02x\n", readw(s3c_rtc_base + S3C2410_RTCCON)); device_init_wakeup(&pdev->dev, 1); /* register RTC and exit */ rtc = rtc_device_register("s3c", &pdev->dev, &s3c_rtcops, THIS_MODULE); if (IS_ERR(rtc)) { dev_err(&pdev->dev, "cannot attach rtc\n"); ret = PTR_ERR(rtc); goto err_nortc; } s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data; /* Check RTC Time */ s3c_rtc_gettime(NULL, &rtc_tm); if (rtc_valid_tm(&rtc_tm)) { rtc_tm.tm_year = 100; rtc_tm.tm_mon = 0; rtc_tm.tm_mday = 1; rtc_tm.tm_hour = 0; rtc_tm.tm_min = 0; rtc_tm.tm_sec = 0; s3c_rtc_settime(NULL, &rtc_tm); dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n"); } if (s3c_rtc_cpu_type == TYPE_S3C64XX) rtc->max_user_freq = 32768; else rtc->max_user_freq = 128; platform_set_drvdata(pdev, rtc); s3c_rtc_setfreq(&pdev->dev, 1); return 0; err_nortc: s3c_rtc_enable(pdev, 0); clk_disable(rtc_clk); clk_put(rtc_clk); err_clk: iounmap(s3c_rtc_base); err_nomap: release_resource(s3c_rtc_mem); err_nores: return ret; }
static int __init k3v2_wifi_init(void) { int ret = 0; ret = init_wifi_mem(); if (ret) { pr_err("%s: init_wifi_mem failed.\n", __func__); goto err_malloc_wifi_host; } wifi_host = kzalloc(sizeof(struct wifi_host_s), GFP_KERNEL); if (!wifi_host) { pr_err("%s: malloc wifi_host failed.\n", __func__); ret = -ENOMEM; goto err_malloc_wifi_host; } #if defined CONFIG_MACH_K3V2OEM1 wifi_host->bEnable = false; /* get 32kb clock */ wifi_host->clk = clk_get(NULL, "clk_pmu32kb"); if (IS_ERR(wifi_host->clk)) { pr_err("%s: clk_get failed\n", __func__); ret = -ENXIO; goto err_clk_get; } /* get wifiio vdd */ wifi_host->vdd = regulator_get(NULL, "wifiio-vcc"); if (IS_ERR(wifi_host->vdd)) { pr_err("%s: regulator_get failed.\n", __func__); ret = -ENXIO; goto err_regulator_get; } ret = regulator_set_voltage(wifi_host->vdd, K3V2_WIFI_VDD_VOLTAGE, K3V2_WIFI_VDD_VOLTAGE); if (ret < 0) { pr_err("%s: regulator_set_voltage failed, ret:%d.\n", __func__, ret); ret = -ENXIO; goto err_regulator_set_voltage; } /* set io mux*/ wifi_host->block = iomux_get_block("block_wifi"); if (!wifi_host->block) { pr_err("%s: iomux_lookup_block failed.\n", __func__); ret = -ENXIO; goto err_iomux_get_block; } wifi_host->config = iomux_get_blockconfig("block_wifi"); if (!wifi_host->config) { pr_err("%s: iomux_get_blockconfig failed.\n", __func__); ret = -ENXIO; goto err_iomux_get_blockconfig; } ret = blockmux_set(wifi_host->block, wifi_host->config, LOWPOWER); if (ret < 0) { pr_err("%s: blockmux_set failed, ret.\n", __func__); goto err_blockmux_set; } #else /* fpga VDD open forver,if can not request other driver maybe has open*/ ret = gpio_request(K3V2_WIFI_VDD_GPIO, NULL); if (ret < 0) { pr_err("%s: gpio_request failed, ret:%d.\n", __func__, K3V2_WIFI_VDD_GPIO); } else gpio_direction_output(K3V2_WIFI_VDD_GPIO, 1); #endif /* set power gpio */ ret = gpio_request(K3V2_WIFI_POWER_GPIO, NULL); if (ret < 0) { pr_err("%s: gpio_request failed, ret:%d.\n", __func__, K3V2_WIFI_POWER_GPIO); goto err_power_gpio_request; } gpio_direction_output(K3V2_WIFI_POWER_GPIO, 0); /* set apwake gpio */ ret = gpio_request(K3V2_WIFI_IRQ_GPIO, NULL); if (ret < 0) { pr_err("%s: gpio_request failed, ret:%d.\n", __func__, K3V2_WIFI_IRQ_GPIO); goto err_irq_gpio_request; } gpio_direction_input(K3V2_WIFI_IRQ_GPIO); #ifdef CONFIG_WIFI_CONTROL_FUNC ret = platform_device_register(&k3v2_wifi_device); if (ret) { pr_err("%s: platform_device_register failed, ret:%d.\n", __func__, ret); goto err_platform_device_register; } #endif return 0; err_platform_device_register: gpio_free(K3V2_WIFI_IRQ_GPIO); err_irq_gpio_request: gpio_free(K3V2_WIFI_POWER_GPIO); err_power_gpio_request: #if defined(CONFIG_MACH_K3V2OEM1) err_blockmux_set: err_iomux_get_blockconfig: err_iomux_get_block: err_regulator_set_voltage: regulator_put(wifi_host->vdd); err_regulator_get: clk_put(wifi_host->clk); err_clk_get: kfree(wifi_host); wifi_host = NULL; #else gpio_free(K3V2_WIFI_VDD_GPIO); #endif err_malloc_wifi_host: deinit_wifi_mem(); return ret; }
static int msm_iommu_probe(struct platform_device *pdev) { struct resource *r, *r2; struct clk *iommu_clk; struct msm_iommu_drvdata *drvdata; struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data; void __iomem *regs_base; resource_size_t len; int ret = 0, ncb, nm2v, irq; if (pdev->id != -1) { drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); if (!drvdata) { ret = -ENOMEM; goto fail; } if (!iommu_dev) { ret = -ENODEV; goto fail; } if (iommu_dev->clk_rate != 0) { iommu_clk = clk_get(&pdev->dev, "iommu_clk"); if (IS_ERR(iommu_clk)) { ret = -ENODEV; goto fail; } if (iommu_dev->clk_rate > 0) { ret = clk_set_rate(iommu_clk, iommu_dev->clk_rate); if (ret) { clk_put(iommu_clk); goto fail; } } ret = clk_enable(iommu_clk); if (ret) { clk_put(iommu_clk); goto fail; } clk_put(iommu_clk); } r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "physbase"); if (!r) { ret = -ENODEV; goto fail; } len = r->end - r->start + 1; r2 = request_mem_region(r->start, len, r->name); if (!r2) { pr_err("Could not request memory region: " "start=%p, len=%d\n", (void *) r->start, len); ret = -EBUSY; goto fail; } regs_base = ioremap(r2->start, len); if (!regs_base) { pr_err("Could not ioremap: start=%p, len=%d\n", (void *) r2->start, len); ret = -EBUSY; goto fail_mem; } irq = platform_get_irq_byname(pdev, "secure_irq"); if (irq < 0) { ret = -ENODEV; goto fail_io; } mb(); if (GET_IDR(regs_base) == 0) { pr_err("Invalid IDR value detected\n"); ret = -ENODEV; goto fail_io; } ret = request_irq(irq, msm_iommu_fault_handler, 0, "msm_iommu_secure_irpt_handler", drvdata); if (ret) { pr_err("Request IRQ %d failed with ret=%d\n", irq, ret); goto fail_io; } msm_iommu_reset(regs_base); drvdata->base = regs_base; drvdata->irq = irq; nm2v = GET_NM2VCBMT((unsigned long) regs_base); ncb = GET_NCB((unsigned long) regs_base); pr_info("device %s mapped at %p, irq %d with %d ctx banks\n", iommu_dev->name, regs_base, irq, ncb+1); platform_set_drvdata(pdev, drvdata); } else msm_iommu_root_dev = pdev; return 0; fail_io: iounmap(regs_base); fail_mem: release_mem_region(r->start, len); fail: kfree(drvdata); return ret; }
static int __devinit em_sti_probe(struct platform_device *pdev) { struct em_sti_priv *p; struct resource *res; int irq, ret; p = kzalloc(sizeof(*p), GFP_KERNEL); if (p == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); ret = -ENOMEM; goto err0; } p->pdev = pdev; platform_set_drvdata(pdev, p); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to get I/O memory\n"); ret = -EINVAL; goto err0; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get irq\n"); ret = -EINVAL; goto err0; } /* map memory, let base point to the STI instance */ p->base = ioremap_nocache(res->start, resource_size(res)); if (p->base == NULL) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); ret = -ENXIO; goto err0; } /* get hold of clock */ p->clk = clk_get(&pdev->dev, "sclk"); if (IS_ERR(p->clk)) { dev_err(&pdev->dev, "cannot get clock\n"); ret = PTR_ERR(p->clk); goto err1; } if (request_irq(irq, em_sti_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, dev_name(&pdev->dev), p)) { dev_err(&pdev->dev, "failed to request low IRQ\n"); ret = -ENOENT; goto err2; } raw_spin_lock_init(&p->lock); em_sti_register_clockevent(p); em_sti_register_clocksource(p); return 0; err2: clk_put(p->clk); err1: iounmap(p->base); err0: kfree(p); return ret; }
int msm_cam_clk_enable(struct device *dev, struct msm_cam_clk_info *clk_info, struct clk **clk_ptr, int num_clk, int enable) { int i; int rc = 0; if (enable) { for (i = 0; i < num_clk; i++) { CDBG("%s enable %s\n", __func__, clk_info[i].clk_name); clk_ptr[i] = clk_get(dev, clk_info[i].clk_name); if (IS_ERR(clk_ptr[i])) { pr_err("%s get failed\n", clk_info[i].clk_name); rc = PTR_ERR(clk_ptr[i]); goto cam_clk_get_err; } if (clk_info[i].clk_rate > 0) { rc = clk_set_rate(clk_ptr[i], clk_info[i].clk_rate); if (rc < 0) { pr_err("%s set failed\n", clk_info[i].clk_name); goto cam_clk_set_err; } } rc = clk_prepare(clk_ptr[i]); if (rc < 0) { pr_err("%s prepare failed\n", clk_info[i].clk_name); goto cam_clk_prepare_err; } rc = clk_enable(clk_ptr[i]); if (rc < 0) { pr_err("%s enable failed\n", clk_info[i].clk_name); goto cam_clk_enable_err; } if (clk_info[i].delay > 20) { msleep(clk_info[i].delay); } else if (clk_info[i].delay) { usleep_range(clk_info[i].delay * 1000, (clk_info[i].delay * 1000) + 1000); } } } else { for (i = num_clk - 1; i >= 0; i--) { if (clk_ptr[i] != NULL) { CDBG("%s disable %s\n", __func__, clk_info[i].clk_name); clk_disable(clk_ptr[i]); clk_unprepare(clk_ptr[i]); clk_put(clk_ptr[i]); } } } return rc; cam_clk_enable_err: clk_unprepare(clk_ptr[i]); cam_clk_prepare_err: cam_clk_set_err: clk_put(clk_ptr[i]); cam_clk_get_err: for (i--; i >= 0; i--) { if (clk_ptr[i] != NULL) { clk_disable(clk_ptr[i]); clk_unprepare(clk_ptr[i]); clk_put(clk_ptr[i]); } } return rc; }