static int __devinit sh_keysc_probe(struct platform_device *pdev) { struct sh_keysc_priv *priv; struct sh_keysc_info *pdata; struct resource *res; struct input_dev *input; char clk_name[8]; int i; int irq, error; if (!pdev->dev.platform_data) { dev_err(&pdev->dev, "no platform data defined\n"); error = -EINVAL; goto err0; } error = -ENXIO; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get I/O memory\n"); goto err0; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get irq\n"); goto err0; } priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); error = -ENOMEM; goto err0; } platform_set_drvdata(pdev, priv); memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); pdata = &priv->pdata; priv->iomem_base = ioremap_nocache(res->start, res_size(res)); if (priv->iomem_base == NULL) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); error = -ENXIO; goto err1; } snprintf(clk_name, sizeof(clk_name), "keysc%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); error = PTR_ERR(priv->clk); goto err2; } priv->input = input_allocate_device(); if (!priv->input) { dev_err(&pdev->dev, "failed to allocate input device\n"); error = -ENOMEM; goto err3; } input = priv->input; input->evbit[0] = BIT_MASK(EV_KEY); input->name = pdev->name; input->phys = "sh-keysc-keys/input0"; input->dev.parent = &pdev->dev; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; input->keycode = pdata->keycodes; input->keycodesize = sizeof(pdata->keycodes[0]); input->keycodemax = ARRAY_SIZE(pdata->keycodes); error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); if (error) { dev_err(&pdev->dev, "failed to request IRQ\n"); goto err4; } for (i = 0; i < SH_KEYSC_MAXKEYS; i++) __set_bit(pdata->keycodes[i], input->keybit); __clear_bit(KEY_RESERVED, input->keybit); error = input_register_device(input); if (error) { dev_err(&pdev->dev, "failed to register input device\n"); goto err5; } clk_enable(priv->clk); iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | pdata->scan_timing, priv->iomem_base + KYCR1_OFFS); iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); device_init_wakeup(&pdev->dev, 1); return 0; err5: free_irq(irq, pdev); err4: input_free_device(input); err3: clk_put(priv->clk); err2: iounmap(priv->iomem_base); err1: platform_set_drvdata(pdev, NULL); kfree(priv); err0: return error; }
static int __devinit sh_keysc_probe(struct platform_device *pdev) { struct sh_keysc_priv *priv; struct sh_keysc_info *pdata; struct resource *res; struct input_dev *input; int i, k; int irq, error; if (!pdev->dev.platform_data) { dev_err(&pdev->dev, "no platform data defined\n"); error = -EINVAL; goto err0; } error = -ENXIO; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get I/O memory\n"); goto err0; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get irq\n"); goto err0; } priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); error = -ENOMEM; goto err0; } platform_set_drvdata(pdev, priv); memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); pdata = &priv->pdata; priv->iomem_base = ioremap_nocache(res->start, res_size(res)); if (priv->iomem_base == NULL) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); error = -ENXIO; goto err1; } priv->input = input_allocate_device(); if (!priv->input) { dev_err(&pdev->dev, "failed to allocate input device\n"); error = -ENOMEM; goto err2; } input = priv->input; input->evbit[0] = BIT_MASK(EV_KEY); input->name = pdev->name; input->phys = "sh-keysc-keys/input0"; input->dev.parent = &pdev->dev; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); if (error) { dev_err(&pdev->dev, "failed to request IRQ\n"); goto err3; } for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { k = pdata->keycodes[i]; if (k) input_set_capability(input, EV_KEY, k); } error = input_register_device(input); if (error) { dev_err(&pdev->dev, "failed to register input device\n"); goto err4; } iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | pdata->scan_timing, priv->iomem_base + KYCR1_OFFS); iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); return 0; err4: free_irq(irq, pdev); err3: input_free_device(input); err2: iounmap(priv->iomem_base); err1: platform_set_drvdata(pdev, NULL); kfree(priv); err0: return error; }
static int pxau2h_ehci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; struct clk *clk = NULL; struct usb_hcd *hcd; int irq, retval, tmp; dev_dbg(&pdev->dev,"Initializing PXA EHCI-SOC USB Controller(U2H)\n"); info = dev->platform_data; /* Enable CKEN_USB */ clk = clk_get(NULL, "U2HCLK"); if (IS_ERR(clk)) { printk(KERN_ERR "Cannot get USB clk\n"); return PTR_ERR(clk); } clk_enable(clk); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "u2h"); info->regbase = (unsigned)ioremap_nocache(res->start, res_size(res)); if (!info->regbase) { printk(KERN_ERR "Cannot get regbase 0x%x\n", info->regbase); return -ENOMEM; } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "u2hphy"); info->phybase = (unsigned)ioremap_nocache(res->start, res_size(res)); if (!info->phybase) { printk(KERN_ERR "Cannot get phybase 0x%x\n", info->phybase); retval = -ENODEV; goto err1; } irq = platform_get_irq(pdev, 0); if (!irq) { printk( KERN_ERR "Cannot get irq %x\n", irq); retval = -ENODEV; goto err1; } printk("u2h regbase 0x%x phybase 0x%x irq %d\n", info->regbase, info->phybase, irq); if (!info->phy_init || info->phy_init(info->phybase)) { printk(KERN_ERR "unable to init pxa usb 2.0 host controller" " phy_init 0x%p\n", info->phy_init); retval = -EBUSY; goto err1; } if (!info->vbus_set || info->vbus_set(1)) { printk(KERN_ERR "Unable to power USB Host Controller.\n"); retval = -EBUSY; goto err1; } hcd = usb_create_hcd(&pxau2h_ehci_hc_driver, &pdev->dev, pdev->dev.bus_id); if (!hcd) { retval = -ENOMEM; goto err1; } hcd->rsrc_start = virt_to_phys((void *)info->regbase); hcd->rsrc_len = 0x1ff; hcd->regs = (void __iomem*)info->regbase; hcd->irq = (unsigned int)irq; /* @USBCMD, Reset USB core */ tmp = readl(hcd->regs + U2xUSBCMD); tmp |= U2xUSBCMD_RST; writel(tmp,hcd->regs + U2xUSBCMD); udelay(1000); retval = usb_add_hcd(hcd, hcd->irq, IRQF_DISABLED | IRQF_SHARED); if (retval != 0) { goto err2; } platform_set_drvdata(pdev, hcd); return retval; err2: usb_put_hcd(hcd); err1: dev_err(&pdev->dev, "init %s fail, %d\n", pdev->dev.bus_id, retval); return retval; }
int __init tegra_sdhci_probe(struct platform_device *pdev) { struct sdhci_host *sdhost; struct tegra_sdhci *host; struct tegra_sdhci_platform_data *plat = pdev->dev.platform_data; struct resource *res; int ret = -ENODEV; static int pmu_count=0; int enable=0; if (pdev->id == -1) { dev_err(&pdev->dev, "dynamic instance assignment not allowed\n"); return -ENODEV; } sdhost = sdhci_alloc_host(&pdev->dev, sizeof(struct tegra_sdhci)); if (IS_ERR_OR_NULL(sdhost)) { dev_err(&pdev->dev, "unable to allocate driver structure\n"); return (!sdhost) ? -ENOMEM : PTR_ERR(sdhost); } sdhost->hw_name = dev_name(&pdev->dev); host = sdhci_priv(sdhost); host->hOdmSdio = NvOdmSdioOpen(pdev->id); if (!host->hOdmSdio) dev_info(&pdev->dev, "no ODM SDIO adaptation\n"); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "no memory I/O resource provided\n"); ret = -ENODEV; goto err_sdhci_alloc; } if (!request_mem_region(res->start, res_size(res), dev_name(&pdev->dev))) { dev_err(&pdev->dev, "memory in use\n"); ret = -EBUSY; goto err_sdhci_alloc; } sdhost->ioaddr = ioremap(res->start, res_size(res)); if (!sdhost->ioaddr) { dev_err(&pdev->dev, "failed to map registers\n"); ret = -ENXIO; goto err_request_mem; } res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { dev_err(&pdev->dev, "no IRQ resource provided\n"); ret = -ENODEV; goto err_ioremap; } sdhost->irq = res->start; host->clk = clk_get(&pdev->dev, NULL); if (!host->clk) { dev_err(&pdev->dev, "unable to get clock\n"); ret = -ENODEV; goto err_ioremap; } host->pdev = pdev; host->pinmux = plat->pinmux; host->nr_pins = plat->nr_pins; host->gpio_cd = plat->gpio_nr_cd; host->gpio_polarity_cd = plat->gpio_polarity_cd; host->gpio_wp = plat->gpio_nr_wp; host->gpio_polarity_wp = plat->gpio_polarity_wp; //add by navy host->gpio_en = plat->gpio_nr_en; host->gpio_polarity_en = plat->gpio_polarity_en; //add end host->card_always_on = plat->is_always_on; dev_dbg(&pdev->dev, "write protect: %d card detect: %d\n", host->gpio_wp, host->gpio_cd); host->irq_cd = -1; host->debounce = plat->debounce; if (plat->max_clk) host->max_clk = min_t(unsigned int, 52000000, plat->max_clk); else {