static int dsps_create_musb_pdev(struct dsps_glue *glue, struct platform_device *parent) { struct musb_hdrc_platform_data pdata; struct resource resources[2]; struct resource *res; struct device *dev = &parent->dev; struct musb_hdrc_config *config; struct platform_device *musb; struct device_node *dn = parent->dev.of_node; int ret; memset(resources, 0, sizeof(resources)); res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc"); if (!res) { dev_err(dev, "failed to get memory.\n"); return -EINVAL; } resources[0] = *res; res = platform_get_resource_byname(parent, IORESOURCE_IRQ, "mc"); if (!res) { dev_err(dev, "failed to get irq.\n"); return -EINVAL; } resources[1] = *res; /* allocate the child platform device */ musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); if (!musb) { dev_err(dev, "failed to allocate musb device\n"); return -ENOMEM; } musb->dev.parent = dev; musb->dev.dma_mask = &musb_dmamask; musb->dev.coherent_dma_mask = musb_dmamask; musb->dev.of_node = of_node_get(dn); glue->musb = musb; ret = platform_device_add_resources(musb, resources, ARRAY_SIZE(resources)); if (ret) { dev_err(dev, "failed to add resources\n"); goto err; } config = devm_kzalloc(&parent->dev, sizeof(*config), GFP_KERNEL); if (!config) { dev_err(dev, "failed to allocate musb hdrc config\n"); ret = -ENOMEM; goto err; } pdata.config = config; pdata.platform_ops = &dsps_ops; config->num_eps = get_int_prop(dn, "mentor,num-eps"); config->ram_bits = get_int_prop(dn, "mentor,ram-bits"); config->host_port_deassert_reset_at_resume = 1; pdata.mode = get_musb_port_mode(dev); /* DT keeps this entry in mA, musb expects it as per USB spec */ pdata.power = get_int_prop(dn, "mentor,power") / 2; config->multipoint = of_property_read_bool(dn, "mentor,multipoint"); ret = platform_device_add_data(musb, &pdata, sizeof(pdata)); if (ret) { dev_err(dev, "failed to add platform_data\n"); goto err; } ret = platform_device_add(musb); if (ret) { dev_err(dev, "failed to register musb device\n"); goto err; } return 0; err: platform_device_put(musb); return ret; }
static int lcdc_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct fb_info *fbi; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc; if (pdev->id == 0) { lcdc_pdata = pdev->dev.platform_data; return 0; } mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; /* * link to the latest pdev */ mfd->pdev = mdp_dev; mfd->dest = DISPLAY_LCDC; /* * alloc panel device data */ if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { printk(KERN_ERR "lcdc_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } /* * data chain */ pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data; pdata->on = lcdc_on; pdata->off = lcdc_off; pdata->next = pdev; /* * get/set panel specific fb info */ mfd->panel_info = pdata->panel_info; #ifdef CONFIG_MSM_FB_RGB565 #ifdef MSMFB_FRAMEBUF_32 mfd->fb_imgType = MDP_RGBA_8888; #else mfd->fb_imgType = MDP_RGB_565; #endif #else mfd->fb_imgType = MDP_ARGB_8888; #endif fbi = mfd->fbi; fbi->var.pixclock = mfd->panel_info.clk_rate; fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch; fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch; fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch; fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch; fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width; fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width; /* * set driver data */ platform_set_drvdata(mdp_dev, mfd); /* * register in mdp driver */ rc = platform_device_add(mdp_dev); if (rc) goto lcdc_probe_err; pdev_list[pdev_list_cnt++] = pdev; return 0; lcdc_probe_err: platform_device_put(mdp_dev); return rc; }
static int wl1271_probe(struct sdio_func *func, const struct sdio_device_id *id) { struct wlcore_platdev_data *pdev_data; struct wl12xx_sdio_glue *glue; struct resource res[1]; mmc_pm_flag_t mmcflags; int ret = -ENOMEM; const char *chip_family; /* We are only able to handle the wlan function */ if (func->num != 0x02) return -ENODEV; pdev_data = kzalloc(sizeof(*pdev_data), GFP_KERNEL); if (!pdev_data) goto out; pdev_data->if_ops = &sdio_ops; glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { dev_err(&func->dev, "can't allocate glue\n"); goto out_free_pdev_data; } glue->dev = &func->dev; /* Grab access to FN0 for ELP reg. */ func->card->quirks |= MMC_QUIRK_LENIENT_FN0; /* Use block mode for transferring over one block size of data */ func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; pdev_data->pdata = wl12xx_get_platform_data(); if (IS_ERR(pdev_data->pdata)) { ret = PTR_ERR(pdev_data->pdata); dev_err(glue->dev, "missing wlan platform data: %d\n", ret); goto out_free_glue; } /* if sdio can keep power while host is suspended, enable wow */ mmcflags = sdio_get_host_pm_caps(func); dev_dbg(glue->dev, "sdio PM caps = 0x%x\n", mmcflags); if (mmcflags & MMC_PM_KEEP_POWER) pdev_data->pdata->pwr_in_suspend = true; sdio_set_drvdata(func, glue); /* Tell PM core that we don't need the card to be powered now */ pm_runtime_put_noidle(&func->dev); /* * Due to a hardware bug, we can't differentiate wl18xx from * wl12xx, because both report the same device ID. The only * way to differentiate is by checking the SDIO revision, * which is 3.00 on the wl18xx chips. */ if (func->card->cccr.sdio_vsn == SDIO_SDIO_REV_3_00) chip_family = "wl18xx"; else chip_family = "wl12xx"; glue->core = platform_device_alloc(chip_family, PLATFORM_DEVID_AUTO); if (!glue->core) { dev_err(glue->dev, "can't allocate platform_device"); ret = -ENOMEM; goto out_free_glue; } glue->core->dev.parent = &func->dev; memset(res, 0x00, sizeof(res)); res[0].start = pdev_data->pdata->irq; res[0].flags = IORESOURCE_IRQ; res[0].name = "irq"; ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); if (ret) { dev_err(glue->dev, "can't add resources\n"); goto out_dev_put; } ret = platform_device_add_data(glue->core, pdev_data, sizeof(*pdev_data)); if (ret) { dev_err(glue->dev, "can't add platform data\n"); goto out_dev_put; } ret = platform_device_add(glue->core); if (ret) { dev_err(glue->dev, "can't add platform device\n"); goto out_dev_put; } return 0; out_dev_put: platform_device_put(glue->core); out_free_glue: kfree(glue); out_free_pdev_data: kfree(pdev_data); out: return ret; }
static void __init omap_hsmmc_init_one(struct omap2_hsmmc_info *hsmmcinfo, int ctrl_nr) { struct omap_hwmod *oh; struct omap_hwmod *ohs[1]; struct omap_device *od; struct platform_device *pdev; char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN]; struct omap_mmc_platform_data *mmc_data; struct omap_mmc_dev_attr *mmc_dev_attr; char *name; int res; mmc_data = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL); if (!mmc_data) { pr_err("Cannot allocate memory for mmc device!\n"); return; } res = omap_hsmmc_pdata_init(hsmmcinfo, mmc_data); if (res < 0) goto free_mmc; omap_hsmmc_mux(mmc_data, (ctrl_nr - 1)); name = "omap_hsmmc"; res = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN, "mmc%d", ctrl_nr); WARN(res >= MAX_OMAP_MMC_HWMOD_NAME_LEN, "String buffer overflow in MMC%d device setup\n", ctrl_nr); oh = omap_hwmod_lookup(oh_name); if (!oh) { pr_err("Could not look up %s\n", oh_name); goto free_name; } ohs[0] = oh; if (oh->dev_attr != NULL) { mmc_dev_attr = oh->dev_attr; mmc_data->controller_flags = mmc_dev_attr->flags; /* * erratum 2.1.1.128 doesn't apply if board has * a transceiver is attached */ if (hsmmcinfo->transceiver) mmc_data->controller_flags &= ~OMAP_HSMMC_BROKEN_MULTIBLOCK_READ; } pdev = platform_device_alloc(name, ctrl_nr - 1); if (!pdev) { pr_err("Could not allocate pdev for %s\n", name); goto free_name; } dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); od = omap_device_alloc(pdev, ohs, 1); if (IS_ERR(od)) { pr_err("Could not allocate od for %s\n", name); goto put_pdev; } res = platform_device_add_data(pdev, mmc_data, sizeof(struct omap_mmc_platform_data)); if (res) { pr_err("Could not add pdata for %s\n", name); goto put_pdev; } hsmmcinfo->pdev = pdev; if (hsmmcinfo->deferred) goto free_mmc; res = omap_device_register(pdev); if (res) { pr_err("Could not register od for %s\n", name); goto free_od; } goto free_mmc; free_od: omap_device_delete(od); put_pdev: platform_device_put(pdev); free_name: kfree(mmc_data->slots[0].name); free_mmc: kfree(mmc_data); }
static int __init spi_gpio_custom_add_one(unsigned int id, unsigned int *params) { struct platform_device *pdev; struct spi_gpio_platform_data pdata; int i; int num_cs; int err; struct spi_master *master; struct spi_device *slave; struct spi_board_info slave_info; int mode, maxfreq, cs; if (!bus_nump[id]) return 0; err = spi_gpio_custom_check_params(id, params); if (err) goto err; /* Create BUS device node */ pdev = platform_device_alloc("spi_gpio", params[BUS_PARAM_ID]); if (!pdev) { err = -ENOMEM; goto err; } num_cs = 0; for (i = 0; i < BUS_SLAVE_COUNT_MAX; i++) { /* no more slaves? */ if (spi_gpio_custom_get_slave_mode(id, params, i) < 0) break; if (spi_gpio_custom_get_slave_cs(id, params, i) >= 0) num_cs++; } if (num_cs == 0) { /* * Even if no CS is used, spi modules expect * at least 1 (unused) */ num_cs = 1; } pdata.sck = params[BUS_PARAM_SCK]; pdata.mosi = gpio_is_valid(params[BUS_PARAM_MOSI]) ? params[BUS_PARAM_MOSI] : SPI_GPIO_NO_MOSI; pdata.miso = gpio_is_valid(params[BUS_PARAM_MISO]) ? params[BUS_PARAM_MISO] : SPI_GPIO_NO_MISO; pdata.num_chipselect = num_cs; err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); if (err) { platform_device_put(pdev); goto err; } err = platform_device_add(pdev); if (err) { printk(KERN_ERR PFX "platform_device_add failed with return code %d\n", err); platform_device_put(pdev); goto err; } /* Register SLAVE devices */ for (i = 0; i < BUS_SLAVE_COUNT_MAX; i++) { mode = spi_gpio_custom_get_slave_mode(id, params, i); maxfreq = spi_gpio_custom_get_slave_maxfreq(id, params, i); cs = spi_gpio_custom_get_slave_cs(id, params, i); /* no more slaves? */ if (mode < 0) break; memset(&slave_info, 0, sizeof(slave_info)); strcpy(slave_info.modalias, "spidev"); slave_info.controller_data = (void *)((cs >= 0) ? cs : SPI_GPIO_NO_CHIPSELECT); slave_info.max_speed_hz = maxfreq; slave_info.bus_num = params[BUS_PARAM_ID]; slave_info.chip_select = i; slave_info.mode = mode; master = spi_busnum_to_master(params[BUS_PARAM_ID]); if (!master) { printk(KERN_ERR PFX "unable to get master for bus %d\n", params[BUS_PARAM_ID]); err = -EINVAL; goto err_unregister; } slave = spi_new_device(master, &slave_info); spi_master_put(master); if (!slave) { printk(KERN_ERR PFX "unable to create slave %d for bus %d\n", i, params[BUS_PARAM_ID]); /* Will most likely fail due to unsupported mode bits */ err = -EINVAL; goto err_unregister; } } devices[nr_devices++] = pdev; return 0; err_unregister: platform_device_unregister(pdev); err: return err; }
static int lcdc_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct fb_info *fbi; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc; if (pdev->id == 0) { lcdc_pdata = pdev->dev.platform_data; return 0; } mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; /* * link to the latest pdev */ mfd->pdev = mdp_dev; mfd->dest = DISPLAY_LCDC; /* * alloc panel device data */ if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { printk(KERN_ERR "lcdc_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } /* * data chain */ pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data; pdata->on = lcdc_on; pdata->off = lcdc_off; pdata->next = pdev; /* * get/set panel specific fb info */ mfd->panel_info = pdata->panel_info; /* RGB interface settings for RGB_565 */ if (mfd->index == 0) { #ifdef CONFIG_HUAWEI_KERNEL mfd->fb_imgType = MDP_RGB_565; #else mfd->fb_imgType = MSMFB_DEFAULT_TYPE; #endif } else mfd->fb_imgType = MDP_RGB_565; fbi = mfd->fbi; fbi->var.pixclock = clk_round_rate(pixel_mdp_clk, mfd->panel_info.clk_rate); fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch; fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch; fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch; fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch; fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width; fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width; #ifndef CONFIG_MSM_BUS_SCALING mfd->ebi1_clk = clk_get(NULL, "ebi1_lcdc_clk"); if (IS_ERR(mfd->ebi1_clk)) return PTR_ERR(mfd->ebi1_clk); #endif /* * set driver data */ platform_set_drvdata(mdp_dev, mfd); /* * register in mdp driver */ rc = platform_device_add(mdp_dev); if (rc) goto lcdc_probe_err; pdev_list[pdev_list_cnt++] = pdev; return 0; lcdc_probe_err: platform_device_put(mdp_dev); return rc; }
static int mipi_tianma_probe(struct platform_device *pdev) { int ret = 0; struct k3_panel_info *pinfo = NULL; struct device_node *np = NULL; if (k3_fb_device_probe_defer(PANEL_RGB2MIPI)) { goto err_probe_defer; } K3_FB_DEBUG("+.\n"); np = of_find_compatible_node(NULL, NULL, DTS_COMP_MIPI_TIANMA_OTM9608A); if (!np) { K3_FB_ERR("NOT FOUND device node %s!\n", DTS_COMP_MIPI_TIANMA_OTM9608A); goto err_return; } gpio_lcd_power_2v85 = of_get_named_gpio(np, "gpios", 0); /*GPIO_6_3*/ gpio_lcd_power_1v8_en0 = of_get_named_gpio(np, "gpios", 1); /*GPIO_6_4*/ gpio_lcd_rst= of_get_named_gpio(np, "gpios", 2); /*GPIO_8_4*/ pdev->id = 1; /* init lcd panel info */ pinfo = tianma_panel_data.panel_info; memset(pinfo, 0, sizeof(struct k3_panel_info)); pinfo->xres = 540; pinfo->yres = 960; pinfo->width = 62; pinfo->height = 110; pinfo->type = PANEL_RGB2MIPI; pinfo->orientation = LCD_PORTRAIT; pinfo->bpp = LCD_RGB888; pinfo->bgr_fmt = LCD_RGB; pinfo->bl_set_type = BL_SET_BY_BLPWM; pinfo->bl_min = 1; pinfo->bl_max = 255; pinfo->ifbc_type = IFBC_TYPE_NON; pinfo->frc_enable = 0; pinfo->esd_enable = 0; pinfo->sbl_support = 0; pinfo->spi_dev = g_spi_dev; pinfo->ldi.h_back_porch = 50; pinfo->ldi.h_front_porch = 177; pinfo->ldi.h_pulse_width = 10; pinfo->ldi.v_back_porch = 32; pinfo->ldi.v_front_porch = 32; pinfo->ldi.v_pulse_width = 3; pinfo->ldi.hsync_plr = 1; pinfo->ldi.vsync_plr = 1; pinfo->ldi.pixelclk_plr = 0; pinfo->ldi.data_en_plr = 0; pinfo->mipi.lane_nums = DSI_2_LANES; pinfo->mipi.color_mode = DSI_24BITS_1; pinfo->mipi.vc = 0; pinfo->mipi.dsi_bit_clk = 241; pinfo->pxl_clk_rate = 40 * 1000000; /* lcd vcc init */ ret = vcc_cmds_tx(pdev, tianma_lcd_vcc_init_cmds, \ ARRAY_SIZE(tianma_lcd_vcc_init_cmds)); if (ret != 0) { #if 0 K3_FB_ERR("LCD vcc init failed!\n"); goto err_return; #endif } /* alloc panel device data */ ret = platform_device_add_data(pdev, &tianma_panel_data, sizeof(struct k3_fb_panel_data)); if (ret) { K3_FB_ERR("platform_device_add_data failed!\n"); goto err_device_put; } k3_fb_add_device(pdev); K3_FB_DEBUG("-.\n"); return 0; err_device_put: platform_device_put(pdev); err_return: return ret; err_probe_defer: return -EPROBE_DEFER; }
static int __init setup_codecvga(void) { int retval = 0; int i; struct resource *res=NULL; int res_num=0; int sprite_num=0, dma_chan=-1; struct platform_device *pdev=NULL; struct codecvga_platform_data *pdata = NULL; #ifdef CONFIG_CODEC_VGA_OF struct device_node *np=NULL; const void *prop=NULL; struct device_node *fbnp=NULL, *spnp=NULL; #endif /* CONFIG_CODEC_VGA_OF */ #ifdef CONFIG_CODEC_VGA_OF /* */ pr_info("cpufpga: **** setup from device tree\n"); /* get node */ np=of_find_compatible_node(NULL, "display", "p2pf,codecvga"); if(!np){ pr_err("A node for \"p2pf,codecvga\" is NOT found.\n"); return 0; } /* fb-handle */ prop = of_get_property(np, "fb-handle", NULL); if (!prop){ retval = -ENOENT; pr_err("%s: property \"fb-handle\" is NOT found.\n",np->full_name); goto err; } fbnp = of_find_node_by_phandle(*(const phandle*)prop); if(!fbnp){ retval = -ENOENT; pr_err("%s: node by \"fb-handle\" is NOT found.\n",np->full_name); goto err; } prop = of_get_property(np, "dma-chan", NULL); if(prop) dma_chan = *(u32*)prop; /* sprite-handle */ prop = of_get_property(np, "sprite-handle", NULL); if (prop){ spnp = of_find_node_by_phandle(*(const phandle*)prop); if(spnp){ prop = of_get_property(spnp, "sprite-num", NULL); if(prop) sprite_num = *(u32*)prop; } else { pr_warning("%s: node by \"sprite-handle\" is NOT found.\n",np->full_name); } } else { pr_warning("%s: property \"sprite-handle\" is NOT found.\n",np->full_name); } #else /* ! CONFIG_CODEC_VGA_OF */ sprite_num = CONFIG_CODEC_VGA_SPRITE_NUM; dma_chan = CONFIG_CODEC_VGA_DMA_CH; #endif /* CONFIG_CODEC_VGA_OF */ /* allocte resources */ res_num = sprite_num + 2; res = (struct resource *)kzalloc(sizeof(struct resource)*res_num, GFP_KERNEL); if(!res){ retval = -ENOMEM; pr_err("no memory for resources\n"); goto err; } /* get address map for control register */ #ifdef CONFIG_CODEC_VGA_OF retval = of_address_to_resource(np, 0, &res[0]); if(retval){ pr_err("%s: failed to get address map\n",np->full_name); goto err; } #else /* ! CONFIG_CODEC_VGA_OF */ res[0].name = "codecvga"; res[0].flags = IORESOURCE_MEM; res[0].start = CONFIG_CODEC_VGA_REG_ADDR; res[0].end = CONFIG_CODEC_VGA_REG_SIZE + CONFIG_CODEC_VGA_REG_ADDR - 1; #endif /* CONFIG_CODEC_VGA_OF */ pr_info("cpufpga: resource reg = [ 0x%08x - 0x%08x ]\n", res[0].start,res[0].end); /* get address map for fram-buffer memory */ #ifdef CONFIG_CODEC_VGA_OF retval = of_address_to_resource(fbnp, 0, &res[1]); if(retval){ pr_err("%s: failed to get address map\n",fbnp->full_name); goto err; } #else /* ! CONFIG_CODEC_VGA_OF */ res[1].name = "fb-handle"; res[1].flags = IORESOURCE_MEM; res[1].start = CONFIG_CODEC_VGA_FB_ADDR; res[1].end = CONFIG_CODEC_VGA_FB_SIZE + CONFIG_CODEC_VGA_FB_ADDR - 1; #endif /* CONFIG_CODEC_VGA_OF */ pr_info("cpufpga: resource fb = [ 0x%08x - 0x%08x ]\n", res[1].start,res[1].end); /* get address map for sprite-buffer memory */ for(i=0; i<sprite_num; i++){ #ifdef CONFIG_CODEC_VGA_OF retval = of_address_to_resource(spnp, i, &res[2+i]); if(retval){ pr_err("%s,i=%d: failed to get address map\n",spnp->full_name,i); goto err; } #else /* ! CONFIG_CODEC_VGA_OF */ res[2+i].name = "sprite-handle"; res[2+i].flags = IORESOURCE_MEM; res[2+i].start = CONFIG_CODEC_VGA_SPRITE_START_ADDR + ( i * CONFIG_CODEC_VGA_SPRITE_SIZE); res[2+i].end = res[2+i].start + CONFIG_CODEC_VGA_SPRITE_SIZE - 1; #endif /* CONFIG_CODEC_VGA_OF */ pr_info("cpufpga: resource sprite#%d = [ 0x%08x - 0x%08x ]\n", i,res[2+i].start,res[2+i].end); } /* allocte platform data for codecvga */ pdata = (struct codecvga_platform_data *)kzalloc(sizeof(struct codecvga_platform_data),GFP_KERNEL); if(!pdata){ retval = -ENOMEM; pr_err("no memory for platform data\n"); goto err; } /* setting platform data */ pdata->sprite_num = sprite_num; pdata->dma_chan = dma_chan; pr_info("cpufpga: sprite number=%d, dma cahnnel=%d\n", pdata->sprite_num, pdata->dma_chan); /* allocte private_device */ pdev = platform_device_alloc("codec_vga", 0); if (!pdev){ pr_err("can't allocate for platform device\n"); retval=-ENOMEM; goto err; } /* add resources to platform device */ retval = platform_device_add_resources(pdev, res, res_num); if(retval){ pr_err("failed to add resources to platform device\n"); platform_device_del(pdev); goto err; } /* add platform data to platform device */ retval = platform_device_add_data(pdev, pdata, sizeof(struct codecvga_platform_data)); if (retval){ pr_err("failed to add platform data to platform device\n"); platform_device_del(pdev); goto err; } /* regiter platform device */ retval = platform_device_add(pdev); if (retval){ pr_err("failed to register platform device\n"); platform_device_del(pdev); goto err; } err: if(pdata) kfree(pdata); if(res) kfree(res); /* complete */ return retval; }
static int __init board_init(void) { /* dma */ #ifdef CONFIG_XBURST_DMAC platform_device_register(&jz_pdma_device); #endif /* i2c */ #ifdef CONFIG_I2C0_JZ4775 platform_device_register(&jz_i2c0_device); #endif #ifdef CONFIG_I2C1_JZ4775 platform_device_register(&jz_i2c1_device); #endif #ifdef CONFIG_I2C2_JZ4775 platform_device_register(&jz_i2c2_device); #endif /* mmc */ #ifndef CONFIG_NAND #ifdef CONFIG_MMC0_JZ4775 jz_device_register(&jz_msc0_device, &inand_pdata); #endif #ifdef CONFIG_MMC1_JZ4775 jz_device_register(&jz_msc1_device, &sdio_pdata); #endif #ifdef CONFIG_MMC2_JZ4775 jz_device_register(&jz_msc2_device, &tf_pdata); #endif #else #ifdef CONFIG_MMC0_JZ4775 jz_device_register(&jz_msc0_device, &tf_pdata); #endif #ifdef CONFIG_MMC1_JZ4775 jz_device_register(&jz_msc1_device, &sdio_pdata); #endif #endif /* sound */ #ifdef CONFIG_SOUND_I2S_JZ47XX jz_device_register(&jz_i2s_device,&i2s_data); jz_device_register(&jz_mixer0_device,&snd_mixer0_data); #endif #ifdef CONFIG_SOUND_PCM_JZ47XX jz_device_register(&jz_pcm_device,&pcm_data); #endif #ifdef CONFIG_JZ_INTERNAL_CODEC jz_device_register(&jz_codec_device, &codec_data); #endif #ifdef CONFIG_LCD_KD50G2_40NM_A2 platform_device_register(&kd50g2_40nm_a2_device); #endif /* panel and bl */ //#ifdef CONFIG_LCD_BYD_BM8766U // platform_device_register(&byd_bm8766u_device); //#endif #ifdef CONFIG_LCD_KFM701A21_1A platform_device_register(&kfm701a21_1a_device); #endif #ifdef CONFIG_BACKLIGHT_PWM platform_device_register(&backlight_device); #endif #ifdef CONFIG_BACKLIGHT_DIGITAL_PULSE platform_device_register(&digital_pulse_backlight_device); #endif /* lcdc framebuffer*/ #ifdef CONFIG_FB_JZ4780_LCDC0 jz_device_register(&jz_fb0_device, &jzfb0_pdata); #endif /* uart */ #ifdef CONFIG_SERIAL_JZ47XX_UART0 platform_device_register(&jz_uart0_device); #endif #ifdef CONFIG_SERIAL_JZ47XX_UART1 platform_device_register(&jz_uart1_device); #endif #ifdef CONFIG_SERIAL_JZ47XX_UART2 platform_device_register(&jz_uart2_device); #endif #ifdef CONFIG_SERIAL_JZ47XX_UART3 platform_device_register(&jz_uart3_device); #endif #ifdef CONFIG_JZ_CIM platform_device_register(&jz_cim_device); #endif /* x2d */ #ifdef CONFIG_JZ_X2D platform_device_register(&jz_x2d_device); #endif #ifdef CONFIG_USB_OHCI_HCD platform_device_register(&jz_ohci_device); #endif #ifdef CONFIG_USB_EHCI_HCD platform_device_register(&jz_ehci_device); #endif /* ethnet */ #ifdef CONFIG_JZ4775_MAC platform_device_register(&jz4775_mii_bus); platform_device_register(&jz4775_mac_device); #endif #ifdef CONFIG_JZ_VPU platform_device_register(&jz_vpu_device); #endif #ifdef CONFIG_KEYBOARD_GPIO platform_device_register(&jz_button_device); #endif /* nand */ #ifdef CONFIG_NAND_JZ4780 jz_device_register(&jz_nand_device, &jz_nand_chip_data); #endif #ifdef CONFIG_HDMI_JZ4780 platform_device_register(&jz_hdmi); #endif #ifdef CONFIG_JZ4775_SUPPORT_TSC i2c_register_board_info(0, mensa_i2c0_devs, ARRAY_SIZE(mensa_i2c0_devs)); #endif #ifdef CONFIG_RTC_DRV_JZ4775 platform_device_register(&jz_rtc_device); #endif #ifdef CONFIG_SPI_JZ4780 #ifdef CONFIG_SPI0_JZ4780 spi_register_board_info(jz_spi0_board_info, ARRAY_SIZE(jz_spi0_board_info)); platform_device_register(&jz_ssi0_device); platform_device_add_data(&jz_ssi0_device, &spi0_info_cfg, sizeof(struct jz47xx_spi_info)); #endif #ifdef CONFIG_SPI1_JZ4780 spi_register_board_info(jz_spi1_board_info, ARRAY_SIZE(jz_spi1_board_info)); platform_device_register(&jz_ssi1_device); platform_device_add_data(&jz_ssi1_device, &spi1_info_cfg, sizeof(struct jz47xx_spi_info)); #endif #endif #ifdef CONFIG_SPI_GPIO spi_register_board_info(jz_spi0_board_info, ARRAY_SIZE(jz_spi0_board_info)); platform_device_register(&jz4780_spi_gpio_device); #endif #ifdef CONFIG_ANDROID_PMEM platform_device_register(&pmem_adsp_device); #endif #ifdef CONFIG_USB_DWC2 platform_device_register(&jz_dwc_otg_device); #endif /* ADC*/ #ifdef CONFIG_BATTERY_JZ4775 jz_device_register(&jz_adc_device, &mensa_battery_pdata); #endif /*IW8103_bcm4330*/ #ifdef CONFIG_BCM4330_RFKILL platform_device_register(&bcm4330_bt_power_device); #endif return 0; }
static int __devinit jdi_probe(struct platform_device *pdev) { struct k3_panel_info *pinfo = NULL; struct platform_device *reg_pdev = NULL; struct lcd_properities lcd_props; struct k3_fb_data_type *k3fd = NULL; int i; g_display_on = false; pinfo = jdi_panel_data.panel_info; /* init lcd panel info */ pinfo->xres = 720; pinfo->yres = 1280; pinfo->width = 58; pinfo->height = 103; pinfo->type = PANEL_MIPI_CMD; pinfo->orientation = LCD_PORTRAIT; pinfo->bpp = EDC_OUT_RGB_888; pinfo->s3d_frm = EDC_FRM_FMT_2D; pinfo->bgr_fmt = EDC_RGB; pinfo->bl_set_type = BL_SET_BY_MIPI; pinfo->bl_min = 1; pinfo->bl_max = 100; pinfo->frc_enable = 1; pinfo->esd_enable = 1; pinfo->sbl_enable = 1; pinfo->sbl.bl_max = 0xff; pinfo->sbl.cal_a = 0x08; pinfo->sbl.cal_b = 0xd8; pinfo->sbl.str_limit = 0x40; pinfo->ldi.h_back_porch = 43; pinfo->ldi.h_front_porch = 80; pinfo->ldi.h_pulse_width = 57; pinfo->ldi.v_back_porch = 12; pinfo->ldi.v_front_porch = 14; pinfo->ldi.v_pulse_width = 2; pinfo->ldi.hsync_plr = 1; pinfo->ldi.vsync_plr = 0; pinfo->ldi.pixelclk_plr = 1; pinfo->ldi.data_en_plr = 0; pinfo->ldi.disp_mode = LDI_DISP_MODE_NOT_3D_FBF; /* Note: must init here */ pinfo->frame_rate = 60; pinfo->clk_rate = 76000000; pinfo->mipi.lane_nums = DSI_4_LANES; pinfo->mipi.color_mode = DSI_24BITS_1; pinfo->mipi.vc = 0; pinfo->mipi.dsi_bit_clk = 241; /* tp vcc init */ vcc_cmds_tx(pdev, jdi_tp_vcc_init_cmds, \ ARRAY_SIZE(jdi_tp_vcc_init_cmds)); /* lcd vcc init */ vcc_cmds_tx(pdev, jdi_lcd_vcc_init_cmds, \ ARRAY_SIZE(jdi_lcd_vcc_init_cmds)); /*tk vcc init*/ g_touchkey_enable = get_touchkey_enable(); if (g_touchkey_enable == true) { vcc_cmds_tx(pdev, jdi_tk_vcc_init_cmds, \ ARRAY_SIZE(jdi_tk_vcc_init_cmds)); } /* tp iomux init */ iomux_cmds_tx(jdi_tp_iomux_init_cmds, \ ARRAY_SIZE(jdi_tp_iomux_init_cmds)); /* lcd iomux init */ iomux_cmds_tx(jdi_lcd_iomux_init_cmds, \ ARRAY_SIZE(jdi_lcd_iomux_init_cmds)); /* alloc panel device data */ if (platform_device_add_data(pdev, &jdi_panel_data, sizeof(struct k3_fb_panel_data))) { k3fb_loge("platform_device_add_data failed!\n"); platform_device_put(pdev); return -ENOMEM; } reg_pdev = k3_fb_add_device(pdev); k3fd = (struct k3_fb_data_type *)platform_get_drvdata(reg_pdev); BUG_ON(k3fd == NULL); /* read product id */ msleep(16); //TE masked in k3_fb_register(), wait 16ms for on-going refreshing for(i = 0; i < 150; i++){ outp32(k3fd->edc_base + MIPIDSI_GEN_HDR_OFFSET, 0xDA << 8 | 0x06); udelay(120); lcd_product_id = inp32(k3fd->edc_base + MIPIDSI_GEN_PLD_DATA_OFFSET); if(lcd_product_id && (lcd_product_id != 0xff)) break; } printk("lcd product id is 0x%x, read times is %d\n", lcd_product_id, i); sema_init(&ct_sem, 1); g_csc_value[0] = 0; g_csc_value[1] = 0; g_csc_value[2] = 0; g_csc_value[3] = 0; g_csc_value[4] = 0; g_csc_value[5] = 0; g_csc_value[6] = 0; g_csc_value[7] = 0; g_csc_value[8] = 0; g_is_csc_set = 0; /* for cabc */ lcd_props.type = TFT; lcd_props.default_gamma = GAMMA25; p_tuning_dev = lcd_tuning_dev_register(&lcd_props, &sp_tuning_ops, (void *)reg_pdev); if (IS_ERR(p_tuning_dev)) { k3fb_loge("lcd_tuning_dev_register failed!\n"); return -1; } jdi_sysfs_init(pdev); return 0; }
static int tvenc_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc; if (pdev->id == 0) { tvenc_base = ioremap(pdev->resource[0].start, pdev->resource[0].end - pdev->resource[0].start + 1); if (!tvenc_base) { printk(KERN_ERR "tvenc_base ioremap failed!\n"); return -ENOMEM; } tvenc_pdata = pdev->dev.platform_data; tvenc_resource_initialized = 1; return 0; } if (!tvenc_resource_initialized) return -EPERM; mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; if (tvenc_base == NULL) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; /* * link to the latest pdev */ mfd->pdev = mdp_dev; mfd->dest = DISPLAY_TV; /* * alloc panel device data */ if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { printk(KERN_ERR "tvenc_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } /* * data chain */ pdata = mdp_dev->dev.platform_data; pdata->on = tvenc_on; pdata->off = tvenc_off; pdata->next = pdev; /* * get/set panel specific fb info */ mfd->panel_info = pdata->panel_info; mfd->fb_imgType = MDP_YCRYCB_H2V1; /* * set driver data */ platform_set_drvdata(mdp_dev, mfd); /* * register in mdp driver */ rc = platform_device_add(mdp_dev); if (rc) goto tvenc_probe_err; pdev_list[pdev_list_cnt++] = pdev; return 0; tvenc_probe_err: platform_device_put(mdp_dev); return rc; }
static int __devinit mipi_s6d6aa0_lcd_probe(struct platform_device *pdev) { int ret = -EINVAL; struct lcd_panel_platform_data *platform_data; struct mipi_dsi_data *dsi_data; struct platform_device *fb_pdev; platform_data = pdev->dev.platform_data; if (platform_data == NULL) return -EINVAL; dsi_data = kzalloc(sizeof(struct mipi_dsi_data), GFP_KERNEL); if (dsi_data == NULL) return -ENOMEM; dsi_data->panel_data.on = mipi_s6d6aa0_lcd_on; dsi_data->panel_data.off = mipi_s6d6aa0_lcd_off; dsi_data->default_panels = platform_data->default_panels; dsi_data->panels = platform_data->panels; dsi_data->lcd_power = platform_data->lcd_power; dsi_data->lcd_reset = platform_data->lcd_reset; dsi_data->eco_mode_switch = mipi_dsi_eco_mode_switch; if (mipi_dsi_need_detect_panel(dsi_data->panels)) { dsi_data->panel_data.panel_detect = mipi_dsi_detect_panel; dsi_data->panel_data.update_panel = mipi_dsi_update_panel; dsi_data->panel_detecting = true; } else { dev_info(&pdev->dev, "no need to detect panel\n"); } ret = mipi_dsi_buf_alloc(&dsi_data->tx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(tx) failed!\n"); goto out_free; } ret = mipi_dsi_buf_alloc(&dsi_data->rx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(rx) failed!\n"); goto out_rx_release; } platform_set_drvdata(pdev, dsi_data); mipi_dsi_set_default_panel(dsi_data); if (dsi_data->panel->esd_failed_check) { dsi_data->esd_wq = create_singlethread_workqueue("panel_esd_check"); if (dsi_data->esd_wq == NULL) { dev_err(&pdev->dev, "can't create ESD workqueue\n"); goto out_tx_release; } INIT_DELAYED_WORK(&dsi_data->esd_work, panel_esd_check_work); dsi_data->esd_check = mipi_dsi_panel_esd_failed_check; } mutex_init(&esd_lock); ret = platform_device_add_data(pdev, &dsi_data->panel_data, sizeof(dsi_data->panel_data)); if (ret) { dev_err(&pdev->dev, "platform_device_add_data failed!\n"); goto out_wq_release; } fb_pdev = msm_fb_add_device(pdev); #ifdef CONFIG_FB_MSM_PANEL_ECO_MODE eco_mode_sysfs_register(&fb_pdev->dev); #endif #ifdef CONFIG_DEBUG_FS mipi_dsi_panel_create_debugfs(fb_pdev, "mipi_s6d6aa0"); #endif return 0; out_wq_release: if (dsi_data->panel->esd_failed_check) destroy_workqueue(dsi_data->esd_wq); out_tx_release: mipi_dsi_buf_release(&dsi_data->rx_buf); out_rx_release: mipi_dsi_buf_release(&dsi_data->tx_buf); out_free: kfree(dsi_data); return ret; }
static int ldi_probe(struct platform_device *pdev) { struct k3_fb_data_type *k3fd = NULL; struct fb_info *fbi = NULL; struct platform_device *k3_fb_dev = NULL; struct k3_fb_panel_data *pdata = NULL; int ret = 0; k3fd = (struct k3_fb_data_type *)platform_get_drvdata(pdev); BUG_ON(k3fd == NULL); /* ldi clock */ if (k3fd->index == 0) { k3fd->ldi_clk = clk_get(NULL, CLK_LDI0_NAME); } else if (k3fd->index == 1) { k3fd->ldi_clk = clk_get(NULL, CLK_LDI1_NAME); } else { k3fb_loge("fb%d not support now!\n", k3fd->index); return EINVAL; } if (IS_ERR(k3fd->ldi_clk)) { k3fb_loge("failed to get ldi_clk!\n"); return PTR_ERR(k3fd->ldi_clk); } /* set ldi clock rate */ ret = clk_set_rate(k3fd->ldi_clk, k3fd->panel_info.clk_rate); if (ret != 0) { k3fb_loge("failed to set ldi clk rate(%d).\n", k3fd->panel_info.clk_rate); /*return ret;*/ } /* k3_fb device */ k3_fb_dev = platform_device_alloc(DEV_NAME_FB, pdev->id); if (!k3_fb_dev) { k3fb_loge("failed to k3_fb platform_device_alloc!\n"); return -ENOMEM; } /* link to the latest pdev */ k3fd->pdev = k3_fb_dev; /* alloc panel device data */ if (platform_device_add_data(k3_fb_dev, pdev->dev.platform_data, sizeof(struct k3_fb_panel_data))) { k3fb_loge("failed to platform_device_add_data!\n"); platform_device_put(k3_fb_dev); return -ENOMEM; } /* data chain */ pdata = (struct k3_fb_panel_data *)k3_fb_dev->dev.platform_data; pdata->on = ldi_on; pdata->off = ldi_off; pdata->remove = ldi_remove; pdata->set_backlight = ldi_set_backlight; pdata->set_timing = ldi_set_timing; pdata->set_frc = ldi_set_frc; pdata->check_esd = ldi_check_esd; pdata->next = pdev; /* get/set panel info */ memcpy(&k3fd->panel_info, pdata->panel_info, sizeof(struct k3_panel_info)); fbi = k3fd->fbi; #ifndef CONFIG_MACH_TC45MSU3 fbi->var.pixclock = k3fd->panel_info.clk_rate; #endif /*fbi->var.pixclock = clk_round_rate(k3fd->ldi_clk, k3fd->panel_info.clk_rate);*/ fbi->var.left_margin = k3fd->panel_info.ldi.h_back_porch; fbi->var.right_margin = k3fd->panel_info.ldi.h_front_porch; fbi->var.upper_margin = k3fd->panel_info.ldi.v_back_porch; fbi->var.lower_margin = k3fd->panel_info.ldi.v_front_porch; fbi->var.hsync_len = k3fd->panel_info.ldi.h_pulse_width; fbi->var.vsync_len = k3fd->panel_info.ldi.v_pulse_width; /* set driver data */ platform_set_drvdata(k3_fb_dev, k3fd); /* register in k3_fb driver */ ret = platform_device_add(k3_fb_dev); if (ret) { platform_device_put(k3_fb_dev); k3fb_loge("failed to platform_device_add!\n"); return ret; } return ret; }
/* si4713_probe - probe for the device */ static int si4713_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct si4713_device *sdev; struct v4l2_ctrl_handler *hdl; struct si4713_platform_data *pdata = client->dev.platform_data; struct device_node *np = client->dev.of_node; struct radio_si4713_platform_data si4713_pdev_pdata; struct platform_device *si4713_pdev; int rval; sdev = devm_kzalloc(&client->dev, sizeof(*sdev), GFP_KERNEL); if (!sdev) { dev_err(&client->dev, "Failed to alloc video device.\n"); rval = -ENOMEM; goto exit; } sdev->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(sdev->gpio_reset)) { rval = PTR_ERR(sdev->gpio_reset); dev_err(&client->dev, "Failed to request gpio: %d\n", rval); goto exit; } sdev->vdd = devm_regulator_get_optional(&client->dev, "vdd"); if (IS_ERR(sdev->vdd)) { rval = PTR_ERR(sdev->vdd); if (rval == -EPROBE_DEFER) goto exit; dev_dbg(&client->dev, "no vdd regulator found: %d\n", rval); sdev->vdd = NULL; } sdev->vio = devm_regulator_get_optional(&client->dev, "vio"); if (IS_ERR(sdev->vio)) { rval = PTR_ERR(sdev->vio); if (rval == -EPROBE_DEFER) goto exit; dev_dbg(&client->dev, "no vio regulator found: %d\n", rval); sdev->vio = NULL; } v4l2_i2c_subdev_init(&sdev->sd, client, &si4713_subdev_ops); init_completion(&sdev->work); hdl = &sdev->ctrl_handler; v4l2_ctrl_handler_init(hdl, 20); sdev->mute = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_AUDIO_MUTE, 0, 1, 1, DEFAULT_MUTE); sdev->rds_pi = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_PI, 0, 0xffff, 1, DEFAULT_RDS_PI); sdev->rds_pty = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_PTY, 0, 31, 1, DEFAULT_RDS_PTY); sdev->rds_compressed = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_COMPRESSED, 0, 1, 1, 0); sdev->rds_art_head = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_ARTIFICIAL_HEAD, 0, 1, 1, 0); sdev->rds_stereo = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_MONO_STEREO, 0, 1, 1, 1); sdev->rds_tp = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_TRAFFIC_PROGRAM, 0, 1, 1, 0); sdev->rds_ta = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_TRAFFIC_ANNOUNCEMENT, 0, 1, 1, 0); sdev->rds_ms = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_MUSIC_SPEECH, 0, 1, 1, 1); sdev->rds_dyn_pty = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_DYNAMIC_PTY, 0, 1, 1, 0); sdev->rds_alt_freqs_enable = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_ALT_FREQS_ENABLE, 0, 1, 1, 0); sdev->rds_alt_freqs = v4l2_ctrl_new_custom(hdl, &si4713_alt_freqs_ctrl, NULL); sdev->rds_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_DEVIATION, 0, MAX_RDS_DEVIATION, 10, DEFAULT_RDS_DEVIATION); /* * Report step as 8. From RDS spec, psname * should be 8. But there are receivers which scroll strings * sized as 8xN. */ sdev->rds_ps_name = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_PS_NAME, 0, MAX_RDS_PS_NAME, 8, 0); /* * Report step as 32 (2A block). From RDS spec, * radio text should be 32 for 2A block. But there are receivers * which scroll strings sized as 32xN. Setting default to 32. */ sdev->rds_radio_text = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_RDS_TX_RADIO_TEXT, 0, MAX_RDS_RADIO_TEXT, 32, 0); sdev->limiter_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_AUDIO_LIMITER_ENABLED, 0, 1, 1, 1); sdev->limiter_release_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_AUDIO_LIMITER_RELEASE_TIME, 250, MAX_LIMITER_RELEASE_TIME, 10, DEFAULT_LIMITER_RTIME); sdev->limiter_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_AUDIO_LIMITER_DEVIATION, 0, MAX_LIMITER_DEVIATION, 10, DEFAULT_LIMITER_DEV); sdev->compression_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_AUDIO_COMPRESSION_ENABLED, 0, 1, 1, 1); sdev->compression_gain = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_AUDIO_COMPRESSION_GAIN, 0, MAX_ACOMP_GAIN, 1, DEFAULT_ACOMP_GAIN); sdev->compression_threshold = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_AUDIO_COMPRESSION_THRESHOLD, MIN_ACOMP_THRESHOLD, MAX_ACOMP_THRESHOLD, 1, DEFAULT_ACOMP_THRESHOLD); sdev->compression_attack_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME, 0, MAX_ACOMP_ATTACK_TIME, 500, DEFAULT_ACOMP_ATIME); sdev->compression_release_time = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME, 100000, MAX_ACOMP_RELEASE_TIME, 100000, DEFAULT_ACOMP_RTIME); sdev->pilot_tone_enabled = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_PILOT_TONE_ENABLED, 0, 1, 1, 1); sdev->pilot_tone_deviation = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_PILOT_TONE_DEVIATION, 0, MAX_PILOT_DEVIATION, 10, DEFAULT_PILOT_DEVIATION); sdev->pilot_tone_freq = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_PILOT_TONE_FREQUENCY, 0, MAX_PILOT_FREQUENCY, 1, DEFAULT_PILOT_FREQUENCY); sdev->tune_preemphasis = v4l2_ctrl_new_std_menu(hdl, &si4713_ctrl_ops, V4L2_CID_TUNE_PREEMPHASIS, V4L2_PREEMPHASIS_75_uS, 0, V4L2_PREEMPHASIS_50_uS); sdev->tune_pwr_level = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_TUNE_POWER_LEVEL, 0, SI4713_MAX_POWER, 1, DEFAULT_POWER_LEVEL); sdev->tune_ant_cap = v4l2_ctrl_new_std(hdl, &si4713_ctrl_ops, V4L2_CID_TUNE_ANTENNA_CAPACITOR, 0, SI4713_MAX_ANTCAP, 1, 0); if (hdl->error) { rval = hdl->error; goto free_ctrls; } v4l2_ctrl_cluster(29, &sdev->mute); sdev->sd.ctrl_handler = hdl; if (client->irq) { rval = devm_request_irq(&client->dev, client->irq, si4713_handler, IRQF_TRIGGER_FALLING, client->name, sdev); if (rval < 0) { v4l2_err(&sdev->sd, "Could not request IRQ\n"); goto free_ctrls; } v4l2_dbg(1, debug, &sdev->sd, "IRQ requested.\n"); } else { v4l2_warn(&sdev->sd, "IRQ not configured. Using timeouts.\n"); } rval = si4713_initialize(sdev); if (rval < 0) { v4l2_err(&sdev->sd, "Failed to probe device information.\n"); goto free_ctrls; } if (!np && (!pdata || !pdata->is_platform_device)) return 0; si4713_pdev = platform_device_alloc("radio-si4713", -1); if (!si4713_pdev) { rval = -ENOMEM; goto put_main_pdev; } si4713_pdev_pdata.subdev = client; rval = platform_device_add_data(si4713_pdev, &si4713_pdev_pdata, sizeof(si4713_pdev_pdata)); if (rval) goto put_main_pdev; rval = platform_device_add(si4713_pdev); if (rval) goto put_main_pdev; sdev->pd = si4713_pdev; return 0; put_main_pdev: platform_device_put(si4713_pdev); v4l2_device_unregister_subdev(&sdev->sd); free_ctrls: v4l2_ctrl_handler_free(hdl); exit: return rval; }
static int lvds_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct fb_info *fbi; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc; if (pdev->id == 0) { lvds_pdata = pdev->dev.platform_data; lvds_clk = clk_get(&pdev->dev, "lvds_clk"); if (IS_ERR_OR_NULL(lvds_clk)) { pr_err("Couldnt find lvds_clk\n"); lvds_clk = NULL; } return 0; } mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; /* * link to the latest pdev */ mfd->pdev = mdp_dev; mfd->dest = DISPLAY_LCDC; /* * alloc panel device data */ if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { pr_err("lvds_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } /* * data chain */ pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data; pdata->on = lvds_on; pdata->off = lvds_off; pdata->next = pdev; /* * get/set panel specific fb info */ mfd->panel_info = pdata->panel_info; if (mfd->index == 0) mfd->fb_imgType = MSMFB_DEFAULT_TYPE; else mfd->fb_imgType = MDP_RGB_565; fbi = mfd->fbi; if (lvds_clk) { fbi->var.pixclock = clk_round_rate(lvds_clk, mfd->panel_info.clk_rate); } fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch; fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch; fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch; fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch; fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width; fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width; /* * set driver data */ platform_set_drvdata(mdp_dev, mfd); /* * register in mdp driver */ rc = platform_device_add(mdp_dev); if (rc) goto lvds_probe_err; pdev_list[pdev_list_cnt++] = pdev; return 0; lvds_probe_err: platform_device_put(mdp_dev); return rc; }
static void __init sc8830_init_machine(void) { printk("sci get chip id = 0x%x\n",__sci_get_chip_id()); sci_adc_init((void __iomem *)ADC_BASE); sci_regulator_init(); #ifndef CONFIG_OF #if defined(CONFIG_ION) && defined(SPRD_ION_BASE_USE_VARIABLE) { extern void init_ion_addr_param(void); init_ion_addr_param(); } #endif #if defined(CONFIG_PSTORE_RAM) && defined(SPRD_ION_BASE_USE_VARIABLE) { extern void init_pstore_addr_param(void); init_pstore_addr_param(); } #endif sprd_add_otg_device(); platform_device_add_data(&sprd_serial_device0,(const void*)&plat_data0,sizeof(plat_data0)); platform_device_add_data(&sprd_serial_device1,(const void*)&plat_data1,sizeof(plat_data1)); platform_device_add_data(&sprd_serial_device2,(const void*)&plat_data2,sizeof(plat_data2)); platform_device_add_data(&sprd_serial_device3,(const void*)&plat_data3,sizeof(plat_data3)); platform_device_add_data(&sprd_keypad_device,(const void*)&sci_keypad_data,sizeof(sci_keypad_data)); platform_device_add_data(&sprd_audio_i2s0_device,(const void*)&i2s0_config,sizeof(i2s0_config)); platform_device_add_data(&sprd_audio_i2s1_device,(const void*)&i2s1_config,sizeof(i2s1_config)); platform_device_add_data(&sprd_audio_i2s2_device,(const void*)&i2s2_config,sizeof(i2s2_config)); platform_device_add_data(&sprd_audio_i2s3_device,(const void*)&i2s3_config,sizeof(i2s3_config)); #if(defined(CONFIG_BACKLIGHT_SPRD_PWM)||defined(CONFIG_BACKLIGHT_SPRD_PWM_MODULE)) platform_device_add_data(&sprd_pwm_bl_device, (const void*)&sprd_pwm_bl_platform_data, sizeof(sprd_pwm_bl_platform_data)); #endif #if(defined(CONFIG_INPUT_HEADSET_SPRD_SC2723)||defined(CONFIG_INPUT_HEADSET_SPRD_SC2723_MODULE)) platform_device_add_data(&headset_sprd_sc2723_device, (const void*)&headset_sprd_sc2723_pdata, sizeof(headset_sprd_sc2723_pdata)); #endif #if(defined(CONFIG_SPRD_KPLED_2723) || defined(CONFIG_SPRD_KPLED_2723_MODULE)) platform_device_add_data(&sprd_kpled_2723_device, (const void*)&sprd_kpled_2723_pdata, sizeof(sprd_kpled_2723_pdata)); #endif platform_add_devices(devices, ARRAY_SIZE(devices)); sc8810_add_i2c_devices(); sc8810_add_misc_devices(); sprd_spi_init(); #else of_platform_populate(NULL, of_sprd_default_bus_match_table, of_sprd_default_bus_lookup, NULL); #endif //sprd_sr2351_vddwpa_ctrl_power_register(); }
static int __init setup_p2msu_wdt(void) { int retval = 0; struct resource res; u32 period=0, ticks=0; struct platform_device *pdev=NULL; struct p2msu_wdt_platform_data *pdata = NULL; struct device_node *np=NULL; const void *prop=NULL; /* */ pr_info("[%s] **** setup from device tree\n",name); /* get node */ np=of_find_compatible_node(NULL, "watchdog", "p2pf,p2msu-wdt"); if(!np){ pr_err("A node for \"p2pf,msudev-fpga-wdt\" is NOT found.\n"); return 0; } /* Watchdog timeout in ticks */ prop = of_get_property(np, "ticks", NULL); if(prop){ ticks = *(u32*)prop; pr_info("[%s] ticks=%d\n", name, ticks); } /* Period in ticks [msec] */ prop = of_get_property(np, "period", NULL); if(!prop){ retval = -ENOENT; pr_err("[%s] property \"period\" is NOT found.\n",np->full_name); goto err; } period = *(u32*)prop; pr_info("[%s] period=%d\n", name, period); /* get address map for control register */ memset(&res,0,sizeof(struct resource)); retval = of_address_to_resource(np, 0, &res); if(retval){ pr_err("[%s] failed to get address map\n",np->full_name); goto err; } pr_info("[%s] resource reg = [ 0x%08x - 0x%08x ]\n", name, res.start,res.end); /* allocte platform data */ pdata = (struct p2msu_wdt_platform_data *)kzalloc(sizeof(struct p2msu_wdt_platform_data),GFP_KERNEL); if(!pdata){ retval = -ENOMEM; pr_err("no memory for platform data\n"); goto err; } /* setting platform data */ pdata->ticks = ticks; pdata->period = period; /* allocte private_device */ pdev = platform_device_alloc(name, 0); if (!pdev){ pr_err("can't allocate for platform device\n"); retval=-ENOMEM; goto err; } /* add resources to platform device */ retval = platform_device_add_resources(pdev, &res, 1); if(retval){ pr_err("failed to add resources to platform device\n"); platform_device_del(pdev); goto err; } /* add platform data to platform device */ retval = platform_device_add_data(pdev, pdata, sizeof(struct p2msu_wdt_platform_data)); if (retval){ pr_err("failed to add platform data to platform device\n"); platform_device_del(pdev); goto err; } /* regiter platform device */ retval = platform_device_add(pdev); if (retval){ pr_err("failed to register platform device\n"); platform_device_del(pdev); goto err; } err: if(pdata) kfree(pdata); /* complete */ return retval; }
static int __init m80701_board_init(void) { /* dma */ #ifdef CONFIG_XBURST_DMAC platform_device_register(&jz_pdma_device); #endif /* i2c */ #ifdef CONFIG_I2C0_JZ4780 platform_device_register(&jz_i2c0_device); #endif #ifdef CONFIG_I2C1_JZ4780 platform_device_register(&jz_i2c1_device); #endif #ifdef CONFIG_I2C2_JZ4780 platform_device_register(&jz_i2c2_device); #endif #ifdef CONFIG_I2C3_JZ4780 platform_device_register(&jz_i2c3_device); #endif #ifdef CONFIG_I2C4_JZ4780 platform_device_register(&jz_i2c4_device); #endif /* ipu */ #ifdef CONFIG_JZ4780_IPU platform_device_register(&jz_ipu0_device); #endif #ifdef CONFIG_JZ4780_IPU platform_device_register(&jz_ipu1_device); #endif /* mmc */ #ifdef CONFIG_MMC2_JZ4780 jz_device_register(&jz_msc2_device, &m80701_tf_pdata); #endif #ifdef CONFIG_MMC1_JZ4780 jz_device_register(&jz_msc1_device, &m80701_sdio_pdata); #endif #ifdef CONFIG_MMC0_JZ4780 jz_device_register(&jz_msc0_device, &m80701_inand_pdata); #endif /* sound */ #ifdef CONFIG_SOUND_I2S_JZ47XX jz_device_register(&jz_i2s_device,&i2s_data); jz_device_register(&jz_mixer0_device,&snd_mixer0_data); #endif #ifdef CONFIG_SOUND_PCM_JZ47XX jz_device_register(&jz_pcm_device,&pcm_data); jz_device_register(&jz_mixer1_device,&snd_mixer1_data); #endif #ifdef CONFIG_JZ4780_INTERNAL_CODEC jz_device_register(&jz_codec_device, &codec_data); #endif /* GPU */ #ifdef CONFIG_PVR_SGX platform_device_register(&jz_gpu); #endif /* panel and bl */ #ifdef CONFIG_LCD_KR070LA0S_270 platform_device_register(&kr070la0s_270_device); #endif #ifdef CONFIG_LCD_EK070TN93 platform_device_register(&ek070tn93_device); #endif #ifdef CONFIG_LCD_HSD070IDW1 platform_device_register(&hsd070idw1_device); #endif #ifdef CONFIG_BACKLIGHT_PWM platform_device_register(&m80701_backlight_device); #endif /* lcdc framebuffer*/ #ifdef CONFIG_FB_JZ4780_LCDC1 jz_device_register(&jz_fb1_device, &jzfb1_pdata); #endif #ifdef CONFIG_FB_JZ4780_LCDC0 jz_device_register(&jz_fb0_device, &jzfb0_hdmi_pdata); #endif /* AOSD */ #ifdef CONFIG_JZ4780_AOSD platform_device_register(&jz_aosd_device); #endif /* ADC*/ #ifdef CONFIG_BATTERY_JZ4780 adc_platform_data.battery_info = m80701_battery_info; jz_device_register(&jz_adc_device,&adc_platform_data); #endif /* uart */ #ifdef CONFIG_SERIAL_JZ47XX_UART0 platform_device_register(&jz_uart0_device); #endif #ifdef CONFIG_SERIAL_JZ47XX_UART1 platform_device_register(&jz_uart1_device); #endif #ifdef CONFIG_SERIAL_JZ47XX_UART2 platform_device_register(&jz_uart2_device); #endif #ifdef CONFIG_SERIAL_JZ47XX_UART3 platform_device_register(&jz_uart3_device); #endif #ifdef CONFIG_SERIAL_JZ47XX_UART4 platform_device_register(&jz_uart4_device); #endif /* camera */ #ifdef CONFIG_JZ_CIM platform_device_register(&jz_cim_device); #endif /* x2d */ #ifdef CONFIG_JZ_X2D platform_device_register(&jz_x2d_device); #endif /* USB */ #ifdef CONFIG_USB_OHCI_HCD platform_device_register(&jz_ohci_device); #endif #ifdef CONFIG_USB_EHCI_HCD platform_device_register(&jz_ehci_device); #endif /* net */ #ifdef CONFIG_JZ_MAC platform_device_register(&jz_mac); #endif /* nand */ #ifdef CONFIG_NAND_DRIVER jz_device_register(&jz_nand_device, NULL); #endif /* hdmi */ #ifdef CONFIG_HDMI_JZ4780 platform_device_register(&jz_hdmi); #endif /* rtc */ #ifdef CONFIG_RTC_DRV_JZ4780 platform_device_register(&jz_rtc_device); #endif /* timed_gpio */ platform_device_register(&jz_timed_gpio_device); /* gpio keyboard */ #ifdef CONFIG_KEYBOARD_GPIO platform_device_register(&jz_button_device); #endif /* tcsm */ #ifdef CONFIG_JZ_VPU platform_device_register(&jz_vpu_device); #endif /* spi */ #ifdef CONFIG_SPI_JZ4780 #ifdef CONFIG_SPI0_JZ4780 spi_register_board_info(jz_spi0_board_info, ARRAY_SIZE(jz_spi0_board_info)); platform_device_register(&jz_ssi0_device); platform_device_add_data(&jz_ssi0_device, &spi0_info_cfg, sizeof(struct jz47xx_spi_info)); #endif #ifdef CONFIG_SPI1_JZ4780 spi_register_board_info(jz_spi1_board_info, ARRAY_SIZE(jz_spi1_board_info)); platform_device_register(&jz_ssi1_device); platform_device_add_data(&jz_ssi1_device, &spi1_info_cfg, sizeof(struct jz47xx_spi_info)); #endif #endif #ifdef CONFIG_SPI_GPIO spi_register_board_info(jz_spi0_board_info, ARRAY_SIZE(jz_spi0_board_info)); platform_device_register(&jz4780_spi_gpio_device); #endif return 0; }
struct platform_device *msm_fb_device_alloc(struct msm_fb_panel_data *pdata, u32 type, u32 id) { struct platform_device *this_dev = NULL; char dev_name[16]; switch (type) { case EBI2_PANEL: snprintf(dev_name, sizeof(dev_name), "ebi2_lcd"); break; case MDDI_PANEL: snprintf(dev_name, sizeof(dev_name), "mddi"); break; case EXT_MDDI_PANEL: snprintf(dev_name, sizeof(dev_name), "mddi_ext"); break; case TV_PANEL: snprintf(dev_name, sizeof(dev_name), "tvenc"); break; case HDMI_PANEL: case LCDC_PANEL: snprintf(dev_name, sizeof(dev_name), "lcdc"); break; case LVDS_PANEL: snprintf(dev_name, sizeof(dev_name), "lvds"); break; case DTV_PANEL: snprintf(dev_name, sizeof(dev_name), "dtv"); break; case MIPI_VIDEO_PANEL: case MIPI_CMD_PANEL: snprintf(dev_name, sizeof(dev_name), "mipi_dsi"); break; case WRITEBACK_PANEL: snprintf(dev_name, sizeof(dev_name), "writeback"); break; default: return NULL; } if (pdata != NULL) pdata->next = NULL; else return NULL; this_dev = platform_device_alloc(dev_name, ((u32) type << 16) | (u32) id); if (this_dev) { if (platform_device_add_data (this_dev, pdata, sizeof(struct msm_fb_panel_data))) { printk ("msm_fb_device_alloc: platform_device_add_data failed!\n"); platform_device_put(this_dev); return NULL; } } return this_dev; }
/** * omap_device_build_ss - build and register an omap_device with multiple hwmods * @pdev_name: name of the platform_device driver to use * @pdev_id: this platform_device's connection ID * @oh: ptr to the single omap_hwmod that backs this omap_device * @pdata: platform_data ptr to associate with the platform_device * @pdata_len: amount of memory pointed to by @pdata * @pm_lats: pointer to a omap_device_pm_latency array for this device * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats * @is_early_device: should the device be registered as an early device or not * * Convenience function for building and registering an omap_device * subsystem record. Subsystem records consist of multiple * omap_hwmods. This function in turn builds and registers a * platform_device record. Returns an ERR_PTR() on error, or passes * along the return value of omap_device_register(). */ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id, struct omap_hwmod **ohs, int oh_cnt, void *pdata, int pdata_len, struct omap_device_pm_latency *pm_lats, int pm_lats_cnt, int is_early_device) { int ret = -ENOMEM; struct omap_device *od; char *pdev_name2; struct resource *res = NULL; int i, res_count; struct omap_hwmod **hwmods; if (!ohs || oh_cnt == 0 || !pdev_name) return ERR_PTR(-EINVAL); if (!pdata && pdata_len > 0) return ERR_PTR(-EINVAL); pr_debug("omap_device: %s: building with %d hwmods\n", pdev_name, oh_cnt); od = kzalloc(sizeof(struct omap_device), GFP_KERNEL); if (!od) return ERR_PTR(-ENOMEM); od->hwmods_cnt = oh_cnt; hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL); if (!hwmods) goto odbs_exit1; memcpy(hwmods, ohs, sizeof(struct omap_hwmod *) * oh_cnt); od->hwmods = hwmods; pdev_name2 = kzalloc(strlen(pdev_name) + 1, GFP_KERNEL); if (!pdev_name2) goto odbs_exit2; strcpy(pdev_name2, pdev_name); od->pdev.name = pdev_name2; od->pdev.id = pdev_id; res_count = omap_device_count_resources(od); if (res_count > 0) { res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL); if (!res) goto odbs_exit3; } omap_device_fill_resources(od, res); od->pdev.num_resources = res_count; od->pdev.resource = res; ret = platform_device_add_data(&od->pdev, pdata, pdata_len); if (ret) goto odbs_exit4; od->pm_lats = pm_lats; od->pm_lats_cnt = pm_lats_cnt; if (is_early_device) ret = omap_early_device_register(od); else ret = omap_device_register(od); for (i = 0; i < oh_cnt; i++) { hwmods[i]->od = od; _add_optional_clock_alias(od, hwmods[i]); if (hwmods[i]->vdd_name) { struct omap_hwmod *oh = hwmods[i]; struct voltagedomain *voltdm; if (is_early_device) continue; voltdm = omap_voltage_domain_lookup(oh->vdd_name); if (!omap_voltage_add_dev(voltdm, &od->pdev.dev)) oh->voltdm = voltdm; } } if (ret) goto odbs_exit4; return od; odbs_exit4: kfree(res); odbs_exit3: kfree(pdev_name2); odbs_exit2: kfree(hwmods); odbs_exit1: kfree(od); pr_err("omap_device: %s: build failed (%d)\n", pdev_name, ret); return ERR_PTR(ret); }
static int __devinit mipi_r63306_lcd_probe(struct platform_device *pdev) { int ret; struct lcd_panel_platform_data *platform_data; struct mipi_dsi_data *dsi_data; #ifdef CONFIG_FB_MSM_PANEL_ECO_MODE struct platform_device *fb_pdev; #endif platform_data = pdev->dev.platform_data; if (platform_data == NULL) return -EINVAL; dsi_data = kzalloc(sizeof(struct mipi_dsi_data), GFP_KERNEL); if (dsi_data == NULL) return -ENOMEM; dsi_data->panel_data.on = mipi_r63306_lcd_on; dsi_data->panel_data.off = mipi_r63306_lcd_off; dsi_data->default_panels = platform_data->default_panels; dsi_data->panels = platform_data->panels; dsi_data->lcd_power = platform_data->lcd_power; dsi_data->lcd_reset = platform_data->lcd_reset; if (mipi_dsi_need_detect_panel(dsi_data->panels)) { dsi_data->panel_data.panel_detect = mipi_dsi_detect_panel; dsi_data->panel_data.update_panel = mipi_dsi_update_panel; dsi_data->panel_detecting = true; } else { dev_info(&pdev->dev, "no need to detect panel\n"); } ret = mipi_dsi_buf_alloc(&dsi_data->tx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(tx) failed!\n"); goto error1; } ret = mipi_dsi_buf_alloc(&dsi_data->rx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(rx) failed!\n"); goto error2; } platform_set_drvdata(pdev, dsi_data); mipi_dsi_set_default_panel(dsi_data); ret = platform_device_add_data(pdev, &dsi_data->panel_data, sizeof(dsi_data->panel_data)); if (ret) { dev_err(&pdev->dev, "platform_device_add_data failed!\n"); goto error3; } #ifdef CONFIG_FB_MSM_PANEL_ECO_MODE fb_pdev = msm_fb_add_device(pdev); eco_mode_sysfs_register(&fb_pdev->dev); #else msm_fb_add_device(pdev); #endif #ifdef CONFIG_DEBUG_FS mipi_dsi_debugfs_init(pdev, "mipi_r63306"); #endif return 0; error3: mipi_dsi_buf_release(&dsi_data->rx_buf); error2: mipi_dsi_buf_release(&dsi_data->tx_buf); error1: kfree(dsi_data); return ret; }
static int mipi_dsi_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct fb_info *fbi; struct msm_panel_info *pinfo; struct mipi_panel_info *mipi; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc; uint8 lanes = 0, bpp; uint32 h_period, v_period, dsi_pclk_rate; resource_size_t size ; if ((pdev->id == 1) && (pdev->num_resources >= 0)) { mipi_dsi_pdata = pdev->dev.platform_data; size = resource_size(&pdev->resource[0]); mipi_dsi_base = ioremap(pdev->resource[0].start, size); MSM_FB_INFO("mipi_dsi base phy_addr = 0x%x virt = 0x%x\n", pdev->resource[0].start, (int) mipi_dsi_base); if (!mipi_dsi_base) return -ENOMEM; if (mdp_rev >= MDP_REV_41) { mmss_sfpb_base = ioremap(MMSS_SFPB_BASE_PHY, 0x100); MSM_FB_INFO("mmss_sfpb base phy_addr = 0x%x," "virt = 0x%x\n", MMSS_SFPB_BASE_PHY, (int) mmss_sfpb_base); if (!mmss_sfpb_base) return -ENOMEM; } dsi_irq = platform_get_irq(pdev, 0); if (dsi_irq < 0) { pr_err("mipi_dsi: can not get mdp irq\n"); return -ENOMEM; } rc = request_irq(dsi_irq, mipi_dsi_isr, IRQF_DISABLED, "MIPI_DSI", 0); if (rc) { pr_err("mipi_dsi_host request_irq() failed!\n"); return rc; } disable_irq(dsi_irq); if (mdp_rev == MDP_REV_42 && mipi_dsi_pdata && mipi_dsi_pdata->target_type == 1) { /* Target type is 1 for device with (De)serializer * 0x4f00000 is the base for TV Encoder. * Unused Offset 0x1000 is used for * (de)serializer on emulation platform */ periph_base = ioremap(MMSS_SERDES_BASE_PHY, 0x100); if (periph_base) { pr_debug("periph_base %p\n", periph_base); writel(0x4, periph_base + 0x28); writel(0xc, periph_base + 0x28); } else { pr_err("periph_base is NULL\n"); free_irq(dsi_irq, 0); return -ENOMEM; } } if (mipi_dsi_pdata) { vsync_gpio = mipi_dsi_pdata->vsync_gpio; pr_debug("%s: vsync_gpio=%d\n", __func__, vsync_gpio); if (mdp_rev == MDP_REV_303 && mipi_dsi_pdata->dsi_client_reset) { if (mipi_dsi_pdata->dsi_client_reset()) pr_err("%s: DSI Client Reset failed!\n", __func__); else pr_debug("%s: DSI Client Reset success\n", __func__); } } mipi_dsi_resource_initialized = 1; return 0; } mipi_dsi_clk_init(pdev); if (!mipi_dsi_resource_initialized) return -EPERM; mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; /* * link to the latest pdev */ mfd->pdev = mdp_dev; /* * alloc panel device data */ if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { pr_err("mipi_dsi_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } /* * data chain */ pdata = mdp_dev->dev.platform_data; pdata->on = mipi_dsi_on; pdata->off = mipi_dsi_off; pdata->next = pdev; /* * get/set panel specific fb info */ mfd->panel_info = pdata->panel_info; pinfo = &mfd->panel_info; if (mfd->panel_info.type == MIPI_VIDEO_PANEL) mfd->dest = DISPLAY_LCDC; else mfd->dest = DISPLAY_LCD; if (mdp_rev == MDP_REV_303 && mipi_dsi_pdata->get_lane_config) { if (mipi_dsi_pdata->get_lane_config() != 2) { pr_info("Changing to DSI Single Mode Configuration\n"); #ifdef CONFIG_FB_MSM_MDP303 update_lane_config(pinfo); #endif } } if (mfd->index == 0) mfd->fb_imgType = MSMFB_DEFAULT_TYPE; else mfd->fb_imgType = MDP_RGB_565; fbi = mfd->fbi; fbi->var.pixclock = mfd->panel_info.clk_rate; fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch; fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch; fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch; fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch; fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width; fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width; h_period = ((mfd->panel_info.lcdc.h_pulse_width) + (mfd->panel_info.lcdc.h_back_porch) + (mfd->panel_info.xres) + (mfd->panel_info.lcdc.h_front_porch)); v_period = ((mfd->panel_info.lcdc.v_pulse_width) + (mfd->panel_info.lcdc.v_back_porch) + (mfd->panel_info.yres) + (mfd->panel_info.lcdc.v_front_porch)); mipi = &mfd->panel_info.mipi; if (mipi->data_lane3) lanes += 1; if (mipi->data_lane2) lanes += 1; if (mipi->data_lane1) lanes += 1; if (mipi->data_lane0) lanes += 1; if ((mipi->dst_format == DSI_CMD_DST_FORMAT_RGB888) || (mipi->dst_format == DSI_VIDEO_DST_FORMAT_RGB888) || (mipi->dst_format == DSI_VIDEO_DST_FORMAT_RGB666_LOOSE)) bpp = 3; else if ((mipi->dst_format == DSI_CMD_DST_FORMAT_RGB565) || (mipi->dst_format == DSI_VIDEO_DST_FORMAT_RGB565)) bpp = 2; else bpp = 3; /* Default format set to RGB888 */ if (mfd->panel_info.type == MIPI_VIDEO_PANEL && !mfd->panel_info.clk_rate) { h_period += mfd->panel_info.mipi.xres_pad; v_period += mfd->panel_info.mipi.yres_pad; if (lanes > 0) { mfd->panel_info.clk_rate = ((h_period * v_period * (mipi->frame_rate) * bpp * 8) / lanes); } else { pr_err("%s: forcing mipi_dsi lanes to 1\n", __func__); mfd->panel_info.clk_rate = (h_period * v_period * (mipi->frame_rate) * bpp * 8); } } pll_divider_config.clk_rate = mfd->panel_info.clk_rate; rc = mipi_dsi_clk_div_config(bpp, lanes, &dsi_pclk_rate); if (rc) goto mipi_dsi_probe_err; if ((dsi_pclk_rate < 3300000) || (dsi_pclk_rate > 103300000)) dsi_pclk_rate = 35000000; mipi->dsi_pclk_rate = dsi_pclk_rate; /* * set driver data */ platform_set_drvdata(mdp_dev, mfd); /* * register in mdp driver */ rc = platform_device_add(mdp_dev); if (rc) goto mipi_dsi_probe_err; pdev_list[pdev_list_cnt++] = pdev; #if defined(CONFIG_MIPI_SAMSUNG_ESD_REFRESH) register_mipi_dev(pdev); #endif return 0; mipi_dsi_probe_err: platform_device_put(mdp_dev); return rc; }
static int __init omap2430_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; struct omap2430_glue *glue; int ret = -ENOMEM; glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { dev_err(&pdev->dev, "failed to allocate glue context\n"); goto err0; } musb = platform_device_alloc("musb-hdrc", -1); if (!musb) { dev_err(&pdev->dev, "failed to allocate musb device\n"); goto err1; } musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &omap2430_dmamask; musb->dev.coherent_dma_mask = omap2430_dmamask; glue->dev = &pdev->dev; glue->musb = musb; pdata->platform_ops = &omap2430_ops; platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); goto err2; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); goto err2; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); goto err2; } pm_runtime_enable(&pdev->dev); return 0; err2: platform_device_put(musb); err1: kfree(glue); err0: return ret; }
static int wl1271_probe(struct spi_device *spi) { struct wl12xx_spi_glue *glue; struct wlcore_platdev_data pdev_data; struct resource res[1]; int ret = -ENOMEM; memset(&pdev_data, 0x00, sizeof(pdev_data)); pdev_data.pdata = dev_get_platdata(&spi->dev); if (!pdev_data.pdata) { dev_err(&spi->dev, "no platform data\n"); ret = -ENODEV; goto out; } pdev_data.if_ops = &spi_ops; glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { dev_err(&spi->dev, "can't allocate glue\n"); goto out; } glue->dev = &spi->dev; spi_set_drvdata(spi, glue); /* This is the only SPI value that we need to set here, the rest * comes from the board-peripherals file */ spi->bits_per_word = 32; ret = spi_setup(spi); if (ret < 0) { dev_err(glue->dev, "spi_setup failed\n"); goto out_free_glue; } glue->core = platform_device_alloc("wl12xx", PLATFORM_DEVID_AUTO); if (!glue->core) { dev_err(glue->dev, "can't allocate platform_device\n"); ret = -ENOMEM; goto out_free_glue; } glue->core->dev.parent = &spi->dev; memset(res, 0x00, sizeof(res)); res[0].start = spi->irq; res[0].flags = IORESOURCE_IRQ; res[0].name = "irq"; ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); if (ret) { dev_err(glue->dev, "can't add resources\n"); goto out_dev_put; } ret = platform_device_add_data(glue->core, &pdev_data, sizeof(pdev_data)); if (ret) { dev_err(glue->dev, "can't add platform data\n"); goto out_dev_put; } ret = platform_device_add(glue->core); if (ret) { dev_err(glue->dev, "can't register platform device\n"); goto out_dev_put; } return 0; out_dev_put: platform_device_put(glue->core); out_free_glue: kfree(glue); out: return ret; }
static int dtv_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct fb_info *fbi; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc; if (pdev->id == 0) { dtv_pdata = pdev->dev.platform_data; #ifdef CONFIG_MSM_BUS_SCALING if (!dtv_bus_scale_handle && dtv_pdata && dtv_pdata->bus_scale_table) { dtv_bus_scale_handle = msm_bus_scale_register_client( dtv_pdata->bus_scale_table); if (!dtv_bus_scale_handle) { pr_err("%s not able to get bus scale\n", __func__); } } #else ebi1_clk = clk_get(&pdev->dev, "mem_clk"); if (IS_ERR(ebi1_clk)) { ebi1_clk = NULL; pr_warning("%s: Couldn't get ebi1 clock\n", __func__); } #endif tv_src_clk = clk_get(&pdev->dev, "src_clk"); if (IS_ERR(tv_src_clk)) { pr_err("error: can't get tv_src_clk!\n"); return IS_ERR(tv_src_clk); } hdmi_clk = clk_get(&pdev->dev, "hdmi_clk"); if (IS_ERR(hdmi_clk)) { pr_err("error: can't get hdmi_clk!\n"); return IS_ERR(hdmi_clk); } mdp_tv_clk = clk_get(&pdev->dev, "mdp_clk"); if (IS_ERR(mdp_tv_clk)) mdp_tv_clk = NULL; return 0; } dtv_work_queue = create_singlethread_workqueue("dtv_work"); INIT_WORK(&dtv_off_work, dtv_off_work_func); mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; /* * link to the latest pdev */ mfd->pdev = mdp_dev; mfd->dest = DISPLAY_LCDC; /* * alloc panel device data */ if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { pr_err("dtv_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } /* * data chain */ pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data; pdata->on = dtv_on; pdata->off = dtv_off; pdata->next = pdev; /* * get/set panel specific fb info */ mfd->panel_info = pdata->panel_info; if (hdmi_prim_display) mfd->fb_imgType = MSMFB_DEFAULT_TYPE; else mfd->fb_imgType = MDP_RGB_565; fbi = mfd->fbi; fbi->var.pixclock = mfd->panel_info.clk_rate; fbi->var.left_margin = mfd->panel_info.lcdc.h_back_porch; fbi->var.right_margin = mfd->panel_info.lcdc.h_front_porch; fbi->var.upper_margin = mfd->panel_info.lcdc.v_back_porch; fbi->var.lower_margin = mfd->panel_info.lcdc.v_front_porch; fbi->var.hsync_len = mfd->panel_info.lcdc.h_pulse_width; fbi->var.vsync_len = mfd->panel_info.lcdc.v_pulse_width; /* * set driver data */ platform_set_drvdata(mdp_dev, mfd); /* * register in mdp driver */ rc = platform_device_add(mdp_dev); if (rc) goto dtv_probe_err; pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); pdev_list[pdev_list_cnt++] = pdev; return 0; dtv_probe_err: #ifdef CONFIG_MSM_BUS_SCALING if (dtv_pdata && dtv_pdata->bus_scale_table && dtv_bus_scale_handle > 0) msm_bus_scale_unregister_client(dtv_bus_scale_handle); #endif platform_device_put(mdp_dev); return rc; }
static int dwc3_pci_quirks(struct pci_dev *pdev) { if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == PCI_DEVICE_ID_AMD_NL_USB) { struct dwc3_platform_data pdata; memset(&pdata, 0, sizeof(pdata)); pdata.has_lpm_erratum = true; pdata.lpm_nyet_threshold = 0xf; pdata.u2exit_lfps_quirk = true; pdata.u2ss_inp3_quirk = true; pdata.req_p1p2p3_quirk = true; pdata.del_p1p2p3_quirk = true; pdata.del_phy_power_chg_quirk = true; pdata.lfps_filter_quirk = true; pdata.rx_detect_poll_quirk = true; pdata.tx_de_emphasis_quirk = true; pdata.tx_de_emphasis = 1; /* * FIXME these quirks should be removed when AMD NL * taps out */ pdata.disable_scramble_quirk = true; pdata.dis_u3_susphy_quirk = true; pdata.dis_u2_susphy_quirk = true; return platform_device_add_data(pci_get_drvdata(pdev), &pdata, sizeof(pdata)); } if (pdev->vendor == PCI_VENDOR_ID_INTEL && pdev->device == PCI_DEVICE_ID_INTEL_BYT) { struct gpio_desc *gpio; acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev), acpi_dwc3_byt_gpios); /* * These GPIOs will turn on the USB2 PHY. Note that we have to * put the gpio descriptors again here because the phy driver * might want to grab them, too. */ gpio = gpiod_get_optional(&pdev->dev, "cs", GPIOD_OUT_LOW); if (IS_ERR(gpio)) return PTR_ERR(gpio); gpiod_set_value_cansleep(gpio, 1); gpiod_put(gpio); gpio = gpiod_get_optional(&pdev->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(gpio)) return PTR_ERR(gpio); if (gpio) { gpiod_set_value_cansleep(gpio, 1); gpiod_put(gpio); usleep_range(10000, 11000); } } if (pdev->vendor == PCI_VENDOR_ID_SYNOPSYS && (pdev->device == PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 || pdev->device == PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI || pdev->device == PCI_DEVICE_ID_SYNOPSYS_HAPSUSB31)) { struct dwc3_platform_data pdata; memset(&pdata, 0, sizeof(pdata)); pdata.usb3_lpm_capable = true; pdata.has_lpm_erratum = true; pdata.dis_enblslpm_quirk = true; return platform_device_add_data(pci_get_drvdata(pdev), &pdata, sizeof(pdata)); } return 0; }
static int __init f71805f_device_add(unsigned short address, const struct f71805f_sio_data *sio_data) { struct resource res = { .start = address, .end = address + REGION_LENGTH - 1, .flags = IORESOURCE_IO, }; int err; pdev = platform_device_alloc(DRVNAME, address); if (!pdev) { err = -ENOMEM; pr_err("Device allocation failed\n"); goto exit; } res.name = pdev->name; err = acpi_check_resource_conflict(&res); if (err) goto exit_device_put; err = platform_device_add_resources(pdev, &res, 1); if (err) { pr_err("Device resource addition failed (%d)\n", err); goto exit_device_put; } err = platform_device_add_data(pdev, sio_data, sizeof(struct f71805f_sio_data)); if (err) { pr_err("Platform data allocation failed\n"); goto exit_device_put; } err = platform_device_add(pdev); if (err) { pr_err("Device addition failed (%d)\n", err); goto exit_device_put; } return 0; exit_device_put: platform_device_put(pdev); exit: return err; } static int __init f71805f_find(int sioaddr, unsigned short *address, struct f71805f_sio_data *sio_data) { int err = -ENODEV; u16 devid; static const char * const names[] = { "F71805F/FG", "F71872F/FG or F71806F/FG", }; superio_enter(sioaddr); devid = superio_inw(sioaddr, SIO_REG_MANID); if (devid != SIO_FINTEK_ID) goto exit; devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID); switch (devid) { case SIO_F71805F_ID: sio_data->kind = f71805f; break; case SIO_F71872F_ID: sio_data->kind = f71872f; sio_data->fnsel1 = superio_inb(sioaddr, SIO_REG_FNSEL1); break; default: pr_info("Unsupported Fintek device, skipping\n"); goto exit; } superio_select(sioaddr, F71805F_LD_HWM); if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) { pr_warn("Device not activated, skipping\n"); goto exit; } *address = superio_inw(sioaddr, SIO_REG_ADDR); if (*address == 0) { pr_warn("Base address not set, skipping\n"); goto exit; } *address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */ err = 0; pr_info("Found %s chip at %#x, revision %u\n", names[sio_data->kind], *address, superio_inb(sioaddr, SIO_REG_DEVREV)); exit: superio_exit(sioaddr); return err; }
static int tvenc_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc; if (pdev->id == 0) { tvenc_base = ioremap(pdev->resource[0].start, pdev->resource[0].end - pdev->resource[0].start + 1); if (!tvenc_base) { pr_err("tvenc_base ioremap failed!\n"); return -ENOMEM; } tvenc_pdata = pdev->dev.platform_data; tvenc_resource_initialized = 1; return 0; } if (!tvenc_resource_initialized) return -EPERM; mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; if (tvenc_base == NULL) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; /* * link to the latest pdev */ mfd->pdev = mdp_dev; mfd->dest = DISPLAY_TV; /* * alloc panel device data */ if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { pr_err("tvenc_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } /* * data chain */ pdata = mdp_dev->dev.platform_data; pdata->on = tvenc_on; pdata->off = tvenc_off; pdata->next = pdev; /* * get/set panel specific fb info */ mfd->panel_info = pdata->panel_info; #ifdef CONFIG_FB_MSM_MDP40 mfd->fb_imgType = MDP_RGB_565; /* base layer */ #else mfd->fb_imgType = MDP_YCRYCB_H2V1; #endif #ifdef CONFIG_MSM_BUS_SCALING if (!tvenc_bus_scale_handle && tvenc_pdata && tvenc_pdata->bus_scale_table) { tvenc_bus_scale_handle = msm_bus_scale_register_client( tvenc_pdata->bus_scale_table); if (!tvenc_bus_scale_handle) { printk(KERN_ERR "%s not able to get bus scale\n", __func__); } } #else mfd->ebi1_clk = clk_get(NULL, "ebi1_tv_clk"); if (IS_ERR(mfd->ebi1_clk)) { rc = PTR_ERR(mfd->ebi1_clk); goto tvenc_probe_err; } clk_set_rate(mfd->ebi1_clk, MSM_SYSTEM_BUS_RATE); #endif /* * set driver data */ platform_set_drvdata(mdp_dev, mfd); /* * register in mdp driver */ rc = platform_device_add(mdp_dev); if (rc) goto tvenc_probe_err; pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); pdev_list[pdev_list_cnt++] = pdev; return 0; tvenc_probe_err: #ifdef CONFIG_MSM_BUS_SCALING if (tvenc_pdata && tvenc_pdata->bus_scale_table && tvenc_bus_scale_handle > 0) { msm_bus_scale_unregister_client(tvenc_bus_scale_handle); tvenc_bus_scale_handle = 0; } #endif platform_device_put(mdp_dev); return rc; }
static int mddi_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc; resource_size_t size ; u32 clk_rate; if ((pdev->id == 0) && (pdev->num_resources >= 0)) { mddi_pdata = pdev->dev.platform_data; size = resource_size(&pdev->resource[0]); msm_pmdh_base = ioremap(pdev->resource[0].start, size); MSM_FB_INFO("primary mddi base phy_addr = 0x%x virt = 0x%x\n", pdev->resource[0].start, (int) msm_pmdh_base); if (unlikely(!msm_pmdh_base)) return -ENOMEM; if (mddi_pdata && mddi_pdata->mddi_power_save) mddi_pdata->mddi_power_save(1); mddi_resource_initialized = 1; return 0; } if (!mddi_resource_initialized) return -EPERM; mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; /* * link to the latest pdev */ mfd->pdev = mdp_dev; mfd->dest = DISPLAY_LCD; /* * alloc panel device data */ if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { printk(KERN_ERR "mddi_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } /* * data chain */ pdata = mdp_dev->dev.platform_data; pdata->on = mddi_on; pdata->off = mddi_off; pdata->next = pdev; /* * get/set panel specific fb info */ mfd->panel_info = pdata->panel_info; if (mfd->index == 0) mfd->fb_imgType = MSMFB_DEFAULT_TYPE; else mfd->fb_imgType = MDP_RGB_565; clk_rate = mfd->panel_info.clk_max; if (mddi_pdata && mddi_pdata->mddi_sel_clk && mddi_pdata->mddi_sel_clk(&clk_rate)) printk(KERN_ERR "%s: can't select mddi io clk targate rate = %d\n", __func__, clk_rate); if (clk_set_max_rate(mddi_clk, clk_rate) < 0) printk(KERN_ERR "%s: clk_set_max_rate failed\n", __func__); mfd->panel_info.clk_rate = mfd->panel_info.clk_min; /* * set driver data */ platform_set_drvdata(mdp_dev, mfd); /* * register in mdp driver */ rc = platform_device_add(mdp_dev); if (rc) goto mddi_probe_err; pdev_list[pdev_list_cnt++] = pdev; #ifdef CONFIG_HAS_EARLYSUSPEND mfd->mddi_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; mfd->mddi_early_suspend.suspend = mddi_early_suspend; mfd->mddi_early_suspend.resume = mddi_early_resume; register_early_suspend(&mfd->mddi_early_suspend); #endif return 0; mddi_probe_err: platform_device_put(mdp_dev); return rc; }
static int __devinit pcf50633_probe(struct i2c_client *client, const struct i2c_device_id *ids) { struct pcf50633 *pcf; struct pcf50633_platform_data *pdata = client->dev.platform_data; int i, ret; int version, variant; if (!client->irq) { dev_err(&client->dev, "Missing IRQ\n"); return -ENOENT; } pcf = kzalloc(sizeof(*pcf), GFP_KERNEL); if (!pcf) return -ENOMEM; pcf->pdata = pdata; mutex_init(&pcf->lock); i2c_set_clientdata(client, pcf); pcf->dev = &client->dev; pcf->i2c_client = client; pcf->irq = client->irq; pcf->work_queue = create_singlethread_workqueue("pcf50633"); if (!pcf->work_queue) { dev_err(&client->dev, "Failed to alloc workqueue\n"); ret = -ENOMEM; goto err_free; } INIT_WORK(&pcf->irq_work, pcf50633_irq_worker); version = pcf50633_reg_read(pcf, 0); variant = pcf50633_reg_read(pcf, 1); if (version < 0 || variant < 0) { dev_err(pcf->dev, "Unable to probe pcf50633\n"); ret = -ENODEV; goto err_destroy_workqueue; } dev_info(pcf->dev, "Probed device version %d variant %d\n", version, variant); /* Enable all interrupts except RTC SECOND */ pcf->mask_regs[0] = 0x80; pcf50633_reg_write(pcf, PCF50633_REG_INT1M, pcf->mask_regs[0]); pcf50633_reg_write(pcf, PCF50633_REG_INT2M, 0x00); pcf50633_reg_write(pcf, PCF50633_REG_INT3M, 0x00); pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00); pcf50633_reg_write(pcf, PCF50633_REG_INT5M, 0x00); ret = request_irq(client->irq, pcf50633_irq, IRQF_TRIGGER_LOW, "pcf50633", pcf); if (ret) { dev_err(pcf->dev, "Failed to request IRQ %d\n", ret); goto err_destroy_workqueue; } /* Create sub devices */ pcf50633_client_dev_register(pcf, "pcf50633-input", &pcf->input_pdev); pcf50633_client_dev_register(pcf, "pcf50633-rtc", &pcf->rtc_pdev); pcf50633_client_dev_register(pcf, "pcf50633-mbc", &pcf->mbc_pdev); pcf50633_client_dev_register(pcf, "pcf50633-adc", &pcf->adc_pdev); for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { struct platform_device *pdev; pdev = platform_device_alloc("pcf50633-regltr", i); if (!pdev) { dev_err(pcf->dev, "Cannot create regulator %d\n", i); continue; } pdev->dev.parent = pcf->dev; platform_device_add_data(pdev, &pdata->reg_init_data[i], sizeof(pdata->reg_init_data[i])); pcf->regulator_pdev[i] = pdev; platform_device_add(pdev); } if (enable_irq_wake(client->irq) < 0) dev_err(pcf->dev, "IRQ %u cannot be enabled as wake-up source" "in this hardware revision", client->irq); ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group); if (ret) dev_err(pcf->dev, "error creating sysfs entries\n"); if (pdata->probe_done) pdata->probe_done(pcf); return 0; err_destroy_workqueue: destroy_workqueue(pcf->work_queue); err_free: i2c_set_clientdata(client, NULL); kfree(pcf); return ret; }